akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
using namespace std;
int divfloor(int a, int b, int h, int w) {
  int h_n = static_cast<int>(a/h);
  int w_n = static_cast<int>(b/w);
  return (h_n*w_n);
}
int main() {
  int n, h, w;
  cin >> n >> h >> w;
  int ans = 0;
  for (int i=0;i<n;i++) {
    int a, b;
    cin >> a >> b;
    int count = divfloor(a, b, h, w);
    if (count > 0) {
      ans++;
    }
  }
  printf("%d\n", ans);
  fflush(stdout);
  return 0;
}


Measured memory_bytes: 256
class Vector:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __sub__(self, other):
        return Vector(self.x - other.x, self.y - other.y)

    @staticmethod
    def cross_product(point1, point2):
        return point1.x * point2.y - point1.y * point2.x


class Triangle:
    def __init__(self, x1, y1, x2, y2, x3, y3):
        self.point1 = Vector(x1, y1)
        self.point2 = Vector(x2, y2)
        self.point3 = Vector(x3, y3)

    def is_contain(self, point):
        line1 = point - self.point1
        line2 = self.point2 - self.point1
        direct1 = Vector.cross_product(line1, line2)

        line1 = point - self.point2
        line2 = self.point3 - self.point2
        direct2 = Vector.cross_product(line1, line2)

        line1 = point - self.point3
        line2 = self.point1 - self.point3
        direct3 = Vector.cross_product(line1, line2)

        if 0 < direct1 and 0 < direct2 and 0 < direct3:
            return 1
        elif direct1 < 0 and direct2 < 0 and direct3 < 0:
            return 1
        else:
            return -1


for _ in range(int(input())):
    data = [int(item) for item in input().split(" ")]

    triangle = Triangle(data[0], data[1], data[2], data[3], data[4], data[5])
    altair_point = Vector(data[6], data[7])
    vega_point = Vector(data[8], data[9])

    is_contain1 = triangle.is_contain(altair_point)
    is_contain2 = triangle.is_contain(vega_point)
    result = is_contain1 * is_contain2

    if result == -1:
        print("OK")
    else:
        print("NG")



Measured memory_bytes: 5640
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let q: usize = input();
    let stx: Vec<(i32, i32, i32)> = (0..n).map(|_| (input(), input(), input())).collect();
    let d: Vec<i32> = (0..q).map(|_| input()).collect();

    let mut e = vec![];
    for i in 0..q {
        e.push((d[i], 2, i as i32));
    }
    for (s, t, x) in stx {
        e.push((s - x, 1, x));
        e.push((t - x, 0, x));
    }
    e.sort();

    let mut xs = std::collections::BTreeSet::new();
    let mut v = vec![-1; q];
    for e in e {
        if e.1 == 2 {
            if let Some(&x) = xs.iter().next() {
                v[e.2 as usize] = x;
            }
        } else if e.1 == 1 {
            xs.insert(e.2);
        } else {
            xs.remove(&e.2);
        }
    }

    for v in v {
        println!("{}", v);
    }
}

trait LowerBound<T: Ord> {
    fn lower_bound(&self, x: &T) -> usize;
}

impl<T: Ord> LowerBound<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut l = -1 as i64;
        let mut r = self.len() as i64;
        while r - l > 1 {
            let m = ((l + r) / 2) as usize;
            if self[m] >= *x {
                r = m as i64;
            } else {
                l = m as i64;
            }
        }
        r as usize
    }
}


