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

# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "<stdin>"
# 1 "../Algo/NumberTheory/modulo.h" 1
class ModuloOps {
public:
    ModuloOps(long long mod): MOD(mod) {
    }

    long long binPow(long long a, long long b) {
        if (b == 0) {
            return 1;
        }
        auto prev = binPow(a, b/2);
        return mul(mul(prev, prev), b % 2 == 1 ? a : 1);
    }

    long long inv(long long a) {
        return binPow(a, MOD - 2);
    }

    inline long long add(long long a, long long b) {
        return (a + b) % MOD;
    }

    inline void inc(long long &a, long long b) {
        a = add(a, b);
    }

    inline long long mul(long long a, long long b) {
        return (a * b) % MOD;
    }

    inline long long div(long long a, long long b) {
        return mul(a, inv(b));
    }

private:
    long long MOD;
};
# 2 "<stdin>" 2

using namespace std;

ModuloOps MOD(1000000000 + 7);

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n-1; i++) {
        int v, u;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<long long> fact(n+1, 1);
    for (int i = 1; i <= n; i++) {
        fact[i] = MOD.mul(fact[i-1], i);
    }
    vector<long long> dp(n, -1);
    vector<int> szs(n, 0);
    function<void(int, int)> calc;
    calc = [&] (int v, int p) {
        long long ans = 1;
        int sz = 1;
        for (int u : g[v]) {
            if (u != p) {
                calc(u, v);
                sz += szs[u];
                ans = MOD.mul(ans, MOD.mul(MOD.inv(fact[szs[u]]), dp[u]));
            }
        }
        ans = MOD.mul(ans, fact[sz-1]);
        dp[v] = ans;
        szs[v] = sz;
    };
    calc(0, -1);
    vector<long long> ans(n, -1);
    function<void(int, int)> enter;
    enter = [&] (int v, int p) {
        long long cur = fact[szs[v]-1];
        for (int u : g[v]) {
            cur = MOD.mul(cur, MOD.mul(MOD.inv(fact[szs[u]]), dp[u]));
        }
        ans[v] = cur;
        for (int u: g[v]) {
            if (u != p) {
                auto tmpDp = dp[v];
                auto szV = szs[v];
                auto szU = szs[u];
                dp[v] = MOD.mul(
                        MOD.mul(cur, fact[szU]),
                        MOD.mul(
                            MOD.mul(MOD.inv(fact[szV-1]), fact[szV-1-szU]),
                            MOD.inv(dp[u])));
                szs[v] -= szU;
                szs[u] += szs[v];
                enter(u, v);
                dp[v] = tmpDp;
                szs[v] = szV;
                szs[u] = szU;
            }
        }
    };
    enter(0, -1);
    for (int i = 0; i < n; i++) {
        cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 19444
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        a: [i64;n],
    }

     let mut sum = 0;
     for i in 0..n {
         sum += a[i];
     }
     let inf = 20000_0000_0+5;
     let mut ans: i64 = inf;
     let mut tmp: i64 = 0;
     for i in 0..n-1 {
         tmp += a[i];
        ans = min(ans, ((sum-tmp) - tmp).abs());
        // debug!(ans);
     }
     println!("{}", ans);
}


Measured memory_bytes: 4808
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(){
	long a, b;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	ifs >> a >> b;
#else
	std::cin >> a >> b;
#endif

	std::cout << std::bitset<32>(a & b) << std::endl;
	std::cout << std::bitset<32>(a | b) << std::endl;
	std::cout << std::bitset<32>(a ^ b) << std::endl;

   
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
	return 0;
}


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

a, b = map(int, input().split())

s = input()

a1 = s[:a]
s1 = s[a]
b1 = s[a+1:]

if a1.isdecimal() and s1 == '-' and b1.isdecimal():
    print('Yes')
else:
    print('No')


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

