akhauriyash/Code-Regression huggingface dataset:
let nmq = readLine()!.split(separator: " ").map { Int($0)! }
let (n, m, q) = (nmq[0], nmq[1], nmq[2])
var a = Array(repeating: 0, count: q)
var b = Array(repeating: 0, count: q)
var c = Array(repeating: 0, count: q)
var d = Array(repeating: 0, count: q)
(0..<q).forEach { i in
  let abcd = readLine()!.split(separator: " ").map { Int($0)! }
  a[i] = abcd[0] - 1
  b[i] = abcd[1] - 1
  c[i] = abcd[2]
  d[i] = abcd[3]
}

func combinations<T: Collection>(_ collection: T, _ length: Int) -> [[T.Element]]? {
  let collection = Array(collection)
  let count = collection.count
  if count < length { return nil }
  var dict = [Int: [Int: [[T.Element]]]]()
  func r(_ index: Int, _ length: Int) -> [[T.Element]] {
    if let result = dict[index]?[length] { return result }
    if length == 0 || index + length > count { return [[]] }
    let result = (index...(count-length)).flatMap { i in
      r(i + 1, length - 1).map { item in [collection[i]] + item }
    }
    dict[index] = dict[index] ?? [Int: [[T.Element]]]()
    dict[index]?[length] = result
    return result
  }
  return r(0, length)
}

let result = combinations(1...m+n-1, n)?.map {
  $0.enumerated().map { $1 - $0 }
}.map { (array: [Int]) -> Int in
  (0..<q).filter {
    array[b[$0]] - array[a[$0]] == c[$0]
  }.map { d[$0] }.reduce(0, +)
}.max() ?? -1

print(result)


