akhauriyash/Code-Regression huggingface dataset:
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= printRes . solve
    where
        printRes = mapM_ print

solve :: [Int] -> [Int]
solve [r, d, x2000] = take 10 $ calc x2000
    where
        calc p = res : calc res
            where
                res = r * p - d 

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll  unsigned long long

signed main(){
	IOS;
    #ifndef ONLINE_JUDGE 
        freopen("inputf.in", "r", stdin);
        freopen("outputf.in", "w", stdout);
    #endif

    long long int a,b;
    string s;
    cin>>a>>s>>b;
    if(s[0]=='+'){
    	cout<<a+b;
    }
    else{
    	cout<<a-b;
    }
    return 0;
}

Measured memory_bytes: 3556
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	l := scanInts(n)
	sort.Ints(l)
	a := 0
	for i := 0; i < n-1; i++ {
		a += l[i]
	}
	if a <= l[n-1] {
		fmt.Fprintln(wr, "No")
	} else {
		fmt.Fprintln(wr, "Yes")
	}
}


Measured memory_bytes: 1776
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

int main() {
	
	ll R;
	cin >> R;
	if (R < 1200) { cout << "ABC"; }
	else if (R < 2800) { cout << "ARC"; }
	else { cout << "AGC"; }
	
	system("PAUSE");
}

Measured memory_bytes: 504
#include <stdio.h>
int main(void){
    
    int n,t[100],m,p,x,i,j,s,a;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&t[i]);
    }
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%d%d",&p,&x);
        s=0;
        a=t[p-1];
        t[p-1]=x;
        for(j=0;j<n;j++) s=s+t[j];
        printf("%d\n",s);
        t[p-1]=a;
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int h,w;
char s[105][105];
int main(void){
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<=h+1;i++){
        s[i][0]='#';
        s[i][w+1]='#';
    }
    for(int i=0;i<=w+1;i++){
        s[0][i]='#';
        s[h+1][i]='#';
    }
    for(int i=0;i<=h+1;i++){
        for(int j=0;j<=w+1;j++){
            cout<<s[i][j];
        }
        cout<<endl;
    }
    
}


Measured memory_bytes: 3620
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc129_b

N = int(input())
weight = list(map(int, input().strip().split()))

S1 = 0
S2 = 0

for i in range(N):
    S1 += weight[i]

res = S1
for i in range(N):
    S1 -= weight[i]
    S2 += weight[i]
    if S1 < S2:
        if S2 - S1 < res:
            res = S2 - S1
        break
    if S1 - S2 < res:
        res = S1 - S2

print(res)


Measured memory_bytes: 8988
#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(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    string s; cin >> s;
    string t; cin >> t;
    int n = s.size();
    int m = t.size();

    vector<int> ans;
    rep(i,n - m + 1){
        int ans_ = s.find(t, i);
        if(ans_ == std::string::npos){
            i = n;
        }else{
            ans.push_back(ans_);
            i = ans_;
        }
    }

    rep(i, ans.size()){
        printf("%d\n", ans[i]);
    }
    
    return 0;
}
 
 



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

