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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int N, Z, W; cin >> N >> Z >> W;
  vi64 a(N); cin >> a;
  
  vi64 dp0(N + 1), dp1(N + 1);
  rrep(i, N) {
    dp0[i] = -1e9;
    i64 Y = (i ? a[i - 1] : W);
    amax(dp0[i], abs(Y - a[N - 1]));
    repi(j, i + 1, N) amax(dp0[i], dp1[j]);

    dp1[i] = -1e9;
    i64 X = (i ? a[i - 1] : Z);
    amax(dp1[i], abs(X - a[N - 1]));
    repi(j, i + 1, N) amin(dp1[i], dp0[j]);
  }
  cout << dp0[0] << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

    vector<int> A(N), B(N);
    inputVector(A, N);
    inputVector(B, N);

    int ret = INT_MAX;
    rep(i, 1 << N) {
        vector<pair<int, int>> even, odd;
        // cerr << "---" << endl;
        // cerr << "i=" << i << endl;
        rep(j, N) {
            // cerr << ((i & (1 << j)) ? 'o' : 'x');
            if ((i & (1 << j)) == 0) {
                if (j % 2 == 0) even.push_back(mp(A[j], j));
                else odd.push_back(mp(A[j], j));
            } else {
                if (j % 2 == 0) odd.push_back(mp(B[j], j));
                else even.push_back(mp(B[j], j));
            }
        }
        // cerr << endl;

        if (even.size() != odd.size() && even.size() != odd.size() + 1) {
            // cerr << "continue!" << endl;
            continue;
        }

        int cnt = 0;
        int val = -1;
        rep(j, N) {
            vector<pair<int, int>> &v = j % 2 == 0 ? even : odd;
            vector<int> &C = j % 2 == 0 ? A : B;
            // cerr << " ";
            // for (auto &a : v) cerr << "(" << a.first << ", " << a.second << ")" << " ";
            // cerr << endl;
            int minIdx = -1;
            int minVal = INT_MAX;
            rep(k, v.size()) {
                if (v[k].first < minVal) {
                    minIdx = k;
                    minVal = v[k].first;
                }
            }
            // cerr << "minVal:" << minVal << endl;
            if (minVal < val) {
                cnt = INT_MAX;
                break;
            }
            val = minVal;

            cnt += v[minIdx].second;

            for (auto &a : even) {
                if (a.second > v[minIdx].second) a.second--;
            }
            for (auto &a : odd) {
                if (a.second > v[minIdx].second) a.second--;
            }
            v.erase(v.begin() + minIdx);
        }
        ret = min(ret, cnt);
    }

    if (ret == INT_MAX) cout << -1 << endl;
    else cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
const long long int mod=1e9+7;


long long int dfs(int K,const vector<vector<int>>&graph, int now,int from) {

	int can_use_color_num;
	if (from==-1) {
		can_use_color_num=K-1;
	}
	else {
		can_use_color_num=K-2;
	}
	if (K<graph[now].size()) {
		return 0;
	}
	else {
		long long int case_num=1;
		for (auto e : graph[now]) {
			if(e==from)continue;

			case_num*=can_use_color_num;
			can_use_color_num--;
			case_num%=mod;
		}
		for (auto e : graph[now]) {
			if(e==from)continue;

			case_num *=dfs(K,graph,e,now);
			case_num %= mod;
		}
		return case_num;
	}
}



