akhauriyash/Code-Regression huggingface dataset:
import sys
from heapq import heappush, heappop

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    B = [[] for _ in range(m)]
    for _ in range(n):
        a, b = map(int, input().split())
        if m - a >= 0:
            B[m - a].append(b)

    que = []
    res = 0
    for i in reversed(range(m)):
        for b in B[i]:
            heappush(que, -b)
        if que:
            res += heappop(que) * (-1)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 24204
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

void f(vll &data, int n, ll num) {
    data.push_back(num);
    if (n == 10) {
        return;
    }
    for (ll i = -1; i <= 1; i++) {
        ll add = (num % 10) + i;
        if (add >= 0 && add <= 9) {
            f(data, n + 1, num * 10 + add);
        }
    }
}

int main() {
    int K;
    cin >> K;
    vll data;
    for (ll i = 1; i < 10; i++) {
        f(data, 1, i);
    }
    sort(data.begin(), data.end());
    cout << data[K - 1] << endl;
}


Measured memory_bytes: 5372
#include<iostream>
#include<cstring>
using namespace std;
int main() {
	int sum = 1;
	int  s[7] = { 0,1,2,3,4,5,6 };
	int a;
	char str[101];
	while (1) {
		sum = 1;
		cin >> a;
		if (a == 0)return 0;
		for (int i = 1; i <= a; i++) {
			cin >> str;
			if (str[0] == 'N') {
				int temp = s[1];
				s[1] = s[2];
				s[2] = s[6];
				s[6] = s[5];
				s[5] = temp;
				sum += s[1];
			}
			else if (str[0] == 'E') {
				int temp = s[1];
				s[1] = s[4];
				s[4] = s[6];
				s[6] = s[3];
				s[3] = temp;
				sum += s[1];
			}
			else if (str[0] == 'W') {
				int temp = s[1];
				s[1] = s[3];
				s[3] = s[6];
				s[6] = s[4];
				s[4] = temp;
				sum += s[1];
			}
			else if (str[0] == 'S') {
				int temp = s[5];
				s[5] = s[6];
				s[6] = s[2];
				s[2] = s[1];
				s[1] = temp;
				sum += s[1];
			}
			else if (str[0] == 'R') {
				int temp = s[2];
				s[2] = s[3];
				s[3] = s[5];
				s[5] = s[4];
				s[4] = temp;
				sum += s[1];
			}
			else if (str[0] == 'L') {
				int temp = s[2];
				s[2] = s[4];
				s[4] = s[5];
				s[5] = s[3];
				s[3] = temp;
				sum += s[1];
			}
		}

		cout << sum << endl;
		for (int i = 0; i < 8; i++) {
			s[i] = i;
		}
	}
	return 0;
}

Measured memory_bytes: 2980
#include <bits/stdc++.h>
#define ll long long 
#define INF 1e9
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
	IOS;
	int n;
	cin>>n;
	vector<ll> v(n);
	for(int i=0;i<n;i++)
	cin>>v[i];
	sort(v.begin(),v.end(), greater<int>());
ll comfort=0;
	vector<ll> b;
	for(int i=0;i<n;i++)
	{
		b.push_back(v[i]);
		if(i!=0)
		b.push_back(v[i]);
		
	}
	
	for(int i=0;i<n-1;i++)
	comfort+=b[i];
	
	
	
	cout<<comfort<<endl;
	}

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

