akhauriyash/Code-Regression huggingface dataset:
s = input()
t = input()
s_list = [-1]*26  # index = string of s, number = string of t
t_list = [-1]*26  # index = string of t, number = string of s
# a = 0, z = 25
ans = "Yes"
for i in range(len(s)):
    s_num = ord(s[i]) - 97
    t_num = ord(t[i]) - 97
    if s_list[s_num] < 0:
        s_list[s_num] = t_num
    else:
        if s_list[s_num] != t_num:
            ans = "No"
            break
    if t_list[t_num] < 0:
        t_list[t_num] = s_num
    else:
        if t_list[t_num] != s_num:
            ans = "No"
            break
print(ans)

Measured memory_bytes: 41840
N = int(input())
num_list = [int(i) for i in input().split(" ")]

tmp1 = 1
tmp2 = 0

for i in range(N):
    tmp1 = tmp1 * num_list[i]

for i in range(N):
    tmp2 += tmp1 / num_list[i]

print(tmp1/tmp2)

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

int main(void){
    string s;
    int N;
    cin >> s;
    cin >> N;
    bool reversed = false;
    for(int i=0; i<N; i++) {
        int t;
        cin >> t;
        if(t==1) {
            reversed = !reversed;
        } else {
          int f;
          string c;
          cin >> f >> c;
          if(!reversed) {
            if(f==1) s.insert(0, c);
            else s += c;
          }else {
            if(f==1) s += c;
            else s.insert(0, c);
          }
        }
    }
    if(reversed) reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;    
}


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

const ll MOD = 1e9+7;

ll mod(ll val, ll m) {
    ll res = val % m;
    if (res < 0) res += m;
    return res;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) {
        ll tmp;
        cin >> tmp;
        tmp %= MOD;
        a[i] = tmp;
    }
    ll ans = 0;
    ll s = 0;
    rep(i,n) {
        s += a[i];
        s %= MOD;
    }
    rep(i,n-1){
        s = mod(s-a[i], MOD);
        ans += a[i]*s;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4804
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000003;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};