int main() {
	int N,K;cin>>N>>K;

	vector<vector<int>>graph(N);
	for (int i = 0; i < N - 1; ++i) {
		int a,b;cin>>a>>b;a--;b--;

		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	long long int answer=K*dfs(K,graph,0,-1);
	answer%=mod;
	cout<<answer<<endl;
	return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,p,q,count=1,i,min;
  cin>>n;
  cin>>p;
  min=p;
  for(i=0;i<n-1;i++)
  {
    cin>>q;
    if(q<min)
    {
      min=q;
      count++;
    }
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
    fscanf(STDIN,"%d%d%d",$L,$R,$d);
    
    $i=1;
    $count=0;
    $ans=$d;
    while($ans<=100){
        $ans = $d*$i;
        // echo $d;
        if($L<=$ans && $ans<=$R){
            $count++;
        }
        $i++;
    }
    echo $count;
?>

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

int main ()
{
	int A = 0 , B = 0 , C = 0 ;
	while ( cin >> A >> B >> C )
	{
			if ( A == 7 ) 
		{
			if ( B == 5 && C == 5 )
			{
				 cout << "YES" << endl ;
			}
			else cout << "NO"  << endl ;
		}
		else if ( A == 5 )
		{
			if ( ( B == 7 && C == 5 ) || ( B == 5 && C == 7 )  )
			{
				 cout << "YES" << endl ;
			} 
			else cout << "NO"  << endl ;
		}
	}
	return 	0 ;
}

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

#define int long long
#define pb push_back
#define all(a) begin(a), end(a)
#define deb(x) cout << #x << " = " << x << endl
template <typename T> vector<T> readVector(int n) { vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; }

void yes() {cout << "YES" << "\n";}
void no() {cout << "NO" << "\n";}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, d;
    cin >> n >> d;
    int ans = 0;
    for(int i=0; i<n; i++) {
        int x, y;
        cin >> x >> y;
        int dist = (int)x*x + y*y;
        if((int)d*d >= (int)dist) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iomanip>
#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() {
  int s, w;
  cin >> s >> w;
  if (s > w) cout << "safe" << endl;
  else cout << "unsafe" << endl;
  return 0;
}

Measured memory_bytes: 3624
import heapq

n, x, y = map(int, input().split())

Edge = [[] for _ in range(n+1)]
for i in range(1,n):
    Edge[i].append([1, i+1])
    Edge[i+1].append([1, i])

Edge[x].append([1,y])
Edge[y].append([1,x])

def dijkstra_heap(s):
    # 始点sから各頂点への最短距離
    d = [10**10] * (n+1)
    used = [False] * (n+1)
    d[s] = 0
    used[s] = True
    edgelist = []
    
    # edgeは各頂点の[重み、行先]からなる配列
    for e in Edge[s]:
        heapq.heappush(edgelist, e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)

        # 未使用の頂点から最小の距離のものを探す
        if used[minedge[1]] == True:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True

        for e in Edge[v]:
            if used[e[1]] == False:
                heapq.heappush(edgelist, [e[0]+d[v], e[1]])
    return d

Ans = [0 for _ in range(n+1)]
for i in range(1,n):
    Dist = dijkstra_heap(i)
    # print(Dist)
    for dist in Dist[i:]:
        Ans[dist] += 1

for i in range(1,n):
    print(Ans[i])

Measured memory_bytes: 74460
dy = (-1,-1,0,1,1,1,0,-1)
dx = (0,1,1,1,0,-1,-1,-1)

def main():
    while True:
        w,h = map(int,input().split())
        if h == 0:
            return
        grid = [list(map(int,input().split())) for _ in range(h)]
        visited = [[0] * w for _ in range(h)]
        ans = 0
        for i in range(h):
            for j in range(w):
                if grid[i][j] == 1 and visited[i][j] == 0:
                    ans += 1
                    stack = [(i,j)]
                    visited[i][j] = 1
                    while stack:
                        p,q = stack.pop()
                        for k in range(8):
                            y = p + dy[k]
                            x = q + dx[k]
                            if y < 0 or y >= h:
                                continue
                            if x < 0 or x >= w:
                                continue
                            if grid[y][x] == 1 and visited[y][x] == 0:
                                stack.append((y,x))
                                visited[y][x] = 1
        print(ans)
if __name__ == '__main__':
    main()



Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
const static int64 INF = 1LL << 55;

int64 N, W[4000], Sum[4001];
int64 dp[4000][4000];
int pos[4000][4000];


int main()
{
  fill_n( *dp, 4000 * 4000, INF);
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> W[i];
    Sum[i + 1] = Sum[i] + W[i];
    dp[i][i] = 0;
  }
  for(int i = 0; i < N; i++) {
    pos[i][i] = i;
  }

  for(int i = 2; i <= N; i++) {
    for(int j = 0; j <= N - i; j++) {
      int left = j, right = j + i - 1;
      for(int k = pos[left][right - 1]; k <= pos[left + 1][right]; k++) {
        int64 Next = dp[left][k] + dp[k + 1][right] + Sum[right + 1] - Sum[left];
        if(dp[left][right] > Next) {
          dp[left][right] = Next;
          pos[left][right] = k;
        }
      }
    }
  }
  cout << dp[0][N - 1] << endl;
}

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

int main() {
    int V, E;
    cin >> V >> E;
    vector<vector<long long> > G(V, vector<long long>(V));
    for(int i=0; i<V; i++) {
        for(int j=0; j<V; j++) {
            if(i==j) G[i][j]=0;
            else G[i][j]=1000000000000000;
        }
    }
    for(int i=0; i<E; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a][b]=c;
    }
    
    for(int k=0; k<V; k++) {
        for(int i=0; i<V; i++) {
            if(G[i][k]==1000000000000000) continue;
            for(int j=0; j<V; j++) {
                if(G[k][j]==1000000000000000) continue;
                G[i][j]=min(G[i][j], G[i][k]+G[k][j]);
            }
        }
    }

    bool negative=false;
    for(int i=0; i<V; i++) {
        if(G[i][i]<0) negative=true;
    }

    if(negative) cout << "NEGATIVE CYCLE" << endl;
    else {
        for(int i=0; i<V; i++) {
            for(int j=0; j<V; j++) {
                if(j) cout << " ";
                if(G[i][j]==1000000000000000) cout << "INF";
                else cout << G[i][j];
            }
            cout << endl;
        }
    }
}


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

int main() {
  int H, W, N; cin >> H >> W >> N;
  int sr, sc; cin >> sr >> sc;
  string S, T; cin >> S >> T;

  int left = 1, right = W;
  if (S.at(N-1) == 'L') left++;
  if (S.at(N-1) == 'R') right--;
  for (int i = N-2; i >= 0; i--) {
    if (T.at(i) == 'L') right = min(right + 1, W);
    if (T.at(i) == 'R') left = max(1, left - 1);
    if (S.at(i) == 'L') left++;
    if (S.at(i) == 'R') right--;
    if (left > right) { cout << "NO" << endl; return 0; }
  }
  if (sc < left || sc > right) { cout << "NO" << endl; return 0; }

  int up = 1, down = H;
  if (S.at(N-1) == 'U') up++;
  if (S.at(N-1) == 'D') down--;
  for (int i = N-2; i >= 0; i--) {
    if (T.at(i) == 'U') down = min(down + 1, H);
    if (T.at(i) == 'D') up = max(1, up - 1);
    if (S.at(i) == 'U') up++;
    if (S.at(i) == 'D') down--;
    if (up > down) { cout << "NO" << endl; return 0; }
  }
  if (sr < up || sr > down) { cout << "NO" << endl; return 0; }
  cout << "YES" << endl;
}

Measured memory_bytes: 3920
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input())
    D, X = li_input()
    A = [int(input()) for _ in range(N)]

    print(
        sum([math.ceil(D / a) for a in A]) + X
    )