Measured memory_bytes: 20840
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long k = sc.nextInt();

        long res = (n/k) * (n/k) * (n/k);
        if(k%2 == 0) {
            long div = n/k;
            if(n%k >= k/2) {
                div++;
            }
            res += div * div * div;
        }
        System.out.println(res);
    }

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
string ans;
long long dp[N][N];
int main()
{
    string s,t;
    cin >> s >>t;
    for (int i=0; i<s.size(); i++){
            string x;
        for ( int j =0; j< t.size(); j++){
            if (s[i]== t[j]){
                dp[i+1][j+1]= dp[i][j]+1;
            }
            else {
                    dp[i+1][j+1] = max (dp[i][j+1], dp[i+1][j]);
            }
                    }
    }
    int i = s.size(), j = t.size();
    while (dp[i][j] >0){
        if ( s[i-1]== t[j-1]) {
                ans+=s[i-1];
        i--, j--;
        }
        else {
            if (dp[i][j-1] > dp[i-1][j]) j--;
            else i--;
        }
    }
    for ( int k = ans.size()-1; k >=0; k--) cout << ans[k];

    return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
 
#define NL '\n'
#define xx first
#define yy second
#define ll long long
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define async() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 
#define FayeValentine 
void dz(){cerr<<NL;}template<typename H,typename... T> void dz(H h,T... t){cerr<<' '<<h;dz(t... );}
#ifdef  FayeValentine
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",dz(__VA_ARGS__)
#else
#define debug(...) 
#endif


void absinthe() {
	int n, x; cin >> n;
	ll s = 0; 
	while(n--) {cin >> x; s += ((ll)x-1); }
	cout << s << NL;
}

 
int main(){
  async();
  int __t = 1, __c; //cin >> __t;
  for(__c = 1; __c <=__t; __c++) {
    //cout << "Case " << __c << ": "; 
    absinthe();
  }
}  


Measured memory_bytes: 256
n = int(input())
s = input()
cnt_l, cnt_r = 0, 0

for x in s:
	if x == "(":
		cnt_l += 1
	elif cnt_l > 0:
		cnt_l -= 1
	else:
		cnt_r += 1

print(cnt_r * "(" + s + cnt_l * ")")


Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1e16
#define MOD 1000000007
ll dx[]={1,0,-1,0};
ll dy[]={0,1,0,-1};
ll n0,m0;
double dp[3002][3002]={0};
ll mark[3002][3002]={0};
double fun(double v1[], ll x,ll a)
{
    if(x==n0)
    {
        if(a>m0)
        return 1;
        else return 0;
    }
    if(mark[x][a]!=0) return dp[x][a];
    
    
    double aa=fun(v1,x+1,a)*(1-v1[x]);
    double bb=fun(v1,x+1,a+1)*(v1[x]);
    aa+=bb;
    mark[x][a]=1;
    dp[x][a]=aa;
    return aa;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d,e,f,n,m,k,t,q;
    t=1;
    //cin>>t;
    while(t--)
    {
        cin>>n;
        m=n/2;
        n0=n,m0=m;
        double v1[n+1];
        //memset(dp,0,sizeof(dp));
        for(int i=0;i<n;i++)
        {
            cin>>v1[i];
            //cout<<v1[i];
        }
        double aa=fun(v1,0,0);
        cout<< fixed << setprecision(10)<<aa;
        
    }
    return 0;
}


Measured memory_bytes: 139520
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

struct BIT{
    vector<int> data;
    int sz;

    BIT(int n){
        sz = n + 1;
        data.assign(sz, 0);
    }

    void add(int i, const int& x){
        ++i;
        while(i <= sz){
            data[i] += x;
            i += i & - i;
        }
        return;
    }

    int getSum(int i){
        ++i;
        int res = 0;
        while(i > 0){
            res += data[i];
            i -= i & -i;
        }
        return res;
    }

    int getSum(int l, int r){
        return getSum(r) - getSum(l - 1);
    }
};

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

    int n, q;
    cin >> n >> q;
    BIT bit(n);
    for(int i = 0; i < q; ++i){
        int com, x, y;
        cin >> com >> x >> y;
        --x;
        if(!com)    bit.add(x, y);
        else    cout << bit.getSum(x, --y) << '\n';
    }
}


