akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <string>
using namespace std;

int x, y;

void solve(int i, int j, vector<int>& v, int ch, int nx) {
	int dxy[] ={0, 1, 0, -1, 0};
	for(int k = 0; k < 4; k++) {
		if(i+dxy[k] >= 0 && i+dxy[k] < y && j+dxy[k+1] >= 0 && j+dxy[k+1] < x) {
			if(((v[i+dxy[k]] >> (2*(j+dxy[k+1]))) & 3) == ch) {
				v[i+dxy[k]] &= ~(3 << (2*(j+dxy[k+1])));
				v[i+dxy[k]] |= nx << (2*(j+dxy[k+1]));
				solve(i+dxy[k], j+dxy[k+1], v, ch, nx);
			}
		}
	}
}

int main() {
	while(cin >> x >> y, x || y) {
		vector<int> v;
		for(int i = 0; i < y; i++) {
			int a = 0;
			for(int j = 0; j < x; j++) {
				string c;
				cin >> c;
				if(c[0] == 'R') {
					a |= 0 << (2*j);
				}
				else if(c[0] == 'G') {
					a |= 1 << (2*j);
				}
				else {
					a |= 2 << (2*j);
				}
			}
			v.push_back(a);
		}

		queue<vector<int> > q;
		q.push(v);
		int ans = -1;
		for(int t = 0;; t++) {
			queue<vector<int> > nex;
			while(!q.empty()) {
				vector<int> vn[2];
				vn[0] = vn[1] = q.front(); q.pop();
				bool flg = true;
				for(int i = 0; i < y; i++) {
					for(int j = 0; j < x; j++) {
						if(((vn[0][i] >> (2*j)) & 3) != (vn[0][0] & 3))
							flg = false;
					}
				}

				if(flg) {
					ans = t;
					goto exit;
				}

				int ch = vn[0][0] & 3;
				vn[0][0] &= ~3;
				vn[0][0] |= (ch+1)%3;
				solve(0,0,vn[0],ch,(ch+1)%3);
				vn[1][0] &= ~3;
				vn[1][0] |= (ch+2)%3;
				solve(0,0,vn[1],ch,(ch+2)%3);

				nex.push(vn[0]);
				nex.push(vn[1]);
			}
			q = nex;
		}
exit:;
		cout << ans << endl;
	}
}

Measured memory_bytes: 19748
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t,u;
	int a,b;
	cin>>s>>t;
	cin>>a>>b;
	cin>>u;
	if(u==s) cout<<a-1<<" "<<b<<endl;
	else cout<<a<<" "<<b-1<<endl;
	return 0; 
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

std::vector<int> v;

ll N;

bool can(ll x){
    v.clear();

    int rest = N;
    for(int i=x;i>0;--i){
        if(rest >= i){
            v.emplace_back(i);
            rest -= i;
        }
    }

    // std::cout << x << ": " << rest << std::endl;
    return rest == 0;
}

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

    std::cin >> N;

    // if minimizing, lb satisfies lb > ub
    // if maximizing, lb satisfies lb < ub
    ll lb = N, ub = 0;
    
    while(std::abs(ub - lb) > 1){
        ll mid = (lb + ub) / 2;
        
        if(can(mid)){
            // std::cout << "ok: " << mid << std::endl;
            lb = mid;
        }else{
            // std::cout << "ng: " << mid << std::endl;
            ub = mid;
        }
    }

    // std::cout << lb << std::endl;
    
    can(lb);

    for(int x : v){
        std::cout << x << std::endl;
    }
}


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

string s;
int i,p;

int main(){
    cin>>s;
    i=0;
    while (s[i]!='A') s.erase(0,1);
    for (i=0; i<s.length(); i++) if (s[i]=='Z') p=i+1;
    cout<<p;
    return 0;
}


Measured memory_bytes: 768
type Dice = [Pip]
type Pip = String
type ToBe = [Pip]

main :: IO ()
main = do
    dice <- fmap words getLine
    _    <- getLine
    questions <- fmap (map words . lines) getContents
    putStr . unlines $ map (rightSide dice) questions

rightSide :: Dice -> ToBe -> Pip
rightSide dice tobe =
    head [s | s@(a:b:_) <- allStates dice, [a,b] == tobe] !! 2

allStates :: Dice -> [Dice]
allStates = concatMap allTurns . allTops

allTops :: Dice -> [Dice]
allTops dice = scanl role dice "EESEE"

allTurns :: Dice -> [Dice]
allTurns dice = scanl turn dice "RRR"

turn :: Dice -> Char -> Dice
turn [a,b,c,d,e,f] com
    | com == 'R' = [a,c,e,b,d,f]
    | com == 'L' = [a,d,b,e,c,f]

