akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <stdio.h>
#include <string.h>

using namespace std;
int main()
{
	int N, K, Ans, i, j;

	Ans = 1;

	cin >> N;
	cin	>> K;

	for (i = 0; i < N; i++) {
		if (Ans < K) {
			Ans = 2 * Ans;
		}
		else {
			Ans = Ans + K;
		}
	}

	cout << Ans;

	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 all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    string s;
    cin >> s;
    ll k;
    cin >> k;
    if(s.size()==1)  { cout << s << endl; return 0;}
    char ans;
    ll cnt = 0;
    rep(i,s.size()){
        if(s[i]!='1') {ans = s[i]; break;}
        else cnt++;
    }
    if(cnt >= k) cout << 1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;
ll cnt[100010];
int main() {
  ll N,K; cin >> N >> K;
  vector<pair<int,int>> pairs(N);
  for ( int i = 0; i < N; i++ ) {
    ll a,b; cin >> a >> b;
    pairs[i] = make_pair(a,b);
  }
  
  sort(pairs.begin(),pairs.end());
  cnt[0] = pairs[0].second;
  for ( int i = 1; i < N; i++ ) {
    cnt[i] = cnt[i-1]+pairs[i].second;
  }
  ll ans;
  for ( int i = 0; i < N; i++ ) {
    if ( cnt[i] >= K ) {
      ans = pairs[i].first;
      break;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        List<Double> p = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            double a = sc.nextDouble();
            a = (a + 1.0) / 2;
            p.add(a);
        }

        double mx = 0.0;
        double s = 0.0;
        Queue<Double> q = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            s += p.get(i);
            q.add(p.get(i));
            if (q.size() > k) {
                s -= q.remove();
            }
            if (q.size() == k) {
                mx = Math.max(mx, s);
            }
        }

        System.out.println(mx);
    }
}

Measured memory_bytes: 164932
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
string s;
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	cin >> s;
	if(s == "ABC"){
		puts("ARC");
	} else {
		puts("ABC");
	}
	return 0;
}


Measured memory_bytes: 3560
#include <iostream>

using namespace std;

int main(){
 int n;
 cin >> n;
  int p[n];
  for(int i=0;i<n;i++){
  cin >> p[i];
  }

 int res=0;
  for(int i=1;i<n-1;i++){
  if((p[i-1]>p[i]&&p[i]>p[i+1])||(p[i-1]<p[i]&&p[i]<p[i+1])){
  res++;
  }
    
  }
  
  cout << res << endl;
  
}

Measured memory_bytes: 256
import sys

def gcd(a,b):
    while a % b != 0:
        a, b = b, a % b
    return b

def lcm(a,b,g):
    _a = a // g
    _b = b // g
    return _a * _b * g

def run():
    data = []
    for n in sys.stdin:
        a, b = list(map(int, n.split()))
        data.append((a,b))

    for _data in data:
        a, b = _data
        g = gcd(a,b)
        l = lcm(a,b,g)
        print(g, l)

if __name__ == '__main__':
    run()




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

int gcd(int x, int y);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

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

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

int main() {
    ll n;
    cin >> n;
    vector<int> num(sqrt(n) + 1);
    int ans = 0;
    ans = fac(n, num);
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}


Measured memory_bytes: 11216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n,k;cin>>n>>k;
    if(n>=10)cout<<k;
    else cout<<k+(100*(10-n));
    return 0;  
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007, MAX = 100001;

template<class T>
struct UnionFind {
  vector<T> parent, siz;

  UnionFind(int n) : parent(n), siz(n) {
    for (int i = 0; i < n; ++i) {
      parent[i] = i;
      siz[i] = 1;
    }
  }

  T root(T x)
  {
    if (parent[x] == x) return x;
    return parent[x] = root(parent[x]);
  }

  bool unite(T x, T y)
  {
    x = root(x);
    y = root(y);

    if (x == y) return false;

    if (siz[x] < siz[y]) swap(x, y);
    parent[y] = x;
    siz[x] += siz[y];

    return true;
  }

  bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  T size(T x)
  {
    return siz[x];
  }
};


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

  int n, m; cin >> n >> m;
  UnionFind<int> uf(n + m);

  rep(i, n) {
    int k; cin >> k;
    
    rep(j, k) {
      int l; cin >> l;
      uf.unite(i, l+n-1);
    }
  }

  int r = uf.root(0);
  rep(i, n) {
    if (r != uf.root(i)) {
      cout << "NO" << endl;
      return (0);
    }
  }
  
  cout << "YES" << endl;

  return (0);
}


Measured memory_bytes: 4576
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll T, A;
	cin >> T >> A;
	REP(i, n - 1) {
		ll a, t;
		cin >> t >> a;
		ll j = max((T + t - 1) / t, (A + a - 1) / a);
		T = j*t;A = j*a;
	}
	cout << T + A << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
int main() {
	int a,b;
    cin >> a >> b;
    a += b;
    if(a >= 10 ){
        cout << "error" << endl;
    }
    else {
        cout << a << endl;
    }
	return 0;
}

Measured memory_bytes: 256
N=int(input())
from collections import defaultdict
f=defaultdict(int)
d=defaultdict(list)

for _ in range(N-1):
    a,b=map(int,input().split())
    d[a].append(b)
    d[b].append(a)

i=0
b=1
w=1
f[1]=1
f[N]=1
bq=d[1]
wq=d[N]

while len(bq)>0 or len(wq)>0:
    tmp=[]
    if i==0:
        for q in bq:
            if f[q]==0:
                f[q]=1
                b+=1
                tmp+=d[q]
    else:
        for q in wq:
            if f[q]==0:
                f[q]=1
                w+=1
                tmp+=d[q]
    if i==0:
        i=1
        bq=tmp
    else:
        i=0
        wq=tmp

if b>w:
    print('Fennec')
else:
    print('Snuke')


Measured memory_bytes: 82264
#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 n;
    cin>>n;
    bool ok=false;
    rep(i,n){
        int a; cin>>a;
        if(a%2==1)ok=true;
    }
    cout<<(ok?"first":"second")<<endl;
    return 0;
}

Measured memory_bytes: 256
roll = {"N": (1, 5, 2, 3, 0, 4),
        "S": (4, 0, 2, 3, 5, 1),
        "E": (3, 1, 0, 5, 4, 2),
        "W": (2, 1, 5, 0, 4, 3)}
dice = input().split()
for direction in input():
    dice = [dice[i] for i in roll[direction]]
print(dice[0])


Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define max(a, b) (((a)<(b))?b:a)
#define min(a, b) ((a>b)?b:a)
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pi 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-14
#define mod ((int)1e9+7)
#define maxlg 18
#define left(i) ((i)<<1)
#define right(i) (((i)<<1)+1)
#define maxn 200006

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
 #endif
    ll x,y;
    cin>>x>>y;
    int ans=0;
    while (x<=y) {
        ans++;
        x*=2;
    }
    cout<<ans;




    return 0;
}

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

bool is_prime(ll num){

    for(ll i = 2; i*i <= num; ++i){
        if(num%i==0)return false;
    }
    return true;
}

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

    ll x;
    cin >> x;

    while(1){
        if(is_prime(x)){
            cout << x << endl;
            return 0;
        }
        ++x;
    }
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;