Measured memory_bytes: 40912
fn main() {
    let a = vec![
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4,
        1, 51,
    ];
    let k: usize = read();
    println!("{}", a[k - 1]);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = String.valueOf(n);
		char[] ss = s.toCharArray();
		int count = 0;
		for(int i=0; i<ss.length; i++) {
			if(ss[i]=='2') {
				count++;
			}else {
				continue;
			}
		}
		System.out.println(count);
	}
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll x,y; cin>>x>>y;
  if((y-2*x)%2!=0){
    cout<<"No"<<endl;
    return 0;
  }
  ll b=(y-2*x)/2;
  ll a=x-b;
  if(a<0 || b<0){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3636
n, k = map(int, input().split())
s = input()
s += 'X'

ans = 0
l = 0
r = 0
count = 1 if s[0]=='0' else 0

while r < n:
    if count <= k:
        ans = max(ans, r-l+1)
        if s[r]=='1' and s[r+1]=='0':
            count += 1
        r += 1
    else:
        if s[l]=='0' and s[l+1]=='1':
            count -= 1
        l += 1

print(ans)

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

int main()
{
    int N,r=0,k=0;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
        if(A.at(i)%2==0){
            r++;
            if(A.at(i)%3==0||A.at(i)%5==0){
                k++;
            }
        }
    }
    if(r==k){
        cout<<"APPROVED"<<endl;
    }else{
        cout<<"DENIED"<<endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <sstream> //string stream its useful!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // vector
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // std::greater
#include <map> //map
#include<set> //set
#include<queue> //queue
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include <iomanip> //cout<<setprecision
#include <regex>

typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
ll W = 1000000007;
// tuple にすれば回るんじゃないかな。


using namespace std;
void omajinai() {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(15);
    //freopen("txt.csv","r",stdin);
}



static function<ll(ll,ll)> sumfunc = [](ll l1,ll l2)->ll{return l1 + l2;};
class UF{
public:
    vector<ll> v;
    vector<ll> v2;
    function<ll(ll,ll)> func;
    UF(long t,function<ll(ll,ll)> func){
        v = vector<ll>(t);
        v2 = vector<ll>(t);
        for(int i = 0; i<v.size();i++) v[i] = i;
        this->func = func;
    }
    long getunion(long t){
        if(v[t] == t) return t;
        v[t] = getunion(v[t]);
        return v[t];
    }
    void unite(pair<long,long> p){
        long a = getunion(p.first), b = getunion(p.second);
        if(a>b) swap(a,b);
        v[b] = a;
        v2[a] = func(v2[b],v2[a]);
    }
    long sizeofunion(){
        long sum = 0;
        for(int i = 0 ; i<v.size();i++) if(v[i] == i ) sum++;
        return sum;
    }
};

class Main{
public:
    
    int pnt[13] = {13,1,2,3,4,5,6,7,8,9,10,11,12};
    int a,b;
    
    Main(){
        cin>>a>>b;
    }
    
    void run(){
        bool isdraw = pnt[a-1]== pnt[b-1];
        if(isdraw){
            cout<<"Draw"<<endl;
            return;
        }
        bool awon = pnt[a-1] > pnt[b-1];
        cout<<(awon? "Alice":"Bob")<<endl;
    }
};

int main(){
    omajinai();
    Main().run();
}


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

int main() {
    vector<vector<int>> c(3, vector<int>(3));
    REP(i, 3) REP(j, 3) cin >> c[i][j];
    bool flag = true;
    REP(i, 2) REP(j, 2) {
        if(c[i][j + 1] - c[i][j] != c[i + 1][j + 1] - c[i + 1][j]) flag = false;
    }
    cout << (flag ? "Yes" : "No") << endl;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

ll pow_mod(ll n, ll m, ll mod=998244353){
    ll a = 1;
    while(m>0){
        if(m&1) a = a*n % mod;
        n = n*n % mod;
        m >>= 1;
    }
    return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N, S;
    cin >> N >> S;
    vll A(N);
    rep(i, N) cin >> A[i];

    vvll dp(N, vll(S+1, 0));
    dp[0][S] = 1;
    ll total = 0;
    rep(n, N){
        if(A[n]<=S) total = (total+dp[n][A[n]]*pow_mod(2, N-n-1)) % 998244353;
        if(n<N-1){
            rep(s, S+1){
                dp[n+1][s] = (dp[n+1][s]+dp[n][s]*2) % 998244353;
                if(s-A[n]>=0) dp[n+1][s-A[n]] = (dp[n+1][s-A[n]]+dp[n][s]) % 998244353;
            }
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 73688
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<char> S(N);
    rep(i, N) cin >> S[i];

    bool flg = false;
    rep(i, N) {
        if (S[i] == 'Y') {
            flg = true;
            break;
        }
    }

    if (flg) {
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,  b, c, d;
  cin >> a >> b >> c >> d;
  int e = a + b, f = c + d;
  if (e > f){
    cout << "Left" << endl;
  } else if (e < f){
    cout<< "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){

	int N;
	scanf("%d",&N);
	int table[N+1];
	int dp[2][N/2+1][2];

	table[0] = 0;
	for(int i = 1; i <= N-1;i++)scanf("%d",&table[i]);
	table[N] = 0;

	for(int a = 0; a < 2; a++){
		for(int b = 0; b <= N/2+1; b++){
			for(int c = 0; c < 2; c++){
				dp[a][b][c] = BIG_NUM;
			}
		}
	}

	dp[0][0][0] = 0;
	dp[0][0][1] = 0;

	for(int i = 0; i <= N-1; i++){

		for(int k = 0; k <= N/2;k++){
			dp[(i+1)%2][k][0] = BIG_NUM;
			dp[(i+1)%2][k][1] = BIG_NUM;
		}

		for(int amount = 0; amount <= N/2; amount++){
			dp[(i+1)%2][amount+1][0] = min(dp[i%2][amount][0],dp[i%2][amount][1]+table[i]);
			dp[(i+1)%2][amount][1] = min(dp[i%2][amount][1],dp[i%2][amount][0]+table[i]);
		}
	}

	printf("%d\n",min(dp[0][N/2][0],dp[0][N/2][1]));

	return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
using namespace std;
long long n,v[19],ct;
long long Min(long long a,long long b){return a<b?a:b;}
long long DP(int l,int r,int s1,int s2)
{
	if(l+1==r)return v[l]*s1+v[r]*s2;
	long long as=2e18;
	for(int i=l+1;i<r;i++)as=Min(as,DP(l,i,s1,s1+s2)+DP(i,r,s1+s2,s2)-v[i]*(s1+s2));
	return as;
}
int main(){scanf("%lld",&n);for(int i=1;i<=n;i++)scanf("%lld",&v[i]);printf("%lld\n",DP(1,n,1,1));}//

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main() {
	string a;
	int ans[11],ans1[11], an,j,i;
	an = 0;
	while (cin >> a) {
		an = an + 1;
		i = 0;
		j = 0;
		ans[an] = 0;
		ans1[an] = 0;
		for (int z = 0; z <= a.size() - 1; z++) {
			if (a[z] == 'J') {
				j = 1;
				i = 0;
				goto a;
			}
			if (a[z] == 'I') {
				if (i == 2) {
					i = 0;
					ans1[an] = ans1[an] + 1;
				}
				if (j == 2) {
					j = 0;
					ans[an] = ans[an] + 1;
				}
				i = 1;
				j = 0;
				goto a;
			}
			if (a[z] == 'O') {
				if (j == 1) {
					j = 2;
					goto a;
				}
				if (i == 1) {
					i = 2;
					goto a;
				}
				i = 0;
				j = 0;
			}
			j = 0;
			i = 0;
		a:;
		}
	}
	for (int i = 1; i <= an; i++) {
		cout << ans[i] << endl;
		cout << ans1[i] << endl;
	}
}


Measured memory_bytes: 3036
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#define endl "\n"

using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

//int  frq[100007];
int main(){
	Lancer();
	//cout << fixed << setprecision(12);
	
	string str;
	cin >> str;
	bool ch = true;
	if (str[2] != str[3] || str[4] != str[5])
		ch = false;
	cout << (ch == true ? "Yes" : "No");
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let s = i::cmap(n);
    let mut set = HashSet::new();
    for ss in s {
        set.insert(ss);
    }
    println!("{}", set.len());
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 31900
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int MAX_N=86;

int main(){
    ios::sync_with_stdio(false);
    int n; cin >> n;
    ll l[MAX_N+5];
    l[0]=2;
    l[1]=1;
    for(int i=2;i<=n;i++){
        l[i]=l[i-1]+l[i-2];
    }
    printf("%lld\n",l[n]);
    return 0;
}

Measured memory_bytes: 256
//In the name of ALLAH the most merciful the most beneficial

#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+7;
static const int INF = 0x3f3f3f3f;
static const int MOD = 1e9+7;




int main(){
/*
    clock_t start,end;
    start = clock();*/
    
    int arr[3];
    FOR(i,0,3)
        cin >> arr[i];
    
    sort(arr,arr+3);
    cout << (arr[0]*arr[1])/2;
        
/*  end = clock();
    double time = double(end-start)/(double)CLOCKS_PER_SEC;
    cout <<fixed<< time/1000 << "sec";*/
}

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


int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x-a) < abs(x-b)) cout << "A" << endl;
  else cout << "B" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int n,a,b;
void solve()
{
    cin>>n>>a>>b;
    if(a==0&&b==0)
    {
        cout<<0;
        return;
    }
    int ans=n/(a+b)*a;
    n%=(a+b);
    cout<<ans+min(n,a);
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("STRWC.inp","r",stdin);
    //freopen("STRWC.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc167/abc167_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S, T;
  cin >> S >> T;

  bool ok = true;
  rep(i, S.size()) { ok &= S[i] == T[i]; }

  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
int map[92][92],move[6]={0,1,0,-1,0},max,n,m;
void search(int x,int y,int sign,int map1[][92],int x1,int y1){
    int mark=0,i,o;
    map1[y][x]=sign;
    for(i=0;i<4;i++){
        if(map1[y+move[i]][x+move[i+1]] == 1 && !(x1 == x+move[i+1] && y1 == y+move[i])){
            mark=1;
            int map2[92][92];
            memcpy(map2,map1,sizeof(map));
            search(x+move[i+1],y+move[i],sign+1,map2,x1,y1);
        }
    }
    if(!mark && max < sign)
        max=sign;
}
int main(void){
    int i,o;
    for(;max=0,memset(map,-1,sizeof(map)),scanf("%d %d",&n,&m),n+m;){
        for(i=1;i<=m;i++){
            for(o=1;o<=n;o++){
                scanf("%d",&map[i][o]);
            }
        }
        for(i=1;i<=m;i++){
            for(o=1;o<=n;o++){
                if(map[i][o] == 1){
                    int map1[92][92];
                    memcpy(map1,map,sizeof(map));
                    search(o,i,1,map1,o,i);
                }
            }
        }
        printf("%d\n",max);
    }
    return 0;
}

Measured memory_bytes: 2756
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double d = sc.nextInt();
		double t = sc.nextInt();
		double s = sc.nextInt();

		if(d/s > t) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}

}

Measured memory_bytes: 35712
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
	var list = nextIntArray();
	var output = new Array(N).fill(0);
	for(var i = 0; i < N - 1; i++){
		output[list[i] - 1]++;
	}
	myout(myconv(output,9));
}

Measured memory_bytes: 53140
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int X, A, B;
	cin >> X >> A >> B;
	cout << (X - A) % B << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int x = INT_MAX, ans = 0, a[n];
	for(int i =0; i < n; i++)
	{
		cin >> a[i];
		if(min(a[i],x) == a[i])
		{
			x = a[i];
			++ans;
		}
	}
	cout << ans;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  cin>>n>>m;
  vi v(n+1,0);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    v[a]++;
    v[b]++;
  }
  rep(i,n+1)if(v[i]%2){
    cout<<"NO"<<endl;
    return 0;
  }
  cout<<"YES"<<endl;
}


Measured memory_bytes: 640
ans_list = []

def solve():
    a, L = map(int,input().split())
    if (a, L) == (0,0):
        return "end"

    def Add(n: int) -> list:
        n = str(n)
        n = list(n)
        n = [int(s) for s in n]
        n = [0]*(L - len(n)) + n
        return n

    def Max(n: list) -> int:
        n = sorted(n, reverse=True)
        n = "".join([str(i) for i in n])
        n = int(n)
        return n
    
    def Min(n: list) -> int:
        n = sorted(n)
        n = "".join([str(i) for i in n])
        n = int(n)
        return n
    
    d = dict()

    d[a] = 0

    for i in range(1,21):
        a = Add(a)
        na = Max(a) - Min(a)
        j = d.get(na)
        if j is None:
            d[na] = i
        else:
            break
        a = na
    
    ans = "{} {} {}".format(j, na, i - j)
    return ans
        
while True:
    ans = solve()
    if ans == "end":
        break
    ans_list.append(ans)

for ans in ans_list:
    print(ans)


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

int main() {
    int n;
    cin >> n;
    vector<int> vs(n);
    for(auto &x:vs)
        cin >> x;
    sort(vs.begin(), vs.end());
    int arc = n;
    int abc = 0;
    int i = 0;
    int ans = 0;
    for(int k=1; k<=100000; ++k){
        while(i<n and vs[i]<k){ 
            ++i;
            --arc; ++abc;
        }
        if(abc == arc) ++ans;
    }
    cout << ans << endl;
}

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

#define pb push_back
#define mp make_pair
#define check cin >>
#define say cout <<
#define nicely << endl
#define initialize_playboy_mode ios_base::sync_with_stdio(0);
#define breakup_with_gf cin.tie(0);
#define messed_up cout << -1 << endl;
#define wife first
#define spare second

#define mgod main
#define wan 1

typedef int single;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

class Riajuu
{
	public:
	
	vector<int> girls;
	int testcount=1;
	
	void hears(int &x)
	{
		cin>>x; 
	}
	void count_girls()
	{
		cin>>testcount;
	}
	bool stillRiajuu()
	{
		girls.clear();
		testcount--;
		if(testcount>=0) return true;
		else return false;
	}
	void remove_girls()
	{
		girls.clear();
	}
	void check_girls(int x){
		for(int i=0;i<x;i++){
			int j; cin >> j;
			girls.push_back(j);
		}
	}
} MGod;

void flirt() {
    single w,a,b; cin >> w >> a >> b;
    if(a>b) swap(a,b);
    cout << max(0,b-a-w);
    return;
}

single mgod() {
    initialize_playboy_mode;
    breakup_with_gf;
    //MGod.count_girls();
    while(MGod.stillRiajuu()) flirt();
}


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

ll N;
ll sqr = 1;
ll res = 0;
vector<ll> prime;
vector<pair<ll, ll>> prime_num;
vector<ll> num_e(60, 0);

int main(){
    cin >> N;

    while(sqr * sqr <= N) ++sqr;  //2乗以上ある最大の素因数
    for(int i = 1; i <= 60; i++) num_e[i] = num_e[i-1] + i;  //べき乗部分

    ll div = 2;
    while(N > 1 && div <= sqr){
        ll n = 0;
        while(N % div == 0){ N /= div; ++n;}
        if(n > 0) prime_num.push_back({div, n});
        ++div;
    }
    if(N > 1) prime_num.push_back({N,1});
    /*for(int i = 0; i < prime_num.size(); i++){
      pair p = prime_num[i];
      cout << p.first << " " << p.second << endl;
    }*/

  for(int i = 0; i < prime_num.size(); i++){
    pair p = prime_num[i];
    ll cn = 0;
    while(p.second >= num_e[cn+1]) ++cn;
    res += cn;
  }

  cout << res << endl;
  return 0;

    
}

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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  string S;
  cin >> S;

  if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3]||S[3]==S[4]){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        boolean arr[]=new boolean[100004];
        for(int i=2;i*i<100004;i++)
        {
            for(int j=i*i;j<100004;j+=i)
            arr[j]=true;
        }
        int n=sc.nextInt();
        for(int i=n;i<arr.length;i++)
        {
            if(!arr[i])
            {
                System.out.println(i);
                break;
            }
        }
    }
}

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