int main(){
    int x;cin >> x;
    if(x >= 2100) cout << 1 << endl;
    else{
        int t = x / 100;
        t *= 5;
        if(x % 100 <= t) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String args[]) {
    Scanner s = new Scanner(System.in);
    if((s.nextInt() & 1) == 0){
      System.out.println("Even");
    } else if((s.nextInt() & 1) == 0){
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  }
}


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

int main(){
    string A,B,C;
    cin >> A >> B >> C;
    bool X=false;
    if (A[A.size()-1]==B[0] && B[B.size()-1]==C[0]) X=true ;
    if (X) cout << "YES" << endl;
    else cout << "NO" << endl;;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	string s; cin >> s;
	if(s == "ABC") puts("ARC");
	else puts("ABC");
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

////////////////////////////////////////////////////////////////////
const int limit=50;
int n,m;
int a[limit], b[limit];
bool Memory[limit][limit];
bool visited[limit];

void dfs(int v){
    visited[v]=true;
    REP(v2,n){
        if(Memory[v][v2]==false) continue;
        if(visited[v2]==true) continue;
        dfs(v2);
    }
}

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

    REP(i,n){
        REP(j,n){
            Memory[i][j]=false;
        }
    }

    REP(i,m){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        Memory[a[i]][b[i]] = Memory[b[i]][a[i]] = true;
    }

    int ans=0;

    REP(i,m){
        Memory[a[i]][b[i]] = Memory[b[i]][a[i]] = false;

        REP(j,n) visited[j] = false;

        dfs(0);

        bool bridge = false;
        REP(j,n) if(visited[j]==false) bridge = true;
        if(bridge) ans++;

        Memory[a[i]][b[i]] = Memory[b[i]][a[i]] = true;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans[100010][2] = {};

int main()
{
ll n;
cin >> n;
ll t[n] = {};
rep(i, n){
    cin >> t[i];
}
sort(t,t+n);
ll sum=0;
ll ma=t[n-1];
ll mi=t[0];
if(n==2){ans[0][0]=ma;ans[0][1]=mi;ma-=mi;}
else{
rep(i,n-2){
    if(t[i+1]>0){ans[i][0]=mi;ans[i][1]=t[i+1];mi-=t[i+1];}
    else {ans[i][0]=ma;ans[i][1]=t[i+1];ma-=t[i+1];}
}
{ans[n-2][0]=ma;ans[n-2][1]=mi;ma-=mi;}
}
cout << ma << endl;
//2次元配列の中身を見る

for (int i = 0; i < n-1; ++i){
for (int j = 0; j < 2; ++j) {
    cout << ans[i][j] << " ";
}cout  << endl;}
return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MAX = 7000;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, t;
  cin >> n >> t;
  vector<pair<int, int>> a(n);
  rep(i, n) cin >> a[i].first >> a[i].second;
  sort(a.begin(), a.end());
  vector<vector<int>> dp(n+1, vector<int>(MAX));
  rep(i, n) {
    rep(j, MAX) {
      chmax(dp[i+1][j], dp[i][j]);
      if (j < t)
        chmax(dp[i+1][j+a[i].first], dp[i][j]+a[i].second);
    }
  }
  int ans = 0;
  rep(i, MAX)
    chmax(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 82432
#include <iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a > b) {cout << "a > b" << endl;}
	if (a < b) {cout << "a < b" << endl;}
	if (a == b) {cout << "a == b" << endl;}
	return 0;
}


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

#define sz(s) (int)(s).size()
#define re(i, n) for (int i = 1; i <= n; i ++)
#define pb push_back
#define finish(x) return cout << x << endl, 0
#define MP make_mair
#define trav(x, a) for(auto& x: a)
#define all(x) (x).begin,(x).end()
#define Sor(x) sort(all(x))
#define REV(x) reverse(all(x))
#define F first
#define S second
#define I insert
#define N 222222
#define MOD 100000007

using namespace std;

typedef long long ll;
vector <ll> vll;
template <class T> bool umin(T& a, T b) {if(a>b){a = b; return 1;}return 0;}
template <class T> bool umax(T& a, T b) {if(a<b){a=b; return 1;}return 0;}
template <class T, class TT> bool pal(T a, TT n){int k = 0; for(int i =0; i <= n / 2; i ++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

ll powmod(ll a, ll b, ll m = MOD){ll r = 1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}


int main()
{	
	ll n, m;
	cin >> n >> m;
	if (n > m)
		cout << "No";
	else	
		cout << "Yes";









	getchar();
	getchar();
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int M;
  cin >> M;
  int hwd;
  int hwdsum = 0;
  for (int i = 0; i < M; i++) {
    cin >> hwd;
    hwdsum+=hwd;
  }
  
  int r;
  if (hwdsum > N){
    r = -1;
  }else{
    r = N - hwdsum;
  }
  
  cout<<r;
}




Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double pi = acos(-1.0); 
typedef long long ll;

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

	string s, t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i < (int)s.size(); i++) {
		if(s[i] != t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3820
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
int main( ) {
    //freopen("C.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char s[256];
    map<char,ll> m;
    ll cnt=0;
    int n;
    scanf("%d",&n);
    while(n--){
        scanf("%s",&s);
        m[s[0]]++;
    }
    if(sz(m)<3){
        printf("%d",0);
        return 0;
    }
    // m['M']*m['A']*m['R']*m['C']*m['H']
    cnt = m['M']*m['A']*m['R']+m['M']*m['A']*m['C']+m['M']*m['A']*m['H']+m['A']*m['R']*m['C']+m['A']*m['R']*m['H']+m['R']*m['C']*m['H']+m['M']*m['R']*m['C']+m['M']*m['R']*m['H']+m['M']*m['C']*m['H']+m['A']*m['C']*m['H'];
    printf("%lld",cnt);
    return 0;
}

Measured memory_bytes: 3820
S = list(map(int, input().split('/')))

result = 'Heisei'
if S[0] < 2019:
    print(result)
    exit(0)

if S[0] == 2019 and S[1] < 4:
    print(result)
    exit(0)

if S[0] == 2019 and S[1] == 4 and S[2] <= 30:
    print(result)
    exit(0)
result = 'TBD'
print(result)


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

int main() {
    int N;
    int ans = -1;
    int max = 0;
    cin >> N;
    for(int i = 1; i <= N; i++)
    {
        int cnt = 0;
        int tmp = i;
        while(tmp % 2 == 0)
        {
            cnt++;
            tmp /= 2;
        }
        if(cnt >= max)
        {
            max = cnt;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

const ll INF = 1LL << 60;

ll dp[3010][3010];
ll N, T;
vector<P> v;

int main() {
    cin >> N >> T;
    v.resize(N);

    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        v[i] = P(a, b);
    }
    sort(v.begin(), v.end());

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < T; j++) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

            if (j + v[i].first < T) {
                dp[i + 1][j + v[i].first] = max(dp[i + 1][j + v[i].first], dp[i][j] + v[i].second);
            }
        }
        ans = max(ans, dp[i][T - 1] + v[i].second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 74228
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define POWT(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODI 10000
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

signed main() {
	int a, b, c,n;
	while (scanf("%d %d %d", &a, &b, &c)) {
		if (!a && !b && !c)
			break;
		scanf("%d", &n);
		vector<array<int, 3>> hu;
		set<int> cor;
		vector<int> ans(a + b + c, 2);
		REP(i, n) {
			int x, y, z, j;
			scanf("%d %d %d %d", &x, &y, &z, &j);
			x--; y--; z--;
			if (j) {
				cor.insert(x);
				cor.insert(y);
				cor.insert(z);
				ans[x] = 1;
				ans[y] = 1;
				ans[z] = 1;
			}
			else {
				hu.push_back({ x,y,z });
			}
		}

		REP(i, hu.size()) {
			int cou = 0;
			int d;
			REP(j, 3) {
				if (cor.find(hu[i][j]) != cor.end())
					cou++;
				else
					d = hu[i][j];
			}
			if (cou == 2)
				ans[d] = 0;
		}
		REP(i, a + b + c) {
			printf("%d\n", ans[i]);
		}
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> A(3);
    rep(i, N){
        int a;
        cin >> a;
        if(a % 4 == 0) A[0]++;
        else if (a % 2 == 0) A[1]++;
        else A[2]++;
    }

    if(A[1] == 0 && A[2] <= 1 + A[0]) cout << "Yes" << endl;
    else if ( A[1] != 0 && A[2] <= A[0]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
long long modpow(long long a,long long b,long long p)
{
	long long ret=1;
	for(;b>0;b>>=1,a=(a*a)%p)
		if(b&1)
			ret=(ret*a)%p;
	return ret;
}
long long phi(long long n)
{
	long long res=n,t=n;
	for(long long i=2;i*i<=t;i++)
		if(t%i==0)
		{
			res-=res/i;
			while(t%i==0)
				t/=i;
		}
	if(t>1)
		res-=res/t;
	return res;
}
long long gcd(long long a,long long b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
long long exgcd(long long a,long long b,long long &x,long long &y)
{
    if(b==0)
    {x=1;y=0;return a;}
    long long g;
    g=exgcd(b,a%b,y,x);
    y-=a/b*x;
    return g;
}
long long solve(long long A,long long M)
{
	if(M<=500)
	{
		long long s=A;
		for(long long i=1;;i++)
		{
			if(s==i%M)
				return i;
			s=(s*A)%M;
		}
	}
	long long pM,At,d,t,x,y;
	pM=phi(M);
	d=gcd(M,pM);
	t=solve(A,d);
	At=modpow(A,t,M);
	exgcd(M/d,pM/d,x,y);
	x=x*(((t-At)%pM+pM)%pM)/d;
	x=((x%(pM/d))+pM/d)%(pM/d)+pM/d;
	return x*M+At;
}
int main()
{
	int Q;
	long long A,M;
	scanf("%d",&Q);
	while(Q--)
	{
		scanf("%lld%lld",&A,&M);
		printf("%lld\n",solve(A,M));
	}
	return 0;
}


Measured memory_bytes: 128
//Wrong answer on test inf.
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
#define y1 y1___
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
ll read(){
	char ch=gc();ll x=0;int op=1;
	for (;!isdigit(ch);ch=gc()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=gc()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
#define N 105
#define mod 1000000007
int ksm(int x,int p){
	int ret=1;
	for (;p;p>>=1,x=(ll)x*x%mod) if (p&1) ret=(ll)ret*x%mod;
	return ret;
}
int n,h[N];
pii solve(int l,int r,int lim){//区间[l,r]比lim高的部分的方案数
	int mi=inf,cnt=0;pii ret;//first：存在相邻格子颜色相同情况的方案数；second：不存在的方案数（固定第一个格子的颜色）
	rep (i,l,r) if (h[i]<mi) mi=h[i],cnt=1;else if (h[i]==mi) cnt++;
	if (cnt==r-l+1){//矩形
		ret.fi=(ksm(2,r-l+1)+mod-2)%mod;
		ret.se=ksm(2,mi-lim-1);
		return ret;
	}
	int rest=r-l+1,s0=1,s1=1,last=0;//rest：上方没有方格的列数；s0,s1：维护上方有方格的列，当前行存在/不存在的方案数
	rep (i,l,r+1)
		if (!last&&h[i]>mi) last=i;
		else if (last&&(h[i]<=mi||i>r)){
			rest-=i-last;
			pii tmp=solve(last,i-1,mi);//子问题，递归求解
			s0=(ll)s0*(tmp.fi+4ll*tmp.se%mod)%mod;//*4是因为上一行可以取反，当前行亦然，2*2
			s1=(ll)s1*(2ll*tmp.se%mod)%mod;
			last=0;
		}
	s0=(s0+mod-s1)%mod;
	ret.fi=(ll)s0*ksm(2,rest)%mod;//如果上方方格已经存在，剩下的列随意
	ret.fi=(ret.fi+(ll)s1*(ksm(2,rest)+mod-2)%mod)%mod;//否则需要去掉两种不合法的情况
	ret.se=(ll)s1*ksm(2,mi-lim-1)%mod;//固定第一个格子（第一行）颜色
	return ret;
}
int main(){
	n=read();rep (i,1,n) h[i]=read();
	if (n==1){//注意特判
		printf("%d\n",ksm(2,h[1]));
		exit(0);
	}
	int ex=1;
	rep (i,1,n) if (h[i]>h[i-1]&&h[i]>h[i+1]){
		ex=(ll)ex*ksm(2,h[i]-max(h[i-1],h[i+1]))%mod;
		h[i]=max(h[i-1],h[i+1]);
	}
	pii ans=solve(1,n,0);
	printf("%d",(ll)ex*(ans.fi+2ll*ans.se%mod)%mod);
	return 0;
}

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

using namespace std;

int main(){
    int n, m;
    map<string, int> strCount;

    cin >> n;
    string temp;

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

    cin >> m;
    
    for(int i = 0; i < m; i++){
        cin >> temp;
        strCount[temp]--;
    }

    /*
    for(auto i = strCount.begin(); i != strCount.end() ; ++i) {
        std::cout << i->first << " " << i->second << "\n";
    }
    */

    /* find max value in strCount */
    int max = 0;
    for(auto i = strCount.begin(); i != strCount.end(); ++i){
        if(max < i->second){
            max = i->second;
        }
    }

    cout << max;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	A := make([][]int, 3)
	for i := 0; i < 3; i++ {
		A[i] = make([]int, 3)
		for j := 0; j < 3; j++ {
			A[i][j] = nextInt()
		}
	}
	N := nextInt()
	bingoCounter := make([]bool, 100)
	for i := 0; i < N; i++ {
		bingoCounter[nextInt()-1] = true
	}
	if (bingoCounter[A[0][0]-1] && bingoCounter[A[0][1]-1] && bingoCounter[A[0][2]-1]) ||
		(bingoCounter[A[1][0]-1] && bingoCounter[A[1][1]-1] && bingoCounter[A[1][2]-1]) ||
		(bingoCounter[A[2][0]-1] && bingoCounter[A[2][1]-1] && bingoCounter[A[2][2]-1]) ||
		(bingoCounter[A[0][0]-1] && bingoCounter[A[1][0]-1] && bingoCounter[A[2][0]-1]) ||
		(bingoCounter[A[0][1]-1] && bingoCounter[A[1][1]-1] && bingoCounter[A[2][1]-1]) ||
		(bingoCounter[A[0][2]-1] && bingoCounter[A[1][2]-1] && bingoCounter[A[2][2]-1]) ||
		(bingoCounter[A[0][0]-1] && bingoCounter[A[1][1]-1] && bingoCounter[A[2][2]-1]) ||
		(bingoCounter[A[0][2]-1] && bingoCounter[A[1][1]-1] && bingoCounter[A[2][0]-1]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#n , m , l = map(int , input().split())

# list_n = list(map(int , inpuut().split()))<Paste>

#n = input()
# list = [input() for i in range(N)

#list = [[i for i in range(N)] for _ in range(M)]


import math
s = int(input().replace(" ", ""))
n = math.sqrt(s)
if n == int(n):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 8996
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX_M=20;
const int MAX_N=50000;

int main(){
	int dp[MAX_M][MAX_N+1];
	int n,m;
	int c[MAX_M];
	cin>>n>>m;
	int i,j;
	for (i=0;i<m;i++){
		cin>>c[i];
	}
	sort(c,c+m);
	//dp初期化
	for (j=1;j<=n;j++){
		dp[0][j]=j;	//j円を支払うのに必要なコインはj枚
	}
	for (i=0;i<m;i++){
		dp[i][0]=0;	//0円払うのに必要な枚数は0枚
	}
	for (i=1;i<m;i++){
		for (j=1;j<=n;j++){
			if (j-c[i]>=0){
				//コインを使える
				dp[i][j]=min(dp[i][j-c[i]]+1,dp[i-1][j]);
			}
			else{
				//コインを使えない
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	cout<<dp[m-1][n]<<endl;
	return 0;
}

Measured memory_bytes: 5080
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int d;
    cin >> d;
    vector<int> c(26);
    int s[d][26];
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < d; i++){
        for(int j = 0; j < 26; j++) cin >> s[i][j];
    }
    vector<int> t(d);
    for(int i = 0; i < d; i++){
        int a;
        cin >> a;
        a--;
        t[i] = a;
    }
    long long ans = 0;
    map<int,int> last;
    for(int i = 0; i < d; i++){
        ans += s[i][t[i]];
        last[t[i]] = i+1;
        for(int j = 0; j < 26; j++){
            ans -= c[j]*(i+1-last[j]);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
#include<unordered_map>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(int i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding Space*/
typedef tuple<int,int,int> tiii;
ll road[301][301];
int main(){
  int n; cin >> n;
  vector<tiii> v;
  rep(i,n)rep(j,n){
    cin >> road[i][j];
    v.pb(tiii{road[i][j],i,j});
  }
  sort(ALL(v));
  
  ll ans = 0;
  for(auto iii : v){
    int cost,from,to;
    tie(cost,from,to) = iii;
    bool flag = 0;
    rep(i,n){
      if(road[from][i] + road[i][to] < cost){cout << -1 << endl; return 0;}
      if(i != from && i != to && road[from][i] + road[i][to] == cost)
        flag = 1;
      else if(!flag && i == n -1)
        ans += cost;
    }
  }
  cout << ans/2 << endl;
}

Measured memory_bytes: 2424
n = int(input())
a, b, c = [list(map(int, input().split())) for _ in range(3)]
ret = 0
for i in range(n):
    ret += b[a[i] - 1]
    if i > 0 and a[i] == a[i - 1] + 1:
        ret += c[a[i - 1] - 1]
print(ret)

Measured memory_bytes: 38256
#include <iostream>

int main(int argc, char const *argv[]) {
  while(1){
    int H=0,W=0;
    std::cin >> H >> W;
    if(H == 0 && W == 0)break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        std::cout << "#";
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3088
while True:
    N = int(input())
    if N == 0:
        break
    
    first_group_menbers = set(input()[:-1].split(":")[1].split(","))
    d = {}
    for i in range(N-1):
        group, members = input()[:-1].split(":")
        d[group] = set(members.split(","))
        
    for i in range(N-2):
        for group, members in d.items():
            if group in first_group_menbers:
                first_group_menbers.remove(group)
                for m in members:
                    first_group_menbers.add(m)
    
    print(len(first_group_menbers))

Measured memory_bytes: 6776
N = int(input())
A = list(map(int,input().split()))
ans = float("inf")
S = sum(A)
acu = []
acu.append(A[0])
for i in range(1,N-1):
  acu.append(acu[-1] + A[i])
for i in range(N-1):
  ans = min(ans,abs((S - acu[i]) - acu[i]))
print(ans)

Measured memory_bytes: 24936
import sys
r = [0]*26
S = ""
for line in sys.stdin.readlines():
    S += line
for i in S:
    if ord("a") <= ord(i) <= ord("z"):
        r[ord(i)-ord("a")] += 1
    elif ord("A") <= ord(i) <= ord("Z"):
        r[ord(i)-ord("A")] += 1
for i in range(26):
    print(chr(i+97) + " : " + str(r[i]))


Measured memory_bytes: 5568
N = int(input())
numbers = [int(i) for i in input().split()]

cnt_4 = 0
cnt_2 = 0

for n in numbers:
    if n % 4 == 0:
        cnt_4 += 1
    elif n % 2 == 0:
        cnt_2 += 1
    
cnt = cnt_4 + (cnt_2 // 2)

if cnt >= N // 2:
    print('Yes')
else :
    print('No')

Measured memory_bytes: 14252
#include <iostream>

int main() {
    int n;
    std::cin >> n;
    if(n % 2 == 0) {
        std::cout << ((n / 2) * (n / 2)) << std::endl;
    } else {
        std::cout << ((n / 2) * (n / 2 + 1)) << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;


int main(void){
    int n;
    cin>>n;
    vector<int> A(n);
    rep(i,n) cin>>A[i];
    vector<int> lgcds(n),rgcds(n);
    lgcds[0]=A[0];
    rep(i,n-1) lgcds[i+1]=__gcd(lgcds[i],A[i+1]);
    /*rep(i,n) cout<<lgcds[i]<<" ";
    cout<<endl;*/
    rgcds[n-1]=A[n-1];
    for(int i=n-2;i>=0;--i) rgcds[i]=__gcd(rgcds[i+1],A[i]);
    /*rep(i,n) cout<<rgcds[i]<<" ";
    cout<<endl;*/
    
    int ans=max(lgcds[n-2],rgcds[1]);
    rep(i,n-2){
        int temp=__gcd(lgcds[i],rgcds[i+2]);//A[i+1]以外のgcd
        //cout<<i<<" "<<temp<<endl;
        ans=max(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4580
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int MOD = (int)(1e9) + 7;
const int INF = (1ll << 31) - 1;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct SegmentTree {
	int n;
	vector<int>d;
	SegmentTree(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
	}
	void update(int i, int x) {
		d[n + i] = x;
		for (int j = (n + i) / 2; j > 0; j >>= 1)d[j] = min(d[2 * j], d[2 * j + 1]);
	}
	int find(int a, int b, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		if (r <= a || b <= l)return INF;
		else if (a <= l&&r <= b)return d[k];
		else return min(find(a, b, 2 * k, l, (l + r) / 2), find(a, b, 2 * k + 1, (l + r) / 2, r));
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q; cin >> N >> Q;
	SegmentTree seg(N);
	rep(i, 0, Q) {
		int com, x, y; cin >> com >> x >> y;
		if (com)cout << seg.find(x, y + 1) << endl;
		else seg.update(x, y);
	}
	return 0;
}

Measured memory_bytes: 3836
X,N  = map(int,input().split())

ans = X
if N !=0:
  P = list(map(int,input().split()))
  ansR = X
  ansL = X
  while True:
    if ansR in P and ansL in P:
      ansR +=1
      ansL -=1
    else:
      ans = min(ansR,ansL)
      if ans in P:
        print(max(ansR,ansL))
        break
      else:
        print(ans)
        break
else:
  print(ans)


Measured memory_bytes: 9192
import bisect

N=int(input())
L=list(map(int, input().split()))
ll=len(L)
L.sort()

s=0
for i in range(ll):
    for j in range(i+1,ll):
        s+=bisect.bisect_right(L,L[i]+L[j]-1)-j-1

print(s)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

int H, W;

vi judgetate(100), judgeyoko(100);
vector<vector<char>> masu(100, vector<char>(100));

int main()
{
  int H, W;
  cin >> H >> W;

  rep(i, H)
  {
    rep(j, W)
    {
      cin >> masu[i][j];
    }
  }

  rep(i, W)
  {
    judgetate[i] = 0;
    rep(j, H)
    {
      if (masu[j][i] == '#')
      {
        judgetate[i] = 1;
      }
    }
  }

  rep(i, H)
  {
    judgeyoko[i] = 0;
    rep(j, W)
    {
      if (masu[i][j] == '#')
      {
        judgeyoko[i] = 1;
      }
    }
  }

  rep(i, H)
  {
    rep(j, W)
    {
      if (judgetate[j] == 1 && judgeyoko[i] == 1)
        cout << masu[i][j];
    }
    if (judgeyoko[i] == 1)
      cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int sum=0;
  for(int i=0;i<n;i++) sum+=a[i];
  int ans=abs(sum-a[0]*2),tmp=0;
  for(int i=0;i<n-1;i++){
    tmp+=a[i];
    if(i) ans=min(ans,abs(sum-tmp*2));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <chrono>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <cctype>
# include <unordered_map>
# include <unordered_set>
//#include <bits/stdc++.h>
 
#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
#define forn(i, n) for (int i = 0; i < (n); i++)
#define forx(i,x,n) for (int i = x; i < (n); i++)
#define form(i, n) for (int i = n-1; i>=0; i--)
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define pf push_front
#define mp make_pair
#define ll long long
#define ld long double
#define ull unsigned ll
#define srt(a) sort(a.begin(), a.end());
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pld pair<ld,ld>
#define ar array
#define endl '\n';
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }
 
const ll MAXN = 2e5 + 7, K = 200043, M = 1000043, INF = 1e18 + 7;
// the good way to get PI number
const ld PI = acos(-1.0);
ll MOD = 1e9 + 7;

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

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

ll sum(ll a, ll b) {
    return ((a % MOD) + (b % MOD)) % MOD;
}

ll sub(ll a, ll b) {
    return sum(a, MOD - b);
}

ll bin_pow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = mul(res, a);
        a = mul(a, a);
        n >>= 1;
    }
    return res;
}

ll inv(ll x) {
    return bin_pow(x, MOD - 2) % MOD;
}

ll fact[MAXN];

ll C(ll n, ll k) {
    return mul(mul(fact[n], inv(fact[k])), inv(fact[n - k]));
}

void solve() {
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    
    fact[0] = 1;
    for (ll i = 1; i < MAXN; ++i)
        fact[i] = mul(fact[i - 1], i);
    
    ll ans = 0;
    for (ll i = b + 1; i <= w; ++i)
        ans = sum(ans, mul(C(h - a + i - 2, i - 1), C(w - i + 1 + a - 2, a - 1)));
    
    cout << ans << endl;
}

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


Measured memory_bytes: 5124
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;


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

	if (k % 2 == 0) {
		cout << a - b << endl;
	}
	else {
		cout << b - a << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.NavigableSet;
import java.util.Scanner;
import java.util.TreeSet;

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

        int N = sc.nextInt();
        int[] P = new int[N];
        int[] pos = new int[N];

        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt() - 1;
            pos[P[i]] = i;
        }

        NavigableSet<Integer> used = new TreeSet<>();
        long sol = 0;

        for (int p = N - 1; p >= 0; p--) {
            int i = pos[p];

            Integer firstLower = used.lower(i);
            firstLower = firstLower == null ? -1 : firstLower;

            Integer secondLower = used.lower(firstLower);
            secondLower = secondLower == null ? -1 : secondLower;

            Integer firstHigher = used.higher(i);
            firstHigher = firstHigher == null ? N : firstHigher;

            Integer secondHigher = used.higher(firstHigher);
            secondHigher = secondHigher == null ? N : secondHigher;

            long times = ((long) (firstLower - secondLower)) * (firstHigher - i);
            times += ((long) (i - firstLower)) * (secondHigher - firstHigher);

            sol += times * (p + 1);
            used.add(i);
        }

        System.out.println(sol);
    }
}


Measured memory_bytes: 66092
N = int(input().rstrip())
A = [int(_) for _ in input().rstrip().split(" ")]
Q = int(input().rstrip())
M = [int(_) for _ in input().rstrip().split(" ")]

import itertools

from functools import lru_cache

@lru_cache(maxsize=2**12)
def solve(i, m):
    if m == 0:
        return True
    elif i >= N:
        return False
    res = solve(i+1, m) or solve(i+1, m - A[i])
    return res
        
        
for m in M:
    if solve(0, m):
        print("yes")
    else:
        print("no")


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

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

 int main() {
   ll N, M;
   cin >> N >> M;
   cout << (100 * N + 1800 * M) * pow(2, M) << endl;
 }


Measured memory_bytes: 256
#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>

#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())

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

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

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

void solve() {
    int a,b;
    cin >> a >> b;
    if (a + b == 15) cout << "+" << endl;
    else if (a * b == 15) cout << "*" << endl;
    else cout << "x" << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100001];
int n, k;
long long ans = 1;
const long long MOD = 1e9+7;
void fail() {
	cout << 0;
	exit(0);
}
void dfs(int i, int p, int par, int sib) {
	int nxt = 0;
	int mult = k-par-sib;
	if(mult <= 0)
		fail();
	ans *= mult;
	ans %= MOD;
	for(int a: adj[i]) {
		if(a == p) continue;
		dfs(a, i, min(par+1, 2), nxt++);
	}
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> n >> k;
	for(int i=0; i<n-1; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(1, 0, 0, 0);
	cout << ans;
}

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

int main(){
    string s; cin>>s;
    int n=s.size();
    ll ans=0;
    int b=0;
    int i=0;
    for (int i=0; i<n; i++){
        if(s[i]=='B') b++;
        if(s[i]=='W') ans+=b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3716
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
using namespace std;
int main() {
	while(true) {
	int a, b;
	int dp[17][17] = { 0 };
	scanf("%d%d", &a, &b);
	if (a == 0 && b == 0) break;
		int n;
		scanf("%d", &n);
		bool kousa[17][17] = { false };
		for (int i = 1;i <= n;++i) {
			int c, d;
			scanf("%d%d", &c, &d);
			kousa[c][d] = true;
		}
		dp[1][1] = 1;
		for (int i = 1;i <= a;++i) {
			for (int q = 1;q <= b;++q) {
				if (kousa[i][q] == false) {
					if (i != 1 || q != 1)
						dp[i][q] = dp[i][q - 1] + dp[i - 1][q];
				}
			}
		}
		printf("%d\n", dp[a][b]);
	}
}


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

int N;
vector<int> kids[100000];

int height(int v) {
  int n = kids[v].size();
  vector<int> heights;
  for(int w : kids[v]) heights.push_back(height(w));
  sort(heights.begin(), heights.end());
  int res = 1;
  for(int i = 0; i < n; ++i) {
    res = max(res, n - i + heights[i]);
  }
  return res;
}

int main() {
  cin >> N;
  for(int i = 1; i <= N - 1; ++i) {
    int A; cin >> A; --A; kids[A].push_back(i);
  }
  cout << height(0) - 1 << endl;
  return 0;
}


Measured memory_bytes: 15104
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a,b,c int
	fmt.Scan(&a,&b,&c)
	
	nums := []int{a,b,c}
	
	sort.Sort(sort.IntSlice(nums))
	
	if nums[0] == 5 && nums[1] == 5 && nums[2] == 7 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI mar;
void fs(){
  cout<<"First\n";
  exit(0);
}
void sc(){
  cout<<"Second\n";
  exit(0);
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  mar.resize(n);
  forn(i,n)
    cin>>mar[i];
  sort(all(mar));
  in rm=0;
  while(sz(mar)>=2 && mar[sz(mar)-2]>rm+1){
    mar.pop_back();
    ++rm;
  }
  in le=mar.back()-rm;
  in c1=0;
  for(in i=sz(mar)-2;i>=0;--i){
    if(mar[i]==rm+1)
      ++c1;
  }
  if(le==1){
    if(c1%2==0)
      sc();
    fs();
  }
  if(c1==0){
    if(le%2==1)
      sc();
    fs();
  }
  if(le%2==0)
    fs();
  if(c1%2==1)
    fs();
  sc();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	int N;
	cin >>N;
	
	vector<int> d(N);
	for(int i=0;i<N;++i){
		cin >> d.at(i);
	}
	
	int sum = 0;
	
	for(int i=0; i<N; i++){
		
		for(int j=0; j<N; j++){
			sum += d.at(i)*d.at(j);
		}			
		
	}
	
	for(int i=0; i<N; i++){
		
		sum -= d.at(i)*d.at(i);
		
	}
	
	sum /= 2;
	cout <<sum <<endl;
	
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, d, x;
    cin >> n >> d >> x;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=d;j+=a[i]){
            ans++;
        }
    }
    cout << ans+x << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace abc170A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = 0;
            for(int n = 0; n < 5; n++)
            {
                A = int.Parse(str[n]);
                if (A == 0)
                    Console.WriteLine(n + 1);
            }
        }
    }
}


Measured memory_bytes: 27500
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  string s;
  cin >> s;
  string a = "maerd", b = "remaerd", c = "esare", d = "resare";
  bool A, B, C, D;
  for(int i = s.size() - 1;i >= 0;i --){
    A = B = C = D = true;
    //dream
    rep(j, 5){
      if(s[i - j] != a[j]){
	A = false;
      }
    }

    //dreamer
    rep(j, 7){
      if(s[i - j] != b[j]){
	B = false;
      }
    }

    //erase
    rep(j, 5){
      if(s[i - j] != c[j]){
	C = false;
      }
    }

    //eraser
    rep(j, 6){
      if(s[i - j] != d[j]){
	D = false;
      }
    }
    //cout << i << " ";
    if(A){
      i -= 4;
    } else if(B){
      i -= 6;
    } else if(C){
      i -= 4;
    } else if(D){
      i -= 5;
    } else {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<short int,short int>P;

string A,B;
short int nex_A[5005][2],nex_B[5005][2];
short int dp[5005][5005];
short int X[5005][5005];
P NEX[5005][5005];

void make_nex(){
  int i_0=A.size()-1;
  int i_1=A.size()-1;
  for(int i=A.size()-1;i>=0;i--){
    nex_A[i][0] = i_0;
    nex_A[i][1] = i_1;
    if(A[i]=='0')i_0=i;
    if(A[i]=='1')i_1=i;
  }
  i_0=B.size()-1;
  i_1=B.size()-1;
  for(int i=B.size()-1;i>=0;i--){
    nex_B[i][0] = i_0;
    nex_B[i][1] = i_1;
    if(B[i]=='0')i_0=i;
    if(B[i]=='1')i_1=i;
  }
}

int dfs(int l,int r){

  if(dp[l][r]!=-1) return dp[l][r];
  if(l==A.size()-1 && r==B.size()-1) return 0;

  int L = dfs( nex_A[l][0] , nex_B[r][0] );
  int R = dfs( nex_A[l][1] , nex_B[r][1] );

  if( L <= R ) NEX[l][r] = P( nex_A[l][0] , nex_B[r][0] ) , X[l][r] = 0 ;
  if( L >  R ) NEX[l][r] = P( nex_A[l][1] , nex_B[r][1] ) , X[l][r] = 1 ;

  return dp[l][r] = min( L , R ) + 1;

}

int main(){
  r(l,5005)r(r,5005) NEX[l][r] = P(-1,-1);
  memset(dp,-1,sizeof(dp));
  cin>>A>>B;
  A="@"+A+"@";
  B="@"+B+"@";
  make_nex();
  dfs(0,0);

  int l=0,r=0;

  while( NEX[l][r] != P(-1,-1) ){
    cout<<X[l][r];
    P p = NEX[l][r];
    l=p.first;
    r=p.second;
  }

  cout<<endl;
}


Measured memory_bytes: 182108
//## MohK
#include <bits/stdc++.h>
using namespace std;
int main()
 {
     int x;
     cin>>x;
     if(x<=111)
     {
         cout<<111;
     }
     else if(x>111&&x<=222)
     {
         cout<<222;
     }
     else if(x>222&&x<=333)
     {
         cout<<333;
     }
     else if(x>333&&x<=444)
     {
         cout<<444;
     }
     else if(x>444&&x<=555)
     {
         cout<<555;
     }
     else if(x>555&&x<=666)
     {
         cout<<666;
     }
     else if(x>666&&x<=777)
     {
         cout<<777;
     }
     else if(x>777&&x<=888)
     {
         cout<<888;
     }
     else if(x>888&&x<=999)
     {
         cout<<999;
     }




	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 1000;
    ll mini = 300, maxi = 0;
    rep(i, n) {
        mini = min(mini, a[i]);
        maxi = max(maxi, a[i]);
        if (i + 1 >= n || a[i] >= a[i + 1]) {
            if (mini == maxi) {
                if (a[i] > a[i + 1]) {
                    mini = 300;
                    maxi = 0;
                }
                continue;
            }
            ans += (maxi - mini) * ll(ans / mini);
            mini = 300;
            maxi = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3564
#include<iostream>

using namespace std;

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

int n, b[1000000], bb[1000000];

int main() {
  while (true) {
    cin >> n;
    if (n == 0) break;
    rep (i, n) cin >> b[i];
    rep (i, 10001) {
      bool f = true;
      rep (j, n) if (b[j] != j + 1) {
	f = false;
	break;
      }
      if (f) {
	cout << i << endl;
	goto next;
      }
      rep (j, n) --b[j];
      b[n] = n;
      int k = 0;
      rep (j, n + 1) if (b[j] > 0) bb[k++] = b[j];
      n = k;
      rep (j, n) b[j] = bb[j];
    }
    cout << -1 << endl;
  next:;
  }
  return 0;
}

Measured memory_bytes: 3216
import java.util.Scanner;
import java.util.Stack;


public class Main {

	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		
		while( sc.hasNextLine() ) {
			String input[] = sc.nextLine().split(" ");
			
			Stack<Double> a = new Stack<Double>();
			int i = 0;
			while ( input.length > i ) {
				if ( !Character.isDigit( input[i].charAt(0) ) && input[i].toCharArray().length == 1 ) {
					char c = input[i].charAt(0);
					Double pop1 = a.pop();
					Double pop2 = a.pop();
					if ( c == '+' ) {
						a.push( pop2 + pop1 );
					} else if ( c == '-' ) {
						a.push( pop2 - pop1 );
					} else if ( c == '*' ) {
						a.push( pop2 * pop1 );
					} else if ( c == '/' ) {
						a.push( pop2 / pop1 );
					}
				} else {
					a.push( Double.valueOf( input[i] ) );
				}
				
				i++;
			}
			System.out.println( a.pop() );
		}
	}
	

}

Measured memory_bytes: 17200