akhauriyash/Code-Regression huggingface dataset:
op = 'a'

while op != '?':
    l = input().split()
    a = int(l[0])
    b = int(l[2])
    op = l[1]
    answer = 0

    if (op == '+'):
        answer = a + b
    elif (op == '-'):
        answer = a - b
    elif (op == '/'):
        answer = a // b
    elif ( op == '*'):
        answer = a * b
    elif ( op == '?'):
        break
    print(str(answer))


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

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    sort(p, p+n);
    int result = 0;
    for(int i=0;i<n-1;i++){
        result += p[i];
    }
    result += p[n-1] / 2;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;
constexpr int Inf = 1 << 28;

int main()
{
    int n;
    int T[3];
    cin >> n >> T[2] >> T[1] >> T[0];

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

    auto GetCost = [&L](int bit, int destLength)
    {
        if (bit == 0)
        {
            return Inf;   // Very high cost
        }

        int length = 0;
        int cost = -10;
        int index = 0;

        while (bit > 0)
        {
            if ((bit & 1) == 1)
            {
                length += L[index];
                cost += 10;
            }

            bit >>= 1;
            index++;
        }

        cost += abs(destLength - length);
        return cost;
    };

    int ans = Inf;

    for (int bit1 = 0; bit1 < (1 << n); bit1++)
    {
        for (int bit2 = 0; bit2 < (1 << n); bit2++)
        {
            for (int bit3 = 0; bit3 < (1 << n); bit3++)
            {
                int cost = 0;
                cost += GetCost(bit1, T[0]);
                cost += GetCost(bit2 & ~bit1, T[1]);
                cost += GetCost(bit3 & ~bit1 & ~bit2, T[2]);
                ans = min(ans, cost);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	string k="keyence";
	string t;
	cin>>t;
	if(t.size()<k.size()) return 0*printf("NO\n");
	for(int i=0;i<k.size()+1;i++)
	{
		string s=t.substr(0,i)+t.substr(t.size()-k.size()+i,k.size()-i);
		if(s==k) return 0*printf("YES\n");
	}
	printf("NO\n");
	return 0;
}


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

using namespace std;
long long MOD = 1000000007LL;
template<class T>
T gcd(T x, T y) {
	return y ? gcd(y, x % y) : x;
}

template<class T>
vector<T> enum_div(T n) {
	vector<T> ret;
	for (T i = 1; i * i < n; ++i) {

		if (n % i == 0) {
			ret.push_back(i);

			if (i != 1 && i * i != n) {
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}

template<class T>
map<T, int> prime_factorization(T n) {
	map<T, int> ret;

	for (long long i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}

	if (n != 1)ret[n] = 1;
	return ret;
}

template<class T>
long long C(T n, T r) {
	static map<pair<T, T>, long long> _map;
	if (n < r) return 0;

	if (n == r || r == 0) {
		_map[make_pair(n, r)] = 1ll;
	}
	else if (_map[make_pair(n, r)] == 0) {
		_map[make_pair(n, r)] = (C(n - 1, r) + C(n - 1, r - 1));
	}

	_map[make_pair(n, r)] %= MOD;
	return _map[make_pair(n, r)];
}

int main() {
	int N, K;
	cin >> N >> K;
	if (N % K == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}



	return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
P = list(map(int, input().split()))

Y = X
Z = X
ans = 0
while True:
    if Y not in P:
        ans = Y
        break
    elif Z not in P:
        ans = Z
        break
    else:
        Y -= 1
        Z += 1

print(ans)


Measured memory_bytes: 9180
import java.util.*;
public class Main {
public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int X = sc.nextInt();
        // スペース区切りの整数の入力
        int K = sc.nextInt();

      
      if((500*X) >= K){
        System.out.println("Yes");
      }else{
          System.out.println("No");
      }
      
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#include <random>
#include <atcoder/all>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint MOD = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<lint, char> pa;

using namespace atcoder;
int N, M;
char mp[100][100];
int main() {
	cin >> N >> M;
	mf_graph<int> G(N * M + 2);
	int s = N * M, t = s + 1;
	REP(i, N) {
		REP(j, M) {
			cin >> mp[i][j];
			if (mp[i][j] == '#') continue;
			if ((i + j) % 2 == 0) {
				G.add_edge(s, i * M + j, 1);
			}
			else {
				G.add_edge(i * M + j, t, 1);
			}
		}
	}
	REP(i, N) {
		REP(j, M) {
			if ((i + j) % 2 == 1) continue;
			if (mp[i][j] == '#') continue;
			REP(k, 4) {
				lint ny = i + dy[k], nx = j + dx[k];
				if (ny < 0 || nx < 0 || ny >= N || nx >= M) continue;
				if (mp[ny][nx] == '#') continue;
				G.add_edge(i * M + j, ny * M + nx, 1);
			}
		}
	}

	cout << G.flow(s, t) << endk;
	auto ess = G.edges();
	for (auto itr : ess) {
		if (itr.flow == 0) continue;
		if (itr.from == s || itr.to == t) continue;
		pair<int, int> p = { itr.from, itr.to };
		if (p.first > p.second) swap(p.first, p.second);
		if (p.first + M == p.second) {
			mp[p.first / M][p.first % M] = 'v';
			mp[p.second / M][p.second % M] = '^';
		}
		else {
			mp[p.first / M][p.first % M] = '>';
			mp[p.second / M][p.second % M] = '<';
		}
	}
	REP(i, N) {
		REP(j, M) {
			cout << mp[i][j];
		}
		cout << endk;
	}
}


Measured memory_bytes: 5480
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define mci             map<char,int>
#define msi             map<string,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
  freopen("ip1.txt", "r", stdin);
  freopen("op1.txt", "w", stdout);
#endif
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
  return (a.second < b.second);
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int prime(int n) {
  int flag = 1;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {flag = 0; break;}
  }
  return flag;
}
int power(int x, int y)
{
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
  else
    return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}
// int JUDGE_ONLINE = 1;
// if (fopen("ip1.txt", "r")) {
//  JUDGE_ONLINE = 0;
//  assert(freopen("ip1.txt", "r", stdin));
//  assert(freopen("op1.txt", "w", stdout));
// }

// if (!JUDGE_ONLINE) {
//  cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
// }


int32_t main()
{
  k_007();
  long double d,t,s;
  cin>>d>>t>>s;
  if(t >= (d/s))
  {
    cout<<"Yes"<<endl;
  }
  else cout<<"No\n";

}


Measured memory_bytes: 3800
n, k = map(int, input().split())
p = [0] + list(map(int, input().split()))
c = [0] + list(map(int, input().split()))

ans = - 10 ** 18
for i in range(1, n+1):
    base = i
    nxt = p[i]
    cnt = 0
    score = 0
    while True:
        cnt += 1
        if cnt > k:
            break
        score += c[nxt]
        ans = max(ans, score)
        #print("i = ", i, "ans = ", ans, "score = ", score)
        if nxt == base:
            break
        nxt = p[nxt]
    if cnt >= k:
        continue
    extra = k - cnt
    score_tmp = score
    nxt = p[nxt]
    nxt_tmp = nxt
    for j in range(min(extra, cnt)):
        score += c[nxt]
        ans = max(ans, score)
        #print("ans = ", ans, "score = ", score, "nxt = ", nxt, "c[nxt] = ", c[nxt])
        nxt = p[nxt]
    #print("score = ", score, "ans = ", ans)
    score = score_tmp
    nxt = nxt_tmp
    a = extra // cnt
    if extra % cnt == 0:
        a -= 1
    score += score * max(a, 0)
    ans = max(ans, score)
    for j in range(extra - a * cnt):
        score += c[nxt]
        ans = max(ans, score)
        #print("ans = ", ans, "score = ", score, "nxt = ", nxt, "c[nxt] = ", c[nxt])
        nxt = p[nxt]

print(ans)

Measured memory_bytes: 74444
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#define ll long long
#define ull unsigned long long
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define numOfOnes(n) __builtin_popcount(n)
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//</DEFINE>

/*█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀█▄▄▄▀▀▀▀▄▄▄█▀*/
ll n, w,MX;
ll res[101][100001];
vector<pair<ll, ll>>v;
//<FUNCTIONS>
ll solve(ll idx, int value) {
	if (value == 0)return 0;
	if (idx == n)return w + 1;
	if (~res[idx][value])return res[idx][value];
	ll take = w + 1, leave;
	if (value - v[idx].second >= 0) {
		take = solve(idx + 1, value - v[idx].second) + v[idx].first;
	}
	leave = solve(idx + 1, value);
	return res[idx][value] = min(leave, take);
}
//</FUNCTIONS>		
int main() {
	Fast();
	cin >> n >> w;
	v.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i].first >> v[i].second;
		MX += v[i].second;
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100000; j++)res[i][j] = -1;
	}
	ll mx = 0;
	for (int i = 1; i <= MX; i++) {
		if (solve(0, i) <= w)mx = max(mx, 1ll * i);
	}
	cout << mx << endl;
}

Measured memory_bytes: 79232
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int64_t gcd(int64_t a, int64_t b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int64_t lcm(int64_t a, int64_t b) {
    int64_t c = gcd(a, b);
    return a / c * b;
}

int main(int argc, const char * argv[]) {
     
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    int64_t c; cin >> c;
    for (int i = 0; i < n - 1; i++) {
        int64_t t; cin >> t;
        c = lcm(c, t);
    }
    
    cout << c << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define size_t 100010
int main() {
 int n,a[size_t],i,count=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)  
  {
    scanf("%d",&a[i]);
  }  
  for(i=1;i<=n;i++)
  {
   if(a[i]!=i)
   { count++; }
  } 
  if(count<=2)
  {printf("YES\n");}
  else { printf("NO\n"); }
    return 0;
    }
    

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

typedef long long ll;
int N;
const int MAX_N = 200000;
ll A[MAX_N], B[MAX_N];
priority_queue<pair<ll, int>> U;

void check_insert(int i)
{
  int i_prev = (i + N - 1) % N, i_next = (i + 1) % N;
  if (B[i] - A[i] >= B[i_prev] + B[i_next])
  {
    U.push(make_pair(B[i], i));
  }
}

ll solve()
{
  ll res = 0;
  for (int i = 0; i < N; ++i)
  {
    check_insert(i);
  }
  while (!U.empty())
  {
    int i = U.top().second;
    U.pop();
    int i_prev = (i + N - 1) % N, i_next = (i + 1) % N;
    ll k = (B[i] - A[i]) / (B[i_prev] + B[i_next]);
    B[i] -= k * (B[i_prev] + B[i_next]);
    res += k;
    check_insert(i_prev);
    check_insert(i);
    check_insert(i_next);
  }
  for (int i = 0; i < N; ++i)
  {
    if (A[i] != B[i])
    {
      return -1;
    }
  }
  return res;
}

int main()
{
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    cin >> A[i];
  }
  for (int i = 0; i < N; ++i)
  {
    cin >> B[i];
  }
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 5492
s = input()
rain_max = 0
local_max = 0
for i in range(len(s)):
    if s[i] == 'R':
        local_max += 1
    else:
        if local_max > rain_max:
            rain_max = local_max
        local_max = 0
if local_max > rain_max:
    rain_max = local_max
print(rain_max)


Measured memory_bytes: 9096
// Author: Mohammad Faisal
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin >> n;
  
  if(n==1)
    cout<<"Hello World"<<endl;
  else if(n==2)
  {
    int a,b;
    cin >> a >> b;
    cout<<(a+b)<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std ;
int main()
{
	char ch , a ;
	while(1)
	{
		scanf("%c",&ch) ;
		if(ch==10) break ;

		else if('a'<=ch&&ch<='z')
		{
			a=ch-32 ;
			cout << a ;
		}
		else if('A'<=ch&&ch<='Z')
		{
			a=ch+32 ;
			cout << a ;
		}
		else cout << ch ;
	}
	cout << endl ;
	return 0 ;
}



Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    map<int, int> mp;
    int a;
    ll ans = 0;
    rep(0, i, N)
    {
        cin >> a;
        ans += mp[i - a];
        mp[i + a]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 20612
from collections import Counter

N, K = map(int, input().split())
TD = [tuple(map(int, input().split())) for _ in range(N)]

TD.sort(reverse=True, key=lambda a: a[1])

A = TD[:K]

B = []
V = set()
for t, d in TD:
    if t in V:
        continue
    B.append((t, d))
    V.add(t)

cntT = Counter([t for t, _ in A])
V = set(cntT.keys())
S = sum([d for _, d in A])
B = [(t, d) for t, d in B if not t in V]

C = []
for t, d in A[::-1]:
    if cntT[t] > 1:
        C.append((t, d))
        cntT[t] -= 1

C = C[::-1]
ans = S + len(V)**2
for t, d in B:
    if not C:
        break
    _, less = C.pop()
    S -= less
    S += d
    V.add(t)
    ans = max(ans, S + len(V)**2)
print(ans)


Measured memory_bytes: 35084
#include<iostream>
#include<set>
int GCD(int a, int b){
  if(b == 0) return a;
  else return GCD(b, a % b);
}
int main(){
  int n;
  int a, b, c;
  int num;
  std::cin >> n;
  if(n == 2){
    std::cin >> a >> b;
    num = GCD(a, b);
  }else if(n == 3){
    std::cin >> a >> b >> c;
    num = GCD(a, b);
    num = GCD(num, c);
  }
  std::set<int> sta;
  for(int i = 1; i * i <= num; i++){
    if(num % i == 0 && i * i == num) sta.insert(i);
    else if(num % i == 0){
      sta.insert(i);
      sta.insert(num / i);
    }
  }
  
  for(auto e : sta){
    std::cout << e << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N;
ll K, a[50][50], res[50][50], ans;

int main() {
	cin >> N >> K;
	for (int i = 0; i != N; ++i)
		for (int j = 0; j != N; ++j) {
			cin >> a[i][j];
			res[i][j] = a[i][j];
		}
	--K;
	while (K) {
		ll m[50][50];
		if (K & 1) {
			for (int i = 0; i != N; ++i) {
				for (int j = 0; j != N; ++j) {
					m[i][j] = 0;
					for (int k = 0; k != N; ++k) {
						m[i][j] += a[i][k] * res[k][j];
						m[i][j] %= mod;
					}
				}
			}
			for (int i = 0; i != N; ++i)
				for (int j = 0; j != N; ++j)
					res[i][j] = m[i][j];
		}
		for (int i = 0; i != N; ++i) {
			for (int j = 0; j != N; ++j) {
				m[i][j] = 0;
				for (int k = 0; k != N; ++k) {
					m[i][j] += a[i][k] * a[k][j];
					m[i][j] %= mod;
				}
			}
		}
		for (int i = 0; i != N; ++i)
			for (int j = 0; j != N; ++j)
				a[i][j] = m[i][j];
		K >>= 1;
	}
	for (int i = 0; i != N; ++i)
		for (int j = 0; j != N; ++j)
			ans = (ans + res[i][j]) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, m, q = map(int, input().split())
G = [[0] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
    l, r = map(int, input().split())
    G[l][r] += 1
for i in range(1, n + 1):
    for j in range(1, n + 1):
        G[i][j] += G[i - 1][j] + G[i][j - 1] - G[i - 1][j - 1]
p = [list(map(int, input().split())) for _ in range(q)]
for u in p:
    s, t = u[0] - 1, u[1]
    print(G[s][s] + G[t][t] - (G[s][t] + G[t][s]))

Measured memory_bytes: 34736
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string o, e;
  cin >> o >> e;
  for(int i = 0; i < e.length(); i++){
    cout << o[i] << e[i];
  }
  if(o.length() == e.length())
    cout << endl;
  else
    cout << o[o.length()-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
ll modpow(ll a, ll n, ll mod) {
    ll ans = 1;
    while (n > 0) {
        if (n & 1) ans = ans * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, maxv, firstv;
    cin >> n;

    unordered_map<ll, ll> m;
    REP(i, n)
    {
        int tmp;
        cin >> tmp;

        if (i == 0)
        {
            firstv = tmp;
        }

        maxv = max(maxv, tmp);
        if (m.count(tmp) == 0)
        {
            m[tmp] = 1;
        }else
        {
            m[tmp]++;
        }
    }

    if(firstv != 0 or m[0] != 1)
    {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    FOR(i, 1, maxv)
    {
        if(m.count(i) == 0 and m.count(i + 1) == 0)
        {
            cout << 0 << endl;
            return 0;
        }
        // cout << "  " << i << " " << m[i] << " " << m[i + 1] << endl;
        ll tmp = 1;
        REP(j, m[i+1])
        {
            tmp = tmp * m[i] % 998244353;
        }
        ans = ans * tmp % 998244353;
    }

    cout << ans << endl;

}

Measured memory_bytes: 4388
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

Measured memory_bytes: 256
#include<cstdio>

int pow(int);
int main(void){
        int i,j;
        int n;
        int a[20];
        int x[20][20];
        int y[20][20];
        scanf("%d",&n);
        for(i=0;i<n;i++){
                scanf("%d",&a[i]);
                for(j=0;j<a[i];j++){
                        scanf("%d%d", &x[i][j],&y[i][j]);
                        x[i][j]--;
                }
        }
//  printf("yay\n");
        int m=0;
        
        for(int z=0;z<pow(n);z++){
                int c=0;
//printf("%d\n",z);
                int b[20];
                for(j=0;j<n;j++){
                        b[j]=(z/(pow(j)))%2;
                }
                
                for(j=0;j<n;j++){
                        if(b[j]==1){
                                c++;
                        }
                }
  //      printf("%d %d\n", z, c[z]);
                if(m<c){
                  bool boo=true;
                        for(i=0;i<n;i++){
                                if(b[i]==1){
                                        for(j=0;j<a[i];j++){
                                                if(b[x[i][j]]!=y[i][j]){
                                                        boo=false;
     //    printf("%d %d %d, �،�%d%d\n",b[0],b[1],b[2],i,j);
                                                }
                                            if(b[x[i][j]]!=y[i][j]){
                                                        break;
                                                }
                                        }
                                }
                  
                        }
                  if(boo==true){
                        m=c;
                  }
                }
        }
        printf("%d\n",m);

        return 0;
}
int pow(int n){
        int a=1;
        for(int i=0;i<n;i++){
                a=a*2;
        }
        return a;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


int32_t main() {
    fastio
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int N, sum = 0;
    cin >> N;

    w(M){
        int d;
        cin >> d;
        sum += d;
    }

    if (sum > N)
        cout << -1 << endl;
    else cout << N - sum << endl;
    return 0;
}

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

using namespace std;

//#define FILE_IO

int N;
int v[200005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
        scanf("%d", &v[i]);

    for(int i = N; i >= 1; i -= 2)
        printf("%d ", v[i]);
    for(int i = 1 + (N & 1); i <= N; i += 2)
        printf("%d ", v[i]);

    return 0;
}


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

def f(a,b) :
    if a > b :
        a,b = b,a
    if b % a == 0 :
        return 2*(b//a-1)*a + a
    else :
        return 2*(b//a)*a + f(a,b%a)
        
ans = N + f(X,N-X)

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    string b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes";
    else cout<<"No";
}

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

int main()
{
	int a, b, c;

	cin >> a >> b >> c;

	string ans;

	bool ab, bc, ca;

	ab = a == b;
	bc = b == c;
	ca = c == a;

	if ((ab || bc || ca) && !(ab && bc && ca)) ans = "Yes";
	else ans = "No";

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

N, C = map(int, input().split())
D = [[int(i) for i in input().split()] for c in range(C)]
Ini = [[int(i) for i in input().split()] for n in range(N)]
C0, C1, C2 = defaultdict(int), defaultdict(int), defaultdict(int)
D0, D1, D2 = [[0, d] for d in range(C)], [[0, d] for d in range(C)], [[0, d] for d in range(C)]
for i in range(N):
    for j in range(N):
        if (i+j+2)%3 == 0:
            C0[Ini[i][j] - 1] += 1
        elif (i+j+2)%3 == 1:
            C1[Ini[i][j] - 1] += 1
        else:
            C2[Ini[i][j] - 1] += 1

for i in range(C):
    for c in C0:
        D0[i][0] += D[c][i] * C0[c]
    for c in C1:
        D1[i][0] += D[c][i] * C1[c]
    for c in C2:
        D2[i][0] += D[c][i] * C2[c]

D0.sort()
D1.sort()
D2.sort()
Ans = float("inf")
for i in range(3):
    I = D0[i]
    for j in range(3):
        J = D1[j]
        for k in range(3):
            K = D2[k]
            if I[1] != J[1] and J[1] != K[1] and K[1] != I[1]:
                Ans = min(Ans, I[0] + J[0] + K[0])
print(Ans)

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

int calcd(int);
int tjudge(int);
  
typedef struct {
  int parent;
  int k;
  int *children;
} Tree;

 Tree *t;

int main()
{
  int i, j;
  int id;
  int n;
  char type[3][15] = {{"root"},{"internal node"},{"leaf"}};

  scanf("%d", &n);

  t = malloc(sizeof(Tree) * n);

   for(i = 0; i < n; i++)
    {
      t[i].parent = -1;
    }
  
  for(i = 0; i < n; i++)
    {    
      scanf("%d", &id);
      
      scanf("%d", &t[id].k);
      t[id].children = malloc(sizeof(int) * t[id].k);
      
      for(j = 0; j < t[id].k; j++)
	{
	  scanf("%d", &t[id].children[j]);
	  t[t[id].children[j]].parent = id;
	}
    }
  for(i = 0; i < n; i++)
    {
      printf("node %d: parent = %d, depth = %d, %s,", i, t[i].parent, calcd(i), type[tjudge(i)]);

      printf(" [");
      if(t[i].k != 0)
	{
	  for(j = 0; j < t[i].k-1; j++)
	    {
	      printf("%d, ",t[i].children[j]);
	    }
	  printf("%d",t[i].children[j]);
	}
      printf("]\n");
    }

  return 0;
}

int calcd(int key)
{
  int count = 0;
  
  while(t[key].parent != -1)
    {
      key = t[key].parent;
      count++;
    }

  return count;
}

int tjudge(int key)
{
  if(t[key].parent == -1)return 0;
  if(t[key].k == 0)return 2;
  return 1;
}



Measured memory_bytes: 6824
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    string s;
    cin>>s;
    unordered_set<int> c;
    for (int i=0;i<s.length();i++)
    {
        if (c.find(s[i]-'a')!=c.end())
        {
            cout<<"no";
            return 0;
        }
        else
        {
            c.insert(s[i]-'a');
        }
    }
    cout<<"yes";
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    int sum = 0;
    int max_l = 0;
    for (int i = 0; i < N; ++i) {
        int Li;
        cin >> Li;
        sum += Li;
        max_l = max(max_l, Li);
    }

    if (sum - max_l > max_l) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

typedef long long               ll;
typedef long double             ld;


#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time_start		 time_t start, end; time(&start);
#define time_end		 time(&end);double time_taken=double(end-start);cout <<"\n"<< time_taken*1000<<" ms";
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807

///knight moves:
///int dx[] = {-2, -1, 1, 2, -2, -1, 1, 2};
///int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};


ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
}

ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}

void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

    
int solve()
{
	string x;
	cin>>x;
	int i=1;

	vector<string>v;
	
	string c;
	c="";
	c+=x[0];
	v.push_back(c);
	while(i<(int)x.size())
	{
		c="";
		c+=x[i];
		if(v.back()==c)
		{
			if(i==(int)x.size()-1) break;
			c+=x[i+1];
			v.pb(c);
		}
		else  v.pb(c);
		i+=v.back().size();
	}
	
	//for(auto it:v) cout<<it<<" ";
	
	cout<<(int)v.size();	
	return 0;
}


int main()
{

    racecar;
    cout<<fixed<<setprecision(6);
//    fileio();
    solve();
    return 0;
}



///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n


Measured memory_bytes: 11016
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

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

    bool good[200000];
    ll hight[200000];

    for(int i = 0; i < 200000; i++){
        good[i] = true;
    }

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

    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(hight[a] >= hight[b]){
            good[b] = false;
        }
        if(hight[a] <= hight[b]){
            good[a] = false;
        }
    }

    int count = 0;
    for(int i = 0; i < N; i++){
        if(good[i]){
            count++;
        }
    }

    cout << count << endl;
    
}

Measured memory_bytes: 4568
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] p = new int[m];
		int[] y = new int[m];
		Map<Integer, Integer> yTree = new TreeMap<Integer, Integer>();

		for (int i = 0; i < m; i++) {
			p[i] = sc.nextInt();
			y[i] = sc.nextInt();
			yTree.put(y[i], p[i]);
		}

		int[] pCount = new int[n];

		for (int yi : yTree.keySet()) {
			yTree.put(yi, ++pCount[yTree.get(yi) - 1]);
		}

		for (int i = 0; i < m; i++) {
			System.out.println(String.format("%06d%06d", p[i], yTree.get(y[i])));
		}

	}
}

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

using namespace std;

string str1;

int main(){
    cin >> str1;
    int cont = 0;
    for(int i=0;i<str1.size()/2;i++){
        if(str1[i] != str1[str1.size()-1-i]) cont++;
    }

    cout << cont << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,b) for(int i=1;i<=b;i++)
#define drep(i,b) for(int i=b;i>=1;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pr pair<int,int>
#define ff first
#define ss second
#define int long long
#define endl '\n'
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int n,m,k,t,x,y,z;

#define vint vector<int>
#define pb push_back
#define ver(a,l,r) a.begin()+l,a.begin()+r+1


void solve(int ans=0) {
    cin>>n>>m;
    vint to(n+1),vis(n+1),cnt(n+1);
    int _cnt=0;
    rep(i,n) {
        cin>>x;
        to[i]=x;
    }
    int u=1;
    while(!vis[u]) {
        vis[u]=1;
        cnt[u]=_cnt++;
        u=to[u];
    }
    _cnt-=cnt[u];
    //cout<<_cnt<<endl;
    if(m<=cnt[u]) {
        u=1;
        rep(i,m) u=to[u];
        cout<<u<<endl;
        return ;
    }
    int t=(m-cnt[u])%_cnt;
    rep(i,t) u=to[u];
    cout<<u<<endl;
}

#undef int
int main() {
    ios::sync_with_stdio(false);
    //int T;cin>>T;
    //while(T--)
        solve();
}


Measured memory_bytes: 7988
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int x,y;
    int p[200][200];
    int p2[200];
    int p1[200];

    scanf("%d %d",&x,&y);
    for(int n=1;n<=x;n++){
        for(int j=1; j<=y;j++){
            scanf("%d",&p[n][j]);
        }
    }
    for(int j=1; j<=y;j++){
        scanf("%d",&p1[j]);
    }

    for(int n=1;n<=x;n++){
        for(int j=1; j<=y;j++){
          p2[n]+=(p[n][j]*p1[j]);
        }
        printf("%d\n",p2[n]);


    }
    return 0;
}



Measured memory_bytes: 2108
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
  int A, B, K; cin >> A >> B >> K;

  for (int i = A; i <= B; i++) {
    if (i <= A+K-1 || B-K+1 <= i) {
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())

H_rad = ( H*30)+M/2 
M_rad  = (M *6)
A_x = A*math.sin(math.radians(H_rad))
A_y = A*math.cos(math.radians(H_rad))
B_x = B*math.sin(math.radians(M_rad))
B_y = B*math.cos(math.radians(M_rad))

sqr = math.pow(A_x -B_x ,2) + math.pow(A_y -B_y,2)

result = math.sqrt(sqr)

print(result)



Measured memory_bytes: 9524
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str1 = sc.nextLine();
        String[] astr1 = str1.split(" ");
        int n = Integer.parseInt(astr1[0]);
        int x = Integer.parseInt(astr1[1]);

        String str2  = sc.nextLine();
        String[] astr2 = str2.split(" "); //状況に合わせて
        int[] in_data = Stream.of(astr2).mapToInt(y->{
            try{
                return Integer.parseInt(y);
            }
            catch(Exception e){
                e.printStackTrace();
            }
            return 0;
        }).toArray();
        sc.close();

        int[] bounds = new int[n+1];
        bounds[0] = 0;
        int count= 0;

        for(int i =1;i<=in_data.length;i++){
            bounds[i] = bounds[i-1] + in_data[i-1];
            }
        for(int j =0;j<bounds.length;j++){
            if(bounds[j]<= x){
                count+=1;
            }
        }

        System.out.println(count);
        }

    }


Measured memory_bytes: 28628
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }
 
#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-12
 
template<class T> T add(T x, T y){ if(abs(x+y) < EPS*(abs(x)+abs(y))) return 0; return x + y; }
template<class T> inline bool semieq(T x, T y){ return abs(x - y) < EPS; }
template<class T> inline bool semige(T x, T y){ return x - y > -EPS; }
template<class T> inline bool semile(T x, T y){ return y - x > -EPS; }
 
template<class Type> struct Line;
 
template<class Type>
struct P
{
  friend struct Line<Type>;
private:
  complex<Type> z;
 
public:
  P(const Type x = 0, const Type y = 0) : z(complex<Type>(x, y)) { }
  void setter(Type x, Type y) { z = complex<Type>(x, y); }
  Type getX(){ return z.real(); }
  Type getY(){ return z.imag(); }
  inline double getSlope(){ return tan(z.arg()); }
  inline double getSlope(P<Type> p){ return (this - p).getSlope(); }
 
  bool operator == (const P<Type> p){ return  semieq(z.real(), p.real()) &&  semieq(z.imag(), p.imag()); }
  bool operator != (const P<Type> p){ return !semieq(z.real(), p.real()) || !semieq(z.imag(), p.imag()); }
  Type operator * (const P<Type> p){ return (z * p.z).real(); }
  Type operator / (const P<Type> p){ return (z * p.z).imag(); }
};
 
template<class Type>
struct Line
{
private:
  P<Type> S, T;
 
public:
  Line(const Type sx, const Type sy, const Type tx, const Type ty) : S(sx, sy), T(tx, ty) {}
  Line(const P<Type> S, const P<Type> T) : S(S), T(T) {}
  inline P<Type> getS(){ return S; }
  inline P<Type> getT(){ return T; }
  inline double getSlope(){ return S.getSlope(T); }
  inline bool isParallel(Line<Type> L){ return semieq(((L.S.z - L.T.z) / (S.z - T.z)).imag(), 0.0); }
  inline bool isVertical(Line<Type> L){ return semieq(((L.S.z - L.T.z) / (S.z - T.z)).real(), 0.0); }
};
 
typedef double Point;
 
int n;
P<Point> A[4];
Point x, y;
 
int main()
{
  cin >> n;
 
  while(n--){
    rep(i, 4){
      cin >> x >> y;
      A[i].setter(x, y);
    }
    Line<Point> AB(A[0], A[1]);
    Line<Point> CD(A[2], A[3]);
    puts(AB.isParallel(CD) ? "YES" : "NO");
  }
 
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////


ll a;
ll N,M;
char S[101010],T[101010];
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    return gcd(b,a%b);
}

int main(){
    
    scanf("%lld%lld%s%s",&N,&M,S,T);
    ll g=gcd(N,M);
    ll l=N*M/g;
    fornum(i,0,N){
        //printf("%lld %lld\n", i * M, i * M % N);
        if(i*M%N==0&&S[i]!=T[i*M/N]){
            printf("-1");
            //printf(" %d %lld", i, i * n / m);
            return 0;
        }
    }
    printf("%lld\n",l);
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		//In
		int n = scan.nextInt();
		boolean result = false;
		
		//Process Out
		for(int i=1;i<10;i++) {
			if(n%i == 0 && n/i<10) {
				result = true;
				break;
			}
		}
		
		if(result == true) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	
	
	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>

int main()
{
  char s[101];
  scanf("%s",s);
  int a=0;
  int b=strlen(s);
  for(int i=0;i<b/2;i++){
    if(s[i]!=s[b-1-i]) a=a+1;
    }
  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 128
import heapq
import math

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

a = [-1*num for num in a]

heapq.heapify(a)

for i in range(m):
	maximum = heapq.heappop(a)
	add = math.trunc(maximum/2)
	heapq.heappush(a,add)

print(-1 * sum(a))


Measured memory_bytes: 73196
#include <iostream>

using namespace std;

int main()
{
    int num;
    int book;
    int sum = 0;

    while (cin >> num, num) {
        for (int i = 0; i < 9; i++) {
            cin >> book;
            sum += book;
        }

        cout << num - sum << endl;
        sum = 0;
    }
}



Measured memory_bytes: 3080
import collections
import itertools
import sys
import time

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n,a=getints()
xs=getints()

def key(pos, s, c):
    return (pos * 2600 + s) * 55 + c

cache=[-1] * key(50, 2500, 50)

def solve(pos, s, c):
    if pos == n:
        if s == a * c and c:
            return 1
        else:
            return 0
    k = key(pos,s,c)
    res = cache[k]
    if res >= 0:
        return res
    res = 0
    res += solve(pos + 1, s + xs[pos], c + 1)
    res += solve(pos + 1, s, c)
    cache[k] = res
    return res

print(solve(0,0,0))

Measured memory_bytes: 62764
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r, c, n; cin >> r >> c >> n;
    V< P<ll, ll> > round;
    REP(i, n) {
        ll x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        if ((0 < x1 && x1 < r) && (0 < y1 && y1 < c)) continue;  // (x1, y1) が内部
        else if ((0 < x2 && x2 < r) && (0 < y2 && y2 < c)) continue;  // (x2, y2) が内部
        else {
            if (x1 == 0) round.emplace_back(y1, i);
            else if (x1 == r) round.emplace_back(c + r + (c - y1), i);
            else if (y1 == 0) round.emplace_back(2 * c + r + (r - x1), i);
            else round.emplace_back(c + x1, i);
            if (x2 == 0) round.emplace_back(y2, i);
            else if (x2 == r) round.emplace_back(c + r + (c - y2), i);
            else if (y2 == 0) round.emplace_back(2 * c + r + (r - x2), i);
            else round.emplace_back(c + x2, i);
        }
    }
    sort(ALL(round));
    vll stack;
    set<ll> app;
    REP(i, round.size()) {
        if (app.find(round[i].second) == app.end()) {
            stack.emplace_back(round[i].second);
            app.insert(round[i].second);
        } else {
            if (round[i].second == *(--stack.end())) {
                app.erase(round[i].second);
                stack.pop_back();
            } else {
                cout << "NO\n";
                return 0;
            }
        }
    }
    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 6892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int A[3];
  rep(i,3) cin>>A[i];
  sort(A,A+3);
  cout<<A[0]*A[1]/2<<endl;
}

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

int main()
{
    int $=1;
    //cin>>$;
    while($--)
    {
        string s;
        cin>>s;
        if((s[0]=='R'&&s[1]=='S'&&s[2]=='S')||(s[0]=='R'&&s[1]=='S'&&s[2]=='R')||(s[0]=='S'&&s[1]=='R'&&s[2]=='S')||(s[0]=='S'&&s[1]=='S'&&s[2]=='R')) cout<<1<<endl;
        else if((s[0]=='R'&&s[1]=='R'&&s[2]=='S')||(s[0]=='S'&&s[1]=='R'&&s[2]=='R')) cout<<2<<endl;
        else if(s[0]=='R'&&s[1]=='R'&&s[2]=='R') cout<<3<<endl;
        else cout<<0<<endl;
    }
}


/*
8888888888888888888888888888
    Md. Masud Mazumder
    University of Chittagong
    Department of CSE
8888888888888888888888888888
*/


Measured memory_bytes: 3624