role :: Dice -> Char -> Dice
role [a,b,c,d,e,f] com
    | com == 'E' = [d,b,a,f,e,c]
    | com == 'N' = [b,f,c,d,a,e]
    | com == 'S' = [e,a,c,d,f,b]
    | com == 'W' = [c,b,f,a,e,d]


Measured memory_bytes: 3692
import collections
N = int(input())

s = [sorted(list(input())) for i in range(N)]

for i in range(N):
    s[i] = ''.join(s[i])

ans = 0

c = collections.Counter(s)
for v in c.values():
    ans += (1/2) * v * (v-1)

print(int(ans))


Measured memory_bytes: 30612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int[] data = new int[n];

		for(int i = 0; i < n; i++){
			data[i] = Integer.parseInt(br.readLine());
		}

		sortManager.shellSort(data, n);

		System.out.println(sortManager.cnt);

		for(int i = 0; i < n; i++){
			System.out.println(data[i]);
		}
	}

}

class sortManager {
	public static int cnt = 0;

	public static void insertionSort(int[] A, int n, int g){
		for(int i = g; i <= n-1; i++){
			int v = A[i];
			int j = i - g;
			while(j >= 0 && A[j] > v){
				A[j+g] = A[j];
				j = j - g;
				cnt++;
			}
			A[j+g] = v;
		}
	}

	public static void shellSort(int[] A, int n){
		cnt = 0;
		//int[] G = {121,40,13,4,1};
		ArrayList<Integer> G = new ArrayList<Integer>();
		
		//G??????????¨??????????
		for(int i = 1;; i++){
			int tmp = ((int)Math.pow(3, i) - 1)/2;
			if(tmp <= n){
				G.add(tmp);
			}
			else break;
		}
		
		int m = G.size();

		System.out.println(m);

		for(int i = 0; i <= m-1; i++){
			System.out.print(G.get(m-i-1));
			if(i != m-1){
				System.out.print(" ");
			}
			insertionSort(A, n, G.get(m-i-1));
		}
		System.out.println();
	}
}

Measured memory_bytes: 106856
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
            var n = int.Parse(Console.ReadLine());
            var data = new List<Data>();
            for (int i = 0; i < n; i++)
            {
                var inputs = Console.ReadLine().Split(' ');
                data.Add(new Data
                {
                    Item1 = inputs[0],
                    Item2 = int.Parse(inputs[1]),
                    Item3 = i + 1
                });
            }

            foreach (var output in data.OrderBy(d => d.Item1).ThenByDescending(d => d.Item2).Select(d => d.Item3))
            {
                Console.WriteLine(output);
            }
		}
	}

    struct Data
    {
        public string Item1;
        public int Item2;
        public int Item3;
    }
}


Measured memory_bytes: 11616
import sys
import itertools
import copy

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    s = list(in_s())[::-1]
    ss = sorted(list(set(s)))

    ans = 100
    for c in ss:
        count = 0
        ts = [c if t == c else 'A' for t in s]
        gr = itertools.groupby(ts)
        for k, v in gr:
            n = len(list(v))
            if k != c:
                count = max(count, n)
        ans = min(ans, count)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9272
#include <iostream>
#include <cmath>

typedef long long int ll;

int main() {
  ll i, n, p, ans = 1;
  
  std::cin >> n >> p;
  
  ll gcd_lim = pow(p, 1.0 / n);
  
  if (n == 1) {
    std::cout << p << std::endl;
    return 0;
  }
  
  for (gcd_lim = gcd_lim + 1; gcd_lim >= 1; gcd_lim--) {
    if ((p % (ll) std::pow(gcd_lim, n)) == 0) {
      break;
    }
  }
  
  std::cout << gcd_lim << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000) # 再帰上限を増やす

def main():
    input = sys.stdin.readline  # 文字列に対してinputした場合は、rstripするのを忘れずに！
    ticket = input().rstrip()
    N = 4
    num_list = []
    for num in ticket:
        num_list.append(int(num))

    for bit in range(1 << (N-1)):
        sum_value = num_list[0]
        op_list = []

        for i in range(N-1):
            if bit & (1 << i):
                # +を入れるパターン
                op_list.append("+")
                sum_value += num_list[i+1]
            else:
                # -を入れるパターン
                op_list.append("-")
                sum_value -= num_list[i+1]

        if sum_value == 7:
            op_list.append("=")
            for num, op, in zip(num_list, op_list):
                print(num, op, sep="", end="")
            print(7)
            exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define str string
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
#define popcount __builtin_popcountll
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve() {
	int ans = 0, d = 0;
	int K, N; cin >> K >> N;
	vi A(N + 1); rep(i, N) cin >> A[i];
	A[N] = K + A[0];
	rep(i, N) {
		d = max(d, A[i + 1] - A[i]);
	}
	ans = K - d;
	cout << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}