int main() {
    int n, ans = 0, sum;
    cin >> n;
    vector<int> up(n), bo(n);
    for (int i = 0; i < n; i++) cin >> up.at(i);
    for (int i = 0; i < n; i++) cin >> bo.at(i);
    sum = up.at(0);
    for (int i = 0; i < n; i++) sum += bo.at(i);
    ans = sum;
    for (int i = 0; i < n - 1; i++) {
        sum = sum - bo.at(i) + up.at(i + 1);
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
const ll mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

    

int main(){
    int n, k;
    cin >> n >> k;
    combination comb(2*n);

    for(int i=1; i<=k; i++) {
        if (n-k<i-1) {
            cout << "0" << endl;
            continue;
        }
        mint res = comb(k-1, i-1);
        res *= comb(n-k+1, i);
        
        cout << res.x << endl;
    }
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template<typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}
struct Dice {
  vi face;
  void init() {
    face.resize(6);
  }
  void rolll() {
    vi newface = {face[4], face[1], face[0], face[3], face[5], face[2]};
    swap(face, newface);
  }
  void rollr() {
    vi newface = {face[2], face[1], face[5], face[3], face[0], face[4]};
    swap(face, newface);
  }
  void rollu() {
    vi newface = {face[1], face[5], face[2], face[0], face[4], face[3]};
    swap(face, newface);
  }
  void rolld() {
    vi newface = {face[3], face[0], face[2], face[5], face[4], face[1]};
    swap(face, newface);
  }
  void rotl() {
    vi newface = {face[0], face[2], face[3], face[4], face[1], face[5]};
    swap(face, newface);
  }
  void rotr() {
    vi newface = {face[0], face[4], face[1], face[2], face[3], face[5]};
    swap(face, newface);
  }
};
bool operator==(Dice d1, Dice d2) {
  return d1.face == d2.face;
}
bool operator<(Dice d1, Dice d2) {
  return d1.face < d2.face;
}
struct Elm {
  Dice dice;
  int r, c;
  int pos;
  int d;
};
bool operator<(Elm e1, Elm e2) {
  return make_tuple(e1.d, e1.r, e1.c, e1.dice, e1.pos) < make_tuple(e2.d, e2.r, e2.c, e2.dice, e2.pos);
}
vi dr = {0, 0, -1, 1};
vi dc = {-1, 1, 0, 0};
bool solve() {
  bool ok = true;
  int n; cin >> n;
  vvi a(n, vi(6));
  for(int i=0;i<(n);++i) {
    for(int j=0;j<(6);++j) {
      cin >> a[i][j];
    }
  }
  for(int i=0;i<(n);++i) {
    for(int j=(i + 1);j<(n);++j) {
      Dice dice;
      dice.face = {a[i][0], a[i][1], a[i][3], a[i][4], a[i][2], a[i][5]};
      Dice dice2;
      dice2.face = {a[j][0], a[j][1], a[j][3], a[j][4], a[j][2], a[j][5]};
      for(int k=0;k<(2);++k) {
        for(int l=0;l<(4);++l) {
          for(int m=0;m<(4);++m) {
            ok &= dice.face != dice2.face;
            dice.rolll();
          }
          dice.rolld();
        }
        dice.rotl();
      }
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
}



Measured memory_bytes: 3240
s = input()
n = len(s)
a = 0
b = 0
for i in range(n):
	if ((i%2 == 0) and (s[i] == '0')):
		a += 1
	if ((i%2 == 1) and (s[i] == '1')):
		a += 1
	if ((i%2 == 0) and (s[i] == '1')):
		b += 1
	if ((i%2 == 1) and (s[i] == '0')):
		b += 1
print(min(a,b))


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

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        if (a % 2 == 1) cout << 0 << endl;
        else cout << -1 << endl;
    } else {
        ll cnt = 0;
        while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
            ll ta = a/2, tb = b/2, tc = c/2;
            a = tb + tc;
            b = ta + tc;
            c = tc + ta;
            cnt++;
        }
        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e6+100,mod=998244353;
ll power(ll n,ll k){
    if (k==0) return 1;
    if (k%2==1){
        ll x=power(n,k/2);
        return x*x%mod*n%mod;
    }
    ll x=power(n,k/2);
    return x*x%mod;
}
ll fac[N],fm[N];
ll ent(ll k,ll n){
    if (k<0 || k>n) return 0;
    if (k==0 || k==n) return 1;
    return fac[n]*fm[k]%mod*fm[n-k]%mod;
}
int32_t main(){
    fac[0]=1;
    for (int i=1;i<N;i++){
        fac[i]=fac[i-1]*i%mod;
        fm[i]=power(fac[i],mod-2);
    }
 //   cout << ent(3,5) << endl;
    ll ans=0;
    ll n,m;
    cin >> n >> m;
    ll z=3*m;
    for (int i=0;i<=min(n,m);i++){
        ll t=z-i;
        if (t%2==1) continue;
        ans+=ent(i,n)*ent(n-1,n-1+t/2)%mod;
    }
    for (int i=2*m+1;i<=3*m;i++){
        ll t=z-i;
        ans-=n*ent(n-2,n-2+t)%mod;
        ans+=mod;
        ans%=mod;
    }
    cout << ans << endl;
}


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

int main() {
  string s;
  int count;
  
  cin >> s;
  
  if(s == "000")
    count = 0;
  else if(s == "100" || s == "010" || s == "001")
    count = 1;
  else if(s == "110" || s == "011" || s == "101")
    count = 2;
  else if(s == "111")
    count = 3;
  
  cout << count << endl;
}

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

int main() {
  int a;
  int b;
  int c;
  int d;
  
  cin >> a;
  
  b = a / 100;
  c = (a - 100 * b) / 10;
  d = (a - 100 * b - 10 * c);
   
  cout << b + c + d << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int h, w;
	cin >> h >> w;

	string s[h];

	REP(i, h) cin >> s[i];

	REP(i, h){
		REP(j, w){
			if (s[i][j] == '#') continue;

			int num = 0;
			REP(d, 8){
				int ni = i + dx[d];
				int nj = j + dy[d];

				if (ni < 0 or h <= ni) continue;
				if (nj < 0 or w <= nj) continue;
				if (s[ni][nj] == '#'){
					num++;
				}
			}

			s[i][j] = num + '0';
		}
	}

	REP(i, h) cout << s[i] << endl;

}


Measured memory_bytes: 256
S = input()
S = S[::-1]
mod = 10 ** 9 + 7
N = len(S)
table = [[0] * 13 for _ in range(N + 1)]
table[0][0] = 1

dd = 1

for i in range(N):
    c = S[i] != '?'
    for j in range(13):
        for k in range(10):
            if c and int(S[i]) != k:
                continue
            table[i+1][(j + dd * k)  % 13] += table[i][j]
            table[i+1][(j + dd * k)  % 13] %= mod
    dd = (dd * 10) % 13

print(table[N][5])


Measured memory_bytes: 63524
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int x,y,z;
	cin >> x >> y >> z;
	swap(x,y);
	swap(x,z);
	cout << x << " " << y << " " << z << '\n'; 
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<int>> rel(n);
  for (int i = 0; i < n; i++){
    if (i == 0) a[i] == 0;
    else cin >> a[i];
  }

  for (int i = 1; i < n; i++){
    rel[a[i] - 1].push_back(i);
  }

  for (int i = 0; i < n; i++){
    cout << rel[i].size() << endl;
  }

}

Measured memory_bytes: 21084
C = [list(map(int, input().split())) for _ in range(3)]

flg = True
a1 = 0
b1 = C[0][0]
b2 = C[0][1]
b3 = C[0][2]

if not (C[1][0]-b1==C[1][1]-b2 and C[1][1]-b2==C[1][2]-b3):
    flg = False
if not (C[2][0]-b1==C[2][1]-b2 and C[2][1]-b2==C[2][2]-b3):
    flg = False

if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
N=int(input())
A=list(map(int,input().split()))

dict={}

for a in A:
    if a in dict.keys():
        dict[a]+=1
    else:
        dict[a]=1
dict[N]=0

for i in range(1,N+1):
    if i in dict.keys():
        print(dict[i])
    else:
        print(0)





Measured memory_bytes: 33432
#include <iostream>

using namespace std;

#define MAX 300010
long long mod = 998244353;
long long inv[MAX],fact[MAX],fi[MAX];

void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<MAX;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
}

void factinv(){
	int i;
	fact[0] = fi[0] = 1;
	for(i=1;i<MAX;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = (fi[i-1]*inv[i])%mod;
	}
}

long long comb(int n,int k){
	if(n<0 || k<0 || n<k){
		return 0;
	}else{
		return (fact[n]%mod*fi[k]%mod*fi[n-k]%mod)%mod;
	}
}
int main(){
	long long i,n,a,b,k,ans=0;
	cin >> n >> a >> b >>k;
	inverse();
	factinv();
	for(i=0;i<=n;i++){
		if(k-a*i>=0 && (k-a*i)%b==0){
			ans += (comb(n,i)*comb(n,(k-a*i)/b))%mod;
			ans = ans%mod;
		}
	}
	cout << ans << endl;
}
			

Measured memory_bytes: 7296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ1_6_A
{
    class Program
    {
        static void Main()//(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            for (int i = n-1; i >= 0; i--)
            {
                Console.Write(str[i]);
                if (i == 0) break;
                else
                {
                    Console.Write(" ");
                }
            }
 Console.Write("\n");
        }
    }
}



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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long n,a,i,sum=0;
    cin>>n>>a;
    long long b[n];
    for(i=0;i<n;i++)
    {
        cin>>b[i];
    }
    sort(b,b+n);
    for(i=0;i<n-a;i++)
    {
        sum=sum+b[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1792
<?php

    fscanf(STDIN,"%d",$N);
        $before1 = 2;
        $before_result = 1;


        if($N == 1){
            echo "1\n";
        }else{
            $l_now=0;
            for($i=1;$i<$N;$i++){
                $l_now = $before1+$before_result;
                $before1 = $before_result;
                $before_result = $l_now;
            }
            echo $l_now."\n";
    
        }
        


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
long long LCD(long long a,long long b){
	if(a<b) swap(a,b);
	while(b){
		long long temp = a%b;
		a = b;
		b = temp;
	}
	return a;
}
bool is_prime(long long num){
	for(long long i = 2; i*i<=num; i++){
		if(num%i==0) return false;
	}
	return true;
}
int main(){
	long long a,b;
	cin>>a>>b;
	vector<long long> divisors;
	a = LCD(a,b);
	for(long long i=1; i*i<=a; i++){
		if(a%i==0){
			divisors.push_back(i);
			if(a/i!=i) divisors.push_back(a/i);
		}
	}
	sort(divisors.begin(),divisors.end());
	int ret = 0;
	for(int i=0; i<divisors.size(); i++){
		if(is_prime(divisors[i])) ret++;
	}
	cout<<ret;
}


Measured memory_bytes: 3676
S = input()
if S.count('E') >= 1 and S.count('W') >= 1 and S.count('N') >= 1 and S.count('S') >= 1:
    print('Yes')
else:
    if S.count('E') == S.count('W') == 0 and S.count('N') >= 1 and S.count('S') >= 1:
        print('Yes')
    elif S.count('N') == S.count('S') == 0 and S.count('E') >= 1 and S.count('W') >= 1:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル

    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()

    a, b = map(int, input().split())

    a = make_divisors(a)
    b = make_divisors(b)

    # 公約数 = 一致する値。
    a_b_divisor = list(set(a) & set(b))

    a_b_divisor.sort()

    if len(a_b_divisor) <= 1:
        print(len(a_b_divisor))
        return

    # エラストテネスの篩
    aa = -1
    for i in a_b_divisor[1:]:
        if len(a_b_divisor) <= 1:
            break

        if i > a_b_divisor[-1] / 2:
            break

        aa += 1
        sieve = i

        new_list = []

        for j in a_b_divisor:
            if j <= i or not j % sieve == 0:
                new_list.append(j)

        a_b_divisor = new_list

    print(len(a_b_divisor))

# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """12 18"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """420 660"""
        output = """4"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """1 2019"""
        output = """1"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 52332
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  double a;
  double sum = 0;
  rep(i,n){
    cin >> a;
    sum += 1/a;
  }
  sum = 1/sum;
  printf("%lf\n", sum);
  return 0;
}


Measured memory_bytes: 256
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
if max(x)+1<=min(y):
    if max(x)+1<=Y and X+1<=min(y):
        print("No War")
    else:
         print("War")
else:
    print("War")

Measured memory_bytes: 3060
import math
from bisect import bisect


def primeFactors(n):
    ar = []
    for i in range(1, 101):
        ar.append(i * (i + 1) // 2)
    d = dict()
    while n % 2 == 0:
        if d.get(2) is None:
            d[2] = 1
        else:
            d[2] += 1
        n = n // 2
    for i in range(3, int(math.sqrt(n)) + 1, 2):
        while n % i == 0:
            if d.get(i) is None:
                d[i] = 1
            else:
                d[i] += 1
            n = n // i
    if n > 2:
        d[n] = 1
    cnt = 0
    for i in d.values():
        if i == 1:
            cnt += 1
        else:
            b = bisect(ar, i)
            cnt += b
    return cnt


print(primeFactors(int(input())))


Measured memory_bytes: 9236
N,M = [int(a) for a in input().split()]
A = []
B = []
for i in range(N):
  A.append(input())
for i in range(M):
  B.append(input())  

wa = len(A[0])
wb = len(B[0])
  
matched = False
for i1 in range(N - M + 1):
  for j1 in range(wa - wb +1):
    cnt = 0
    for i2 in range(M):
      #print(B[i2]," vs ", A[i1+i2][j1:j1+wb])
      if B[i2] == A[i1+i2][j1:j1+wb]:
        cnt += 1
    if cnt == M:
      matched = True
      break
          

if matched:
  print("Yes")
else:
  print("No")
      

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder text = new StringBuilder();
		while (true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				boolean nextChar = true;
				for (int i = 0; i < H; i++) {
					if(i % 2 == 0)
						nextChar = true;
					else
						nextChar = false;
					for (int t = 0; t < W; t++) {
						if (nextChar) {
							text.append("#");
							nextChar = false;
						} else {
							text.append(".");
							nextChar = true;
						}
					}
					text.append("\n");
				}
				text.append("\n");
			}
		}
	}
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = 0;
  ans += (N / (A + B)) * A + min(A, (N - (N / (A + B)) * (A + B)));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define PI 2*acos(0)
