akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main()
{
	int i, N, A, B, C;
	char s[100001][3];
	scanf("%d %d %d %d", &N, &A, &B, &C);
	for (i = 1; i <= N; i++) scanf("%s", s[i]);
	
	char ans[100001];
	if ((A + B == 0 && s[1][0] == 'A' && s[1][1] == 'B') || (A + C == 0 && s[1][0] == 'A' && s[1][1] == 'C') || (B + C == 0 && s[1][0] == 'B' && s[1][1] == 'C')) {
		printf("No\n");
		fflush(stdout);
		return 0;
	} else if (A + B + C <= 1) {
		for (i = 1; i <= N; i++) {
			if ((A + B == 0 && s[i][0] == 'A' && s[i][1] == 'B') || (A + C == 0 && s[i][0] == 'A' && s[i][1] == 'C') || (B + C == 0 && s[i][0] == 'B' && s[i][1] == 'C')) {
				printf("No\n");
				fflush(stdout);
				return 0;
			} else if (A == 1) {
				A = 0;
				if (s[i][1] == 'B') {
					B = 1;
					ans[i] = 'B';
				} else {
					C = 1;
					ans[i] = 'C';
				}
			} else if (B == 1) {
				B = 0;
				if (s[i][0] == 'A') {
					A = 1;
					ans[i] = 'A';
				} else {
					C = 1;
					ans[i] = 'C';
				}
			} else {
				C = 0;
				if (s[i][0] == 'A') {
					A = 1;
					ans[i] = 'A';
				} else {
					B = 1;
					ans[i] = 'B';
				}
			}
		}
	} else {
		for (i = 1; i < N; i++) {
			if (s[i][0] == 'A' && s[i][1] == 'B') {
				if (A == 0) {
					A++;
					B--;
					ans[i] = 'A';
				} else if (B == 0) {
					A--;
					B++;
					ans[i] = 'B';
				} else if (A == 1 && C == 0 && s[i+1][0] == 'A' && s[i+1][1] == 'C') {
					A++;
					B--;
					ans[i] = 'A';
				} else {
					A--;
					B++;
					ans[i] = 'B';
				}
			} else if (s[i][0] == 'A' && s[i][1] == 'C') {
				if (A == 0) {
					A++;
					C--;
					ans[i] = 'A';
				} else if (C == 0) {
					A--;
					C++;
					ans[i] = 'C';
				} else if (A == 1 && B == 0 && s[i+1][0] == 'A' && s[i+1][1] == 'B') {
					A++;
					C--;
					ans[i] = 'A';
				} else {
					A--;
					C++;
					ans[i] = 'C';
				}
			} else {
				if (B == 0) {
					B++;
					C--;
					ans[i] = 'B';
				} else if (C == 0) {
					B--;
					C++;
					ans[i] = 'C';
				} else if (B == 1 && A == 0 && s[i+1][0] == 'A' && s[i+1][1] == 'B') {
					B++;
					C--;
					ans[i] = 'B';
				} else {
					B--;
					C++;
					ans[i] = 'C';
				}
			}
		}
		if (s[N][0] == 'A' && s[N][1] == 'B') {
			if (A == 0) ans[N] = 'A';
			else ans[N] = 'B';
		} else if (s[N][0] == 'A' && s[N][1] == 'C') {
			if (A == 0) ans[N] = 'A';
			else ans[N] = 'C';
		} else {
			if (B == 0) ans[N] = 'B';
			else ans[N] = 'C';
		}
	}
	
	printf("Yes\n");
	for (i = 1; i <= N; i++) printf("%c\n", ans[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2128
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

bool cmp(const tuple<ll, ll, ll>& l, const tuple<ll, ll, ll>& r) {
  if (get<0>(l) < get<0>(r))
    return true;
  else if (get<0>(l) == get<0>(r) && get<1>(l) < get<1>(r))
    return true;
  return false;
}

int main() {
  //
  ll n, q;
  cin >> n >> q;
  vl s(n), t(n), x(n), d(q);
  vector<tuple<ll, ll, ll>> data;
  rep(i, n) {
    cin >> s[i] >> t[i] >> x[i];
    data.emplace_back(s[i] - x[i], 1, x[i]);
    data.emplace_back(t[i] - x[i], 0, x[i]);
  }
  rep(i, q) {
    cin >> d[i];
    data.emplace_back(d[i], 2, 0);
  }
  sort(ALL(data), cmp);
  multiset<ll> cur;
  for (auto& x : data) {
    // cout << get<0>(x) << "," << get<1>(x) << "," << get<2>(x) << endl;
    ll category = get<1>(x);
    ll val = get<2>(x);
    if (category == 0) {
      cur.erase(cur.find(val));
    } else if (category == 1) {
      cur.insert(val);
    } else {
      if (cur.size() == 0) {
        cout << -1 << endl;
      } else {
        // cout << "!" << endl;
        cout << *(cur.begin()) << endl;
      }
    }
  }
  return 0;
}


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

using namespace std;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  
  if(N&1) {
    cout << "No" << endl;
    return 0;
  }
  
  for(int i=0;i<N/2;i++) {
    if(S[i] != S[N/2+i]) {
      cout << "No" << endl;
      return 0;
    }
  }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set


int main() 
{
	ll n,m;
	cin>>n>>m;
	cout<<(n*(n-1))/2 + (m*(m-1))/2<<endl;
	return 0;
}  


Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d %d", $a, $b);
  $all = $a * $b;
  $wide = 1 * $b;
  $height = 1* $a;
  $dup = 1 * 1;
  $answer = $all - $wide - $height + $dup;
  echo $answer;
?>

Measured memory_bytes: 4856
from collections import Counter
N, M = map(int, input().split())
A = list(map(int, input().split()))

A = Counter(A)

for _ in range(M):
    b, c = map(int, input().split())
    A[c] += b

A = sorted(A.items(), key=lambda x: x[0], reverse=True)

ans = 0
for key, value in A:
    if N - value >= 0:
        ans += key * value
        N -= value
    else:
        ans += N * key
        break

print(ans)

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
//const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

template< int mod >
struct ModInt {
	int x;

	ModInt() : x(0) {}

	ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

	ModInt &operator+=(const ModInt &p) {
		if ((x += p.x) >= mod) x -= mod;
		return *this;
	}

	ModInt &operator-=(const ModInt &p) {
		if ((x += mod - p.x) >= mod) x -= mod;
		return *this;
	}

	ModInt &operator*=(const ModInt &p) {
		x = (int)(1LL * x * p.x % mod);
		return *this;
	}

	ModInt &operator/=(const ModInt &p) {
		*this *= p.inverse();
		return *this;
	}

	ModInt operator-() const { return ModInt(-x); }

	ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

	ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

	ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

	ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

	bool operator==(const ModInt &p) const { return x == p.x; }

	bool operator!=(const ModInt &p) const { return x != p.x; }

	ModInt inverse() const {
		int a = x, b = mod, u = 1, v = 0, t;
		while (b > 0) {
			t = a / b;
			a -= t * b;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		return ModInt(u);
	}

	friend ostream &operator<<(ostream &os, const ModInt< mod > &p) {
		return os << p.x;
	}

	friend istream &operator>>(istream &is, ModInt< mod > &a) {
		long long x;
		is >> x;
		a = ModInt< mod >(x);
		return (is);
	}

};

const int mod = 1e9 + 7;
using modint = ModInt< mod >;

modint c[4002][4002];
void init() {
	c[0][0] = 1;
	for (int i = 0; i <= 4000; i++) {
		for (int j = 0; j <= i; j++) {
			c[i + 1][j] += c[i][j];
			c[i + 1][j + 1] += c[i][j];
		}
	}
}

modint comb(int n, int k) {
	return c[n][k];
}

modint f2(int n, int k) {
	return comb(n + k - 1, k - 1);
}
modint f(int n, int k) {
	if (n < k) return 0;
	if (n == 0 && k == 0) return 1;
	if (k < 1) return 0;
	return f2(n - k, k);
}

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

	init();
	int n, k;
	cin >> n >> k;

	for (int i = 1; i <= k; i++) {
		modint blue = f(k, i);
		modint red = 0;
		red += f(n - k, i - 1);
		red += f(n - k, i);
		red += f(n - k, i);
		red += f(n - k, i + 1);
		modint ans = blue * red;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 62976
h,w=gets.chomp.split(" ").map(&:to_i)
fir = 0;
if w % 2 == 1
  fir = (w+1)/2
else
  fir = w/2
end
ans = 0
if h % 2 == 1
	ans = ((h -1)/2 * w ) + fir
else
	ans = h/2 * w
end
if w == 1|| h == 1 #対策忘れだとぉ！？
  ans = 1
end
puts ans

Measured memory_bytes: 1788
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int r,c,a[][]=new int[101][101],i,j;
		r=stdIn.nextInt();
		c=stdIn.nextInt();
		for(i=0;i<r;i++){
			for(j=0;j<c;j++){
				a[i][j]=stdIn.nextInt();
				a[i][c]+=a[i][j];
			}
		}
		for(i=0;i<c;i++){
			for(j=0;j<r;j++)a[r][i]+=a[j][i];
			a[r][c]+=a[r][i];
		}
		for(i=0;i<=r;i++){
			for(j=0;j<=c;j++){
				if(j!=0)System.out.print(" ");
				System.out.print(a[i][j]);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 42232
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int x, y, a, b, c;
vector<ll> p, q, r;

ll solve() {
    sort(RALL(p));
    sort(RALL(q));
    sort(RALL(r));
    vector<ll> vec;
    for (int i = 0; i < x; i++) {
        vec.push_back(p[i]);
    }
    for (int i = 0; i < y; i++) {
        vec.push_back(q[i]);
    }
    sort(ALL(vec));
    int l = min((int)vec.size(), c);
    for (int i = 0; i < l; i++) {
        vec[i] = max(vec[i], r[i]);
    }

    ll res = 0;
    for (ll v : vec) {
        res += v;
    }
    return res;
}

void input() {
    cin >> x >> y >> a >> b >> c;
    p = vector<ll>(a);
    q = vector<ll>(b);
    r = vector<ll>(c);
    for (int i = 0; i < a; i++) cin >> p[i];
    for (int i = 0; i < b; i++) cin >> q[i];
    for (int i = 0; i < c; i++) cin >> r[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{
    int n;cin >> n ;
    vector<int> c(n);
    vector<int> s(n);
    vector<int> f(n);

    for(int i=0;i<n-1;i++){
        cin >> c[i] >> s[i] >> f[i];
    }

    for(int i=0;i<n-1;i++){
        int res;
        for(int j=i;j<n-1;j++){
            if(i==j || res<=s[j]) res = (s[j]+c[j]);
            else res += c[j] + (res%f[j]==0?0:f[j]-res%f[j]);
        }
        p(res)
    }
    p(0)
} 

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

long check(long op, long sum, long[] as)
{
    foreach (a; as) {
        if (sum < 0) {
            if ((sum + a) <= 0) {
                op += (1 - (sum + a));
                sum = 1;
            } else {
                sum += a;
            }
        } else {
            if ((sum + a) >= 0) {
                op += sum + a + 1;
                sum = -1;
            } else {
                sum += a;
            }
        }
    }
    return op;
} 

void main()
{
    readln;
    auto as = readln.chomp.split(" ").map!(to!long).array;

    auto op1 = check(0, as[0], as[1..$]);
    auto op2 = check((as[0] - 1).abs, 1, as[1..$]);
    auto op3 = check((as[0] + 1).abs, -1, as[1..$]);

    if (as[0] == 0) op1 = long.max;

    writeln(min(op1, op2, op3));
}

Measured memory_bytes: 4356
/// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  
 
  var a = [];
for (var f = 0; f < 5; f++) {
      var r= parseInt(input[f], 10);
  //   console.log(r);
           a[f] = r;}
    //  console.log(a);
     
  var total=0;
                 var b = [];  
    for (var i = 0;i<5;i++){
        var l = Math.ceil(a[i]/10) * 10;
      var total = total+l;
    }
 //    console.log(total); 
     
  
     
     var mm = a[0]%10;
     if (mm ==0){var mm = 10;}
   for (var i = 0;i<5;i++){ var m = a[i]%10;
                             if (m == 0){var m =10;}
                                if( mm >  m) { var mm =  m;}
                                         }
        
     //   console.log(mm);
 console.log(total-(10-mm));
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8")); 
 
 
 
 

Measured memory_bytes: 7372
#include "bits/stdc++.h"
using namespace std;
int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  int N; cin >> N;
  int a[N*3]; for (int i{0}; i < N*3; ++i) cin >> a[i];
  sort(a, a + N*3, greater<int>());
  long total{0};
  for (int i = 1; i < N*2; i += 2) total += a[i];
  cout << total << "\n";
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
  int i1,N;
  int m,MAX=0;
  int sum=0;
  int p[10000];
  
  scanf("%d", &N);
  for(i1=0;i1<N;i1++){
    scanf("%d", &p[i1]);
    if(p[i1]>MAX){
      m=i1;
      MAX=p[i1];
    }
  }
  
  p[m]=(int)p[m]/2;
  
  for(i1=0;i1<N;i1++){
    sum+=p[i1];
  }
  
  printf("%d", sum);
  
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int v, e;
    cin >> v >> e;
    ll m[v][v];

    rep(i, v) rep(j, v) m[i][j] = (i == j ? 0 : INT_MAX);

    rep(i, e)
    {
        int s, t, d;
        cin >> s >> t >> d;
        m[s][t] = d;
    }

    rep(k, v)
    {
        rep(i, v)
        {
            if (m[i][k] == INT_MAX)
                continue;
            rep(j, v)
            {
                if (m[k][j] == INT_MAX)
                    continue;
                m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
            }
        }
    }

    bool nega = 0;
    rep(i, v) if (m[i][i] < 0) nega = 1;

    if (nega == 1)
    {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }

    rep(i, v)
    {
        rep(j, v)
        {
            if (m[i][j] == INT_MAX)
            {
                cout << "INF";
            }
            else
            {
                cout << m[i][j];
            }
            if (j != v - 1)
                cout << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3172
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string.h>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	scanf("%d", &N);
	
	int nc = 0; // 桁数
		for(int i = 0; i <= 7; i++){
			if(N >= pow(10, i)){
			nc++;
		}
	}
	
	ll count = 0;
	for(int n = 1; n <= N; n++){
		if(n % 10 == 0){
			continue;
		}
		
		int c = 0; // 桁数
		for(int i = 0; i <= 7; i++){
			if(n >= pow(10, i)){
			c++;
			}
		}
		
		int first = n / (int)pow(10, c-1);
		int last = n % 10;
		
		if(first == last){
			count ++; // 1桁のもの
		}
		
		// 上限２桁以下なら終わり
		if(nc == 1){
			continue;
		}
		else if(nc == 2){
			if(last*10 + first <= N){
				count++;
			}
			continue;
		}
		
		// 2桁以降nc桁未満
		for(int i = 2; i < nc; i++){
			count += (int)pow(10, i-2); // 例えば100000なら0~9999の10000通り
		}
		// nc桁のもの
		if((last + 1) * (int)pow(10, nc-1) - 10 + first <= N){
			count += (int)pow(10, nc-2);
		}
		else if((last) * (int)pow(10, nc-1) + first > N)
		{
			continue;
		}else{
			int upper = (N % (int)pow(10, nc-1)) / 10;
			if(N % 10 >= first){
				upper ++;
			}
			count += upper;
		}
		
	}
	
	printf("%lld\n", count);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;

class Main {

	void solve() {
		
		int five = 0, seven = 0;
		for (int i=0; i<3; i++) {
			if (inint() == 5) five++;
			else seven++;
		}
		
		out.println(five==2&&seven==1? "YES" : "NO");
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

	public char[][] incharmap(int h, int w) {
		char[][] a = new char[h][w];
		for (int i=0; i<h; i++) {
			String temp = in.next();
			for (int j=0; j<w; j++) {
				a[i][j] = temp.charAt(j);
			}
		}
		return a;
	}

}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
using P = pair<ll,ll>;

int main(){
  ll n;cin >> n;
  vector<ll> a(n);
  vector<ll> c(1000005,0);
  rep(i,n){
    cin >> a.at(i);
    c.at(a.at(i))++;
  }

  // pairwise の判定
  bool pairwise = true;
  for(ll i=2;i<1000005;++i){
    ll cnt = 0;
    for(ll j=i;j<1000005;j+=i){
      cnt += c.at(j);
    }
    if( cnt > 1 ){
      pairwise = false;
    }
  }

  // setwise の判定
  bool setwise = true;
  ll gcd_all = 0;
  rep(i,n) gcd_all = __gcd(gcd_all,a.at(i));
  if( gcd_all != 1 ) setwise = false;

  // 出力
  if( pairwise )
    cout << "pairwise coprime" << endl;
  else if( setwise )
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n;cin>>n;
    set<char> st;
    for(int i=0;i<n;i++){
        char c;cin>>c;
        st.insert(c);
    }
    if(st.size()==3) cout<<"Three"<<endl;
    else cout<<"Four"<<endl;
}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define REP(idx, N) for (u64 idx = 2; idx < N; idx++)

int main() {
  u64 Nin, N = 0;
  cin >> Nin;
  N = Nin;

  map<u64, u64> factors;

  u64 lim = sqrt(N) + 1;
  REP(f, lim) {
    if (N % f == 0) {
      factors[f] = 1;
      N = N / f;
      while (N % f == 0) {
        N = N / f;
        factors[f] += 1;
      }
    }
  }

  if (N > lim) {
    factors[N] = 1;
  }

  if (factors.empty()) {
    if (Nin == 1) {
        cout << 0 << endl;
        return 0;
    } else {
        cout << 1 << endl;
        return 0;
    }
  }

  u64 ans = 0;
  for (auto f : factors) {
    auto n = f.second;
    u64 sum = 0;
    for (u64 i = 1; i <= n; i++) {
      sum += i;
      if (n - sum < i + 1) {
        ans += i;
        break;
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3712
/*  -*- coding: utf-8 -*-
 *
 * u.cc: U - Grouping
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 16;
const int NBITS = 1 << MAX_N;
const int MAX_M = MAX_N * (MAX_N - 1) / 2;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

/* global variables */

int as[MAX_N][MAX_N], bnums[NBITS];
pii ps[MAX_M];
vi bts[MAX_N + 1];
ll asums[NBITS], dp[NBITS];

/* subroutines */

inline void setmax(ll &a, ll b) { if (a < b) a = b; }

/* main */

int main() {
  int n;
  scanf("%d", &n);
  int nbits = 1 << n;

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

  int m = 0;
  for (int i = 0, bi = 1; i < n; i++, bi <<= 1)
    for (int j = i + 1, bj = 1 << j; j < n; j++, bj <<= 1)
      ps[m++] = pii(bi | bj, as[i][j]);
  //printf("m=%d\n", m);

  for (int bits = 0; bits < nbits; bits++)
    for (int i = 0; i < m; i++) {
      int &pb = ps[i].first, &pa = ps[i].second;
      if ((bits & pb) == pb) asums[bits] += pa;
    }
  
  bnums[0] = 0;
  for (int bits = 1, msb = 1; bits < nbits; bits++) {
    if ((msb << 1) <= bits) msb <<= 1;
    bnums[bits] = bnums[bits ^ msb] + 1;
    bts[bnums[bits]].push_back(bits);
  }

  for (int bits = 0; bits < nbits; bits++) {
    int bn = bnums[bits];
    if (bn < 2) continue;

    int hbn = bn / 2;
    dp[bits] = asums[bits];
    for (int i = 1; i <= hbn; i++) {
      vi &bti = bts[i];
      for (vi::iterator vit = bti.begin(); vit != bti.end(); vit++) {
	int &bi = *vit;
	if ((bits & bi) == bi) setmax(dp[bits], dp[bi] + dp[bits ^ bi]);
      }
    }
  }

  printf("%lld\n", dp[nbits - 1]);
  return 0;
}


Measured memory_bytes: 1920
import java.util.*;

class Main{

    char[][] field;
    int[] dx = {1, -1, 0, 0};
    int[] dy = {0, 0, 1, -1};
    int h = 12, w = 6;
    ArrayList<int[]> clearList;

    void solve(){
        Scanner sc = new Scanner(System.in);

        int dataset = sc.nextInt();
        while(dataset-->0){
            field = new char[h][w];
            for(int i=0; i<h; i++){
                field[i] = sc.next().toCharArray();
            }

            int cnt = 0;
            while(true){
                clearList = new ArrayList<int[]>();
                for(int i=0; i<h; i++){
                    for(int j=0; j<w; j++){
                        if(field[i][j]!='.' && field[i][j]!='O') find(i, j);
                    }
                }
                if(clearList.size()==0) break;
                clear(clearList);
                down();
                cnt++;
            }
            System.out.println(cnt);
        }
    }

    boolean find(int y, int x){
        char clear = field[y][x];
        ArrayList<int[]> clearList2 = new ArrayList<int[]>();
        LinkedList<int[]> list = new LinkedList<int[]>();
        boolean[][] v = new boolean[h][w];
        list.add(new int[]{x, y});

        while(list.size()>0){
            int[] qq = list.poll();
            int xx = qq[0], yy = qq[1];

            if(v[yy][xx]) continue;
            v[yy][xx] = true;
            clearList2.add(new int[]{xx, yy});

            for(int i=0; i<4; i++){
                int nx = xx + dx[i], ny = yy + dy[i];
                if(nx<0 || nx>=w || ny<0 || ny>=h || field[ny][nx]!=clear) continue;
                list.add(new int[]{nx, ny});
            }
        }

        if(clearList2.size()>=4){
            for(int[] xy : clearList2) clearList.add(xy);
        }
        return false;
    }

    void print(){
        for(int i=0; i<h; i++)
            System.out.println(Arrays.toString(field[i]));
        System.out.println("------");
    }

    void clear(ArrayList<int[]> clearList1){
        for(int[] xy : clearList1){
            int x = xy[0], y = xy[1];
            field[y][x] = '.';
            for(int i=0; i<4; i++){
                int nx = x + dx[i], ny = y + dy[i];
                if(nx<0 || nx>=w || ny<0 || ny>=h || field[ny][nx]!='O') continue;
                field[ny][nx] = '.';
            }
        }
    }

    void down(){
        for(int k=0; k<w; k++){
            for(int i=h-1; i>=0; i--){
                if(field[i][k]!='.') continue;
                int idx = -1;
                for(int j=i; j>=0; j--){
                    if(field[j][k]!='.'){
                        idx = j;
                        break;
                    }
                }
                if(idx==-1) break;
                else{
                    char tmp = field[i][k];
                    field[i][k] = field[idx][k];
                    field[idx][k] = tmp;
                }
            }
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 26568
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int w = scanner.nextInt();
        final int h = scanner.nextInt();
        final int x = scanner.nextInt();
        final int y = scanner.nextInt();

        final BigDecimal divide = BigDecimal.valueOf(w).multiply(BigDecimal.valueOf(h)).divide(BigDecimal.valueOf(2));
        final int able = x * 2 == w && y * 2 == h ? 1 : 0;
        System.out.println(divide + " " + able);
    }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc079_d.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int N = 10;
int findMin(vector<vector<int>> &g, int i) {
  priority_queue<P, vector<P>, greater<P>> que;
  vector<int> c(N, -1);
  que.push({0, i});
  while (que.size()) {
    auto p = que.top();
    que.pop();
    int j = p.second;
    if (c[j] != -1) continue;
    int cost = p.first;
    c[j] = cost;
    rep(l, N) {
      if (l == j) continue;
      que.push({cost + g[j][l], l});
    }
  }
  return c[1];
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int H, W;
  cin >> H >> W;

  vector<vector<int>> g(N, vector<int>(N, 0));
  rep(i, N) rep(j, N) { cin >> g[i][j]; }

  vector<vector<int>> m(H, vector<int>(W, 0));
  rep(i, H) rep(j, W) { cin >> m[i][j]; }

  vector<int> c(N, 0);
  rep(i, N) { c[i] = findMin(g, i); }

  ll ans = 0;
  rep(i, H) rep(j, W) {
    if (m[i][j] != -1) {
      ans += c[m[i][j]];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,y;
long long m;
int main(){
scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
if(a>=2*c&&x>=y){
	m=(long long)x*c*2;
}
else if(b>=2*c&&y>=x){
	m=(long long)y*c*2;
}
else if(a+b>=2*c){
	if(y>=x){
		m=(long long)x*c*2;
		m+=(long long)(y-x)*b;
	}
	else {
		m=(long long)y*c*2;
		m+=(long long)(x-y)*a;
	}
}
else {
	m=(long long)x*a+y*b;
}
printf("%lld",m);
	return 0;
}


Measured memory_bytes: 256
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#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 INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    FOR(i, 1, 9)
    {
        FOR(j, 1, 9)
        {
            if (i * j == N)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3660
n = int(input())
s = len(input())
mod = 10**9+7
dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
  dp[i][0] = (dp[i-1][0] + dp[i-1][1])%mod
  for j in range(1,min(n,i+1)):
    dp[i][j] = (dp[i-1][j-1]*2 + dp[i-1][j+1])%mod
  dp[i][n] = dp[i-1][n-1]*2%mod
s2 = pow(2,s,mod)
rev = pow(s2,mod-2,mod)
print(dp[n][s]*rev%mod)


Measured memory_bytes: 229640
#include <iostream>
bool isRight(int a, int b, int c)
{
    if (a > c) {
        std::swap(a, c);
    }
    if (b > c){
        std::swap(b, c);
    }
    
    return a * a + b * b == c * c;
}

int main()
{
    int N;
    int a, b, c;
    std::cin >> N;
    for (int i = 0; i < N; i++) {
        std::cin >> a >> b >> c;
        if (isRight(a, b, c)) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }
    }
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)

int main(){
  int n,ans=0;cin>>n;
  map<int,int> mp;
  REP(i,n){
    int t;cin>>t;
    mp[t-1]++;mp[t]++;mp[t+1]++;
  }
  for(auto p:mp) ans=max(ans,p.second);  
  cout<<ans;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <ios>

using namespace std;

//skip
void C111()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
}


void pyramid()
{
  int n;
  cin >> n;
  vector<int> x(n), y(n), h(n);
  int x1, y1, h1;
  for (int i = 0; i < n; ++i)
  {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] >= 1)
    {
      x1 = x[i];
      y1 = y[i];
      h1 = h[i];
    }
  }

  for (int i = 0; i <= 100; ++i)
  {
    for (int j = 0; j <= 100; ++j)
    {
      int h_max = max(0, h1 + abs(i - x1) + abs(j - y1));
      int exist_ans = 1;
      for (int k = 0; k < n; ++k)
      {
        if (h[k] != max(0, h_max - abs(i - x[k]) - abs(j - y[k])))
        {
          exist_ans = 0;
          break;
        }
      }
      if (exist_ans)
      {
        cout << i << " " << j << " " << h_max << "\n";
        return;
      }
    }
  }
}


void id_113()
{
  int n, m;
  cin >> n >> m;
  
  vector<vector<pair<int, int>>> py(n);
  for (int i = 0; i < m; ++i)
  {
    int p, y;
    cin >> p >> y;

    py[p - 1].push_back(make_pair(y, i));
  }

  for (int i = 0; i < n; ++i) sort(py[i].begin(), py[i].end());

  map<int, pair<int, int>> ans;
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < py[i].size(); ++j)
    {
      ans[py[i][j].second] = make_pair(i + 1, j + 1);
    }
  }
  
  for (int i = 0; i < m; ++i)
  {
    cout << setfill('0') << right << setw(6) << ans[i].first;
    cout << setfill('0') << right << setw(6) << ans[i].second << "\n";
  }
}


int main()
{
  //C111();
  //pyramid();
  id_113();
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }


int main()
{
  fastio();

  int n;
  string s;
  cin >> n >> s;


  for (char &c : s) {
    c = (c - 'A' + n) % 26 + 'A';
  }

  cout << s << endl;

  return 0;
}


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

typedef long long ll;

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

    int n,m;
    cin>>n>>m;
    vector<pair<pair<ll,ll>,pair<ll,ll>>> v(n);
    for(int i=0;i<n;i++)cin>>v[i].first.second>>v[i].second.first>>v[i].second.second;
    ll ans=-1;
    for(int i=0;i<8;i++){
        for(int j=0;j<n;j++){
            v[j].first.first=0;
            if(i & 1)v[j].first.first-=v[j].first.second;
            else v[j].first.first+=v[j].first.second;
            if(i & 2)v[j].first.first-=v[j].second.first;
            else v[j].first.first+=v[j].second.first;
            if(i&4)v[j].first.first-=v[j].second.second;
            else v[j].first.first+=v[j].second.second;
        }
        sort(v.begin(),v.end());
        reverse(v.begin(),v.end());
        ll cnt1=0,cnt2=0,cnt3=0;
        for(int j=0;j<m;j++){
            cnt1+=v[j].first.second;
            cnt2+=v[j].second.first;
            cnt3+=v[j].second.second;
        }
        if(cnt1<0)cnt1*=-1;
        if(cnt2<0)cnt2*=-1;
        if(cnt3<0)cnt3*=-1;
        ans=max(ans,cnt1+cnt2+cnt3);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char ans;
        
        Set<Character> set = new HashSet<>();
        for(int i = 0; i < S.length(); i++){
            set.add(S.charAt(i));
        }
        
        for(int i = 'a'; i <= 'z'; i++){
            if(set.size() == 26){
                System.out.println("None");
                break;
            }
            if(!set.contains((char)i)){
                System.out.println((char)i);
                break;
            }
        }
    }
}


Measured memory_bytes: 25800
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
typedef pair<int,int> P;

string ans;
vector<int> a(10);

void dfs(int pos, string str, int sum){
    if(pos==4){
        if(sum==7){
            ans=str;
        }
        return;
    }
    dfs(pos+1,str+"+",sum+a[pos]);
    dfs(pos+1,str+"-",sum-a[pos]);
}


int main(){
    string s;
    cin >> s;
    rep(i,4){
        a[i] = stoi(s.substr(i,1));
    }
    dfs(1, "",a[0]);
    for (int i = 0; i < 3; ++i) {
        char x = ans[i];
        cout << s[i] << x;
    }
    cout << s[3] << "=7" << endl;
    // cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s;
  int n;
  cin >> n;
  for (int i = n; i <= 999; ++i) {
    if (i % 10 == i/10 % 10 && i % 10 == i/100 % 10) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>








const int N = 1e5 + 10;
int n, m, h[N], a, b, res;
vector<int>adj[N];
bool c;





void solve()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		cin >> h[i];
	}
	for(int i = 1; i <= m; i++)
	{
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	res = 0;
	for(int i = 1; i <= n; i++)
	{
		c = true;
		for(int j = 0; j < adj[i].size(); j++)
		{
			if(h[i] <= h[adj[i][j]])
			{
				c = false;
				break;
			}
		}
		if(c)res++;
	}
	cout << res << "\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  string s;
  cin >> s;

  bool good = 1;
  string r = s;
  reverse(r.begin(), r.end());

  if (r != s) good = 0;
  string rr(s.begin(), s.begin() + (int)s.size()/2);
  string tmp = rr;
  reverse(tmp.begin(), tmp.end());

  if (rr != tmp)  good = 0;
  string rrr(s.begin() + (int)s.size()/2 + 1, s.end());
  
  tmp = rrr;
  reverse(tmp.begin(), tmp.end());

  if (tmp != rrr) good = 0;

  if (good) cout << "Yes\n";
  else cout << "No\n";
}
     

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, ans = 0; 
	for (int h = 0; h < 5; h++) {
		cin >> n;
		if (n > 40) {
			ans += n;
		}
		else {
			ans += 40;
		}
	}
	cout << ans / 5 << endl;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	char c;
	cin >> c;
	if(c >= 'A' && c <= 'Z') cout << 'A' << endl;
	else cout << 'a' << endl;
	return 0;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=  200005;
typedef long long ll;

int main()
{
	char s[maxn];
	scanf("%s",s+1);
	int n = strlen(s+1);
	int cnt[200];
	
	for(int i = 1; i <= n; ++i) {
		cnt[s[i]]++;
	}
	
	ll pary = (ll)n*(n-1)/2;
	
	for(char zn = 'a'; zn <= 'z'; ++zn) {
		pary -= (ll)cnt[zn]*(cnt[zn]-1)/2;
	}
	printf("%lld", 1+pary);
	
	
	
}


Measured memory_bytes: 384
#include <stdio.h>

typedef long long ll;

int main(void)
{
	int N, N2, Q, B, C, i, sub, sum;
	ll ans = 0;
	scanf("%d\n", &N);

	int a[100001][1] = {0};

	for (i = 0; i < N; i++)
	{
		scanf("%d", &N2);
		a[N2][0]++;
		ans += N2;
	}
	scanf("%d\n", &Q);
	for (i = 0; i < Q; i++)
	{
		scanf("%d %d", &B, &C);
		sub = C - B;
		sum = a[B][0] * sub;
		a[C][0] += a[B][0];
		a[B][0] = 0;
		ans += sum;
		printf("%lld\n", ans);
	}

	return (0);
}

Measured memory_bytes: 2116
from collections import deque

N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)


# print(G)
INF = float("inf")


def BFS(G, s):
    n = len(G)
    q = deque()
    D = [INF] * n
    q.append(s)
    D[s] = 0
    while len(q) != 0:
        p = q.popleft()
        for i in G[p]:
            if D[i] == INF:
                q.append(i)
                D[i] = D[p] + 1
    if D[n - 1] == 2:
        return "POSSIBLE"
    else:
        return "IMPOSSIBLE"


print(BFS(G, 0))


Measured memory_bytes: 40472
str = $stdin.gets(chomp:true)
odr_q = $stdin.gets(chomp:true).to_i
order = []

odr_q.times do
  order << $stdin.gets.split
end

order.each do | cmd |
  cmd[1] = cmd[1].to_i
  cmd[2] = cmd[2].to_i
  case cmd[0]
  when  "print"
    puts str[cmd[1]..cmd[2]]
  when  "reverse"
    str[cmd[1]..cmd[2]] = str[cmd[1]..cmd[2]].reverse
  when  "replace"
    str[cmd[1]..cmd[2]] = cmd[3]
  end
end



Measured memory_bytes: 6928
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
ll sm,a[1000];
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;
	cin >> n >> m;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		sm+=a[i];
	}
	x=0;
	for(i=1;i<=n;i++)
	{
		if(sm%(4*m)==0 && a[i]>=sm/(4*m))x++;
		if(sm%(4*m)!=0 && a[i]>sm/(4*m))x++;
	}
	
	if(x>=m)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		int values[] = new int[3];
		values[0] = Integer.parseInt(sc.next());
		values[1] = Integer.parseInt(sc.next());
		values[2] = Integer.parseInt(sc.next());
		
		for(int i= 0; i< values.length;i++){
			
			for(int j = 0,tmp; j<values.length-1;j++)
			if(values[j] > values[j+1]){
				tmp = values[j+1];
				values[j+1] = values[j];
				values[j] = tmp;
			}
			
		}
		
		System.out.println(values[0] + " " + values[1] + " " + values[2]);
		
		
		sc.close();
		
	}

}


Measured memory_bytes: 26292
H,W = map(int,input().split())
N = int(input())
colors = [int(x) for x in input().split()]

grid = [[0 for x in range(W)] for y in range(H)]
x,y = 0,0
for i in range(N):
    while colors[i] > 0:
        grid[y][x] = i + 1
        if x % 2 == 0:
            if y == H - 1:
                x += 1
            else:
                y += 1
        else:
            if y == 0:
                x += 1
            else:
                y -= 1
                
        colors[i] -= 1
        
for i in range(H):
    for j in range(W):
        print(grid[i][j],end=" ")
    print()


Measured memory_bytes: 3828
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

ll ans[100005];int tot=0;
const ll mx=3234566667ll;
void dfs(ll k)
{
	if(k>mx) return;
	ans[++tot]=k;
	int d=k%10;
	if(d>=1) dfs(k*10+d-1);
	dfs(k*10+d);
	if(d<=8) dfs(k*10+d+1);
}
int main()
{
	F(i,1,9) dfs(i);
	sort(ans+1,ans+100001);
	cout<<ans[rd()]<<endl;
	return 0;
}
////////////////////////

Measured memory_bytes: 1024
N = int(input())
pos = "Yes"

# all lines shuld be tested.
for l in range(1, N+1):
  t1, x1, y1 = [int(l) for l in input().split()]
  result = abs(x1) + abs(y1)
  if result > t1:
    pos = "No"
    break
  elif result <= t1:
    if t1 % 2 == 0 and result %2 != 0:
    	pos = "No"
    	break
    elif t1 % 2 != 0 and result %2 == 0:
    	pos = "No"
    	break
    else:
      continue
  else:
      print("Error")

print(pos)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#define maxn zhi5968
typedef long long ll;
using namespace std;

int main()
{
	int x,y,n,m;
	cin>>n>>m>>x>>y;
	int i,tmp;
	for(i=0;i<n;i++)
	{
		cin>>tmp;
		x=max(x,tmp);
	}
	for(i=0;i<m;i++)
	{
		cin>>tmp;
		y=min(y,tmp);
	}
	if(x<y)
		cout<<"No War"<<endl;
	else
		cout<<"War"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  int M=0;
  vector<int>V{105,135,165,189,195};
  for(int X=0;X<5;X++){
    if(N<V[X]){
      break;
    }
    else{
      M++;
    }
  }
  cout<<M<<endl;
}

Measured memory_bytes: 3600