int main(){
    int n,a,b,c;
    double d;
    cin>>n;
    a=n/2;
    b=n%2;
    c=a+b;
    d=double(c)/n;
    cout<<setprecision(10)<<d<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  string s;
  cin >> s;
  int n = sz(s);

  bool ok = true;
  string sr = s;
  reverse(rng(sr));
  if (s != sr) ok = false;

  string s1 = s.substr(0,(n-1)/2);
  string sr1 = s1;
  reverse(rng(sr1));
  if (s1 != sr1) ok = false;

  string s2 = s.substr(((n-1)+3)/2,(n-1)/2);
  string sr2 = s2;
  reverse(rng(sr2));
  if (s2 != sr2) ok = false;

  if (ok) yn;
  return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n = int(input())
ord_a = ord("a")
ans = []
def dfs(s,k):
    if n == len(s):
        ans.append(s)
        return
    for i in range(k+1):
        dfs(s+chr(ord_a + i), k if i!=k else k+1)

dfs("a", 1)

ans.sort()
print("\n".join(ans))

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

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

const int inf=1e9;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,M,X,Y,x,y,xmax=-inf, ymin=inf; cin>>N>>M>>X>>Y;
	for (int i=0; i<N; i++)
		cin>>x, xmax=max(xmax,x);
	for (int i=0; i<M; i++)
		cin>>y, ymin=min(ymin,y);
	for (int Z=X+1; Z<=Y; Z++)
		if(xmax<Z&&Z<=ymin) {
			cout << "No War" << endl;
			return 0;
		}
	cout << "War" << endl;
	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
 
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
    
  int A, B;
  vector<int> c(N);
  for (int j = 0; j < M; j++) {
    cin >> A >> B;
    if (H.at(A-1) > H.at(B-1) && c.at(A-1) != 2) {
      c.at(A-1) = 1;
      c.at(B-1) = 2;
    }
    else if (H.at(A-1) < H.at(B-1) && c.at(B-1) != 2) {
      c.at(A-1) = 2;
      c.at(B-1) = 1;
    }
    else {
      c.at(A-1) = 2;
      c.at(B-1) = 2;
    }
  }
  
  int cnt;
  for (int k = 0; k < N; k++) {
    if (c.at(k) != 2) cnt++;
  }
  
  cout << cnt << endl;
}

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

using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;

    int count=0;

    for( int i=0;i<s.length();i++){
        if(s[i]!=t[i]) count++;
    }


    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 3824
#include<stdio.h>

int main(){
	int A, B, C, X;
	scanf("%d %d %d %d", &A, &B, &C, &X);
	
	int i, j, k, count=0;
	for(i=0; i<=A; i++){
		for(j=0; j<=B; j++){
			for(k=0; k<=C; k++){
				if(500*i + 100*j + 50*k == X)	count++;
			}
		}
	}
	
	printf("%d\n", count);
	
	return 0;
}


Measured memory_bytes: 128
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn dfs(s: usize, k: usize, nine: bool, n: &Vec<char>) -> usize {
    let mut s = s;
    if nine {
        s += 9;
    } else {
        s += (n[k] as usize) - 48;
    }
    if k == n.len() - 1 {
        return s;
    }

    if !nine {
        std::cmp::max(dfs(s, k+1, false, n), dfs(s-1, k+1, true, n))
    } else {
        std::cmp::max(dfs(s, k+1, true, n), dfs(s-1, k+1, true, n))
    }
}

fn main() {
    let n = read1::<String>().chars().collect::<Vec<char>>();
    println!("{}", dfs(0, 0, false, &n));    
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#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(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    int r=x%y;
    x=y;
    y=r;
    if(y==0) return x;
    else return gcd(x,y); 
}

int main()
{
    int n,x;
    cin>>n>>x;
    vector<int> p(n),d(n);
    REP(i,n) cin>>p[i];

    p.push_back(x);
    sort(ALL(p));
    REP(i,n) d[i]=p[i+1]-p[i];

    sort(ALL(d));
    int minv=INF;
    if(n==1){
        cout<<d[0]<<endl;
        return 0;
    }
    REP(i,n-1) minv=min(minv,gcd(d[0],d[i+1]));

    cout<<minv<<endl;
    
	return 0; 
}

Measured memory_bytes: 1408
N,X,Y = map(int,input().split())
A = [0]*(N-1)
mi = 0
for i in range(1,N+1):
  for j in range(1,N+1):
    if i < j :
      mi = min(j-i,(abs(X-i)+abs(Y-j)+1))
      A[mi-1] += 1
for i in range(N-1):
  print(A[i])
    

Measured memory_bytes: 3444
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    ans=0
    for i in range(1,n):
        for k in range(i+1,n):
            for j in range(k+1,n+1):
                if i+k+j==x:
                    ans+=1
    print(ans)


Measured memory_bytes: 5592
from math import log
from functools import reduce
N = int(input())
A = sorted(list(map(int, input().split())))
if A[0] == 0:
  print(0)
else:
  ans = 1
  for a in reversed(A):
    ans *= a
    if ans > 10**18:
      ans = -1
      break
  print(ans)


Measured memory_bytes: 84300
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