string s, t;

int work[3010][200];

int memo[3010][3010];
bool used[3010][3010];

int dp(int i, int j){
  if(i == s.size() || j == t.size()){
    return 0;
  }

  if(memo[i][j] != -1) return memo[i][j];


  int yes = -1;
  if(work[j][s[i]] < INT_MAX){
    yes = dp(i+1, work[j][s[i]]+1) + 1;
  }

  int no = dp(i+1, j);
  if(yes < no){
    used[i][j] = false;
    memo[i][j] = no;
  }else{
    used[i][j] = true;
    memo[i][j] = yes;
  }

  return max(yes, no);
}

void answer(int i, int j){
  if(i == s.size()) return;
  if(j == t.size()) return;

  if(used[i][j]){
    cout << s[i];
    answer(i+1, work[j][s[i]]+1);
  }else{
    answer(i+1, j);
  }

  return;
}

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

  for(int i = 'a';i <= 'z';i++){
    work[t.size()][i] = INT_MAX;
  }

  for(int i = t.size()-1;i >= 0;i--){
    for(int j = 'a';j <= 'z'; j++){
      if(t[i] == j){
        work[i][j] = i;
      }else{
        work[i][j] = work[i+1][j];
      }
    }
  }

  memset(memo, -1, sizeof(memo));

  dp(0, 0);

  answer(0, 0);
  cout << endl;
  return 0;
}


