akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
  int n, k, q;
  cin >> n >> k >> q;

  vi score(n,k-q);
  rep(i,q){
    int ai;
    cin >> ai;
    score.at(ai-1)++;
  }

  rep(i,n) cout << (score.at(i) > 0 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3708
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


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


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    k, n = map(int, input().strip().split())
    a = list(map(int, input().strip().split()))

    a.append(a[0]+k)
    ans = sys.maxsize
    for i in range(n):
        ans = min(k - (a[i+1] - a[i]), ans)
    print(min(ans, a[n-1] - a[0]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 28964
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

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

  int N, M;
  cin >> N >> M;
  vector<vector<int> > edge;
  for (int i = 0; i < N; i++) edge.push_back(vector<int>());
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    edge[a-1].push_back(b-1); // zero index
  }

  vector<int> longest(N, 0);
  vector<bool> visited(N, false);

  for (int i = 0; i < N; i++) {
    if (visited[i]) continue;
    stack<Pii> st;
    st.push(Pii(i, 0));
    int revCount = 0;
    while (!st.empty()) {
      Pii now = st.top();
      st.pop();
      visited[now.first] = true;
      if (now.second < edge[now.first].size()) {
        st.push(Pii(now.first, now.second+1));
        if (visited[edge[now.first][now.second]]) {
          longest[now.first] = max(longest[now.first], longest[edge[now.first][now.second]] + 1);
        }
        else {
          st.push(Pii(edge[now.first][now.second], 0));
          longest[now.first] = max(longest[now.first], revCount);
          revCount = 0;
        }
        continue;
      }
      else {
        longest[now.first] = max(longest[now.first], revCount);
        revCount = longest[now.first] + 1;
        continue;
      }
    }
  }

  cout << *max_element(longest.begin(), longest.end()) << endl;

  return 0;
}


Measured memory_bytes: 6512
// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector <ll> vec;
typedef pair <ll, ll> pr;
typedef pair <ll, pr> pr2;
typedef map <ll, vector<ll> > mv;

const int MX = 2e6+10;
const int mod = 1e9 + 7;
const ll inf = 1LL << 62;

int dx4[] = { 0, 0, -1, 1 };
int dy4[] = { 1, -1, 0, 0 };

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

// TOOLS
#define LCM(a,b)        (a / __gcd(a,b) ) *b
#define gcd(a,b)        __gcd(a,b)
#define all(x)          (x).begin(), (x).end()
#define mem(a, n)       memset(a, n, sizeof(a))
#define for1(i, n)      for(int i=1; i<=n; i++)
#define for0(i, n)      for(int i=0; i<n; i++)
#define rof0(i, n)      for(int i=n-1; i>=0; i--)
#define rof1(i, n)      for(int i=n; i>=1; i--)
#define forab(i, a, b)  for(int i=a; i<=b; i++)
#define rofab(i, a, b)  for(int i=b; i>=a; i--)
#define pb              push_back
#define pbb             pop_back

// CIN/COUT
#define sin(s)          getline(cin, s)
#define case(a)              cout << "Case "<<(a)<<": "

// SCANF/PRINTF
#define fYES            printf("YES\n")
#define fNO             printf("NO\n")
#define Scf(a)          scanf("%lld", &a)
#define Scf2(a, b)      scanf("%lld %lld", &a, &b)
#define Scf3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define Scf4(a,b,c,d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define Pnf(a)          printf("%lld\n", a)
#define Pnf2(a, b)      printf("%lld %lld\n", a, b)
#define Pnf3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define Bug(n)          printf(">> %lld <<\n", n)

// OTHERS
#define sz(n)          n.size()
#define clr(v)          v.clear()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in              freopen("input.txt", "r", stdin)
#define out             freopen("output.txt", "w", stdout)
#define FastIO          { ios_base::sync_with_stdio(false); cin.tie(0); }
#define F               first
#define S               second
#define mpp             make_pair
//End
vector<int> v;
map<ll,vector<ll> > mp;
priority_queue<ll> PQ;
//priority_queue<pair<ll,ll> >PQ;

int main()
{

    ll  n,k,q, t, cnt = 0, sum = 0,ans=10000000000000000, mx = -inf, mn = inf, a, b, c,d,e,f,g,h,i,j ,x, y, z,temp, temp1;
    string s, s1, s2, s3;
    cin>>n>>k;
    for0(i,n)
    {
        Scf(a);
        v.pb(a);
    }
    j=0;
    for(int i=k-1;i<n;i++)
    {
        if(v[j]<0)
        {
            a=fabs(v[j]);
            b=max(0,v[i]);
            sum=min(a,b);
            sum+=min(a,b)+max(a,b);
        }
        else
            sum=v[i];
        j++;
        ans=min(sum,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 892
let _ = readLine()
let an = readInts()

var current = 0
var res = 0

for a in an {
    if a < current {
        res += current - a
    } else {
        current = a
    }
}

print(res)







// MARK: ----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func tuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func tuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func tuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
    
    func safe(at index: Index) -> Element? {
        self.indices.contains(index) ? self[index] : nil
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating _read {
            if let note = dictionary[argument] {
                yield note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                yield result
            }
        }
    }
}

extension Dictionary {
    init(_ initialize: (inout Self) -> ()) {
        var dictionary = Self()
        initialize(&dictionary)
        self = dictionary
    }
}


extension Int {
    var abs: Int {
        self < .zero ? -self : self
    }
}


Measured memory_bytes: 21472
#include <stdio.h>
#include <string.h>
 
void printstr(int a, int b, char *str) {
    int length = strlen(str);
    char s[length+1];
 
    strncpy(s, str+a, b-a+1);
 
    s[b-a+1] = '\0';
 
    printf("%s\n", s);
}
 
void reversestr(int a, int b, char *str) {
    int length = strlen(str);
    char s[length + 1];
     
    strcpy(s, str);
 
    int i;
    for (i = 0; i < b - a + 1; i++) {
        str[a + i] = s[b - i];
    }
}
 
void replacestr(int a, int b, char *str, char *p) {
    int i;
    for (i = 0; i < b - a + 1; i++) {
        str[a + i] = p[i];
    }
}
 
int main(void)
{
    int a, b;
    char str[1001], command[8], p[1001];
 
    scanf("%s", str);
 
    int q;
 
    scanf("%d", &q);
 
    for (; q > 0; q--) {
        scanf("%s %d %d", command, &a, &b);
 
        if (strcmp(command, "print") == 0)
            printstr(a, b, str);
        else if (strcmp(command, "reverse") == 0)
            reversestr(a, b, str);
        else if (strcmp(command, "replace") == 0) {
            scanf("%s", p);
            replacestr(a, b, str, p);
        }
    }
 
    return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N, K; cin >> N >> K;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int h; cin >> h;
    if (h >= K) cnt++;
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long
#include <string>
#include <algorithm>
int main()
{
	string s;
	getline(cin,s);
	char a;
	cout<<s[0];
	for(int i=0;i<s.size();i++)
	{
		if(s[i]==' ')
		cout<<s[i+1];
	}
	return 0;
} 


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



int main() {
	int N, K;
	cin >> N >> K;
	vector<int> l(N);
	for(int i = 0; i < N; i++){
		cin >> l.at(i);
	}
	sort(l.begin(), l.end());
	reverse(l.begin(), l.end());
	int ans = 0;
	for(int i = 0; i < K; i++){
		ans += l.at(i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
while true
    record1 = gets.chomp
    break if record1 == "0"
    record2 = gets.chomp
    record3 = gets.chomp
    game1 = record1[1..-1] + record2[0]
    game2 = record2[1..-1] + record3[0]
    game3 = record3[1..-1] + (record3[1..-1].count("A") > record3[1..-1].count("B") ? "A" : "B")

    puts "#{game1.count("A")} #{game1.count("B")}"
    puts "#{game2.count("A")} #{game2.count("B")}"
    puts "#{game3.count("A")} #{game3.count("B")}"
end


Measured memory_bytes: 6868
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;


void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//素数かどうかを判定する関数.
int isprime(long long int n){
	if (n == 1) return 0;
    for (long long int i=2;i*i <= n;i++){
        if (n % i == 0) return 0;
    }
    return 1;
}

//nの約数を返す関数.sortされてない.
vector<long long int> divisors(long long int n){
	vector<long long int> res;
	for (long long int i = 1; i * i <= n;i++){
		if (n % i == 0){
			res.push_back(i);
			if(i * i != n){
				res.push_back(n / i);
			}
		}
	}
	return res;
}

vector<long long int> common_divisors(long long int a, long long int b){
	vector<long long int> veca = divisors(a);
	set<long long int> seta = set<long long int>(all(veca));
	vector<long long int> vecb = divisors(b);
	vector<long long int> res;
	for (int i = 0; i < vecb.size();i++)
	{
		if(seta.count(vecb[i]) == 1){
			res.push_back(vecb[i]);
		}
	}
	return res;
}

int main() {
	ll a, b;
	cin >> a >> b;
	vector<ll> cd = common_divisors(a, b);
	int ans = 0;
	rep(i, cd.size()){
		if(isprime(cd[i]))
			ans++;
	}
	cout << ans + 1 << endl;

	return 0;
}

Measured memory_bytes: 768
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N, K;
list<int>edge[5000];
list<int>can;
queue<int>box;
priority_queue<long long int, vector<long long int>, greater<long long int>>Q;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> K;
	vector<int>cost(N);
	vector<int>far(N);
	vector<int>dis(N, INT_MAX);
	dis[0] = 0;
	for (int i = 0; i < N; i++)cin >> cost[i] >> far[i];
	for (int i = 0; i < K; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	vector<int>move(N, INT_MAX);
	Q.push(0);
	while (!Q.empty()) {
		int current = Q.top() % MOD;
		int dist = Q.top() / MOD;
		box.push(current);
		for (int i = 0; i < N; i++)move[i] = INT_MAX;
		move[current] = 0;
		while (!box.empty()) {
			for (auto j : edge[box.front()]) {
				if (move[j] > move[box.front()] + 1) {
					move[j] = move[box.front()] + 1;
					box.push(j);
				}
			}
			box.pop();
		}
		for (int j = 0; j < N; j++) {
			if (move[j] && move[j] <= far[current])can.push_back(j);
		}
		for (auto i : can) {
			if (dis[i] > dist + cost[current]) {
				dis[i] = dist + cost[current];
				Q.push(dis[i] * MOD + i);
			}
		}
		can.clear();
		Q.pop();
	}
	cout << dis[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 4084
#include <iostream>
using namespace std;
typedef long long ll;
int N, K;
int A[200100];

bool ok(int x) {
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        cnt += (A[i] - 1) / x;
    }
    if (cnt <= K) return true;
    return false; 
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> A[i];
    
    int l = 0, r = 1000000000;
    while (r - l > 1) {
        int m = (l +  r) / 2;
        if (ok(m)) r = m;
        else l = m;
    } 
    cout << r << endl;
}

Measured memory_bytes: 4388
import scala.io.StdIn.readLine
import scala.io.StdIn.readInt

object Main {
  def main(args: Array[String]): Unit = {
    (1 to readInt()).foreach(_ => {
      val t = readLine().split(" ").map(x => x.toInt)
      val ans = t.permutations.exists(a => a(0) * a(0) + a(1) * a(1) == a(2) * a(2))
      println(if (ans) "YES" else "NO")
    })
  }
}

Measured memory_bytes: 48528
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    vector<int> b(n);
    int m;
    if(n%2==0)m = n/2;
    else m = n/2;
    rep(i,n){
        if(i%2==0)b[m+i/2] = a[i];
        else b[m-i/2-1] = a[i];
    }
    if(n % 2 == 1)reverse(all(b));
    rep(i,n){
        if(i!=n-1)cout << b[i] << " ";
        else cout << b[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#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 debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;

//=============================
void input()
{
    cin>>N;

}
//=============================
void func(){}
//=============================
void solve()
{
    deque<int> q;



    int r = 1;
    vector<int> a;
    while (N) {
        debug(N);
        int k = abs(N)%(2);
        q.push_front( k);
        a.push_back(k);
        N = (N>0) ? (-N/2) : ((-(N-1)/2));
    }


    if (q.empty()){
        cout<<0;
    }else
    while(!q.empty()) {
        cout<<q.front();
        q.pop_front();
    }
    cout<<endl;


}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

int main(){
	string s;
	int idx, idx_start, count_change = 0;
	
	cin >> s;
	
	// 回文判定の開始位置を決定
	idx_start = s.length()/2;
	
	// 現在位置と対を成す位置の文字を比較し，異なる場合のみcountを追加
	for(idx=idx_start;idx>0;idx--){
//		cout << idx << endl;
//		cout << s[idx-1] << " and " << s[s.length()-idx] << endl;
		if(s[idx-1] != s[s.length()+1-idx-1]){
			count_change++;
		}
	}
	
	cout << count_change;
	
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {

    val input1 = readLine()!!

    // N
    val numberOfQuestions = input1.split(" ")[0].toInt()
    // M
    val numberOfSubmit = input1.split(" ")[1].toInt()

    val submits = mutableListOf<Submit>()

    for (i in 1..numberOfSubmit) {
        val input2 = readLine()!!
        submits.add(
            Submit(
                input2.split(" ")[0].toInt(),
                input2.split(" ")[1]
            )
        )
    }

    var correctNum = 0
    var penaltyNum = 0

    var resultsPerQuestion: Collection<List<String>> = submits
        .groupBy({ it.questionId }, { it.result })
        .values

    for (entry: List<String> in resultsPerQuestion) {
        for ((index, value) in entry.withIndex()) {
            if (value == "AC") {
                correctNum++
                penaltyNum += index
                break
            }
        }
    }

    println("$correctNum $penaltyNum")
}

data class Submit(
    val questionId: Int,
    val result: String
)

Measured memory_bytes: 87368
import sys
input = sys.stdin.readline
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] > self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.par[x] = y
            self.size[y] += self.size[x]

    def same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]


n,m,k=map(int,input().split())
tomo=[[] for _ in range(n)]
blo=[[] for _ in range(n)]
tomouf=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    tomo[a].append(b)
    tomo[b].append(a)
    tomouf.union(a,b)
for i in range(k):
    a,b=map(int,input().split())
    a-=1
    b-=1
    blo[a].append(b)
    blo[b].append(a)
aans=[]
for i in range(n):
    ans=tomouf.get_size(i)
    for j in tomo[i]:
        if tomouf.same(i,j):
            ans-=1
    for j in blo[i]:
        if tomouf.same(i,j):
            ans-=1
    aans.append(ans-1)
print(*aans)


Measured memory_bytes: 124124
from operator import itemgetter

N = int(input())
# table = [[i for i in input().split()] for j in range(N)]
table = []
for i in range(N):
    value = list(input().split())
    value[1] = int(value[1])
    value.append(str(i + 1))
    table.append(value)

point_sort = sorted(table, key=itemgetter(1), reverse=True)
alphabet_sort = sorted(point_sort, key=itemgetter(0))

for i in alphabet_sort:
    print(i[2])


Measured memory_bytes: 3060
N = int(input())
Ss = input()

def getZArray(Ss):
    lenS = len(Ss)
    As = [lenS] * lenS
    i, j = 1, 0
    while i < lenS:
        while i+j < lenS and Ss[j] == Ss[i+j]:
            j += 1
        As[i] = j
        if j == 0:
            i += 1
        else:
            k = 1
            while i+k < lenS and k+As[k] < j:
                As[i+k] = As[k]
                k += 1
            i += k
            j -= k
    return As

ans = 0
for i in range(N):
    ZArray = getZArray(Ss[i:])
    for i, Z in enumerate(ZArray):
        L = min(Z, i)
        ans = max(ans, L)

print(ans)


Measured memory_bytes: 50780
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<boost/date_time/gregorian/gregorian.hpp>

using namespace std;

int main(){
  int y1, m1, d1, y2, m2, d2;
  while(scanf("%d%d%d%d%d%d",
              &y1, &m1, &d1,
              &y2, &m2, &d2), y1 != -1){
    boost::gregorian::date day1(y1, m1, d1);
    boost::gregorian::date day2(y2, m2, d2);
    printf("%d\n", (int)abs((day1 - day2).days()));
  }
  return 0;
}

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

int main(){
  ull x, y;
  cin >> x >> y;
  ull ans=0;
  while(x <= y){
    ans++;
    x*=2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res
 
N,A,B = map(int,input().split())
if (N == 2):
    print(0)
else:
    print((2**N - 1 - combination(N, A) - combination(N, B)) % (10**9+7))

Measured memory_bytes: 282776
#include <stdio.h> 
int main(void) {
  int i, prime[90000], j, n;
  for(i = 0; i < 90000; ++i) prime[i] = 1;
  for(i = 2; i < 300; ++i) if(prime[i]) {
    for(j = 2; i * j < 90000; ++j) prime[i * j] = 0;
  }
  while(scanf("%d", &n) != EOF) {
    for(i = n - 1; i >= 2; --i) {
      if(prime[i]) {
        printf("%d ", i);
        break;
      }
    }
    for(i = n + 1; i < 90000; ++i) {
      if(prime[i]) {
        printf("%d\n", i);
        break;
      }
    }
  }
  return 0; 
} 


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

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

	int ans = -1;
	for (int i = 1; i <= 1000; i++) {

		int x = i*0.08;
		int y = i*0.1;
		if (x == a && y == b) {
			ans = i;
			break;
		}

	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back

int main(){
    int H, W;
    cin >> H >> W;

    bool S[H][W];
    int num[H][W];

    char ch;
    // 入力＋横方向の個数
    for (int hi = 0; hi < H; hi++){

        int start = 0;
        int count = 0;
        for(int wi = 0; wi < W; wi++){
            num[hi][wi] = 0;
            cin >> ch;
            if(ch == '#'){
                S[hi][wi] = false;
                for(int i = start; i < wi; i++){
                    num[hi][i] = count;
                }
                count = 0;
                start = wi + 1;
            }
            else
            {
                S[hi][wi] = true;
                count++;
            }
        }
        for (int i = start; i < W; i++)
        {
            num[hi][i] = count;
        }
    }

    int max = 0;
    // 縦方向の個数 + 最大値を求める
    for (int wi = 0; wi < W; wi++)
    {

        int start = 0;
        int count = 0;
        for (int hi = 0; hi < H; hi++)
        {
            if (S[hi][wi] == false)
            {
                for (int i = start; i < hi; i++)
                {
                    num[i][wi] += count;
                    if (max < num[i][wi])
                    {
                        max = num[i][wi];
                    }
                }
                count = 0;
                start = hi + 1;
            }
            else
            {
                count++;
            }
        }

        for (int i = start; i < H; i++)
        {
            num[i][wi] += count;
            if (max < num[i][wi])
            {
                max = num[i][wi];
            }
        }
    }

    cout << max - 1 << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int n, m;
  cin >> n >> m;
  int h[n];
  rep(i, n) cin >> h[i];

  vector<int> to[n];
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  int ans = 0;
  rep(i, n){
    int mx = h[i];
    bool ok = true;
    for(auto v: to[i]){
      if(mx <= h[v]) ok = false;
    }
    if(ok) ++ans;
  }

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


Measured memory_bytes: 9096
import Data.Array 
import Control.Monad
import Control.Applicative

main = do
    [width, height] <- map read . words <$> getLine :: IO [Int]
    when (width/=0 || height/=0) $ do
        solve width height
        main

solve width height = do
    n <- read <$> getLine :: IO Int
    ngL <- replicateM n ((\[x,y]->(x,y)) . map read . words <$> getLine) :: IO [(Int, Int)]
    let ng = array ((1,1),(width,height)) 
             $ [((x,y), True)|x<-[1..width], y<-[1..height]] 
            ++ [((x,y), False)|(x,y)<-ngL] 
    print $ dp ng

dp ng = memo!(w,h) where
    (_, (w,h)) = bounds ng
    memo = array ((1,1), (w,h)) [((x,y), f x y)|y<-[1..h], x<-[1..w]]
    f 1 1 = 1
    f 1 y = if ng!(1,y) then memo!(1,y-1)                else 0
    f x 1 = if ng!(x,1) then memo!(x-1,1)                else 0
    f x y = if ng!(x,y) then memo!(x-1,y) + memo!(x,y-1) else 0



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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n,q;
    cin >> n >> q;
    if(!n&&!q) return 0;
    vector<int> conv;
    conv.assign(128,0);
    REP(i,n){
      int m;
      cin >> m;
      REP(j,m){
	int tmp;
	cin >> tmp;
	conv[tmp]++;
      }
    }
    REP(i,128) q=max(q,conv[i]);
    int answer=0;
    REP(i,128) if(q==conv[i]){
      answer=i;
      break;
    }
    cout << answer << endl;
  }
}

Measured memory_bytes: 1192
from math import sqrt, ceil
def solve():
    n = int(input())
    keta = [0] * (n+1)
    for i in range(2, n+1):
        for j in range(2, int(pow(i, 0.5))+1):
            while i % j == 0:
                i //= j
                keta[j] += 1
        keta[i] += 1

    mod = 1000000007
    ans = 1
    keta[0] = 0
    keta[1] = 0
    for ex in keta:
        ans *= (ex + 1)
        ans %= mod
    print(ans)

if __name__ == '__main__':
    solve()

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  string s,t;
  cin >> s >> t;
  ANS(t + s);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back

using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here
void solve(ll a, ll b){
    if (a * b <= 0) {
        cout << "Zero\n";
    } else if (a > 0 || (b - a) % 2) {
        cout << "Positive\n";
    } else {
        cout << "Negative\n";
    }
}

int main() {
    ll a;
    ignore_ret(scanf("%lld",&a));
    ll b;
    ignore_ret(scanf("%lld",&b));
    solve(a, b);
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<list>
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define ll rt<<1
#define rr rt<<1|1
#define mid int m=(x+((y-x)>>1))
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
#define lowbit(x) (x&-x)
#define PB push_back
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define fi freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9;

int a[N];
int num1, num2, num4;
int main()
{
#ifndef ONLINE_JUDGE

#endif

    int n;
    SC(n);
    FF(i, 1, n) SC(a[i]);
    ///
    FF(i, 1, n)
    {
        if(a[i] % 2 == 0 && a[i]%4) ++num2;
        else if(a[i] % 4 == 0) ++num4;
        else if(a[i] % 4 && a[i] % 2) ++num1;
    }
    if(num2) ++num1;

    ///
    if(num4+1 >= num1) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("trapv")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	vector< string > ss(n);
	map< vector<ll>, ll> mp1;
	for (auto& e:ss) {
		vector<ll> freq(26);
		cin >> e;
		for(auto& f:e) {
			freq[(f-'a')]++;
		}
		mp1[freq]++;
	}
	ll ans = 0;
	for(auto& e:mp1) {
		if (e.second > 1) {
			ll v = e.second;
			ans += (v*(v-1))/2;
		}
	}
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 35884
from operator import itemgetter
from collections import defaultdict
from scipy.sparse.csgraph import minimum_spanning_tree
from scipy.sparse import csr_matrix

n = int(input())
xy = [list(map(int, input().split())) + [i] for i in range(n)]
INF = 10 ** 9 + 1

d = defaultdict(lambda: INF)

for key in (itemgetter(0), itemgetter(1)):
    xy.sort(key=key)
    for (x1, y1, i1), (x2, y2, i2) in zip(xy, xy[1:]):
        c = min(abs(x1 - x2), abs(y1 - y2))
        d[(i1, i2)] = min(d[(i1, i2)], c)

row = []
col = []
cost = []
for (k1, k2), c in d.items():
    row.append(k1)
    col.append(k2)
    cost.append(c)

graph = csr_matrix((cost, (row, col)), shape=(n, n))
mst = minimum_spanning_tree(graph, overwrite=True).astype(int)
ans = mst.sum()
print(ans)


Measured memory_bytes: 78780
#include <cstdio>
#include <algorithm>
#include <functional>

#define MAX 100000

int main()
{
	int N, M, ans, L[MAX], R[MAX];
	scanf("%d %d", &N, &M);
	for(int i=0; i<M; i++){
		scanf("%d %d", &L[i], &R[i]);
	}
	std::sort(L, L+M, std::greater<int>());
	// if(L[0] == N){
	// 	printf("1\n");
	// 	return 0;
	if(L[0]<=R[0]){
		std::sort(R, R+M);
		ans = R[0]-L[0]+1;
	}
	else{
		ans = 0;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define SQR(X)  ( (X)*(X) )
#define CUBE(X) ( (X)*(X)*(X) )
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;
 
 
void reader(int &a){scanf("%d",&a);}
void reader(double &a){scanf("%lf",&a);}
void reader(char a[]){scanf("%s",a);}
void reader(ll &a){scanf("%lld",&a);}
void reader(ull &a){scanf("%llu",&a);}
// void reader(string& a){cin >> a;};
template<class T,class U> void reader(T& t,U& u){reader(t); reader(u);}
template<class T,class U,class V> void reader(T& t,U& u,V& v){reader(t); reader(u); reader(v);}
 
void writer(int a,char c) {printf("%d",a); putchar(c);}
void writer(ll a,char c) {printf("%lld",a); putchar(c);}
void writer(double a,char c) {printf("%.20lf",a); putchar(c);}
void writer(char a[]) {printf("%s",a);};
void writer(char a[],char c) {printf("%s",a);putchar(c);};
void writer(char a,char c) {putchar(a); putchar(c);};
template<class T>void writerLn(T t){writer(t,'\n');}
template<class T,class U>void writerLn(T t,U u){writer(t,' ');writer(u,'\n');}
template<class T,class U,class V> void writerLn(T t,U u,V v){writer(t,' ');writer(u,' ');writer(v,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){putchar('\n');return;}rep(i,n-1) writer(x[i],' ');writer(x[n-1],'\n');}
template<class T> void writerVec(vector<T> x){int n=x.size();int i;if(!n){putchar('\n');return;}rep(i,n-1) writer(x[i],' ');writer(x[n-1],'\n');}
 

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
// #define int ll
 
bool test = 1;

//............................
#define MAX 300000
signed main(){
  int i,j,k,l;
  int n;
  cin >> n;
  rep(loop,n) {
	int y,m,d;
	cin >> y >> m >> d;
	int cnt = 0;
	while(y != 1000) {
	  ++cnt;
	  ++d;
	  if(y % 3 == 0 || m % 2 == 1) {
		if(d > 20) {
		  d = 1;
		  ++m;
		}
	  } 
	  else{
		if(d > 19) {
		  d = 1;
		  ++m;
		}
	  }
	  if(m > 10) {
		m = 1;
		++y;
	  }
	}
	cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
from random import *
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(d)]
for i in range(d):
    cand=0
    for j in range(26):
        if s[i][cand]<s[i][j]:
            cand=j
    print(randrange(1,26))

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

int main () {
    int n;
    ll sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                sum+=__gcd(__gcd(i,j),k);
            }
        }
    }
    cout<<sum;
}

Measured memory_bytes: 3620
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;

class BrickBreak
{
    static void Main(string[] args)
    {
        var number = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(' ');
        var ans = 0;
        int count = 0;
   

        int check = 1;

        var c = Array.IndexOf(input, "1");

        if(c == -1)
        {
            ans = -1;
            Console.WriteLine(ans);
            return;
        }

        for(var i = 0; i < number; i++)
        {
            if(check == int.Parse(input[i])){
                check++;
            }
            else
            {
                count++;
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 32476
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(unknown_lints)]
#![allow(unused_variables)]
#![allow(unused_must_use)]
#![allow(unused_mut)]
#![allow(dead_code)]
#![allow(unused_assignments)]

use std::collections::HashMap;
use std::io::{stderr, Write};
use std::process::exit;

macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        //let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn csvec_new(src: Vec<char>) -> Vec<i32> {
    let mut cs: Vec<i32> = vec![0];
    cs.push(0);
    debug!(cs);
    let len = src.len();
    let mut new = 0;
    for i in 1..len {
        if src[i-1] == 'A' && src[i] == 'C' {
            new = new + 1;
        }
        cs.push(new);
        debug!(src[i-1]);
        debug!(src[i]);
        debug!(cs);
    }
    cs
}

fn main() {
    input!{
        n: usize,
        q: usize,
        s: String,
        lr: [(usize, usize); q]
    } debug!(n);
    debug!(q);
    debug!(s);
    debug!(lr);
    let s: Vec<char> = s.chars().collect();
    let cs = csvec_new(s);
    debug!(cs);
    let stdout_ = std::io::stdout();
    //let mut stdout = std::io::BufWriter::new(stdout_.lock());
    let mut stdout = std::io::BufWriter::new(stdout_);
    for i in 0..q {
        debug!(i);
        let (l, r) = lr[i];
        debug!(l);
        debug!(r);
        let res = cs[r] - cs[l];
        //println!("{}", res);
        writeln!(stdout, "{}", res).unwrap();
    }
}

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

int main() {
	int N;
	cin >> N;
	vector<P> xy(N);
	rep(i, N) cin >> xy[i].first >> xy[i].second;

	double sum = 0;
	rep(i, N) {
		rep(j, N) {
			if(i == j) continue;
			sum += sqrt(pow(xy[i].first - xy[j].first, 2) + pow(xy[i].second - xy[j].second, 2));
		}
	}

	double avg = sum / (double)N;
	cout << fixed << setprecision(10);
	cout << avg << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using   namespace  std;
typedef  long long  ll;
typedef pair<ll,ll>pll;
typedef    double   db;

#define fi  first
#define se second
#define endl "\n"
#define pb(x)       push_back(x)
#define mp(a,b)  make_pair(a,b);
#define sz(a)  ((int)(a).size())
#define all(x) x.begin(),x.end()

#define ff(i,a,b) for(ll i=a;i<=b;++i)

#define de(a) cout << #a << " = " << a << endl;
#define dd(a) cout << #a << " = " << a << "  ";

#define mem(a,b)   memset(a,b,sizeof(a))
#define file freopen("in.txt","r",stdin)
#define jkl ios::sync_with_stdio(false);cin.tie(0);
#define list list2

const ll INF     =    0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;
const ll MOD     =   1e9+7;
const double eps =    1e-8;
const double PI=acos(-1.0);
/*************************************************/
int main() {
	int  a,b,c;
	cin >>  a >> b >> c;
	if(c>=a-b) cout << c-a+b;
	else cout << 0;
}


Measured memory_bytes: 256
s = input()+"_"
cnt = 0
ans = 0
for i in range(len(s)):
    if s[i] == "A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
        cnt+=1
    else:
        ans = max(ans, cnt)
        cnt = 0

print(ans)
        

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

// 1-indexedで考える
// 左から奇数番目の列は、(W+1)/2個
// 左から偶数番目の列は、W/2個
// 奇数番目の列で動けるマスは、(H+1)/2個
// 偶数番目の列で動けるマスは、H/2個
// よって、全てで(W+1)/2*(H+1)/2 + W/2*H/2
// 片方の長さが1だと、もう片方がどれだけ長くても答えが0になるコーナーケースがあった

int main()
{
    ll H, W;
    cin >> H >> W;
    if(H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }
    ll ans = ((W+1)/2)*((H+1)/2) + (W/2)*(H/2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int date[101][101];
	int i, j, x, y, goukei = 0;
	
	scanf("%d %d",&y,&x);
	
	for(i = 0; i < y; ++i){
		for(j = 0; j < x; ++j){
			
			scanf("%d",&date[i][j]);
		}
	}
	
	for(i = 0; i < y; ++i){
		for(j = 0; j < x; ++j){
			
			goukei += date[i][j];
		}
		
		date[i][x] = goukei;
		goukei = 0;
	}
	
	for(i = 0; i <= x; ++i){
		for(j = 0; j < y; ++j){
			
			goukei += date[j][i];
		}
		
		date[y][i] = goukei;
		goukei = 0;
	}
	
	for(i = 0; i <= y; ++i){
		for(j = 0; j <= x; ++j){
			
			if(j == 0){
				printf("%d",date[i][j]);
			}
			
			else{
				printf(" %d",date[i][j]);
			}
		}
		
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 640
#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>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    cin >> n;
    vector<ll> v;
    for(int i = 0; i < 3 * n; i++){
        ll in;
        cin >> in;
        v.push_back(in);
    }
    sort(v.begin(), v.end(), greater<ll>());
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ans += v[2 * i - 1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6000
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  std::string S; std::cin >> S;
  std::sort(S.begin(), S.end());
  if ( S == "abc" ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}


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

int main() {
  int x,y;
  cin >> x >> y;
  while (x != 0 || y != 0) {
    if (x < y) {
      cout << x << " " << y << endl;
    } else {
      cout << y << " " << x << endl;
    }
    cin >> x >> y;
  }
}



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

int A[200000];

void Main()
{
  int K, N;
  cin >> K >> N;
  rep(i,N) {cin >> A[i];}
  int min1 = K;
  //int min2 = K;
  for (int i=1; i < N-1; i++) {
    min1 = min(min1, (K-A[i]) + A[i-1]);
    min1 = min(min1, A[i] + (K - A[i+1]));
  }
  min1 = min(min1, A[N-1]-A[0]);
  //min1 = min(min1, A[0] + (K-A[N-1]));
  if (N>2) min1 = min(min1, (K-A[N-1]) + A[N-2]);
  
  cout << min1 << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 1024
def JudgeStatusSummary():

    num = int(input())

    list_result = []

    for n in range(num):
        result = str(input())
    
        list_result.append(result)
    
    print('AC x ', list_result.count('AC'))
    print('WA x ', list_result.count('WA'))
    print('TLE x ', list_result.count('TLE'))
    print('RE x ', list_result.count('RE'))


if __name__ == '__main__':
    JudgeStatusSummary()


Measured memory_bytes: 16212
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int n, sum, m, p, x;
int arr[105];

int main(){
    ios::sync_with_stdio(0);
    cin >> n;
    sum = 0;
    forn(i,n){
        cin >> arr[i];
        sum += arr[i];
    }
    cin >> m;
    forn(i,m){
        cin >> p >> x;
        p--;
        sum -= arr[p];
        sum += x;
        cout << sum << "\n";
        sum -= x;
        sum += arr[p];
    }
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto X = s[1] - 1;
    auto Y = s[2] - 1;

    auto D = new int[][](N, N);
    foreach (i; 0..N) foreach (j; 0..N) D[i][j] = abs(i - j);
    D[X][Y] = D[Y][X] = 1;

    foreach (i; 0..N) foreach (j; 0..N) D[i][j] = min(D[i][j], abs(i - X) + 1 + abs(j - Y));
    foreach (i; 0..N) foreach (j; 0..N) D[i][j] = min(D[i][j], abs(i - Y) + 1 + abs(j - X));

    auto ans = new int[](N+1);
    foreach (i; 0..N) foreach (j; i+1..N) ans[D[i][j]] += 1;

    ans[1..N].each!writeln;
}

Measured memory_bytes: 18172