akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX = 1000000;
int B[MAX + 1]{};

int main() {
    int N;
    cin >> N;
    int A[N];

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        B[A[i]]++;
    }
    bool flag1 = true;
    bool flag2 = true;
    for (int i = 2; i <= MAX; i++) {
        int cnt = 0;
        for (int j = 1; j < MAX; j++) {
            if (i * j > MAX) break;
            cnt += B[i * j];
        }
        if (cnt > 1) {
            flag1 = false;
        }
        if (cnt == N) {
            flag2 = false;
        }
    }
    if (flag1) {
        cout << "pairwise coprime\n";
    } else if (flag2) {
        cout << "setwise coprime\n";
    } else {
        cout << "not coprime\n";
    }
    return 0;
}

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

void swapCK(int *x, int *y){
    int temp;

    temp = *x;
    *x = *y;
    *y = temp;
}

int euclid(int small, int big){
    int amari = 0;

    if(small > big)
        swapCK(&small, &big);

    while(true){
        if((amari = big % small) == 0)
            return small;

        big = small;
        small = amari;
    }

    return 0;
}

int main() {

  int N;
  cin >> N;

  unsigned long long ans = 0;

  for(int i=1; i<=N; i++){
    for(int j=1; j<=N; j++){
      for(int k=1; k<=N; k++){
        vector<int> kumi = {i,j,k};
        int koutmpAB = euclid(kumi.at(0), kumi.at(1));
        int kou = euclid(koutmpAB, kumi.at(2));
        ans += kou;
      }
    }
  }

  cout << ans << endl;

  return 0;

}


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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  ll result;
  if (A + B < C * 2) {
    result = A * X + B * Y;
  } else {
    result = min(C * min(X, Y) * 2 + (max(X, Y) - min(X, Y)) * (max(X, Y) == X ? A : B), C * max(X, Y) * 2);
  }
  cout << result << endl;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

x = tx - sx
y = ty - sy

ans = ''

# 行き1回目
for i in range(x):
    ans += 'R'
for i in range(y):
    ans += 'U'
# 帰り1回目
for i in range(x):
    ans += 'L'
for i in range(y):
    ans += 'D'
# 行き2回目
ans += 'D'
for i in range(x + 1):
    ans += 'R'
for i in range(y + 1):
    ans += 'U'
ans += 'L'
# 帰り2回目
ans += 'U'
for i in range(x + 1):
    ans += 'L'
for i in range(y + 1):
    ans += 'D'
ans += 'R'

print(ans)

Measured memory_bytes: 3064
//
// Created on 2020/09/29.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