int main(){

  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  bool ans=true;

  for(int i=0; i<S.size(); i++){
    if(i==A){
      if(S[i]!='-') ans = false;
    }else{
      if(!(S[i]>='0' && S[i]<='9')) ans = false;
    }
  }

  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,K,mini=1e9+100;

int main(){
    cin>>N>>K;
    K--;
    int h[N];
    rep(i,N){
        cin>>h[i];
    }
    sort(h,h+N);
    rep(i,N-K){
        mini=min(mini,h[i+K]-h[i]);
    }
    out(mini);
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25

typedef pair<int, pair<int, int>> P;
int a[2][100];
int b[2][100];
int d[2][2] = {{0, 1}, {1, 0}};
int main()
{
	int n;
	cin >> n;
	rep(i, n) {
		cin >> a[0][i];
		b[0][i] = 0;
	}
	rep(i, n) {
		cin >> a[1][i];
		b[1][i] = 0;
	}
	queue<P> q;
	q.push(make_pair(a[0][0], make_pair(0, 0)));
	int mx = 0;
	while(!q.empty()) {
		P p = q.front();
		q.pop();
		int c = p.first;
		int y = p.second.first;
		int x = p.second.second;
		if (y == 1 && x == n - 1) {
			mx = max(mx, c);
			continue;
		}
		rep(i, 2) {
			int dy = y + d[i][0];
			int dx = x + d[i][1];
			if (dy >= 2 || dx >= n) continue;
			if (c > b[dy][dx]) {
				q.push(make_pair(c + a[dy][dx], make_pair(dy, dx)));
			}
		}
	}
	cout << mx << endl;
	return 0;
}

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

 
int main() {
  vector<int> a(1000001);
  int n,i;
  int64_t sum=0;
  cin >> n;
  for(i=1;i<=n;i++){
    if(i%5==0||i%3==0){
      a.at(i)=0;
    }else{
      //cout << i << endl;
      a.at(i)=i;
    }
    sum+=a.at(i);
  }
  cout << sum << endl;
}


Measured memory_bytes: 7036
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
A = [1 for _ in range(200001)]
for i in range(2,200001):
    A[i] = (i*A[i-1])%p
B = [1 for _ in range(200001)]
B[200000] = pow(A[200000],p-2)
for i in range(199999,1,-1):
    B[i] = (B[i+1]*(i+1))%p
    
n,a,b = map(int,input().split())
a1 = 1
for i in range(n,n-a,-1):
    a1 = (a1*i)%p
a1 = (a1*B[a])%p
b1 = 1
for i in range(n,n-b,-1):
    b1 = (b1*i)%p
b1 = (b1*B[b])%p
ans = (pow(2,n)-1-a1-b1)%p
print(ans)

Measured memory_bytes: 64204
import sys
input = sys.stdin.readline

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 size(self, x):
        if self.parents[x] < 0:
            return -self.parents[x]
        else:
            self.parents[x] = self.size(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

n, m = map(int, input().split())
A = [list(map(int, input().split())) for i in range(m)]

for i in range(m):
    for j in range(2):
        A[i][j] -= 1

U = UnionFind(n)
ans = n * (n-1) // 2
ANS = []
for i in range(m-1, -1, -1):
    ANS.append(ans)
    a = A[i][0]
    b = A[i][1]
    ua = U.find(a)
    ub = U.find(b)
    if ua != ub:
        ans -= U.size(ua) * U.size(ub)
        U.union(ua, ub)

for i in range(len(ANS)-1, -1, -1):
    print(ANS[i])

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

def main():
    """Function."""
    a, b, x = map(int, input().split())

    aflag, bflag = a % x, b % x

    dum = (b // x) - (a // x)
    if aflag == 0:
        dum += 1
    print(dum)

if __name__ == "__main__":
    main()


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

typedef long long int lli;
typedef long int li;
typedef long double ld;

const double pi = acos(-1);
const long long mod = 1e9+7;

#define tc() long long int t; scanf("%lld",&t); while (t>0)

int main(){
	float d,s,t;
	scanf("%f %f %f",&d,&t,&s);
	float tn=d/s;
	if (tn<=t){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;

struct parser{
	vector<int> sz;
	vector<map<int, int>> var;
	vector<string> prog;

	parser(vector<string> &vs){
		prog = vs;
		sz.resize(256);
		var.resize(256);
	}

	int parse(){
		for (int i = 0; i < prog.size(); ++i){
			if (!program(prog[i])) return i + 1;
		}
		return 0;
	}

	int program(const string &s){
		if (s.find("=") == -1) return declaration(s);
		return assignment(s);
	}

	bool declaration(const string &s){
		int len = s.size();
		char ar = s[0];
		sz[ar] = number(s.substr(2, len - 3));
		return true;
	}

	bool assignment(const string &s){
		int eq = 0;
		while (s[eq] != '=') ++eq;

		char ar = s[0];
		int idx = expression(s.substr(2, eq - 3));
		if (idx < 0 || idx >= sz[ar]) return false;
		int asgn = expression(s.substr(eq + 1));
		if (asgn < 0) return false;
		var[ar][idx] = asgn;
		return true;
	}

	int expression(const string &s){
		if (!isalpha(s[0])) return number(s);
		int len = s.size();
		char ar = s[0];
		int idx = expression(s.substr(2, len - 3));
		if (idx < 0 || idx >= sz[ar]) return -1;
		if (!var[ar].count(idx)) return -1;
		return var[ar][idx];
	}

	int number(const string &s){
		return stoi(s);
	}

};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(20);

	while (1){
		vector<string> vs;
		string s;
		while (cin >> s, s != "."){
			vs.emplace_back(s);
		}
		if (vs.empty()) break;
		parser p(vs);
		cout << p.parse() << endl;
	}

}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main(){
  ll n;
  cin>>n;
  cout<<fixed<<setprecision(10);
  vector<double> v(n);
  rep(i,n)cin>>v[i];
  sort(v.begin(),v.end());
  rep(i,n-1){
    v[i+1]=(v[i+1]+v[i])/2;
  }
  cout<<v[n-1]<<endl;
}


Measured memory_bytes: 256
import sys
class Tree():
    def __init__(self):
        self.root = None
    def insert(self, key):
        z = Node(key)
        y = None
        x = self.root
        while x:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        if y == None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z
    def find(self, key):
        x = self.root
        while x and x.key != key:
            if x.key < key:
                x = x.right
            else:
                x = x.left
        print('yes' if x else 'no')
    def print(self):
        print('',' '.join(map(str, self.root.inwalk())))
        print('',' '.join(map(str, self.root.prewalk())))
    
class Node():
    def __init__(self, key):
        self.key = key
        self.parent = self.left = self.right = None
    def prewalk(self):
        ret = [self.key]
        if self.left:
            ret += self.left.prewalk()
        if self.right:
            ret += self.right.prewalk()
        return ret
    def inwalk(self):
        ret = []
        if self.left:
            ret += self.left.inwalk()
        ret += [self.key]
        if self.right:
            ret += self.right.inwalk()
        return ret
tree = Tree()
n = sys.stdin.readline()
for line in sys.stdin:
    if line[0] == 'i':
        tree.insert(int(line.split()[1]))
    elif line[0] == 'f':
        tree.find(int(line.split()[1]))
    else:
        tree.print()


Measured memory_bytes: 117612
#!/usr/bin/env python3

n = int(input().split()[0])
max_diff = -float("inf")
min_value = float("inf")

for i in range(n):
    r = int(input().split()[0])
    if i != 0:
        diff = r - min_value
        max_diff = max(max_diff, diff)
    min_value = min(min_value, r)

ans = max_diff
print(max_diff)



Measured memory_bytes: 5624
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#define int long long

using namespace std;

const int N=2009,M=1000000007;
int f[N];

int ksm(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
			res=res*a%M;
		b>>=1,a=a*a%M;
	}
	return res;
}

signed main()
{
	int n;
	scanf("%lld",&n);
	f[0]=1;
	for (int i=3;i<=n;i++)
		for (int j=3;i-j>=0;j++)
			f[i]=(f[i]+f[i-j])%M;
	printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define pb push_back
#define long long long
#define pll pair < long , long >
#define vll vector < pll >
#define ml map < long , long >
#define mll map < pll , long >
#define x first
#define y second
#define vl vector < long >
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    io
    long q,h,s,d,n,ans=1e18,t=1e18;
    cin>>q>>h>>s>>d>>n;
    t=min(t,4*q);
    t=min(t,2*h);
    t=min(t,s);
    ans=min(ans,4*q*n);
    ans=min(ans,2*h*n);
    ans=min(ans,s*n);
    ans=min(ans,(n/2)*d+(n%2)*t);
    cout<<ans;
    return 0;
}


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


#define mod                1000000000000000007
#define pi                 3.1415926535897932384626433832795
#define ll                 long long
#define pb                 push_back
#define pii                pair < int , int >
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define forn(i,n)          for(i = 0 ; i < n ; i++)
#define deb(x)             cout << #x << " " << x << endl;
#define vecsum(v)          accumulate(v.begin(), v.end(), 0)
#define T(t)               cout << "Case " << t <<": ";
#define fast_cin           ios_base::sync_with_stdio(false);cin.tie(NULL)

char a[10][10],b[10][10];
int n , m , k;

void copy_matrix( ){

     for( int i = 0 ; i < n ; i++ ){
         for( int j = 0 ; j < m ; j++ ){
             b[i][j] = a[i][j];
         }
     }
}

void color( int i , int j ){


    for( int x = 0 ; x < n ; x++ ){
        if( i & ( 1 << x  )){
            for( int y = 0 ; y < m ; y++ ){
                b[x][y] = '$';
            }
        }
    }

    for( int  x = 0 ; x < m ; x++ ){
        if( j & ( 1 << x ) ){
            for( int y = 0 ; y < n ; y++ ){
                b[y][x] = '$';
            }
        }
    }

    return ;


}

bool check( ){

     int cnt = 0 ;

     for( int i = 0 ;i < n ; i++ ){
         for( int j = 0 ; j < m ; j++ ){
             if (b[i][j] == '#'){
                 cnt++;
             }
         }
     }

     if( cnt == k ){
         return true;
     }

     else{
         return false;
     }


}


void solve( ){

    cin >> n >> m >> k;
    int ans = 0 ;

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

            copy_matrix();
            color(i,j);
            if( check() ){
                ans++;
            }
        }
    }

    cout << ans << endl;
}




int main() {


    solve();



    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n,k,r,s,p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    vector<char> c(n);
    LL ans = 0;
    REP(i,0,n) {
        if (i < k) {
            if (t[i] == 'r') {
                c[i] = 'p';
                ans += p;
            }
            if (t[i] == 's') {
                c[i] = 'r';
                ans += r;
            }
            if (t[i] == 'p') {
                c[i] = 's';
                ans += s;
            }
            continue;
        }
        if (t[i] == 'r') {
            if (c[i-k] == 'p') continue;
            c[i] = 'p';
            ans += p;
        }
        if (t[i] == 's') {
            if (c[i-k] == 'r') continue;
            c[i] = 'r';
            ans += r;
        }
        if (t[i] == 'p') {
            if (c[i-k] == 's') continue;
            c[i] = 's';
            ans += s;
        }
    }
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  set<string> s,t;
  ll n; cin>>n;
  
  map<string,ll> m;
  rep(i,n){
    string a; cin>>a;
    m[a]++;
  }
  cin>>n;
  rep(i,n){
    string a; cin>>a;
    m[a]--;
  }
  ll ans=0;
  for(auto e: m){
    chmax(ans,e.second);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
Sharif Hasan - CSE, PUST
Apr 04, 2020 02: 47 PM 
*/
#include<bits/stdc++.h>
#define br cout<<"\n"

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(i=0;i<n;i++)
#define FROM(a,i,n) for(i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
vector<string>ln;
void calc(string a=""){
    int i=0,k=0;
    if(a.length()!=0){
        
        if(ln.size()>1000000||a.size()>10) return;
        ln.pb(a);
    }
    
    FOR(i,10){
        string p =""; p+=i+'0';
        if(a.length()==0&&i==0) continue;
        if(a.length()==0){
            calc(p);
        }else{
            int ld = a[a.length()-1]-'0';
            if(abs(i-ld)<=1){
                calc(a+p);
            }
        }
    }
}
/*Main function*/
int main()
{
calc();
//cout<<ln.size();br;
vector<long long int> v;
int i;
FOR(i,ln.size()){
    long long int k = stoll(ln[i]);
    v.pb(k);
}
sort(v.begin(),v.end());
//cout<<v[100000];
int n;cin>>n;
cout<<v[n-1];br;
return 0;
}

Measured memory_bytes: 17008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    ll ans = 0;

    for (int i = 0; i < k;i++)
    {
        char tmp = t[i];
        int cnt = 1;
        for (int j = 0;k * j + i < n;j++){
            int x = k * j + i;
            if(tmp == t[x]){
                cnt++;
            }else{
                if (tmp == 'r')
                {
                    ans += cnt / 2 * p;
                }
                else if (tmp == 's')
                {
                   ans+=cnt/2*r;
                }
                else if (tmp == 'p')
                {

                    ans+=cnt/2*s;
                }
                tmp = t[x];
                cnt = 2;
            }
        }
        if (tmp == 'r')
        {
            ans += cnt / 2 * p;
        }
        else if (tmp == 's')
        {
            ans += cnt / 2 * r;
        }
        else if (tmp == 'p')
        {

            ans += cnt / 2 * s;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
n=int(input())
a=[int(input()) for i in range(n)]
a.append(1000000001)
a.append(0)
a.sort()
c=0
ans=0
s=0
#print(a)
for i in range(1,n+2):
    if a[i]==c:
        s+=1
    else:
        ans+=(s%2)
        c=a[i]
        s=1
    #print(s)
print(ans)

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

to = [[] for _ in range(N)]
visited = [False] * N

def dfs(v):
    if sum(visited) == N:
        return 1 
    
    ret = 0
    for u in to[v]:
        if not visited[u]:
            visited[u] = True
            ret += dfs(u)
            visited[u] = False  # 最も深い点から帰ってくる道中に、始点を除く全ての点を未訪問にする => 他のパスを辿ることが可能になる

    return ret


for _ in range(M):
    a, b = map(int, input().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)

visited[0] = True
print(dfs(0))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include <array>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X;}
#define TF(f) {f;}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1000000;
#define NMAX 5000
#define MAX 10

ll sum[NMAX + 1], temp, buff = 0;
int N, K, ans = 0;
int A[100010];
int count = 0;
std::array<std::array<bool, NMAX + 10>, NMAX + 10> dp, dp1;
std::array<std::array<bool, NMAX + 10>, NMAX + 10> vis, vis1;
int low = 0, high, mid;

bool dfs(ll x, ll y) {
	if (y == 0) {
		return true;
	}
	if (y<0)return false;
	if (vis[x][y]) {
		return dp[x][y];
	}
	else vis[x][y] = true;
	if (y == 0) { dp[x][y] = true; /*DEB(dp[x][y])DEB(x)DEB(y)END*/ return dp[x][y]; }
	if (x == N) { dp[x][y] = false;/*DEB(dp[x][y])DEB(x)DEB(y)END*/ return dp[x][y]; }

	if (dfs(x + 1, y) || dfs(x + 1, y - A[x])) {
		dp[x][y] = true;
	}
	else dp[x][y] = false;
	//DEB(dp[x][y])DEB(x)DEB(y)END
	return dp[x][y];
}
bool front(ll x, ll y) {
	if (y == 0) {
		return true;
		//dp1[x][y] = true; //DEB(dp1[x][y])DEB(x)DEB(y)END
		//return dp1[x][y];
	}
	if (y<0)return false;
	if (x<0) {
		//DEB(dp1[x][y])DEB(x)DEB(y)END
		return false;
	}
	if (vis1[x][y]) {
		return dp1[x][y];
	}
	else vis1[x][y] = true;


	if (front(x - 1, y) || front(x - 1, y - A[x])) {
		dp1[x][y] = true;
	}
	else dp1[x][y] = false;
	//DEB(dp1[x][y])DEB(x)DEB(y)END
	return dp1[x][y];
}
#if 0
int main() {
	ios_base::sync_with_stdio(false);
	cin >> N >> K;
	ans = N;
	REP(i, N) { cin >> A[i]; }
	sort(A, A + N);
	high = N - 1;
	REP(i, N) {
		bool m = false;
		FOR(j, K - A[i], K) {
			if (j<0)j = 0;
			//if(front(i,j)) m=true;
			REP(k, K) {
				//if(j+k>K)break;
				DEB(i)DEB(j)DEB(k)
					TF(front(i, j))
					TF(dfs(i, k))
					TF(dfs(i, k) && front(i, j))
					END
					if (dfs(i, k) && front(i, j)) {
						ans = i;
						if (i == N - 1)ans = 0;
						m = true;
						break;
					}

			}
			if (m)break;
		}
		if (m)break;
	}

	cout << ans << endl;
}
#else
int main() {
	ios_base::sync_with_stdio(false);
	cin >> N >> K;
	ans = N;
	REP(i, N) { cin >> A[i]; }
	sort(A, A + N);
	REP(i, N) {
		bool m = false;
		REP(k, K) {
			FOR(j, K - A[i] - k, K-k+1) {
				if (j<0)j = 0;
				if (dfs(i+1, k) && front(i-1, j)) {
					//必要
					ans = i;
					//if (i == N - 1)ans = 0;
					m = true;
					break;
				}
			}
			if (m)break;
		}
		if (m)break;
	}
	cout << ans << endl;
}
#endif
//ABC056 AtCoDeer




Measured memory_bytes: 98816
#include <stdio.h>
 
int main(void){
  int r, D, x, ret;
  
  ret = scanf("%d %d %d", &r, &D, &x);
  
  for(int i = 0; i < 10; i++){
    x = r*x - D;
    printf("%d\n", x);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    int X,A,B;
    cin >> X;
    cin >> A;
    cin >> B;
    cout << (X-A) % B;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())

ans = 0
tmp = 0
for _ in range(N):
    d1, d2 = mapint()
    if d1==d2:
        tmp += 1
    else:
        tmp = 0
    ans = max(ans, tmp)
if ans>=3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62072
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,s;
  while(scanf("%d %d %d",&n,&m,&s),n!=0&&m!=0&&s!=0){
    int sum[50][3001] = {};
    sum[0][0] = 1;
    for(int i=1;i<=m;i++){
      for(int j=min(i,n*n);j>0;j--){
	for(int k=i;k<=s;k++){
	  sum[j][k] = (sum[j][k] + sum[j-1][k-i])%100000;
	}
      }
    }
    printf("%d\n",sum[n*n][s]);
  }
  return (0);
}

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

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

    int a1 = a;
    int b1 = b;
    if (a1 == 1) {
        a1 += 100;
    }
    if (b1 == 1) {
        b1 += 100;
    }

    if (a1 == b1) {
        cout << "Draw" << endl;
    }
    else if (a1 > b1) {
        cout << "Alice" << endl;
    }
    else {
        cout << "Bob" << endl;
    }


    return 0;
}


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

int main(){
    int x, a = 2001, b = 2001;
    for(int i = 0; i < 3; i++){
        cin >> x;
        a = min(a,x);
    }
    for(int i = 0; i < 2; i++){
        cin >> x;
        b = min(b,x);
    }
    cout << a+b-50 << endl;
    return 0;
}


Measured memory_bytes: 3076
//#include<bits/stdc++.h>
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<list>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>

#define ll long long

using namespace std;

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll sum = 0;
	if (k <= a) sum += k;
	else if (k > a && k <= a + b) sum += a;
	else sum += a - k + a + b;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>

int main()
{

    int w,h,x,y,r;
    std::cin >> x;
    std::cin >> y;
    std::cin >> w;
    std::cin >> h;
    std::cin >> r;
    if (w+r > x|| w-r < 0|| h+r > y|| h-r < 0 ){
        std::cout << "No" << std::endl;
    }else{
        std::cout << "Yes" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String[] Lary= {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
        String[] Sary= {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
        int[] ansBox=new int[26];

        //ansBox初期化
        for(int i=0;i<26;i++) {
            ansBox[i]=0;
        }

        //文字列を入力
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc=new Scanner(System.in);
        String str;
        //while(true){
        while(sc.hasNext()) {
            str=sc.nextLine();
            //if(str.equals("")){break;}
            //文字数をカウント
            int n=str.length();
            //n回廻す
            for(int i=0;i<n;i++) {
                //strからi個目の文字を切り出す
                char a;
                a=str.charAt(i);

                //それぞれをif文にかけ、アルファベットを判断
                for(int j=0;j<26;j++) {
                    if(Lary[j].equals(String.valueOf(a)) || Sary[j].equals(String.valueOf(a))) {
                        ansBox[j]++;
                    }
                }
            }
        }
        for(int i=0;i<26;i++) {
            System.out.println(Sary[i]+" : "+ansBox[i]);
        }
	}

}



Measured memory_bytes: 29464
N, M = map(int, input().split())
a_n = [int(input()) for i in range(M)]
def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
now = 0
before = -9999
answer = 1

for a in a_n:
    if a - before == 1:
        answer = 0
        break

    answer *= Fib( a - 1 - now + 2 )
    answer %= 1000000007
    now = a + 1
    before = a

if answer > 0:
    answer *= Fib( N - now + 2)
    answer %= 1000000007

print(answer)

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

int main() {
  int n; cin >>n;
  vector<long long>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.rbegin(),a.rend());
  long long tate=0;
  long long yoko=0;
  bool hantei=false;
  for(int i=0;i<n;i++){
    if(hantei==true&&a[i]==a[i+1]){
      yoko=a[i];
      break;
    }
    if(hantei==false&&a[i]==a[i+1]){
      tate=a[i];
      hantei=true;
      i++;
    }
  }
  cout<<tate*yoko<<endl;
  return 0;
}
  
 

Measured memory_bytes: 4044
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

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

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, X;
    cin >> n >> X;
    vector<int> x(n+1);
    rep(i, n) cin >> x[i];
    x[n] = X;
    
    sort(x.begin(), x.end());
    
    vector<int> dx(n);
    rep(i, n)
    {
        dx[i] = x[i+1] - x[i];
    }
    
    int gcd = 0;
    rep(i, n)
    {
        gcd = GCD(gcd, dx[i]);
    }
    
    cout << gcd << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  int64_t A;
  
  cin >> N;
  
  int64_t T = 1;
  bool over = false;
  bool zero = false;
  
  for(int i = 0; i < N; i++)
  {
    cin >> A;
    if(A == 0)
    {
      zero = true;
      break;
    }
    if(A > 1000000000000000000 / T){over = true;}
    else{T *= A;}   
  }
  
  if(zero){cout << "0" << endl;}
  else if(over){cout << "-1" << endl;}
  else{cout << T << endl;}
}

Measured memory_bytes: 3636
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		
		String T = sc.next();
		
		for(int i = 0; i < T.length(); i++) {
			System.out.print((T.charAt(i) == '?')?'D':T.charAt(i));
		}
		System.out.println();
		sc.close();
	}
}

Measured memory_bytes: 56532
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

const int N = 200'009;

char s[N];
vector<int> g[N];
int cnt[N][2];
bool was[N];

int main() {
  //
  int n, m;
  scanf("%d %d", &n, &m);
  scanf("%s", s);
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x;
    --y;
    if (x == y) {
      ++cnt[x][(int)(s[x] - 'A')];
    } else {
      g[x].push_back(y);
      g[y].push_back(x);
      ++cnt[x][(int)(s[y] - 'A')];
      ++cnt[y][(int)(s[x] - 'A')];
    }
  }
  memset(was, false, sizeof was);
  vector<int> a;
  for (int i = 0; i < n; ++i) {
    if (cnt[i][0] == 0 || cnt[i][1] == 0) {
      was[i] = true;
      a.push_back(i);
    }
  }
  int rem = n;
  while (!a.empty()) {
    vector<int> na;
    for (int x : a) {
      for (int y : g[x]) {
        if (was[y]) {
          continue;
        }
        --cnt[y][(int)(s[x] - 'A')];
        if (cnt[y][0] == 0 || cnt[y][1] == 0) {
          was[y] = true;
          na.push_back(y);
        }
      }
    }
    rem -= (int)a.size();
    a = na;
  }
  puts(rem != 0 ? "Yes" : "No");
}


Measured memory_bytes: 13052
#include <stdio.h>
int A[20],n;
int search(int,int);

int main(){
  int i,q,m;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(search(0,m))
      printf("yes\n");
    else
      printf("no\n");
  }
  
  return 0;
}