Measured memory_bytes: 46976
#include <iostream>
#include <map>

int main()
{
	int n;
	std::cin >> n;
	std::map<std::string, bool> mp;
	std::string s;
	for (int i = 0; i < n; i++) {
		std::cin >> s;
		mp[s];
	}
	
	std::cout << mp.size() << std::endl;
	
	return 0;
}


Measured memory_bytes: 18776
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        //スタックサイズ2^24で処理を行う
        new Thread(null, () -> {
            int n;
            int k;
            List<Integer> as = new ArrayList<>();

            //try-with-resources文(カッコ内で宣言した変数はtry句を抜けると自動的に閉じられる)
            try (Scanner sc = new Scanner(System.in)) {
                n = sc.nextInt();
                k = sc.nextInt();
                for (int i = 0; i < n; i++) {
                    as.add(sc.nextInt() - 1);
                }
            }
            System.out.println(new Calculator(n, k, as).calculate());
        }, "", 1 << 24).start();
    }
}

/**
 * 計算クラス
 */
class Calculator {
    /**
     * 整数K
     */
    private int k;

    /**
     * 転送先を変えなければならないテレポータの数
     */
    private int answer = 0;

    /**
     * 計算済みかどうか
     */
    private boolean isCalculate = false;

    /**
     * ある町へ転送するテレポータが設置されている町のリスト
     */
    private List<List<Integer>> lists = new ArrayList<>();