Measured memory_bytes: 1920
<?php
fscanf(STDIN, '%d', $S);
$x1 = intdiv($S, pow(10, 9)) + ($S % pow(10, 9) !== 0);
$y2 = pow(10, 9);
$y1 = 1;
$x2 = $x1 * $y2 - $S;
$x3 = $y3 = 0;
$v = abs(($x1 - $x3) * ($y2 - $y3) - ($x2 - $x3) * ($y1 - $y3));
//printf("%d\n", PHP_INT_MAX);
//printf("%d\n", $v);
//printf("%d\n", $S);
//printf("%d\n", abs($v - $S));
printf("%d %d %d %d %d %d", $x1, $y1, $x2, $y2, $x3, $y3);

Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
void solve();
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("error.txt", "w", stderr);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--)
		{
			solve();
			cout << "\n";
		}

	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}
void solve()
{
	string s;
	cin >> s;
	if (s.back() == 's')
		{
			cout << s << "es" << endl;
		}
	else cout << s << "s" << endl;

}


Measured memory_bytes: 3840
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#define PI 3.14159265359
using namespace std;

int main(){
    double x,y,angle;
    double area,surround,high;
    cin >> x >> y >> angle;
    area = 0.5 * x * y * sin(PI * angle/180);
    surround = x + y + sqrt( (x*x + y*y) -2*x*y*cos(PI * angle/180) );
    high = y * sin(PI * angle/180);

    cout << fixed << setprecision(10) << area << endl;
    cout << fixed << setprecision(10) << surround << endl;
    cout << fixed << setprecision(10) << high << endl;

    return 0;
}

Measured memory_bytes: 3416
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        String line = sc.nextLine();
        String S = line + line;
        char[] s = S.toCharArray();

        line = sc.nextLine();
        char[] p = line.toCharArray();

        int check = 0;

        point:
        for(int i = 0; i < s.length; i++) {
          if(s[i] == p[0]) {
            for(int j = 0; j < p.length; j++) {
              if(i + j == s.length) {
                break point;
              } else if(s[i + j] != p[j]) {
                break;
              } else if(j == p.length - 1) {
                check = 1;
                break point;
              }
            }
          }
        }

        if(check == 1) {
          System.out.println("Yes");
        } else {
          System.out.println("No");
        }
    }
}

Measured memory_bytes: 26160
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

require 'prime'

A, B = get_ints

def divisor(n)
  result = SortedSet.new
  result.add(1); result.add(n)
  i = 1
  num = Math.sqrt(n)
  while i <= num do
    remainder = n % i
    if remainder == 0
      result.add(i)
      result.add(n/i)
    end
    i += 1
  end
  result.to_a
end

a_divisors = divisor(A)
b_divisors = divisor(B)

ab_divisors = (a_divisors & b_divisors).sort[1..] # 1 は必ず入っているので削除

count = 1 # 1を入れるので1からカウント
set = Set.new
i = 0
while i < ab_divisors.length
  unless set.include?(ab_divisors[i])
    count += 1
    j = i + 1
    while j < ab_divisors.length
      set.add(ab_divisors[j]) if ab_divisors[j] % ab_divisors[i] == 0
      j += 1
    end
  end
  i += 1
end

puts count


Measured memory_bytes: 15376
#include<stdio.h>
int main(){int W,H,x,y,r;
scanf("%d%d%d%d%d", &W,&H,&x,&y,&r);
if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){printf("Yes\n");}

else{printf("No\n");}

return 0;
}

Measured memory_bytes: 584
#!/usr/bin/env python3

a_r_list = []
a_c_list = [[],[],[]]
a_table = []
for _ in range(3):
    a_list = list(map(int, input().split()))
    a_r_list.append(a_list)
    for i, a in enumerate(a_list):
        a_c_list[i].append(a)
    a_table.append(a_list)
a_list_list = a_r_list + a_c_list
a_list_list += [[a_table[0][0], a_table[1][1], a_table[2][2]]]
a_list_list += [[a_table[0][2], a_table[1][1], a_table[2][0]]]

N = int(input().split()[0])
is_ok = False
for _ in range(N):
    b = int(input().split()[0])
    for a_list in a_list_list:
        try:
            a_list.remove(b)
        except ValueError:
            pass
        if not a_list:
            is_ok = True
ans = "Yes" if is_ok else "No"
print(ans)


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

double p[301][451][2];
double e[301][451][2];

