akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

type Train = (i64, i64, i64);

fn main() {
    let n: usize = read();
    let trains: Vec<Train> = readn(n-1);

    for i in 0..n {
        let mut j = i;
        let mut now = 0;
        while j < n-1 {
            now = next(now, &trains[j]);
            j += 1;
        }
        println!("{}", now);
    }
}

fn next(now: i64, train: &Train) -> i64 {
    let to = max(now, train.1);
    let wait = (train.2 - (to-train.1) % train.2) % train.2;
    to + wait + train.0
}


Measured memory_bytes: 4352
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func solve(G [][]int, visited []bool, v, n int) int {
	if n == len(G) {
		return 1
	}
	visited[v] = true
	var res int
	for _, u := range G[v] {
		if visited[u] {
			continue
		}
		res += solve(G, visited, u, n+1)
	}
	visited[v] = false
	return res
}

func main() {
	defer stdout.Flush()
	n := readInt()
	m := readInt()
	G := make([][]int, n)
	for i := 0; i < m; i++ {
		a := readInt() - 1
		b := readInt() - 1
		G[a] = append(G[a], b)
		G[b] = append(G[b], a)
	}

	println(solve(G, make([]bool, n), 0, 1))
}

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


Measured memory_bytes: 640
n,d=map(int,input().split())
ans=0
x=[]
y=[]
check=0
e=0
for i in range(n):
    x.append(input())
    x[i]=x[i].split()
    for j in range(d):
        x[i][j]=int(x[i][j])
for z in range(1,n):
    for l in range(n-z):
        for k in range(d):
            e=x[l][k]-x[l+z][k]
            check+=e**2
        q=int(check**0.5)
        if q**2==check:
            ans+=1
            check=0
        else:
            check=0
print(ans)

Measured memory_bytes: 3188
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}

void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}

#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif

const double PI = acos(-1);
typedef long long ll;
#define int ll
#define fori(n) for(int i=0; i<int(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

void solve() {
    cini(n);
    cini(k);
    vb a(n);
    for(int i=0; i<k; i++) {
        cini(m);
        cinai(s, m);
        for(int j=0; j<m; j++) 
            a[s[j]-1]=true;
    }
    int ans=0;
    for(int i=0; i<n; i++)
        if(!a[i])
            ans++;

    cout<<ans<<endl;
}

signed main() {
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,ans=0;cin>>n;
  V<ll> v(n);
  rep(i,0,n)cin>>v[i];
  ll mn=LINF;
  rep(i,0,n){
    if(mn>v[i])ans++;
    chmin(mn,v[i]);
  }
  cout<<ans<<ENDL;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

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

using namespace std;

int main(){
  int N,M;
  while(cin >> N >> M){
    if(N==0 && M==0){
      break;
    }

    /*    else{
      cout << N << " " << M << endl;
    }
    */    

    int ban[N],dice[M];
    
    for(int k=0;k < N;k++){
      cin >> ban[k];
      //      cout << ban[k] << " ";
    }
    //    cout << endl;

    for(int j=0;j<M;j++){
      cin >> dice[j];
      //cout << dice[j] << " ";
    }
    //    cout << endl;
    int count = 1;
    int koma = 0;
    for(int l=0;l<M;l++){
      koma += dice[l];
      //koma += ban[koma];
      if(koma + 1 >= N){
	cout << count << endl;
	break;
      }
      else{
	koma += ban[koma];
	if(koma + 1 >= N){
	  cout << count << endl;
	  break;	
	}
	count++;
      }
    }
  } 
}

Measured memory_bytes: 0
a, b, c, x, y = map(int, input().split())

l = a*x + b*y
m = max(x,y)*2*c
if x >= y:
    n = y*2*c + (x-y)*a
else:
    n = x*2*c + (y-x)*b

print(min(l,m,n))

Measured memory_bytes: 3060
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int r;
  cin >> r;
  cout << r * 2 * acos(-1) << endl;
  return (0 ^ _ ^ 0);
}



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

using namespace std;

typedef long long lint;
lint gcd(lint a, lint b){
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return gcd(b, a%b);
}

lint lcm(lint a, lint b){
	lint ret = a/gcd(a, b);
	return ret*b;
}