int N, M, K, H, W, L, R;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

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

	cin >> N >> M;
	while(N){
	    vector<vector<int>>edge(N);
	vector<int>depth(N,MOD);
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		L--;
		R--;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	Calculate_Depth(edge, depth, 0);
	int ans = -1;
	for (auto i : depth) {
		ans += i < 3;
	}
	cout << ans << endl;
	cin>>N>>M;
	}
	return 0;
}


Measured memory_bytes: 3208
package main

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

func main() {
	S := nextString()
	m := map[rune]bool{}
	for _, s := range S {
		if m[s] {
			fmt.Println("no")
			return
		}
		m[s] = true
	}
	fmt.Println("yes")
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
program green_bin
  implicit none
  integer :: n, i, j
  character(10) :: s(100001) = ""
  integer(8) :: ans = 0_8, m
  read(*,*) n
  do i = 1, n
    read(*,*) s(i)
    call bubble_sort(s(i))
  end do
  call quick_sort(s(1:n))
  i = 1
  do while (i <= n)
    j = i
    do
      if (s(i) /= s(j)) then
        m = int(j-i,8)
        ans = ans+m*(m-1_8)/2_8
        i = j
        exit
      end if
      j = j+1
    end do
  end do
  write(*,'(i0)') ans
contains
  subroutine bubble_sort(s)
    character(*) :: s
    character(1) :: t
    integer :: i, j, n
    n = len_trim(s)
    do i = 1, n-1
      do j = 2, n-i+1
        if (s(j-1:j-1) > s(j:j)) then
          t = s(j-1:j-1)
          s(j-1:j-1) = s(j:j)
          s(j:j) = t
        end if
      end do
    end do
  end
  recursive subroutine quick_sort(a)
    character(*), intent(inout) :: a(:)
    character(10) :: p, c
    integer :: n, l, r
    n = size(a)
    l = 1
    r = n
    p = a((l+r)/2)
    do
      do while (a(l) < p)
        l = l+1
      end do
      do while (a(r) > p)
        r = r-1
      end do
      if (l >= r) exit
      c = a(l)
      a(l) = a(r)
      a(r) = c
      l = l+1
      r = r-1
    end do
    if (l > 2) call quick_sort(a(1:l-1))
    if (n > r+1) call quick_sort(a(r+1:n))
  end
end program green_bin

Measured memory_bytes: 1152
#include	<stdio.h>
int	main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a<b){
		printf("a < b\n");

	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	return	0;
}

Measured memory_bytes: 580
import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()
ans = 0
for i in range(N):
    a_cnt = bisect.bisect_left(A, B[i])
    c_cnt = N-bisect.bisect_right(C, B[i])
    ans += a_cnt*c_cnt
print(ans)


Measured memory_bytes: 23232
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  if (x < 1200){
    cout << "ABC" << endl;
  }else{
    cout << "ARC" << endl;
  }

}


Measured memory_bytes: 256
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
typedef long long LL;
typedef unsigned long long ULL;

string s;

int main() {
	cin >> s;
	int flg = 0;
	REP(i, 0, s.size()) {
		if (flg == 0 && s[i] == 'C') {
			flg++;
		} else if (flg == 1 && s[i] == 'F') {
			flg++;
		}
	}
	cout << (flg == 2 ? "Yes" : "No") << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

ll wazu = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (wazu - inv(wazu % x) * (wazu / x)) % wazu;
        if (a >= 0) { return a; }
        else { return wazu + a; }
    }
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    vector<int> a(N);
    vector<int> b(N + 1);

    rep(i, N) cin >> a[i];

    b[0] = 1;

    for (int i = 1; i <= N; ++i) {
        b[i] = a[b[i - 1]-1];
        if (b[i] == 2) {
            cout << i << endl;
            goto xyz;
        }
    }
    cout << -1 << endl;