int search(int i,int m){
  int res;
  
  if(m==0)
    return 1;
  if(i>=n)
    return 0;
  res=search(i+1,m) || search(i+1,m-A[i]);
  return res;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,a,b;
	t = 1;
	while(t--) {
	 cin >> a >> b;
	 if((a * b) % 2)
	  cout << "Yes" << endl;
     else
	  cout << "No" << endl;
	}
	return 0;
}



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

using i64 = int64_t;

int main(){
    i64 n, k;
    cin >> n >> k;
    i64 ans = 1, q = k;
    while(q <= n){
        q *= k;
        ans++;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define N 12000

int n,a[N],b[N];
long long cnt; 

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) scanf("%d",&b[i]);
	for (int i=1;i<=n;i++){
		if (a[i]<b[i]) cnt+=(b[i]-a[i]+1)/2,a[i]+=(b[i]-a[i]+1)/2*2;
		if (a[i]>b[i]) cnt-=a[i]-b[i];
	}
	if (cnt>=0) puts("Yes");
	else puts("No");
	
	return 0;
}
			

Measured memory_bytes: 384
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 1e6 + 5;

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

	int g = 0;

	vector<int>vis(N , 0);
	int x;
	for(int i=0;i<n;i++){
		cin>>x;
		g = __gcd(g,x);
		vis[x]++;
	}	

	if(g > 1){
		cout<<"not coprime\n";
	}else{
		bool f = false;
		for(int i=2;i<=N;i++){
			int sum = 0;
			for(int j = i;j<=N;j+=i){
				sum += vis[j];
			}
			if(sum > 1){
				f = true;
				break;
			}
		}
		if(f){
			cout<<"setwise coprime\n";
		}else{
			cout<<"pairwise coprime\n";
		}
	}


	

	return 0;
}