int main(){
  for(int i=0;i<=300;++i)
    for(int j=0;j<=450;++j)
      for(int k=0;k<2;++k){
	p[i][j][k]=0;
	e[i][j][k]=0;
      }

  int N;
  std::cin>>N;
  int n1=0,n2=0,n3=0;

  for(int i=0;i<N;++i){
    int a;
    std::cin>>a;
    if(a==1)++n1;
    else if(a==2)++n2;
    else ++n3;
  }
  p[n3][n2][(n1+2*n2+3*n3)%2]=1;
  for(int sum=n1+2*n2+3*n3;sum>0;--sum){
    for(int i=0;i<=300;++i){
      for(int j=0;j<=450;++j){
  	int k=sum-3*i-2*j;
	if(k<0||k>900)continue;
	if(p[i][j][sum%2]==0)continue;
  	if(i>0) p[i-1][j+1][(sum+1)%2]+=p[i][j][sum%2]*1.*i/(i+j+k);
  	if(j>0) p[i][j-1][(sum+1)%2]+=p[i][j][sum%2]*1.*j/(i+j+k);
  	if(k>0) p[i][j][(sum+1)%2]+=p[i][j][sum%2]*1.*k/(i+j+k);
      }
    }
    for(int i=0;i<=300;++i){
      for(int j=0;j<=450;++j){
  	int k=sum-3*i-2*j;
	if(k<0||k>900)continue;
	if(p[i][j][sum%2]==0)continue;
  	if(i>0) e[i-1][j+1][(sum+1)%2]+=(e[i][j][sum%2]+1.*N/(i+j+k))*p[i][j][sum%2]*1.*i/(i+j+k)/p[i-1][j+1][(sum+1)%2];
	if(j>0) e[i][j-1][(sum+1)%2]+=(e[i][j][sum%2]+1.*N/(i+j+k))*p[i][j][sum%2]*1.*j/(i+j+k)/p[i][j-1][(sum+1)%2];
	if(k>0) e[i][j][(sum+1)%2]+=(e[i][j][sum%2]+1.*N/(i+j+k))*p[i][j][sum%2]*1.*k/(i+j+k)/p[i][j][(sum+1)%2];
      }
    }
    for(int i=0;i<=300;++i){
      for(int j=0;j<=450;++j){
  	int k=sum-3*i-2*j;
	e[i][j][sum%2]=0;
	p[i][j][sum%2]=0;
      }
    }
  }
  printf("%.20f\n",e[0][0][0]);
  return 0;
}


Measured memory_bytes: 4480
#include<stdio.h>
#include<string.h>
#define INT_MAX 0x3f3f3f3f
struct edge
{
    int x, y, z;
}a[10005];
int n, m, dis[105];
void Bellman_ford()
{
    memset(dis, INT_MAX, sizeof(dis));
    dis[0] = 0;
    for(int i = 1; i < n; i++)
        for(int j = 1; j <= m; j++)
            if(dis[a[j].y] > dis[a[j].x] + a[j].z)
                dis[a[j].y] = dis[a[j].x] + a[j].z;
}
int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        int x, j;
        scanf("%d%d", &x, &j);
        while(j--){
            a[++m].x = x;
            scanf("%d%d", &a[m].y, &a[m].z);
        }
    }
    Bellman_ford();
    for(int i = 0; i < n; i++)
        printf("%d %d\n", i, dis[i]);
    return 0;
}


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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define let const auto
#define USE1(T) template <typename T>
#define USE2(T, U) template <typename T, typename U>
#define I_ inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

USE1(T) using duo = std::pair<T, T>;
USE1(T) using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE2(T,U) I_ bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U) I_ bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int) I_ T in(){T x;std::cin>>x;return x;}
USE1(T=int) I_ vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T) vec<T> ndvec(T v,int n){return vec<T>(n, v);}
USE2(T,...Ts) auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T) I_ void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts) I_ void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
I_ int re(){int x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
I_ void wr(int x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
struct IoSetup {
  IoSetup(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cerr<<setprecision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int N = in();
  int K = in();
  int X = in();
  int Y = in();

  pr(min(K, N) * X + max(N - K, 0) * Y);

  return 0;
}


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

def primes(m) :
    ps = [2]
    for i in range(3, m+1) :
        for p in ps :
            if i%p == 0 :
                break
        else :
            ps.append(i)
    return ps

def fdivisor(m) :
    ps = primes(m)
    df = {p:0 for p in ps}
    for i in range(1, m+1) :
        ii = i
        while ii != 1 :
            for p in ps :
                if ii%p == 0 :
                    df[p] += 1
                    ii //= p
    return df

ans = 0
df = fdivisor(n)
over2 = len([v for v in df.values() if v >= 2])
over4 = len([v for v in df.values() if v >= 4])
over14 = len([v for v in df.values() if v >= 14])
over24 = len([v for v in df.values() if v >= 24])
over74 = len([v for v in df.values() if v >= 74])
ans += over4*(over4-1)//2*(over2-2)
ans += over14*(over4-1)
ans += over24*(over2-1)
ans += over74

print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long
#define ulli unsigned long long int
#define ld long double  
#define endl "\n"
using namespace std; 


void solve() {
    int n, d, x;
    cin >> n >> d >> x;

    int sum = x;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        sum += ceil(d/(float)a);
    }

    cout << sum << endl;
}

int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  
    int t = 1; 
    //cin >> t; 
    while (t--) { 
        solve(); 
    } 
  
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
    return 0; 
} 


Measured memory_bytes: 3792
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val field = Array(h) { readLine()!!.toCharArray() }
    for (y in 0 until h) {
        for (x in 0 until w) {
            if (field[y][x] == '#') continue
            var bomb = 0
            for (yy in y - 1..y + 1) {
                if (yy !in 0 until h) continue
                for (xx in x - 1..x + 1) {
                    if (xx !in 0 until w) continue
                    if (field[yy][xx] == '#') {
                        bomb++
                    }
                }
            }
            field[y][x] = '0' + bomb
        }
    }
    field.forEach {
        println(it.joinToString(""))
    }
}