int main(){
	cin.sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	lint ans = 1;
	for (int qq=0; qq<n; ++qq){
		lint x; cin >> x;
		ans = lcm(x, ans);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool isEven(int x){
    return (x%2==0);
}

int main(void){
  int a,b;
  
  cin >> a >> b;
  if (isEven(a) || isEven(b)) {
      cout << "Even";
  }
  else {
      cout << "Odd";
  }
}

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

int main()
{
	int n;
	cin >> n;
	int P[2*100001];
	for (int i = 0; i < n; ++i)
	{
		cin >> P[i];
	}
	int mi = (1<<30)-1;
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans += (P[i] <= mi);
		mi = min(mi, P[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
/*
    なせば大抵なんとかなる！
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vpd vector<pair<int,int>>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int>
#define pd pair<int,int>
#define qd queue<int>
#define qpd queue<pair<int,int>>
#define fr front
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forineq(a,b,c) for(int a=b ; a<=c ; a++)
#define forde(a,b,c) for(int a=b ; a>=c ; a--)
#define UPC(oo) (oo>='A' && oo<='Z')
#define LWC(oo) (oo>='a' && oo<='z')
#define DGT(oo) (oo>='0' && oo<='9')
#define UPCVOC(oo) (oo=='A' || oo=='E' || oo=='I' || oo=='U' || oo=='O')
#define LWCVOC(oo) (oo=='a' || oo=='e' || oo=='i' || oo=='u' || oo=='o')

inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void sctlld(LL &a,LL &b,LL &c){scanf("%I64d %I64d %I64d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}

inline void prd(int a){printf("%d",a);};
inline void prdd(int a,int b){printf("%d %d",a,b);};
inline void prtd(int a, int b, int c){printf("%d %d %d",a,b,c);};
inline void prtlld(LL a, LL b, LL c){printf("%I64d %I64d %I64d",a,b,c);};
inline void prdlld(LL a, LL b){printf("%I64d %I64d",a,b);};
inline void prlld(LL a){printf("%I64d",a);};

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	int x,y;
	scdd(x,y);
	string a[2000];
	forin(i,0,x)
	{
		cin>>a[i];
	}
	forin(i,0,y+2)
	{
		cout<<"#";
	}
	newline;
	forin(i,0,x)
	{
		cout<<"#"<<a[i]<<"#"<<endl;
	}
	forin(i,0,y+2)
	{
		cout<<"#";
	}
	newline;
	return 0;
}


Measured memory_bytes: 256
s = input()
num = len(s)
a = [0]*(num+1)

for i in range(num):
    if s[i] is '<':
        a[i+1] = max(a[i+1], a[i]+1)

for i in range(1, num+1):
    if s[-i] is '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
print(sum(a))


Measured memory_bytes: 29064
'''
参考
https://note.com/sdestiny/n/nbd01567e6f7a
テレポート回数=Kは制約で
1<=K<=10**18
とされているため、愚直にシミュレーションしていると実行時間制限を超過してしまう
ただし、町の数=Nは
2<=N<=2*10**5
となっており実行時間制限に影響はないと思われる
---
テレポータが示す転送先=dstと、各町の訪問回数を参照しながら、
・訪問した町=Aのインデックスの記録=visit
・各町の訪問回数をカウントアップ（0→1）=cnt
をすると、どこかで必ず2回目に訪問する町が出現する⇒ループ発生
---
ループ発生したら記録先を切り替え、
・ループ発生以降に訪問した町=Aのインデックスの記録=loop
・各町の訪問回数をカウントアップ（1→2）=cnt
を同様に行う
---
カウントが「2」となっている町が次の訪問箇所となったら、記録とカウントを中止する（ループ終端）
---
1.Kから、ループ終端前までの回数=len(visit)+len(loop)を減算
2.上記「1.」の数値を、ループしている町の数=len(loop)で割った余り=ans
が示すインデックスに該当する、ループ発生以降に訪問する町=loop[ans]+1が解となる
（Kは考慮せずとも、ループはどこかで必ず発生するため記録処理が無限ループになることはない）
※ループ発生前にテレポートが終了する場合：len(visit)>Kは、そのままvisit[K]+1が解となる
'''

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

dst= 0          # テレポータが示す訪問先（インデックスにするため-1する）
visit = []      # ループ発生前に訪問した町のインデックスを記録
loop = []       # ループ発生以降に訪問した町のインデックスを記録
cnt = [0] * N   # 各町の訪問回数

while cnt[dst] < 2:         # 訪問先が3回目となったら終了
    if cnt[dst] == 0:       # 未訪問（1回目の訪問）
        visit.append(dst)
    else:                   # 1度訪問済（2回目の訪問=ループ発生以降）
        loop.append(dst)
    cnt[dst] += 1
    dst = A[dst] - 1        # その町にあるテレポータが指定する訪問先（インデックスなので-1する）

if len(visit) > K:
    print(visit[K]+1)
else:
    tmp = K - len(visit) - len(loop)
    ans = tmp % len(loop)
    print(loop[ans]+1)


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

int main(void) {
    string S;
    int count = 0;
    
    cin >> S;
    
    for (int i = 0; i < S.length() / 2; i ++) {
        if (S[i] != S[S.length() - 1 - i]) {
            count ++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
import queue
n=int(input())
r=[[] for i in range(n)]
d=[[] for i in range(n)]

for i in range(n-1):
    line=input().split()
    a=int(line[0])-1
    b=int(line[1])-1
    c=int(line[2])
    r[a].append(b)
    r[b].append(a)
    d[a].append(c)
    d[b].append(c)

line=input().split()
q=int(line[0])
k=int(line[1])-1

dist=[-1 for i in range(n)]

qd=queue.Queue()
qn=queue.Queue()
qd.put(0)
qn.put(k)

while not qn.empty():
    dd=qd.get()
    nn=qn.get()
    dist[nn]=dd
    for i in range(len(r[nn])):
        if dist[r[nn][i]]!=-1:
            continue
        qd.put(dd+d[nn][i])
        qn.put(r[nn][i])

for i in range(q):
    line=input().split()
    x=int(line[0])-1
    y=int(line[1])-1
    print(dist[x]+dist[y])


Measured memory_bytes: 104988
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int n,m,X,Y;
  std::cin >> n >> m >> X >> Y;
  int x[110],y[110];
  for(int i=0; i<n; i++) std::cin >> x[i];
  for(int i=0; i<m; i++)std::cin >> y[i];
  bool f=true;
  sort(x,x+n);
  sort(y,y+m);
  if(y[0]-x[n-1]>0 && y[0]>=X+2 && x[n-1]<=Y-2 ) std::cout << "No War" << '\n';
  else std::cout << "War" << '\n';
  return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = [0]*n
for i in range(n):
    a, b = map(str, input().split())
    b = int(b)
    ans[i] = [i+1, a, b]
ans.sort(key=lambda x: (x[1], -x[2]))
for j in ans:
    print(j[0])

Measured memory_bytes: 9088
N, W = map(int, input().split(" "))
items = {i: [] for i in range(4)}
w1 = -1
for _ in range(N):
    w, v = map(int, input().split(" "))
    if w1 == -1:
        w1 = w
    items[w - w1].append(v)

for i in range(4):
    items[i].sort()
    items[i].append(0)
    items[i].reverse()
    for j in range(1, len(items[i])):
        items[i][j] += items[i][j - 1]

ans = 0
for i in range(len(items[3])):
    if i * (w1 + 3) > W:
        break
    for j in range(len(items[2])):
        if i * (w1 + 3) + j * (w1 + 2) > W:
            break
        for k in range(len(items[1])):
            if i * (w1 + 3) + j * (w1 + 2) + k * (w1 + 1) > W:
                break
            w_three = (W - i * (w1 + 3) - j * (w1 + 2) - k * (w1 + 1)) // w1
            w_three = min(len(items[0]) - 1, w_three)
            ans = max(items[3][i] + items[2][j] + items[1][k] + items[0][w_three], ans)
print(ans)

Measured memory_bytes: 40048
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define MAX 1000000007
int main()
{
    string c;
    cin >> c;
    if(c[2]==c[3] && c[4]==c[5])
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int m,f,r;
    char grade;
    while(true){
        scanf("%d %d %d",&m,&f,&r);
        if(m == -1 && f == -1 && r == -1) break;
        if(m == -1 || f == -1){
            grade = 'F';
        }else if(m+f >= 80){
            grade = 'A';
        }else if(m+f >= 65){
            grade = 'B';
        }else if(m+f >= 50){
            grade = 'C';
        }else if(m+f >= 30){
            grade = (r >= 50)? 'C':'D';
        }else{
            grade = 'F';
        }
        printf("%c\n",grade);
    }
}


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

int main() {
   int N, Y;
   int A = -1, B = -1, C = -1;
   cin >> N >> Y;
   for(int a = 0; a <= N; ++a){
        for(int b = 0; b + a <= N; ++b){
            int c = N - a - b;
                int total = (a * 10000) + (b * 5000) + (1000 * c);
               if (Y == total){
                A = a;
                B = b;
                C = c;
               }
        }
    }
    cout << A << " " << B << " " << C << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  ll n;
  cin >> n;
  vector<char> p(26);
  rep(i, 26) p[i] = 'a'+i;
  string ans;
  for(int i=0; n>0; i++) {
    n--;
    ans += p[n%26];
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

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

using namespace std ;
int n , m , ans = 0 ,a[120000] ;
int main () {
	cin >> n ;int maxx = 0 , ans = 0 ;
	for(int i = 1 ; i <= n ; i ++) {
		cin >> a[i] ;
		if(a[i] <= a[i-1]) maxx ++ , ans = max(maxx,ans) ;
		else maxx = 0 ;
	}
	cout << ans << endl ;
	return 0 ;
}	

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        if(n == 1){
            pw.println(2);
        }else{
            pw.println(n % 2 == 0 ? n : 2*n);
        }
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25332
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
	if (a < b) return gcd(b, a);
	if (b == 0) return a;
	return gcd(b, a % b);
}
bitset<1000001> bs;
vector<long long> primes;
void sieve() {
	bs.set();
	bs[0] = bs[1] = 0;
	for (long long i = 2; i <= 1000000; ++i) {
		if (bs[i]) {
			primes.push_back(i);
			for (long long j = i * i; j <= 1000000; j += i) bs[j] = 0;
		}
	}
}
int main() {
	sieve();
	long long a, b,g, ans = 1;
	cin>>a>>b;
	g = gcd(a, b);
	for (long long i: primes) {
		if (g % i == 0) ++ans;
		while (g % i == 0) g /= i;
	}
	if (g != 1) ++ans;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1528
#include <iostream>

using namespace std;

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

int main()
{
    int h, w, cnt, a[510][510], ans[300000][4];
    cin >> h >> w;
    REP(i, h)
    REP(j, w)
    cin >> a[i][j];

    cnt = 0;
    REP(i, h)
    REP(j, w)
    {
        if (a[i][i % 2 == 0 ? j : w - j - 1] % 2 == 0)
            continue;

        if (j == w - 1)
        {
            if (i < h - 1)
                ans[cnt][0] = i, ans[cnt][1] = i % 2 == 0 ? j : w - j - 1, ans[cnt][2] = i + 1, ans[cnt][3] = i % 2 == 0 ? w - 1 : 0, a[i + 1][i % 2 == 0 ? w - 1 : 0]++, cnt++;
        }
        else
            ans[cnt][0] = i, ans[cnt][1] = i % 2 == 0 ? j : w - j - 1, ans[cnt][2] = i, ans[cnt][3] = i % 2 == 0 ? j + 1 : w - j - 2, a[i][i % 2 == 0 ? j + 1 : w - j - 2]++, cnt++;
    }

    cout << cnt << endl;
    REP(i, cnt)
    cout << ans[i][0] + 1 << " " << ans[i][1] + 1 << " " << ans[i][2] + 1 << " " << ans[i][3] + 1 << endl;

    return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <list>
#include <vector>

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

	std::list<int> b(n);
	for (auto&& e : b) {
		std::cin >> e;
	}

	std::vector<int> ans;
	ans.reserve(n);
	while (!b.empty()) {
		auto it = b.rbegin();
		int idx = b.size(); // 1-indexed
		bool found = false;

		for (; it != b.rend(); ++it, --idx) {
			if (*it == idx) {
				ans.push_back(idx);
				b.erase(--(it.base()));
				found = true;
				break;
			}
		}

		if (!found) {
			std::cout << -1 << std::endl;
			return 0;
		}
	}

	for (int i = ans.size() - 1; i >= 0; --i)
		std::cout << ans[i] << std::endl;
}

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

int main(){
  int n1,n2,d1,d2;
  cin >> n1 >> d1;
  cin >> n2 >> d2;
  if(d2==1){
    cout << 1 << endl;
    return 0;
  }
  else{
    cout << 0 << endl;
      return 0;
  }
}
    


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



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

  
  cout << min(n*a, b) << endl;
  
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  string s;cin>>s;
  int ret = 0;
  int tmp = 0;
  for(int i = 0; s.size() > i; i++){
    
  	if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
    	tmp++;
    }else{
    	ret = max(ret,tmp);
      	tmp = 0;
    }
  }
  ret = max(ret,tmp);
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep_rev(i, n) for (int i = n-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}

template<class... T>
void debug_print(T... args){
    vector<lint> tmp = initializer_list<lint>{args...};
    print_vec(all(tmp));
}
template<class T>
void print(T a){ cout << a << endl;}

vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int ord(char x){ return (int)(x - 'a');}
char chr(lint x){ return (char)(x + (lint)('a'));}
lint mod = 1e9+7;
// lint mod = 

lint sum(vlint a){lint ret = 0; for(auto&& v:a) ret += v; return ret;}
lint vmini(vlint a, lint &index){
    lint ret = LLONG_MAX;
    rep(i, Size(a)){ if (chmin(ret, a[i])) index = i;}
    return ret;
}
lint vmaxi(vlint a, lint &index){
    lint ret = -LLONG_MAX;
    rep(i, Size(a)){ if (chmax(ret, a[i])) index = i;}
    return ret;
}

lint vmin(vlint a){
    lint ret = LLONG_MAX; for (auto && v : a) chmin(ret, v); return ret;
}
lint vmax(vlint a){
    lint ret = -LLONG_MAX; for (auto && v : a) chmax(ret, v); return ret;
}


vlint base_3(int k){
    vlint ret; while (k > 0){ ret.pb(k % 3); k /= 3;} reverse(all(ret)); return ret;
}
map<lint, lint> trial_division(lint n){
    map<lint, lint> factor;
    lint tmp = (lint)(sqrt(n)) + 1;
    for (lint i = 2; i < tmp; ++i){
        while (n % i == 0){
            n /= i;
            factor[i] ++;
        }
    }
    if(n != 1) factor[n] ++;
    return factor;
}

int main(){
    STR(s);
    int cnt = 0; int ans = -1;
    rep(i, Size(s)){
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C'){
            cnt++;
        }
        else
        {
            chmax(ans, cnt); cnt= 0;
        }
    }
    chmax(ans, cnt);
    print(ans);
    
    
}


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

using namespace std;

int x, y, kl, arr[100];

int main(){
    cin >> x >> y;
    arr[x]++;
    arr[y]++;
    cin >> x >> y;
    arr[x]++;
    arr[y]++;
    cin >> x >> y;
    arr[x]++;
    arr[y]++;


    if(arr[1] % 2 == 1)kl++;
    if(arr[2] % 2 == 1)kl++;
    if(arr[3] % 2 == 1)kl++;
    if(arr[4] % 2 == 1)kl++;

    if(kl > 2){
        cout << "NO";
    } else{
        cout << "YES";
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int ab=a-b;

		if(ab<0) {
			ab=-ab;
		}
		int bc=b-c;
		if(bc<0) {
			bc=-bc;
		}
		int ac=a-c;
		if(ac<0) {
			ac=-ac;
		}

		if(ac<=d||(ab<=d&&bc<=d)) {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}




	}
}


Measured memory_bytes: 21972
from collections import defaultdict, deque
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


a, b = LI()
if (a == 1 and b == 1) or a == b:
    print('Draw')
elif a == 1:
    print('Alice')
elif b == 1:
    print('Bob')
elif a > b:
    print('Alice')
else:
    print('Bob')

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

int main(void){
   int N;
   cin>>N;
   vector<int> s(N);
   for(int i=0;i<N;i++){
      cin>>s[i];
   }
   int sum=0;
   for(int i=0;i<N;i++){
      sum+=s[i];
   }
   int ans=-1;
   if(sum%10!=0){
      cout<<sum<<endl;
      return 0;
   }else{
      for(int i=0;i<N;i++){
         int temp=sum;
         temp=temp-s[i];
         if(temp%10==0) temp=0;
         ans=max(ans,temp);
      }
      cout<<ans<<endl;
   }
   return 0;
}



Measured memory_bytes: 256
# coding: utf-8

import heapq


class Dijkstra:

    """
    Dijkstra's algorithm: find the shortest path from a vertex
    O(E + log(V))
    verified:
        https://onlinejudge.u-aizu.ac.jp/#/courses/lesson/1/ALDS1/12/ALDS1_12_B
    """

    def __init__(self, V, G, INF=float("inf")):

        """
        V: the number of vertexes
        E: adjacency list (all edge in G must be 0 or positive)
        INF: Infinity distance
        """
        self.V = V
        self.G = G
        self.INF = INF
        self.distance, self.prev = list(), list()


    def dijkstra(self, start):

        Q = list()
        self.distance = [self.INF for _ in range(self.V)]
        self.prev = [-1 for _ in range(self.V)]

        self.distance[start] = 0
        heapq.heappush(Q, (0, start))

        while len(Q) > 0:
            dist, from_v = heapq.heappop(Q)
            if self.distance[from_v] < dist:
                continue
            for to_v, nxt_dist in self.G[from_v]:
                if self.distance[from_v] + nxt_dist >= self.distance[to_v]:
                    continue
                self.distance[to_v] = self.distance[from_v] + nxt_dist
                heapq.heappush(Q, (self.distance[to_v], to_v))
                self.prev[to_v] = from_v
        
        return self.distance


    def get_path(self, goal):

        path = [goal]
        while self.prev[goal] != -1:
            path.append(prev[goal])
            goal = self.prev[end]

        return path[::-1]


if __name__ == "__main__":
    
    """
    an example of use
    """

    n = int(input())
    g = [[] for _ in range(n)]
    for _ in range(n):
        v, _, *e = map(int, input().split())
        for u, d in zip(e[::2], e[1::2]):
            g[v].append((u, d))
 

    dist = Dijkstra(n, g).dijkstra(0)
    for i, d in enumerate(dist):
        print(i, d)



Measured memory_bytes: 68740
#include<iostream>

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  if(k > (n-2)*(n-1)/2){
    cout << -1 << endl;
    return 0;
  }
  int edge = n - 1 + ((n-2)*(n-1)/2 - k);
  cout << edge << endl;
  for(int i = 1; i < n; i++){
    cout << 1 << ' ' << i+1 << endl;
  }
  int count = 0;
  for(int i = 1; i < n; i++){
    for(int j = i+1; j < n; j++){
      if(count == ((n-2)*(n-1)/2 - k)){
        return 0;
      }
      count++;
      cout << i+1 << ' ' << j+1 << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int gcd(int p, int q){
    if(p%q == 0) return q;
    return gcd(q,p%q);
}

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

   int l=0;
   rep(a,k) rep(b,k) rep(c,k) l += gcd(a+1,gcd(b+1,c+1));
   cout << l << endl;
   
 return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define vuni(v) v.erase(unique(v.begin(), v.end()), v.end());
#define mins(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9 + 7;

int main() {
    int n, x, l, sum, i;
    cin >> n >> x;
    sum = 0;
    for(i = 0; i < n; i++) {
        cin >> l;
        sum += l;
        if(sum > x) {
            break;
        }
    }
    cout << i + 1 << endl;
    return 0;
}

Measured memory_bytes: 3628
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    tmp = input.split("\n");
    N = Number(tmp[0]);
    a = tmp[1].split(" ");
    a = a.map(Number);
    count = 0;
    for(i=0; i<N; i++){
        
        while(true){
            if( (a[i]%2) ==0){
                a[i]= (a[i] / 2);
                count += 1;

            }else{
                break;
            }
        }
    }
    console.log(count);
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7756
// verified at https://judge.yosupo.jp/submission/3400
#ifndef Union_find_hpp
#define Union_find_hpp

#include <cassert>
#include <cstddef>
#include <vector>

class union_find
{
    std::vector<int> link;

public:
    explicit union_find(const size_t n) : link(n, -1) {}

    size_t find(size_t x)
    {
        assert(x < size());
        while(link[x] >= 0)
        {
            if(link[link[x]] >= 0) link[x] = link[link[x]];
            x = link[x];
        }
        return x;
    }

    size_t size() const { return link.size(); }

    size_t size(const size_t x)
    {
        assert(x < size());
        return -link[find(x)];
    }

    bool same(const size_t x, const size_t y)
    {
        assert(x < size() && y < size());
        return find(x) == find(y);
    }

    size_t unite(size_t x, size_t y)
    {
        assert(x < size() && y < size());
        if((x = find(x)) != (y = find(y)))
        {
            if(link[x] > link[y]) std::swap(x, y);
            link[x] += link[y];
            link[y] = x;
        }
        return x;
    }
}; // class union_find

#endif // Union_find_hpp

#include <iostream>
#include <tuple>

using namespace std;

int main(int argc, char *argv[])
{
    std::ios::sync_with_stdio(false), std::cin.tie(nullptr);

    int n,h,w; cin>>n>>h>>w;
    vector<vector<pair<int,int>>> cards(100000);
    for(int i=n,r,c,a; i--; )
    {
        cin>>r>>c>>a; --r,--c;
        cards[a].emplace_back(r,c+h);
    }
    union_find uf(h+w);
    long long ans{};
    bool ext[2<<17]={};
    for(int i=100000; i; --i)
    {
        for(auto&& e:cards[i])
        {
            int r,c; tie(r,c)=e;
            r=uf.find(r),c=uf.find(c);
            if(r!=c)
            {
                if(ext[r] and ext[c]) continue;
                ext[uf.unite(r,c)]=ext[r]||ext[c];
                ans+=i;
            }
            else if(!ext[r])
            {
                ext[r]=true;
                ans+=i;
            }
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a;
  long long s;
  for(int i=0;i<n; i++){
    int ai;
    cin>>ai;
    a.push_back(ai);
    s +=ai;
  }
  for(int i=1; i<n; i +=2){
    s =s-2*a.at(i);
  }
  cout<<s<<" ";
  int l=s;
  for(int i=0; i<n-1; i++){
    long long r=2*a.at(i)-l;
    cout<<r<<" ";
    l=r;
  } 
}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
   int a,b; cin >> a >> b;
   cout << a*b << "\n";
}

Measured memory_bytes: 3636
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import Counter 
def main():
    N = int(readline())
    S = readline().rstrip().decode()
    d = Counter(S)
    sg = d['R']*d['G']*d['B']
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            if (i+j)%2 == 0:
                m = (i+j)//2
                if (S[i]!=S[j]) and (S[j]!=S[m]) and (S[m]!=S[i]):
                    cnt += 1
    print(sg-cnt)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9520
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  LL n, m; cin >> n >> m;
  string s, t; cin >> s >> t;
  LL g = __gcd(n, m);
  for (int ds = n / g, dm = m / g, i, j; i < n; i += ds, j += dm) {
    if (s[i] != t[j]) cout << -1 << '\n', exit(0);
  }
  cout << n * m / __gcd(n, m) << '\n';
}


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



int main() {
    int a, b;
    cin >> a >> b;
    
    int ans = max(a+b, a-b);
    ans = max(ans, a*b);
    
    cout << ans << endl;
    
    
    return 0;
}




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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define SUBL freopen("/home/ajinkya/Desktop/input.txt","r",stdin); freopen("/home/ajinkya/Desktop/output.txt","w",stdout); 
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;




int main()
{
    fastio 
    // SUBL
  	int k, x;
  	cin >> k >> x;
  	int l, h;
  	l = max(-1000000, x-k+1);
  	h = min(1000000, x+k-1);
  	for(int i=l; i<=h; i++) cout << i << " ";
    return 0;
}         	

Measured memory_bytes: 256
n=int(input())
a=[input() for _ in range(n)]
m=int(input())
b=[input() for _ in range(m)]
da={}
for word in a:
    da[word]=a.count(word)
for i in b:
    if i in da.keys():
        da[i]-=1
if max(da.values())>=0:
    print(max(da.values()))
else:
    print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
int main() {
    int n;
    scanf("%d", &n);

    // |A1−(x+1)|+|A2−(x+1)|+⋯+|AN−(x+N)|をBi=Ai−i として式変形してくと|x−B1|+|x−B2|+⋯+|x−BN|になる
    vector<ll> a(n), b(n);
    rep(i, n) scanf("%lld", &a[i]), b[i] = a[i] - i;

    // |x-a|+|x-b|+|x-c|+...を最小にする x は、a,b,cが小さい順になっていたらその中央値
    sort(b.begin(), b.end());
    ll x = b[n / 2];

    ll res = 0;
    rep(i, n) res += max(x - b[i], -x + b[i]);  // |A| = max(A, -A)
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 6368
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	ll K, A, B;

	cin >> K >> A >> B;

	ll cnt = 0;
	ll bis = 1;

	ll add = B - A;
	if (add > 2)
	{
		if (K >= A - 1)
		{
			cnt += A - 1;
			bis += A - 1;
		}
		else
		{
			cnt += K;
			bis += K;
		}

		ll n_add = (K - cnt) / 2;
		if (n_add >= 1)
		{
			cnt += n_add * 2;
			bis += n_add * add;
		}

		if (K - cnt >= 1)
		{
			bis += K - cnt;
			cnt += K - cnt;
		}
	}
	else
	{
		cnt += K;
		bis += K;
	}

	cout << bis << endl;


	//system("pause");
}


Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    num = c
    lis = list(map(int,input().split()))
    for j in range(m):
        num += b[j] * lis[j]
    if num > 0:ans += 1
print(ans)

Measured memory_bytes: 3060
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto k = readln.chomp.to!long, n = 50;

  auto kd = k/n, km = k%n;
  auto a = new long[](n);
  a[] = n-1+kd;
  foreach (i; 0..km) {
    a[] -= 1;
    a[i] += n+1;
  }

  writeln(n);
  foreach (i, ai; a)
    write(ai, i < n-1 ? " " : "");
  writeln;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

import heapq


class PriorityQueue:
    class Reverse:
        def __init__(self, val):
            self.val = val

        def __lt__(self, other):
            return self.val > other.val

        def __repr__(self):
            return repr(self.val)

    def __init__(self, x=None, desc=False):
        if not x:
            x = []
        if desc:
            for i in range(len(x)):
                x[i] = self.Reverse(x[i])
        self._desc = desc
        self._container = x
        heapq.heapify(self._container)

    @property
    def is_empty(self):
        return not self._container

    def pop(self):
        if self._desc:
            return heapq.heappop(self._container).val
        else:
            return heapq.heappop(self._container)

    def push(self, item):
        if self._desc:
            heapq.heappush(self._container, self.Reverse(item))
        else:
            heapq.heappush(self._container, item)

    def top(self):
        if self._desc:
            return self._container[0].val
        else:
            return self._container[0]

    def sum(self):
        return sum(self._container)

    def __len__(self):
        return len(self._container)


def main():
    from operator import itemgetter

    n, k = list(map(int, readline().split()))
    sushis_original = [list(map(int, readline().split())) for _ in range(n)]

    sushis_original.sort(key=itemgetter(1))
    sushis_original.sort(key=itemgetter(0))

    new_type = 0
    prev = -1
    for i in range(n):
        cur = sushis_original[i][0]
        if prev != cur:
            new_type += 1
        if cur > new_type:
            sushis_original[i][0] = new_type
        prev = cur

    type_num = sushis_original[-1][0]

    sushis = {i: [] for i in range(1, type_num + 1)}

    for sushi_type, val in sushis_original:
        sushis[sushi_type].append(val)

    eat_sushis = PriorityQueue()
    rem_sushis = PriorityQueue(desc=True)
    rem = k

    if rem >= type_num:
        for i in range(1, type_num + 1):
            eat_sushis.push(sushis[i].pop())
        rem -= type_num
        for vals in sushis.values():
            for val in vals:
                rem_sushis.push(val)
        for _ in range(rem):
            eat_sushis.push(rem_sushis.pop())
    else:
        for i in range(1, type_num + 1):
            eat_sushis.push(sushis[i].pop())
        discard_num = type_num - k
        for _ in range(discard_num):
            eat_sushis.pop()
        for vals in sushis.values():
            for val in vals:
                rem_sushis.push(val)

    cur_type = min(k, type_num)
    sub_next = 2 * cur_type - 1

    while rem_sushis:
        cur_val = eat_sushis.top()
        new_val = rem_sushis.top()
        diff = new_val - cur_val
        if diff >= sub_next:
            eat_sushis.pop()
            eat_sushis.push(rem_sushis.pop())
            cur_type -= 1
            sub_next = 2 * cur_type - 1
        else:
            break

    ans = cur_type ** 2 + eat_sushis.sum()

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    int A,B,C,D,E;
    cin >> A >> B >> C >> D >> E;
    if(A==0){
        cout << 1 << endl;
    }
    else if(B==0){
        cout << 2 << endl;
    }
    else if(C==0){
        cout << 3 << endl;
    }
    else if(D==0){
        cout << 4 << endl;
    }
    else if(E==0){
        cout << 5 << endl;
    }
}

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

using namespace std;

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

#define int ll

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

	int ans = 0;
	for(int i=1;i<=n;i++){
		int j=n-i;
		if(j<=i) break;
		else ans++;
	}

	cout << ans << endl;

	return 0;
}


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


using ll = long long int;
using namespace std;





int main()
{
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	
	int A, B, i;
	
	cin >> A >> B;
	for(i = 1; i < 2000; ++i)
	{
		if ((i * 2 / 25) == A && (i / 10) == B)
		{
			cout << i;
			return 0;
		}
	}
	cout << -1;
	
	return 0;
}

Measured memory_bytes: 256