xyz:;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
  int r, c;
  int arr[100][100];
  int arr_r[100];
  int arr_c[100];
  int total=0;
  int input;
  int i, j;

  //input r×c
  scanf("%d %d", &r, &c);
  for(i=0; i<r; i++){
    for(j=0; j<c; j++){
      scanf("%d", &input);
      arr[i][j]=input;
    }
  }

  //calculation
  for(i=0; i<r; i++){
    for(j=0; j<c; j++){
      arr_r[i]+=arr[i][j];
      arr_c[j]+=arr[i][j];
    }
    total+=arr_r[i];
  }

  //output
  for(i=0; i<r+1; i++){
    for(j=0; j<c+1; j++){
      if(i != r){
        if(j != c){
          printf("%d ", arr[i][j]);
        }else{
          printf("%d\n", arr_r[i]);
        }
      }else{
        if(j != c){
          printf("%d ", arr_c[j]);
        }else{
          printf("%d\n", total);
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  int ans = 0;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    ans += (i % 2 == 0 && a % 2 == 1);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
while True:
	pt=map(int,raw_input().split(" "))
	if pt[0]==-1 and pt[1]==-1 and pt[2]==-1:
		break
	elif pt[0]==-1 or pt[1]==-1:
		print "F"
	elif pt[0]+pt[1]>=80:
		print "A"
	elif 65<=pt[0]+pt[1]<80:
		print "B"
	elif 50<=pt[0]+pt[1]<65:
		print "C"
	elif 30<=pt[0]+pt[1]<50 and pt[2]<50:
		print "D"
	elif 30<=pt[0]+pt[1]<50 and pt[2]>=50:
		print "C"
	elif pt[0]+pt[1]<30:
		print "F"

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

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

int main()
{
  typedef pair<int,int> P;

  int H, W; cin >> H >> W;
  int INF = 1000000000;
  vector< vector<int> > maze(H), dist(H);

  char c_tmp;
  int sx,sy,gx,gy; // start, goal
  int white_count = 0;
  sx=0; sy=0; gx=H-1; gy=W-1; // init

  REP(i,H){
    maze[i].resize(W);
    dist[i].resize(W,INF);
    REP(j,W){
      cin >> c_tmp;
      if(c_tmp == '#'){ maze[i][j]=1; 
      } else{ maze[i][j]=0; white_count++; }

      if(c_tmp == 's'){ sx=i; sy=j;}
      if(c_tmp == 'g'){ gx=i; gy=j;}
    }
  }

  vector<int> dx = {1,0,-1,0};   vector<int> dy = {0,1,0,-1}; // 十字方向


  // bfs
  queue<P> q;
  q.push( P(sx,sy) ); dist[sx][sy] = 0;
  while( q.size() ){
    P p = q.front(); q.pop();
    if( p.first==gx && p.second==gy ){ break; }
    REP(i,dx.size()){
      int nx = p.first + dx[i]; int ny = p.second + dy[i];
      if( 0<=nx && nx<H && 0<=ny && ny<W && maze[nx][ny]==0 && dist[nx][ny]==INF ){
        // 未訪問かつ移動可能な場合
        q.push( P(nx,ny) );
        dist[nx][ny] = dist[p.first][p.second] + 1;
      }
    }
  }

  int min_dist = dist[gx][gy];
  if( min_dist!=INF ){   cout << white_count-min_dist-1 << endl; }
  else{ cout << -1 << endl; }

  return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const L = parseInt(arg[0].split(" ")[0]);
    const R = parseInt(arg[0].split(" ")[1]);
    const d = parseInt(arg[0].split(" ")[2]);
    
    let answer = 0;
    
    for(let i=L; i<=R; i++) {
        if(i % d === 0) answer++;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	int a[n];
	REP(i, 0, n){
		cin >> a[i];
		if(i == 0) ans += abs(a[i]);
		else ans += (abs(a[i] - a[i-1]));
	}
	ans += abs(a[n-1]);
	
	ll tmp = 0;
	REP(i, 0, n){
		tmp = ans;
		if(i == 0){
			tmp -= abs(a[i]);
			tmp -= abs(a[i+1] - a[i]);
			tmp +=  abs(a[i+1]);
		}
		else if(i == n-1){
			tmp -= abs(a[i] - a[i-1]);
			tmp -= abs(a[i]);
			tmp +=  abs(a[i-1]);
		}
		else{
			tmp -= abs(a[i] - a[i-1]);
			tmp -= abs(a[i+1] - a[i]);
			tmp +=  abs(a[i+1]-a[i-1]);
		}
		cout << tmp << endl;
	}
		
			

}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    if (S == "ABC") {
        cout << "ARC\n";
    } else {
        cout << "ABC\n";
    }
}


Measured memory_bytes: 3572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String args[]) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String st = br.readLine();
    br.close();

    String m = "No";
    if (Integer.valueOf(st) >= 30) {
      m = "Yes";
    }
    System.out.println(m);
  }
}


Measured memory_bytes: 25256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

const int N = 21;

bool treasure[N][N];
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
string str = "NESW";

main(){
  int n;
  while(cin >> n && n){
    fill(treasure[0], treasure[N], false);
    for(int i=0;i<n;i++){
      int a, b;
      cin >> a >> b;
      treasure[b][a] = true;
    }
    int m;
    cin >> m;
    int rem = n;
    int y = 10, x = 10;
    for(int i=0;i<m;i++){
      char d;
      int l;
      cin >> d >> l;
      for(int j=0;j<str.size();j++){
        if(str[j] == d){
          for(int k=0;k<l;k++){
            y += dy[j];
            x += dx[j];
            if(treasure[y][x]){
              treasure[y][x] = false;
              rem--;
            }
          }
        }
      }
    }
    cout << (rem ? "No" : "Yes") << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n,*a=open(0).readlines();n=int(n);*b,=zip(*a);f,e=[sum(n==t.count(c)for t in b)for c in'#.'];print(-(e==n)or min(n*2-f-a[i].count('#')+(not'#'in b[i])for i in range(n)))

Measured memory_bytes: 5236
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <map>
#include <utility>
#define N 200020
#define MOD 1000000007
using namespace std;

long long a[N], b[N];
map<pair<long long, long long>, int> f;
set<pair<long long, long long> > u;

int Power(int x, int y)
{
    int o;

    for(o = 1; y; y >>= 1)
    {
        if(y & 1)
            o = (long long)o * x % MOD;
        x = (long long)x * x % MOD;
    }

    return o;
}

int main(void)
{
    int n;
    int i, o;
    long long g;
    map<pair<long long, long long>, int>::iterator t;
    pair<long long, long long> v;

    scanf("%d", &n);
    for(i = 0; i < n; i ++)
    {
        scanf("%lld %lld", &a[i], &b[i]);
        if(!a[i] && !b[i])
            f[make_pair(0, 0)] ++;
        else if(!a[i])
            f[make_pair(0, 1)] ++;
        else if(!b[i])
            f[make_pair(-1, 0)] ++;
        else
        {
            g = __gcd(abs(a[i]), abs(b[i]));
            a[i] /= g;
            b[i] /= g;
            if(b[i] < 0)
            {
                a[i] = -a[i];
                b[i] = -b[i];
            }
            f[make_pair(a[i], b[i])] ++;
        }
    }

    u.insert(make_pair(0, 0));
    for(t = f.begin(), o = 1; t != f.end(); ++ t)
    {
        v = t -> first;
        if(!u.count(v))
        {
            swap(v.first, v.second);
            v.first = -v.first;
            if(v.second < 0)
            {
                v.first = -v.first;
                v.second = -v.second;
            }
            u.insert(v);
            // printf("fetch [%d,%d] <-> [%d,%d]\n", t->first.first,t->first.second,v.first,v.second);
            o = (long long)o * (Power(2, t -> second) + Power(2, f[v]) - 1) % MOD;
        }
    }
    o = (o + f[make_pair(0, 0)]) % MOD;
    printf("%d\n", (o + MOD - 1) % MOD);

    return 0;
}


Measured memory_bytes: 44260
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
int a[10][500];int s[10][500];
int main()
{
 	//freopen("","r",stdin);
	//freopen("","w",stdout);
	 int n;cin>>n;
	 for(int i=0;i<2;i++)
	 {
	 	for(int j=0;j<n;j++)
	 	{
	 		cin>>a[i][j];if(j==0) s[i][j]=a[i][j];else s[i][j]=s[i][j-1]+a[i][j];
	 	}
	 }
	 int ans=0;
	 for(int i=0;i<n;i++)
	 {
	 	int p;if(i==0) p=0;else p=s[1][i-1];
	 	int t=s[0][i]-p+s[1][n-1];ans=max(ans,t);
	 }cout<<ans;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0208
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                long n = RLong(); if (n == 0) break;
                long m = long.Parse(Convert.ToString(n, 8));
                Console.WriteLine(m.ToString().Replace('7', '9').Replace('6', '8').Replace('5', '7').Replace('4', '5'));
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 18048
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
const int MAX = 2001;
const int MOD = 1000000007;
 
 
vector<int> ko[100001];



 
signed main(){
    int n,k;
    cin>>n>>k;
    int oya[n],used[n]={},a;
    for(int i=0;i<n;i++){
        cin>>a;
        oya[i]=a-1;
        if(i!=0) ko[a-1].push_back(i);
       
    }
    int  t=0;
    queue<int> que,que2;
    priority_queue<pair<int,int>> pq;
    que.push(0);
    while(!que.empty()){
        a=que.front();
       
        que.pop();
        for(int i=0;i<ko[a].size();i++){
            if(ko[a][i]!=0)que2.push(ko[a][i]);
        }
       
        if(ko[a].size()==0){
            pq.push(make_pair(t,a));
             ;}
        while(!que.empty()){
             a=que.front();
          
        que.pop();
        for(int i=0;i<ko[a].size();i++){
            if(ko[a][i]!=0)que2.push(ko[a][i]);
        }
        
        if(ko[a].size()==0){
            pq.push(make_pair(t,a));
            
        }
        }
        swap(que,que2);
        t++;

    }
  
    int ans=0;
    pair<int,int> p;
    used[0]=1;
    while(!pq.empty()){
        p=pq.top();
        pq.pop();
        a=p.second;
        //cerr<<p.first<<' '<<p.second<<endl;
        t=0;
        if(used[a]!=1){
        used[a]=1;
        while(a!=0&&used[oya[a]]!=1&&t!=k-1){
            a=oya[a];
            t++;
            used[a]=1;

        }
        
           //cerr<<oya[a]<<endl;
        if(a!=0&&used[oya[a]]!=1&&t==k-1){
            pq.push(make_pair(p.first - k,oya[a]));
         
           
        }
        if(a!=0&&oya[a]!=0&&t==k-1){
         
            ans++;
        }
        }

    }
    if(oya[0]!=0)ans++;
    cout<<ans;

    return 0;
}

Measured memory_bytes: 8692
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    L,R,d = isRaw()

    ans = (R//d)-(L//d)
    if L%d==0:
        ans+=1
    print(ans)


main()


Measured memory_bytes: 67420
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int a=0;
        for(int i=s.length()-1;i>=0;i--){
            if(i%2!=0) continue;
            if(s.substring(0,i/2).equals(s.substring(i/2,i))){
                a=i;
                break;
            }
        }
        System.out.println(a);
    }
}

Measured memory_bytes: 21076
// Problem : B - 1%
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_b?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll cur=100;
    ll cnt=0;
    while(cur<n){
    	cur=cur+(cur/100);
    	cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

char s[55][55];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	vector<int>a(n); int sum = 0;
	rep(i, n) {
		if (s.at(i) == 'E')a[i] = 1;
		else a[i] = 0;
		if (i >= 1)sum += a[i];
	}
	int ans = sum;
	for (int i = 1; i < n; i++) {
		sum -= a[i];
		if (a[i - 1] == 0)sum++;
		chmin(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

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

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

using namespace std;

int main() {
  while(1){
    string s;
    cin>>s;
    if(s=="#") break;
    int l=s.size();
    vector<string> st;
    REP(i,1<<l) {
      string cp=s;
      bool ok = true;
      REP(j,l) {
        if ((i>>j)&1) {
          if (cp[j] == 'z') {
            ok = false;
            break;
          }
          cp[j]++;
        }
      }
      if (!ok) {
        i += i & (-i);
        --i;
        continue;
      }
      vector<bool> isc(26,false);
      auto cpen = cp;
      REP(j,l) {
        if (!isc[cp[j]-'a'] && cp[j] != 'a') {
          if (((i>>j)&1)==0) {
            ok = false;
            break;
          }
          isc[cp[j]-'a'] = true;
          --cpen[j];
        }
        if(cpen[j] != s[j]) {
          ok=false;
          break;
        }
      }
      if (!ok) continue;
      st.push_back(cp);
    }
    sort(begin(st),end(st));
    auto itr = unique(begin(st),end(st));
    cout<<(itr-begin(st))<<endl;
    if ((itr-begin(st)) < 10) {
      REP(i,itr-begin(st)) cout << st[i] << endl;
    } else {
      REP(i,5) cout<<st[i]<<endl;
      REP(i,5) cout<<st[itr-begin(st)-5+i]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2356
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int x[11][11];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%d",&x[i][j]);
	int ret=0;
	for(int i=0;i<a;i++)for(int j=i+1;j<a;j++){
		int tmp=0;
		for(int k=0;k<b;k++){
			tmp+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
		}
		int v=(int)sqrt(tmp+0.5);
		if(v*v==tmp)ret++;
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int X,A,B;

    cin>>X>>A>>B;

    if(A>=B){
    cout<<"delicious";
    }else if(B-A>X){
    cout<<"dangerous";
    }else{ 
        cout<<"safe";
    }

    cout<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
 
template <typename Weight, int MAX_N, Weight INF> class MaxFlow{
private:
	struct E{
		int to, rev;
		Weight lim;
		E(int x, Weight y, int z){
			to = x;
			lim = y;
			rev = z;
		}
	};
 
	vector<E> edge[MAX_N];
	int lev[MAX_N];
	int iter[MAX_N];
 
 
	Weight dfs(int s, int g, Weight f){
		if(s == g)return f;
		for(int &i = iter[s];i < edge[s].size();i++){
			E &e = edge[s][i];
			if(lev[e.to] <= lev[s] || e.lim <= 0)continue;
			Weight tmp = dfs(e.to, g, min(f, e.lim));
			if(tmp<1e-9)continue;
			e.lim -= tmp;
			edge[e.to][e.rev].lim += tmp;
			return tmp;
		}
		return 0;
	}
 
	void bfs(int x){
		queue<int> q;
		q.push(x);
		int p = 0;
		while(!q.empty()){
			for(int i = q.size();i--;){
				int tmp = q.front();q.pop();
				if(lev[tmp] != MAX_N)continue;
				lev[tmp] = p;
				for(int j = 0;j < edge[tmp].size();j++){
					if(edge[tmp][j].lim > 0 && lev[edge[tmp][j].to] == MAX_N)q.push(edge[tmp][j].to);
				}
			}
			p++;
		}
	}
 
public:
	void make_edge(int a, int b, Weight l){
		edge[a].push_back(E(b, l, edge[b].size()));
		edge[b].push_back(E(a, 0, edge[a].size() - 1));
	}
 
	Weight max_flow(int s, int g){
		Weight res = 0;
		bool fin = false;
		while(!fin){
			fill(lev, lev + MAX_N, MAX_N);
			fill(iter, iter + MAX_N, 0);
			bfs(s);
			fin = true;
			while(true){
				Weight p = dfs(s, g, INF);
				if(p < 1e-9)break;
				fin = false;
				res += p;
			}
		}	
		return res;
	}
};

int n;
int a[108000], b[108800], c[10800], d[10880];

int main(){

	MaxFlow<int, 216, 108000> mf;	
	cin >> n;
	for(int i = 0;i < n;i++)cin >> a[i] >> b[i];
	for(int i = 0;i < n;i++)cin >> c[i] >> d[i];
	int start = 213, goal = 214;
	
	for(int i = 0;i < n;i++){
		mf.make_edge(start, i, 1);
		mf.make_edge(i + 100, goal, 1);
		for(int j = 0;j < n;j++){
			if(a[i] < c[j] && b[i] < d[j]){
				mf.make_edge(i, j + 100, 1);
			}
		}
	}
	cout << mf.max_flow(start, goal) << endl;
	return 0;
}

Measured memory_bytes: 384
import sys
import math
import cmath
sys.setrecursionlimit(1000000)

def dft_divide(f, l):
    if l == 1:
        return
    ll = l // 2
    f0, f1 = [0] * ll, [0] * ll
    for i in range(ll):
        f0[i] = f[2 * i]
        f1[i] = f[2 * i + 1]
    dft_divide(f0, ll)
    dft_divide(f1, ll)
    dft_solve(f, f0, f1, l)
    return

def dft_solve(f, f0, f1, l):
    ll = l // 2
    for i in range(l):
        z = cmath.exp(2j * i * cmath.pi / l)
        f[i] = f0[i % ll] + z * f1[i % ll]
    return

def idft_divide(f, l):
    if l == 1:
        return
    ll = l // 2
    f0, f1 = [0] * ll, [0] * ll
    for i in range(ll):
        f0[i] = f[2 * i]
        f1[i] = f[2 * i + 1]
    idft_divide(f0, ll)
    idft_divide(f1, ll)
    idft_solve(f, f0, f1, l)
    return

def idft_solve(f, f0, f1, l):
    ll = l // 2
    for i in range(l):
        z = cmath.exp(-2j * i * cmath.pi / l)
        f[i] = f0[i % ll] + z * f1[i % ll]
    return

def multiply(f, g, ma):
    lf, lg = len(f), len(g)
    m = 2 ** (int(math.log2(lf + lg)) + 1)
    for i in range(m - lf):
        f.append(0)
    for i in range(m - lg):
        g.append(0)
    dft_divide(f, m)
    dft_divide(g, m)
    fg = [0] * m
    for i in range(m):
        fg[i] = f[i] * g[i]
    idft_divide(fg, m)
    #c = [round(fg[i].real / m) for i in range(m)]
    c = [0] * (2 * ma + 1)
    for i in range(2 * ma + 1):
        c[i] = round(fg[i].real / m)
    return c

n, m = map(int, input().split())
a = list(map(int, input().split()))
ma = max(a)
happiness1 = [0] * (ma + 1)
happiness2 = [0] * (ma + 1)
for i in a:
    happiness1[i] += 1
    happiness2[i] += 1
c = multiply(happiness1, happiness2, ma)
cnt = 0
ans = 0
for i in range(2 * ma, -1, -1):
    if c[i] + cnt >= m:
        ans += (m - cnt) * i
        cnt += (m - cnt)
    else:
        ans += c[i] * i
        cnt += c[i]
    if cnt == m:
        break
print(ans)

Measured memory_bytes: 227432
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 100000;

int x;
int dp[MAX + 1];



int main(){
    cin >> x;
    int a;

    for (int i = 0; i < 100; i++) dp[i] = 0;
    for (int i = 100; i <= 105; i++) dp[i] = 1;

    for (int i = 106; i <= x; i++){
        a = dp[i - 100] + dp[i - 101] + dp[i - 102] + dp[i - 103] + dp[i - 104] + dp[i - 105];
        if (a > 0) a = 1;
        dp[i] = a;
    }

    if (dp[x] == 1) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

int main(){

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int b, e;
		cin >> b >> e;
		reverse(a.begin() + b, a.begin() + e);
	}
	for (int i = 0; i < n; i++) cout << (i == 0 ? "" : " ") << a[i];
	cout << endl;
	return 0;
}


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

int main()
{
	int N;
	cin >> N;
	int ans;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		ans += tmp;
	}
	ans -= N;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
F = [int(input().replace(' ', ''),2) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]

ans = -(10**9+7)
for i in range(1, 2**10):
  tmp = 0
  for f, p in zip(F, P):
    tmp += p[bin(f&i).count('1')]
  ans = max(ans, tmp)
print(ans)


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

int main() {
  int a,b;
  cin >> a >> b;
  cout << max(a+b,max(a-b,a*b));
}

Measured memory_bytes: 3608
//スマホから提出
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1010],b[1010];
int main(void)
{
  ll n,h,w;
  cin >>n>>h>>w;
  ll ans=0;
  for(ll i=0;i<n;i++) {
    cin >> a[i] >> b[i];
    if(a[i]>=h&&b[i]>=w) ans++;
  }
  cout << ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, char> plc;

map<int, int> m;

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

	rep(i, n) {
		int a;
		cin >> a;
		m[a]++;
		m[a - 1]++;
		m[a + 1]++;
	}

	int ans = -1,mx = 0;
	for (int i = -1; i <= 100001; i++) {
		if (m[i] > mx) {
			mx = m[i];
		}
	}
	cout << mx << endl;
	return 0;
}


Measured memory_bytes: 4992
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = -1;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    ULL N, K;
    cin >> N >> K;
    if (K % 2 == 1) {
        ULL X = N/K;
        cout << X*X*X << "\n";
    } else {
        ULL X = N/K;
        ULL Y = N/(K/2) - N/K;
        cout << X*X*X + Y*Y*Y << "\n";
    }
}


Measured memory_bytes: 256