Measured memory_bytes: 38308
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

int main() {
  ll N, T;
  cin >> N >> T;

  vP lst(N);
  vvll dp(N + 1, vll(T + 1, 0));

  for (ll i = 0; i < N; i++) {
    cin >> lst[i].first >> lst[i].second;
  }
  sort(lst.begin(), lst.end());

  ll ans = LONG_LONG_MIN;
  for (ll i = 0; i < N; i++) {
    P p = lst[i];
    for (ll j = 0; j < T; j++) {
      chmax(dp[i + 1][j], dp[i][j]);
      ll nj = j + p.first;
      if (nj < T) chmax(dp[i + 1][nj], dp[i][j] + p.second);
    } // j
    ll now = dp[i][T-1] + p.second;
    chmax(ans, now);
  }  // i

  cout << ans << endl;

  return 0;
}


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

int gcd(int a,int b) {return b ? gcd(b,a%b) : a;}
int n, m, g, x, y;
char S[100100], T[100100];

int main() {
	scanf("%d%d%s%s",&n,&m,S,T);
	g = gcd(n,m);  x = n / g;  y = m / g;
	for (int i=0,j=0;i<n&&j<m;i+=x,j+=y) {
		if (S[i] != T[j]) return puts("-1"),0;
	}
	printf("%lld\n",(ll)n*m/g);
}

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

int arr[100000];
int oddV[100001];
int evenV[100001];

int main()
{
    for (int i = 0; i <= 100000; i++)
    {
        oddV[i] = 0;
        evenV[i] = 0;
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        if (i % 2 == 0) {evenV[arr[i]]++;}
        else {oddV[arr[i]]++;}
    }
    int oddF = -1, oddS = -1;
    int oddFi = -1, oddSi = -1;
    for (int i = 0; i <= 100000; i++)
    {
        if (oddV[i] > oddF)
        {
            oddS = oddF;
            oddSi = oddFi;
            oddF = oddV[i];
            oddFi = i;
        }
        else if (oddV[i] > oddS)
        {
            oddS = oddV[i];
            oddSi = i;
        }
    }
    int evenF = -1, evenS = -1;
    int evenFi = -1, evenSi = -1;
    for (int i = 0; i <= 100000; i++)
    {
        if (evenV[i] > evenF)
        {
            evenS = evenF;
            evenSi = evenFi;
            evenF = evenV[i];
            evenFi = i;
        }
        else if (evenV[i] > evenS)
        {
            evenS = evenV[i];
            evenSi = i;
        }
    }
    int result;
    if (oddFi != evenFi)
    {
        result = n - oddF - evenF;
    }
    else
    {
        result = min(n - oddF - evenS, n - oddS - evenF);
    }
    cout << result << endl;
}


Measured memory_bytes: 1408
#include <cassert>
#include <vector>

