akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & (-x))


using namespace std;



int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin >> n;
    ll ans1 = 1, ans2 = 1;
    for(i = 0; i < n; i++) {
       int ch;
       cin >> ch;
       if(ch % 2 == 0) {
           ans1 *= 3;
           ans2 *= 2;
       }
       else {
           ans1 *= 3;
           ans2 *= 1;
       }
    }
    cout << (ans1 - ans2);
    //cin.close();
    //cout.close();
    return 0;
}


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

using namespace std;

const int INF = 1 << 30;

int main()
{
  int N, A[100];
  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);
  cout << A[N - 1] - A[0] << endl;
}

Measured memory_bytes: 256
// Problem : D - Friends
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 200005

//Solution

int n,m;

struct dsu{
    int p[N], size[N], c; 
    dsu(){
        for(int i=0;i<N;i++) size[i] = 1;
        c = 0;
    }
    int find(int u){
        if(!p[u]) return u;
        return p[u] = find(p[u]);
    }
    void merge(int u, int v){
        u = find(u);
        v = find(v);
        if(u != v){
            if(size[u] < size[v]) swap(u,v);
            p[v] = u;
            size[u] += size[v];
            c++;
        }
    }
} d;

void solve(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int u,v; cin>>u>>v;
        d.merge(u,v);
    }
    int ans = 0;
    for(int i=1;i<=n;i++) ans = max(ans,d.size[d.find(i)]);
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    for(int test=1;test<=tests;test++){
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 6732
a,b,c,x = map(int,[input() for i in range(4)])
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for f in range(c+1):
      if i*500 + j*100 + f*50 == x:
        ans +=1
            
print(ans)

Measured memory_bytes: 3060
// D - Disjoint Set of Common Divisors

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

ll get_gcd(ll x, ll y) {
	if (x < y) {
		swap(x, y);
	}

	ll m = x % y;

	while (m != 0) {
		x = y;
		y = m;
		m = x % y;
	}

	return y;
}

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

int main(){
	ll A, B;
	cin >> A >> B;

	int ans = 0;

	ll gcd = get_gcd(A, B);

	vector<pair<long long, long long>> primes = prime_factorize(gcd);

	ans = primes.size() + 1; // 素因数の要素の数 + 1

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n, maxwt;
	cin>>n>>maxwt;
	vector<vector<long long int> >dp(n+1, vector<long long int>(maxwt+1));
	int wt[n], val[n];
	for(int i = 0; i<n; i++)
	cin>>wt[i]>>val[i];
	for(int i = 0; i<n+1; i++){
		for(int j = 0; j<maxwt+1; j++){
			if(i == 0|| j == 0){
				dp[i][j] = 0;
				continue;
			}
			if(j-wt[i-1]>=0){
				dp[i][j] = max(dp[i-1][j], val[i-1] + dp[i-1][j-wt[i-1]]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout<<dp[n][maxwt];
	return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
void qsort(int l,int r,int a[])
{
    int mid=a[(l+r)/2];
    int i=l,j=r;
    do{
        while(a[i]<mid) i++;
        while(a[j]>mid) j--;
        if(i<=j)
        {
            swap(a[i],a[j]);
            i++;
            j--;
        }
    }while(i<=j);
    if(l<j) qsort(l,j,a);
    if(i<r) qsort(i,r,a);
}
int main(){
	int a[1001];
	for(int i=1;i<=3;++i){
		cin>>a[i];
	}
	qsort(1,3,a);
	cout<<a[3]*10+a[1]+a[2];
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		long[] a = new long[N+1];
		for(int i=0; i<N+1; i++) {
			a[i] = sc.nextLong();
		}

		long[] b = new long[N];
		for(int i=0; i<N; i++) {
			b[i] = sc.nextLong();
		}

		sc.close();

		long cnt = 0;
		//後ろから算出 N+1は勇者nしか倒せない
		for(int i=N; i>0; i--) {
			//街i+1が勇者iのキャパオーバの場合は街iは全て倒せない。
			if(a[i]>=b[i-1]) {
				cnt += b[i-1];
				a[i] -= b[i-1];
				b[i-1] = 0;
			//街i+1が勇者iが全て倒せる場合は街iは全て倒せる
			}else if(a[i]<b[i-1]) {
				cnt += a[i];
				b[i-1] -= a[i];
				a[i] = 0;
				//勇者iが街iのモンスター倒せる場合
				//街iのモンスターの方が多い場合
				if(a[i-1]>=b[i-1]) {
					cnt += b[i-1];
					a[i-1] -= b[i-1];
					b[i-1] = 0;
				//街iのモンスターの方が少ない場合
				}else if(a[i-1]<b[i-1]){
					cnt += a[i-1];
					b[i-1] -= a[i-1];
					a[i-1] = 0;
				}
			}
		}
		System.out.println(cnt);
	}
}

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

int selection_sort(std::vector<int>& ary) {
    int n = ary.size();
    int replace_counter = 0;
    for(int i = 0; i < n; i++) {
        int minj = i;
        for(int j = i; j < n; j++) {
            if (ary[minj] > ary[j]) {
                minj = j;
            }
        }
        if (i != minj) {
            std::swap(ary[i], ary[minj]);
            replace_counter++;
        }
    }
    return replace_counter;
}

int main(int argc, char const* argv[])
{
    int n = 0;
    std::cin >> n;
    std::vector<int> ary(n);
    for(auto& i: ary) {
        std::cin >> i;
    }

    int rep_c = selection_sort(ary);
    for(int i = 0; i < n-1; i++) {
        std::cout << ary[i] << " ";
    }
    std::cout << ary[n - 1] << std::endl;
    std::cout << rep_c << std::endl;

    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using ll = long long;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
int const nmax = 26;
int frec[1 + nmax];

int main() {
  std::string s;
  std::cin >> s;
  if(s == "zyxwvutsrqponmlkjihgfedcba")
    std::cout << -1;
  else if(s.size() < 26) {
    for(char ch = 'a'; ch <= 'z'; ch++) {
      int result = 0;
      for(int j = 0;j < s.size(); j++)
        result |= (s[j] == ch);
      if(result == 0) {
        std::cout << s + ch;
        return 0;
      }
    }
  } else {
    for(int i = s.size() - 1; 0 < i; i--)
      if(s[i - 1] < s[i]) {
        std::string s2;
        for(int j = 0; j < i - 1; j++)
          s2 = s2 + s[j];
        for(int j = i - 1; j < s.size(); j++)
          frec[s[j] - 'a']++;
        for(int j = s[i - 1] - 'a' + 1; j < nmax; j++) 
          if(0 < frec[j]) {
            s2 += j + 'a';
            frec[j] = 0;
            break;
          }
        std::cout << s2 << '\n';
        return 0;
      }
  }
  return 0;
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto& vv : V) os << vv << ","; os << "]";
  return os;
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

#define MAX 100100
int n,m;
map<int,vector<int>> d[MAX];
set<int> cz[MAX];
bool odw[MAX];
vector<int> d1,d2;
void add(int i){
  if(odw[i])return;
  odw[i] = 1;
  d2.PB(i);
}
void dfs(int v,int kol){
  if(cz[v].find(kol) != cz[v].end())return;
  cz[v].insert(kol);
  add(v);
  for(auto &el:d[v][kol]){
    dfs(el,kol);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> m;
  R(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    d[a][c].PB(b);
    d[b][c].PB(a);
  }
  int odl = -1;
  add(0);
  while(!d2.empty()){
    d1.clear();
    swap(d1,d2);
    odl++;
    R(i,SZ(d1)){
      int ak = d1[i];
      if(ak == n-1){
        cout << odl << "\n";
        return 0;
      }
      for(auto &el:d[ak]){
        dfs(ak,el.FI);
      }
    }
  }
  cout << "-1\n";
}


Measured memory_bytes: 72192
#include <iostream>
#include <cstdint>
#include <vector>
#include <set>
#include <cassert>

using namespace std;
typedef std::multiset<uint64_t> S;

uint64_t target(uint64_t x) {
  int b = 0;
  uint64_t temp = x;
  while(temp > 0) {
    temp = temp >> 1;
    b++;
  }
  return (1ull << (b)) - x;
}

S read() {
  uint64_t N;
  cin >> N;

  S s;
  for(uint64_t i=0; i<N; i++) {
    uint64_t x;
    cin >> x;
    s.insert(x);
  }

  return std::move(s);
}

int solve(S& s) {
  int num_pairs = 0;
  while(s.size() > 0) {
    auto last = s.end();
    last--;
    uint64_t t = target(*last);
    s.erase(last);
    auto found = s.find(t);
    if( found != s.end() ) {
      num_pairs++;
      s.erase(found);
    }
  }
  return num_pairs;
}

void test() {
  S s = {1,2,3};
  assert(solve(s)==1);

  S s2 = {3,11,14,5,13};
  assert(solve(s2)==2);

  S s3 = {1,1,3,7};
  assert(solve(s3) == 2);

  S s4 = {8,8,8,8};
  assert(solve(s4) == 2);

  S s5 = {1,9,5};
  assert(solve(s5) == 0);

  S s6 = {1,3,7,15};
  assert(solve(s6) == 1);
}

int main() {
  S s = read();
  int r = solve(s);
  cout << r << endl;

  return 0;
}



Measured memory_bytes: 9600
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
const long long LMOD=1000000007;
vector<long long>v[1000001];
long long n,m;
long long x,y;
long long f[100005];
long long f2[100005];
long long res[100005];
long long K;
long long inv[100005];
long long T[100005];
long long T2[100005];
vector<int>vt[100005];
long long wry(long long k,long long p)
{
	for(long long i=0;i<v[k].size();i++)
	{
		if(v[k][i]==p)continue;
		wry(v[k][i],k);
		vt[k].push_back(v[k][i]);
	}
	f[k]=1;
	for(long long i=0;i<vt[k].size();i++)
	{
		f[k]*=f[vt[k][i]]+1;
		f[k]%=m;
	}
	return 0;
}
long long wryy(long long k,long long p)
{
	//cout<<k<<" "<<f2[k]<<endl;
	if(vt[k].size()==0)return 0;
	T[0]=1;
	T2[vt[k].size()+1]=1;
	for(int i=0;i<vt[k].size();i++)
	{
		T[i+1]=T[i]*(f[vt[k][i]]+1);
		T[i+1]%=m;
	}
	for(int i=vt[k].size()-1;i>=0;i--)
	{
		T2[i+1]=T2[i+2]*(f[vt[k][i]]+1);
		T2[i+1]%=m;
	}
	for(long long i=0;i<vt[k].size();i++)
	{
		f2[vt[k][i]]=(T[i]*T2[i+2]%m)%m;
		f2[vt[k][i]]*=f2[k]+1;
		f2[vt[k][i]]%=m;
	}
	for(long long i=0;i<vt[k].size();i++)
	{
		wryy(vt[k][i],k);
	}
	return 0;
}
long long wryyy(long long k,long long p)
{
	for(long long i=0;i<vt[k].size();i++)
	{
		wryyy(vt[k][i],k);
	}
	res[k]=(f[k])*(f2[k]+1)%m;
	return 0;
}
vector<long long>pr;
int main()
{
	scanf("%lld%lld",&n,&m);
	long long x,y;
	for(long long i=1;i<n;i++)
	{
		scanf("%lld%lld",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	wry(1,-1);
	wryy(1,-1);
	wryyy(1,-1);
	for(long long i=1;i<=n;i++)
	{
		printf("%lld\n",res[i]);
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl

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

  string s;
  cin >> s;

  int score = 0;

  FOR(i, 0, N) {
    if (s[i] == 'R')
      score++;
    else
      score--;
  }

  if (score > 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll n, m;

ll ans = -1;

int main(void) {
  // Here your code !
  scanf("%lld %lld", &n, &m);

  for (ll i = 1; i * i <= m; ++i) {
    if (m % i != 0) continue;

    ll i_co = m / i;

    if (i_co >= n) {
      ans = max(ans, i);
    }

    if (i >= n) {
      ans = max(ans, i_co);
    }
  }

  printf("%lld\n", ans);

  return 0;
}


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

typedef long long ll;

ll n;
ll cnt;
ll res;

int main()
{
    cin >> n;
    cnt = 1;
    while (n > 0) {
        res += cnt;
        cnt *= 2;
        n /= 2;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const int MAXN = 1e3+5;
double a[MAXN];
int main() {
    int n, T, A; cin>>n>>T>>A;
    for(int i=0; i<n; i++) {
        cin>>a[i];
        a[i] = T-a[i]*0.006;
        a[i] = fabs(a[i]-A);
    }
    double mn = 100000;
    int ans = -1;
    for(int i=0; i<n; i++) {
        if(mn > a[i]) {
            mn = a[i];
            ans = i;
        }
    }
    cout<<ans+1<<endl;
    return 0;
}


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

int main(){
  int H,N;
  cin>>H>>N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin>>A.at(i);
  }
  for(int i=0; i<N; i++){
    H=H-A.at(i);
  }
  if(H<=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 
}



Measured memory_bytes: 640
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Control.DeepSeq
import Data.Array
import Data.Bits
import Data.Char
import Data.Functor.Identity
import Data.List
import Data.Maybe
import Data.Ord
import Data.Tree
import Data.Tuple
import qualified System.IO
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Sequence as Q
import qualified Data.ByteString.Char8 as B

main = do
  s <- getLine
  print $ length $ foldl' go [] s

go [] c = [c]
go ('S':s) 'T' = s
go s c = c:s



 
type Z = Int
type Q = Rational
type R = Double
type S = String

fint :: (Integral a, Num b) => a -> b
fint = fromIntegral

getInt = fst . fromJust . B.readInt <$> B.getLine
getIntPair = (\[a,b]->(a,b)) <$> getInts
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
getStr = B.unpack <$> B.getLine

yesNo :: Bool -> String
yesNo True = "Yes"
yesNo False = "No"

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . unwords . map show

readLnList :: (Read a) => IO [a]
readLnList = map read . words <$> getLine


-----  Union-find
type UnionFindT v m a = StateT (M.Map v (UnionFindVal v)) m a
newtype UnionFindVal v = UnionFindVal v

runUnionFindT :: (Monad m) => UnionFindT v m a -> m a
runUnionFindT = flip evalStateT $ M.empty

runUnionFind = runIdentity . runUnionFindT

ufFresh :: (Monad m, Ord v) => v -> UnionFindT v m ()
ufFresh v = modify $ M.insert v (UnionFindVal v)

ufClass :: (Monad m, Ord v) => v -> UnionFindT v m v
ufClass v = do
  (UnionFindVal pv) <- gets (M.! v)
  if v == pv
    then return v
    else do
      c <- ufClass pv
      modify $ M.insert v (UnionFindVal c)
      return c

ufUnify v w = do
  cv <- ufClass v
  cw <- ufClass w
  modify $ M.insert cw (UnionFindVal cv)
  return $ cv /= cw


Measured memory_bytes: 13948
def Sankakusu(N) :
    tmp  = 0
    i = 1
    while tmp < N :
        tmp = (i * (i + 1)) / 2
        i += 1
    if tmp == N :
        return True
    else :
        return False

def Step_Check(List) :
    for i in range(len(List)) : 
        if List[i] != i + 1 :
            return False
    return True
    
            

while True :
    n = int(input())
    if n == 0 :
        break
    
    count = 0
    block = list(map(int, input().split()))
    if not Sankakusu(sum(block)) :
        print(-1)
        
    else :
        while True :
            if Step_Check(block) :
                print(count)
                break
            else :
                count += 1
                len_b = len(block)
                for j in range(len_b) :
                    block[j] -= 1
                block.append(len_b)
                while 0 in block :
                    block.remove(0)
            if count == 10001 :
                print(-1)
                break


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

using namespace std;

const int M = 2000;
const int T = 5 * M;

bool match(char x, char y)
{
	return x == '?' || y == '?' || x == y;
}

int main()
{
	string a, b, c;
	cin >> a >> b >> c;

	int la = a.size();
	int lb = b.size();
	int lc = c.size();

	vector<bool> ab(2 * T, true);
	vector<bool> ac(2 * T, true);
	vector<bool> bc(2 * T, true);

	for (int i = 0; i < la; ++i) {
		for (int j = 0; j < lb; ++j) {
			if (!match(a[i], b[j])) {
				ab[T + i - j] = false;
			}
		}
	}
	for (int i = 0; i < la; ++i) {
		for (int j = 0; j < lc; ++j) {
			if (!match(a[i], c[j])) {
				ac[T + i - j] = false;
			}
		}
	}
	for (int i = 0; i < lb; ++i) {
		for (int j = 0; j < lc; ++j) {
			if (!match(b[i], c[j])) {
				bc[T + i - j] = false;
			}
		}
	}

	int ans = 3 * M;

	for (int i = -2 * M; i <= 2 * M; ++i) {
		for (int j = -2 * M; j <= 2 * M; ++j) {
			if (ab[T + i] && ac[T + j] && bc[T + j - i]) {
				int L = min({ 0, i, j });
				int R = max({ la, i + lb, j + lc });
				ans = min(ans, R - L);
			}
		}
	}
	cout << ans << endl;
}


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

int main(void){
  string s;
  cin >> s;
  int i = 0;
  int f = 0;
  for(int i = 0;i < (int)s.size();++i){
    if(f == 0 &&
       s[i] == 'C')++f;
    else if(f == 1 &&
	    s[i] == 'F')++f;
  }
  if(f == 2)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
from itertools import permutations
n=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))

a,b=0,0
A=sorted([i for i in permutations(P)])
for j,i in enumerate(A):
    i=list(i)
    if i==P:a=j+1
    if i==Q:b=j+1
print(abs(a-b))

Measured memory_bytes: 45936
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
if N == 2:
    print(A[0])
else:
    tocome = N-2
    curval = A[0]
    i = 1
    while tocome > 1:
        curval += A[i]*2
        tocome -= 2
        i += 1
    if tocome == 1:
        curval += A[i]
    print(curval)

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

int main(){
    ll x,y,z,N;
    cin >> x >> y >> z >> N;
    vector<ll> a(x),b(y),c(z);
    vector<ll> ab,ans;
    rep(i,x){cin >> a[i];}
    rep(i,y){cin >> b[i];}
    rep(i,z){cin >> c[i];}
 
    rep(i,x){
        rep(j,y){
            ab.push_back(a[i]+b[j]);
        }
    }
    sort(ab.begin(),ab.end(),greater<ll>());
    rep(i,min(N,x*y)){
        rep(j,z){
            ans.push_back(ab[i]+c[j]);
        }
    }
    sort(ans.begin(),ans.end(),greater<ll>());
 
    rep(i,N)cout << ans[i] << endl;
}

Measured memory_bytes: 43292
#include <iostream>

int main()
{
	int v[2][4];
	while( std::cin>>v[0][0]>>v[0][1]>>v[0][2]>>v[0][3]>>v[1][0]>>v[1][1]>>v[1][2]>>v[1][3] )
	{
		int hit = 0, blow = 0;

		for( int i=0; i<4; ++i )
		{
			if( v[0][i] == v[1][i] )
			{
				++hit;
				continue;
			}

			for( int j=0; j<4; ++j )
			{
				blow += v[0][i] == v[1][j];
			}
		}

		std::cout << hit << ' ' << blow << '\n';
	}
}

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

using namespace std;

int main(){
  long int a,b,x;
  cin >> a >> b >> x;
  if(a%x == 0){
    cout << b/x-a/x+1 << endl;
  }
  else{
    cout << b/x-a/x << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define Max 100

void push(int, int *);
int pop(int *);

int sp = 0;

int main(){

  int op2;
  int K[Max];
  char A[8];

  while(scanf("%s",A)==1){
    if(A[0] == '+'){
      push(pop(K) + pop(K), K);
    }
    else if(A[0] == '*'){
      push(pop(K) * pop(K), K);
    }
    else if(A[0] == '-'){
      op2 = pop(K);
      push(pop(K) - op2,K);
    }
    else{
      push(atoi(A), K);
    }
  }

  printf("%d\n",K[0]);

  return 0;
}


void push(int f, int K[]){
    K[sp++] =  f;
}

int pop(int K[]){
  return K[--sp];
}
    
    


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll m,n;
vector<string> vs;
ll dx[] = {0,1,0,-1};
ll dy[] = {1,0,-1,0};

bool in(ll cy,ll cx){
    return cy >= 0 && cy < m && cx >= 0 && cx < n;
}

char get(ll cy,ll cx,ll dir){
    ll ny = cy,nx = cx;
    while(in(ny,nx)){
        if(vs[ny][nx] != '.')return vs[ny][nx];
        ny += dy[dir];
        nx += dx[dir];
    }
    return '#';
}

void erase(ll cy,ll cx,ll dir,char c){
    ll ny = cy,nx = cx;
    while(in(ny,nx)){
        if(vs[ny][nx] == c){
            vs[ny][nx] = '.';
            return;
        }
        ny += dy[dir];
        nx += dx[dir];
    }
}

ll solve(ll cy,ll cx){
    map<char,ll> m;
    rep(i,4)m[get(cy,cx,i)]++;
    ll res = 0;
    rep(i,26){
        if(m[(char)('A'+i)] == 2){
            rep(j,4)erase(cy,cx,j,(char)('A'+i));
            res += 2;
        }
    }
    return res;
}



int main(){
    cin >> m >> n;
    vs.resize(m);
    rep(i,m)cin >> vs[i];
    bool iserase = true;
    ll ans = 0;
    while(iserase){
        iserase = false;
        rep(i,m){
            rep(j,n){
                if(vs[i][j] != '.')continue;
                ll num = solve(i,j);
                if(num != 0){
                    ans += num;
                    iserase = true;
                }
            }
        }
        // rep(i,m){
        //     rep(j,n)cout << vs[i][j] << " ";
        //     cout << endl;
        // }
    }
    cout << ans << endl;
}


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


int selectionSort ( int A[], int N) {
    int i, j;
    int minj;
    int count = 0;
    for ( i = 0; i < N; i++) {
        minj = i;
        for ( j = i; j < N; j++) {
            if ( A[j] < A[minj])
                minj = j;
        }
        swap(A[i], A[minj]);
        if ( i != minj)
            count++;

    }

    return count;
}


int main () {
    int i, N;
    int A[100];
    int count;

    cin >> N;
    for ( i = 0; i < N; i++) cin >> A[i];

    count = selectionSort(A, N);
    for ( i = 0; i < N; i++) {
        if ( i > 0) 
            cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
   
    return 0;
}
        




Measured memory_bytes: 3104
// c lib
#include <cstdio>
#include <cstdlib>
#include <cmath>

// container
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>

// Convenience
#include <algorithm>
#include <functional>

// IO
#include <iostream>

using namespace std;

int n;
int a[320];

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

  int count = 0;
  for (int i = 1; ; i <<= 1) {
    for (int j = 0; j < n; j++) {
      if (i & a[j]) goto end;
    }
    count++;
  }

end:

  cout << count << endl;
}

Measured memory_bytes: 256
n, x = map(int, input().split())


def p(level):
    if level == 0:
        return 1
    return 2*p(level-1)+1


def a(level):
    if level == 0:
        return 1
    return 2*a(level-1)+3


def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a(N-1):
        return f(N-1, X-1)
    else:
        return p(N-1) + 1 + f(N-1, X-2-a(N-1))



print(f(n, x))

Measured memory_bytes: 3064
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }
    else{
        int a,b;cin>>a>>b;
        cout<<a+b<<endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

VV<> G(100000);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    REP(i, n-1){
        int a, b; cin >> a >> b; a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    int k; cin >> k;
    V<ll> ans(n, -INF);
    priority_queue<pair<int,int>> q;
    while(k--){
        int v, p; cin >> v >> p; v--;
        ans[v] = p;
        q.push({p, v});
    }
    while(q.size()){
        int num = q.top().first, now = q.top().second; q.pop();
        for(auto v:G[now]){
            if(ans[v] == -INF){
                q.push({num - 1, v});
                ans[v] = num - 1;
            }
            if(ans[v] != ans[now] + 1 and ans[v] != ans[now] - 1){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    REP(i, n) cout << ans[i] << endl;
}

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

using namespace std;

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

	string s;

	cin >> s;

	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='1')
		{
			cout << 9;
		}
		else
		{
			cout << 1;
		}
	}
	cout << '\n';
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
bool pdd(double x){
    int a=x;
    x-=a;
    if(x>0){
        return false;
    }
    else{
        return true;
    }
}
int main(){
    char a[5],b[5];
    while(scanf("%s%s",a,b)!=EOF){
        int c;
        c=pow(10,strlen(b))*(atoi(a))+atoi(b);
        if(pdd(sqrt(c))==true){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double a[110];
int main()
{
	int n;double sum = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		scanf("%lf",&a[i]);
		sum += 1*1.0/a[i];
	}
	cout << 1/sum <<endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

c = 0
i = 0
ans = 0
while i < n-1:
    if a[i] == a[i+1]:
        c += 1
        i += 1
    else:
        ans += (c+1)//2
        c = 0
        i += 1
print((ans+(c+1)//2,ans)[c==0])

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

using namespace std;
typedef struct hhh
{
    char p[500];
    int a;
    int num;
}stu;
stu s[105];
bool cmp(stu s1,stu s2)
{
    if(strcmp(s1.p,s2.p)>0)
        return s1.p>s2.p;
    if(strcmp(s1.p,s2.p)<0)
        return s1.p<s2.p;
    if(strcmp(s1.p,s2.p)==0)
        return s1.a>s2.a;
}
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
         scanf("%s%d",s[i].p,&s[i].a);
         s[i].num=i+1;
    }
    sort(s,s+n,cmp);
    for(i=0;i<n;i++)
        printf("%d\n",s[i].num);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		String ans = (a+b>=c) ? "Yes" : "No";
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;
vector<int> G[MAX];
int size[MAX];
int N;

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}
ll sum=0;

void preDFS(int u,int p){
    size[u]=1;
    for(int to:G[u]){
        if(to==p) continue;
        preDFS(to,u);
        size[u]+=size[to];
    }
}

void solve(int u,int p){
    
    ll prob=mod+1;
    prob-=rui(rui(2,mod-2),N-1);
    for(int to:G[u]){
        prob+=mod;
        prob-=(rui(2,size[to])-1)*rui(rui(2,size[to]),mod-2)%mod*rui(rui(2,mod-2),N-1-size[to])%mod;
        prob%=mod;
        
        if(to==p) continue;
        
        size[u]-=size[to];
        size[to]=N;
        
        solve(to,u);
        
        size[to]-=size[u];
        size[u]=N;
    }
    if(G[u].size()==1) prob=0;
    sum+=prob*rui(2,mod-2);
    sum%=mod;
    
    //cout<<u<<" "<<sum<<endl;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    preDFS(0,-1);
    
    solve(0,-1);
    
    cout<<sum<<endl;
    
}




Measured memory_bytes: 25344
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010], B[100010];
    rep(i, N + 1) cin >> A[i];
    rep(i, N) cin >> B[i];
    ll ans = 0;
    rep(i, N) {
        int k = min(A[i], B[i]);
        ans += k;
        B[i] -= k;
        k = min(A[i + 1], B[i]);
        ans += k;
        B[i] -= k;
        A[i + 1] -= k;
    }
    cout << ans << endl;


    return 0;
}


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

int main(){

  int N;
  int i;
  
  cin >> N;
  vector<int> vec(N);
  
  for(i=0;i<N;++i){
      cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(i=1;i<N;++i){
    if(vec.at(i) == vec.at(i-1)){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <set>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou(bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  vector<int> kazu;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    kazu = vector<int>(n,1);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
      kazu.at(rx) += kazu.at(ry);
    }
    else{
      par.at(rx) = ry;
      kazu.at(ry) += kazu.at(rx);
    }
  }
  void newkazu(){
    int n = kazu.size();
    for(int i=0;i<n;i++){
      kazu.at(i) = kazu.at(root(i));
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n;
  cin >> n;
  vector<long long> a(n),b(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i) >> b.at(i);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(n % 2){
    cout << b.at((n-1)/2) - a.at((n-1)/2) + 1 << endl;
  }
  else{
    long long x = (b.at(n/2 - 1) + b.at(n/2));
    long long y = (a.at(n/2 - 1) + a.at(n/2));
    cout << (x - y) + 1 << endl;
  }
}

Measured memory_bytes: 6324
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

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

    map<int, int> M;
    for (auto x : A) M[x]++;

    int ans = 0;
    int d = 0;
    for (auto x : M) {
        if (x.second % 2 == 1)ans++;
        else d++;
    }

    ans += d;
    if (d % 2 == 1) ans--;

    cout << ans << endl;

}




























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

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

	if (a > b){
		cout << "a > b" << endl;
	}
	else if (a < b){
		cout << "a < b" << endl;
	}
	else{
		cout << "a == b" << endl;
	}

	return 0;
}

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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int A, B;
    string op;
    cin >> A >> op >> B;
    
    cout << (op=="+"?A+B:A-B) << endl;
}


Measured memory_bytes: 256
//Postdocs

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
using g = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    string t;cin>>t;
    rep(i,0,t.size()){
        if(t[i]=='?')t[i]='D';
    }
    cout<<t<<nnn;
    return 0;
}

Measured memory_bytes: 3756
f = lambda: map(int, input().split())
n,c = f()
d = [list(f()) for _ in range(n)]
d.sort(key=lambda x: (x[2],x[0]))
p = []
for i in range(n):
    if len(p)>0 and p[-1][2]==d[i][2] and p[-1][1]==d[i][0]:
        p[-1][1]=d[i][1]
    else:
        p.append(d[i])
ans = [0]*200100
for i in range(len(p)):
    ans[p[i][0] - 1] += 1
    ans[p[i][1]] -= 1
from itertools import accumulate as acc
print(max(acc(ans)))

Measured memory_bytes: 36832
while True:
        H, W = map(int,input().split())
        if H == 0 and W == 0:
                break
        elif H == 1 and W == 1:
                print ("#")
                print()
        else:
                if H % 2 == 0 and W % 2 == 0:
                        for i in range(H//2):
                                print("#."*(W//2))
                                print(".#"*(W//2))
                        print()
                elif H % 2 == 0 and W % 2 == 1:
                        for i in range(H//2):
                                print("#."*(W//2)+"#")
                                print(".#"*(W//2)+".")
                        print()
                elif H % 2 == 1 and W % 2 == 0:
                        for i in range(H//2):
                                print("#."*(W//2))
                                print(".#"*(W//2))
                        print("#."*(W//2))
                        print()
                else:
                        for i in range(H//2):
                                print("#."*(W//2)+"#")
                                print(".#"*(W//2)+".")
                        print("#."*(W//2)+"#")
                        print()
                


Measured memory_bytes: 5620
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

a,b,n=i2()
if b<=n:
	print( a*(b-1)//b )
else:
	print( a*n//b )

Measured memory_bytes: 9164
fn main() {
    proconio::input! {
        s: String,
        t: String
    };
    let a = s.as_bytes();
    let b = t.as_bytes();
    let mut res = b.len();
    for i in 0..=(a.len()-b.len()) {
        let mut cnt = 0;
        for j in 0..b.len() {
            if a[i+j] != b[j] { cnt += 1 }
        }
        res = res.min(cnt);
    }
    println!("{}", res);
}


Measured memory_bytes: 2100
/*package whatever //do not write package name here */

import java.io.*;

import java.util.*;
public class Main{
	public static void main (String[] args) {
	Scanner s=new Scanner(System.in);
	long n=s.nextLong();
	long k=s.nextLong();
	System.out.println(Math.min((n%k),Math.abs(k-(n%k))));
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, s;
    cin >> k >> s;
    ll ans = 0;
    for (int x = 0; x <= k; x++)
    {
        for (int y = 0; y <= k; y++)
        {
            int z = s - x - y;
            if (0 <= z && z <= k)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  vector<int> b(N);
  for (int i = 0; i < N; i++)
    cin >> a[i] >> b[i];
  vector<int> c(M);
  vector<int> d(M);
  for (int i = 0; i < M; i++)
    cin >> c[i] >> d[i];
  for (int i = 0; i < N; i++)
  {
    int id = -1;
    int dist = 1000000000;
    for (int j = 0; j < M; j++)
    {
      int tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (tmp < dist)
      {
        id = j;
        dist = tmp;
      }
    }
    cout << id + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>

using namespace std;

int main()
{
	//初めて計算量を意識した…
	long long a, b,x,cnt=0;
	cin >> a >> b >> x;
	cout << (b/x+1) - ((a-1)/x+1)*(a!=0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, seisu) for(int i = 0; i < (int)(seisu); i++)
typedef long long ll;
///vector<pair<string, int>>;

int main(){
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  vector<string> moji;
  rep(i, n) {
    moji.push_back(s.substr(i));
  }
  //rep(i ,n) cout << moji[i]  << endl;

  int ans = 2 * n;

  rep(i, n){
    if(moji[i] == t.substr(0, n-i)) {
      ans = 2 * n - moji[i].size();
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]
ans = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
count = 0
for i in info:
  ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] += i[3]
  if ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] > 9:
    ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] = 9
  elif ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] < 0:
        ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] = 0
for j in ans:
  count += 1
  for k in j:
    out = ""
    for l in k:
      out += " " + str(l)
    print(out)
  if count < 4: 
    print("#"*20)


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

bool digit(char c){
  return (c-'0'>=0 && c-'0'<=9);
}

int stoi(string s){
  int res,tmp;
  res = 0;
  tmp = 1;
  for(int i=(int)s.size()-1;i>=0;i--){
    res += (s[i]-'0') * tmp;
    tmp *= 10;
  }
  return res;
}

int cal(string s){
  vector<int> v,op;
  int pos = 0;
  while(pos<(int)s.size()){
    if(s[pos] == '('){
      int c = 1;
      string tmp;
      while(1){
	pos++;
	if(s[pos] == '(')c++;
	if(s[pos] == ')')c--;
      if(!c)break;
      tmp.push_back(s[pos]);
      }
      v.push_back(cal(tmp));
      pos++;
    }else if(digit(s[pos])){
      string tmp;
      while(digit(s[pos])){
	tmp.push_back(s[pos]);
	pos++;
      }
      v.push_back(stoi(tmp));
    }else{
      op.push_back(s[pos]);
      pos++;
    }
  }
    
  for(int i=0;i<(int)op.size();i++){
    if(op[i] == '*'){
      int tmp = v[i]*v[i+1];
      v.insert(v.begin()+i,tmp);
      v.erase(v.begin()+i+1);
      v.erase(v.begin()+i+1);
      op.erase(op.begin()+i);
      i = - 1;
    }
    if(op[i] == '/'){
      int tmp = v[i]/v[i+1];
      v.insert(v.begin()+i,tmp);
      v.erase(v.begin()+i+1);
      v.erase(v.begin()+i+1);
      op.erase(op.begin()+i);
      i = - 1;
    }
  }
  for(int i=0;i<(int)op.size();i++){
    if(op[i] == '+'){
      int tmp = v[i]+v[i+1];
      v.insert(v.begin()+i,tmp);
      v.erase(v.begin()+i+1);
      v.erase(v.begin()+i+1);
      op.erase(op.begin()+i);
      i = - 1;
    }
    if(op[i] == '-'){
      int tmp = v[i]-v[i+1];
      v.insert(v.begin()+i,tmp);
      v.erase(v.begin()+i+1);
      v.erase(v.begin()+i+1);
      op.erase(op.begin()+i);
      i = - 1;
    }
  }
  return v[0]; 
}

int main(){
  string s;
  int n;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    s.erase(s.end()-1);
    cout << cal(s) << endl;
  }
}

Measured memory_bytes: 0
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

if __name__ == '__main__':
    k = int(input())
    print(l[k-1])


Measured memory_bytes: 2940
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  cout << 1 - N << endl;
  return 0;
}


Measured memory_bytes: 3648