Measured memory_bytes: 3344
#include<bits/stdc++.h>
using namespace std;
const int N=1000005;
struct Roa{
	int u,v,k;
};
vector<Roa>ans;
int n,m,lg[N];
void addedge(int u,int v,int k){
	Roa a;
	a.u=u,a.v=v,a.k=k;
	ans.push_back(a);
	m++;
}
int main(){
	int l;
	scanf("%d",&l);
	lg[1]=0;
	for (int i=2;i<=l;i++) lg[i]=lg[i>>1]+1;
	int p=lg[l]+1;
	n=p;
	for (int i=1;i<n;i++)
	addedge(i,i+1,0),addedge(i,i+1,(1<<(n-i-1)));
	int now=1<<(n-1);
	for (int i=n-1;i>=1;i--){
		if (l&(1<<(i-1))) addedge(1,n-i+1,now),now+=(1<<(i-1));
	}
	printf("%d %d\n",n,m);
	for (int i=0;i<ans.size();i++){
		int u=ans[i].u,v=ans[i].v,k=ans[i].k;
		printf("%d %d %d\n",u,v,k);
	}
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string s;
	char t;
	int count=0;
	cin >> s;
	for (int i = 0; i < s.size()-1; i++) {
		if (s[i+1]==s[i]) {
			if (s[i] == '0') {
				s[i + 1] = '1';
				count++;
			}
			else if(s[i]=='1'){
				s[i + 1] = '0';
				count++;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 512
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


n, m = map(int, input().split())
print(n*(n-1)//2+m*(m-1)//2)


Measured memory_bytes: 3832
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,X = map(int,input().split())
A = list(map(int,input().split()))

ans = 0 
if A[0]>X:
    ans = A[0]-X
    A[0] -= ans

for i in range(N-1):
    r = max(A[i]+A[i+1]-X,0)
    A[i+1] -= r
    ans += r

print(ans)


Measured memory_bytes: 14656
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
using vi = vector <int>;
using vvi = vector <vi>;

class unionFindTree{
	private:
		vector <int> tree;
		vector <int> rank;

	public:
		unionFindTree(int sz){
			tree = vector <int> (sz);
			rank = vector <int> (sz, 0);
			for(int i = 0; i < tree.size(); i++)
				tree[i] = i;
		}

		int root(int x){
			return tree[x] == x ? x : tree[x] = root(tree[x]);
		}

		bool same(int a, int b){
			return root(a) == root(b);
		}

		void unite(int a, int b){
			a = root(a);
			b = root(b);
			if(a == b)return;

			if(rank[a] < rank[b]) swap(a, b);

			tree[b] = a;
			rank[a] += rank[a] == rank[b];
		}

		int size(){
			return tree.size();
		}

};


class Kruskal{
private:
	struct edge{
		int u, v, cost;
		bool operator< (const edge& e) const{
			return cost < e.cost;
		}
	};
	vector <edge> es;
	int V;

public:
	Kruskal(int v, int e){
		V = v;
		es = vector <edge> (e);
	}

	void addEdge(int start, int end, int cost){
		es.push_back({start, end, cost});
	}

	int execute(){
		unionFindTree uft(V);
		sort(es.begin(), es.end());
		int res = 0;
		for(int i = 0; i < es.size(); i++){
			edge e = es[i];
			if(!uft.same(e.u, e.v)){
				uft.unite(e.u, e.v);
				res += e.cost;
			}
		}
		return res;
	}
};

signed main(){
	int v, e;
	cin >> v >> e;
	Kruskal kruskal(v, e);

	rep(i, e){
		int s, t, w;
		cin >> s >> t >> w;
		kruskal.addEdge(s, t, w);
		kruskal.addEdge(t, s, w);
	}

	cout << kruskal.execute() << endl;
}


Measured memory_bytes: 12224
#include <iostream>
using namespace std;
#define ll long long
int main()
{
    ll cnt=0;
    string s,t;
    cin>>s;
    cin>>t;
    for(ll i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3860
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<functional>
#define all(c) c.begin(),c.end()
#define uni(c) c.erase(unique(c.begin(),c.end()),c.end())
#define pb push_back
using namespace std;
typedef long long int ll;
int main(){
	int n;
	while(cin>>n){
		vector<ll> x(n);
		for(int i=0;i<n;i++)
			cin>>x[i];
		ll ans=1;
		sort(all(x),greater<ll>());
		ll ms=0;
		for(int i=0;i<n;i++){
			if(i&&i%4==0){
				ms++;
			}
			if(x[i]-ms>=0){
				ans+=x[i]-ms;
			}
		}
		
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    char s[5];
    int ac = 0, wa = 0, tle = 0, re = 0;
    for(int i = 0; i<n; i++){
        scanf("%s", s);
        
        if( 'A' == s[0] ){ac++;}
        else if( 'W' == s[0]){wa++;}
        else if('T' == s[0]){tle++;}
        else if('R' == s[0]){re++;}
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac, wa, tle, re);
    return 0;
}

Measured memory_bytes: 1728
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N = inputI()
A = inputILs(N)

B = A[:]
A.sort()

a = set([A[i] for i in range(N)[::2]])
b = set([B[i] for i in range(N)[::2]])

print(len(a-b))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int m1, d1, m2, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;

    if(m1 != m2){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <limits>

using vi = std::vector<int>;
using vvi = std::vector<vi>;
/*
int kaisuu(const vi& keiro)
{
	int prev = keiro[0];
	int count = 0;
	for (size_t i = 0; i < keiro.size(); ++i)
	{
		if (prev == 1 && keiro[i] == 0)
		{
			count++;
		}
		prev = keiro[i];
	}
	if (prev == 1) count++;

	return count;
}

int dfs(const vvi& s, vvi& dp, int H, int W, int h, int w, int prev)
{
	if (prev == 1 && s[h][w] == 0) count++;

	if (h == H - 1 && w == W - 1)
	{
		return kaisuu(keiro);
	}

	keiro[h+w] = s[h][w];
	int migi = 999999, shita = 999999;
	if (h < H - 1)
	{
		shita = dfs(s, keiro, H, W, h+1, w);
	}
	if (w < W - 1)
	{
		migi = dfs(s, keiro, H, W, h, w+1);
	}
	return std::min(migi, shita);
}
*/

int main()
{
	int H, W;
	std::cin >> H >> W;
	vvi s(H, vi(W));
	for (int h = 0; h < H; h++)
	{
		std::string line;
		std::cin >> line;
		for (int w = 0; w < W; w++)
		{
			s[h][w] = (line[w] == '#') ? 1 : 0;
		}
	}

	vvi dp(H, vi(W));
	for (int h = 0; h < H; h++)
	{
		for (int w = 0; w < W; w++)
		{
			if (h == 0 && w == 0)
			{
				dp[0][0] = s[0][0];
				continue;
			}

			int left = 999999, up = 999999;
			if (h > 0)
			{
				up = dp[h - 1][w] + ((s[h - 1][w] == 0 && s[h][w] == 1) ? 1 : 0);
			}
			if (w > 0)
			{
				left = dp[h][w - 1] + ((s[h][w - 1] == 0 && s[h][w] == 1) ? 1 : 0);
			}
			dp[h][w] = std::min(up, left);
		}
	}
	std::cout << dp[H-1][W-1];
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  rep(i, 1, n + 1) {
    ll m = k - (i % k);
    if (m > n) continue;
    if (k - m != m && m != k) continue;
    ll count = 1 + (n - m) / k;
    ans += count * count;
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


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

void main_()
{
    string S;
    cin >> S;

    if (S.size() < 26) {
        bitset<26> exists;
        for (auto ch : S) {
            exists.set(ch - 'a');
        }
        char ch = 0;
        for (ll i = 0; i < 26; ++i) {
            if (!exists.test(i)) {
                ch = i + 'a';
                break;
            }
        }
        cout << S << ch << endl;
        return;
    }

    // アルファベットの順序が戻る文字の場所を末尾から探す
    auto rit = adjacent_find(rbegin(S), rend(S), [](auto a, auto b) { return a > b; });
    if (rit == rend(S)) {
        cout << -1 << "\n";
        return;
    }

    // 順序が戻る文字の場所のイテレータを取得
    auto it = next(rit, 2).base();

    // その文字の前まで出力
    copy(begin(S), it, ostreambuf_iterator<char>(cout));

    // その文字から末尾までで、アルファベット順でその文字より大きく一番近い文字を探す
    auto out_it = min_element(it, end(S), [base = *it](auto a, auto b) {
        a = (a > base) ? a : numeric_limits<decltype(a)>::max();
        b = (b > base) ? b : numeric_limits<decltype(b)>::max();
        return a < b;
    });

    // それを出力
    cout << *out_it << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
while True:
    s = input()
    if s == "#":break
    s = s.split("/")
    area = [0] * len(s)
    for i in range(len(s)):
        t = []
        while True:
            if s[i][0] == "b":
                t.append(1)
                s[i] = s[i][1:]
            else:
                if "b" in s[i]:
                    t += [0] * int(s[i][:s[i].index("b")])
                    s[i] = s[i][s[i].index("b"):]
                else:
                    t += [0] * int(s[i])
                    break
            if s[i] == "":
                break
        area[i] = t
    a, b, c, d = map(int, input().split())
    area[a - 1][b - 1] = 0
    area[c - 1][d - 1] = 1
    t = ""
    for i in range(len(area)):
        j = 0
        while True:
            if area[i][j] == 1:
                t += "b"
                j += 1
            else:
                k = 0
                while j < len(area[i]) and area[i][j] == 0:
                    k += 1
                    j += 1
                t += str(k)
            if j == len(area[i]):break
        if i < len(area) - 1:
            t += "/"
    print(t)


Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int n;
    int m = 0;
    cin >> n;
    while (1) {
        if (n == 4 || n == 1 || n == 2) {
            cout << m + 4 << endl;
            return 0;
        } else if (n % 2 == 0) {
            n /= 2;
            m++;
        } else if (n % 2 == 1) {
            n = n * 3 + 1;
            m++;
        }
    }
}


Measured memory_bytes: 256
N,K = map(int,input().split())
H = [int(input()) for _ in range(N)]

H.sort()

res = 1000000000
for i in range(N-K+1):
    #print(H)
    #print(H[i+K-1],H[i])
    tmp = H[i+K-1]-H[i]
    if tmp < res:
        res = tmp
print(res)

Measured memory_bytes: 7512
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n, x, y;
    cin >> n >> x >> y;

    map<int, int> mp;

    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            int path = j - i;
            if(j<=x){
               mp[path]++; 
            }
            else if(y<=i){
                mp[path]++;
            }
            else if(j>x && x>=i && y>=j){
                path = min(x-i+y-j+1, path);
                mp[path]++;
            }
            else if(x<=i && j<=y){
                path = min(path, i-x + y-j + 1);
                mp[path]++;
            }
            else if(x<=i && y<=j && y>=i){
                path = min(path, i-x + j-y + 1);
                mp[path]++;
            }
            else if(i<=x && j>=y){
                path = min(path, x-i+j-y+1);
                mp[path]++;
            }
        }
    }

    for(int i=1; i<n; i++){
        cout << mp[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 384
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(n, i, s):
    c = 0
    for i in s:
        if i=='-':
            c+=1
    if  s[n]=='-' and c==1:
        return 'Yes'
    else:
        return 'No'

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line1 = sys.stdin.readline().rstrip()
    [str_n, str_i] = line1.split(' ')
    line2 = sys.stdin.readline().rstrip()
    return (int(str_n), int(str_i), line2)

def main():
    n, i, s = readQuestion()
    answer = solve(n, i, s)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;cin>>n;int p=1;
  int k;
  for(int i=0;i<n;i++)
  {
  cin>>k;
    if(k==p)
      p++;
  }
  if(p==1)
    cout<<"-1";
  else cout<<n-p+1;
}


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

using namespace std ;

const int MAX = 2010 ;

int dp[MAX][MAX][2] , arr[MAX];
int n , x , y ;

int solve(int idx , int idx2 , int turn)
{
	int now ;
	if(idx2 == 0)
	{
		if(turn == 0)
			now = y ;
		else
			now = x ;
	}
	else
		now = arr[idx2] ;
	if(idx == n)
		return (abs(arr[idx] - now)) ;
	int &ret = dp[idx][idx2][turn] ;
	if(ret != -1)
		return ret ;
	if(turn == 0)
	{
		ret = solve(idx+1 , idx2 , turn) ;
		ret = max(ret , solve(idx+1 , idx , !turn)) ;
	}
	else
	{
		ret = solve(idx+1 , idx2 , turn) ;
		ret = min(ret , solve(idx+1 , idx , !turn)) ;
	}
	return ret ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>x>>y ;
	for(int i = 1 ; i <= n ; ++i)
		cin>>arr[i] ;
	memset(dp , -1 , sizeof(dp)) ;
	return cout<<solve(1 , 0 , 0)<<"\n" , 0 ;
}


Measured memory_bytes: 32000
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = input()
    res = 0
    for i in range(len(n)):
        res += int(n[i])
    if res%9==0:
        print("Yes")
    else:
        print("No")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9244
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        // Your code here!
        
        string s = Console.ReadLine();
        if(s=="SUN"){
            Console.WriteLine("7");
        }else if(s=="MON"){
            Console.WriteLine("6");
        }else if(s=="TUE"){
            Console.WriteLine("5");
        }else if(s=="WED"){
            Console.WriteLine("4");
        }else if(s=="THU"){
            Console.WriteLine("3");
        }else if(s=="FRI"){
            Console.WriteLine("2");
        }else if(s=="SAT"){
            Console.WriteLine("1");
        }
    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll x;
    ll t; cin>>t;
    x.pb(t);
    rep(i,n){
        ll t; cin>>t;
        x.pb(t);
    }
    sort(all(x));
    vll y(n);
    rep(i,n){
        y[i] = x[i+1]-x[i];
    }
    ll g = y[0];
    rep(i,n){
        g = __gcd(g,y[i]);
    }
    cout<<g<<endl;
    return 0;
}


Measured memory_bytes: 1908
def examA():
    N = I()
    if N%2==0:
        ans = N
    else:
        ans = N*2
    print(ans)





import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 3436
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    int a[N],b[N];
    for(int i = 0; i < N; i++) cin >> a[i] >> b[i];
    int c[M],d[M];
    for(int i = 0; i < M; i++) cin >> c[i] >> d[i];
    for(int i = 0; i < N; i++){
        int min = abs(a[i]-c[0]) + abs(b[i]-d[0]), num=1;
        for(int j = 0; j < M; j++){
            int m = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(min > m){min = m; num = j+1;}
        }
        cout << num << endl;
    }
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>

#define MODULE 
#define RAND(min,max) (rand()%(max-min+1)+min)
#define LOGI(log) printf("\n%d\n",log);
#define LOGS(log) printf("\n%s\n",log);
#define DEBUG() {printf("\nDEBUG %d\n",num_debug);num_debug++;}
char num_debug = 0;
int main(void) {
	srand((unsigned)time(NULL));

	char c;
	scanf("%c", &c);

	if ('A' <= c&&c<'a')
		printf("A");
	else
		printf("a");

	//LOGI('A')//65
	//LOGI('a')//97
	return 0;
}

Measured memory_bytes: 1564
<?php
fscanf(STDIN, "%d %d", $a, $b);

$add = $a + $b;
$sub = $a - $b;
$mod = $a * $b;

$ret = ($add > $sub)? $add : $sub;
$ret = ($ret > $mod)? $ret : $mod;

echo $ret, "\n";

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

ll a[2020];
pair<ll,ll> p[2020];
ll dp[2020][2020];

void solve(){

    ll n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
        p[i] = make_pair(-a[i],i);
    }
    sort(p,p+n);
    /*
    rep(i,n){
        cout << p[i].second << " ";
    }
    cout << endl;
    */
    rep(i,2020){
        rep(j,2020){
            dp[i][j]=0;
        }
    }
    rep(i,n){
        rep(j,n){
            if(i+j>n) continue;
            if(i==0&&j==0) continue;
            if(i==0){
                ll x = p[i+j-1].second;
                dp[i][j]=dp[i][j-1]+abs(x-(n-j))*a[x];
            }
            else if(j==0){
                ll x = p[i+j-1].second;
                dp[i][j]=dp[i-1][j]+abs(x-(i-1))*a[x];
            }
            else{
                ll x = p[i+j-1].second;
                dp[i][j]=max(dp[i-1][j]+abs(x-(i-1))*a[x], dp[i][j-1]+abs(x-(n-j))*a[x]);
            }
        }
    }

    /*
    rep(i,n){
        rep(j,n){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */

    ll ans = 0;
    rep(i,n){
        ans = max(ans, dp[i][n-i]);
    }

    cout << ans << endl;

}

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


Measured memory_bytes: 35552
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
	int num, i = 0, buf, d[100004] = { 0 }, ans = 0;
	cin >> num;
	for (; i < num; i++) {
		scanf("%d", &buf);
		d[buf]++;
		d[buf + 3]--;
	}
	buf = 0;
	for (i = 0; i <= 100000; i++) {
		buf += d[i];
		ans = max(ans, buf);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 640
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

def dijkstra(src):
    from heapq import heappush, heappop
    from collections import defaultdict

    que = [(0, src)]
    dist = defaultdict(lambda: INF)
    dist[src] = 0
    while que:
        cost, u = heappop(que)
        dist[0] = min(dist[0], cost+abs(u)*d)
        if u >= 5:
            x = u % 5
            v = (u-x) // 5
            if cost+c+d*x < dist[v]:
                dist[v] = cost+c+d*x
                heappush(que, (cost+c+d*x, v))
            if u % 5 != 0:
                x = 5 - u % 5
                v = (u+x) // 5

                if cost+c+d*x < dist[v]:
                    dist[v] = cost+c+d*x
                    heappush(que, (cost+c+d*x, v))
        if u >= 3:
            x = u % 3
            v = (u-x) // 3
            if cost+b+d*x < dist[v]:
                dist[v] = cost+b+d*x
                heappush(que, (cost+b+d*x, v))
            if u % 3 != 0:
                x = 3 - u % 3
                v = (u+x) // 3
                if cost+b+d*x < dist[v]:
                    dist[v] = cost+b+d*x
                    heappush(que, (cost+b+d*x, v))
        if u >= 2:
            x = u % 2
            v = (u-x) // 2
            if cost+a+d*x < dist[v]:
                dist[v] = cost+a+d*x
                heappush(que, (cost+a+d*x, v))
            if u % 2 != 0:
                x = 2 - u % 2
                v = (u+x) // 2
                if cost+a+d*x < dist[v]:
                    dist[v] = cost+a+d*x
                    heappush(que, (cost+a+d*x, v))
    return dist

for _ in range(INT()):
    N, a, b, c, d = MAP()

    res = dijkstra(N)
    ans = res[0]
    print(ans)


Measured memory_bytes: 112208
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
clist = Counter(S)
M = max(clist.values())
rlist = []

for i in clist.keys():
    if clist[i] == M:
        rlist.append(i)

rlist.sort(reverse=False)

for i in range(len(rlist)):
  print(rlist[i])

Measured memory_bytes: 35568
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
//const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	double N, K;
	cin >> N >> K;

	vdouble P(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i];
		P[i] = (P[i]+1) / (2);
	}


	double ans = 0;
	double sum = 0;
	for (int i = 0; i < K; i++) {
		sum += P[i];
	}

	ans = sum;

	for (int i = 0; i+K < N; i++) {
		sum -= P[i];
		sum += P[i+K];
		ans = max(ans, sum);
		//cout << sum << endl;
	}

	cout << ans;




}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll L; cin >> L;
  double x = (double)L / 3.0;
  cout << x*x*x << endl;

  return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    ll p[N];
    rep(i,N) cin >> p[i];
    ll out = 0;
    rep(i,N){
        if(p[i]==i+1){
            out++;
            if(p[i+1]==i+2) i++;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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


rA = []
for i in range(1, N):
    rA.append(A[i] - A[i-1])
rA.append(K-A[-1]+A[0])

rA.sort()
rA[-1] = 0
print(sum(rA))



Measured memory_bytes: 25292
n = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
A.sort(); B.sort(); C.sort()
INF = 10**10
A += INF,; B += INF,; C += INF,
a = b = c = i = j = k = 0
while min(i, j, k) < n:
    v = min(A[i], B[j], C[k])
    if v == C[k]:
        c += b
        k += 1
    elif v == B[j]:
        b += a
        j += 1
    else:
        a += 1
        i += 1
print(c)

Measured memory_bytes: 23220
while True:
    n, k = [int(i) for i in input().split()]
    if n == 0 and k == 0:
        break
    a = [int(input()) for i in range(n)]
    s = sum(a[0:k])
    max = s
    for i in range(k, n):
        s = s + a[i]-a[i - k]
        if s > max:
            max = s
    print(max)


Measured memory_bytes: 9880
#include <cstdio>
int n,cnt=0;
char last,c;
int main(){
	scanf("%d\n",&n);
	for(int i=1;i<=n;++i){
		c = getchar();
		if(i == 1)last = c;
		if(c != last){
			++cnt;
			last = c;
		}
	}
	++cnt;
	printf("%d",cnt);
	return 0;
}


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

int main() {
    long long int A, B, C, K;
    cin >> A >> B >> C >> K;

    long long int ans = 0;
    if (A <= K) {
        ans += A;
        if (0 < K - A - B) {
            ans -= K - A - B;
        }
    }
    else{
        cout << K << endl;
        return 0;
    }

    cout << ans << endl;
}

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

int main(){
    //入力
    int N;
    cin >> N;

    //処理
    int f_X,X;
    f_X=0;
    X=N;
    while(X>0){
        f_X+=X%10;
        X/=10;
    }


    //出力
    if(N%f_X==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int a[200000];
int mod=998244353;
long long int pingfang(int qian,int hou)
{
    int i;
    long long int fang=1;
    for(i=0; i<hou; i++)
        fang=(fang*qian)%mod;
    return fang;
}

int main()
{
    int n;
    while(cin>>n)
    {
        memset(a,0,sizeof(a));
        int i;
        for(i=0; i<n; i++)
        {
            int x;
            scanf("%d",&x);
            if(!i&&x)
                a[0]=-20000;
            a[x]++;
        }
        if(a[0]!=1)
        {
            printf("0\n");
            continue;
        }
        long long int num=1;
        for(i=0; i<n; i++)
            num=num%mod*pingfang(a[i],a[i+1])%mod;
        cout<<num<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String b = sc.next();
    if(b.equals("A")) System.out.println("T");
    if(b.equals("T")) System.out.println("A");
    if(b.equals("C")) System.out.println("G");
    if(b.equals("G")) System.out.println("C");
  }
}


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

import math
import itertools

def main():
    n = int(input())

    x_list = []

    for i in range(n):
        x, y = map(int, input().split())
        x_list.append([x, y])

    li = list(itertools.permutations(x_list))

    c = 0
    for l in li:
        for i, (x, y) in enumerate(l):
            if i+1 == n:
                break
            else:
                x1, y1 = l[i+1]
                c += math.sqrt((x1 - x)**2 + (y1 - y)**2)


    print(c / len(li))



if __name__ == '__main__':
    main()


Measured memory_bytes: 8052
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	int n,m;
	cin>>n>>m;
	vl dp(5000,inf);
	vi cost(m);
	vvi keys(m);
	for(int i=0;i<m;i++){
		int a,b,x;
		cin>>a>>b;
		cost[i]=a;
		for(int j=0;j<b;j++) cin>>x,keys[i].pb(x-1);
	}
	dp[0]=0;
	for(int i=0;i<m;i++){
		int now=0;
		for(int j=0;j<keys[i].size();j++){
			now|=(1<<keys[i][j]);
		}
		for(int mask=0;mask<(1<<n);mask++){
			dp[mask|now]=min(dp[mask|now],dp[mask]+cost[i]);
		}
	}
	int target=(1<<n)-1;
	if(dp[target]==inf) cout<<"-1";
	else cout<<dp[target];
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

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

arms = []

for i in range(n):
    x, l = map(int, input().split())
    arms.append([x-l, x+l])

arms.sort(key=lambda x: x[1])

cnt = 0
r = -10**10

for a in arms:
    if a[0] >= r:
        r = a[1]
    else:
        cnt += 1

print(n - cnt)


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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N; cin >> N;int Q; cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21736