template <typename SemiLattice> class SparseTable {
public:
	using value_type = SemiLattice;
	using container_type = std::vector<value_type>;
	using size_type = typename container_type::size_type;

private:
	static size_type clz32(size_type c) {
#ifdef __GNUC__
		return 31 ^ __builtin_clz(c);
#else
		size_type ret = 0;
		if (c & 0xFFFF0000)
			c &= 0xFFFF0000, ret |= 16;
		if (c & 0xFF00FF00)
			c &= 0xFF00FF00, ret |= 8;
		if (c & 0xF0F0F0F0)
			c &= 0xF0F0F0F0, ret |= 4;
		if (c & 0xCCCCCCCC)
			c &= 0xCCCCCCCC, ret |= 2;
		if (c & 0xAAAAAAAA)
			ret |= 1;
		return ret;
#endif
	}
	std::vector<container_type> matrix;

public:
	SparseTable(const container_type &a)
		: matrix(a.empty() ? 0 : clz32(a.size()) + 1) {
		if (!a.empty())
			matrix[0].reserve(a.size());
		for (size_type i = 0; i < a.size(); ++i)
			matrix[0].emplace_back(a[i]);
		for (size_type i = 1; i < matrix.size(); ++i) {
			const size_type msiz = a.size() + 1 - (static_cast<size_type>(1) << i);
			matrix[i].reserve(msiz);
			for (size_type j = 0; j < msiz; ++j)
				matrix[i].emplace_back(
					matrix[i - 1][j] +
					matrix[i - 1][j + (static_cast<size_type>(1) << (i - 1))]);
		}
	}
	value_type range(const size_type begin, const size_type end) const {
		assert(begin < end);
		assert(begin < size());
		assert(end <= size());
		const size_type t = clz32(end - begin);
		return matrix[t][begin] + matrix[t][end - (static_cast<size_type>(1) << t)];
	}
	size_type size() const noexcept { return empty() ? 0 : matrix[0].size(); }
	bool empty() const noexcept { return matrix.empty(); }
};
#include <algorithm>
#include <limits>
template <typename T> struct Mini {
	using value_type = T;
	T a;
	explicit Mini(const T &x = std::numeric_limits<T>::max()) : a(x) {}
	Mini operator+(const Mini &o) const { return Mini(std::min(a, o.a)); }
};
#include<iostream>
#include<vector>
int main() {
	using M = Mini<int>;
	int n, l;
	std::cin >> n >> l;
	std::vector<M> a(n);
	for (auto &x : a)std::cin >> x.a;
	SparseTable<M> T(a);
	for (int i = 0;i <= n - l;++i)
		std::cout << T.range(i, i + l).a << " \n"[i == n - l];
	return 0;
}


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

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

using namespace std;

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

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

void solve() {
  int n;
  cin >> n;
  vi32 cnt(n, 1e9);
  vi32 a(n);
  cin >> a;
  rep(i, n) a[i]--;
  auto dfs = [&](auto dfs, int u, int d) -> void {
    if (cnt[u] != 1e9) return;
    cnt[u] = d;
    dfs(dfs, a[u], d + 1);
  };
  dfs(dfs, 0, 0);
  if (cnt[1] != 1e9) {
    cout << cnt[1] << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 1024
c = [[int(i) for i in input().split()] for i in range(3)]

Sum = 0
for i in c:
    Sum += sum(i)

if Sum % 3:
    print('No')
else:
    if c[0][0]-c[0][1] != c[1][0]-c[1][1] or c[1][0]-c[1][1] != c[2][0]-c[2][1] or c[0][1]-c[0][2] != c[1][1]-c[1][2] or c[1][1]-c[1][2] != c[2][1]-c[2][2]:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 3064
import sys
from collections import deque
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
from itertools import combinations_with_replacement

def main():
    n,m=map(int,input().split())
    h=[int(i) for i in input().split()]
    t=[[] for _ in range(n)]
    for _ in range(m):
        a,b=map(int,input().split())
        t[a-1].append(h[a-1]-h[b-1])
        t[b-1].append(h[b-1]-h[a-1])
    #print(*t)
    HH=[]
    for i in t:
        try:
            HH.append(min(i))
        except:
            HH.append(1)
    #print(HH)
    ans=0
    for i in range(n):
        if HH[i]>0:
            ans+=1
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 31308
#include<bits/stdc++.h>
#define int long long 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std ;

char s;

int32_t main(){IOS;

        cin >> s ; 
        if(s == 'A') s = 'T';
        else if(s == 'T') s = 'A';
        else if(s == 'C') s = 'G';
        else if(s == 'G') s = 'C';
        cout << s << endl;
        return 0;
}


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

using namespace std;

int main()
{
  int N;
  int A,B;
  cin >> N >> A >> B;

  int x[5];
  int sum,Num;
  int ans = 0;
  for( int i = 1; i <= N; i++){
    sum = 0;
    Num = i;
    for ( int j = 4; j >= 0; j--){
      x[j] = Num/pow(10,j);
      sum += x[j];
      Num -= x[j]*pow(10,j);
    }
    if( sum >= A && sum <= B ) ans += i;
  }

  cout << ans << "\n";

  return 0;
}


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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    string S;
    cin >> S;
    vector<int64_t> cum;
    cum.push_back(0);

    char prev = S[0];
    int cnt = 0;
    for (int i = 0; i < n; i++){
        if (prev == S[i])
            cnt++;
        else{
            cum.push_back(cum[cum.size() - 1] + cnt);
            cnt = 1;
            prev = S[i];
        }
    }
    cum.push_back(cum[cum.size() - 1] + cnt);

    int64_t ans = 0;

    for (int cur = (S[0] == '1') ? 0 : 1; cur < cum.size(); cur += 2)
        ans = max(ans, cum[min(cur + 2 * k + 1, int(cum.size()) - 1)] - cum[cur]);

    if (S[0] == '0')
        ans = max(ans, cum[min(2 * k, int(cum.size()) - 1)] - cum[0]);

    cout << ans << endl;
}

Measured memory_bytes: 1528
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char s[15];
	cin>>s;
	int n=strlen(s);
	if(s[0]!='A'||s[1]=='C'||s[n-1]=='C')
	{
		cout<<"WA"<<endl;
		return 0;
	}
	int num=0,num1=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='C')
			num++;
		if(s[i]>='A'&&s[i]<='Z')
			num1++;
	}
	if(num!=1||num1!=2)
	{
		cout<<"WA"<<endl;
		return 0;
	}
	cout<<"AC"<<endl;
	return 0;	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define 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 all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  int n;
  int t,a;
  cin >> n;
  cin >> t >> a;
  int h[n];
  int num;
  double minimum = INF,tmp;
  rep(i,n){
    cin >> h[i];
    tmp = abs(a-(t-h[i]*0.006));
    if(minimum > tmp){
      minimum = tmp;
      num = i+1;
    }
  }
  cout << num;
}


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    string S;
    cin >> S;
    int ans = MOD;
    for (int i = 0; i < S.size() - 2; i++)
    {
        string tmp = S.substr(i, 3);
        int tmp2 = atoi(tmp.c_str());
        ans = min(ans, abs(tmp2 - 753));
    }
    cout << ans;
}