Measured memory_bytes: 7212
import sys
import heapq as hq

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    X, Y, A, B, C = map(int, rl().split())
    p = list(map(int, rl().split()))
    q = list(map(int, rl().split()))
    r = list(map(int, rl().split()))
    
    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)
    heap_p = p[:X]
    heap_q = q[:Y]
    hq.heapify(heap_p)
    hq.heapify(heap_q)
    
    for ri in r:
        if heap_p[0] < ri and heap_p[0] <= heap_q[0]:
            hq.heappushpop(heap_p, ri)
        elif heap_q[0] < ri:
            hq.heappushpop(heap_q, ri)
        else:
            break
    
    ans = sum(heap_p) + sum(heap_q)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 96040
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2014&lang=jpd>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int w,h;
vector<int> solve(){
    vector<int> res{0,0};
    vector<vector<char>> a(h+2,vector<char>(w+2,'#'));
    for(int i = 1; i <= h;i++) for(int j = 1; j <= w;j++) cin >> a[i][j];
    vector<vector<int>> flag(h+2,vector<int>(w+2,0));
    for(int i = 1; i <= h;i++){
        for(int j = 1; j <= w;j++){
            if(a[i][j] == '.') continue;
            int cost = (a[i][j]=='W')?2:1;
            int d[4] = {1,0,-1,0};
            queue<pii> q;
            for(int k = 0; k < 4;k++){
                int ni = i + d[k], nj = j + d[k^1];
                if(a[ni][nj] == '.') q.push(make_pair(ni,nj));
            }
            while(q.size()){
                int x,y; tie(x,y) = q.front(); q.pop();
                if(flag[x][y]&cost) continue;
                flag[x][y] += cost;
                for(int k = 0; k < 4;k++){
                    int nx = x + d[k], ny = y + d[k^1];
                    if(a[nx][ny] != '.') continue;
                    q.push(make_pair(nx,ny));
                }
            }
        }
    }
    for(int i = 1; i <= h;i++){
        res[0] += count(flag[i].begin(),flag[i].end(),1);
        res[1] += count(flag[i].begin(),flag[i].end(),2);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> w >> h,w){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3244
import sys
input=sys.stdin.readline

S = input().strip()
n = S.count("N") > 0
w = S.count("W") > 0
e = S.count("E") > 0
s = S.count("S") > 0

if (n and not s) or (not n and s) or (w and not e) or (not w and e):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int i,n;
	int tag=0;
	int flag=0;
	int a,b,c,d;
	int count=0;
	int t[1000][4];
	while(scanf("%d",&n)!=EOF)
	{
		for(a=0;a<10;a++)
		{
			for(b=0;b<10;b++)
			{
				for(c=0;c<10;c++)
				{
					for(d=0;d<10;d++)
					{
						if(a+b+c+d==n)
						{
							for(i=0;i<flag;i++)
							{
								if(t[i][0]!=a || t[i][1]!=b || t[i][2]!=c || t[i][3]!=d)
									tag++;
							}
			
							if(tag==flag)
							{
								t[flag][0]=a;
								t[flag][1]=b;
								t[flag][2]=c;
								t[flag][3]=d;
							}
							flag++;
							tag=0;
						}
					}
				}
			}
		}
		printf("%d\n",flag);
		flag=0;
	}
	return 0;
}

Measured memory_bytes: 592
#include<stdio.h>
#include<math.h>
int main(){

  int n,a[10000],i,j,count=0;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&a[i]);
  }

  for(i = 0; i < n; i++){      
    for(j = sqrt(a[i]);j > 2; j--){
      if(a[i] % j == 0)break;
    }
    if(a[i] % j != 0 || a[i] == 2 || a[i] == 3)count++;
  }

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

  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323