#define INF 1e17
#define mx 2*1000000+5
using namespace std;
const ll int p=1e9+7;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,ans;
    cin>>n;
    if(n%1000==0) ans=0;
    else ans=1000-n%1000;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll X;
    cin >> X;
    for(int i=1;pow(i,2)<=X;i++){
        if(X%i==0){
            for(int x=0;x<10000;x++){
                if(pow(x,4)+pow(x,3)*(x-i)+pow(x,2)*pow(x-i,2)+x*pow(x-i,3)+pow(x-i,4)==(X/i)){
                    cout << x << " " << x-i << endl;
                    return 0;
                }else{
                    if(pow(x,4)+pow(x,3)*(x-X/i)+pow(x,2)*pow(x-X/i,2)+x*pow(x-X/i,3)+pow(x-X/i,4)==i){
                        cout << x << " " << x-i << endl;
                        return 0;
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4224
n,k=map(int,input().split())
arr=list(map(int,input().split()))
cnt=[0]*(n+1)
cnt2=[]
for i in range(n):
  cnt[arr[i]]+=1
for i in range(1,n+1):
  if cnt[i]!=0:
    cnt2.append(cnt[i])
cnt2=sorted(cnt2)
if len(cnt2)<=k:
  print(0)
else:
  print(sum(cnt2[:len(cnt2)-k]))

Measured memory_bytes: 24836
N = int(input())
cut = 0
lis = [ a for a in range(1, N+1)]
while True:
  li_yojo = [ a % 2 for a in lis]
  if li_yojo.count(0) == 0:
    break
  else:
    lis = [ a / 2 for a in lis]
    cut += 1
        
print(2 ** (cut))

Measured memory_bytes: 3060
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
       mut A:[i64;N],
       Q:usize,
       query:[(i64,i64);Q],
    }

    let mut ans: usize = 0;
    let mut h = HashMap::new();

    for i in 0..N {
        let mut hp = h.entry(A[i]).or_insert(0);
        *hp += 1;
    }
    let mut sum = A.iter().fold(0, |a, x| a + x);
    for &(a, b) in &query {
        let mut z = 0;
        if let Some(x) = h.get(&a) {
            z = *x;
            sum += (b - a) * z;
            let mut hp = h.entry(a).or_insert(0);
            *hp = 0;
            let mut hp = h.entry(b).or_insert(0);
            *hp += z;
        }
        echo!(sum);
    }
}


Measured memory_bytes: 9600
import java.io.*;
 
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
    char[] c = br.readLine().toCharArray();
    
    for (char c1 : c){
      if (c1 == '7'){
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 32440
// AOJ 0212
#include<cstdio>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#define rep(i,a) for( int i = 0; i != (a); ++i )

typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;

const int INF = 10000000;

int c, n, m, s, d;	
std::vector<P> G[101];
int dist[101][11];

int dijkstra( int s )
{
	rep( i, 101 )
		rep( j, 11 )
			dist[i][j] = INF;
	dist[s][0] = 0;
	std::priority_queue<PP, std::vector<PP>, std::greater<PP> > pque;
	pque.push( PP( P( s, 0 ), 0 ) );
	while( !pque.empty() )
	{
		PP p = pque.top(); pque.pop();
		int v = p.first.first, cost = p.first.second, tic = p.second;

		if( dist[v][tic] < cost )
			continue;

		rep( i, G[v].size() )
		{
			P &e = G[v][i];

			if( dist[e.first][tic] > dist[v][tic]+e.second )
			{
				dist[e.first][tic] = dist[v][tic]+e.second;
				pque.push( PP( P( e.first, dist[e.first][tic] ), tic ) );
			}
		}

		if( tic < c ) rep( i, G[v].size() )
		{
			P &e = G[v][i];

			if( dist[e.first][tic+1] > dist[v][tic]+e.second/2 )
			{
				dist[e.first][tic+1] = dist[v][tic]+e.second/2;
				pque.push( PP( P( e.first, dist[e.first][tic+1] ), tic+1 ) );
			}
		}
	}

	return *std::min_element( dist[d], dist[d]+11 );
}

int main()
{
	while( scanf( "%d%d%d%d%d", &c, &n, &m, &s, &d ), c|n|m|s|d )
	{
		rep( i, 101 )
			G[i].clear();

		rep( i, m )
		{
			int a, b, f;
			scanf( "%d%d%d", &a, &b, &f );
			G[a].push_back( P( b, f ) );
			G[b].push_back( P( a, f ) );
		}

		printf( "%d\n", dijkstra( s ) );
	}

	return 0;
}

Measured memory_bytes: 1144
N, L = map(int, input().split())
apple_min = 1000
apple_sum = 0
ans = 0

for i in range(1, N + 1):
    if apple_min > abs(L + i - 1):
        apple_min = abs(L + i - 1)
        ans = L + i - 1 
    apple_sum += L + i - 1
    
print(apple_sum - ans)

Measured memory_bytes: 39664
#include<bits/stdc++.h>
#include<algorithm>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
int main()
{
  int N,K;
  ll ans=0;
  cin >> N >> K;
  vector<int> H(N);
  rep(i,N) cin >> H.at(i); 
  sort(H.begin(),H.end(),greater<int>());
  
  for(int i=K; i<N; i++) ans += H.at(i);
  cout << ans << endl;
}

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

int main_()
{
    int N;
    vector<int> As;
    cin >> N;
    copy_n(istream_iterator<int>(cin), N, back_inserter(As));
    auto as_sort(As);
    partial_sort(as_sort.begin(), as_sort.begin() + 2, as_sort.end(),
                 [](int a, int b) { return a > b; });

    vector<int> outs;
    transform(As.begin(), As.end(), back_inserter(outs),
              [&as_sort](int a) { return (a < as_sort[0] ? as_sort[0] : as_sort[1]); });

    for (auto out : outs)
    {
        printf("%d\n", out);
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 4084
import numpy as np
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
expect_list = np.array(p_list)
expect_list = (expect_list + 1)/2
sum_list = []
#print(expect_list)
sum=0
for i in range(K):
    sum += expect_list[i]

sum_list.append(sum)

for i in range(1,N-K+1):
    sum -= expect_list[i-1]
    sum += expect_list[i+K-1]
    sum_list.append(sum)

print(max(sum_list))

Measured memory_bytes: 33888
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 N; cin >> N;
    vector<i64> a(N + 1);
    rep(i, N+1) cin >> a[i];

    vector<i64> b(N);
    rep(i, N) cin >> b[i];

    i64 ans = 0;

    rep(i, N) {
        const i64 k = min(b[i], a[i]);
        a[i] -= k;
        b[i] -= k;
        ans += k;

        const i64 l = min(b[i], a[i+1]);
        a[i+1] -= l;
        ans += l;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8


int main(){
    ll N,K,A[57],C=0;cin >> N >> K;
    rep(i,N){
        cin >> A[i];
    }
    sort(A,A+N);
    reverse(A,A+N);
    rep(i,K){
        C+=A[i];
    }
    cout << C <<  endl;
}

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

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

    int lmax = 0, rmin = 999999;
    int L, R;
    for (int i = 0; i < M; ++i) {
        std::cin >> L >> R;

        lmax = std::max(lmax, L);
        rmin = std::min(rmin, R);
    }

    if (rmin < lmax) {
        std::printf("0\n");
    } else {
        std::printf("%d\n", rmin - lmax + 1);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
#include <functional>
 
using namespace std;
typedef long long ll;
// const ll INF = 1e18;

# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
# define pb push_back
 
string S;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
        return 0;
    }
    
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


int main(){
    int N; cin >> N;
    int ans = MM;
    for (int i = 1; i < N; i++){
        int t1 = i, t2 = N-i;
        int mx = 0;
        while (t1 > 0){
            mx += t1 % 10;
            t1 /= 10;
        }
        while (t2 > 0){
            mx += t2 % 10;
            t2 /= 10;
        }
        ans = min(mx,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>



int main(void){
    int A,B,K;
    scanf("%d %d %d",&A,&B,&K);
    if(B-A+1<2*K)for(int i=A;i<=B;i++)printf("%d\n",i);
    else {
        for(int i=A;i<A+K;i++)printf("%d\n",i);
        for(int i=B-K+1;i<=B;i++)printf("%d\n",i);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, a, b, p, d[MAX_N+5];
int fa[MAX_N+5], dep[MAX_N+5];
vector <int> G[MAX_N+5], seq, rev, ans;
void DFS(int u) {
	for (int v : G[u]) if (v ^ fa[u])
		fa[v] = u, dep[v] = dep[u]+1, DFS(v);
}
int main() {
	read(n);
	for (int i = 1, u, v; i < n; i++)
		read(u), read(v), d[u]++, d[v]++, 
		G[u].push_back(v), G[v].push_back(u);
	DFS(1);
	for (int i = 1; i <= n; i++)
		if (dep[i] > dep[a]) a = i;
	fa[a] = dep[a] = 0, DFS(a);
	for (int i = 1; i <= n; i++)
		if (dep[i] > dep[b]) b = i;
	for (int i = b; i; i = fa[i])
		if (i == a || i == b)
			seq.push_back(d[i]-1);
		else seq.push_back(d[i]-2);
	rev = seq, reverse(rev.begin(), rev.end());
	for (int i = 0; i < (int)seq.size(); i++)
		if (seq[i] < rev[i]) break;
		else if (seq[i] > rev[i])
			{seq = rev; break;}
	for (int c : seq) {
		p++;
		for (int i = 1; i <= c; i++)
			ans.push_back(p+i);
		ans.push_back(p), p += c;
	}
	if ((int)ans.size() < n)
		return puts("-1"), 0;
	for (int x : ans)
		printf("%d ", x);
	return puts(""), 0;
}


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

#define ll long long
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int H1,M1,H2,M2,K;
    cin>>H1>>M1>>H2>>M2>>K;
    cout<<max(0,(H2-H1)*60+(M2-M1)-K)<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>

vector<pair<ll, ll>> v;
ll func(ll k)
{
    ll n = v.size();
    ll ans = 0;
    forn(i, n)
    {
        bool flag = true;
        ll x = v[i].fi;
        forn(j, 31)
        {
#define getbit(x, i) (((x) >> (i)) & 1)
            if (!getbit(k, j) && getbit(x, j))
                flag = false;
        }
        if (flag)
            ans += v[i].se;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    v = vector<pair<ll, ll>>(n);
    forn(i, n) cin >> v[i].fi >> v[i].se;

    ll ans = func(k);
    forn(i, 31)
    {
        ll x = k;
        if (getbit(x, i))
        {
            x &= ((1LL << 32) - 1 - (1LL << i));
            x |= ((1LL << i) - 1);
            ans = max(ans, func(x));
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1920
#include <vector>
#include <iostream>
#include <iomanip>
#include <map>
#include <string.h>
#include <cstring>
#include <queue>
#include <limits>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <cmath>
#include <stdio.h>
#include <set>
#include <cstdio>
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define FOR(i, a) for(int i = 0; i < (a); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int N = 1e5 + 10;
double esp = 1e-10;
int n;
int a[105];
int main() {
    while (cin >> n) {
        for (int i = 0; i < n; i++) cin >> a[i];
        sort(a, a + n);
        vector<int> c;
        for (int i = 0; i < n; i++) {
            auto p = lower_bound(c.begin(), c.end(), a[i]);
            if (p == c.end()) c.push_back(a[i]);
            else *p = a[i];
        }
        cout << c.size() << endl;
    }
    return 0;
}




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

const int INF = 1e9 + 7;

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

  vector<pair<int,int>> a(n);
  for (int i = 0; i < n; i++) {
    int x,l;
    cin >> x >> l;

    int left = x - l;
    int right = x + l;
    a[i].first = right;
    a[i].second = left;
  }

  sort(a.begin(),a.end());
  int answer = 0;
  int last = -INF;

  for (int i = 0; i < n; i++) {
    int left = a[i].second;
    int right = a[i].first;

    if(left >= last) {
      answer++;
      last = right;
    }
  }

  cout << answer << '\n';

  return 0;
}


Measured memory_bytes: 4052
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    int ans = 0;
    int anser = 1;
    for (int i = 1; i <= n; i++) {
        int many = 0;
        int p = i;
        while (p % 2 == 0) {
            p /= 2;
            many++;
        }
        if (chmax(ans, many)) anser=i;
    }
    cout << anser << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i=(l); i<(r); ++i)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

// (x,y)∈[x-k+1, x]*[y-k+1, y]の範囲でimos[i][j]+=1と累積されるように値をセットする
void set_square(int x, int y, int k, vector<vector<int>> &imos){
    if(x<0 || y<0 || x>=3*k-1 || y>=3*k-1) return;
    imos[ max(0, x-k+1) ][ max(0, y-k+1) ] += 1;
    imos[ max(0, x-k+1) ][ min(y+1, 2*k) ] -= 1;
    imos[ min(x+1, 2*k) ][ max(0, y-k+1) ] -= 1;
    imos[ min(x+1, 2*k) ][ min(y+1, 2*k) ] += 1;
}

void set_imos(int x, int y, int k, vector<vector<int>> &imos){
    set_square(x, y, k, imos);
    set_square(x+k, y-k, k, imos);
    set_square(x-k, y-k, k, imos);
    set_square(x+k, y+k, k, imos);
    set_square(x-k, y+k, k, imos);
    set_square(x, y+2*k, k, imos);
}

int main(){
    int n, k; cin >> n >> k;
    // 入力を受け取り、扱いやすいように希望を同値変形して座標を圧縮する
    // 具体的には全ての希望を、「(x,y)∈[0,2k)*[0,2k)を黒に塗りたいな」という希望に同値変形する
    vector<int> x(n), y(n);
    rep(i, 0, n){
        cin >> x[i] >> y[i];
        char c; cin >> c;
        if(c=='W') x[i] += k;
        x[i]%=2*k; y[i]%=2*k;
    }

    // 市松模様は[0,2k)*[0,2k)のどこを黒い部分の左下にするかという情報で一意に定まる（全単射）ので、そのように表す
    // imos[i][j] := (i,j)が黒い部分の左下になるような市松模様を塗った時に叶えられる希望の数
    vector<vector<int>> imos(2*k+5, vector<int>(2*k+5, 0));
    rep(i, 0, n){
        // (x[i],y[i])を黒に塗れるような市松模様(X, Y)について、最後に累積した時に imos[X][Y]+=1 になるように重みを加算する
        set_imos(x[i], y[i], k, imos);
    }

    // 左→右へ累積
    rep(i, 0, 2*k) rep(j, 1, 2*k) imos[i][j] += imos[i][j-1];
    // （問題文の画像で）下→上へ累積
    rep(j, 0, 2*k) rep(i, 1, 2*k) imos[i][j] += imos[i-1][j];

    // 最大値の検索
    int ans=0;
    rep(i, 0, 2*k) rep(j, 0, 2*k) chmax(ans, imos[i][j]);

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 16768