    /**
     * コンストラクタ
     *
     * @param n  町の数
     * @param k  整数K
     * @param as 各町のテレポータの転送先リスト
     */
    Calculator(int n, int k, List<Integer> as) {
        this.k = k;
        for (int i = 0; i < n; i++) {
            this.lists.add(new ArrayList<>());
        }
        for (int i = 0; i < n; i++) {
            int j = as.get(i);
            if (0 < i) {
                this.lists.get(j).add(i);
            } else if (0 < j) {
                this.answer++;
            }
        }
    }

    /**
     * 転送先を変えなければならないテレポータの数を求める
     *
     * @return 転送先を変えなければならないテレポータの数
     */
    int calculate() {
        if (!this.isCalculate) {
            this.dfs(0, 0);
            this.isCalculate = true;
        }
        return this.answer;
    }

    /**
     * 転送回数を算出する
     *
     * @param a   着目する町
     * @param pre 1つ前の町
     * @return 転送回数
     */
    private int dfs(int a, int pre) {
        int h = 0;

        //拡張for文(リストや配列から要素を1つずつ取り出す)
        for (int i : this.lists.get(a)) {
            h = Math.max(h, this.dfs(i, a));
        }

        if (0 < pre && h == this.k - 1) {
            h = 0;
            this.answer++;
        } else {
            h++;
        }

        return h;
    }
}

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