ll n,m,x,c[13],a[13][13];
ll mi;

bool ch(ll q, ll y)
{
	ll z=pow(2,y);
	q=q/z;
	if(q%2==0)
		return 0;
	else
		return 1;
}

void fun(ll mask)
{
	ll tc=0;
	ll ts[m]={0};
	for(int i=0;i<n;i++)
	{
		if(ch(mask,i))
		{
			tc+=c[i];
			for(int j=0;j<m;j++)
				ts[j]+=a[i][j];
		}
	}
	bool b=1;
	for(int i=0;i<m;i++)
		if(ts[i]<x)
			b=0;
	if(b)
		mi=min(mi,tc);
	if(mask>0)
		fun(mask-1);
}

int main() 
{
    FAST;
    cin>>n>>m>>x;
    for(int i=0;i<n;i++)
    {
    	cin>>c[i];
    	for(int j=0;j<m;j++)
    		cin>>a[i][j];
    }
    ll mask = (1<<12)-1;
    mi=1000000000000000ll;
    fun(mask);
    if(mi!=1000000000000000ll)
    	cout<<mi;
   	else
   		cout<<-1;
    //cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
main(){
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  string s=string()+s1.front()+s2.front()+s3.front();
  for(auto&c:s)c=toupper(c);
  cout<<s<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i,n)   for (int i = 0; i < (n); ++i)
#define SORT(a)    sort((a).begin(), (a).end());
#define UNIQ(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define FIND(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define REVERSE(a) reverse((a).begin(), (a).end());

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

const int MOD = 1000000007; // 10^9 + 7

int a[10];

bool dfs(int i, int b, int c) {
  if (i == 10) return true;

  if (a[i] > b && dfs(i + 1, a[i], c)) return true;
  if (a[i] > c && dfs(i + 1, b, a[i])) return true;
  return false;
}

bool solve() {
  return dfs(0, -1, -1);
}

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

  int n; cin >> n;
  REP(i, n) {
    REP(j, 10) cin >> a[j];
    cout << (solve() ? "YES" : "NO") << endl;
  }
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,count5=0,count7=0;
  bool d=true;
  cin>>a>>b>>c;
  if(a==5 &&count5<2){
    count5++;
  }
  else if(a==7&&count7<1){
    count7++;
  }
  else{
    d=false;
  }
    if(b==5 &&count5<2){
    count5++;
  }
  else if(b==7&&count7<1){
    count7++;
  }
  else{
    d=false;
  }
    if(c==5 &&count5<2){
    count5++;
  }
  else if(c==7&&count7<1){
    count7++;
  }
  else{
    d=false;
  }
  if(d){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
}

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

using namespace std;

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

int main(){
	int n;
	stack<int> st;
	while (cin>>n){
		if (n){
			st.push(n);
		}
		else{
			cout<<st.top()<<endl;
			st.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, m, mod = 1000000007;
vector< int > s( 2e3 + 3 ), t( 2e3 + 3 );
long long dp[ 2003 ][ 2003 ];

long long solve( int i, int j )
{
	if( i == 0 || j == 0 )
	{
		return 1;
	}
	if( dp[ i ][ j ] != -1 )
	{
		return dp[ i ][ j ];
	}
	dp[ i ][ j ] = 0;
	if( s[ i ] == t[ j ] )
	{
		dp[ i ][ j ] += solve( i - 1, j - 1 );
	}
	dp[ i ][ j ] += solve( i - 1, j ) + solve( i, j - 1 ) - solve( i - 1, j - 1 );
	dp[ i ][ j ] += mod;
	dp[ i ][ j ] %= mod;
	return dp[ i ][ j ];
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	memset( dp, -1, sizeof( dp ) );
	cin	>> n >> m;
	for( int i = 1; i <= n; ++i )
	{
		cin >> s[ i ];		
	}
	for( int i = 1; i <= m; ++i )
	{
		cin >> t[ i ];
	}
	cout << solve( n, m ) << "\n";
	return 0;
}

Measured memory_bytes: 31872
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
template<class T>
T gcd(T x, T y) {
	return y ? gcd(y, x % y) : x;
}

template<class T>
vector<T> enum_div(T n) {
	vector<T> ret;
	ret.push_back(1);
	ret.push_back(n);
	for (T i = 1ll; i * i < n; ++i) {

		if (n % i == 0ll) {
			ret.push_back(i);

			if (i != 1ll && i * i != n) {
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}

template<class T>
map<T, T> prime_factorization(T n) {
	map<T, T> ret;

	for (long long i = 2ll; i * i <= n; ++i) {
		while (n % i == 0ll) {
			ret[i]++;
			n /= i;
		}
	}

	if (n != 1)ret[n] = 1;
	return ret;
}

template<class T>
long long C(T n, T r) {
	static map<pair<T, T>, long long> _map;
	if (n < r) return 0;

	if (n == r || r == 0) {
		_map[make_pair(n, r)] = 1ll;
	}
	else if (_map[make_pair(n, r)] == 0) {
		_map[make_pair(n, r)] = (C(n - 1, r) + C(n - 1, r - 1));
	}

	_map[make_pair(n, r)] %= MOD;
	return _map[make_pair(n, r)];
}

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

	long long dist = 1ll << 60;
	for (long long i = 1; i <= sqrt(N); ++i) {
		if (N % i == 0) {
			dist = min(dist, i + N / i - 2);
		}
	}
	cout << dist << endl;

	return 0;
}

Measured memory_bytes: 256