akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

const int N = 1 << 21;
LL dp[22][N];
int a[21][21];
int main() {
	int n;
	scanf("%d", &n);
	REP(i, n)REP(j, n)scanf("%d", &a[i][j]);
	dp[0][0] = 1;
	REP(i, n) {
		REP(k, 1 << n) {
			if (!dp[i][k])continue;
			REP(j, n) {
				if (!a[i][j])continue;
				if (k & (1 << j))continue;
				dp[i + 1][k | (1 << j)] = (dp[i + 1][k | (1 << j)] + dp[i][k]) % MOD;
			}
		}
	}
	cout << dp[n][(1 << n) - 1] << endl;
	return 0;
}

Measured memory_bytes: 309504
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
X, L = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))

# 右端が左にあるものからとる
X = np.array(X, dtype=int)
L = np.array(L, dtype=int)

R = X + L
L = X - L
I = R.argsort()
R = R[I].tolist()
L = L[I].tolist()

ans = 0
m = -INF
for l, r in zip(L, R):
    if m <= l:
        m = r
        ans += 1
print(ans)


Measured memory_bytes: 74884
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int N;
	string S, T;
	cin >> N >> S >> T;
	for (int i = 0; i < N; i++) {
		cout << S[i] << T[i];
	}
	cout << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll r,D,x;
  cin>>r>>D>>x;
  for(ll i=0;i<10;i++) {
x=r*x-D;
    cout<<x<<endl;
  }
}
              
              
              
              
                  
              
              
              
              
  
  

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h;
  while(cin>>h,h){
    int a[10][5],ans=0;
    for(int i=0;i<h;i++)
      for(int j=0;j<5;j++)cin>>a[i][j];
    bool f=1;
    while(f){
      f=0;
      for(int i=0;i<h;i++){
	int c=1,p=0;
	for(int j=1;j<5;j++)
	  if(a[i][p]==a[i][j])c++;
	  else if(c<3)c=1,p=j;
	  else break;
	if(c>=3){
	  ans+=c*a[i][p];
	  for(int k=0;k<c;k++)a[i][p+k]=0;
	}
      }
      for(int i=0;i<5;i++)
	for(int j=1;j<h;j++)
	  for(int k=j;k>0;k--)
	    if(!a[k][i]&&a[k-1][i])swap(a[k][i],a[k-1][i]),f=1;
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3072
#include <stdio.h> 
int prime(int x) { 
    int i; 
    if (x<2) return 0; 
    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 main(void){ 
        int i,n,c=0,a; 
        scanf("%d", &n); 
        for(i=0; i<n; i++) { 
            scanf("%d", &a); 
            c+=prime(a);
            
            
        } 
        printf("%d\n", c); 
        return 0; 
        
    } 






Measured memory_bytes: 2064
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


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

	public static void main (String [] args){
		//		String [][] boad = new String[4][4];
		int n = Integer.parseInt(sc.next());
		List <Integer> list = new ArrayList<Integer>();
//		int b = 0;
//		int c = 0;
		String d = null;
		if(n==23){
			d = "Christmas Eve Eve";
		}else if(n==24){
			d = "Christmas Eve";
		}else if(n==25){
			d = "Christmas";
		}else{
			d = "Christmas Eve Eve Eve";
		}
		System.out.println(d);
		System.out.flush();
		sc.close();
	}
}

Measured memory_bytes: 21712
#include<iostream>

using namespace std;

int main(){
    pair<int,int> a,b;

    cin>>a.first>>a.second>>b.first>>b.second;
    int mx=b.second-a.second;
    int my=b.first-a.first;

    cout<<b.first-mx<<" "<<b.second+my<<" ";
    cout<<a.first-mx<<" "<<a.second+my;
    cout<<endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	string s;
	cin >> s;
	
	if(s[0]==s[1]&&s[1]==s[2]){
		cout << "Yes\n";
	}else if(s[1]==s[2]&&s[2]==s[3]){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	
	
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

P cor[MAX_N];
int n;

int main()
{
	scanf("%d",&n);
	rep(i,n){
		scanf("%lld%lld",&cor[i].first,&cor[i].second);
	}
	ll ans = 0;
	rep(i,n){
		ans += cor[i].first*cor[(i+1)%n].second - cor[(i+1)%n].first*cor[i].second;
	}
	printf("%.1f\n",(double)ans/2.0);
	return 0;
}

Measured memory_bytes: 4004
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
bool cmp(const int &x,const int &y)
{
	return x>y;
}
int a[101010];
int main()
{
	int n,now=1,cnt,k;
	int ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	a[n+1]=0;
	sort(a+1,a+1+n,cmp);
	while(a[now+1]>=now+1)
		now++;
	ans|=((a[now]-now)&1);
	k=now;
	while(a[now+1]>=k)
	{
		cnt++;
		now++;
	}
	ans|=(cnt&1);
	if(ans)
		printf("First");
	else
		printf("Second");
	return 0;
}

Measured memory_bytes: 640
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    let word = line.trim();

    let mut text = String::new();
    loop {
        let mut line = String::new();
        io::stdin().read_line(&mut line).ok();
        if line.trim() == "END_OF_TEXT" { break }

        text.push_str(&line);
    }

    let out = text.to_lowercase().split_whitespace().filter(|&s| s == word).count();
    println!("{}", out);
}



Measured memory_bytes: 5044
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i,s,e) for(int i = (s);i <= (e);i++)


typedef long long i64;

int n;

vector<i64> a;


int main()
{
	cin >> n;
	a.resize(n,0);
	rep(i,0,n - 1) cin >> a[i];

	int cou = 0;
	rep(i,0,n -1) cou += a[i] % 2;

	if(cou % 2 == 0) cout << "YES";
	else cout << "NO";
	return 0;
}



Measured memory_bytes: 1024
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
d = list(map(int,stdin.readline().rstrip().split()))
m = int(stdin.readline().rstrip())
t = list(map(int,stdin.readline().rstrip().split()))
d.sort()
t.sort()
now = 0
for i in d:
    if i == t[now]:
        now += 1
    if now == m:
        print("YES")
        exit()
else:
    print("NO")

Measured memory_bytes: 35408
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    for (int i=0;i<n-2;i++)
    {
        if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
            cnt++;
    }
    cout<<cnt;




}

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

int main(){
  long long n,a,b,c,d,e;
  cin>>n>>a>>b>>c>>d>>e;
  vector<long long>v={a,b,c,d,e};
  sort(v.begin(),v.end());
  cout<<(n+v[0]-1)/v[0]+4<<endl;
}  

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<cstdlib>
using namespace std;

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  cout << (min(min(a, b), c) + min(d, e) - 50) << endl;
}