#[fastout]
fn main() {
    input! {
    n: usize,
    s: Chars
    }

    let fs = s[..n /  2].iter().collect::<String>();
    let ls = s[n/2..].iter().collect::<String>();
    let ans = if fs == ls {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


Measured memory_bytes: 2172
#include "bits/stdc++.h"
using namespace std;

int in[2][105];

int main() {
    int n;

    cin >> n;
    for (int i = 0; i < 2; ++i) {
        for (int j = 1; j <= n; ++j) {
            cin >> in[i][j];
        }
    }

    for (int j = 1; j <= n; ++j) in[0][j] += in[0][j - 1];
    for (int j = n; j >= 1; j--) in[1][j] += in[1][j + 1];

    int res = 0;
    for (int i = 1; i <= n; ++i) res = max(res, in[0][i] + in[1][i]);
    printf("%d\n", res);
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		int ans = 1;
		for(int i = 0;i < n;i++){
			if(ans <= k){
				ans *= 2;
			} else {
				ans += k;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    int str_len = str.length();
    
    if(Integer.parseInt(str.substring(str_len-1,str_len))==3)
      System.out.println("bon");
    else if(Integer.parseInt(str.substring(str_len-1,str_len))==0 ||
            Integer.parseInt(str.substring(str_len-1,str_len))==1 ||
            Integer.parseInt(str.substring(str_len-1,str_len))==6 ||
            Integer.parseInt(str.substring(str_len-1,str_len))==8)
      System.out.println("pon");
    else
      System.out.println("hon");
  }
}

Measured memory_bytes: 32392
// AOJ 2000
#include<iostream>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

const int XMAX = 30, YMAX = 30, MMAX = 40;

bool field[XMAX][YMAX];
char dir[MMAX];
int dist[MMAX];
int N, M;

void init() {
  REP(x, XMAX) REP(y,YMAX) { field[x][y] = false; }
}

bool solve() {
  int items = 0;
  int x = 10, y = 10;
  REP(i, M) {
    REP(d, dist[i]) {
      x += (dir[i] == 'E' ? 1 : dir[i] == 'W' ? -1 : 0);
      y += (dir[i] == 'N' ? 1 : dir[i] == 'S' ? -1 : 0);

      if (field[x][y]) {
        field[x][y] = false;
        items++;
      }
    }
  }
  return items == N;
}

int main() {
  while (cin >> N and N) {
    init();
    REP(i, N) {
      int x, y;
      cin >> x >> y;
      field[x][y] = true;
    }

    cin >> M;
    REP(i, M) {
      cin >> dir[i] >> dist[i];
    }

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

Measured memory_bytes: 1152
N,K = map(int,input().split())
X = list(map(int,input().split()))

ans = float('inf')
for i in range(K-1,N):
    xl = X[i-K+1]
    xr = X[i]
    ans = min(abs(xr)+abs(xr-xl),abs(xl)+abs(xr-xl),ans)
print(ans)

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

int main() {
  int N; 
  cin >> N;
  vector<int> A(N);
  
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  bool check = true;
  bool changed = false;
  int temp1;
  int temp2;
  
  while(check){
    changed = false;
    for (int i = 0; i < N - 1; i++){
      if (A.at(i) < A.at(i+1)){
        temp1 = A.at(i);
        temp2 = A.at(i+1);
        A.at(i) = temp2;
        A.at(i+1) = temp1;
        changed = true;
      }
    }
    
    if (changed == false){
      check = false;
    }
  }
  
  int ans = 0;
  
  for (int i = 0; i < N; i++){
    if (i % 2 == 0){
      ans += A.at(i);
    }
    else{
      ans -= A.at(i);
    }
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3568
#include <stdio.h>

int main(){
    int a, b, c, x;
    scanf("%d %d %d", &a, &b, &c);
    if(a>b){
        x=a;
        a=b;
        b=x;
    }
    if(b>c){
        x=b;
        b=c;
        c=x;
    }
    if(a>b){
        x=a;
        a=b;
        b=x;
    }
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}


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

int64_t lucas(int n);

int main()
{
  int n; cin >> n;
  cout << lucas(n) << endl;
}

int64_t lucas(int n)
{
  vector<int64_t> l(n+1);
  for (int i = 0; i <= n; i++)
  {
    if (i == 0) l[0] = 2;
    else if (i == 1) l[1] = 1;
    else l[i] = l[i-1] + l[i-2];
  }
  return l[n];
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
A=get_i
flag=0
ans=1
(N-1).times do|i|
  case flag
  when 0 then
      if A[i]<A[i+1]
          flag=1
      elsif A[i]>A[i+1]
          flag=-1
      end
  when 1 then
      if A[i]>A[i+1]
        ans+=1
        flag=0
      end
  when -1 then
      if A[i]<A[i+1]
          ans+=1
          flag=0
      end
  end
end
puts ans

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

int main() {
	int m[11][11];
	int n;
	while (cin >> n, n) {
		memset(m, 0, sizeof(m));
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> m[i][j];
				m[n][j] += m[i][j];
				m[i][n] += m[i][j];
				m[n][n] += m[i][j];
			}
		}
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n; j++) {
				printf("%5d", m[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1164
N = int(input())
n = list(str(N))
for i in range(4):
    if i == 0:
        a = n[i]
        count = 1
    else:
        if n[i]!=a:
            a = n[i]
            if count < 3:
                count = 1
        else:
            count+=1
if count >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;
template<class T> inline bool chmin(T &a, T b) { return a > b ? (a = b, 1) : 0; }

vector<vector<int>> calc_next(const string &s) {
    int n = s.size();
    vector<vector<int>> nxt(n + 1, vector<int>(26, n));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) nxt[i][j] = nxt[i + 1][j];
        nxt[i][s[i] - 'a'] = i;
    }
    return nxt;
}

int main() {
    int n; cin >> n;
    string cat;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        cat += s.front();
    }
    auto nxt = calc_next(cat);
    vector<int> dp(n + 1, INF);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        chmin(dp[i + 1], dp[i] + 1);
        chmin(dp[nxt[i + 1][cat[i] - 'a']], dp[i]);
    }
    cout << dp[n - 1] << endl;
    return 0;
}



Measured memory_bytes: 16680
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#include<vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  cout << a*b << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll X,K,D;
    cin>>X>>K>>D;
    X=abs(X);
    ll N=X/D;
    ll Y=X%D;
    ll ans=0;
    if(K>=N){
        if((K-N)%2==0){
            ans=Y;
        }
        else{
            ans=D-Y;
        }
    }
    else{
        ans=X-K*D;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#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 N, X;
  cin >> N >> X;

  vector<int> L(N);
  rep(i, N) cin >> L[i];

  int z = 0;
  int ans = 1;
  rep(i, N) {
    z += L[i];
    if (z <= X) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
// clang-format off
#define FOR(i, n) for (int i=0; i<(int)n; ++i)
#define RFOR(i, n) for (int i=n-1; i>=0; --i)
#define OUTV(x) FOR(j,x.size()) cout<<x[j]<<(x.size()-j-1?' ':'\n');
#define OUTM(x) FOR(i,x.size()) {OUTV(x[i])}
#define BLE cerr<<"BLE"<<endl;
#define DEBUG(x) cerr<<"DEBUG: "<<#x<<" = "<<x<<endl;
#define PB push_back
#define MP make_pair
// clang-format on
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  //  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

  int A, B;
  cin >> A >> B;
  int K;
  cin >> K;
  vector<int> div;
  for (int a = 1; a <= min(A, B); ++a) {
    if (A % a == 0 and B % a == 0) {
      div.push_back(a);
    }
  }
  cout << div[div.size() - K] << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(9 + n - 100 + 1)
elif n < 10000:
    print(909)
elif n < 100000:
    print(909 + n - 10000 + 1)
else:
    print(90909)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (lld)1e7+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


lld extend_gcd(lld a, lld b, lld& x, lld& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    lld x1, y1;
    lld d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

lld rowNum[]={-1,0,0,1};
lld colNum[]={0,-1,1,0};

lld divi[MAX2];

void divisor(lld n)
{
	for(lld i=1;i<=n;i++)
	{
		for(lld j=i;j<=n;j+=i)
			divi[j]++;
	}
}

int main()
{
	fastio
	lld n,ans=0;
	cin>>n;

	divisor(n);

	for(lld i=1;i<=n;i++)
	{
		ans+=(i*(divi[i]));
	}

	cout<<ans<<endl;
}

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

using namespace std;

int main(){
  int N,W,x;
  while(cin >> N >> W, N){
    int n = 0;
    double p[11] = {0};
    for(int i = 0 ; i < N ; i++){
      cin >> x; p[x/W]++;
      n = max(n,x/W);
    }
    double den = *max_element(p,p+11);
    double ans = 0,t = n;
    for(int i = 0 ; i < n ; i++){
      ans += (p[i]/den)*(t--/n);
    }
    printf("%f\n",ans+0.01);
  }
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
//#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, ans = 0,x,y,h,w,bla=0,cnt=0,u,v;
    ll a[100004]={0};
    cin>>n;
    for(i=1;i<=100;i++){
        for(j=1;j<=100;j++){
            for(k=1;k<=100;k++){
                a[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    for(i=1;i<=n;i++)
        cout<<a[i]<<endl;
    


    return 0;
}

Measured memory_bytes: 4360
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // long long64_t, long long*_t
#include <cstdio> // prlong longf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack 
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <list>
using namespace std;
int main(){
  double r;
  cin >> r;
  cout << r*2*3.1415926535 << endl;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  string s;
  cin>>s;
  long long n = s.size();
  long long bisum = 0;
  long long bnum = 0;
  REP(i,n){
    if(s[i] == 'B'){
      bnum++;
      bisum += i;
    }
  }
  long long ans = 0;
  REP(i,bnum){
    ans += n-1-(long long)i;
  }
  ans -= bisum;
  cout<<ans<<endl;
  return 0; 
}


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


int main(){
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for(auto& a : A){
    cin >> a;
  }
  cout << min(
    count_if(A.begin(), A.end(), [&X](const int& a){return a < X;}),
    count_if(A.begin(), A.end(), [&X](const int& a){return a > X;})
  ) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)
#define INF 100000000
#define ll long long
 
queue<string> str;
int main()
{
    string S;
    vector<string> gene;
    cin >> S;
     
    gene.push_back("A");
    gene.push_back("B");
    gene.push_back("C");
 
    str.push(S);
    while (!str.empty()) {
        string s = str.front();
        str.pop();
 
        if (s.size() == 3 && s == "ABC") {
            cout << "Yes" << endl;
            return 0;
        }
 
        REP(i, 0, 3) {
            int cnt = 0;
            string ns = s;
            vector<int> idx;
            bool flag = false;
 
            RREP(j, 0, (int)s.size() - 2) {
                if (ns[j] == 'A' && ns[j + 1] == 'B' && ns[j + 2] == 'C') {
                    flag = true;
                    idx.push_back(j);
                    cnt++;
                }
            }
             
            if (cnt != count(ns.begin(), ns.end(), 'A' + i)) continue;
 
            REP(k, 0, (int)idx.size()) {
                ns.replace(idx[k], 3, gene[i]);
            }
 
            if (flag) str.push(ns);
        }
    }
 
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3192
using System;
using System.IO;
using System.Linq;

namespace ABC126A
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = temp[0];
            var K = temp[1];
            var S = Console.ReadLine().ToArray();

            S[K - 1] = S[K - 1].ToString().ToLower().ToCharArray()[0];
            Console.WriteLine(S);
        }
    }
}


Measured memory_bytes: 13396
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi, greater<int>> mpq;

const ll INF = 1e18;
const ll NINF = -1e18;
const int inf = 1e9+5;
const int ninf = -(1e9+5);
const int mod = 1e9+7;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

#define whatis(x) cerr << #x << " is " << x << endl;
#define dbg(x) for(auto y:x) cerr << y << " ";cout << endl;
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ft front()
#define bk back()
#define sz(x) (long long)x.size()
#define all(x) (x).begin(), (x).end()
#define ub upper_bound
#define lb lower_bound
#define FOR(i, a) for(int i = 0; i < a; i++)
#define FoR(i, a) for(int i = 1; i <= a; i++)
#define ROF(i, a) for (int i = (a)-1; i >= 0; i--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//-----------------------| Template By: DakDak |----------------------------

int main(){
    int a, b; cin >> a >> b;
    cout << a*b << endl;
    return 0;
    // Read notes to self
}

/* NOTES TO SELF:
 * Check for int vs ll, worst case just switch everything to ll
 * Check for array bounds if you SEGFAULT, especially in range based loops
 * Always initialize everything in global 
 * Edge cases such as n = 1 or 0
 * Make sure to calculate big O complexity
 * You are geniosity you got this
 */





Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    cout << "ABC" + s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<int,int> P;
ll mod=pow(10,9)+7;
ll INF=pow(10,18);

int main(){
    ll N,A,B;cin>>N>>A>>B;
    cout<<A*(N/(A+B))+min(A,N-(N/(A+B))*(A+B))<<endl;
    return 0;
}

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

int main() {
  ll a,b,k;
  cin >> a >> b >>k;
  
  if (a >= k) {
    cout << a - k << " " << b << endl;
  } else if (a + b >= k) {
    cout << 0 << " " << a + b - k << endl;
  } else {
    cout << 0 << " " << 0 << endl;
  }
}


Measured memory_bytes: 256
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]


n, m = map(int, input().split())

bridges = []
for i in range(m):
    a, b = map(int, input().split())
    bridges.append((a-1, b-1))

uf = UnionFind(n)
ans = [n * (n-1) // 2]
for a, b in bridges[::-1]:
    a1 = uf.get_size(a)
    b1 = uf.get_size(b)
    uf.union(a, b)
    a2 = uf.get_size(a)
    b2 = uf.get_size(b)

    conv = (a1 * (a2 - a1) + b1 * (b2 - b1)) // 2
    ans.append(ans[-1]-conv)

print('\n'.join(map(str, ans[-2::-1])))


Measured memory_bytes: 131332
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    VP vec(n);
    rep(i,n)cin>>vec[i].F>>vec[i].S;
    ll reg1;
    ll reg2;
    rep(i,n){
        if(i==0){
            reg1=vec[i].F;
            reg2=vec[i].S;
         //   cout<<vec[i].F<<" "<<vec[i].S<<endl;
        }else{
            ll x=reg1/vec[i].F;
            ll y=reg2/vec[i].S;
            if(reg1%vec[i].F!=0)x++;
            if(reg2%vec[i].S!=0)y++;
            ll res=max(x,y);
            reg1=res*vec[i].F;
            reg2=res*vec[i].S;
        }
     //   cout<<reg1<<" "<<reg2<<endl;
    }
    cout<<reg1+reg2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using ll =long long ;
using namespace std;
int main(){
    ll n;
    cin >> n;
    int count=0;
    for(int i=0;i<n;i++){
        ll a;cin >> a;
        while(1){
            if(a%2==0){
                count++;
                a /= 2;
            }else{
                break;
            }
        }
    }
    cout << count << endl;
}

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

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
ll dp[150][10]; // dp[i][j] := 高さがi-0.5でj番目にいく方法の総和
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int H,W,K;
    cin >> H >> W >> K;
    dp[0][0] = 1;
    for(int i=0;i<=H;i++){
        for(int j=0;j<W;j++){
            // 2^W通りの線のはやしかたを調べてつながっていないかどうかを調べる
            for(int a=0;a<1<<(W-1);a++){
                bool ok = true;
                // a の 0 bit 目が1  := 1と2の間に線を入れる
                // W-1とWの間に線 := W-2bit目が1
                for(int b=1;b<W-1;b++){
                    if((a>>(b-1)) & a>>(b)) ok = false;
                }
                if(!ok)continue;
                // 各点jについて
                if(a>>j & 1){
                    (dp[i+1][j+1] += dp[i][j])%=mod;
                }else if( a>>(j-1) & 1){
                    (dp[i+1][j-1] += dp[i][j])%=mod;
                }else (dp[i+1][j] += dp[i][j])%=mod;
            }
        }
    }
    cout << dp[H][K-1]%mod << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int n, l, sum;
  cin >> n >> l;

  sum = n*(l + l + n - 1)/2;

  if (l + n - 1 < 0) {
    sum -= l + n - 1;
  } else if (0 < l ) {
    sum -= l;
  }

  cout << sum << endl;

  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    lli g[n][n];
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        cin >> g[i][j];
      }
    }

    const lli inf = 1LL << 60;
    const int N = (1 << 16) + 1;

    lli cost[N];
    fill(cost, cost + N, 0);
    for (int bit = 0; bit < (1 << n); ++bit) {
      for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
          unless (bit & (1 << i)) continue;
          unless (bit & (1 << j)) continue;
          cost[bit] += g[i][j];
        }
      }
    }

    lli dp[N];
    fill(dp, dp + N, -inf);
    dp[0] = 0;

    // O(3^N), P.144
    for (int bit = 0; bit < (1 << n); ++bit) {
      int sup = bit ^ ((1 << n) - 1);
      int sub = sup;
      do {
        setmax(dp[bit | sub], dp[bit] + cost[sub]);
        sub = (sub - 1) & sup;
      } while (sub != sup);
    }
    cout << dp[(1 << n) - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 1280
fun main(args: Array<String>) {
  var split = readLine()!!.split(" ")
  val L = split[0].toLong()!!
  val R = split[1].toLong()!!
  val a = L / 2019
  val b = R / 2019
  if (a == b) {
    var min: Long = Long.MAX_VALUE
    for (i in L..R-1) {
      for (j in i+1..R) {
        val mod = (i * j) % 2019
        if (mod < min) {
			min = mod
        }
      }
    }
    println(min)
  } else {
    println(0)
  }
}

Measured memory_bytes: 38248
N=int(input())
ans=0
an=0
for i in range(1,int(N/2+1)):
    for j in range(i,N):
        if(i*j<N):
            if(i!=j):
                ans=ans+1
            else:
                an=an+1
            #print(i,j)


        else:
            break
print(ans*2+an)


Measured memory_bytes: 73384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
#define fi cin
#define fo cout 
#define repi(i,a,n) for(i=a;i<n;i++)
#define repie(i,a,n) for(i=a;i<=n;i++)
#define repd(i,a,n) for(i=n;i>a;i--)
#define repde(i,a,n) for(i=n;i>=a;i--) 
#define pb(n) push_back(n)
#define ff first
#define ss second
#define dfo if(0) cout
#define mod 1000000007

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	fi.tie(0);
	fo.tie(0);

	ll i,j,t,tc;
	map<string,int>ma;

	map<string,int>::iterator it;

	ll n,m;
	fi>>n;
	string s;
	repi(i,0,n)
	{
		fi>>s;
		ma[s]++;
	}
	fi>>m;
	repi(i,0,m)
	{
		fi>>s;
		ma[s]--;
	}

	it=ma.begin();
    int ans=0;
	while(it != ma.end())
	{
		ans=max(ans,it->ss);
		it++;
	}	
	cout<<ans<<endl;

}	

Measured memory_bytes: 256
# C - Many Requirements

import itertools

N, M, Q = map(int, input().split())
TEST = [0] * Q
for i in range(Q):
    TEST[i] = list(int(x) for x in input().split())

nums = [i+1 for i in range(M)]

ans = 0
for l in list(itertools.combinations_with_replacement(nums, N)):
    tmp = 0
    for t in TEST:
        if l[t[1]-1]-l[t[0]-1] ==t[2]:
            tmp += t[3]
        else:
            continue
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 21304
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

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

  set <char> char_set;
  for(int i = 0; i < S.size(); i++){
    char_set.insert(S[i]);
  }

  if(S.size() < 26){
    for(int i = 0; i < 26; i++){
      if(char_set.find('a' + i) == char_set.end()){
        S.push_back('a' + i);
        cout << S << endl;
        return 0;
      }
    }
  } else {
    if(S == "zyxwvutsrqponmlkjihgfedcba"){
      cout << -1 << endl;
      return 0;
    } else {
      char smallest;
      int start_ind;
      for(int i = S.size() - 2; i >= 0; i--){
        if(S[i + 1] > S[i]){
          for(int j = S.size() - 1; j > i; j--){
            if(S[i] < S[j]){
              S[i] = S[j];
              cout << S.substr(0, i + 1) << endl;
              return 0;
            }
          }
        }
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
#define rep2(i, n, m) for(int i=n; i<=m; i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
const ll inf=1LL << 60;
const ll MOD=1e9+7;

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

  int n, k;
  cin >> n >> k;
  int a[n];
  rep(i, n)cin >> a[i];

  cout << (n-k)/(k-1)+1+((n-k)%(k-1)==0 ? 0 : 1) << endl;

  return 0;
}

Measured memory_bytes: 4036
import math

N, K = map(int, input().split())
mod = 1000000007

# 順列(Permutation)を求める関数
def P(n, k):
    return math.factorial(n)//math.factorial(n-k)
    
# 組合せ(Combination)を求める関数
def C(n, k):
    return P(n, k)//math.factorial(k)
   
for i in range(1, K+1):
    if (N-K+1 < i) or (K-1 < i-1):
        print(0)
    else:
        print(((C(N-K+1, i)%mod)*(C(K-1, i-1)%mod))%mod)


Measured memory_bytes: 66264
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int a, b, c;
    cin >> a>> b >> c;
    if(c >= a and c <= b)puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int S;
	int h;
	int m;
	int s;
	
	scanf("%d",&S);
	
	h=S/3600;
	m=S%3600/60;
	s=S%3600%60;
	
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}
	

Measured memory_bytes: 592