main()


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

int main() {
  int N;
  cin >> N;
  string ans = "Three";
  for (int i = 0; i < N; i++) {
    char S;
    cin >> S;
    if (S == 'Y') {
      ans = "Four";
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


int main() {
	ll x, y, a, b, ans = 0;
	cin >> x >> y >> a >> b;
	double p = x * y;
	if (x % 2 == 0 and y % 2 == 0 and x / 2 == a and y / 2 == b) ans = 1;
	cout << fixed << p / 2;
	cout << " " << ans << endl;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

b = Hash.new(0)
c = Hash.new(0)

n.times{|i|
  b[a[i]]+=1 if i%2==0
  c[a[i]]+=1 if i%2==1
}

if a.uniq.size == 1
  p n/2
else
  b = b.sort{|a,b|a[1]<=>b[1]}
  c = c.sort{|a,b|a[1]<=>b[1]}
  if b[-1][0] == c[-1][0]
    ans1 =  n/2 - c[-2][1].to_i + n/2 - b[-1][1].to_i
    ans2 =  n/2 - b[-2][1].to_i + n/2 - c[-1][1].to_i
    p [ans1, ans2].min
  else
    p (n/2 - b[-1][1]) + (n/2 - c[-1][1])
  end
end


Measured memory_bytes: 21908
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  int b[n];
  long long int a_sum = 0;
  long long int b_sum = 0;
  int i = 0;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    a_sum += (long long int) a[i];
  }
  for(i=0;i<n;i++){
    scanf("%d",&b[i]);
    b_sum += (long long int) b[i];
  }
  if(a_sum < b_sum){
    puts("-1");
    return 0;
  }
  int d[n];
  for(i=0;i<n;i++){
    d[i] = a[i] - b[i];
  }
  qsort(d, n, sizeof(int), compare_int);
  int ans = 0;
  i = 0;
  long long int need = 0;
  while(d[i] < 0){
    need += (long long int) d[i];
    ans++;
    i++;
  }
  i = n - 1;
  while(need < 0){
    need += (long long int) d[i];
    ans++;
    i--;
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(void)
{
	int a,b;
	
	cin >> a >> b;
	
	if(a < b) {
		cout << "a < b" << endl;
	} else if(a == b) {
		cout << "a == b" << endl;
	} else {
		cout << "a > b" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3044
n=int(input())
s=[i for i in input()]
import collections
c=collections.Counter(s)
if len(c)<3:
    print(0)
    quit()
ans=c["R"]*c["G"]*c["B"]
for i in range(1,(n+1)//2):
    for j in range(n):
        if j+i+i>=n:
            break
        if s[j]!=s[j+i] and s[j]!=s[j+i+i] and s[j+i]!=s[j+i+i]:
            ans-=1
print(ans)

Measured memory_bytes: 68824
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll n,ans,a,b;
vector<ll> q(10),p(10);
void solve()
{
    cin>>n;
    vector<ll> chk(n);
    for(ll i=0;i<n;i++)
    {
        cin>>p[i];
        chk[i]=i+1;
    }
    for(ll i=0;i<n;i++)
    {
        cin>>q[i];
    }
    ll i=0,fir,sec;
    do
    {
        bool pf,qf;     pf=qf=1;
         for(ll i=0;i<n;i++)
        {
            if(chk[i]!=p[i])
                {pf=0;break;}
        }
        for(ll i=0;i<n;i++)
        {
            if(chk[i]!=q[i])
                {qf=0;break;}
        }
        if(pf)
            fir=i;
        if(qf)
            sec=i;
        i++;
    }while(next_permutation(chk.begin(),chk.end()));
    cout<<abs(fir-sec)<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import math
while(True):
    a,op,b=input().split()
    a = int(a)
    b = int(b)
    if (op == '+'):print(a + b)
    elif (op == '-'):print(a - b)
    elif (op == '*'):print(a * b)
    elif (op == '/'):print(int(a / b))
    elif (op == '?'):break

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

H = input().split()

C = [0] * N

for MM in range(M):
    A, B = map(int,input().split())

    if int(H[A-1]) == int(H[B-1]):
        C[A-1] = 1
        C[B-1] = 1
    elif int(H[A-1]) > int(H[B-1]):
        C[B-1] = 1
    else :
        C[A-1] = 1

ANS = 0

for CC in C:
    if CC == 0:
        ANS += 1

print(ANS)

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

using namespace std;

struct P {
	int x, y;
};

struct Edge {
	int to, cost;
};

const int inf = 1e9;

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

int W, H;
int dist[20][20];
bool m[20][20];
bool inRange(int x, int y) {
	return 0 <= x && x < W && 0 <= y && y < H;
}
void bfs(P s) {
	fill(dist[0], dist[20], inf);
	dist[s.y][s.x] = 0;
	queue<P> Q; Q.push( (P){s.x, s.y} );
	while ( !Q.empty() ) {
		P p = Q.front(); Q.pop();
		for (int d = 0; d < 4; ++d) {
			int nx = p.x+dx[d];
			int ny = p.y+dy[d];
			if (inRange(nx, ny) && !m[ny][nx] && dist[p.y][p.x]+1 < dist[ny][nx]) {
				dist[ny][nx] = dist[p.y][p.x]+1;
				Q.push((P){nx, ny});
			}
		}
	}
}
int main() {
	while (cin >> W >> H, W || H) {
		fill(m[0], m[20], false);
		int sx = -1, sy = -1;
		vector<P> target;
		for (int y = 0; y < H; ++y) {
			string str; cin >> str;
			for (int x = 0; x < W; ++x) {
				switch (str[x]) {
					case '.': break;
					case 'o': sx = x, sy = y; break;
					case '*': target.push_back( (P){x, y} ); break;
					case 'x': m[y][x] = true; break;
				}
			}
		}
		target.push_back((P){sx, sy});
		int cost[20][20];
		int N = target.size();
		for (int i = 0; i < N; ++i) {
			bfs(target[i]);
			for (int j = 0; j < N; ++j) {
				cost[i][j] = dist[target[j].y][target[j].x];
//				cout << i << " " << j << " " << cost[i][j] << endl;
			}
		}

		int dp[12][1 << 11]; fill(dp[0], dp[12], inf); dp[N-1][1<<(N-1)] = 0;
		for (int w = 1; w <= N; ++w) {
			for (int i = 0; i < N; ++i) {
//				for (int j = 1; j < (1 << N); ++j) {
				int j = (1 << w)-1;
				while (j < 1 << N) {
					for (int to = 0; to < N; ++to) {
						if ( (j & (1 << to)) == 0 && dp[i][j] != inf ) {
//							cout << i << " " << j << " " << to << " " << dp[i][j] << " " << cost[i][to] << endl;
							dp[to][j|(1<<to)] = min(dp[to][j|(1<<to)], dp[i][j]+cost[i][to]);
						}
					}
					int x = j & -j, y = j+x;
					j = ((j&~y)/x>>1) | y;
				}
			}
		}
		int ans = inf;
		for (int i = 0; i < N; ++i) {
			ans = min(ans, dp[i][(1<<N)-1]);
		}
		if (ans == inf) {
			cout << -1 << endl;
		}
		else {
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =   998244353;
string s;
void fn(int x)
{
    if(x==s.size())
    {
        cout<<"YES";
        exit(0);
    }
    if(s.substr(x,5)=="dream") fn(x+5);
     if(s.substr(x,5)=="erase") fn(x+5);
      if(s.substr(x,6)=="eraser") fn(x+6);
       if(s.substr(x,7)=="dreamer") fn(x+7);
}
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

cin>>s;
fn(0);
cout<<"NO";
}







Measured memory_bytes: 1872
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
bool dp1[8005][16005],dp2[8005][16005];
vector<int> a1,a2;

int main()
{
	string S;
	cin >> S;
	int x,y;
	cin >> x >> y;
	int cnt = 0;
	while(cnt <= S.size())
	{
		if (S[cnt] == 'F') cnt++;
		else break;
	}
	bool UD = true;
	int cnt2 = 0;
	for (int i = cnt+1; i < S.size(); ++i)
	{
		if (S[i] == 'T')
		{
			if (UD) 
			{
				a2.push_back(cnt2);
				UD = false;
			}
			else
			{
				a1.push_back(cnt2);
				UD = true;
			}
			cnt2 = 0;
		}
		else
		{
			cnt2++;
		}
	}
	if (UD) 
	{
		a2.push_back(cnt2);
		UD = false;
	}
	else
	{
		a1.push_back(cnt2);
		UD = true;
	}
	/*
	cout << cnt << endl;
	rep(i,a1.size())
	{
		cout << a1[i] << " ";
	}
	cout << endl;
	rep(i,a2.size())
	{
		cout << a2[i] << " ";
	}
	cout << endl;
	*/
	int a1s = a1.size(), a2s = a2.size();
	dp1[0][8000+cnt] = true;
	rep(i,a1s)
	{
		rep(j,16005)
		{
			if (dp1[i][j])
			{
				dp1[i+1][j-a1[i]] = true;
				dp1[i+1][j+a1[i]] = true;
			}
		}
	}
	dp2[0][8000] = true;
	rep(i,a2s)
	{
		rep(j,16005)
		{
			if (dp2[i][j])
			{
				dp2[i+1][j-a2[i]] = true;
				dp2[i+1][j+a2[i]] = true;
			}
		}
	}
	//cout << dp1[a1s][8000+x] << " " << dp2[a2s][8000+y] << endl;
	if (dp1[a1s][8000+x] && dp2[a2s][8000+y]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 125696
N, M = map(int,input().split())
P = [[] for k in range(N)]
A = [0 for k in range(M)]

for k in range(M):
    s, t = map(int,input().split())
    P[s-1].append([t,k])

for k in range(N):
    P[k].sort()
    for l in range(len(P[k])):
        A[P[k][l][1]] = str(k+1).zfill(6) + str(l+1).zfill(6)

for a in A:
    print("".join(a))

Measured memory_bytes: 81712
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e6+10;
int main()
{
    FASTINOUT;
    ll x,d,y;
    cin>>x>>d;
    ll mn=0;
    for (int i=0;i<x;i++){
        cin>>y;
        mn=__gcd(mn,abs(y-d));
    }
    cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100001][3],dp[100001][8],n,k;

int call(int i,int s){
    if(i==n)
        return 0;
    if(dp[i][s]!=-1)
        return dp[i][s];
    int res=0;
    if(!(s&(1<<0)))
       res=max(res,a[i][0]+call(i+1,1));
    if(!(s&(1<<1)))
       res=max(res,a[i][1]+call(i+1,2));
    if(!(s&(1<<2)))
        res=max(res,a[i][2]+call(i+1,4));
    return dp[i][s]=res;
}


int main(){

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    memset(dp,-1,sizeof(dp));
    cout<<call(0,0);



return 0;
}


Measured memory_bytes: 12620
#include <stdio.h>

void amida(int a, int b, int list[]) {
  int tmp;

  tmp = list[a - 1];
  list[a - 1] = list[b - 1];
  list[b - 1] = tmp;
}

int main(void) {
  int w, n, a, b, i;
  int list[30];

  for (i = 0; i < 30; i++)
    list[i] = i + 1;

  scanf("%d", &w);
  scanf("%d", &n);

  while (!!n--) {
    scanf("%d,%d", &a, &b);

    amida(a, b, list);
  }

  for (i = 0; i < w; i++)
    printf("%d\n", list[i]);

  return 0;
}

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

// Contest: AtCoder Beginner Contest 152 (https://atcoder.jp/contests/abc152)
// Problem: C: Low Elements (https://atcoder.jp/contests/abc152/tasks/abc152_c)

using namespace std;

#define sz(x)       (int)size(x)
#define rep(a, b)   for(int a = 0; a < (b); ++a)
#define all(a)      (a).begin(),(a).end()
#define trav(a, b)  for(auto& a : b)

template <class T, size_t... Is> struct arr_helper;
template <class T, size_t... Is> using arr = typename arr_helper<T, Is...>::type;
template <class T> struct arr_helper<T> { using type = T; };
template <class T, size_t I, size_t... Is>
struct arr_helper<T, I, Is...> { using type = array<arr<T, Is...>, I>; };

using ll = long long;
using u64 = uint64_t;
using u32 = uint32_t;

using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pi>;

const int INF = (int)1e9;
const ll INFL = (ll)1e18;

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

    int n; cin >> n;
    vi p(n);
    trav(pi, p) cin >> pi;

    int cnt = 0, mn = INF;
    rep(i, n) {
        mn = min(mn, p[i]);
        cnt += (mn == p[i]);
    }

    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    long long res = 0;
    for (int i = 0, j = 0, x = 0, s = 0; i < n; ++i) {
        x ^= A[i];
        s += A[i];
        while (x != s) {
            x ^= A[j];
            s -= A[j];
            ++j;
        }
        res += i - j + 1;
    }

    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int tax(int a, int t) {
    return static_cast<int> (a*(100+t)/100);
}

int main()
{
    int x, y, s, ans;
    
    while (cin >> x >> y >> s) {
        if (x==0) break;

        ans = 0;
        for (int i = 1; i < s; i++) {
            for (int j = i; j < s; j++) {
                if (tax(i,x)+tax(j,x) == s) {
                    ans = max(ans, tax(i,y)+tax(j,y));
                }
            }
        }
        cout << ans << endl;
    }
}

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

string addplus(string, string);

long long calc(string);

string next(string);


int main()
{
	//S=1なら1個、S=2なら2個、S=nなら、各数字の間に入れる入れないがあるので2^(n-1)個。

	string S;
	cin >> S;
	int veclen = S.length()-1;
	string plus = "";
	string last = "";
	for (int i = 0; i < veclen; i++)
	{
		plus += "0";
		last += "1";
	}
	long long output;
	output = 0;
	while (plus != last)
	{
		string next_siki = addplus(S, plus);
		output += calc(next_siki);
		plus = next(plus);
	}
	output += calc(addplus(S, plus));
	cout << output << endl;
	return 0;
}

string next(string s)
{
	string output = s;
	int keta = '1';
	int zero = '0';
	int one = '1';
	int two = '2';
	for (int i = s.length() - 1; i != -1; i--)
	{
		if (s[i] + keta == zero + zero)
		{
			output[i] = '0';
			keta = '0';
		}
		if (s[i] + keta == zero + one)
		{
			output[i] = '1';
			keta = '0';
		}
		if (s[i] + keta == one + one)
		{
			output[i] = '0';
			keta = '1';
		}

	}
	return output;

}

long long calc(string s)
{
	long long output = 0;
	long long lookingnumber = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] != '+')
		{
			lookingnumber *= 10;
			long long keta = s[i]-'1'+1;
			lookingnumber += keta;
		}
		else
		{
			output += lookingnumber;
			lookingnumber = 0;
		}
	}
	output += lookingnumber;
	return output;
}

string addplus(string s, string plus)
{
	string output = s;
	for (int i = plus.length() - 1; i != -1; i--)
	{
		if (plus[i] == '1')
		{
			output = output.substr(0, i+1) + "+" + output.substr(i + 1, output.length()-1);
		}
	}
	return output;

}

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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
//		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		if (str.length() == 2)
			System.out.println(str);
		else {
			for (int i = 2; i >= 0; i--) {
				System.out.print(str.charAt(i));
			}
			System.out.println();
		}
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int A[100000 + 10];
int M[100000 + 10]; //i番目の店でリンゴ買った時に売れる最高額

signed main(void) {
    int N, T;
    cin >> N >> T;
    rep(i, N) {
        cin >> A[i];
    }
    int Max = A[N-1];
    M[N-1] = 0;
    for (int i=N-2; i>=0; i--) {
        M[i] = Max;
        if (A[i] > Max) Max = A[i];
    }

    int Mmargin = 0;
    rep(i, N) {
        Mmargin = max(Mmargin, M[i]-A[i]);
    }

    int n_chance=0;
    rep(i, N) {
        if (M[i]-A[i] == Mmargin) n_chance++;
    }

    cout << n_chance << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

//Weighted edge set
template <typename T>
using Edges = vector<edge<T>>;

//Weighted graph
template <typename T>
using WeightedGraph = vector<Edges<T>>;

template <typename T>
T Prim(WeightedGraph<T> &g)
{
    T res = 0;
    vector<bool> used(g.size(), false);
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> que;
    que.emplace(0, 0);
    while (que.empty() != true)
    {
        auto p = que.top();
        que.pop();
        if (used[p.second] == true)
            continue;
        used[p.second] = true;
        res += p.first;
        for (auto &e : g[p.second])
        {
            que.emplace(e.cost, e.to);
        }
    }
    return res;
}

int N;

int main()
{
    cin >> N;
    vector<pair<pair<int, int>, int>> x, y;
    WeightedGraph<int> G(N);
    for (int i = 0; i < N; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        x.emplace_back(make_pair(a, b), i);
        y.emplace_back(make_pair(b, a), i);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    for (int i = 0; i + 1 < N; i++)
    {
        int a = x[i].first.first, b = x[i].first.second, c = x[i + 1].first.first, d = x[i + 1].first.second;
        int p1 = x[i].second, p2 = x[i + 1].second;
        G[p1].emplace_back(p2, min(abs(a - c), abs(b - d)));
        G[p2].emplace_back(p1, min(abs(a - c), abs(b - d)));
    }

    for (int i = 0; i + 1 < N; i++)
    {
        int a = y[i].first.first, b = y[i].first.second, c = y[i + 1].first.first, d = y[i + 1].first.second, p1 = y[i].second, p2 = y[i + 1].second;
        G[p1].emplace_back(p2, min(abs(a - c), abs(b - d)));
        G[p2].emplace_back(p1, min(abs(a - c), abs(b - d)));
    }

    cout << Prim(G) << endl;
}

Measured memory_bytes: 14636
#include<iostream>
#include<cstring>
#define MAX 90
using namespace std;
char str[MAX];
bool contain(){
	for(int i=0;str[i]!='\0';i++){
		if(str[i]=='t'){
			if(strncmp(&str[i],"the",3)==0)
			return 1;
			else if(strncmp(&str[i],"this",4)==0)
			return 1;
			else if(strncmp(&str[i],"that",4)==0)
			return 1;
		}
	}
	return 0;
}
void rotate(){
	for(int i=0;str[i]!='\0';i++)
	if(str[i]=='z')
	str[i]='a';
	else if(isalpha(str[i]))
	str[i]=(char)(str[i]+1);
}
int main(){
	while(cin.getline(str,MAX)){
		for(int i=0;i<26;i++){
			rotate();
			if(contain())
				break;
		}
		cout<<str<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
from scipy.sparse import*;f=lambda*z:map(int,input().split());n,=f();g,h=csgraph.dijkstra(csr_matrix(([1]*~-n,list(zip(*map(f,[0]*~-n)))),[n+1]*2),0,[1,n]);print('FSennunkeec'[sum(g[i]>h[i]for i in range(n+1))*2>=n::2])

Measured memory_bytes: 69728
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n,a,b;cin>>n>>a>>b;
  if(a%2==b%2){
    cout<<min({(b-a)/2,max(a-1,b-1),max(n-a,n-b)})<<endl;
    return 0;
  }
  cout<<min({max(a-1,b-1),max(n-a,n-b),(n-a+n-b+1)/2,(a+b-2+1)/2})<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>

using namespace std;
 
int main(){
    int h, w;
    char flag[1000][1000];

    scanf("%d %d\n", &h, &w);
    vector<pair<int, int> > blacks;
    for(int i = 0; i < h; ++i){
        string s;
        getline(cin, s);
        for(int j = 0; j < s.size(); ++j){
            if(s.at(j) == '#'){
                blacks.push_back(pair<int, int>(i, j));
                flag[i][j] = 1;
            }else{
                flag[i][j] = 0;
            }
        }
    }

    int count = 0;
    while(1){
        // printf("count = %d, blacks.size() = %ld\n", count, blacks.size());
        vector<pair<int, int> > new_blacks;
        for(auto &p : blacks){
            if(p.first > 0 && flag[p.first - 1][p.second] == 0){
                new_blacks.push_back(pair<int, int>(p.first - 1, p.second));
                flag[p.first - 1][p.second] = 1;
            }
            if(p.first < h - 1 && flag[p.first + 1][p.second] == 0){
                new_blacks.push_back(pair<int, int>(p.first + 1, p.second));
                flag[p.first + 1][p.second] = 1;
            }
            if(p.second > 0 && flag[p.first][p.second - 1] == 0){
                new_blacks.push_back(pair<int, int>(p.first, p.second - 1));
                flag[p.first][p.second - 1] = 1;
            }
            if(p.second < w - 1 && flag[p.first][p.second + 1] == 0){
                new_blacks.push_back(pair<int, int>(p.first, p.second + 1));
                flag[p.first][p.second + 1] = 1;
            }
        }
        // printf("new_blacks.size() = %ld\n", new_blacks.size());
        if(!new_blacks.empty()){
            count++;
        }else{
            break;
        }
        blacks = new_blacks;
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 15976
fun main(args :Array<String>) {
    val n = readInteger()
    val aArray = readIntegerList().toIntArray()

    var m = 0
    val boxes = IntArray(n)
    for (i in (n - 1) downTo 0) {
        var count = 0
        for (j in i until n step (i + 1)) {
            count += boxes[j]
        }

        if (count % 2 != aArray[i]) {
            m++
            boxes[i] = 1
        }
    }

    println(m)
    val ans = boxes
        .mapIndexed { index, it ->
            if (it == 1) index + 1 else 0
        }.filter { it > 0 }
        .joinToString(" ")
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 78152
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        Arrays.sort(s);
        String ans = "No";
        if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ans = "Yes";
        System.out.println(ans);
    }
}


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

int main() {
  int N;
  cin >> N;
  string a;
  for (int i = 0; i < N; i++) {
    cin >> a;
    if(a == "Y"){
      cout << "Four" << endl;
      exit(0);
    }
  }
  cout << "Three" << endl;
  
}

Measured memory_bytes: 3556
import collections

def comb2(n):
    return (n*(n-1))//2

n=int(input())
a=list(map(int,input().split()))

sums=[0]
for i in range(n):
    sums.append(sums[i]+a[i])
counts=collections.Counter(sums)

res=0

for i in counts:
    res += comb2(counts[i])
print(res)

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

int main() {
  
  	int N,A,B;
  	cin >> N >> A;
  
  	B=N%500;
  	if(A>=B){
    	cout << "Yes" << endl;
    }
  	else{
    	cout << "No"<< endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> S;
  if(S[0]>='a')Out('a');
  else Out('A');
}

Measured memory_bytes: 3608
import java.util.*

fun main(args: Array<String>) {
    val s = Scanner(System.`in`)
    val a = s.nextInt()
    val b = s.nextInt()
    val k = s.nextInt()

    val pa = (1..a).filter { a % it == 0 }
    val pb = (1..b).filter { b % it == 0 }
    val ret = pa.intersect(pb).sortedDescending()[k - 1]
    println(ret)
}

Measured memory_bytes: 36036
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string str;
	cin >> str;
	
	int i = 0, count = 0;
	int ans = 0;
	while(i < str.size()){
		if(str[i] == 'O'){
			count++;
			if(str[i + 1] != 'O'){
				if(i >= count && i + count < str.size()){
					int a = 0;
					bool check = true;
					while(a < count){
						if(str[i - count - a] != 'J' || str[i + count - a] != 'I'){
							check = false;
							break;
						}
						a++;
					}
					if(check)
						ans = max(ans, count);
				}
				count = 0;
			}
		}
		++i;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2704
n = int(input())
a = list(map(int, input().split()))
four = 0
two = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0:
        two += 1

if four >= n // 2 or n - 2 * four <= two:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 20064
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define Rep1(i,k,n) for(int i=k ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

int main(){

    int n; cin >> n;
    int r = n % 100;
    int l = n/100;

    if((r > 12 or r == 0) and (l > 12 or l == 0)) cout << "NA" << endl;
    else if(r > 12 or r == 0) cout << "MMYY" << endl;
    else if(l > 12 or l == 0) cout << "YYMM" << endl;
    else cout << "AMBIGUOUS" << endl; 
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	char c;
	cin >> c;
	if(c>='a') cout << 'a';
	else cout << 'A';
	return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    if (N < 1000) {
        print("ABC");
    } else {
        print("ABD");
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 256
def main():
    sx, sy, tx, ty = map(int, input().split())
    ans = ""
    ans += "U" * (ty - sy)
    ans += "R" * (tx - sx)
    ans += "D" * (ty - sy)
    ans += "L" * (tx - sx)
    ans += "L"
    ans += "U" * (ty - sy + 1)
    ans += "R" * (tx - sx + 1)
    ans += "D"
    ans += "R"
    ans += "D" * (ty - sy + 1)
    ans += "L" * (tx - sx + 1)
    ans += "U"
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 80140
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int h[110];
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  int ans = 0;
  for(int i=0; i<100000; i++){
    int cnt = 0;
    for(int j=0; j<n; j++){
      if(cnt>0 && h[j]==0){
        ans++;
        cnt = 0;
        continue;
      }
      if(h[j]==0) continue;
      h[j]--;
      cnt++;
    }
    if(cnt>0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384