akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    while(1) {
        int H,W;
        cin >> H >> W;
        if (H+W==0){
            break;
        }
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                if((i+j)%2==0) cout <<'#';
                else cout <<'.';
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, m, x, cost[15], skill[15][15], ans = 1e9;

int main() {
	fastio; cin >> n >> m >> x;
	FOR(i, 1, n) {
		cin >> cost[i];
		FOR(j, 1, m) cin >> skill[i][j];
	}
	FOR(i, 0, (1<<n)-1) {
		int ok[15], cur = 0; memset(ok, 0, sizeof ok);
		FOR(j, 1, n) if (i & (1<<(j-1))) {
			cur += cost[j];
			FOR(k, 1, m) ok[k] += skill[j][k];
		}
		bool can = 1;
		FOR(j, 1, m) if (ok[j] < x) can = 0;
		if (can) ans = min(ans, cur);
	}
	cout << (ans == 1e9 ? -1 : ans);
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  if (S=="abc" || S=="acb" || S=="bac" || S=="bca" || S=="cab" || S=="cba"){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    bool prime[1000000];
    for(int i=0;i<1000000;i++)prime[i]=true;
    prime[0]=prime[1]=false;
    for(int i=0;i<1005;i++){
        if(prime[i]){
            for(int j=i*2;j<1000000;j+=i)prime[j]=false;
        }
    }
    int n;
    while(cin>>n){
        for(int i=n-1;i>0;i--){
            if(prime[i]){
                cout<<i<<" ";
                break;
            }
        }
        for(int i=n+1;i<100000;i++){
            if(prime[i]){
                cout<<i<<endl;;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 2136
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

typedef long long Int;

Int gcd(Int a, Int b) {
  return b==0 ? a : gcd(b, a%b);
}
Int lcm(Int a, Int b) {
  // printf("%lld,%lld  %lld\n",a,b,gcd(a,b));
  return a / gcd(a,b) * b;
}
Int gcd(vector<Int> v) {
  Int res = 0;
  REP(i,v.size()) {
    if (!i) res = v[0];
    else res = gcd(res,v[i]);
  }
  return res;
}
Int lcm(vector<Int> v) {
  Int res = 1;
  FOR(it,v)
    res = lcm(res, *it);
  return res;
}

int main() {
  int n;
  while(cin >> n, n) {
    vector<Int> d(n), v(n);
    REP(i,n)
      cin >> d[i] >> v[i];
    Int l = lcm(d);
    // cout << " "<<l << endl;
    vector<Int> ans;
    REP(i,n)
      ans.push_back(l / d[i] * v[i]);
    Int g = gcd(ans);
    REP(i,n)
      cout << ans[i] / g << endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include <numeric>
using namespace std;
string str;
int main() {
    cin >> str;
    bool flag=false;
    for(int i=0; i<str.size()-1; ++i){
        if(str[i]=='A'&&str[i+1]=='C'){
            cout << "Yes" << endl;
            flag = true;
        }
        if(flag) break;
    }
    if(!flag) cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int vis[85]={0};
void init(){
    int k;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=i;j++){
            k = i * j;
            vis[k] = 1;
        }
    }
}
int main(){
    init();
    int n;
    cin>>n;
    if(n>81){
        cout<<"No";
    } else {
        if(vis[n]){
            cout<<"Yes"<<endl;
        } else {
            cout<<"No"<<endl;
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

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

    vector<pair<int,int>> wv(n);
    int weight[4] = {0,};
    vector<ll> value[4];
    vector<ll> value_sum[4];
    for(int i=0;i<n;i++){
        cin >> wv[i].first >> wv[i].second;
        weight[wv[i].first-wv[0].first]++;
        value[wv[i].first-wv[0].first].push_back(wv[i].second);
        value_sum[wv[i].first-wv[0].first].push_back(wv[i].second);
    }
    for(int i = 0; i < 4; i++){
        value_sum[i].push_back(0);
        sort(value[i].begin(),value[i].end());
        reverse(value[i].begin(),value[i].end());
        sort(value_sum[i].begin(),value_sum[i].end());
        for(int j = 1; j < value_sum[i].size(); j++){
            value_sum[i][j] = value_sum[i][j-1] + value[i][j-1];
        }
    }
    ll min_weight = wv[0].first;
    ll max_value = 0;
    for(int i=0;i<weight[3]+1;i++){
        for(int j=0;j<weight[2]+1;j++){
            for(int k=0;k<weight[1]+1;k++){
                for(int l=0;l<weight[0]+1;l++){
                    if((min_weight+3)*i+(min_weight+2)*j+(min_weight+1)*k+(min_weight)*l <= W){
                        max_value = max(max_value,value_sum[3][i]+value_sum[2][j]+value_sum[1][k]+value_sum[0][l]);
                    }else{
                        break;
                    }
                }
            }
        }
    }
    cout << max_value << endl;

}


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

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

    if(a.at(0)==b.at(2) && a.at(1)==b.at(1) && a.at(2)==b.at(0))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

long long n,m;

int main(){
    cin >> n >> m;
    if(abs(n-m) >= 2){
        cout << "0\n";
        return 0;
    }

    long long ans = 1;
    for(int i = n; i > 0; i--){
        ans *= i;
        ans %= 1000000007;
    }
    long long ans2 = 1;
    for(int i = m; i > 0; i--){
        ans2 *= i;
        ans2 %= 1000000007;
    }
    if(n == m){
        cout << (ans2 * ans * 2) % 1000000007 << endl;
    }
    else{
        cout << (ans2 * ans) % 1000000007 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a;
	cin >> a;
	int c = a % 10;
	if (c == 3)cout << "bon" << endl;
	else if (c == 0 || c == 1 || c == 6 || c == 8)cout << "pon" << endl;
	else cout << "hon" << endl;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int getTwo(int n) {
    int cnt = 0;
    while (n) {
        if (n % 2) break;
        else cnt++;
        n /= 2;
    }
    return cnt;
}
int main()
{
    int N;
    cin >> N;

    vector<int> a(N);
    rep(i, N) cin >> a[i];

    int ans = 0;
    rep(i, N) {
        ans += getTwo(a[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
  H,N = map(int,input().split())
  AB = [list(map(int,input().split())) for _ in range(N)]
  mi_a,mi_b = min(AB,key = lambda x:x[1])
  INF = float('inf')
  dp = [0]+[mi_b]*mi_a+[INF]*H
  for i in range(mi_a+1,H+1):
    mi = float('inf')
    for a,b in AB:
      mi = min(mi,dp[max(0,i-a)]+b)
    if dp[i]>mi:
      dp[i] = mi

  print(dp[H])
  
main()

Measured memory_bytes: 42732
#include<iostream>
using ll = long long;
using namespace std;
ll gcd(ll x,ll y){
	if(x<y)	swap(x,y);
	if(y==0)	return x;
	return gcd(y,x%y);
}
int main(){
	ll a,b;
	cin >> a >> b;
	cout << gcd(a,b) << endl;
	return 0;
}


Measured memory_bytes: 3104
import math
N,K = map(int,input().split())
mod = 1000000007

for j in range(K):
    i = j+1
    p = N-K+1-i
    if p <0:
        p = 0
    x = math.factorial(K-1)//(math.factorial(K-i)*math.factorial(i-1))
    y = math.factorial(N-K+1)//(math.factorial(p)*math.factorial(i))
    ans = x*y
    ans = int(ans%mod)
    print(ans)
    

Measured memory_bytes: 3316
#include<stdio.h>
#define MAX 100000
#define NIL -1
 
typedef struct {
  int par;
  int left;
  int right;
}Node;
 
Node T[MAX];
int n,A=0,D[MAX];
 
 int rec(int n){
  int m=0;
  while(1){
    n=T[n].par;
    if(n==NIL) break;
    m++;
  }
  return m;
}
 
 
void print(int n){
  int i,c;
  printf("node %d: parent = %d, depth = %d, ",n,T[n].par,D[n]);
 
  if(T[n].par==NIL) printf("root, ");
  else if(T[n].left==NIL) printf("leaf, ");
  else printf("internal node, ");
 
  printf("[");
  for(i=0,c=T[n].left;c!=NIL;i++,c=T[c].right){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int main(){
  int i,a,b,j,c,l;
   
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    T[i].par=NIL;
    T[i].left=NIL;
    T[i].right=NIL;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      if(j==0) T[a].left=c;
      else T[l].right=c;
      T[c].par=a;
      l=c;
    }
  }
   
  for(i=0;i<n;i++){
    D[i]=rec(i);
    if(D[i]>A){
      A=D[i];
    }
  }  
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<vector<int>> v(10);
    rep(i, n) v[s[i] - '0'].push_back(i);
    rep(i, 10) {
        v[i].push_back(INF);
    }
    int ans = 0;
    rep(i, 10) rep(j, 10) rep(k, 10) {
        int a = *upper_bound(all(v[i]), -1);
        if (a == INF) continue;
        int b = *upper_bound(all(v[j]), a);
        if (b == INF) continue;
        int c = *upper_bound(all(v[k]), b);
        if (c == INF) continue;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt(){
		return Integer.parseInt(s.next());
	}
	public static void main(String[]$){
		int n=gInt();
		int[] a=in(n),
				b=in(n),
				c=in(n);
		long[] v1=new long[n],v2=new long[n];
		{
			int v=0;
			for(int i=0;i<n;++i){
				for(;v<n&&a[v]<b[i];++v){
				}
				v1[i]=v;
			}
		}
		Arrays.parallelPrefix(v1,Long::sum);
		{
			int v=0;
			for(int i=0;i<n;++i){
				for(;v<n&&b[v]<c[i];++v){
				}
				v2[i]=v==0?0:v1[v-1];
			}
		}
		System.out.println(Arrays.stream(v2).sum());
	}
	static int[] in(int n){
		return IntStream.range(0,n).map(i->gInt()).sorted().toArray();
	}
}

Measured memory_bytes: 68884
#include<iostream>

using namespace std;

static const int MAXN = 100;

int main() {
  int n, A[MAXN];

  cin >> n;

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

  for (int l = 0; l < n; l++) {
    /* code */
    if (l > 0) {
      cout << " ";
    }
    cout << A[l];
  }
  cout << endl;

  for (int i = 1; i < n; i++) {

    int j = i - 1;
    int value = A[i];

    while (j >= 0 && value < A[j]) {
        A[j+1] = A[j];
        A[j] = value;
      j--;
    }

    for (int l = 0; l < n; l++) {
      /* code */
      if (l > 0) {
        cout << " ";
      }
      cout << A[l];
    }
    cout << endl;
  }

}

Measured memory_bytes: 3072
#include<stdio.h>
#include<math.h>

int main(void){
    int n,S[1000];
    int i,sum;
    double m,a,sumA;

    while(1){
        scanf("%d",&n);
        if(n==0) break;
        sum=0;

        for(i=0;i<n;i++){
            scanf("%d",&S[i]);
            sum+=S[i];
        }
        m=(double)sum/n;

        sumA=0;
        for(i=0;i<n;i++){
            sumA+= (S[i]-m)*(S[i]-m);
        }
        printf("%.8f\n",sqrt(sumA/n));
    }
    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int A,B;
cin >> A >> B;
int a[13] = {0};
a[A] = 1;
a[B] = 1;
int x = a[1] + a[3] + a[5] + a[7] + a[8] + a[10] + a[12];
int y = a[4] + a[6] + a[9] + a[11];
string ans = "No";
if(A!=2&&B!=2) {
  if(x==2||y==2) ans ="Yes";
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();

		if (k <= a) {
			System.out.println(a - k + " " + b);
			return;
		}
		if (k <= a + b) {
			System.out.println(0 + " " + (b - k + a));
			return;
		}
		System.out.println("0 0");
	}

}

Measured memory_bytes: 21844
import sys
#sys.exit()
#sorted( ,reverse=True)
N = int(input())
#S,T = map(int, input().split())
A = list(map(int, input().split()))
#print(N)
#print(S,T)
#print(A)
ans = [0,]*N
for a in A:
    ans[a-1] += 1
for b in ans:
    print(b)
    

Measured memory_bytes: 32228
#include <iostream>

using ll = long long int;

constexpr int MAX_N = 1e5 + 1;

bool used[MAX_N];

int main()
{
    int n, m;

    std::cin >> n >> m;

    if (n % 2)
    {
        for (int i = 1; i <= m; ++i)
        {
            std::cout << i << ' ' << n + 1 - i << std::endl;
        }
    }
    else
    {
        int x = n - ((n + 2) / 4 * 2 + 1);
        x = (x + 1) / 2;
        for (int i = 1; i <= m && i <= x; ++i)
        {
            std::cout << i << ' ' << n + 1 - i << std::endl;
        }

        for (int i = x + 1; i <= m; ++i)
        {
            std::cout << i << ' ' << n - i << std::endl;
        }
    }

    return 0;
}

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

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

int main() {

  while(true) {
    int n, x;
    int count = 0;
    cin >> n >> x;
    if(n == 0 && x == 0) break;

    for(int i = 1; i < n; i++) {
      for(int j = i + 1; j < n; j++) {
        if(x-i-j >= j+1 && x-i-j <= n) count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}


Measured memory_bytes: 3084
# 標準入力
A = int(input())
B = int(input())
C = int(input())
X = int(input())

x = X // 50

cnt = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 10*a + 2*b + c == x:
                cnt += 1
            else:
                c += 1
        b += 1
    a += 1

print(cnt)


Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main()
{
    ll n,k;
    cin >> n >> k;
    ll ans=0;
    ll v=n/k;
    if(k%2==0){
        ll d=k/2;
        ll num=n/d;
        num-=v;
        ans+=num*num*num;
    }
    ans+=v*v*v;
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct Point{
  int x,y;
  bool operator<(const Point & p) const{
    return x < p.x; 
  }
};
int main(){
  int n,m;cin>>n>>m;
  int i,j,k;
  Point p[n];
  for(i=0;i<n;i++) scanf("%d %d",&p[i].x,&p[i].y);
  sort(p,p+n);
  int sx,sy,tx,ty;
  for(i=0;i<m;i++){
    scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
    int ans = 0;
    for(j=0;j<n;j++) {
      if(sx<=p[j].x&&p[j].x<=tx&&sy<=p[j].y&&p[j].y<=ty){
	ans++;
      }
      if(tx<p[j].x) break;
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define pi 3.14159265358979323846264338327950L
#define loop(i,a,b) for(int i=a;i<b;i++)
int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    int A,B,H,M;
    cin>>A>>B>>H>>M;
    long double h=((H*30)+(0.5*M));
    long double m=(0.2*M)*30;
    long double theta=fabs(h-m);
    long double rad=(pi/180)*theta;
    long double ans=(long double)(A*A+B*B)-(long double)(2*A*B*cosl(rad));
    cout<<setprecision(20)<<sqrtl(ans)<<endl;



    return 0;
}


Measured memory_bytes: 4172
#include <stdio.h>

int main(void) {
	int A;
	int B;
	int res;

	scanf("%d", &A);
	scanf("%d", &B);

	res = A + B;

	if (res < A - B)
	{
		res = A - B;
	}
	if (res < A * B)
	{
		res = A * B;
	}

	printf("%d", res);


	return 0;
}

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

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    long long x, y, ans = 1e9 + 10;
    cin >> x >> y;
    if (y == 100) {
        if (x == 0) {
            cout << 101 << endl;
            return 0;
        }
        if (x == 1) {
            cout << y * 101 << endl;
            return 0;
        } else if (x == 2) {
            cout << y * 10000 + 10000 << endl;
            return 0;
        }
        return 0;
    }
    if (x == 0) {
        cout << y << endl;
    } else if (x == 1) {
        cout << y * 100 << endl;
    } else {
        cout << y * 10000 << endl;
    }
}

Measured memory_bytes: 256
import collections
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

grA = dict(collections.Counter(d))
grB = dict(collections.Counter(t))
#print(grA,grB)

for numB,cntB in grB.items():
  #print(numB,grA[numB])
  try:
    if grA[numB] < cntB:
      print("NO")    
      exit()
  except KeyError:
    print("NO")    
    exit()
    
print("YES")

Measured memory_bytes: 69340
S = list(input())


#print(S)



count = 0
max = 0
for _ in range(len(S)):
    if(S[_] == 'A' or S[_] == 'C' or S[_] == 'G' or S[_] == 'T'):
        count = count + 1

        if(count > max): max = count
    else:
        count = 0

print(max)


Measured memory_bytes: 2940
#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()
//
int main(){
   int N,M;cin>>N>>M;
   vector<pair<int,int>> v;
   rep(i,M) {
      int a,b;
      cin>>a>>b;
      v.push_back(pair<int,int>(a,b));
   }
   int ans=0;
   vector<int> mi,ma;
   rep(i,M){
      mi.push_back(v[i].first);
      ma.push_back(v[i].second);
   }
   int s=*min_element(all(ma)),t=*max_element(all(mi));
   if(s-t<0) ans=0;
   else ans=s-t+1;
   cout<<ans<<endl;
}



Measured memory_bytes: 2292
N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for i in range(N)]
tmp = [[0]*N for i in range(8)]

for n, _ in enumerate(xyz):
    x,y,z = _
    tmp[0][n] = x+y+z
    tmp[1][n] = x+y-z
    tmp[2][n] = x-y+z
    tmp[3][n] = x-y-z
    tmp[4][n] = -x+y+z
    tmp[5][n] = -x+y-z
    tmp[6][n] = -x-y+z
    tmp[7][n] = -x-y-z

result = -float("inf")
for i in range(8):
    result = max(result, sum(sorted(tmp[i], reverse=True)[:M]))
print(result)


Measured memory_bytes: 3700
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.split("\n");
var q=arr[0].split(" ").map(Number)[1];
var s = arr[1];
var a=[0,0];
var cnt=0;
for(var i=1;i<s.length;i++){
   if(s[i]=="C" && s[i-1]=="A")cnt++;
   a.push(cnt);
}
var ans=[];
while(ans.length < q) {
   var lr=arr[ans.length+2].split(" ");
   ans.push(a[parseInt(lr[1])]-a[parseInt(lr[0])]);
}
console.log(ans.join("\n"));

Measured memory_bytes: 34744
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;

int main(){
    int w, a, b; cin >> w >> a >> b;
    int ans;
    
    if(a > b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    
    if(a + w < b){
        ans = b - (a + w);
    }else{
        ans = 0;
    }
    
    cout << ans << endl;
}



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

typedef long long ll;
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(c) c.begin(),c.end()
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
#define pu push
#define pb push_back
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
const ll MOD = 1000000007;
const int inf = 1000000001;
const ll INF = 1e16;
ll i,j,k;
// #define max 105

ll digit(ll temp){
    ll num_di=0;
    while(temp != 0){
        temp = temp/10;
        num_di++;
    }
    return num_di;
}
int main(){
    fio();
    ll N,a,b,dig_a,dig_b,local_max,ans;
    cin>>N;
    ans = 15;
    for(i=1;i*i<=N;i++){
        if(N%i == 0){
            a = i;
            b = N/i;
            dig_a = digit(a);
            dig_b = digit(b);
            if(dig_a > dig_b)
                local_max = dig_a;
            else    
                local_max = dig_b;
            
            if(local_max < ans){
                ans = local_max;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
using System;
using System.Globalization;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var MD1 = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var M1 = MD1[0];
            var D1 = MD1[1];
            //var MD2 = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            //var M2 = MD2[0];
            //var D2 = MD2[1];

            DateTime dateTime;
            if (DateTime.TryParseExact("2019" + M1.ToString("00") + D1.ToString("0"), "yyyyMMdd", null, DateTimeStyles.None, out dateTime))
                Console.WriteLine(dateTime.Day == DateTime.DaysInMonth(2019, M1) ? "1" : "0");
            else
                Console.WriteLine("0");
        }
    }
}

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

typedef long long ll;

int g[10][10];

int main(int argc, char const *argv[])
{
    int n,m;scanf("%d %d",&n,&m);
    for (int i = 0; i < m; ++i)
    {
        int a,b;scanf("%d %d",&a,&b);
        a--,b--;
        g[a][b] = g[b][a] = 1;
    }
//    cout << g[0][1] << " " << g[1][0] << endl;
    vector<int> v(n-1);
    int ans = 0;
    iota(v.begin(),v.end(),1);
    do{
        vector<int> path;
        path.push_back(0);
        bool ok = true;
        for(int i = 0 ;i < n-1;i++)path.push_back(v[i]);
        for(int i = 0;i < n-1;i++){
            if(!g[path[i]][path[i+1]]){ok = false;break;}
        }
        if(ok){ans++;}
    }while(next_permutation(v.begin(),v.end()));

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
import sys
import math
lines = sys.stdin.readlines()
line1 = lines.pop(0).split(' ')
#print(line1)
N = int(line1[0])
M = int(line1[1])
#print(N)
#print(M)

#初期化
str = [10] * N
#print(str)

for i in range(M):
  line = lines.pop(0).split(' ')
#  print(line)
  s = int(line[0])
  c = int(line[1])
#  print(s)
#  print(c)
#  print(str[s-1])
#  if str[s-1] > c:
  if str[s-1] == 10:
    str[s-1] = c
  elif(str[s-1] == c):
    #同じ値の場合は何もしない
    pass
  else:
    #既に何かしらの異なる値が入っている場合はエラー
    print('-1')
    sys.exit()

#print(str)
#str = [0 if i == 10 else i for i in str]
#print(str)
if N == 3:
  if str[0] == 10 and str[1] == 10:
    str[0] = 1
    str[1] = 0
  elif str[0] == 10 and str[1] != 10:
    str[0] = 1
  elif str[0] != 10 and str[1] == 10:
    str[1] = 0

  str[2] = 0 if str[2] == 10 else str[2]

  ret = (int(str[0])*100 + int(str[1])*10 + int(str[2])) if int(str[0]) > 0 else -1
elif N ==2:
  str[0] = 1 if str[0] == 10 else str[0]
  str[1] = 0 if str[1] == 10 else str[1]
  ret = (int(str[0])*10 + int(str[1])) if int(str[0]) > 0 else -1
elif N ==1:
  str[0] = 0 if str[0] == 10 else str[0]
  ret = int(str[0])

print(ret)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

int main(){
	std::string s;
	std::cin>>s;

	if(s=="SUN")
		std::cout<<7<<std::endl;
	else if(s=="MON")
		std::cout<<6<<std::endl;
	else if(s=="TUE")
		std::cout<<5<<std::endl;
	else if(s=="WED")
		std::cout<<4<<std::endl;
	else if(s=="THU")
		std::cout<<3<<std::endl;
	else if(s=="FRI")
		std::cout<<2<<std::endl;
	else if(s=="SAT")
		std::cout<<1<<std::endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,j,k,cnt;
        int[] n = new int[990];
        String[] str = new String[990];
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;;){
            str = in.readLine().split(" ");
            for(i=0;i<2;i++){
                n[i]=Integer.parseInt(str[i]);   
            } 
            cnt=0;
            if(n[0]==0 && n[1]==0) break; 
            for(i=1;i<=n[0];i++){
                for(j=i+1;j<=n[0];j++){
                    for(k=j+1;k<=n[0];k++){
                        cnt+=(i+j+k==n[1] ? 1 : 0);
                    }
                } 
            }
            System.out.println(cnt);
        }
        System.out.flush();
    }
}

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

int main(){
    long long h, w;
    cin >> h >> w;

    char s[h][w];
    long long length_sx[h][w];
    long long length_sy[h][w];

    for(long long y = 0; y < h; y++){
        for(long long x = 0; x < w; x++){
            cin >> s[y][x];
            length_sx[y][x] = 0;
            length_sy[y][x] = 0;
        }
    }

    
    for(long long y = 0; y < h; y++){
        long long x = 0;
        while(x < w){
            if(s[y][x] == '.'){
                long long length = 0;
                while(x < w and s[y][x] == '.'){
                    x++;
                    length++;
                }
                length_sx[y][x-1] = length;
            }
            x++;
        }
    }

    for(long long x = 0; x < w; x++){
        long long y = 0;
        while(y < h){
            if(s[y][x] == '.'){
                long long length = 0;
                while(y < h and s[y][x] == '.'){
                    y++;
                    length++;
                }
                length_sy[y-1][x] = length;
            }
            y++;
        }
    }

    for(long long y = 0; y < h; y++){
        long long x = w-1;
        while(x >= 0){
            if(s[y][x] == '.'){
                long long length = length_sx[y][x];
                while(x >= 0 and s[y][x] == '.'){
                    length_sx[y][x] = length;
                    x--;
                }
            }
            x--;
        }
    }

    for(long long x = 0; x < w; x++){
        long long y = h-1;
        while(y >= 0){
            if(s[y][x] == '.'){
                long long length = length_sy[y][x];
                while(y >= 0 and s[y][x] == '.'){
                    length_sy[y][x] = length;
                    y--;
                }
            }
            y--;
        }
    }

    long long maxv = 0;
    for(long long y = 0; y < h; y++){
        for(long long x = 0; x < w; x++){
            if(s[y][x] == '.'){
                maxv = max(maxv, length_sx[y][x] + length_sy[y][x]-1);
            }
        }
    }

    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 69988
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> list = new ArrayList<>();
    int x = sc.nextInt();
    int n = sc.nextInt();
    for(int i=0; i<n; i++){
       list.add(sc.nextInt());
    }

    Collections.sort(list);


    int i = 0;
    int ans = 0;
    while(true){
      if(!(list.contains(x-i))){
        ans = x-i;
        break;
      }

      // for(int j=0; j<list.size(); j++){
      //   System.out.println("*"+list.get(j));
      // }
      if(!(list.contains(x+i))){
        ans = x+i;
        break;
      }
      i++;
    }
    System.out.println(ans);

    //for(int i=0; i<list.size(); i++){
      //System.out.println(list.get(i));
    //}

  }

}

Measured memory_bytes: 35936
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n;
cin >> n;
string s;
map<string,int> m;
REP(i,n) {
  cin >> s;
  m[s]++;
}
vector<pair<int,string>> v;
for(auto && a:m) {
  v.push_back({a.second*-1,a.first});
}
sort(ALL(v));
int ans = v[0].first;
REP(i,v.size()) {
  if(v[i].first==ans) {
    cout << v[i].second << endl;
  }
}
return 0;
}


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

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

    int n;
    string s;
    cin >> n >> s;
    int resp = 1;
    for (int i=1; i<n; i++){
        if (s[i] != s[i-1]) resp++;
    }
    cout << resp << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
char in[20];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	int ret=0;
	for(int i=0;i<=a;i++)for(int j=0;j<=a;j++){
		int k=b-i-j;
		if(0<=k&&k<=a)ret++;
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll MAXN = 

ll n,m,q;
vector<ll> s,t;
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n >> m >> q;
    REP (i,n) {
        ll ts;
        cin >> ts;
        s.emplace_back(ts);
    }

    REP (i,m) {
        ll tt;
        cin >> tt;
        t.emplace_back(tt);
    }

    while (q--) {
        ll pos;
        cin >> pos;
        vector<ll> sc,tc;
        if (lower_bound(ALL(s),pos) != s.end()) {
            sc.emplace_back(*lower_bound(ALL(s),pos));
        }
        if (lower_bound(ALL(s),pos) != s.begin()) {
            sc.emplace_back(*prev(lower_bound(ALL(s),pos)));
        }
        if (lower_bound(ALL(t),pos) != t.end()) {
            tc.emplace_back(*lower_bound(ALL(t),pos));
        }
        if (lower_bound(ALL(t),pos) != t.begin()) {
            tc.emplace_back(*prev(lower_bound(ALL(t),pos)));
        }

        debug(sc,tc);
        ll ans = INF;
        for (auto px : sc) {
            for (auto py : tc) {
                ans = min(min(abs(py-pos),abs(px-pos))+abs(py-px),ans);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main()
{
    int N, Q;
    cin >> N >> Q;
    dsu g(N);
    int ti, ui, vi;
    vector<int> res;
    for(int i=0;i<Q;i++){
        cin >> ti >> ui >> vi;
        if(ti == 0){
            g.merge(ui, vi);
        }else if(ti == 1){
            res.push_back(g.same(ui, vi));
        }else{
            abort();
        }
    }
    for(auto v : res) cout << v << endl;

    return 0;
}

Measured memory_bytes: 4420
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#define debug cout

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[]={1,-1,0,0,1,-1,1,-1,0};
const int dy[]={0,0,1,-1,1,-1,-1,1,0};

int n,m,t;
vector<pair<int,pint> > p;
int v[20010];

int main() {
	IL{
		cin>>n>>m;
		if(n==0&&m==0)break;
		p.clear();
		rep(i,m){
			int t,s,d;
			cin>>t>>s>>d;
			p.PB(MP(t,MP(s,d)));
		}
		sort(all(p));
		memset(v,0,sizeof(v));
		v[1]=1;
		rep(i,m){
			if(v[p[i].second.first]==1)v[p[i].second.second]=1;
		}
		int res=0;
		repn(i,1,n)res+=v[i];
		cout<<res<<endl;
	}
	
	return 0;
}

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

int main(){
  int x[10000], i;

  for(i=1;i<=10000;i++) {
    cin >> x[i];
    if(x[i]==0) break;
  }

  for(i=1;i<=10000;i++) {
    if(x[i]==0) break;
    cout << "Case " << i << ": " << x[i] << endl;
  }

}



Measured memory_bytes: 3100
#include <stdio.h>

int main(void)
{
    int i, j, k, N;
    int P[N];
    int max;
    int sum;
    int tmp;
    
    scanf("%d",&N);
    
    for(i=0; i<N; i++){
        scanf("%d",&P[i]);
    }
    
    for(j=1; j<N; j++){
        if(P[0] < P[j]){
            tmp = P[0];
            P[0] = P[j];
            P[j] = tmp;
        }
    }
    sum = P[0]/2;
    
    for(k=1; k<N; k++){
        sum += P[k];
    }
    printf("%d\n",sum);
    
    return 0;
}


Measured memory_bytes: 128
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::*;
use maplit::*;
use num::Integer;
use proconio::input;
use proconio::marker::*;
use proconio::fastout;
const INF: usize = 1_000_000_007;

#[fastout]
fn main() {
  input! {
    d : usize,
    c : [isize; 26],
  };
  input! {
    s : [[isize; 26]; d],
  };

  let mut last = vec![0usize; 26];

  let mut score : isize = 0;
  for i in 0..d {
    input! {
      t : usize,
    };

    last[t - 1] = i + 1;
    score += s[i][t - 1];
    for j in 0..26 {
      score -= c[j] * (1 + i as isize - last[j] as isize);
    }
    println!("{}", score);
  }
}

Measured memory_bytes: 2292
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
int main() {
	string s;
	cin>>s;
	bool flg=true;
	int ls=s.length();
	while(flg){
		flg=false;
		if(ls>=5&&(s.substr(ls-5,5)=="dream")){
			ls-=5;
			flg=true;
		}else if(ls>=5&&s.substr(ls-5,5)=="erase"){
			ls-=5;
			flg=true;
		}else if(ls>=7&&s.substr(ls-7,7)=="dreamer"){
			ls-=7;
			flg=true;
		}else if(ls>=6&&s.substr(ls-6,6)=="eraser"){
			ls-=6;
			flg=true;
		}
	}
	if(ls==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner


object Main {

  case class Gate(l: Int, r: Int)

  def read() = {
    val sc = new Scanner(System.in)
    val n,m = sc.nextInt()
    val gates = IndexedSeq.fill(m)(Gate(sc.nextInt(), sc.nextInt()))
    (n, gates)
  }

  def solve(n: Int, gates: IndexedSeq[Gate]): Int = {
    val result = gates.foldLeft(Gate(1, n))((acc, gate) =>
      Gate(math.max(acc.l, gate.l), math.min(acc.r, gate.r))
    )
    math.max(0, result.r - result.l + 1)
  }

  def main(args: Array[String]): Unit = {
    val (n, gates) = read()
    println(solve(n, gates))
  }
}

Measured memory_bytes: 71716
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
bool t[3][500][500];
int n,h,x,y;
string s;
int main(){
	while(cin>>n>>h&&n+h){
	int cnt,ans=0;
	for(int i=0;i<3;i++){
		for(int j=0;j<n;j++)for(int k=0;k<n;k++){
			t[i][j][k]=0;
		}
	}
	for(int i=0;i<h;i++){
		cin>>s>>x>>y;x--,y--;
		if(s=="xy"){
			t[0][x][y]=1;
			for(int i=0;i<n;i++){
				cnt=0;
				if(t[1][x][i])cnt++;
				if(t[2][y][i])cnt++;
				if(cnt==2)cnt--;
				ans+=cnt;
			}
		}
		if(s=="xz"){
			t[1][x][y]=1;
			for(int i=0;i<n;i++){
				cnt=0;
				if(t[0][x][i])cnt++;
				if(t[2][i][y])cnt++;
				if(cnt==2)cnt--;
				ans+=cnt;
			}
		}
		if(s=="yz"){
			t[2][x][y]=1;
			for(int i=0;i<n;i++){
				cnt=0;
				if(t[0][i][x])cnt++;
				if(t[1][i][y])cnt++;
				if(cnt==2)cnt--;
				ans+=cnt;
			}
		}
	}
	cout<<n*(n*n-h)+ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3716
#include<iostream>
using namespace std;
int main(void){
  int x,y;
  for(int i=0;;i++){
  cin>>x>>y;
  if(x==0&&y==0)break;
  if(x>y)cout<<y<<" "<<x<<endl;
  else cout<<x<<" "<<y<<endl;
}
  return 0;
}


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

ans = sum(a)
ans2 = 0
for i in range(n):
    if abs((ans - a[i]) - (ans2 + a[i])) < abs(ans - ans2):
        ans2 += a[i]
        ans -= a[i]
    else:
        break

print(abs(ans - ans2))
    


Measured memory_bytes: 26764
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	string s; cin >> s;
	int N; cin >> N;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		string t; cin >> t;
		t += t;
		if (t.find(s) != string::npos) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
using namespace std;
int main()
{
    int s[10001];
    int n,q,i,j,c=0,t;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>s[i];
    cin>>q;
    for(i=0;i<q;i++)
    {
        cin>>t;
        j = 0;
        s[n] = t;
        while(s[j]!=t)
            j++;
        if(j!=n)
            c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3112
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    int h,a;
    cin >> h >> a;
    if(h%a == 0){
        cout << h/a << endl;
    }
    else{
        cout << (h/a) + 1 << endl;
    }

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n) {
    for(int i=2;i*i<=n;++i) {
        if(n%i==0)
        return false;
    }
    return true;
}


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    string s;
    cin>>s;
    int n=s.size();
    n/=2;
    int i=0,j=s.size()-1;
    int cnt=0;
    while(i<n&&j>=n) {
        if(s[i]!=s[j])++cnt;
        ++i;
        --j;
    }

    cout<<cnt<<endl;

    
    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
const int MAXN = 1000005;
const int mod = 998244353;

int n;
lint a[MAXN];

int main(){
	cin >> n;
	for(int i=1; i<=n; i++){
		int x; scanf("%d",&x);
		a[i] = a[i-1] + x;
	}
	lint ret = 1e18;
	for(int i=1; i<n; i++){
		lint x = a[i];
		lint y = a[n] - a[i];
		ret = min(ret, abs(x - y));
	}
	cout << ret << endl;
}


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

int gcd(int a,int b){
  int c=1;
  while(c>0){
    c = a - (int)(a/b)*b;
    a=b;
    b=c;
  }
  return a;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  
  int ans = A.at(0);
  for(int i=1;i<N;i++){
    ans = gcd(ans,A.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int s[maxn];
int gcd(int a,int b){
        return b == 0 ? a : gcd(b , a % b);
    }
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%d",&s[0]);
	for(int i=1;i<=n;i++)
		scanf("%d",&s[i]);
	sort(s,s+n+1);
	int ant=s[1]-s[0];
	for(int i=2;i<=n;i++)
		ant=gcd(ant,s[i]-s[i-1]);
	printf("%d\n",ant);
	
	return 0;
} 



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

int N,M;
vector<int> A;

int main(){
    cin>>N>>M;
    A.resize(N);
    double sum;
    for(int i=0;i<N;i++){
        cin>>A[i];
        sum+=A[i];
    }
    int count=0;
    double x=sum/(4*M);
    for(int i=0;i<N;i++){
        if(A[i]>=x)count++;
    }
    if(M<=count){printf("Yes");
    }else{printf("No");}
    return 0;
}

Measured memory_bytes: 256
import sys
import math
a = input().split()
#print(a)

H = int(a[0])
W = int(a[1])

if H == 1 or W == 1:
  print(1)
  sys.exit()

c = H * W
if c % 2 == 1:
  c = math.floor(c / 2) + 1
else:
  c = math.floor(c / 2)

print(c)

Measured memory_bytes: 3060