akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

/*vector<int> p(n);
cin >> p[i]*/

int main(){

    long long int h,w;
    cin >> h >> w;

    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }
    if((h*w)%2 == 0) cout << (h*w)/2 << endl;
    else cout << (h*w)/2+1 <<endl;

    return 0;
}

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

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

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


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


void main_(istream &cin) {
    ll b;
    ll a;
    cin >> a;
    cin >> b;
    solve(a, b);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 764
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

h,w = map(int, input().split())
board = [list(map(lambda x: int(x=="#"), input())) for i in range(h)]

def make_array(dims, fill):
    if len(dims) == 1:
        return [fill]*dims[0]
    nxt = dims[1:]
    ret = [make_array(nxt,fill) for i in range(dims[0])]
    return ret

DP = make_array((h,w,2), float("inf"))
for i in range(h):
    for j in range(w):
        if i|j:
            if board[i][j]:
                DP[i][j][1] = min(DP[i][j-1][0]+1, DP[i][j-1][1], DP[i-1][j][0]+1, DP[i-1][j][1])
            else:
                DP[i][j][0] = min(DP[i][j-1][0], DP[i][j-1][1], DP[i-1][j][0], DP[i-1][j][1])
        else:
            if board[i][j]:
                DP[i][j][1] = 1
            else:
                DP[i][j][0] = 0
ans = min(DP[-1][-1])
print(ans)

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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

typedef VVI Graph;
Graph G;
const int N = 100000;
const int LOG_N = 20;
int depth[N];
int parent[LOG_N][N];
void dfs(int node ,int p = -1, int d = 0)
{
  if(depth[node] >= 0) return;
  depth[node] = d;
  parent[0][node] = p;
  for(int i=0;i<SZ(G[node]);++i)
	dfs(G[node][i], node, d+1);
}

void init(int V){
  fill(depth, depth+N, -1);
  dfs(0);
  for(int i=0;i+1<LOG_N;++i){
	for(int v=0;v<V;++v){
	  if(parent[i][v] == -1) parent[i+1][v] = -1;
	  else parent[i+1][v] = parent[i][parent[i][v]];
	}
  }
}

int LCA(int u, int v){
  if(depth[u] > depth[v]) swap(u, v);
  //depth[u] <= depth[v]
  for(int i=0;i<LOG_N;++i)
	if((depth[v] - depth[u]) >> i & 1)
	  v = parent[i][v];
  if(u == v) return u;

  for(int i=LOG_N-1;i>=0;--i){
	if(parent[i][u] != parent[i][v]){
	  u = parent[i][u];
	  v = parent[i][v];
	}
  }
  return parent[0][u];
}

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

  int V; cin >> V;
  G.assign(V, VI());
  REP(i,V){
	int k; cin >> k;
	REP(j,k){
	  int c; cin >> c;
	  G[i].PB(c);
	}
  }
  init(V);
  int Q; cin >> Q;
  while(Q--){
	int u, v; cin >> u >> v;
	cout << LCA(u,v) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 19540
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t a, b, t;
  cin >> a >> b >> t;
  
  int64_t x, y, ans;
  
  x = b / t;
  y = (a+(t-1))/t;
  
  ans = x-y+1;
  
  

  
  cout << ans << endl;

  
 
}
             

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
 
#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>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

ll gcd(ll a, ll b) {
  if (b > a) {
    swap(a, b);
  }
  if (b == 0) return a;
  ll r = a%b;
  while (r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}


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

  vl a(n);
  rep (i, n) cin >> a[i];
  vl sum1(n + 1), sum2(n + 1);
  rep (i, n) {
    sum1[i + 1] = gcd(sum1[i], a[i]);
  }
  rrep (i, n) {
    sum2[i] = gcd(sum2[i + 1], a[i]);
  }

  ll ans = 0;
  rep (i, n) {
    chmax(ans, gcd(sum1[i], sum2[i + 1]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 2688
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

#include <x86intrin.h>

using namespace std;

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

const ll mod = 1000000007;

ll a[200100];
ll dp[3][100100];

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

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i/2+(i&1)*100030];

/*
  if (n % 2 == 0) {
    ll now = 0;
    for (int i = 0; i < n; i += 2) now += a[i];
    ll maximum = now;
    for (int i = n-2; i >= 0; i -= 2) {
      now += (a[i+1] - a[i]);
      if (now > maximum) maximum = now;
    }

    cout << maximum << endl;
  }
  else {
    vector<vector<ll> > dp(n+2, vector<ll>(3, (ll) -1e18));
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    dp[2][2] = a[2];
    for (int i = 0; i < n; i++) {
      if (i+2 < n) dp[i+2][0] = max(dp[i+2][0], dp[i][0] + a[i+2]);
      if (i+2 < n) dp[i+2][1] = max(dp[i+2][1], dp[i][1] + a[i+2]);
      if (i+2 < n) dp[i+2][2] = max(dp[i+2][2], dp[i][2] + a[i+2]);
      if (i+3 < n) dp[i+3][1] = max(dp[i+3][1], dp[i][0] + a[i+3]);
      if (i+3 < n) dp[i+3][2] = max(dp[i+3][2], dp[i][1] + a[i+3]);
      if (i+4 < n) dp[i+4][2] = max(dp[i+4][2], dp[i][0] + a[i+4]);
    }

    cout << max(max(dp[n-3][0], dp[n-2][1]), dp[n-1][2]) << endl;
  }
*/

  dp[0][0] = a[0];
  for (int i = 1; i < n/2; i++) {
    dp[0][i] = dp[0][i-1] + a[i];
  }
  dp[1][0] = a[100030];
  for (int i = 1; i < n/2; i++) {
    dp[1][i] = (dp[0][i-1] > dp[1][i-1] ? dp[0][i-1] : dp[1][i-1]) + a[i+100030];
  }
  dp[2][0] = a[1];
  for (int i = 1; i < n/2; i++) {
    dp[2][i] = (dp[0][i-1] > dp[1][i-1] ? (dp[0][i-1] > dp[2][i-1] ? dp[0][i-1] : dp[2][i-1]) : (dp[1][i-1] > dp[2][i-1] ? dp[1][i-1] : dp[2][i-1])) + a[i+1];
  }

  ll ans = max(dp[0][n/2-1], dp[1][n/2-1]);
  if (n % 2 == 1) ans = max(ans, dp[2][n/2-1]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7524
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>

using ll = long long;

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


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

int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  P vec = {x2-x1, y2-y1};
  int x3, y3, x4, y4;
  x3 = x2 - vec.second;
  y3 = y2 + vec.first;
  P vec2 = {x3-x2, y3-y2};
  x4 = x3 - vec2.second;
  y4 = y3 + vec2.first;
  cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}

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


int main()
{
    // Based on the solution on GeeksForGeeks
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, K;
    ll mod=1e9+7;
    cin >> N >> K;
    vector <ll> A(N);
    loop(i,0,N) cin >> A[i];
    // sort(A.begin(), A.end(),mycomp);
    if (K%2)
    {
        if ((*max_element(A.begin(), A.end()))==0) {
            cout << 0 << "\n";
        }
        else if ((*max_element(A.begin(), A.end()))<0) {
            sort(A.begin(), A.end());
            reverse(A.begin(), A.end());
            ll prod=1;
            for (int i=0; i<K; ++i) prod=(prod*A[i])%mod;
            cout << (mod+prod)%mod << "\n";
        }
        else {
            sort(A.begin(),A.end());
            ll prod=A[N-1];
            A.pop_back();
            K-=1;
            int left=0, right=N-2;
            while (K)
            {
                if (A[left]*A[left+1] > A[right]*A[right-1])
                {
                    prod=(((prod*A[left])%mod)*A[left+1])%mod;
                    left+=2;
                }
                else {
                    prod=(((prod*A[right])%mod)*A[right-1])%mod;
                    right-=2;
                }
                K-=2;
            }
            cout << (mod+prod)%mod << "\n";
        }
    }
    else {
        sort(A.begin(),A.end());
        ll prod=1;
        int left=0, right=N-1;
        while (K)
        {
            if (A[left]*A[left+1] > A[right]*A[right-1])
            {
                prod=(((prod*A[left])%mod)*A[left+1])%mod;
                left+=2;
            }
            else {
                prod=(((prod*A[right])%mod)*A[right-1])%mod;
                right-=2;
            }
            K-=2;
        }
        cout << (mod+prod)%mod << "\n";
    }
    return 0;
}

Measured memory_bytes: 4756
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(n, m);
    if (n % 2 == 0)
    {
        rep(i, m)
        {
            if ((n/2+1+i) - (n/2-i) >= n/2)
            {
                cout << n/2-i << " " << n/2+2+i << endl;
            }
            else
                cout << n/2-i << " " << n/2+1+i << endl;
        }
    }
    else
    {
        rep(i, m)
        {
            cout << n/2-i << " " << n/2+2+i << endl;
        }
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  cin >> s;

  for (int i = 0; i < 8; i++) {
    int sum = (s[0] - '0');
    string ans = "";
    ans += s[0];
    for (int j = 0; j < 3; j++) {
      if ((i >> j) & 1) {
        sum += (s[j+1] - '0');
        ans += "+";
        ans += s[j+1];
      } else {
        sum -= (s[j+1] - '0');
        ans += "-";
        ans += s[j+1];
      }
    }
    if (sum == 7) {
      cout << ans << "=7" << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
word = input()

length = int((len(word) - 1) / 2)


def judge_a(kaibun):
    if kaibun == kaibun[::-1]:
        return True
    return False


def judge_b(kaibun):
    if kaibun[:length] == kaibun[length-1::-1]:
        return True
    return False


def judge_c(kaibun):
    if kaibun[length + 1:] == kaibun[:length:-1]:
        return True
    return False


if judge_a(word) == True:
    if judge_b(word) == True:
        if judge_c(word) == True:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 3064
/*
 * main.c
 *
 *  Created on: 2020/02/22
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

int X[101] = {0};
int sum[101] = {0};

int main()
{
	int N = 0, i = 0, j = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &X[i]);
	}
	for (i = 0; i < 100; i++) {
		for (j = 0; j < N; j++) {
			sum[i] += (X[j] - (i+1)) * (X[j] - (i+1));
		}
	}
	qsort(sum, 100, sizeof(int), sort_inc);
	printf("%d\n",sum[0]);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int ods[10000], evs[10000];

VI od, ev;

int main() {
    string s;
    cin >> s;
    int k = 0;
    int cnt = 0;
    int orige = -1;
    REP(i,s.size()) {
        if (s[i] == 'T') {
            if (k == 0) {
                if (orige == -1) {
                    orige = cnt;
                } else if (cnt) ev.push_back(cnt);
            } else {
                if (cnt) od.push_back(cnt);
            }
            k ^= 1;
            cnt = 0;
        } else {
            cnt++;
        }
    }
    if (k == 0) {
        if (orige == -1) {
            orige = cnt;
        } else if (cnt) ev.push_back(cnt);
    } else {
        if (cnt) od.push_back(cnt);
    }
    long x, y;
    cin >> x >> y;
    x -= orige;
    
    evs[0] = 1;
    ods[0] = 1;
    REP(i,ev.size()) {
        for (int j = 9999; j >= 0; j--) {
            if (j - ev[i] >= 0 && evs[j - ev[i]]) {
                evs[j] = 1;
            }
        }
    }
    REP(i,od.size()) {
        for (int j = 9999; j >= 0; j--) {
            if (j - od[i] >= 0 && ods[j - od[i]]) {
                ods[j] = 1;
            }
        }
    }
    
    int flx = false, fly = false;
    long e = 0, o = 0;
    REP(i,ev.size()) e += ev[i];
    REP(i,od.size()) o += od[i];
    
    REP(i,e+1) {
        if (evs[i]) {
            if (abs(i - (e - i)) == abs(x)) flx = true;
        }
    }
    REP(i,o+1) {
        if (ods[i]) {
            if (abs(i - (o - i)) == abs(y)) fly = true;
        }
    }
    if (flx && fly) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,t;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>t;
    rep(i,t){
        cin>>a>>b>>c>>d;
        if(a<b)Cout("No");
        else if(b>d)Cout("No");
        else{
            pos=b-__gcd(b,d)+a%__gcd(b,d);
            if(pos>c)Cout("No");
            else Cout("Yes");
        }
    }
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
// use std::collections::HashMap;

fn read_int(s: &mut StdinLock) -> usize {
    s.by_ref().bytes().map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .skip_while(|c| c.is_whitespace())
        .fold(0, |a, x| (x as u8 - b'0') as usize + a * 10)
}

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let k = read_int(&mut s);
    let mut ll: usize = 0;
    let mut ll_old: usize = 0;
    for _ in 0..k {
        let mut ll_old_vec: Vec<usize> = ll_old.to_string().chars().map(|x| (x as u8 - b'0') as usize).collect();
        let keta = ll_old_vec.len();
        for j in 1..keta {
            if ll_old_vec[keta-j] < ll_old_vec[keta-j-1] || (ll_old_vec[keta-j] == ll_old_vec[keta-j-1] && ll_old_vec[keta-j] != 9) {
                ll_old_vec[keta-j] += 1;
                for k in keta - j + 1..keta {
                    if ll_old_vec[k-1] > 0 {
                        ll_old_vec[k] = ll_old_vec[k-1] - 1;
                    } else {
                        ll_old_vec[k] = 0;
                    }
                }
                ll = ll_old_vec.iter().fold(0, |a, x| *x as usize + a * 10);
                break;
            }
        }
        if ll != ll_old {
            ll_old = ll;
        } else if ll_old_vec[0] == 9 {
            ll = 10_usize.pow(ll_old_vec.len() as u32);
            ll_old = ll;
        } else {
            ll_old_vec[0] = ll_old_vec[0] + 1;
            for j in 1..keta {
                if ll_old_vec[j-1] > 0 {
                    ll_old_vec[j] = ll_old_vec[j-1] - 1;
                } else {
                    ll_old_vec[j] = 0;
                }
            }
            ll = ll_old_vec.iter().fold(0, |a, x| *x as usize + a * 10);
            ll_old = ll;
        }
        // println!("{}", ll);
    }
    println!("{}", ll);
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    string s;
    cin >> s;

    int size = s.size();
    int amari = 0;

    rep(i, size){
        amari = (amari + (s[i] - '0')) % 9;
    }

    if(amari == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3752
import java.util.Scanner;

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

    String s = scanner.next();
    if (possible(s)) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }

  private static boolean possible(CharSequence s) {
    for (int i = 0; i < s.length();) {
      if (startsWith(s, i, "dreamer")) {
        i += 5;
        if (!startsWith(s, i, "erase")) i += 2;
      } else if (startsWith(s, i, "dream")) {
        i += 5;
      } else if (startsWith(s, i, "eraser")) {
        i += 6;
      } else if (startsWith(s, i, "erase")) {
        i += 5;
      } else {
        return false;
      }
    }
    return true;
  }

  private static boolean startsWith(CharSequence s, int i, String t) {
    if (i + t.length() > s.length()) return false;
    for (int j = 0; j < t.length(); j++) {
      if (s.charAt(i + j) != t.charAt(j)) return false;
    }
    return true;
  }
}


Measured memory_bytes: 26484
l = list(map(str, input()))
n = len(l)
for i in range(2 ** (n-1)):
    bag = ['' for _ in range(n-1)]
    m = l[:]
    idx = n
    for j in range(n-1):
        if (i>>j) & 1:
            bag[j] = '+'
        else:
            bag[j] = '-'        
    for op in bag[::-1]:
        m.insert(idx-1, op)
        idx -= 1

    if eval(''.join(m)) == 7:
        print(''.join(m), "=7", sep="")
        break

Measured memory_bytes: 3064
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto ab = readln.split.to!( int[] );
	writeln( solve( ab[ 0 ], ab[ 1 ] ) );
}

auto solve( in int a, in int b )
{
	return ( a <= 8 && b <= 8 ) ? "Yay!" : ":(" ;
}

unittest
{
	assert( solve( 5, 4 ) == "Yay!" );
	assert( solve( 8, 8 ) == "Yay!" );
	assert( solve( 11, 4 ) == ":(" );
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int n, x;

    while (1) {

        int cnt = 0;

        cin >> n >> x;

        if (n == 0 && x == 0) {
            break;
        }

        for (int i = 1; i <= n - 2; i++) {
            for (int j = i + 1; j <= n - 1; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if (i + j + k == x) {
                        cnt++;
                    }
                }
            }
        }

        cout << cnt << endl;

    }

    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
int main(void) {
	int i, j;
	char s[6];
	j = 0;
	scanf("%s", s);
	for (i = 0; i < 3; i++) {
		if (s[i] == 'o')j++;
	}
	printf("%d\n", 700 + 100 * j);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int n,x;
	while(~scanf("%d%d",&n,&x))
{
	int a[n+1],b[n];
	int i;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	b[0]=0;
	for(i=1;i<=n;i++)
	 {
	 	b[i]=b[i-1]+a[i];
	 }
	 int t=0;
	 for(i=0;i<=n;i++)
	 {
	 	if(b[i]<=x)
	 	t=t+1;
	 }
	 printf("%d\n",t);
}
	 return 0;
}//

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

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

    int64_t odd, even, odd_total, even_total;
    odd = (h + 1) / 2;
    odd_total = odd * ((w + 1) / 2);
    even = h / 2;
    even_total = even * (w / 2);

    int64_t total;
    if (h == 1 || w == 1) {
        total = 1;
    }
    else {
        total = odd_total + even_total;
    }

    cout << total << endl;
}

Measured memory_bytes: 256
N = int(input())
count = {
    'M': 0,
    'A': 0,
    'R': 0,
    'C': 0,
    'H': 0
}

for i in range(N):
    S = input()
    for a in count:
        if S.startswith(a):
            count[a] += 1
# print(count)

val_list = {}
for key, val in count.items():
    if val > 0:
        val_list[key] = val

import itertools

ans = 0
for i in list(itertools.combinations(val_list.keys(), 3)):
    # print(i)
    ans += val_list[i[0]]*val_list[i[1]]*val_list[i[2]]
print(ans)

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

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

using namespace std;

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

const int N_MAX=144,T_MAX=6;
int Dreyfus_Wagner(int n,int d[N_MAX][N_MAX],int nt,int *t){
	rep(k,n) rep(i,n) rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);

	static int dp[1<<T_MAX][N_MAX];
	rep(S,1<<T_MAX) rep(i,n) dp[S][i]=INF;
	rep(i,nt) rep(j,n) dp[1<<i][j]=d[t[i]][j];

	rep(S,1<<nt) if(S && S&S-1) { // |S|>=2
		for(int T=S-1&S;T;T=T-1&S) rep(p,n) {
			dp[S][p]=min(dp[S][p],dp[T][p]+dp[S&~T][p]);
		}
		rep(p,n) rep(q,n) dp[S][p]=min(dp[S][p],dp[S][q]+d[p][q]);
	}

	return dp[(1<<nt)-1][t[0]];
}

int main(){
	for(int h,w;scanf("%d%d",&h,&w),h;){
		int d[N_MAX][N_MAX];
		rep(i,h) rep(j,w) rep(y,h) rep(x,w) d[i*w+j][y*w+x]=(i==y&&j==x?0:INF);

		int n=0,heart[6];
		rep(i,h) rep(j,w) {
			int choco; scanf("%d",&choco);
			if(choco) heart[n++]=i*w+j;
			rep(k,4){
				int y=i+dy[k],x=j+dx[k];
				if(0<=y && y<h && 0<=x && x<w) d[i*w+j][y*w+x]=1;
			}
		}

		printf("%d\n",h*w-Dreyfus_Wagner(h*w,d,n,heart)-1);
	}

	return 0;
}

Measured memory_bytes: 884
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		ArrayList<Integer> list = new ArrayList();
		int cnt = 0;
		int check = 0;

		//リストに追加
		for (int i = 0; i < a; i++) {
			int b = sc.nextInt();
			list.add(b);
		}

		//奇数が含まれていたら0
			//1になるまで繰り返す
			while (list.contains(1) == false) {
				//リスト内を2で割る
				for (int i = 0; i < list.size(); i++) {
					//取り出して
					int new_a = list.get(i);
					//奇数偶数チェック
					check = new_a % 2;
					//奇数があったらcntを-1にしてfor抜ける
					if(check==1) {
						break;
					}
					//割り算をする
					new_a = new_a / 2;
					//リスト更新
					list.set(i, new_a);
				}
				if(check == 1) {
					break;
				}
				cnt++;

			}

		System.out.println(cnt);
	}

}


Measured memory_bytes: 21588
import java.util.*;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		int ans = 0;
		int w = 0;
		int r = 0;
		char[] c = s.toCharArray();
		for (int i = 0; i < s.length(); i++) {
			if (c[i] == 'W')
				w++;
			else 
				r++;

		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < r; i++) {
			sb.append("R");
		}
		for (int i = 0; i < w; i++) {
			sb.append("W");
		}
		String ss = sb.toString();
		for (int i = 0; i < N; i++) {
			if (ss.charAt(i) != s.charAt(i))
				ans++;
		}
		if (ans % 2 != 0)
			ans++;
		System.out.print(ans/2);
	} 
}

Measured memory_bytes: 42076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = "";
		while ((s = br.readLine()) != null) {

			int n = Integer.parseInt(s);

			int[] num = new int[n];

			boolean[] nums = new boolean[n + 1];

			for (int i = 0; i < nums.length; i++) {
				nums[i] = true;
			}

			nums[0] = false;
			nums[1] = false;

			int p = 0;

			for (int i = 2; i < n; i++) {
				num[p++] = i;
				if (nums[i]) {
					for (int k = i * 2; k <= n; k += i) {
						nums[k] = false;
					}
				}
			}
			int count = 0;
			for (int k = 0; k < nums.length; k++) {
				if (nums[k]) {
					count++;
				}
			}
			System.out.println(count);
		}

	}

}

Measured memory_bytes: 55908
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
	map<string, int> m;
	string s;
	while(cin>>s){
		m[s]++;
	}
	string often, longest;
	for(map<string, int>::iterator it=m.begin();it!=m.end();it++){
		if(longest.length() < it->first.length() ){
			longest = it->first;
		}
		if(m[often] < it->second){
			often = it->first;
		}
	}
	cout<<often<<' '<<longest<<endl;
	
	return 0;
}

Measured memory_bytes: 1192
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
const double pi=acos(-1.0);
const int N=200005,inf=100000000;
int a[N];
struct P{
	int x,y;
}p[N];
bool cmp(P a,P b){return a.x<b.x;}
int main(){
	int x1,y1,x2,y2,n,m=0;
	scanf("%d%d%d%d%d",&x1,&y1,&x2,&y2,&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y);
	if (x1>x2) swap(x1,x2),swap(y1,y2);
	if (y1>y2){
		y1=inf-y1;y2=inf-y2;
		for (int i=1;i<=n;i++) p[i].y=inf-p[i].y;
	}
	for (int i=1;i<=n;)
		if (p[i].x<x1||p[i].x>x2||p[i].y<y1||p[i].y>y2) swap(p[i],p[n--]);
			else i++;
	sort(p+1,p+n+1,cmp);
	for (int i=1;i<=n;i++)
		if (p[i].y>=a[m]) a[++m]=p[i].y;
			else a[lower_bound(a+1,a+m+1,p[i].y)-a]=p[i].y;
	double ans=100.0*(x2-x1+y2-y1)+m*(5*pi-20);
	if (m==min(x2-x1,y2-y1)+1) ans+=5*pi;
	printf("%.15f\n",ans);
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void) {
  int a, b, n, i=0;

  while(scanf("%d %d", &a, &b) != EOF) {
    int cnt = 0;
    
    n = a + b;

    while(n > 9) {
      ++cnt;
      n /= 10;
    }

    printf("%d\n", cnt+1);
    ++i;
  }

  return 0;
}



Measured memory_bytes: 2060
#include<stdio.h>
int main(void)
{
	int a,b,c,d,h1,h2,k1,k2,hiroshi,kenjiro;
	scanf("%d %d %d %d %d %d %d %d",&h1,&h2,&k1,&k2,&a,&b,&c,&d);
	hiroshi=h1*a+h2*b+h1/10*c+h2/20*d;
	kenjiro=k1*a+k2*b+k1/10*c+k2/20*d;
	if(hiroshi>kenjiro){
		printf("hiroshi\n");
	}
	else if(hiroshi<kenjiro){
		printf("kenjiro\n");
	}
	else {
		printf("even\n");
	}
	return 0;
}
	


Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, t) for(int i = (s), mi = (t); i <= mi; i++)
#define dwn(i, s, t) for(int i = (s), mi = (t); i >= mi; i--)

int read() {
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)){ if(c == '-') f = -1; c = getchar(); }
	while(isdigit(c)){ x = x * 10 + c - '0'; c = getchar(); }
	return x * f;
}

#define maxn 200010
#define LL long long
#define pii pair <int, int>
#define x first
#define y second
#define mp(x, y) make_pair(x, y)

const LL ool = 1ll << 60;

int n, K, num[maxn], cntn, clr;
pii lr[maxn];

int keepIn(int x) {
	if(x < 0) return x + K;
	if(x >= K) return x - K;
	return x;
}

void getVal(int &x) {
	x = lower_bound(num + 1, num + cntn + 1, x) - num;
	return ;
}

namespace Sgt {
	int setv[maxn<<2];
	
	void pushdown(int o, int l, int r) {
		if(l == r || !setv[o]) return ;
		int lc = o << 1, rc = lc | 1;
		setv[lc] = setv[rc] = setv[o];
		setv[o] = 0;
		return ;
	}
	void update(int o, int l, int r, int ql, int qr, int v) {
		if(ql > qr) return ;
		pushdown(o, l, r);
		if(ql <= l && r <= qr) setv[o] = v;
		else {
			int mid = l + r >> 1, lc = o << 1, rc = lc | 1;
			if(ql <= mid) update(lc, l, mid, ql, qr, v);
			if(qr > mid) update(rc, mid + 1, r, ql, qr, v);
		}
		return ;
	}
	
	int query(int o, int l, int r, int x) {
		pushdown(o, l, r);
		if(l == r) return setv[o];
		int mid = l + r >> 1, lc = o << 1, rc = lc | 1;
		if(x <= mid) return query(lc, l, mid, x);
		return query(rc, mid + 1, r, x);
	}
}

LL f[maxn];

int main() {
	n = read(); K = read();
	int suma = 0, lst;
	LL ans = 0;
	bool ok = 1;
	rep(i, 1, n) {
		int A = read(), B = read();
		if((A << 1) > K && B == 1) ok = 0;
		ans += A << 1;
		lst = suma;
		(suma -= A << 1) %= K;
		if(suma < 0) suma += K;
		if(B == 1) lr[++clr] = mp(lst, suma), num[++cntn] = lr[clr].x, num[++cntn] = lr[clr].y;
	}
	if(!ok) return puts("-1"), 0;
	
	sort(num + 1, num + cntn + 1);
	cntn = unique(num + 1, num + cntn + 1) - num - 1;
	rep(i, 1, clr) getVal(lr[i].x), getVal(lr[i].y);
	dwn(i, clr, 1) {
		int id = Sgt::query(1, 1, cntn, lr[i].x);
		if(!id) f[i] = 0;
		else f[i] = f[id] + (num[lr[id].x] - num[lr[i].x] + K) % K;
		if(lr[i].y < lr[i].x) Sgt::update(1, 1, cntn, lr[i].y + 1, lr[i].x - 1, i);
		else Sgt::update(1, 1, cntn, lr[i].y + 1, cntn, i), Sgt::update(1, 1, cntn, 1, lr[i].x - 1, i);
	}
	
	LL mn = ool;
	rep(i, 1, cntn) {
		int id = Sgt::query(1, 1, cntn, i);
		if(!id) { mn = 0; break; }
		mn = min(mn, f[id] + (num[lr[id].x] - num[i] + K) % K);
	}
	printf("%lld\n", ans + mn);
	
	return 0;
}

Measured memory_bytes: 6528
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(x[k-1])

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int main() {
	makei(D);
	makei(N);
	if (N == 100)++N;
	cout << N;
	rep(D) {
		cout << "00";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/






int N, K, A[101010];
int ok[101010];
vector<int> E[101010];
int ein[101010], dp[101010], vis[101010];
//--------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];

    rep(i, 0, N) {
        if (A[i] == 0) ok[i] = 1;
        else {
            E[i].push_back(A[i] - 1);
            ein[A[i] - 1]++;
        }
    }

    rep(i, 0, N) if (ein[i] == 0) ok[i] = 1;

    queue<int> q;
    rep(i, 0, N) if (ein[i] == 0 && 0 < E[i].size()) {
        q.push(i);
        dp[i] = K;
    }

    while (!q.empty()) {
        int i = q.front(); q.pop();
        if (vis[i]) continue;
        vis[i] = 1;

        if (dp[i] == 0) continue;

        ok[i] = 1;
        fore(to, E[i]) {
            dp[to] = max(dp[to], dp[i] - 1);
            q.push(to);
        }
    }

    int ans = 0;
    rep(i, 0, N) if (ok[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 10768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("in.txt","r",stdin);
    priority_queue< pair< ll,pair< ll,ll > > > q;
    int n,m;
    cin >> n >> m;
    ll sum = 0;
    for(int i=0;i<n;i++){
        ll x;
        cin >> x;
        sum += x;
        q.push(make_pair(x-x/2,make_pair(x/2,1)));
    }
    for(int i=0;i<m;i++){
        if(q.empty())break;
        pair< ll,pair< ll,ll > > curr = q.top();
        q.pop();

        ll value = curr.second.first;
        ll num = curr.second.second;
        sum -= curr.first;
        pair< ll,pair< ll,ll > > next = make_pair(value - value/2,make_pair(value>>1,num+1));
        q.push(next);
    }

    cout << sum << endl;
}


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

using namespace std;
typedef long long ll;

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

    // ll n, m; cin>>n>>m;
    // vector<int> done(n+1, 0);
    // ll pens=0, acs=0;
    // ll p; string s;
    // for(ll i=0; i<m; i++)
    // {
    //     cin>>p>>s;
    //     if(done[p]==0)
    //     {
    //         if(s[0]=='W') pens++;
    //         else if(s[0]=='A') {done[p]=1; acs++;}
    //     }
    // }
    // cout<<acs<<" "<<pens<<endl;


    ll n, m; cin>>n>>m;
    vector<int> ac(n+1, 0);
    vector<int> wa(n+1, 0);
    ll acc=0, wac=0;
    ll p; string s;
    for(int i=0; i<m; i++)
    {
        cin>>p>>s;
        if(ac[p]==0)
        {
            if(s=="WA") wa[p]++;
            else {ac[p]=1; acc++; wac+=wa[p];}
        }
    }
    cout<<acc<<" "<<wac<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<queue>
using namespace std;


int main()
{
    int n,k,x;
    cin>>n>>k;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x>=k) sum++;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

input()
ans = []
for i, j in Counter(map(int, input().split())).items():
    if j >= 4:
        ans.append(i)
    if j >= 2:
        ans.append(i)
if len(ans) >= 2:
    ans.sort()
    print(ans[-1] * ans[-2])
else:
    print(0)


Measured memory_bytes: 28036
while True:
    n=int(input())
    p=0
    if n==0:
        break
    else:
        s=[i for i in range(1,n)]
        for i in range(2,n):
            for j in range(0,n-i+1):
                ss=sum(s[j:i:])
                if ss==n:
                    p+=1
    print(p)


Measured memory_bytes: 5616
while True:
    a, b = list(map(int, input().split()))
    if a == 0 & b == 0:
        break
    ans = 0
    for i in range(1, a + 1):
        for j in range(1, i):
            for n in range(1, j):
                if i + j + n == b:
                    ans += 1
    print(ans)


Measured memory_bytes: 5592
from collections import defaultdict
n = int(input())
dic = defaultdict(list)
mod = 10**9 + 7
for i in range(n-1):
    x, y = map(int, input().split())
    dic[x].append(y)
    dic[y].append(x)
dic_pc = {}
dp = [[1, 1] for i in range(n+1)]
parent = [0] * (n + 1)
v = [0] * (n+1)
q = [1]
cnt = 0
order = []
while q:
    p = q.pop()
    v[p] = 1
    order.append(p)
    for child in dic[p]:
        if v[child]:
            continue
        parent[child] = p
        q.append(child)
order.reverse()
for i in order:
    p = parent[i]
    dp[p][0] *= dp[i][0] + dp[i][1]
    dp[p][0] %= mod
    dp[p][1] *= dp[i][0]
    dp[p][1] %= mod
print(dp[0][0])
        

Measured memory_bytes: 91864
#include<bits/stdc++.h>
#define clr(a,b) memset(a,b,sizeof(a))
using namespace std;

typedef long long ll;

int a, b;
int main(){
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
}



Measured memory_bytes: 256
import collections

from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N = int(input())
s = [" ".join(sorted(list(input()))) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for i in c.values():
    if i > 1:
        ans += cmb(i, 2)
print(ans)


Measured memory_bytes: 20740
num = int(input())
sumList = [0] * num
minusList = [0] * num
for id in range(num):
    x, y = map(int, input().split())
    sumList[id-1] = x + y
    minusList[id-1] = x - y
sumMax = max(sumList) - min(sumList)
minusMax = max(minusList) - min(minusList)
print(max(sumMax, minusMax))


Measured memory_bytes: 24700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{
	int n,m;
	char s;
	string t;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		t="";
		for(int j=0;j<m;j++)
		{
			cin>>s;
			t+=s;
		}
		cout<<t<<endl;
		cout<<t<<endl;
	}
	return 0;
}
	

Measured memory_bytes: 256
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if w-v==0:
    if a!=b:
        print("NO")
    else:
        print("YES")
elif -t<=abs(a-b)//(w-v)<=0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = ReadLine().Split().Select(long.Parse).ToArray();
		var x = n[0];
		var k = n[1];
		var d = n[2];
		var a = Abs(x) / d;
		var b = Min(k, a);
		if(0 < x)
		{
			x -= b * d;
		}
		else if(x < 0)
		{
			x += b * d;
		}

		for(long i = b + 1; i <= k; i++)
		{
			
			if(0 < x)
			{
				var before = x;
				x -= d;
				if(x <= 0)
				{
					if((k - i) % 2 == 0)
					{
						WriteLine(Abs(x));
						return;
					}
					else
					{
						WriteLine(Abs(before));
						return;
					}
				}
			}
			else
			{
				var before = x;
				x += d;
				if (0 <= x)
				{
					if((k - i) % 2 == 0)
					{
						WriteLine(Abs(x));
						return;
					}
					else
					{
						WriteLine(Abs(before));
						return;
					}
				}
			}
		}
		WriteLine(Abs(x));
	}
}


Measured memory_bytes: 19044
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int n, a[1000010], cnt, m[100];
vector<int> v;
void insertionSort(int *a, int n, int g) {
	rep2(i,g,n) {
		int v = a[i];
		int j = i - g;
		while(j >= 0 && a[j] > v) {
			a[j+g] = a[j];
			j -= g;
			cnt++;
		}
		a[j+g] = v;
	}
}
void shellSort(int *a, int n) {
	cnt = 0;
	int h = 1;
	while(h <= n) {
		h = 3 * h + 1;
	}
	while(h) {
		h = (h - 1) / 3;
		if(h) v.push_back(h);
	}
	rep(i,v.size()) {
		insertionSort(a, n, v[i]);
	}
}
int main() {
	cin >> n;
	rep(i,n) {
		cin >> a[i];
	}
	shellSort(a, n);
	cout << v.size() << endl;
	rep(i,v.size() - 1) {
		cout << v[i] << " ";
	}
	cout << v[v.size() - 1] << endl;
	cout << cnt << endl;
	rep(i,n) {
		cout << a[i] << endl;
	}
	return 0;
}

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

using namespace std;

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

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

    vector<pair<int, int>> vt(n);
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        vt[i] = make_pair(a, b);
    }
    sort(vt.begin(), vt.end(), cmp);

    bool flag = true;
    long long tot = 0;
    for (int i = 0; i < n; ++i) {
        tot += vt[i].first;
        if (tot > vt[i].second) flag = false;
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: chars,
        B: chars,
        C: chars,
    }
    let mut S = HashMap::new();
    S.insert('a',A);
    S.insert('b',B);
    S.insert('c',C);
    let mut cnt = HashMap::new();
    cnt.insert('a',0);
    cnt.insert('b',0);
    cnt.insert('c',0);
    let mut turn = 'a';
    while cnt[&turn] < S[&turn].len(){
        let val:usize = *cnt.get(&turn).unwrap();
        cnt.insert(turn, val+1);
        turn = S[&turn][val];
    }
    // ↓は1.16から？
    // let ans = turn.to_uppercase().to_string();
    let ans = match turn {
        'a' => 'A',
        'b' => 'B',
        'c' => 'C',
        _ => ' '
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    
    tmp = 10**10

    for i in range(1,n):
        sa = abs(sum(inlis[:i]) - sum(inlis[i:]))
        if sa <= tmp:
            tmp = sa
    print(tmp)

    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9160
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[10001],ans=0,bns=0,n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+2*n);    
	for(int i=1;i<=2*n;i+=2)
	{
		bns+=a[i];
	} 
	printf("%d\n",bns);
	return 0;
}


Measured memory_bytes: 256