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

int main(){
    
    // 1. 入力情報.
    int T;
    scanf("%d", &T);
    
    // 2. N枚のクッキーの美味しさの合計.
    // ex.
    // 4 108
    // 108
    // 127 19
    // 127 127 108
    // 127 127 127 19
    // -> 合計 400 となる.
    rep(i, T){
        int n, d, ans;
        scanf("%d %d", &n, &d);
        if(n & 1) ans = 127 * (n - 1) + d;
        else      ans = 127 * (n - 1) + (d ^ 127);
        printf("%d\n", ans);
    }
    return 0;
    
}

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

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

    string ans = "yes";
    for (int i = 0; i < S.size(); i++) {
        for (int j = i + 1; j < S.size(); j++) {
            if (S.at(i) == S.at(j)) ans = "no";
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

int main() {
  int a,b,t;
  cin >> a >> b >> t;

  int tt = t / a;
  cout << tt * b << endl;
}


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

const int INF = 2e9;

int main(){
    ll n,d;
    cin >> n >> d;
    d *= d;
    ll ans = 0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        x *= x;
        y *= y;
        if((x+y) <= d)ans++;
    }
    cout << ans << endl;
}

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

int main() {
  int N, X = 1, Y = 1;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    X *= 3;
    if (A % 2 == 0) Y *= 2;
  }
  cout << X - Y << endl;
}

Measured memory_bytes: 3644
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine

getRoot :: Int -> Int -> Int -> Int
getRoot n r s
  | r^2 > n = s
  | n `mod` r == 0 = getRoot n (r+1) (r + n `div` r - 2)
  | otherwise = getRoot n (r + 1) s

main = do
  n <- getInt
  print $ getRoot n 1 0


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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

vector<int> G[100010];
int n, m;
int a[100010], b[100010];

int color[100010];