int main() {
    int a, b, c, t;
    cin >> a >> b >> c;
    if (b < a) {
        t = a; a = b; b = t;
    }
    if (c < b) {
        t = b; b = c; c = t;
    }
    if (b < a) {
        t = a; a = b; b = t;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
int n,x,sum;
int main(){
	read(sum);
	read(n);
	while (n--) read(x),sum-=x;
	if (sum<=0)puts("Yes"); else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<int> A(N),B(N);
  vector<bool> C(N);
  bool exist = true;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < N; i++) {
    C[i] = true;
  }
  for (int i = 1; i <= N; i++) {
    int la = lower_bound(A.begin(),A.end(),i) - A.begin();
    int ra = upper_bound(A.begin(),A.end(),i) - A.begin() - 1;
    int lb = lower_bound(B.begin(),B.end(),i) - B.begin();
    int rb = upper_bound(B.begin(),B.end(),i) - B.begin() - 1;
    if (la > ra || lb > rb) continue;
    if (ra - la + 1 + rb - lb + 1 > N) {
      exist = false;
      break;
    }
    int ln = (la - rb + N) % N;
    int rn = (ra - lb + N) % N;
    for (int j = ln; ; j++) {
      j %= N;
      C[j] = false;
      if (j == rn) break;
    }
  }

  if (!exist) {
    cout << "No" << endl;
    return 0;
  } else {
    for (int i = 0; i < N; i++) {
      if (C[i]) {
        cout << "Yes" << endl;
        for (int j = 0; j < N; j++) {
          cout << B[(j - i + N) % N] << " ";
        }
        cout << endl;
        return 0;
      }
    }
    cout << "No" << endl;
    return 0;
  }
  return 0;
}

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

int main(){
    int A, B, C, X, Y, ans = 2e9, tmp, buyX, buyY;
    cin >> A >> B >> C >> X >> Y;

    C *= 2;

    for(int i=0; i<max(X, Y)+1 ; i++){
	buyX = max((X-i), 0);
	buyY = max((Y-i), 0);
	tmp = buyX*A + buyY*B + i*C;
	ans = min(ans, tmp);
    }
    
    cout << ans <<endl;
    
}




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

const int N = 300000;

int n, suf[N + 1];
char s[N + 1];

int main()
{
    scanf("%d%s", &n, s);
    for (int i = n - 1; i >= 0; -- i) {
        suf[i] = suf[i + 1] + (s[i] == 'E');
    }
    int result = n;
    int pre = 0;
    for (int i = 0; i < n; ++ i) {
        result = std::min(result, pre + suf[i + 1]);
        pre += (s[i] == 'W');
    }
    printf("%d\n", result);
}

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

int main() {
  int N;
  cin >> N;
  
  // 終わりにしたいボタン番号 配列添字の都合で -1
  int finish_no = 2-1;
  // 入力読み込み用の配列
  vector<int> next_button(N);
  
  // 標準入力から読み込み
  for (int i = 0; i < N; i++) {
    cin >> next_button.at(i);
  }
  
  // 答えを探す ボタンの数だけ試せば十分
  int cur_button = 0; // 配列添字の都合でボタン番号 -1
  int cnt = 0;
  for (int i = 0; i < N; i++) {
//    cout << cur_button + 1 << "番のボタンを押したら" << next_button.at(cur_button) << "番のボタンが光りました" << endl;
    // 終わりにしたいボタン番号かどうか判定 ボタン番号と添字の-1に注意
    if (next_button.at(cur_button)-1 == finish_no) {
      cout << i+1 << endl;
      return 0;
    }
    else {
      // カレントボタンを置き換え ボタン番号と添字の-1に注意
      cur_button = next_button.at(cur_button) -1;
    }
}
   
  // 終わりにしたい番号は出なかった
  cout << -1;
  return 0;
}

Measured memory_bytes: 3768
import java.util.Scanner;

public class Main {

 public static void main(String[] args) {

  Scanner scanner = new Scanner(System.in);

  while (true) {

   int a = scanner.nextInt();

   int b = scanner.nextInt();

   if (a == 0 & b == 0)

    break;

   for (int i = 0; i < a; i++) {

    for (int j = 0; j < b; j++) {

     System.out.print("#");

    }
    System.out.println();

   }
   System.out.println();

  }
 }
}


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

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

  int start = 1;

  for(int i=1;i<s.size();i++) {
    if(s[i] == s[i-1]) start++;
    else break;
  }

  int end = s.size()-1;
  for(int i=s.size()-2;i>=0;i--) {
    if(s[i] == s[i+1]) end--;
    else break;
  }

  if(start == s.size()) {
    cout << 0 << endl;
  } else {
    int seqNum = 0;
    for(int i=start;i<end;i++) {
      if(s[i] == s[i-1]) continue;
      else seqNum++;
    }

    cout << seqNum + 1 << endl;
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define print(n) std::cout << n << std::endl
#define FOR(i,n) for(int i = 0; i < n; i++)
using namespace std;

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

    vector<string> title(n);
    vector<int> time(n);

    for (int i = 0; i < n; ++i) {
        cin >> title.at(i);
        cin >> time.at(i);
    }
    string x;
    cin >> x;
    int num = 0;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        if(x == title.at(i)) num = i;
    }
    for (int i = num + 1; i < n; ++i) {
        sum += time.at(i);
    }
    print(sum);


}