Measured memory_bytes: 256
import sys

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

for i in range(len(a)):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            pass
        else:
            print("DENIED")
            sys.exit(0)
print("APPROVED")



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> A(N, vector<int>(M, 0));
    REP(i, N) {
        int K;
        cin >> K;
        REP(j, K) {
            int x;
            cin >> x;
            A[i][x - 1] = 1;
        }
    }
    int ans = 0;
    REP(j, M) {
        bool ok = true;
        REP(i, N) {
            ok &= A[i][j];
        }
        if (ok) {
            ans ++;
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



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

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int s;
    cin >> s;
    
    set<int> st;
    st.insert(s);
    int pre_val = s, pre_n = 1, ans = -1;
    for (int i = 1; ; i++) {
        if (pre_val % 2 == 0) {
            st.insert(pre_val / 2);
            pre_val = pre_val / 2;
        }else{
            st.insert(pre_val * 3 + 1);
            pre_val = pre_val * 3 + 1;
        }
        if (pre_n == st.size()) {
            ans = i + 1;
            break;
        }
        pre_n = st.size();
    }
    cout << ans << endl;
}


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

int main()
{
  string S;
  cin >> S;
  int cnt['z' + 1] = {};
  for (auto & s : S)
    cnt[s] = 1;
  for (char c = 'a'; c <= 'z'; ++c)
  {
    if (0 == cnt[c])
    {
      cout << c;
      return 0;
    }
  }
  cout << "None";
  return 0;
}


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

int main() {
  int n;
  scanf("%d", &n);
  double ans = 0.0;
  for (int i = 0; i < n; i++) {
    double a;
    scanf("%lf", &a);
    ans += 1.0 / a;
  }
  ans = 1.0 / ans;
  printf("%.10lf\n", ans);
}

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

using namespace std;

#define equals(a, b) (a == b)

class Point {
    public:
        Point() = default;
        Point(double x = 0, double y = 0): x(x), y(y) {}
        Point operator + (Point p) { return Point(x + p.get_x(), y + p.get_y()); }
        Point operator - (Point p) { return Point(x - p.get_x(), y - p.get_y()); }
        Point operator * (double k) { return Point(k * x, k * y); }
        Point operator / (double k) { return Point(x / k, y / k); }
        double abs() { return sqrt(norm()); }
        double norm() { return x * x + y * y; }
        bool operator < (const Point &p) const {
            return x != p.get_x() ? x < p.get_x() : y < p.get_y();
        }
        bool operator == (const Point &p) const {
            return x == p.get_x() && y == p.get_y();
        }
        const double get_x() const { return x; }
        const double get_y() const { return y; }
    private:
        double x = 0;
        double y = 0;
};

typedef Point Vector;

double dot(Vector a, Vector b) {
    return a.get_x() * b.get_x() + a.get_y() * b.get_y();
}

double cross(Vector a, Vector b) {
    return a.get_x() * b.get_y() - a.get_y() * b.get_x();
}

struct Segment {
    Point p1;
    Point p2;
};
typedef Segment Line;

bool is_orthogonal(Vector a, Vector b) {
    return equals(dot(a, b), 0);
}

bool is_orthogonal(Point a1, Point a2, Point b1, Point b2) {
    return is_orthogonal(a1 - a2, b1 - b2);
}

bool is_orthogonal(Segment s1, Segment s2) {
    return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0);
}