int main() {
    string n;
    cin>>n;
    for (int i = 0; i < n.size(); ++i) {
        if(n[i] == '1'){
            n[i] = '9';
        }else if(n[i] == '9'){
            n[i] = '1';
        }
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(n); ++i)
#define REP(i, d, n) for(long long i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {//---------------------------------------------------------
 
ll a,v,b,w,t; cin>>a>>v>>b>>w>>t;
  
  ll sa;
  if(a>=b){sa=a-b;}
  else{sa=b-a;}
  
  ll aa=t*(v-w);
  if(sa<=aa){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
    
return 0; }


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().ToCharArray().Select(x => Int32.Parse(x.ToString())).ToArray();
        var a = l[0]; var b = l[1]; var c = l[2]; var d = l[3];
        var ap = 0; var bp = 0; var cp = 0;
        for (var i = 0; 2 > i; i++)
        {
            if (i == 0) ap = a + b;
            else ap = a - b;
            for (var j = 0; 2 > j; j++)
            {
                if (j == 0) bp = ap + c;
                else bp = ap - c;
                for (var k = 0; 2 > k; k++)
                {
                    if (k == 0) cp = bp + d;
                    else cp = bp - d;
                    if (cp == 7)
                    {
                        var ops = new Char[3];
                        if (i == 0) ops[0] = '+';
                        else ops[0] = '-';
                        if (j == 0) ops[1] = '+';
                        else ops[1] = '-';
                        if (k == 0) ops[2] = '+';
                        else ops[2] = '-';
                        Console.WriteLine($"{a}{ops[0]}{b}{ops[1]}{c}{ops[2]}{d}=7");
                        return;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 13396
n=int(input())
A = []
for _ in range(n):
  x = int(input())
  A.append(x)
standard = max(A)
counter = A.count(max(A))
for i in range(n):
  if A[i] != standard:
    print(standard)
  elif counter >=2:
    print(standard)
  else:
    temp = 0
    for t in range(n):
      if t != i:
        if A[t] >= temp:
          temp = A[t]
    print(temp)

Measured memory_bytes: 12516
#include <iostream>
#include <math.h>
using namespace std;


bool judgePrime(int num) {

	int mid = sqrt((double)num);

	for (int i = 2; i <= mid; i++) {
		if (num % i == 0) return false;
	}
	return true;
}

int main() {

	int n;
	cin >> n;

	int count = 0;

	for (int i = 0; i < n; i++)
	{
		int temp = 0;
		cin >> temp;
		if (judgePrime(temp)) count++;
	}
	cout << count << endl;
	return 0;
}



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

int main() {
	int n;
	cin>>n;
	string p;
	cin>>p;
	int ans=0;
	for(int i=0;i<n;i++){
		if(p[i]=='A' && p[i+1]=='B' && p[i+2]=='C') ans++;
	}
	cout<<ans<<endl;
}

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

int main(){

	int n,k;
	cin>>n>>k;
	vector<int> a;
	a.resize(n);
	for(int i=0;i<n;++i)
		cin>>a[i];
	sort(a.begin(),a.end());
	int sum=0;
	for(int i=0;i<k;++i){
		sum+=a[i];
	}cout<<sum<<'\n';
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,h,w;

int main(){
	cin>>n>>h>>w;
	int res=0;
	for(int i=0;i<n;i+=2){
		int a,b;
		cin>>a>>b;
		res+=(2*w-max(w+a,2*w-b)+min(a,w-b))*h;
	}
	cout<<res<<endl;
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s,t;
  cin >> s >> t;
  int ans = 0;
  rep(i,3){
    if(s[i]==t[i]) ++ans;
  }
  cout << ans << endl;
}


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

int64_t gcd(int64_t A,int64_t B){
  if(B==0){return A;}
  return gcd(B,A%B);
}

int main(){
  int64_t A,B,C,D,E;
  cin>>A>>B>>C>>D;
  E=C*D/gcd(C,D);

  int64_t c,d,e;
  if(A%C==0){
    c=(B/C)-(A/C)+1;
  }
  else{
    c=(B/C)-(A/C);
  }
  if(A%D==0){
    d=(B/D)-(A/D)+1;
  }
  else{
    d=(B/D)-(A/D);
  }
  if(A%E==0){
    e=(B/E)-(A/E)+1;
  }
  else{
    e=(B/E)-(A/E);
  }

  int64_t count;
  count=(B-A)+1-(c+d-e);
  cout<<count<<endl;
}

Measured memory_bytes: 256
def popcnt(n):
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff)
    return c


n = int(input())
f = [sum([(1 << (9 - x)) * y for x, y in enumerate(list(map(int, input().split())))]) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

ans = -1 << 60
for i in range(1, 1024):
    tmp = 0
    for x, y in zip(f, p):
        tmp += y[popcnt(i & x)]
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 9264
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

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

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n,ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//long longしか使わない
//素数は1より大きい
int main() {
	double a, b, x;
	cin >> a >> b >> x;
	double h = x / (a * a);
	double ans;
	if (2*h >= b) {
		double res = 2 * b / a - 2 * x / (a * a * a);
		ans = atan(res);
	}
	else {
		double res = a * b * b / (2 * x);
		ans = atan(res);
	}
	ans *= 180;
	ans /= M_PI;
	exout(ans);
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int num[200100];

int main(void){
    int i,n,t;
    cin>>n;
    for(i=1;i<n;i++){
        cin>>t;
        num[t]++;
    }
    for(i=1;i<=n;i++){
        cout<<num[i]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 4348
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
int gcd(int x,int y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int n,a[6000];
int sum=0;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    cout<<sum-n<<endl;
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

string s;

void input(){
    cin >> s;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int n = s.size();
    int cnt0 = 0;
    int cnt1 = 0;
    for(int i=0;i<n;++i){
        if(s[i] == '0') cnt0++;
        else cnt1++;
    }
    int ans = min(cnt0, cnt1);
    cout << ans*2 << endl;
    return 0;
}

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

int main() {
    ll n;
    cin >> n;
    vector<char> ans;
    while(n > 0){
        int scr = n % 26;
        if (scr == 0) scr = 26;
        ans.push_back('a' - 1 + scr);
        if (scr == 26) n--;
        n /= 26;
    }
    int sz = ans.size();
    for (int i = sz - 1; i >= 0; i--){
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 3628
def main():
    n, k = map(int, input().split())
    inlis = list(map(int, input().split()))
    #print(inlis)
    inlis.sort()
    ans = 0
    for i in range(k):
        ans += inlis[i]
    print(ans)



    

 
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9240
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
//priority_queue<long long, vector<long long>, greater<long long>> pq;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


int n;
LL a[3];
pair<int, int> p[100005];

int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif

  scanf("%d", &n);
  cin >> a[0] >> a[1] >> a[2];

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int x = s[0] - 'A';
    int y = s[1] - 'A';
    p[i] = {x, y};
  }

  vector<char> ans;
  bool flag = true;
  for (int i = 0; i < n; i++) {
    int x = p[i].first;
    int y = p[i].second;
    int z = 3 - x - y;
    if (a[x] == a[y] && a[x] == 1 && a[z] == 0 && i < n - 1
        && (p[i + 1].first == z || p[i + 1].second == z)) {
          if (x == p[i + 1].first || x == p[i + 1].second) {
            a[x] += 1;
            a[y] -= 1;
            ans.push_back((char)('A' + x));
          } else {
            a[x] -= 1;
            a[y] += 1;
            ans.push_back((char)('A' + y));
          }
    }
    else if (a[x] > a[y]) {
      a[x] -= 1;
      a[y] += 1;
      ans.push_back((char)('A' + y));
    } else {
      a[x] += 1;
      a[y] -= 1;
      ans.push_back((char)('A' + x));
    }
    if (a[x] < 0 || a[y] < 0) {
      flag = false;
    }
  }

  if (flag) {
    puts("Yes");
    for (auto ch : ans) {
      printf("%c\n", ch);
    }
  } else {
    puts("No");
  }

  return 0;
}

Measured memory_bytes: 4700
#include <cstdio>
#include <algorithm>

#define MOD 1000000007LL

using namespace std;

long long dp[2048][2048], fact[4000010], inv[4000010];

long long put (long long n, long long p)
{
    long long rez = 1LL;

    for (long long i = 0LL; (1LL << i) <= p; i += 1LL)
    {
        if ((1LL << i) & p) rez *= n, rez %= MOD;

        n *= n;
        n %= MOD;
    }

    return rez;
}

long long comb (int n, int k)
{
    long long rez = fact[n] * inv[k];
    rez %= MOD;

    rez *= inv[n - k];
    rez %= MOD;

    return rez;
}

int main ()
{
 //   freopen ("file.in", "r", stdin);

    int n, k;
    scanf ("%d %d", &n, &k);

    if (k == 1)
    {
        printf ("1\n");
        return 0;
    }

    fact[0] = inv[0] = 1LL;
    for (int i = 1; i <= n * k; ++i)
        fact[i] = 1LL * i * fact[i - 1] % MOD;

    inv[n * k] = put (fact[n * k], MOD - 2LL);

    for (int i = n * k - 1; i; --i)
        inv[i] = 1LL * (i + 1) * inv[i + 1] % MOD;

    dp[0][0] = 1LL;

    for (int i = 0; i <= n; ++i)
        for (int j = i; j <= n; ++j)
        {
            if (i == 0 && j == 0) continue;

            dp[i][j] = (i > 0 ? dp[i - 1][j] : 0LL) + dp[i][j - 1] * comb (i + j * (k - 1) - 1, k - 2);
            dp[i][j] %= MOD;
        }

    printf ("%lld\n", dp[n][n] * fact[n] % MOD);

    return 0;
}


Measured memory_bytes: 94464
def main():
    S = input()
    T = input()
    minv = len(T)
    cnt = 0
    if T in S:
        print(0)
        exit()
    else:
        for i in range(len(S)-len(T)+1):
            for s, t in zip(S[i:len(T)+i], T):
                if s != t:
                    cnt += 1
            minv = min(minv, cnt)
            cnt = 0
    print(minv)

if __name__ == '__main__':
    main()

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


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

    vector<int> x(n);
    rep(i, n) cin >> x[i];

    int min = INF;

    rep(i, 1, 101) {
        int sum = 0;

        rep(j, n)
            sum += (x[j] - i) * (x[j] - i);

        if (sum < min)
            min = sum;
    }

    cout << min << endl;

    return 0;
}


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

int main() {
  int num1, num2;
  cin >> num1 >> num2;
  if (num1 > num2){
    for (int i=0; i < num1; i++) {
      cout << num2;
    }
  }
  else if (num1 < num2){
    for (int i=0; i < num2; i++) {
      cout << num1;
    }
  }
  else {
    for (int i=0; i < num1; i++) {
      cout << num2;
    }
  }
  return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
class UnionFind:
    def __init__(self,N):
        self.Parent=[-1]*N
    def unite(self,m,n):
        rm=self.root(m)
        rn=self.root(n)
        if rm==rn:
            return False
        else:
            if self.size(rm)<self.size(rn):
                rm,rn=rn,rm
            self.Parent[rm]+=self.Parent[rn]
            self.Parent[rn]=rm
            return True
    def root(self,n):
        if self.Parent[n]<0:
            return n
        else:
            self.Parent[n]=self.root(self.Parent[n])
            return self.Parent[n]
    def size(self,n):
        return -self.Parent[self.root(n)]
u=UnionFind(N)
for a,b in AB:
    u.unite(a-1,b-1)
print(len(set([u.root(i) for i in range(N)]))-1)

Measured memory_bytes: 30528
h,w=map(int,input().split())
t=[list(input()) for _ in range(h)]
for i in range(h):
    t[i]=[(tij=="#")*1 for tij in t[i]]
rows=[]
columns=[]
for i,ti in enumerate(t):
    if sum(ti)==0:
        rows+=[i]
for j,tj in enumerate(zip(*t)):
    if sum(tj)==0:
        columns+=[j]
nt=[]
for i,ti in enumerate(t):
    if i in rows:continue
    nti=[]
    for j,tij in enumerate(ti):
        if j in columns:continue
        nti+=["#" if tij else "."]
    print(*nti,sep="")


Measured memory_bytes: 4596
#include <iostream>
#include <cmath>
#include <vector>

const int data_count = 4;

bool read_dataset(std::istream& input, int* a, int* b)
{
	for (int i = 0; i < data_count; ++i) {
		input >> a[i];
	}
	for (int i = 0; i < data_count; ++i) {
		input >> b[i];
	}
	return input.good();
}

int main()
{
	int a[data_count], b[data_count];
	while (read_dataset(std::cin, a, b)) {
		int hit_count = 0;
		int blow_count = 0;
		for (int ia = 0; ia < data_count; ++ia) {
			for (int ib = 0; ib < data_count; ++ib) {
				if (a[ia] == b[ib]) {
					if (ia == ib) {
						++hit_count;
					} else {
						++blow_count;
					}
				}
			}
		}
		std::cout << hit_count << ' ' << blow_count << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1160
n, a, b = map(int, input().split())
ans = []
for i in range(1, n+1) :
    one = [int(x) for x in list(str(i))]
    ans.append(sum(one))
co = 0
for d, s in enumerate(ans):
    if a <= s <= b :
        co += (d + 1)
print(co)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

#define __ { \
	freopen("input.txt","r",stdin); \
	freopen("output.txt","w",stdout); \
}
#define _ { \
	ios_base::sync_with_stdio(false); \
    cin.tie(NULL); \
}

int main(){
   _;
 //  __;
   int n,k;cin>>n>>k;
   if((n+1)/2>=k)cout<<"YES";
   else cout<<"NO";

}

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

int main(){
	int N;
	cin >> N;
	queue<pair<string,int>> q;
	q.push({"", 0});
	int sum = 0;
	while(!q.empty()) {
		auto tmp  = q.front(); q.pop();
		string now = tmp.first;
		if(now.size() == N) {
			cout << now << endl;
			continue;
		}
		int cnt = tmp.second;
		for(int i=0;i<=cnt;i++) {
			string next = now + char('a'+i);
			q.push({next, ((i < cnt) ? cnt : cnt+1)});
		}
	}
}

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

int main(){
  int N;
  cin >> N;
  
  int a = N/1000;
  int b = N%1000/100;
  int c = N%100/10;
  int d = N%10;
  
  if (a == b)
    if (a == c)
      cout << "Yes" << endl;
  	else 
      cout << "No" << endl;
  
  else 
    if (c == d)
      if (b == c)
        cout << "Yes" << endl;
  	  else 
        cout << "No" << endl;
    else 
      cout << "No" << endl;
}

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

 int main() {
   string S, T;
   cin >> S >> T;

   map<char, char> s, t;

   bool ok = true;

   rep(i, 0, S.length()) {
     char tmps, tmpt;
     tmps = S.at(i);
     tmpt = T.at(i);
     if (s.count(S.at(i))) {
       if (s.at(S.at(i)) != T.at(i)) ok = false;
     }
     if (t.count(T.at(i))) {
       if (t.at(T.at(i)) != S.at(i)) ok = false;
     }
     s[S.at(i)] = T.at(i);
     t[T.at(i)] = S.at(i);
   }
   if (ok) cout << "Yes" << endl;
   else cout << "No" << endl;
 }


Measured memory_bytes: 776
#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()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

#define MAX 1000000

struct osa_k {
    vector<int> minfactor;

    osa_k(int n) {
        eratos(n);
    }

    vector<int> eratos(int n) {
        minfactor.resize(n + 1);
        iota(minfactor.begin(), minfactor.end(), 0);
        for (int i = 2; i * i <= n; i++) {
            if (minfactor[i] < i) continue;
            for (int j = i * i; j <= n; j += i) {
                if (minfactor[j] == j) minfactor[j] = i;
            }
        }
        return minfactor;
    }

    map<int, int> PrimeFactor(int n) {
        map<int, int> mp;
        while (n > 1) {
            mp[minfactor[n]]++;
            n /= minfactor[n];
        }
        return mp;
    }
};

signed main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
    }
    osa_k os(MAX);
    bool visited[MAX + 1] = {};
    bool flag = true;
    rep(i, n) {
            auto pf = os.PrimeFactor(a[i]);
            for (auto p : pf) {
                if (visited[p.first]) {
                    flag = false;
                    goto fin;
                }
                visited[p.first] = true;
            }
        }
fin:;
    if (flag) {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    int g = a[0];
    rep(i, n) {
        g = gcd(g, a[i]);
    }
    cout << (g == 1 ? "setwise coprime" : "not coprime") << endl;
    return 0;
}

Measured memory_bytes: 14852
N=int(input())
D,X=map(int,input().split())
A=[int(input()) for i in range(N)]

#print('N,D,X',N,D,X)
sum=0

for i in range(N):
    for j in range(101):
        tmp = j*A[i]+1
#        print('i,j,tmp',i,j,tmp)
        if tmp>D:
            sum+=(j)
#            print('sum',sum)
            break

print(X+sum)


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

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

    int score[n];
    for( int i = 0; i < n; i++ )
        score[i] = 0;
    
    int out = 0, inning = 0;
    bitset<4> b = 0;
    string event;

    while( cin >> event )
    {
        if( event == "HIT" )            //ヒット
        {
            b <<= 1;                    // <<=1は1ビット左にシフト
            b[0] = 1;                   // b[0]は000'0'を示す。b[1]は00'0'0を示す。

            if( b[3] == 1 )
            {
                score[inning]++;
                b[3] = 0;
            }
        }
        else if( event == "OUT" )       //アウト
        {
            out++;
            if( out == 3 )
            {
                inning++;
                out = 0;
                b = 0;
            }
        }
        else                            //ホームラン
        {
            score[inning] += b.count() + 1;
            b = 0;
        }
    }

    for( int i = 0; i < n; i++ )
        cout << score[i] << endl;

    return 0;
}


Measured memory_bytes: 3148
/*
 * ???????????§??????????´? EightQueen.java
 *
 * Copyright(C) 2016 Nagasaki Team All Rights Reserved.
 */
/**
 * ??°?????????????????????(ITP1_9-B)
 *
 * @author Masuyama
 * @version 1.00
 */
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
	/**
	 * ??°?????????????????????
	 */
	public static void main(String[] args) throws IOException {	//try????????\????????????
        BufferedReader br = 
        	new BufferedReader(new InputStreamReader(System.in)); 	//?¨??????\???
		String str = br.readLine();									//??????????????????
		int count = 1;				//???????????°
		while(!str.equals("0")) {	//0?????\?????????????????????
			System.out.println( "Case " + count + ": " + str );	//"Case 1: ??\?????°???"?????¢?????§??????
			count++;				//?????°????????????????????????
			str = br.readLine();	//??????????????????
		}
	}
}

Measured memory_bytes: 31688
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<=n;i++){
    	for(int j=0;j<=n-i;j++){
    		 if(i*10000+j*5000+(n-i-j)*1000==m){
    		 	cout<<i<<" "<<j<<" "<<n-i-j<<endl;
    		 	return 0;
			 }
		}
	}
    cout<<"-1 -1 -1";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#define ll long long
#define pi (acos(-1))
using namespace std;
int main()
{
    unsigned ll n, x;
   cin >> n >> x;
    vector<unsigned ll> vec(n);

    for (unsigned ll i = 0; i != n; ++i) { cin >> vec[i]; }

    unsigned ll a = 0;
    long long tmp = 0;
    for (auto &i : vec)
    {
        tmp = i - x;
        a = gcd(a, abs(tmp));
    }

    std::cout<<a<<std::endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
ll h, w;
const ll H_MAX = 1000+10;
const ll W_MAX = 1000+10;
ll dp[H_MAX][W_MAX];
string grid[H_MAX];

ll q(ll i, ll j){
    if(dp[i][j]!=-1) return dp[i][j];

    if(grid[i][j]=='#') dp[i][j] = 0;
    else{
        dp[i][j] = q(i-1,j) + q(i,j-1);
        dp[i][j] %= MOD;
    }

    return dp[i][j];
}

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

    cin >> h >> w;



    REP(i,h){
        cin >> grid[i];
    }
    
    dp[0][0] = 1;
    for(ll i=1;i<h;i++){
        if(grid[i][0]=='#') dp[i][0] = 0;
        else dp[i][0] = dp[i-1][0];
    }
    for(ll j=1;j<w;j++){
        if(grid[0][j]=='#') dp[0][j] = 0;
        else dp[0][j] = dp[0][j-1];
    }
    for(ll i=1;i<h;i++){
        for(ll j=1;j<w;j++){
            dp[i][j] = -1;
        }
    }

    cout << q(h-1,w-1) <<endl;

    
    return 0;
}



Measured memory_bytes: 12664
/*input
10 9 10 10
*/
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define max(x, y) ((x) > (y) ? (x) :(y))
#define pii pair< int , int> 
#define vi vector<int>
#define fore( i ,st) for ( int i= 0 ; i < (int)(st) ; i ++)
#define REP( i , st , en ) for ( int i =st; i < (int)en; i++)
#define REPD( i , en , st ) for ( int i =en; i >= (int)st; i--)
#define SZ(a) (int)a.size()
#define all(v) v.begin() , v.end()
#define pb push_back
#define F first
#define S second
#define bitch_i_m_on_fiyaah_yeahhhh ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// const int mod = 998244353;
const int mod = 1e9+7;
ostream& operator << ( ostream&  o, vector<int> s){for ( int i = 0;  i < (int)s.size() ; i++)o << s[i] << " ";o << "\n";return o;}
void  add( int &a, int b){a = a + b;if ( a< 0 ) a += mod; if ( a> mod ) a-= mod;}
void sub( int &a, int b){a = a - b;if ( a < 0) a += mod;}
int mul( int a , int b){return ((a %mod) * (b %mod) ) %mod;}
int exp( int a , int pow){ return (pow == 0 ? 1 : ( pow & 1  ? mul ( a ,exp( mul(a, a) , pow /2) ) : exp(mul(a ,a) , pow/2)));}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
// const int inf = 1e18;
const int maxn = 2e5 + 5;

vector<int> cnt[maxn];

void solve(int test ) 
{		
	int n;
	cin >> n ; 
	set<string> s;
	fore( i , n ){
		string x;cin >> x;
		s.insert(x);
	}
	cout << s.size();

}
signed main(){
	bitch_i_m_on_fiyaah_yeahhhh
	int t =1; 
	// cin >> t;
	for ( int i = 0 ; i < t; i++)
	solve(i+1 );
}

Measured memory_bytes: 23932
#include <iostream>
#include <numeric>
 
#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
 
 
using namespace std;
int main() {
 int n, m, c;
 cin >> n >> m >> c;
 int b[m];
 rep(i,m){
   cin >> b[i];
 }
 int ans=0;
 int sum=0;
 int a[n][m];
 rep(j,n){
   rep(k,m){
     cin >> a[j][k];
   }
 }
  rep(p,n){
    sum=0;
  rep(l,m){
  sum += a[p][l]*b[l];
  }
  sum += c;
  if (sum>0){
    ans++;
  }
  }

cout << ans;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a,b,c,d;
cin>>a>>b>>c>>d;
long long int ans,ans1;
ans=max((a*c), (a*d));
ans1=max( (b*c), (b*d));
cout<<max(ans, ans1)<<endl;
    
return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }


int main(){
    char s;
    cin >> s;
    if(isupper(s)) cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}



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

int main(){
  int t,n,k,ans;
  int x[100000],d[100000];
  cin >> t;

  while(t--){
    cin >> n >> k;
    for(int i=0;i<n;i++){
      cin >> x[i];
      if(i)d[i-1] = x[i] - x[i-1];
    }
    if(n<=k)cout << 0 << endl;
    else{
      ans = x[n-1]-x[0];
      sort(d,d+n-1);

      int tmp = 1;
      while(k!=tmp)ans -= d[n-1-tmp++];
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 0
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
    var n = parseInt(input[0], 10);
    
    var f = 0;

    for(i = 0;i<n;i++){
        var a = tmp[i];
        if(a%2==0){
            if(a%3==0 || a%5==0){

            }else{
                f++;
            }

        }

    }
    if(f>0){
        console.log('DENIED');
    }else{
        console.log('APPROVED');
    }
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
h = "";
i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[200000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = a[0] - 1;
	//a[0]=1
	int ma = 1;
	for (int i = 1; i < n; i++) {
		if (a[i] == ma + 1) {
			ma = a[i];
		}
		else {
			ans += (a[i] - 1) / (ma + 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import std.stdio;
import std.array;
import std.algorithm;
import std.string;
import std.conv;
import std.format;

long[][] map;
long n;

long hai(int i, int j) {
	long a = 0;
	if (j < n-1) {
		a = max(a, hai(i, j+1) + map[i][j]);
	}
	if (i == 0) {
		a = max(a, hai(i+1, j)+map[i][j]);
	}
	return a;
}

void main()
{
	n = readln.chomp.to!long;
	long[] a = readln.chomp.split(" ").to!(long[]);
	long[] b = readln.chomp.split(" ").to!(long[]);

	map ~= a;
	map ~= b;

	writeln(hai(0, 0) + map[1][n-1] );
}


Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	a+=b;
	int num;
	sscanf(a.c_str(),"%d",&num);
	int F=sqrt(num);
	if(num-F*F) puts("No");
	else puts("Yes");
	return 0;
}

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

int main()
{
  int n;
  bool table[100]{};
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
	int a;
    scanf("%d", &a);
    table[a - 1] = true;
  }
  int count{};
  for (int i = 0; i < 100; i++)
  {
	count += table[i];
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

int main() {
	int D, G;
	int *p, *c;
	scanf("%d%d", &D, &G);
	int n = 0;
	p = new int[D];
	c = new int[D];
	for (int i = 0; i < D; ++i) {
		scanf("%d%d", &p[i], &c[i]);
		n += p[i];
	}
	int **f = new int*[D + 1];
	for (int i = 0; i <= D; ++i) {
		f[i] = new int[n + 1];
	}
	for (int i = 0; i <= n; ++i) {
		f[0][i] = 0;
	}
	int res = n + 1;
	for (int i = 1; i <= D; ++i) {
		int pp = p[i - 1], cc = c[i - 1];
		for (int j = 0; j <= n; ++j) {
			f[i][j] = 0;
			for (int k = 0; k <= min(pp, j); ++k) {
				f[i][j] = max(f[i][j], f[i - 1][j - k] + k * i * 100);
			}
			if (pp <= j) {
				f[i][j] = max(f[i][j], f[i - 1][j - pp] + pp * i * 100 + cc);
			}
			if (f[i][j] >= G) {
				res = min(res, j);
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define MOD 1000000009
using namespace std;
typedef long long ll;
int main()
{
  int a;
  cin >> a;
  int ans = 0;
  if(a%2 == 0){
    ans = a/2 - 1;
  }else{
    ans = a/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define classname SubtreeSumHash

const int maxn = 100000 + 5;
int ss[maxn], st[maxn];

int getss(int l, int r)
{
    int res = ss[r];
    if(l)
    {
        res -= ss[l - 1];
    }
    return res;
}

int getst(int l, int r)
{
    int res = st[r];
    if(l)
    {
        res -= st[l - 1];
    }
    return res;
}

void solve()
{
    string s, t;
    cin >> s >> t;
    int n = (int) s.length(), m = (int) t.length();
    
    for(int i = 0; i < n; i++)
    {
        ss[i] = 2;
        if(s[i] == 'A')
        {
            ss[i] = 1;
        }
        if(i)
        {
            ss[i] += ss[i - 1];
        }
    }
    
    for(int i = 0; i < m; i++)
    {
        st[i] = 2;
        if(t[i] == 'A')
        {
            st[i] = 1;
        }
        if(i)
        {
            st[i] += st[i - 1];
        }
    }
    
    int q;
    cin >> q;
    for(int i = 0; i < q; i++)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        int t1 = getss(a, b) % 3;
        int t2 = getst(c, d) % 3;
        if(t1 == t2)
        {
            cout << "YES";
        }
        else
        {
            cout << "NO";
        }
        cout << "\n";
    }
}

void gcj()
{
    int t;
    cin >> t;
    for(int i = 0; i < t; i++)
    {
        cout << "Case #" << i + 1 << ": ";
        solve();
        cout << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //gcj();
    solve();
    return 0;
}


Measured memory_bytes: 1744
#include<stdio.h>
char map[3][3];
int judge(int x,int y,int c,char mark,int pattern){
	int i,j;
	switch(pattern){
	case 0:
		if(map[x+1][y]==mark &&map[x+2][y]==mark )return 1;
		break;
	case 1:
		if(map[x][y+1]==mark &&map[x][y+2]==mark )return 1;
		break;
	case 2:
		if(map[x+1][y+1]==mark &&map[x+2][y+2]==mark )return 1;
		break;
	case 3:
		if(map[x-1][y+1]==mark &&map[x-2][y+2]==mark )return 1;
		break;
	}
	return 0;
}
int main(){
	char str[12];
	int i,j,k,n,c=0;
	for(;scanf("%s",str)!=EOF;c=0){
		for(i=0,j=0,k=0;i<9;i++){
			map[j][k++]=str[i];
			if((i+1)%3==0){j++;k=0;}
		}
		if(map[0][0]!='s'&&judge(0,0,0,map[0][0],0)){
			printf("%c\n",map[0][0]);
			c=1;
		}
		if(map[0][1]!='s'&&judge(0,1,0,map[0][1],0)){
			printf("%c\n",map[0][1]);
			c=1;
		}
		if(map[0][2]!='s'&&judge(0,2,0,map[0][2],0)){
			printf("%c\n",map[0][2]);
			c=1;
		}
		if(map[0][0]!='s'&&judge(0,0,0,map[0][0],1)){
			printf("%c\n",map[0][0]);
			c=1;
		}
		if(map[1][0]!='s'&&judge(1,0,0,map[1][0],1)){
			printf("%c\n",map[1][0]);
			c=1;
		}
		if(map[2][0]!='s'&&judge(2,0,0,map[2][0],1)){
			printf("%c\n",map[2][0]);
			c=1;
		}
		if(map[0][0]!='s'&&judge(0,0,0,map[0][0],2)){
			printf("%c\n",map[0][0]);
			c=1;
		}
		if(map[2][0]!='s'&&judge(2,0,0,map[2][0],3)){
			printf("%c\n",map[2][0]);
			c=1;
		}
		if(!c)printf("d\n");
	}
	exit(0);
}

Measured memory_bytes: 0
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <bitset>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 1000500
#define mod 1001
#define eps 1e-9
#define pi 3.1415926
int Num;
const ll inf=999999999;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{
    int n,m;
    cin>>n>>m;
    int k = n%500;
    if(m>=k)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/*------------------------------↓ここからコード↓----------------------------------*/
void solve(){
    int X;
    cin >> X;
    if(X >= 30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); ++i)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

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

    int c=0;
    for(int a=1;a<n;a++){
        if(a*a>=n)break;
        for(int b=a;b<n;b++){
            if(a*b<n){
                if(a==b)c++;
                else c+=2;
            }
        }
    }
    cout<<c<<endl;


}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int; 

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

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

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

LL res;

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

  res = n / 500;
  n -= res * 500LL;
  debug(n);
  res *= 1000;


  LL x = n / 5;
  res += x * 5;
  cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define SENTINEL 2000000000

int compare = 0;

int main(){

  int n,i,a[500000];

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

  MergeSort(a, 0, n);

  for(i=0; i<n-1; i++)
    printf("%d ", a[i]);
  printf("%d\n",a[n-1]);
  printf("%d\n", compare);

  return 0;
  
}

int Merge(int A[], int left, int mid, int right){

  int n1,n2;
  int i,j,k;
    
  n1=mid-left;
  n2=right-mid;

  int L[n1+1],R[n2+1];

  for(i=0;i<=n1-1;i++)
    L[i]=A[left+i];
  for(i=0;i<=n2-1;i++)
    R[i]=A[mid+i];
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left; k<=right-1; k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
      compare++;
    }
    else {
      A[k]=R[j];
      j=j+1;
      compare++;
    }
  }
}

int MergeSort(int A[], int left, int right){

  int mid;

  if(left+1<right){
    mid=(left+right)/2;
    MergeSort(A, left, mid);
    MergeSort(A,mid, right);
    Merge(A, left, mid, right);
  }

}

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

typedef long long ll;

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

int main() {
ll a, b;
while(cin >> a >> b)
cout << gcd(a, b) << " " << a / gcd(a, b) * b << endl;}

Measured memory_bytes: 3044