Measured memory_bytes: 256
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
//#define =1e9 =(int)1e9
const ll mod = 1000000007;
const ll nmax=1000003;
#define int ll
int n, k, a[501], b[501], s, ans=1;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n>>k;
    for(int i=1; i<=n; i++) cin>>a[i], s+=a[i];
    for(int d=1; d*d<=s; d++){
        if(s%d) continue;
        int xd=0, cnt=0;
        for(int i=1; i<=n; i++) b[i]=a[i]%d, xd+=b[i];
        sort(b+1, b+n+1);
        xd/=d;
        for(int i=n; i && xd && cnt<=k; i--, xd--) cnt+=(d-b[i]);
        if(cnt<=k) ans=max(d, ans);

        int xxxx=d; d=s/d;
		cnt=0, xd=0;
        for(int i=1; i<=n; i++) b[i]=a[i]%d, xd+=b[i];
        sort(b+1, b+n+1);
        xd/=d;
        for(int i=n; i && xd && cnt<=k; i--, xd--) cnt+=(d-b[i]);
        if(cnt<=k) ans=max(d, ans);
        d=xxxx;
    }
    cout<<ans;
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  ll a, b, k ;
  set<ll>s ;
  scanf("%lld %lld %lld", &a, &b, &k) ;
  for(int i =0 ; i<k ; i++)
    if(a+i<=b) s.insert(a+i) ;
  for(int i = k-1 ; i>=0 ; i--)
    if(b -i >= a)s.insert(b-i) ;

  for(auto i: s)
    printf("%lld\n", i) ;
	
  return 0 ;
}

Measured memory_bytes: 256
n, q = map(int, input().split())
S = input()
 
counts = [0 for i in range(n)]
cnt = 0
 
for i in range(n):
  if S[i-1:i+1] == "AC":
    cnt += 1
  counts[i] = cnt
    
for i in range(q):
    l, r = map(int, input().split())
    print(counts[r-1] - counts[l-1])