bool is_parallel(Vector a, Vector b) {
    return equals(cross(a, b), 0);
}

bool is_parallel(Point a1, Point a2, Point b1, Point b2) {
    return is_parallel(a1 - a2, b1 - b2);
}

bool is_parallel(Segment s1, Segment s2) {
    return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0);
}

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / base.norm();
    return s.p1 + base * r;
}

Point reflect(Segment s, Point p) {
    return p + (project(s, p) - p) * 2.0;
}

int
main(int argc, const char *argv[])
{
    double x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    int q;
    cin >> q;
    while (q--) {
        double p0, q0;
        cin >> p0 >> q0;
        Point p{p0, q0};
        Point sp1{x0, y0}, sp2{x1, y1};
        Segment s{sp1, sp2};
        Point r = reflect(s, p);
        printf("%.10f %.10f\n", r.get_x(), r.get_y());
    }

    return 0;
}

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

const int NMAX=1000000;

int main() {
  bool p[NMAX+1];
  vector<int> pv;
  for (int i=2; i<=NMAX; i++) {
    p[i] = true;
  }
  for (int i=2; i*i<=NMAX; i++) {
    if (!p[i]) continue;
    for (int j=i+i; j<=NMAX; j+=i) {
      p[j] = false;
    }
  }
  for (int i=2; i<=NMAX; i++) {
    if (p[i]) pv.push_back(i);
  }

  int n, ans;
  while (1) {
    cin >> n;
    if (!n) break;
    ans = 0;
    for (int i=0; i<pv.size(); i++) {
      if (pv[i] > n - pv[i]) break;
      if (p[n-pv[i]]) ++ans;
    }
    cout << ans << endl;
  }

  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int ans = 100;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    
    int j = 0;
    while (j >= 0) {
      if (A % 2 == 1) {
        break;
      }
      A /= 2;
      j++;
    }
    if (ans > j) {
     ans = j;
    }
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(){
    int n; string s; cin  >> n >> s;
    ll r = 0,g = 0,b = 0;
    rep(i,n){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
    }
    ll cnt = 0;
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            if(s[i] != s[j] && s[j] != s[2*j-i]){
                if(s[i] != s[2*j-i] && 2*j -i < n) cnt++;
            }
        }
    }
    ll ans = r*g*b - cnt;
    cout << ans << endl;
    
}

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

int main() {
  int a, b;
  cin >> a; //合計
  cin >> b; //一円

  if (a*b%2 == 0){
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }

}



Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=ja
//全点対間最短経路
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}

//到達できないところは,LINFで初期化
//d[a][b] a->bのcostいれる
//ある頂点vから頂点v（それ自身)への最短距離が負になれば、Gに負の閉路が存在すると判断できる。
template< typename T >
void warshall_floyd(vector<vector<T>>& d) //nは頂点数
{
  const int n = d.size();
	for(int i = 0; i < n; i++) // 経由する頂点
		for(int j = 0; j < n; j++) // 開始頂点
			for(int k = 0; k < n; k++) // 終端
        if(d[j][i] != LINF && d[i][k] != LINF) //負辺がない場合は不要
				  d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main() {
  ll V,E; cin>>V>>E;
  vector<vector<ll>> g(V,vector<ll>(V,LINF));
  REP(i,E){
   ll a,b,c; cin>>a>>b>>c;
   g[a][b]=c; 
  }
  REP(i,V){
    g[i][i]=0;    
  }

  warshall_floyd(g);

  //ある頂点vから頂点v（それ自身)への最短距離が負になれば、Gに負の閉路が存在すると判断できる。
  REP(i,V){
    if(g[i][i]<0){
      cout<<"NEGATIVE CYCLE"<<endl;
      return 0;
    }
  }

  REP(y,V) {
    REP(x,V) {
      if(x!=0)cout<<" ";
      ll v=g[y][x];
      if(v==LINF){
        cout<<"INF";
      }else{
        cout<<g[y][x];
      }
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 3232
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int x;
    cin >> x;
    if (400 <= x && x <= 599)
        cout << 8;
    if (600 <= x && x <= 799)
        cout << 7;
    if (800 <= x && x <= 999)
        cout << 6;
    if (1000 <= x && x <= 1199)
        cout << 5;
    if (1200 <= x && x <= 1399)
        cout << 4;
    if (1400 <= x && x <= 1599)
        cout << 3;
    if (1600 <= x && x <= 1799)
        cout << 2;
    if (1800 <= x && x <= 1999)
        cout << 1;

    return 0;
}

Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()
	h, n := io.ScanInt(), io.ScanInt()
	atacks := io.ScanInts(n)
	var sum int
	for _, a := range atacks {
		sum += a
		if sum >= h {
			io.Println("Yes")
			return
		}
	}
	io.Println("No")
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 4608