Measured memory_bytes: 3104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char * argv[]){
    char s[100] = {'\0'};
    scanf("%s",s);
    int x = 0;
    int c = 0;
    int f = 0;
    while(s[x]!= '\0'){
        if(s[x] == 'C' && f==0) c = 1;
        if(s[x] == 'F' && c==1) f = 1;
        x++;
    }
    
    if(f>0 && c>0){
        printf("Yes\n");
        }else{
        printf("No\n");
        }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 128
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int[] p = new int[N];
		for(int i = 0; i < N; i++) p[i] = in.nextInt();
		
		int index = 0;
		int count = 0;
		while(index < N - 1){
			//System.out.println(index);
			if(p[index] == index + 1){
				count++;
				index += 2;
			}else index++;
		}
		
		if(index == N-1 && p[index] == index + 1) count++;
		
		System.out.println(count);
	}
}


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

void solve(){
	ll n;
	cin>>n;
	string ans;
	while(n>0){
		ans+=(((n-1)%26)+'a');
		n=(n-1)/26;
	}
	reverse(all(ans));
	cout<<ans<<endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

int main() {
	char S[5];
	scanf("%s", S);
	if (S[0] == S[1] && S[1] == S[2]) { printf("Yes\n"); return 0; }
	if (S[1] == S[2] && S[2] == S[3]) { printf("Yes\n"); return 0; }
	printf("No\n");
}

Measured memory_bytes: 128
N=int(input())
S=input()
R=S.count("R")
G=S.count("G")
B=S.count("B")
ans=R*G*B
for i in range(N):
    for j in range(i,N):
        k=j+j-i
        if k>=N:
            continue
        if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
            ans-=1
print(ans)


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

int main(){
  ll k;cin>>k;
  
  ll ans=0;
  for(int a=1;a<=k;a++)for(int b=1;b<=k;b++)for(int c=1;c<=k;c++){
    int g=min(a,min(b,c));
    for(int i=g;i>=1;i--)if(a%i==0&&b%i==0&&c%i==0){ans+=i;break;}
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3644
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)

    if op == '?':
        break

    if op == '+':
        print(a + b)

    if op == '-':
        print(a - b)

    if op == '*':
        print(a * b)

    if op == '/':
        print(a // b)

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N, M;
string S;
vector<int> ans;


int main(){
  cin >> N >> M >> S;
  bool flag = false;
  while(N){
    flag = false;
    for(int i = M; i > 0; i--){
      if(N-i < 0 || S[N-i]== '1') continue;
      ans.push_back(i);
      N-=i;
      flag = true;
      break;
    }
    if(!flag){
      break;
    }
  }
  if(flag){
    REPR(i, ans.size()-1){
      cout << ans[i] << " ";
    }
    cout << endl;
  }
  else{
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 1144
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string s; cin >> s;
	cout << 700 + 100 * count(ALL(s), 'o') << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define VV(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int H, W;
	string s[2];
	while(true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		s[0] = s[1] = "";
		rep(i, 0, W) {
			s[0] += i % 2 ? "." : "#";
			s[1] += i % 2 ? "#" : ".";
		}
		rep(i, 0, H) P(s[i%2]);
		P("");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    for(char&c:s)
        if(c=='?')
            c='D';
    cout<<s;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, d, x, Ai, c, ans = 0, i, j;
    cin>>n>>d>>x;
    int ara[n+1];
    for(i=0;i<n;i++)
    {
        cin>>ara[i];
    }
    for(i=1;i<=n;i++)
    {
        Ai = 1, c = 1;
        for(j=0;j<10000;j++)
        {
            if((ara[i-1]*Ai+1)<=d)
            {
                c++;
            }
            else
                break;
            Ai++;
        }
//        printf("%d\n",c);
        ans+=c;
    }
    cout<<ans+x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <queue>
using namespace std;

int main(){
	int n,a[100],b[100];
	scanf("%d", &n);
	for(int i=0;i<n;++i) scanf("%d", a+i);
	memcpy(b,a,sizeof(a));
	sort(a, a+n);
	for(int i=0,x=0;i<n;++i){
		if(a[i] != b[i]){
			if(++x > 2){
				printf("NO\n");
				return 0;
			}
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];} 
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";} cout<<endl;
#define S second
#define F first
#define SZ(x) (int)x.size()
typedef long long ll;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;
const int  M = 1e9;

void solve(){
    ll n , k , s;
    cin>>n>>k>>s;
    for(int i = 0 ; i < k ; i++) cout<<s<<" ";

    for(int i = k ; i < n; i++) cout<< (s == M ? 1 : s + 1) <<" ";
    cout<<endl;
}

int main(){
    ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  int N;
  cin >> N;
  int as[N];
  for (int i = 0; i < N; i++) {
    cin >> as[i];
  }
  sort(as, as + N, greater<int>());
  ll total = 0;
  for (int i = 0; i < N - 1; i++) {
    total += as[(i + 1) / 2];
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 4416
N = int(input())
A = list(map(int, input().split()))


'''考え方
最大公約数が正解となる
'''

# 最大公約数を求める関数
def f_gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

# 1回目は普通に求める。これ以降はループさせる
m,n = A[0],A[1]
gcd = f_gcd(m,n)

# 2回目以降
if len(A) >= 3:
  for i in A[2:]:
    gcd = f_gcd(gcd,i)
else:
  pass


print(gcd)

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

int main(void) {
  long long a = 0, b = 0, c = 0, d = 0;
  long long N;
  cin >> N;
  for (int i = 0; i <N; i++) {
    string s;
    cin >> s;
    if (s == "AC") {
      a+= 1;
    }
      else  if (s == "WA") {
      b+= 1;
    }
    else if (s == "TLE") {
      c+= 1;
    }
       else if (s == "RE") {
      d+= 1;
    }
  }
  cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

void printString(vector<string>& ans){
    ll h = ans.size(), w = ans[0].size();
    cout << h << " " << w << endl;
    rep(i, h) cout << ans[i] << endl;
}

int main(){
    Init();
    ll a, b; cin >> a >> b;
    string wb = string(100, '.');
    string bw = string(100, '#');
    vector<string> ans;
    for(ll i=1; i<100; i+=2){
        wb[i] = '#';
        bw[i] = '.';
    }

    a--; b--;
    ll bh = ((ll)ceil(b/50.0));
    ll wh = ((ll)ceil(a/50.0));

    // □■□■□■...□■
    // □□□□□□...□□　で白1個に対して黒50個おける。（20行あれば500個おける。）
    rep(i, bh){
        if(i == bh-1){
            if(b%50 != 0) ans.emplace_back(wb.substr(0, (b%50)*2+1) + string(100-((b%50)*2+1), '.'));
            else ans.emplace_back(wb);
        }
        else{
            ans.emplace_back(wb);
            ans.emplace_back(string(100, '.'));
        }
    }
    // □□□□□□...□□
    // ■■■■■■...■■　を境界に置く。
    ans.emplace_back(string(100, '.'));
    ans.emplace_back(string(100, '#'));

    // ■□■□■□...■□
    // ■■■■■■...■■　で黒1個に対して白50個おける。（20行あれば500個おける。）
    rep(i, wh){
        if(i == wh-1){
            if(a%50 != 0) ans.emplace_back(bw.substr(0, (a%50)*2+1) + string(100-((a%50)*2+1), '#'));
            else ans.emplace_back(bw);
        }
        else{
            ans.emplace_back(bw);
            ans.emplace_back(string(100, '#'));
        }
    }

    printString(ans);
}

Measured memory_bytes: 3652
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}
const ll mod = 998244353;
const ll N = 3005;

vvi dp(N,vi (N,-1));
ll a,b,c,d;

ll fun(ll x,ll y)
{
	if(dp[x][y]!=-1) return dp[x][y];
	if(x==a) dp[x][y] = (fun(x,y-1)*x)%mod;
	else if(y==b) dp[x][y]=(fun(x-1,y)*y)%mod;
	else dp[x][y] = (((fun(x,y-1)*x)%mod + (fun(x-1,y)*y)%mod)%mod - (fun(x-1,y-1)*(x-1)*(y-1))%mod +mod )%mod;
	return dp[x][y];
}
		
int solve()
{
	cin>>a>>b>>c>>d;
	rep(i,0,a+1) rep(j,0,b+1) dp[i][j]=1;
	cout<<fun(c,d);
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

int main(){
  int N;
  cin >> N;
  vector<int> C(4,0);
  vector<string> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  } 
  for(int i=0; i<N; i++){
    
    if(vec.at(i)== "AC"){
          C.at(0) ++;
         }
     if(vec.at(i)== "WA"){
          C.at(1) ++;
      }
    if(vec.at(i)== "TLE"){
          C.at(2) ++;
     }
    if(vec.at(i)== "RE"){
          C.at(3) ++;
     }
  }
  cout <<"AC x "<< C.at(0) << endl; 
  cout <<"WA x "<< C.at(1) << endl; 
  cout <<"TLE x "<< C.at(2) << endl; 
  cout <<"RE x "<< C.at(3) << endl; 
}



Measured memory_bytes: 6428
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#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){
    string s;
    cin>>s;
    ll ans = 0;
    ll n = s.length();
    vector<ll>a;
    if(s[0]=='>')a.push_back((ll)0);
    for(ll i=0;i<n;){
        ll j=i;
        while(true){
            if(i==n){
                a.push_back(i-j);
                break;
            }
            if(s[j]==s[i])i++;
            else{
                a.push_back(i-j);
                break;
            }
        }
    }
    if(s[n-1]=='<')a.push_back((ll)0);
    n = a.size();
    for(int i=0;i<n;i+=2){
        ll first = a[i];
        ll second = a[i+1];
        ll Max = max(first,second);
        ll Min = min(first,second);
        ans += Max*(Max+1)/2;
        ans += Min*(Min-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	int N;
  cin >> N;
  vector<int>a(N);
  int count = 0;
  for(int i = 0 ; i < N ; i++){
  		cin >> a.at(i);
    if(i%2==0&&a.at(i)%2==1)count++;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long i,j,t,a,b,n,temp;
    t=1;
    // cin>>t;
    while(t--)
    {
       int arr[3];
       cin>>arr[0]>>arr[1]>>arr[2];
       sort(arr,arr+3);
       cout<<arr[0]+arr[1];
        
        
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble()-1;
        double b = sc.nextDouble()-1;
        int ans = (int) Math.ceil(b/a);
        System.out.println(ans);
    }

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    int ans = N*(N+1)/2;

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
  n,m=map(int,input().split())
  uf=UnionFind(n)
  now=n*(n-1)//2
  g=[]
  ans=[now]
  now=n*(n-1)//2
  for i in range(m):
    a,b=map(int,input().split())
    g.append((a-1,b-1))
  #print(g)
  g=g[::-1]
  for a,b in g:
    now-=uf.size(a)*uf.size(b)*(1-uf.same(a,b))
    ans.append(now)
    uf.union(a,b)
  ans=ans[:-1][::-1]
  print("\n".join(map(str,ans)))
  
  
  
  
  
  
  
  
  
  
  
  
  
  
if __name__ == "__main__":
	main()

Measured memory_bytes: 117340
# include<iostream>

int main()
{
	const int NumOfCup = 2;

	char exchange[NumOfCup];

	char conma, BallIn='A';

	while(std::cin >> exchange[0] >> conma >> exchange[1])
	{
		for(int i=0; i<NumOfCup; ++i)
		{
			if(BallIn == exchange[i])
			{
				BallIn = exchange[(i+1)%2];

				break;
			}
		}
	}

	std::cout << BallIn << '\n';

}

Measured memory_bytes: 1100
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

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

	string s;
	cin >> s;
	int n = (int)s.size();
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int j = n - 1 - i;
		if (i < j && s[i] != s[j]) ans++;
	}
	cout << ans << endl;

}


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

int main()
{
    int n;
    std::cin >> n;

    std::vector<std::tuple<int, int>> points(n);
    for (int i=0; i<n; ++i) {
        int x, y;
        std::cin >> x >> y;
        points[i] = std::make_tuple(x, y);
    }

    int indexes[n];
    for (int i=0; i<n; ++i) {
        indexes[i] = i;
    }

    long double distance = 0;
    int npr = 0;
    do {
        std::tuple<int, int> cp = points.at(indexes[0]);
        for (int i=1; i<n; ++i) {
            std::tuple<int, int> p = points.at(indexes[i]);

            long double dx = std::get<0>(p) - std::get<0>(cp);
            long double dy = std::get<1>(p) - std::get<1>(cp);

            distance += std::sqrt(std::pow(dx, 2) + std::pow(dy, 2));
        }
        ++npr;
    } while (std::next_permutation(indexes, indexes+n));

    std::cout << std::fixed << std::setprecision(10) << distance / npr << std::endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <typename Monoid>
struct RMQ {
  RMQ(int sz, const Monoid UNITY) : UNITY(UNITY) {
    init(sz);
    dat.assign((n << 1) - 1, UNITY);
  }

  RMQ(const std::vector<Monoid> &a, const Monoid UNITY) : UNITY(UNITY) {
    int a_sz = a.size();
    init(a_sz);
    dat.resize((n << 1) - 1);
    for (int i = 0; i < a_sz; ++i) dat[n - 1 + i] = a[i];
    for (int i = n - 2; i >= 0; --i) dat[i] = std::max(dat[(i << 1) + 1], dat[(i << 1) + 2]);
  }

  void update(int node, Monoid val) {
    node += n - 1;
    dat[node] = val;
    while (node > 0) {
      node = (node - 1) >> 1;
      dat[node] = std::max(dat[(node << 1) + 1], dat[(node << 1) + 2]);
    }
  }

  Monoid query(int a, int b) const { return query(a, b, 0, 0, n); }

  int find(int a, int b, Monoid val) const { return find(a, b, val, 0, 0, n); }

  Monoid operator[](const int idx) const { return dat[idx + n - 1]; }

private:
  int n = 1;
  const Monoid UNITY;
  std::vector<Monoid> dat;

  void init(int sz) { while (n < sz) n <<= 1; }

  Monoid query(int a, int b, int node, int left, int right) const {
    if (right <= a || b <= left) return UNITY;
    if (a <= left && right <= b) return dat[node];
    return std::max(query(a, b, (node << 1) + 1, left, (left + right) >> 1), query(a, b, (node << 1) + 2, (left + right) >> 1, right));
  }

  int find(int a, int b, Monoid val, int node, int left, int right) const {
    if (dat[node] < val || right <= a || b <= left) return -1;
    if (right - left == 1) return node - (n - 1);
    int res_l = find(a, b, val, (node << 1) + 1, left, (left + right) >> 1);
    return res_l == -1 ? find(a, b, val, (node << 1) + 2, (left + right) >> 1, right) : res_l;
    // int res_r = find(a, b, val, (node << 1) + 2, (left + right) >> 1, right);
    // return res_r == -1 ? find(a, b, val, (node << 1) + 1, left, (left + right) >> 1) : res_r;
  }
};

int main() {
  constexpr int X = 300000;
  int n, k; cin >> n >> k;
  RMQ<int> rmq(X + 1, -INF);
  while (n--) {
    int a; cin >> a;
    rmq.update(a, max(rmq.query(max(a - k, 0), min(a + k, X) + 1), 0) + 1);
  }
  cout << rmq.query(0, X) << '\n';
  return 0;
}


Measured memory_bytes: 7428
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////

int power(int bs, int exp, int mod) {
    int ans = 1;
    while(exp) {
        if(exp & 1)
            ans = (bs * ans) % mod;
        bs = (bs * bs) % mod;
        exp /= 2;
    }

    return ans;
}

int32_t main() {

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

    string st;
    cin >> st;

    int n = sz(st);

    vector<vector<int>> dp(n+1,vector<int>(13, 0));

    dp[0][0] = 1;
    rep(i,n) {
        if(st[i] != '?') {
            rep(j,13) {
                // db2(i,j);
                dp[i + 1][(j + (st[i] - '0')*power(10, n - i - 1, 13)) % 13] += dp[i][j];
                dp[i + 1][(j + (st[i] - '0')*power(10, n - i - 1, 13)) % 13] %= MOD;
            }
        }
        else {
            rep(j,13) {
                rep(k,10) {
                    // db3(i,j,k);
                    dp[i + 1][(j + k*power(10, n - i - 1, 13)) % 13] += dp[i][j];
                    dp[i + 1][(j + k*power(10, n - i - 1, 13)) % 13] %= MOD;
                }
            }
        }
    }

    cout << dp[n][5] << '\n'; 
}

Measured memory_bytes: 13648
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
using namespace std;

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

	vector<int> h(N);
	for(int i=0; i<N; i++)
		cin >> h[i];

	vector<long long> dp(N, LLONG_MAX);
	dp[0] = 0;
	for(int i=0; i<N; i++){
		for(int j=1; j<=2; j++){
			if(i+j<N)
				dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
		}
	}

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

	return 0;
}


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

int main(){
  char a;
  cin>>a;
  if(a=='A')cout<<'T'<<endl;
  if(a=='C')cout<<'G'<<endl;
  if(a=='T')cout<<'A'<<endl;
  if(a=='G')cout<<'C'<<endl;

}


Measured memory_bytes: 256
import itertools

N = int(input())
L = list(map(int, input().split()))
# L = set(L)
# print(L)
PL = []
c = 1
for l in L:
    PL.append([c, l])
    c += 1

cnt = 0
result = []
for hen in itertools.combinations(PL, 3):
    if(hen[0][1] + hen[1][1] > hen[2][1] and hen[0][1] + hen[2][1] > hen[1][1] and hen[1][1] + hen[2][1] > hen[0][1] and hen[0][1] != hen[1][1] and hen[1][1] != hen[2][1] and hen[0][1] != hen[2][1]):
        # print(hen)
        result.append(hen)
    # cnt += 1
# result = set(result)
print(len(result))
# print(result)
# print(cnt)


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

int main()
{
	double weight;
	while(cin >> weight){
		if(weight <= 48.00)
			cout << "light fly" << endl;
		else if(48.00 < weight && weight <= 51.00)
			cout << "fly" << endl;
		else if(51.00 < weight && weight <= 54.00)
			cout << "bantam" << endl;
		else if(54.00 < weight && weight <= 57.00 )
			cout << "feather" << endl;
		else if(57.00 < weight && weight <= 60.00)
			cout << "light" << endl;
		else if(60.00 < weight && weight <= 64.00)
			cout << "light welter" << endl;
		else if(64.00 < weight && weight <= 69.00 )
			cout << "welter" << endl;
		else if(69.00 < weight && weight <= 75.00)
			cout << "light middle" << endl;
		else if(75.00 < weight && weight <= 81.00)
			cout << "middle" << endl;
		else if(81.00 < weight && weight <= 91.00 )
			cout << "light heavy" << endl;
		else 
			cout << "heavy" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())  # n分間
m = int(input())  # トンネル内車両数の初期値
mmax = m  # 最大値保持用
A = []  # 出入り台数のリスト [[a1, b1],[a2, b2],,] a:入り, b:出
for i in range(n):
	A.append(list(map(int, input().split())))

# print(A)

# リストを回して、ドンネル内の車両台数を計算し、最大値を更新する
for a in A:
	m = m + a[0] - a[1]
	if m < 0:
		mmax = 0
		break
	if m > mmax:
		mmax = m

# 出力部
print(mmax)



Measured memory_bytes: 6712
from math import sqrt
from scipy.misc import comb

n, m = map(int, input().split())
mod = 10 ** 9 + 7


def sieve(x):
    primes = []
    li = list(range(2, x + 1))

    while li[0] <= sqrt(x):
        p = li[0]
        primes.append(p)
        li = [e for e in li if e % p != 0]

    primes += li
    return primes


def prime_fact(x):
    primes = sieve(int(sqrt(x)) + 1)
    d = {}

    for p in primes:
        cnt = 0
        while x % p == 0:
            x //= p
            cnt += 1

        if cnt:
            d[p] = cnt

    if x != 1:
        d[x] = 1

    return d


pf = prime_fact(m)
ans = 1
for v in pf.values():
    ans *= comb(v + n - 1, v, exact=True)
    ans %= mod

print(ans)


Measured memory_bytes: 14392
import sys
import math
import itertools as it
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass

n = i()
p = t()
q = t()
pt = 1
ck = 0
l = [i for i in range(1,n+1)]
for i in it.permutations(l):
    if p == i:
        cnt1 = pt
        ck += 1
    elif i == q:
        cnt2 = pt
        ck += 1
    pt += 1
if ck >= 2:
    print(abs(cnt1-cnt2))
else:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


char a,b;

int main(){
	cin >> a >> b;
	
	if(a == 'H' && b == 'H' || a == 'D' && b == 'D')
		cout << 'H' << endl;
	else cout << 'D' << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    auto res = 0;
    if (b > a + w || b + w < a) {
        res = max(b - a - w, a - b - w);
    }

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


Measured memory_bytes: 256
h,w=map(int,input().split())
ans=10**9
for i in range(1,w):
  ans=min(max(abs(i*h-h//2*(w-i)),abs(i*h-(h+1)//2*(w-i)),((h+1)//2-h//2)*(w-i)),ans)
for i in range(1,h):
  ans=min(max(abs(i*w-w//2*(h-i)),abs(i*w-(w+1)//2*(h-i)),((w+1)//2-w//2)*(h-i)),ans)
if h%3==0 or w%3==0:
  ans=0
else:
  ans=min(ans,h,w)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cstdio>

typedef long long int llint;

int main(void){
  double a, b, x;
  std::cin >> a >> b >> x;

  if(x > a*a*b/2){
    double tantheta = 2 * (b - x / a / a ) / a;
    double rad = std::atan(tantheta);
    double deg = rad/2/3.14159265358979323 * 360;

    std::printf("%.10f\n", deg);
  }else{
    double tantheta = b*b*a/2/x;
    double rad = std::atan(tantheta);
    double deg = rad/2/3.14159265358979323 * 360;

    std::printf("%.10f\n", deg);
  }
  


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const double pi = 2.0 * acos(0.0);

int d, a;

int main(){
	double theta = pi / 2;
	double x = 0.0, y = 0.0;
	while(1){
		scanf("%d,%d", &d, &a);
		//cout << d << " " << a << endl;
		if(d == 0.0 && a == 0.0) break;
		x += d * cos(theta); y += d * sin(theta);
		theta -= (double)a / 180.0 * pi;
		//cout << x << " " << y << endl;
	}
	cout << (int)x << endl << (int)y << endl;
	return 0;
}

Measured memory_bytes: 3500
using System;

class Program {
    static void Main( string[] args )
    {
        string[] s = Console.ReadLine().Split();
        int a = int.Parse( s[ 0 ] );
        int b = int.Parse( s[ 1 ] );
        Console.WriteLine( ( a > b ? "a > b" : ( a < b ? "a < b" : "a == b" ) ) );
    }
}

Measured memory_bytes: 8892
#include <iostream>
#include <string>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

string s;
string t;
int dp[3001][3001];
int Prev[3001][3001][2];

signed main() {
	int i, j;
	
	rep(i, 3001) rep(j, 3001) dp[i][j] = -114514;
	dp[0][0] = 0;
	
	cin >> s >> t;
	rep(i, s.length()) {
		rep(j, t.length()) {
			if (dp[i + 1][j] < dp[i][j]) {
				dp[i + 1][j] = dp[i][j];
				Prev[i + 1][j][0] = i;
				Prev[i + 1][j][1] = j;
			}
			if (dp[i][j + 1] < dp[i][j]) {
				dp[i][j + 1] = dp[i][j];
				Prev[i][j + 1][0] = i;
				Prev[i][j + 1][1] = j;
			}
			if (s[i] == t[j] && dp[i + 1][j + 1] < dp[i][j] + 1) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
				Prev[i + 1][j + 1][0] = i;
				Prev[i + 1][j + 1][1] = j;
			}
		}
	}
	
	int bestI = 0, bestJ = 0;
	rep(i, s.length() + 1) {
		rep(j, t.length() + 1) {
			if (dp[bestI][bestJ] < dp[i][j]) {
				bestI = i;
				bestJ = j;
			}
		}
	}
	
	string rev_ans;
	i = bestI;
	j = bestJ;
	while (i > 0 || j > 0) {
		int PrevI = Prev[i][j][0];
		int PrevJ = Prev[i][j][1];
		if (i - PrevI == 1 && j - PrevJ == 1) {
			rev_ans += s[PrevI];
		}
		i = PrevI;
		j = PrevJ;
	}
	
	for (i = rev_ans.length() - 1; i >= 0; i--) cout << rev_ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 105856
# Contest No.: ABC173
# Problem No.: D
# Solver:      JEMINI
# Date:        20200705

import sys
import heapq

def main():
    n = int(input())    
    nums = list(map(int, sys.stdin.readline().split()))

    nums.sort()
    ans = 0

    # initial
    temp = nums.pop()
    ans += temp
    n -= 2

    for i in range(n // 2):
        ans += nums[-i - 1] * 2

    if n % 2:
        ans += nums[-(n // 2) - 1]
    
    
    print(ans)

    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 91860
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K,X,Y;
string S,T;
vector<int> A,B;
//=============================
void input()
{
    cin>>N>>K;
    A.resize(N);
    rep(i,0,N-1){
        int k;
        cin>>k;k--;
        A[i]=k;
    }
}
//=============================
void func(){}
/*
 - 樹形図をかく
*/
vector<int> b;
//=============================
void solve()
{
    b.resize(N);
    for(auto x : A){
        b[x]++;
    }

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

    int i=0;
    int ans = 0;
    int val=0;
    //debugv(b);
    for( ; i<(N-K); ++i){
        if(b[i]==0) continue;
        ans += b[i];
        val++;
    }
    cout<<ans<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define NIL NULL

struct node{
  int d;
  struct node *p;
  struct node *r;
  struct node *l;
};
typedef struct node *NP;

NP root;

void my_insert(NP);
void my_inorder_print(NP);
void my_preorder_print(NP);
int my_find(NP,int);
NP make_node(int);

int main(){
  int i,n,input;
  char in[7];
  NP z;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",in);
    if(strcmp(in,"insert")==0){
      scanf("%d",&input);
      //INSERT
      z=make_node(input);
      my_insert(z);
    }
    if(strcmp(in,"print")==0){
      //PRINT
      my_inorder_print(root);
      printf("\n");
      my_preorder_print(root);
      printf("\n");
    }
    if(strcmp(in,"find")==0){
      scanf("%d",&input);
      //FIND
      if(my_find(root,input)==1) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

void my_insert(NP z){
  NP x,y;
  y=NIL;
  x=root;
  while(x!=NIL){
    y=x;
    if(z->d<x->d) x=x->l;
    else x=x->r;
  }
  z->p=y;

  if(y==NIL){
    root=z;
  }else if(z->d<y->d){
    y->l=z;
  }else{
    y->r=z;
  }
}

void my_inorder_print(NP p){
  if(p!=NIL){
    my_inorder_print(p->l);
    printf(" %d",p->d);
    my_inorder_print(p->r);
  }
}

void my_preorder_print(NP p){
  if(p!=NIL){
    printf(" %d",p->d);
    my_preorder_print(p->l);
    my_preorder_print(p->r);
  }
}

NP make_node(int key){
  NP p;
  p=(NP)malloc(sizeof(struct node));
  p->d=key;
  p->p=NIL;
  p->r=NIL;
  p->l=NIL;
  return p;
}

int my_find(NP x,int k){
  if(x==NIL) return 0;
  if(x->d==k) return 1;
  if(k<x->d) return my_find(x->l,k);
  else return my_find(x->r,k);
}



Measured memory_bytes: 20516
#include<stdio.h>
#include<string.h>
int main(void){
  char a[4];
  char b[4]="ABC";
  char c[4]="ARC";
  scanf("%s",a);
  if (strcmp(a,b)==0){
    printf("ARC\n");
  }
  if(strcmp(a,c)==0){
    printf("ABC\n");
  }
  return 0;
}


Measured memory_bytes: 1616