bool dfs(int v, int c) {
	color[v] = c;
	for (int i = 0; i < G[v].size(); i++) {
		if(color[G[v][i]] == c) return false;

		if(color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
	}

	return true;
}

int main(void){
	cin>>n>>m;
	for (int i = 0; i < m; i++)  {
		int a, b; cin>>a>>b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	for (int i = 0; i < n; i++) {
		if(color[i] == 0) {
			if(!dfs(i, 1)) {
				cout<< (ll)n * (n - 1) / 2 - m <<endl;
				return 0;
			}
		}
	}

	ll black = 0, white = 0;
	for (int i = 0; i < n; i++) {
		if(color[i] == 1) black++;
		else if(color[i] == -1) white++;
	}

	cout<< black * white - m <<endl;
	
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

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

int main() {


    int h, w;

    cin >> h >> w;

    vector<vector<ll>> mp(10, vector<ll>(10, 0));

    for(int i = 0; i <= 9; ++i)
        for(int j = 0; j <= 9; ++j)
            cin >> mp[i][j];
        
    
    vector<ll> needMP(10, -1);

    ll sum = 0;

    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {

            int value;
            cin >> value;

            if(value == -1)
                continue;

            if(needMP[value] != -1) {
                sum += needMP[value];
                continue;
            }

            auto comp = [&](const pil &a, const pil &b) { return a.second > b.second; };
            priority_queue<pil, vector<pil>, decltype(comp)> q(comp);

            q.push(make_pair(value, 0));
            vector<bool> visited(10, false);

            while(!q.empty()) {

                auto node = q.top(); q.pop();
                int index = node.first;
                ll distance = node.second;

                if (visited[index])
                    continue;

                if(index == 1) {
                    needMP[value] = distance;
                    sum += distance;
                    break;
                }

                visited[index] = true;

                for(int i = 0; i <= 9; ++i) {
                    q.push(make_pair(i, distance + mp[index][i]));

                }
                
            }

        }
    }

    cout << sum << endl;

    return 0;
}

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

int main()
{
	int x;
	cin >> x;
	if (x < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
 
#define MOD 1000000007
void init();
void solve();

signed main()
{
    init();
    solve();
}

int n;
vector<int> a;
vector<int> dp;
#define INF 1234567891

void init()
{
    cin >> n;
    CINV(a, n);
    dp.RS(n, INF);
}

void solve()
{
    rep(i, n) {
        int x = a[i];
        *lower_bound(all(dp), x) = x;
    }
    cout << lower_bound(all(dp), INF) - dp.begin() << endl;
}




Measured memory_bytes: 3624
def common_multiple(x, y):
    for i in range(2, min(x, y)+1):
        x0, y0 = x % i, y % i
        if x0 == 0 or y0 == 0:
            return common_multiple(x // i if x0 == 0 else x, y // i if y0 == 0 else y) * i
    return x * y

a = input().split(" ")
A, B, C, D = int(a[0]) - 1, int(a[1]), int(a[2]), int(a[3])

M = common_multiple(C, D)
B0 = B // C + B // D - B // M
A0 = A // C + A // D - A // M
print(B - A - B0 + A0)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    
   	ll n, a[100005], ans = 1;
   	cin >> n;
   	for(int i = 0; i < n; i++){
   		cin >> a[i];
   	}
   	for(int i = 0; i < n; i++){
   		if(a[i] == 0){
   			cout << "0";
   			return 0;
   		}
   	}
   	for(int i = 0; i < n; i++){
   		if(a[i] <= 1000000000000000000 / ans){
   			ans *= a[i];
   		}
   		else{
   			ans = -1;
   			break;
   		}
   	}
   	cout << ans;

    return 0;
}

Measured memory_bytes: 4432
import sys
readline = sys.stdin.readline
import math
    
def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True  # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False  # 2,3,5の倍数は合成数
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False
        prime += step
        step = 6 - step
    return True

def main():
    Q = int(readline())
    is_2017 = [True] * (10**5 // 2)
    for i in range(10**5//2):
        if not is_prime(2*i+1):
            is_2017[i] = False
        if not is_prime(i+1):
            is_2017[i] = False

    is_2017[0] = 0
    for i in range(1, 10**5//2):
        is_2017[i] += is_2017[i-1]
    
    for _ in range(Q):
        l, r = map(int, readline().rstrip().split())
        if l == 1:
            print(is_2017[(r-1)//2])
        else:
            print(is_2017[(r-1)//2] - is_2017[(l-1)//2-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 5400
#include <iostream>
#include <cstdlib> //絶対値abs
#include <vector>
#include <algorithm> //minmax
using namespace std;
int N, M, tmp, tmp2;
long long h[100010];
long long dp[100010];
int like[50][50];
int like2;
const long long INF = 1LL << 62;

int main(){
	cin >> N;
	cin >> M;
	for (int i = 0; i < N; ++i){
		cin >> tmp;
		for(int j = 0; j < tmp; ++j){
			cin >> tmp2;
			like[i][tmp2] = 1;
		}
	}
	for (int i = 0; i < M+1; ++i){
		for(int j = 0; j < N; ++j){
			if (like[j][i]==0){
				break;
			}else if(j==N-1){
				like2++;
			}
		}
	}
	cout << like2;

	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, Q = (int(i) for i in input().split())
    edge = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = (int(i) for i in input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
    vertex = [0 for i in range(N)]
    for q in range(Q):
        p, x = (int(i) for i in input().split())
        vertex[p-1] += x
    from collections import deque
    G_color = ['WHITE' for _ in range(N)]
    G_parent = ['NIL' for _ in range(N)]

    def bfs(G, s):
        G_color[s] = 'GRAY'
        Q = deque()
        Q.append(s)
        while Q:
            u = Q.popleft()
            for v in G[u]:
                if G_color[v] == 'WHITE':
                    G_color[v] = 'GRAY'
                    G_parent[v] = u
                    vertex[v] += vertex[u]
                    Q.append(v)
            G_color[u] = 'BLACK'

    bfs(edge, 0)
    print(*vertex)


if __name__ == '__main__':
    main()


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

int main() {
  string S;
  int ans = 0, rans = 0;
  cin >> S;
  char c = '1';
  if('1' != S[0]) ans++;
  for(int i = 0; i < S.size()-1; i++) {
    if(c == S[i+1]){   
      ans++;
    }
    if(c == '1') c = '0';
    else c = '1';
  }
  c = '0';
  if('0' != S[0]) rans++;
  for(int i = 0; i < S.size()-1; i++) {
    if(c == S[i+1]){   
      rans++;
    }
    if(c == '1') c = '0';
    else c = '1';
  }
  cout << min(ans, rans);
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>


using namespace std;

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

    vector<int> v(N, 0);

    for (int i=0; i<M; ++i) {
        int a, b;
        cin >> a >> b;
        v[a-1] += 1;
        v[b-1] += 1;
    }

    for (auto &i : v) {
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

Measured memory_bytes: 3080
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<typename T>
T power(T x, long long n, const T &m){
    if(n == 0) return 1;
    if(n == 1) return x;
    T tmp = power(x, n/2, m);
    if(n%2 == 0) return tmp * tmp % m;
    else return tmp * tmp % m * x % m;
}

template<typename T>
T inverse(T x, const T &m){
    return power(x, m-2, m);
}

struct Combination{
private:
    int N;
    long long M;
    vector<long long> f, i;
public:
    void init(int n, long long m){
        N = n; M = m;
        f.resize(N+1); f[0] = 1;
        i.resize(N+1); i[0] = 1;
        for(long long j=1; j<=N; j++){
            f[j] = f[j-1]*j%M;
            i[j] = inverse(f[j], M);
        }
    }
    long long fact(int n){
        return f[n];
    }
    long long C(int n, int r){
        return f[n] * i[r] % M * i[n-r] % M;
    }
};

int K;
string S;
Combination C;

signed main(){
    cin >> K >> S;
    C.init(K+S.size(), MOD);
    ll ans = 0;
    rep(i, K+1){
        ans += C.C(i+S.size()-1, i) * power(25LL, i, MOD) % MOD * power(26LL, K-i, MOD) % MOD;
    }
    cout << ans%MOD << endl;
}

Measured memory_bytes: 35556
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,q;
int par(int x){
    return (x-1 + n-1)/n;
}

int main(void){
    cin>>n>>q;
    while(q--){
        int v,w;
        cin>>v>>w;
        if(n==1){
            cout<<v<<endl;
            continue;
        }
        while(v != w){
            while(v < w) w = par(w);
            if(v == w) break;
            v = par(v);
        }
        cout<<v<<endl;
    }
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    double r=sc.nextDouble();
    double s=Math.PI*r*r;
    double l=2*Math.PI*r;
    System.out.printf("%.6f",s);
    System.out.print(" ");
    System.out.printf("%.6f\n",l);
  }
}



Measured memory_bytes: 28356
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
typedef long long int lli;
const lli mod = 1e9+7;
using namespace std;

int main()
{
    int n,m;cin>>n>>m;
    cout<<((n-1)*n)/2 + ((m-1)*m)/2;


    return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int p[n];
	int ans = 0;
	for (int i = 0; i < n; i++){
		cin >> p[i];
	}
	for (int i = 0; i < n; i++){
		if (i && i != n - 1){
			if (p[i] > min(p[i - 1], p[i + 1]) && p[i] < max(p[i - 1], p[i + 1])){
				ans ++;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
S = input()

if len(S) % 2 == 1:
    S = S[:-1]

flag = 0
while flag == 0:
    S = S[:-2]
    ans = int(len(S) / 2)
    same_char = 0
    i = 0
    while i < ans:
        if S[i] == S[ans + i]:
            same_char += 1
        else:
            break
        i += 1
    if ans == same_char:
        flag = 1

print(len(S))

Measured memory_bytes: 3064
import math

D, G = map(int, input().split())
p = [0] * D
c = [0] * D
for i in range(D):
    p[i], c[i] = map(int, input().split())
# 各配点について全問解いた時のポイント
fsp = [p[i]*100*(i+1)+c[i] for i in range(D)]

# print(fsp)

min_pro = 100000000

def dfs(solve):
    global min_pro
    max_rest = -1
    if len(solve) == D:
        sum_point = 0
        sum_pro = 0
        for i in range(D):
            if solve[i] == "1":
                sum_point += fsp[i]
                sum_pro += p[i]
            else:
                max_rest = i
        #print(solve, sum_point, max_rest,math.ceil((G - sum_point) / ((max_rest+1)*100)))
        if sum_point < G:
            if math.ceil((G - sum_point) / ((max_rest+1)*100)) < p[max_rest]:
                sum_pro += math.ceil((G - sum_point) / ((max_rest+1)*100))
            else:
                sum_pro += 100000
        if min_pro > sum_pro:
            min_pro = sum_pro


        #pps[counter] = [sum_point, sum_pro, solve]
        #counter += 1
        return 0

    dfs(solve+"0")
    dfs(solve+"1")
    return 0

dfs("0")
dfs("1")

print(min_pro)
print("\n")


Measured memory_bytes: 3188
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
using namespace std;

namespace zyt
{
	template<typename T>
	inline bool read(T &x)
	{
		char c;
		bool f = false;
		x = 0;
		do
			c = getchar();
		while (c != EOF && c != '-' && !isdigit(c));
		if (c == EOF)
			return false;
		if (c == '-')
			f = true, c = getchar();
		do
			x = x * 10 + c - '0', c = getchar();
		while (isdigit(c));
		if (f)
			x = -x;
		return true;
	}
	template<typename T>
	inline void write(T x)
	{
		static char buf[20];
		char *pos = buf;
		if (x < 0)
			putchar('-'), x = -x;
		do
			*pos++ = x % 10 + '0';
		while (x /= 10);
		while (pos > buf)
			putchar(*--pos);
	}
	typedef long long ll;
	const int N = 60, P = 1e9 + 7;
	int n, deg[N], fa[2][N];
	bool mp[2][N][N];
	vector<int> g[N];
	void dfs(const int id, const int u, const int f)
	{
		fa[id][u] = f;
		for (int i = 1; i <= n; i++)
			if (i != f && mp[id][u][i])
				dfs(id, i, u);
	}
	bool vis[N], insta[N];
	bool dfs2(const int u)
	{
		insta[u] = true;
		for (auto v : g[u])
			if (!vis[v] && (insta[v] || !dfs2(v)))
				return false;
		vis[u] = true, insta[u] = false;
		return true;
	}
	int solve(const int r)
	{
		int ans = 0;
		dfs(0, r, 0), dfs(1, r, 0);
		for (int i = 1; i <= n; i++)
			g[i].clear();
		for (int i = 1; i <= n; i++)
		{
			if (fa[0][i] != fa[1][i])
			{
				++ans;
				if (fa[0][fa[0][i]] != fa[1][fa[0][i]])
					g[i].push_back(fa[0][i]);
				if (fa[0][fa[1][i]] != fa[1][fa[1][i]])
					g[fa[1][i]].push_back(i);
			}
			else
			{
				int tmp = i;
				while (tmp)
				{
					if (fa[0][tmp] != fa[1][tmp])
						return n + 1;
					tmp = fa[0][tmp];
				}
				tmp = i;
				while (tmp)
				{
					if (fa[0][tmp] != fa[1][tmp])
						return n + 1;
					tmp = fa[1][tmp];
				}
			}
		}
		memset(vis, 0, sizeof(bool[n + 1]));
		memset(insta, 0, sizeof(bool[n + 1]));
		for (int i = 1; i <= n; i++)
			if (fa[0][i] != fa[1][i] && !vis[i] && !dfs2(i))
				return n + 1;
		return ans;
	}
	int work()
	{
		int T;
		read(T);
		while (T--)
		{
			read(n);
			int ans = n + 1;
			memset(mp, 0, sizeof(mp));
			memset(deg, 0, sizeof(int[n + 1]));
			for (int i = 0; i < 2; i++)
				for (int j = 1; j < n; j++)
				{
					int a, b;
					read(a), read(b);
					mp[i][a][b] = mp[i][b][a] = true;
				}
			for (int i = 1; i <= n; i++)
			{
				int d = 0, t = 0;
				for (int j = 1; j <= n; j++)
					if (mp[0][i][j])
						++d, t = j;
				if (d > 1)
					continue;
				for (int j = 1; j <= n; j++)
					if (i != j)
					{
						mp[0][i][t] = mp[0][t][i] = 0;
						mp[0][i][j] = mp[0][j][i] = 1;
						ans = min(ans, solve(i) + (t != j));
						mp[0][i][j] = mp[0][j][i] = 0;
						mp[0][i][t] = mp[0][t][i] = 1;
					}
			}
			write(ans > n ? -1 : ans), putchar('\n');
		}
		return 0;
	}
}
int main()
{
	return zyt::work();
}

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

#define MAX_NODE 10000000

typedef long long ll;
typedef unsigned int uint;
ll INF=(1LL<<60);

extern inline uint xor128(void){
  static uint x=123456789,y=362436069,z=521288629,w=88675123; 
  uint t=x^(x<<11);
  x=y; y=z; z=w;
  return w=(w^(w>>19))^(t^(t>>8)); 
}

struct treap{
  treap* lch;
  treap* rch;
  uint pri;
  int cnt;
  ll val;
  ll min;
  treap(){  }
};

treap Field[MAX_NODE];
typedef treap* Treap;

int cnt(Treap t){  return (t?t->cnt:0); }
ll min(Treap t){ return (t?t->min:INF); }

Treap update(Treap t){
  if(!t)return NULL;
  t->cnt = cnt(t->lch) + cnt(t->rch) + 1;
  ll dat=t->val;
  dat=min(dat, min(t->lch) );
  dat=min(dat, min(t->rch) );
  t->min = dat;
  return t;
}

Treap makenode(ll v){
  static int cc=1;
  treap &res=Field[cc++];
  res.lch=res.rch=NULL;
  res.val=v;
  res.min=v;
  res.cnt=1;
  res.pri=xor128();
  return &res;
}

ll Find(Treap t,int k=1e9){
  k=min(k,cnt(t)-1);
  int f=cnt(t->lch);
  ll res;
  if(f>k)res=Find(t->lch,k);
  if(f<k)res=Find(t->rch,k-f-1);
  if(f==k)res=t->val;
  return res;
}

Treap merge(Treap l,Treap r){
  if(!l)return r;
  if(!r)return l;
  
  if( l->pri > r->pri ){
    l->rch = merge( l->rch , r );
    return update(l);
  }else{
    r->lch = merge( l , r->lch );
    return update(r);
  }
}

typedef pair< Treap, Treap > treaps;
treaps split(Treap t,int k){
  if(!t)return treaps(NULL,NULL);
  
  if(k<=cnt(t->lch)){
    treaps s=split(t->lch,k);
    t->lch=s.second;
    return treaps(s.first,update(t));
  }else{
    treaps s=split(t->rch, k-cnt(t->lch)-1 );
    t->rch=s.first;
    return treaps( update(t), s.second );
  }
}

Treap insertk(Treap &t,int k,ll val){
  Treap f=makenode(val);
  treaps s=split(t,k);
  return t=merge( merge(s.first,f) , s.second );
}

Treap erasek(Treap &t,int k){
  treaps a=split(t,k);
  treaps b=split(a.second,1);
  return t=merge(a.first,b.second);
}


int main(){
  Treap root=NULL;
  int n,q;
  scanf("%d %d",&n,&q);
  for(int i=0;i<n;i++)insertk(root,i,2147483647);
  
  while(q--){
    int type;
    scanf("%d",&type);
    if(type==0){
      int i,x;
      scanf("%d %d",&i,&x);
      erasek(root,i);
      insertk(root,i,x);
    }else{
      int l,r;
      scanf("%d %d",&l,&r);
      r++;
      treaps tmp = split(root,r);
      treaps tmp2 = split( tmp.first,l);
      printf("%lld\n",tmp2.second->min);
      root= merge( merge(tmp2.first,tmp2.second) , tmp.second );
    }
  }
  return 0;
}

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

typedef long long ll;

int N;
ll A[110];
int mem[110] = {0};

ll unit(int n)
{
    ll res = 0;
    if(3 * n > N)
    {
        for(int i = n; i <= N; i++)
        {
            if((i % 2 == 0 && i / 2 >= n) || mem[i])continue;
            if(i * 2 > N)res += max(0LL,A[i]);
            else
            {
                if(mem[i * 2])res += max(0LL,A[i]);
                else res += max(0LL,max(A[i],A[i] + A[i * 2]));
            }
        }
        return res;
    }
    if(mem[n])return unit(n + 1);
    res = A[n] + unit(n + 1);
    for(int i = n * 2; i <= N; i += n)mem[i]++;
    res = max(res,unit(n + 1));
    for(int i = n * 2; i <= N; i += n)mem[i]--;
    return res;
}

int main()
{
    scanf("%d",&N);
    for(int i = 1; i <= N; i++)scanf("%lld",A + i);

    printf("%lld\n",unit(1));
    return 0;
}


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


int main(){
	int a,b;
//	while(1){
		cin>>a>>b;
		if((a<=0&&b>=0)||(a>=0&&b<=0) )printf("Zero\n");
		else if(a>0&&b>0) printf("Positive\n");
		else{
			int k=min(a,b);
			int l=a+b-k;
			k=abs(k);
			l=abs(l);
			if((k-l+1)%2==0) printf("Positive\n");
			else printf("Negative\n");
		}
//	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int pflag = 0;
  int gflag = 0;
  int wflag = 0;
  int yflag = 0;
  
  // ここにプログラムを追記
  for(int i = 0; i < N; i++){
    string n;
    cin >> n;
    
    if(pflag && gflag && wflag && yflag){
		cout << "Four" << endl;
        break;
    }
  
    if(n == "P"){
      pflag = 1;
    } else if (n == "G"){
      gflag = 1;
    } else if (n == "W"){
      wflag = 1;
    } else if (n == "Y"){
      yflag = 1;
    }
  }
  
  if((!pflag && gflag && wflag && yflag) || (pflag && !gflag && wflag && yflag) || (pflag && gflag && !wflag && yflag) || (pflag && gflag && wflag && !yflag)){
  	cout << "Three" << endl;
  }
  
}


Measured memory_bytes: 256
n,k=map(int,input().split())
dp=[[0 for i in range(k+1)] for j in range(n+1)]
for i in range(n+1):
  dp[i][0]=1
dp[1][1]=1
for i in range(2,n+1):
  for j in range(1,k+1):
    dp[i][j]=dp[i-1][j-1]+dp[i-1][j]
for i in range(1,k+1):
  ans=dp[n-k+1][i]*dp[k-1][i-1]
  while ans>10**9+7:
    ans%=10**9+7
  print(ans)

Measured memory_bytes: 357592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    sort(a.begin(), a.end());

    int b = 0, c = 0;
    REP(i, N) if(i % 2) b += a[i]; else c += a[i];

    cout << abs(b - c) << endl; 

    return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

i = 0
j = 0
k = 0
list_all = []

for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            list_all.append((500*i + 100*j + 50 *k))
count = 0
for l in list_all:
    if l == X:
        count += 1

print(count)

Measured memory_bytes: 8276
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()
    val x = readLine()!!.toInt()
    var count = 0
    for (i in 0..a) {
        for (j in 0..b) {
            for (k in 0..c)
                if (500 * i + 100 * j + 50 * k == x) count++
        }
    }
    println(count)
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  int x, m;
  cin >> n >> x >> m;
  vector<int> ind(m, -1), a;
  int len = 0;
  long long pre_sum = 0;
  while (ind[x] == -1) {
    a.emplace_back(x);
    ind[x] = len++;
    pre_sum += x;
    x = (long long)x * x % m;
  }
  int nc = len - ind[x];
  long long ans = 0;
  if (n <= len) {
    for (int i = 0; i < n; i++) {
      ans += a[i];
    }
  } else {
    ans += pre_sum;
    n -= len;
    long long cyc_sum = 0, rem_sum = 0;
    int r = n % nc;
    for (int i = ind[x]; i < len; i++) {
      cyc_sum += a[i];
      if (i < ind[x] + r) {
        rem_sum += a[i];
      }
    }
    ans += cyc_sum * (n / nc) + rem_sum;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3944
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(s[0] == s[1] and s[1] != s[2] and s[2] == s[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

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

	int A = T.size();
	int B = A - 1;
	char C = T.at(B);

	if (S + C == T) {
		cout << "Yes" << endl;
		}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define speed ios::sync_with_stdio(0); cin.tie(0);
int const N = 1e5 + 2;
int a[N], fd[N];

int solve(int n, int k){
	int an = 1;
	n -= k;
	if (n % (k - 1) == 0) return an + n / (k - 1);
	if (n % (k - 1) != 0) return 1 + an + n / (k - 1);
	else return an + n;
}

int main(){
	speed
	int n, k;
	cin >> n >> k;
	f(i, 0, n)cin >> a[i];
	cout << solve(n, k) << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int x, a, b,c,d;
	scanf("%d %d %d", &x, &a, &b);
	x = x - a;
	c = x / b;
	d = x - c * b;
	printf("%d", d);
	system("pause");
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  string tmp, res;
  cin >> tmp;

  res += tmp[0];
  for (int i = 0; i < n - 1; i++) {
    if (tmp[i] != tmp[i + 1]) {
      res += tmp[i + 1];
    }
  }

  cout << res.size() << endl;
}



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

bool isPrime(int n){
  for(int i=2;i<=sqrt((double)n);i++){
    if(n%i == 0)return false;
  }
  return true;
}


int main(){
  int in;
  while(cin >> in){
    for(int i=in-1;i>=1;i--){
      if(isPrime(i)){
	cout << i << " ";
	break;
      }
    }
    for(int i=in+1;i<=60000;i++){
      if(isPrime(i)){
	cout << i << endl;
	break;
      }
    }

  }
  return 0;
}

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

const int limits = 100010;
int N;
vector<int> odd[limits];
vector<int> even[limits];
vector<int> color(limits, 0);

void dfs(int n, int c){
  color[n] = c;
  for(auto x: odd[n]){
    if(color[x] == 0){
      dfs(x, -c);
    }
  }
  for(auto x: even[n]){
    if(color[x] == 0){
      dfs(x, c);
    }
  }
}

int main(){
  cin >> N;
  int u,v,w;
  for(int i = 0; i < N-1; ++i){
    cin >> u >> v >> w;
    u--; v--;
    if(w%2 == 0){
      even[u].push_back(v);
      even[v].push_back(u);
    }else{
      odd[u].push_back(v);
      odd[v].push_back(u);
    }
  }
  dfs(0, 1);
  for(int i = 0; i < N; ++i){
    if(color[i] == 1){
      cout << 1 << endl;
    }else{
      cout << 0 << endl;
    }
  }
  
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long X, Y;
  cin >> X >> Y;
  int cnt = 0;
  while (Y >= X) Y >>= 1, cnt++;
  cout << cnt << '\n';
  return 0;
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	vector<int>a(3);
	rep(i, 3) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int sumb = a[2] - a[0];
	int sums = a[2] - a[1];
	int ans = 0;
	if ((sumb - sums) % 2 == 0) {
		ans = sums + (sumb - sums) / 2;
	}
	else {
		ans = 1+ sums + (sumb - sums+1) / 2;
	}
	print(ans);
}

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

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			int tot = i*m+j*n-2*i*j;
			if (k == tot) { puts("Yes"); return 0; }
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
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;
}
int main()
{
    Imposter

    int t=1;
    //cin>>t;
    while(t--)
    {
        ll x;
        cin>>x;
        if(x>=400 and x<=599)
        cout<<8<<endl;
        else if(x>=600 and x<=799)
        cout<<7<<endl;
        else if(x>=800 and x<=999)
        cout<<6<<endl;
        else if(x>=1000 and x<=1199)
        cout<<5<<endl;
        else if(x>=1200 and x<=1399)
        cout<<4<<endl;
        else if(x>=1400 and x<=1599)
        cout<<3<<endl;
        else if(x>=1600 and x<=1799)
        cout<<2<<endl;
        else
        cout<<1<<endl;

    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
 
int main() {
  string S, T; cin >> S >> T;
  int count = 0;
  rep(i, 3) {
    if (S.at(i) == T.at(i)) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t, req = 0;
    cin >> t;
    int a[t];
    for( int i = 0; i < t; i++){
        cin >> a[i];
    }
    sort (a, a+t);
    req += a[t-1]/2;
    for( int i = 0; i < t-1; i++){
        req += a[i];
    }
    cout << req << endl;

return 0;
}


Measured memory_bytes: 256
N = int(input())

sum = 0
for i in range(1, N+1, 2):
    cnt = 0
    for j in range(1, i+1):
        if i % j == 0:
           cnt += 1
        if cnt > 8:
            break
    else:
        if cnt == 8:
            sum += 1
print(sum)


Measured memory_bytes: 3060
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N;
    vector<ll> A(100010,0), x(100010,0);
    cin >> N;
    for (int i=0;i<N;i++) cin >> A[i];
    ll sum = accumulate(A.begin(), A.begin()+N, 0LL)/2;
    for (int i=0;i<N-2;i+=2) sum -= A[i];
    x[N-1] = sum;
    x[0] = A[N-1]-x[N-1];
    for (int i=1;i<N-1;i++) x[i] = A[i-1]-x[i-1];
    for (int i=0;i<N;i++) {
        cout << 2*x[i];
        if (i==N-1) cout << endl;
        else cout << " ";
    }

    return 0;
}


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

const int N = 1e5 + 5;

int n;
int dp[N][5];
int  a[N][5];

main(){
    scanf("%d" , &n);

    for(int i = 1 ; i <= n ; i ++)
        for(int j = 1 ; j <= 3 ; j ++)
            scanf("%d" , &a[i][j]);


    for(int i = 1 ; i <= n ; i ++){
        for(int j = 1 ; j <= 3 ; j ++){
            for(int k = 1 ; k <= 3 ; k ++){
                if(k != j)
                    dp[i][k] = max(dp[i][k] , a[i][k] + dp[i-1][j]);
            }
        }
    }

    printf("%d\n" , max( dp[n][1] , max(dp[n][2] , dp[n][3])));
}


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

int main() {
    int N, K;
    cin >> N >> K;
    if (K > (N - 1) * (N - 2) / 2) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> G[N + 1];
    int sum = (N - 1) * (N - 2) / 2;
    for (int i = 2; i <= N; i++) {
        G[1].emplace_back(i);
    }
    for (int i = 2; i <= N && sum != K; i++) {
        for (int j = i + 1; j <= N && sum != K; j++) {
            G[i].emplace_back(j);
            sum--;
        }
    }
    cout << N - 1 + (N - 1) * (N - 2) / 2 - K << endl;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < G[i].size(); j++) {
            cout << i << " " << G[i][j] << endl;
        }
    }
}

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

int main()
{
    int n, a[100], b[100];
    char c;
    string s;

    while( cin >> n )
    {
        if( !n )
            break;
        
        cin >> s;

        for( int i = 0; i < n; i++ )
            cin >> a[i] >> b[i];

        for( int i = n - 1; i >= 0; i -- )
        {
            s[a[i]-1] = ( s[a[i]-1] - 'a' + b[i] - a[i] ) % 26 + 'a';
            s[b[i]-1] = ( s[b[i]-1] - 'a' + b[i] - a[i] ) % 26 + 'a';

            c = s[a[i]-1];
            s[a[i]-1] = s[b[i]-1];
            s[b[i]-1] = c;
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
//#define _GLIBCXX_DEBUG

int main() {
    int A, B;
    cin >> A >> B;
    cout << A*B << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>
#include <deque>
using namespace std;
using ll = long long;

void solve();
int main() {
	solve();
#ifdef DBG
	while (true);
#endif
}

int n;
char s[600][600];
int Check(int A, int B, int i, int j) {
	return s[A + i][B + j] == s[A + j][B + i];
}
int Init(int A, int B) {
	int count = 0;
	for (int i = 1; i < n; i++)
		for (int j = 0; j < i; j++)
			count += Check(A, B, i, j);
	return count;
}
int Remove(int A, int B) {
	int count = 0;
	for (int i = 1; i < n; i++)
		count += Check(A, B, i, 0);
	return count++;
}
int Add(int A, int B) {
	int count = 0;
	for (int i = 0; i < (n - 1); i++)
		count += Check(A, B, n - 1, i);
	return count;
}
void solve() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%s", s[i]);
	for (int i = 0, j; i < n; i++)
		for (j = 0; j < n; j++)
			s[n + i][j] = s[i][n + j] = s[n + i][n + j] = s[i][j] = s[i][j] - 'a';

	int count = 0;
	for (int i = 0; i < n; i++) {
		int cur = Init(i, 0);
		for (int A = i, B = 0; A < n;) {
			if (cur == n * (n - 1) / 2)
				count++;
			cur -= Remove(A, B);
			A++, B++;
			cur += Add(A, B);
		}
	}
	for (int i = 1; i < n; i++) {
		int cur = Init(0, i);
		for (int A = 0, B = i; B < n;) {
			if (cur == n * (n - 1) / 2)
				count++;
			cur -= Remove(A, B);
			A++, B++;
			cur += Add(A, B);
		}
	}
	printf("%d\n", count);
}

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

using namespace std;

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

int vv[110][110];
int main() {
	int h, w;
	cin >> h >> w;
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			cin >> vv[i][j];
		}
	}
	if(w == 1) {
		rep(i, h) {
			if(i) ans += 1 - vv[i][0];
			else ans += vv[i][0];
		}
		cout << ans << endl;
		return 0;
	}
	reep(i, 1, h) {
		vv[i][0] = 1 - vv[i][0];
		vv[i][w - 1] = 1 - vv[i][w - 1];
	}
	reep(j,1, w-1) {
		vv[0][j] = 1 - vv[0][j];
	}
	rep(i, h) {
		bool ok = false;
		rep(j, w) {
			if(!vv[i][j]) ok = true;
			ans += vv[i][j];
		}
		if(ok) ans += 1;
		else ans -= 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3088
def main():
    N = int(input())
    S = []
    for i in range(N):
        S.append(input())
    S = sorted(S)

    c = {}
    for i in range(N):
        s = S[i]
        c[s] = c[s] + 1 if (s in c)  else 1

    m = max(list(c.values()))
    ss = sorted(list(c.keys()))
    for s in ss:
        if c[s] == m:
            print(s)

if __name__ == "__main__":
    main()

Measured memory_bytes: 38180
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int w[114],v[114];
//i個目までの価値jのときの重さの最小値
int dp[114][114514];
signed main(){
	int ans=-1;
	int n,W;
	cin>>n>>W;
	rep(i,n)cin>>w[i]>>v[i];
	rep(i,n){rep(j,114511)dp[i][j]=1e9+7;}
	dp[0][0]=0;
	dp[0][v[0]]=w[0];
	for(int i=1;i<n;i++){
		for(int j=0;j<114511;j++){
			if(j<v[i])dp[i][j]=dp[i-1][j];
			else dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
		}
	}
	for(int j=0;j<114511;j++){
		if(dp[n-1][j]<=W&&dp[n-1][j]!=1e9+7)ans=max(ans,j);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 90496
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll x;
    cin>>x;
    
    if (1200 > x)cout <<"ABC"<< endl;
    else cout << "ARC" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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


typedef complex<double> Point, Vector;
typedef pair<Point, Point> Segment, Line;
typedef vector<Point> Polygon;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

double dot(Vector a, Vector b){
    return a.X * b.X + a.Y * b.Y;
}

double cross(Vector a, Vector b){
    return a.X * b.Y - a.Y * b.X;
}

double norm(Vector a){
    return a.X * a.X + a.Y * a.Y;
}

double abs(Vector a){
    return sqrt(norm(a));
}

// ベクトルと点の位置関係
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a, b) < -EPS) return CLOCKWISE;
    if(dot(a, b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;

    return ON_SEGMENT;
}

bool isConvex(Polygon pol){
    int n = pol.size();

    for(int i=0; i<n; i++){
        if(ccw(pol[i], pol[(i+1)%n], pol[(i+2)%n]) == CLOCKWISE){
            return false;
        }
    }

    return true;
}

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

    double x1, y1, x2, y2, x3, y3, x4, y4;
    char a;
    while(cin>>x1>>a>>y1>>a>>x2>>a>>y2>>a>>x3>>a>>y3>>a>>x4>>a>>y4){
        Point p1 = Point(x1, y1), p2 = Point(x2, y2), p3 = Point(x3, y3), p4 = Point(x4, y4);
        Polygon pol1, pol2;
        pol1.emplace_back(p1);
        pol1.emplace_back(p2);
        pol1.emplace_back(p3);
        pol1.emplace_back(p4);

        pol2.emplace_back(p1);
        pol2.emplace_back(p4);
        pol2.emplace_back(p3);
        pol2.emplace_back(p2);

        cout << (isConvex(pol1) || isConvex(pol2) ? "YES" : "NO") << endl;
    }


    return 0;
}


Measured memory_bytes: 3208
a, b, c, d = (int(i) for i in input().split())
l = [0] * 101

for i in range(a, b+1):
    l[i] += 1
    
for i in range(c, d+1):
    l[i] += 1
ans = 0
for i in l:
    if i == 2: ans += 1
print(max(ans-1, 0))


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

using namespace std;

#define endl '\n'

typedef long long int lli;

int d[10], a[10];

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < 10; i++) {
		a[i] = -1;
	}
	for (int i = 0; i < k; i++) {
		cin >> d[i];
		a[d[i]] = 1;
	}
	int res = -1;
	for (int i = n; ; i++) {
		int m = i;
		bool ch = true;
		while (m > 0) {
			int r = m % 10;
			m /= 10;
			if (a[r] == 1) {
				ch = false;
				break;
			}
		}
		if (ch) {
			res = i;
			break;
		}
	}
	cout << res << "\n";
	return 0;
}

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

int main(){
    int N,M,A,ans=0;
    cin >> N >> M;
    for (int i=0 ; i<M ; i++){
        cin >> A;
        ans+=A;
    }
    if (N-ans>=0)
    cout << N-ans << endl;
    else 
    cout << -1 << endl;
}



Measured memory_bytes: 3596
import sys
input = sys.stdin.readline

S = input().rstrip()

for i in range(len(S)):
  S = S[:-1]
  Slen = len(S)
  if Slen % 2 != 0:
    pass
  if S[:int(Slen/2)] == S[int(Slen/2):]:
    print(int(Slen))
    sys.exit()


Measured memory_bytes: 2940
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
numMap = {}
ans = 0

for i in range(n):
    num = a[i]
    if num in numMap:
        numMap[num] += 1
    else:
        numMap[num] = 1

if len(numMap) <= k:
    print(0)
    sys.exit()

cnts = []
for cnt in numMap.values():
    cnts.append(cnt)
cnts.sort()
temp = len(numMap)

for cnt in cnts:
    if temp == k:
        break
    ans += cnt
    temp -= 1

# print(numMap)
# print(cnts)
print(ans)


Measured memory_bytes: 97608
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())

print(s[k-1])

Measured memory_bytes: 2940
# PROBLEM C
h, w = [int(s) for s in input().split()]
sij = [input() for _ in range(h)]
#print(sij)

lonely_sharp = False
for idx in range(h):
    for jdx in range(w):
        #print(idx, jdx)
        if sij[idx][jdx] == '#' and all([
                idx == 0 or sij[idx - 1][jdx] == '.',
                idx == h - 1 or sij[idx + 1][jdx] == '.',
                jdx == 0 or sij[idx][jdx - 1] == '.',
                jdx == w - 1 or sij[idx][jdx + 1] == '.']):
            lonely_sharp = True
            break
if lonely_sharp:
    print('No')
else:
    print('Yes') 

Measured memory_bytes: 3064