Measured memory_bytes: 6184
# include <bits/stdc++.h>
using namespace std;
# define ll long long
const int N = 1e3 + 10, M = 1e4 + 10;
ll a[N], b[N], d[M];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    ll n, m, ans = 1e9;
    cin >> m >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 1; i <= 10000; i++)d[i] = 1e9 + 10;
    for(int i = 1; i <= n; i++){
        for(int j = a[i]; j <= 10000; j++){
            d[j] = min(d[j - a[i]] + b[i], d[j]);
            if(j >= m)ans = min(ans, d[j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a[3],flag=1,k=1;
  for(int i=0;i<3;i++)
    cin>>a[i];
    for(int i=0;i<3;i++)
    {

        for(int j=i+1;j<3;j++)
        {
            if(a[i]==a[j])
            {
                k+=1;


            }
        }
    }
  if(k==2)
    cout<<"Yes";
  else
    cout<<"No";

}


Measured memory_bytes: 256
// Problem : B - Product Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

Falling down is an accident, Staying down is a choice.

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

int main()
{
    io;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    vll v={a*c,a*d,b*c,b*d};
    sort(all(v));
    cout<<v[3];
    return 0;
}



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

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

    int firstW = 0;
    int lastR = n-1;
    int count = 0;

    while(firstW < lastR){
        while(firstW <= n-1 && c[firstW] == 'R')firstW++;
        while(lastR >= 0 && c[lastR] == 'W')lastR--;

        if (firstW < lastR){
            count++;
            c[firstW] = 'R';
            c[lastR] = 'W';
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3436
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
long long p[110000];
long long dp[310][110000];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++)scanf("%lld",p+i);
	for(int i=0;i<a;i++)dp[1][i]=p[i];
	for(int i=2;i<=c;i++){
		deque<pair<long long,int> > Q;
		for(int j=0;j<a;j++){
			while(Q.size()&&Q.front().second<j-b){
				Q.pop_front();
			}
			if(Q.size()==0)dp[i][j]=-inf;
			else dp[i][j]=Q.front().first+p[j]*i;
			while(Q.size()&&Q.back().first<=dp[i-1][j]){
				Q.pop_back();
			}
			Q.push_back(make_pair(dp[i-1][j],j));
		}
	}
	long long ret=0;
	for(int i=0;i<a;i++)ret=max(ret,dp[c][i]);
	printf("%lld\n",ret);
}

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

import numpy as np

data = np.fromstring(read(), np.int64, sep=' ')

N, K  = data[:2]
P = data[2:] + 1

Pcum = np.zeros(N + 1, np.int32)
Pcum[1:] = P.cumsum()

length_K_sums = Pcum[K:] - Pcum[0:-K]
print(length_K_sums.max() / 2)

Measured memory_bytes: 18220
#include<iostream>
#include<vector>

int main(){
    int i,j,k,s;
    int h,w;
    std::vector<int> H,W;

    h=3;
    w=3;

    k=0;
    while(h!=0&&w!=0){
        std::cin>>h>>w;
        H.push_back(h);
        W.push_back(w);
        k=k+1;
    }
    for(s=0;s<k-1;s++){

        for(i=0;i<W[s];i++){
            std::cout<<"#"<<std::flush;
        }
        std::cout<<std::endl;

        for(i=0;i<H[s]-2;i++){
            std::cout<<"#"<<std::flush;
            for(j=0;j<W[s]-2;j++){
                std::cout<<"."<<std::flush;
            }
            std::cout<<"#"<<std::endl;
        }    

        for(i=0;i<W[s];i++){
            std::cout<<"#"<<std::flush;
        }
        std::cout<<std::endl;
        std::cout<<std::endl;
    }
    return 0;

}


Measured memory_bytes: 3148
package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	q := nextInt()
	A_slices := make([][]int, n)
	for i := 0; i < n; i++ {
		A_slices[i] = make([]int, 0)
	}
	for i := 0; i < q; i++ {
		// fmt.Println(A_slices)
		switch nextInt() {
		case 0:
			t := nextInt()
			x := nextInt()
			A_slices[t] = append(A_slices[t], x)
			// fmt.Println(A_slices)
		case 1:
			t := nextInt()
			if len(A_slices[t]) == 0 {
				continue
			}
			top := A_slices[t][len(A_slices[t])-1]
			fmt.Println(top)
		case 2:
			t := nextInt()
			if len(A_slices[t]) == 0 {
				continue
			}
			A_slices[t] = A_slices[t][:len(A_slices[t])-1]
		default:
			panic("no such operation!")
		}
	}
}


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a <<" "<< b <<" " <<c;
 return 0;
}

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

a, b = [int(x) for x in input().split()]

white = [['.'] * 100 for _ in range(50)]
black = [['#'] * 100 for _ in range(50)]

a, b = a - 1, b - 1

if b != 0:
    for i in range(0, 50, 2):
        flag = 0
        for j in range(0, 100, 2):
            white[i][j] = '#'
            b -= 1
            if b == 0:
                flag = 1
                break
        if flag:
            break

if a != 0:
    for i in range(1, 50, 2):
        flag = 0
        for j in range(1, 100, 2):
            black[i][j] = '.'
            a -= 1
            if a == 0:
                flag = 1
                break
        if flag:
            break
print(100, 100)
for i in white:
    print(''.join(i))
for j in black:
    print(''.join(j))





Measured memory_bytes: 38384