akhauriyash/Code-Regression huggingface dataset:
def main():
    S = input()
    K = int(input())
    A = []
    last = S[0]
    count = 1
    for i in range(1, len(S)):
        s = S[i]
        if last == s:
            count += 1
        else:
            A.append({'key': last, 'count': count})
            count = 1
        last = s
    A.append({'key': last, 'count': count})
    # print(A)
    if len(A) == 1:
        c = A[0]['count']
        l = c*K
        ans = l//2
        print(ans)
        return
    ans = 0
    if A[0]['key'] != A[-1]['key']:
        for a in A:
            c = a['count']
            ans += (c//2) * K
        print(ans)
        return
    for i in range(1, len(A) - 1):
        a = A[i]
        c = a['count']
        ans += (c//2) * K
    a0 = A[0]
    a1 = A[-1]
    c0 = a0['count']
    c1 = a1['count']
    ans += c0//2
    ans += c1//2
    ans += ((c0 + c1)//2) * (K - 1)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import numpy as np
N,Q = map(int,input().split())
S = np.array(list('_' + input()), dtype='U2')
A = (S == 'A')
C = (S == 'C')
AC = (A[:-1] & C[1:])
AC_cum = AC.cumsum()

for _ in range(Q):
  L,R = map(int,input().split())
  print(AC_cum[R-1] - AC_cum[L-1])


Measured memory_bytes: 17212
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

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

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

using namespace std;

struct order
{
  string name;
  string type;
  string comm;
  int    price;
};

typedef pair<int, int> Pi;
typedef pair<Pi, Pi> Ti;

int main()
{
  int n;
  while(cin >> n, n) {
    vector<order> orders(n);
    vector<bool> used(n, false);
    map<string, Ti> comms;
    map<string, Pi> dealers;
    for(int i = 0; i < n; i++) {
      string name, type, comm; int price;
      cin >> name >> type >> comm >> price;
      orders[i] = order{name, type, comm, price};
      if(dealers.count(name) == 0) dealers[name] = Pi(0, 0);
      order deal = order{"", "", "", (type == "SELL" ? -1 : 1010)};
      int idx = -1;
      for(int j = 0; j < i; j++) {
	if(used[j]) continue;
	if(orders[j].name == name) continue;	
	if(orders[j].type == type) continue;
	if(orders[j].comm != comm) continue;
	if(type == "SELL" && deal.price < orders[j].price ||
	   type == "BUY" && deal.price > orders[j].price) {
	  deal = orders[j];
	  idx = j;
	}
      }
      if(idx == -1) continue;
      int dlprice = (price + deal.price) / 2;
      if(type == "SELL") {
	if(price > deal.price) continue;
	dealers[deal.name].first += dlprice;
	dealers[name].second += dlprice;
      } else if(type == "BUY") {
	if(price < deal.price) continue;	
	dealers[name].first += dlprice;
	dealers[deal.name].second += dlprice;
      }
      if(comms.count(comm) == 0) comms[comm] = Ti(Pi(1010, -1), Pi(0, 0));
      comms[comm].first.first = min(comms[comm].first.first, dlprice);
      comms[comm].first.second = max(comms[comm].first.second, dlprice);
      comms[comm].second.first += dlprice;
      comms[comm].second.second++;
      used[i] = used[idx] = true;
    }
    for(auto c : comms) {
      cout << c.first << " ";
      cout << c.second.first.first << " ";
      cout << c.second.second.first / c.second.second.second << " ";
      cout << c.second.first.second << endl;
    }
    cout << "--" << endl;
    for(auto d : dealers) {
      cout << d.first << " ";
      cout << d.second.first << " ";
      cout << d.second.second << endl;
    }
    cout << "----------" << endl;
  }
  return 0;
}

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

using namespace std;

using ll = long long;

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

    int a, b, c;
    cin >> a >> b >> c;

    if (b < a) swap(a, b);
    if (c < a || b < c) cout << "No\n";
    else cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 256
import sys, bisect
input = sys.stdin.readline

a, b, q = map(int, input().split())
al = [-float("INF")] + [int(input()) for _ in range(a)] + [float("INF")]
bl = [-float("INF")] + [int(input()) for _ in range(b)] + [float("INF")]
for _ in range(q):
    res = float("INF")
    x = int(input())
    b, d = bisect.bisect_right(al, x), bisect.bisect_right(bl, x)
    ans = min(max(abs(al[b-1] - x), abs(bl[d-1] - x)),
              abs(al[b-1] - x) * 2 + abs(bl[d] - x),  # 左の神社行って右の寺
              abs(bl[d-1] - x) * 2 + abs(al[b] - x),  # 左の寺行って右の神社
              abs(al[b] - x) * 2 + abs(bl[d-1] - x),  # 右の神社行って左の寺
              abs(bl[d] - x) * 2 + abs(al[b-1] - x),  # 右の寺行って左の神社
              max(abs(al[b] - x), abs(bl[d] - x)),
              )
    print(ans)


Measured memory_bytes: 12852
package main

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

func solve() {
	n := getInt()
	colors := make(map[int]bool)
	variable := 0
	for i := 0; i < n; i++ {
		a := getInt()
		if a < 3200 {
			colors[a/400] = true
		} else {
			variable++
		}
	}
	cnt := len(colors)

	ans1 := max(cnt, 1)
	ans2 := cnt + variable
	fmt.Fprintln(wr, ans1, ans2)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int main()
{
	//c_p_c();
	int n, k;
	cin >> n >> k;
	int count = 1;
	while (n--)
	{
		int temp = count * 2;
		int temp1 = count + k;
		if (temp > temp1)
			count = temp1;
		else
			count = temp;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    int a[200];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int r=0,flag=0;
    while(flag == 0){
        for(int i=0;i<n;i++){
            if(a[i] % 2 == 0){
                a[i] /= 2;
            }else{
                flag = 1;
            }
        }
        r++;
    }
    cout << r-1 << endl;
    return 0;
}

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

using namespace std;

int main(){
  int n;
  long a[11111];

  cin>>n;
  for(int i = 0;i<n;i++){
    cin>>a[i];
  }
  long ans = 0;
  for(int i = 0;i<n;i++){
    while(a[i]%2==0){
      ans++;
      a[i] /= 2;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>

const size_t di[]={size_t(-1), 0, 1, 0};
const size_t dj[]={0, size_t(-1), 0, 1};
const int INF=1e9;
const size_t dti[]={0, 0, 1, 0, 0, 0, 0, 0, size_t(-1)};
const size_t dtj[]={0, 0, 0, 0, size_t(-1), 0, 1, 0, 0};

int testcase_ends() {
  size_t H, W;
  scanf("%zu %zu", &H, &W);

  if (H == 0 && W == 0)
    return 1;

  std::vector<std::string> s(H);
  size_t si=-1, sj=-1;
  size_t ti=-1, tj=-1;
  for (size_t i=0; i<H; ++i) {
    char buf[128];
    scanf("%s", buf);
    s[i] = buf;
    for (size_t j=0; j<W; ++j) {
      if (s[i][j] == 'A') {
        si = i;
        sj = j;
      } else if (s[i][j] == 'B') {
        ti = i;
        tj = j;
      }
    }
  }

  char buf[128];
  scanf("%s", buf);
  std::string t=buf;

  std::queue<std::pair<size_t, size_t>> q;
  q.emplace(si, sj);
  std::vector<std::vector<int>> dp(H, std::vector<int>(W, INF));
  dp[si][sj] = 0;
  while (!q.empty()) {
    std::pair<size_t, size_t> p=q.front();
    q.pop();
    size_t i=p.first, j=p.second;
    for (size_t k=0; k<4; ++k) {
      size_t ni=i+di[k], nj=j+dj[k];
      if (!(ni < H && nj < W)) continue;
      if (s[ni][nj] == '#') continue;
      if (dp[ni][nj] <= dp[i][j] + 1) continue;
      dp[ni][nj] = dp[i][j] + 1;
      q.emplace(ni, nj);
    }
  }

  // for (size_t i=0; i<H; ++i)
  //   for (size_t j=0; j<W; ++j)
  //     if (dp[i][j] < INF)
  //       printf("%d%c", dp[i][j], j+1<W? ' ':'\n');
  //     else
  //       printf("#%c", j+1<W? ' ':'\n');

  size_t tlen=t.length();
  std::pair<size_t, size_t> res(-1, -1);
  int tt=INF;
  for (int i=0; i<1000; ++i) {
    size_t nti=ti+dti[t[i%tlen]-'0'];
    size_t ntj=tj+dtj[t[i%tlen]-'0'];
    if (nti < H) ti = nti;
    if (ntj < W) tj = ntj;
    if (dp[ti][tj] < INF) {
      if (dp[ti][tj] > i+1) continue;
      if (i+1 < tt) {
        tt = i+1;
        res = {ti, tj};
      }
    }
  }
  if (tt < INF)
    return !printf("%d %zu %zu\n", tt, res.first, res.second);
  printf("impossible\n");
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2816
// atcoder/abc142/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#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, m;
  while (cin >> n >> m) {
    int a[m];
    int mask[m];
    for (int i = 0; i < m; ++i) {
      int b;
      cin >> a[i] >> b;
      vector<int> c(b);
      cin >> c;
      mask[i] = 0;
      each (j, c) mask[i] += (1 << (j - 1));
    }

    const int M = 1000 + 5;
    const int BIT = (1 << 12) + 1;
    const lli inf = 1LL << 60;
    static lli dp[M][BIT];
    fill(&dp[0][0], &dp[M - 1][BIT - 1] + 1, inf);
    dp[0][0] = 0;

    for (int i = 0; i < m; ++i) {
      for (int bit = 0; bit < BIT; ++bit) {
        setmin(dp[i + 1][bit], dp[i][bit]);
        setmin(dp[i + 1][bit | mask[i]], dp[i][bit] + a[i]);
      }
    }

    lli mn = 1LL << 60;
    for (int i = 0; i < M; ++i) {
      setmin(mn, dp[i][(1 << n) - 1]);
    }
    cout << (mn != inf ? mn : -1) << endl;
  }

  return 0;
}


Measured memory_bytes: 32512
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: u64 = sc.read();

    for h in 1..3501 {
        for w in 1..3501 {
            // 4/n - 1/h - 1/w = 4*h*w - w*n - h*n
            if 4 * h * w < w * n + h * n {
                continue;
            }
            let a = 4 * h * w - w * n - h * n;
            let b = h * n * w;
            if a > 0 && b % a == 0 {
                println!("{} {} {}", b / a, w, h);
                return;
            }
        }
    }
    unreachable!()
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
using namespace std;
int A[9];
int main() {
	int N;
	
	long int a;
	cin >> N ;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a <= 399)A[0]++;
		if (400 <= a && a <= 799)A[1]++;
		if (800 <= a && a <= 1199)A[2]++;
		if (1200 <= a && a <= 1599)A[3]++;
		if (1600 <= a && a <= 1999)A[4]++;
		if (2000 <= a && a <= 2399)A[5]++;
		if (2400 <= a && a <= 2799)A[6]++;
		if (2800 <= a && a <= 3199)A[7]++;
		if (a >= 3200)A[8]++;
	}
	long long int Y = 0;
	for (int i = 0; i < 8; i++) {
		if (A[i] > 0)Y++;
	}

	long long int Z = A[8] + Y;
	if (Y == 0)Y=1;



	cout << Y << ' ' << Z << endl;


	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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;
}

int main() {
  int n;
  cin >> n;
  vector<int> a = vector<int>(n);
  rep(i, n) cin >> a[i];

  int c4 = 0;
  int c2 = 0;
  int c1 = 0;
  rep(i, n) {
    if(a[i] % 4 == 0)
      c4++;
    else if(a[i] % 2 == 0)
      c2++;
    else
      c1++;
  }

  if(c2 > 0) {
    c1++;
  }
  if(c4 + 1 >= c1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long A = sc.nextLong();
    long B = sc.nextLong();
    long min = A * (N - 1) + B;
    long max = B * (N - 1) + A;
    long ans = Math.max(0, max - min + 1);
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {  
    long long int a, b, x;
    cin >> a >> b >> x;
    cout << b / x + 1 - a / x - 1 + (a % x == 0 ? 1 : 0) << endl;   
}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0); ios_base::sync_with_stdio(0);
    int n,cnt1=0,cnt2=0,cnt3=0,cnt4=0; cin>>n;
    while(n--){
        string s; cin>>s;
        if(s=="AC")cnt1++;
        else if(s=="WA")cnt2++;
        else if(s=="TLE")cnt3++;
        else if(s=="RE")cnt4++;
    }
    cout<<"AC x "<<cnt1<<'\n';
    cout<<"WA x "<<cnt2<<'\n';
    cout<<"TLE x "<<cnt3<<'\n';
    cout<<"RE x "<<cnt4<<'\n';
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>

using namespace std;

int main(){
  int a, b ,c, d;
  cin >> a >> b >> c >> d;
  if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int A, B, C;
  cin >> A >> B >> C;
  if (A < B) swap(A, B);
  if (A < C) swap(A, C);
  if (A == 7 && B == 5 && C == 5) {
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define F first
#define S second

using namespace std;

typedef long long ll;

ll n, d, a;
pair<ll, ll> b[200005];
ll e[200005];
ll c[200005];
ll ans;

int main()
{
    scanf("%lld%lld%lld", &n, &d, &a);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld%lld", &b[i].F, &b[i].S);
        b[i].S = (b[i].S + a - 1) / a;
        e[i] = b[i].F;
    }
    sort(b, b + n);
    sort(e, e + n);
    for(ll i = 0; i < n; i++)
    {
        c[i] += c[i - 1];
        b[i].S -= c[i];
        if(b[i].S <= 0) continue;
        c[i] += b[i].S;
        ans += b[i].S;
        ll t = upper_bound(e, e + n, b[i].F + 2 * d) - e;
        c[t] -= b[i].S;
    }
    printf("%lld\n", ans);
    return 0;
}


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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, m; cin>>n>>m;
    ll sum=0;
    map<ll, ll> mp;
    mp[0]++;
    for(int i=0; i<n; i++){
        int a; cin>>a;
        sum+=a;
        mp[sum%m]++;
    }
    
    ll ans=0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        ll num=itr->second;
        ans+=num*(num-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int d;
  cin>>d;

  vector<ll> p(26);
  rep(i,26) {
    cin>>p[i];
  }


  vector<vector<ll>> q(d,vector<ll>(26));
  rep(i,d) {
    rep(j,26) {
      cin>>q[i][j];
    }
  }

  ll pre=0;
  vector<int> r(26,0);
  rep(i,d-5){
    ll ans=-INF;
    ll memo;
    rep(j,26){
      ll sum=pre;
      auto last=r;
      sum+=q[i][j];
      last[j]=i+1;
      rep(k,26){
        sum-=103*p[k]*(i+1-last[k])/20;
      }
      if(sum>ans) {
        memo=j;
        chmax(ans,sum);
      }
    }
    cout << memo+1 << endl;
    pre=ans;
    r[memo]=i+1;
  }

  ll answer=-INF;
  ll A,B,C,D,E;
  vector<int> zen(5);
  rep(i,26){
    rep(j,26){
      rep(k,26){
        rep(l,26){
          rep(m,26){
            zen[0]=i;
            zen[1]=j;
            zen[2]=k;
            zen[3]=l;
            zen[4]=m;

            ll sum=0;
            auto last=r;
            rep(n,5){
              sum+=q[d-5+n][zen[n]];
              last[zen[n]]=d-5+n+1;
              rep(o,26){
                sum-=p[o]*(d-5+n+1-last[o]);
              }
            }

            if(sum>answer) {
              A=zen[0];
              B=zen[1];
              C=zen[2];
              D=zen[3];
              E=zen[4];
            }
            chmax(answer,sum);

          }
        }
      }
    }
  }

  cout << A+1 << endl;
  cout << B+1 << endl;
  cout << C+1 << endl;
  cout << D+1 << endl;
  cout << E+1 << endl;
  
}

Measured memory_bytes: 3744
s = str(input())
s=s[::-1]
mod = 2019
li = [0]*(len(s)+1)
cnt=1
for i in range(len(s)):
    li[i+1]=li[i] + int(s[i]) * cnt
    li[i+1]%=mod
    cnt*=10
    cnt%=mod
import collections
A=collections.Counter(li[1:]);ans=0
for u,v in A.items():
    ans+=v*(v-1)//2
    if u==0:
        ans+=v
print(ans)





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

import heapq as hp


def main():
    N, K, Q = map(int, input().split())
    A = list(map(int, input().split()))

    NUM = sorted(list(set(A)))

    ans = 10**10
    for n in NUM:
        Qs = []
        q = []
        for i in range(N):
            if A[i] < n:
                if q:
                    Qs.append(q)
                    q = []
                continue
            if not q:
                q = [A[i]]
            else:
                hp.heappush(q, A[i])
        if q:
            Qs.append(q)
        P = []
        for q in Qs:
            l = len(q)
            if l < K: continue
            for _ in range(min(Q, l-K+1)):
                v = hp.heappop(q)
                P.append(v)
        if len(P) < Q:
            break
        P.sort()
        ans = min(ans, P[Q-1]-P[0])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 64348
#include <stdio.h>
#include <iostream>
 
using namespace std;
 
void uru(int c, int d) {
    int counter = 0;
 
    for (int i = c; i <= d; i++) {
        if (i % 4 == 0) {
            if (i % 100 == 0) {
                if (i % 400 == 0) {
                    cout << i << endl;
                    counter++;
                } 
            } else {
                cout << i << endl;
                counter++;
            }
        }
    }
    if (counter == 0) {
        cout << "NA" << endl;
    }
    //cout << endl;
    return;
}
 
int main() {
    int a,b;
 	bool flag=false;
    while (cin >> a >> b) {
    	if (a == 0 && b == 0) {
            break;
        }
    	if(flag) cout<<endl;
            uru(a,b);
    	flag=true;
    }
	//cout<<000000<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(){
	int N, M; 
	cin >> N >> M; 
	vector<int> A[310] = {}; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			int a; 
			cin >> a; 
			A[i].push_back(a); 
		}
	}
	int ans = 314; 
	for(int q = 0; q < M; q++){
		int count[310] = {}; // 現時点で一番好きなスポーツの種類をカウント
		for(int i = 0; i < N; i++){
			count[A[i].at(0)] ++;  
		}
		int mx = 0; int ind = 0; 
		for(int j = 1; j <= M; j++){
			if(mx < count[j]){
				ind = j; 
				mx = max(mx, count[j]);
			} 
		}
		ans = min(mx, ans); 
		for(int i = 0; i < N; i++){
			for(int j = 0; j < M; j++){
				if(A[i].at(j) == ind){
					A[i].erase(A[i].begin() + j); //最大値を与えるスポーツの1つを除去
					break; 
				}
			}
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 896
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
#define reps(i,j,k) for(int i = j; i <  k; i++)
#define rep(i,j) reps(i,0,j)
void chenge(char str[10],char sub[35]){
	int numb[10]={0};
	rep(i,8){
		if(str[i] >= 'a')numb[i] = str[i]-'a'+10;
		else numb[i] = str[i] - '0';
	}
	rep(i,8){
		int x[]={8,4,2,1};
		reps(j,i*4,(i+1)*4){
			if(numb[i]-x[j%4] >= 0){
				numb[i]-=x[j%4];
				sub[j] = '1';
			}
			else sub[j] = '0';
		}
	}
	sub[32] = '\0';
	return;
}
int main(){
	int Q;
	scanf("%d",&Q);
	while(Q--){
		char str[10];
		char bin[35];
		scanf("%s",str);
		chenge(str,bin);
		double ans = 0.0;
		int index = 25;
		reps(i,1,25){
			if(bin[i]=='1')ans += pow(2,24-i);
		}
		reps(i,25,32){
			if(bin[i]=='1'){
				ans += pow(0.5,i-24);
				index = i;
			}
		}
		if(bin[0]=='1')ans *= -1.0;
		char hoge[50];
		sprintf(hoge,"%s%d%s","%.", index-24 ,"lf\n");
		printf(hoge,ans);
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

char score[15];

main()
{
        rep(i,15)score[i]='o';
        string s; cin>>s;
        int n=s.size();
        rep(i,n)score[i]=s[i];
        int cnt=0;
        rep(i,15)cnt+=score[i]=='o';
        if(cnt>=8)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = n - 1; i>= 0; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;

const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];
	// i - j = a[i] + a[j] 
	// a[j] + j i= i - a[i]
	map<int,int> freq;
	ll cnt = 0;
	rep(i,n){
		cnt+=freq[i - a[i]];
		freq[a[i] + i]++;
	}
	cout<<cnt<<nl;
	return 0;
}



Measured memory_bytes: 21096
/**
 * Copyright (c) 2017, xehoth
 * All rights reserved.
 * 「ARC 085E」MUL 06-12-2017
 *
 * @author xehoth
 */
#include <bits/stdc++.h>

namespace {

struct Node {
    int v, index;
    long long f;

    Node(int v, long long f, int index) : v(v), f(f), index(index) {}
};

const int MAXN = 100 + 9;
const long long INF = LLONG_MAX / 2;

std::vector<Node> edge[MAXN];

inline void addEdge(const int u, const int v, const long long f) {
    edge[u].push_back(Node(v, f, edge[v].size()));
    edge[v].push_back(Node(u, 0, edge[u].size() - 1));
}

int h[MAXN], gap[MAXN];

inline long long sap(int v, long long flow, int s, int t, int n) {
    if (v == t) return flow;
    register long long rec = 0;
    static int iter[MAXN];
    for (register int &i = iter[v]; i < edge[v].size(); i++) {
        register Node *p = &edge[v][i];
        if (h[v] == h[p->v] + 1) {
            register long long ret =
                sap(p->v, std::min(flow - rec, p->f), s, t, n);
            p->f -= ret, edge[p->v][p->index].f += ret;
            if ((rec += ret) == flow || h[s] >= n) return iter[v] = 0, rec;
        }
    }
    if (--gap[h[v]] == 0) h[s] = n;
    gap[++h[v]]++, iter[v] = 0;
    return rec;
}

inline long long sap(int s, int t, int n) {
    register long long ret = 0;
    for (gap[0] = n; h[s] < n;) ret += sap(s, INF, s, t, n);
    return ret;
}

inline void solve() {
    register int n;
    std::cin >> n;
    const int S = 0, T = n + 1;
    register long long sum = 0;
    for (register int i = 1, a; i <= n; i++) {
        std::cin >> a;
        if (a <= 0)
            addEdge(S, i, -a);
        else
            addEdge(i, T, a), sum += a;
    }
    for (register int i = 1; i <= n; i++)
        for (register int j = i + i; j <= n; j += i) addEdge(i, j, INF);
    std::cout << sum - sap(S, T, T + 1);
}
}  // namespace

int main() {
    // freopen("sample/1.in", "r", stdin);
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    int N = in.nextInt();
    int K = in.nextInt();
    char[] s = in.next().toCharArray();

    List<Integer> nums = new ArrayList<Integer>();

    char prev = s[0];
    int count = 1;

    for (int i = 1; i < N; i++) {
      if (prev == s[i]) {
        count++;
      } else {
        nums.add(count);
        count = 1;
        prev = s[i];
      }
    }
    nums.add(count);

    // Make nums start with '0' count
    if (s[0] == '1') {
      nums.add(0, 0);
    }
    // Make num ends with '0' count
    if (s[N - 1] == '1') {
      nums.add(0);
    }

    int numflip = 0;
    int ans = 0;
    int curr = 0;

    for (int i = 0; i < nums.size(); i++) {
      // We are looking at '0' count
      if (i % 2 == 0) {
        if (numflip < K) {
          numflip++;
        } else {
          int kickedOut0Index = i - K * 2;
          curr -= nums.get(kickedOut0Index);
          if (0 < kickedOut0Index) {
            curr -= nums.get(kickedOut0Index - 1);
          }
        }
        curr += nums.get(i);
      }
      // We are looking at '1' count
      else {
        curr += nums.get(i);
      }
      ans = Math.max(ans, curr);
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 26380
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		Integer[] numbers = new Integer[n];
		int alice = 0;
		int bob = 0;

		for (int i = 0; i < n; i++) {
			numbers[i] = scanner.nextInt();
		}
		Arrays.sort(numbers, Collections.reverseOrder());

		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				alice += numbers[i];
			} else {
				bob += numbers[i];
			}
		}

		System.out.println(Math.abs(alice - bob));

		System.out.println();

		scanner.close();
	}
}

Measured memory_bytes: 21844
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	s := []byte(getString())
	for i := 0; i < len(s); i++ {
		s[i] = byte((int(s[i]-'A')+N)%26 + 'A')
	}
	out(string(s))
}


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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin>>s;
	int sum=0;
	REP(i,s.length()){
		if(s[i]=='C')sum=1;
		if(sum==1&&s[i]=='F'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

int main(void)
{
	int h, m, s;
	
	scanf("%d %d %d", &h, &m, &s);
	while (h != -1 | m != -1 | s != -1){
		int remain = 7200;
		
		remain -= h * 3600 + m * 60 + s;
		h = remain / 3600;
		m = (remain % 3600) / 60;
		s = remain % 60;
		printf("%02d:%02d:%02d\n", h, m, s);
		h *= 3;
		m *= 3;
		if (m >= 60){
			h += m / 60;
			m %= 60;
		}
		s *= 3;
		if (s >= 60){
			m += s / 60;
			s %= 60;
		}
		printf("%02d:%02d:%02d\n", h, m, s);
		
		scanf("%d %d %d", &h, &m, &s);
	}
	
	return 0;
}

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

using namespace std;
int A, B, C;
int K;
bool found;
bool dfs(int A, int B, int C, int count);

int main(void) {
 cin >> A >> B >> C;
 cin >> K;
 found = false;
 int count = 0;
 bool ans = false;
 
 ans = dfs(A, B, C, count);

 if (ans || found) {
   cout << "Yes" << endl;
 } else {
   cout << "No" << endl;
 }
}

bool dfs(int A, int B, int C, int count) {
  //cout << "count: " << count << endl;
  //cout << "A: " << A << endl;
  //cout << "B: " << B << endl;
  //cout << "C: " << C << endl;
  //cout << "---" << endl;
  if (count > K) {
    return false;
  } else if (B > A && C > B) {
    found = true;
    return true;
  } else if(dfs(A*2, B, C, count + 1)) {
    found = true;
    return true;
  } else if(dfs(A, B*2, C, count + 1)) {
    found = true;
    return true;
  } else if(dfs(A, B, C*2, count + 1)) {
    found = true;
    return true;
  } else {
    return false;
  }
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	vector<string> a;
	while (true)
	{
		string s;
		cin >> s;
		if(s == "0") break;
		a.push_back(s);
	}

	vi ans;
	rep(i, a.size())
	{
		int sum = 0;
		rep(j, a[i].size())
		{
			sum += a[i][j] - '0';
		}
		ans.push_back(sum);
	}

	rep(i, ans.size()) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 3192
#include<stdio.h>

int main(void){
    int a,b,c;
    
    scanf("%d%d%d",&a,&b,&c);
    
    if(a<b&&b<c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
    
}


Measured memory_bytes: 2552
import numpy as np

N, M = map(int, input().split())
A_l = np.array(list(map(int, input().split())))


A_l = np.sort(A_l)

thr = np.sum(A_l) / 4 / M

num = np.sum(A_l >= thr)

if num >= M:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 12508
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    priority_queue<ll> qu;
    rep(i,N) {
        cin>>A[i];
        qu.emplace(A[i]);
    }
    ll ans=0;
    while(1){
        ll x=qu.top();
        if(x+ans<=N-1) break;
        ll buf=(x+ans-(N-1)+(N-1))/N;
        x-=buf*(N+1);
        ans+=buf;
        qu.pop();
        qu.emplace(x);
    }
    cout<< ans <<"\n";

}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	int n;
	cin >> n;
	cout << n * (n + 1) / 2 << endl;
}


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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

int main(){
//  ios::sync_with_stdio(false);
//  cin.tie(0);
  string s;
  cin >> s;
  string a = "10";
  bool f = 0;
  int ans = inf;
  int k = 0;
  REP(i,sz(s)) {
    if (s[i] != a[f]) k++;
    f = !f;
  }
  ans = min(ans,k);
  k = 0;
  f = 1;
  REP(i,sz(s)) {
    if (s[i] != a[f]) k++;
    f = !f;
  }
  ans = min(ans,k);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
global count
count = 0


def merge(num_list, left, mid, right):
    a = mid - left
    b = right - mid
    L = []
    R = []

    for i in range(a):
        L.append(num_list[left + i])
    for i in range(b):
        R.append(num_list[mid + i])

    L.append(float("inf"))
    R.append(float("inf"))

    i = 0
    j = 0
    global count

    for k in range(left, right):
        if L[i] <= R[j]:
            num_list[k] = L[i]
            i += 1
        else:
            num_list[k] = R[j]
            j += 1
        count += 1


def mergeSort(num_list, left, right):
    if left+1 < right:
        mid = (left + right) / 2
        mergeSort(num_list, left, mid)
        mergeSort(num_list, mid, right)
        merge(num_list, left, mid, right)

    return num_list


if __name__ == "__main__":
    num = raw_input()
    line = raw_input()

    num_list = line.strip().split()
    num_list = map(int, num_list)

    merge_list = mergeSort(num_list, 0, len(num_list))
    merge_list = map(str, merge_list)
    print " ".join(merge_list)
    print count

Measured memory_bytes: 75252
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define X first
#define Y second

using namespace std;

int n,m;

int main() {
  while(1){
    int ms[55];
    cin>>n;
    if(n==0) break;
    pair<int,int> lines[55][15];
    REP(i,0,n+1){
      cin>>m;
      ms[i] = m;
      REP(j,0,m){
        int x, y;
        cin>>x>>y;
        lines[i][j] = make_pair(x,y);
      }
    }
    //
    pair<int,int> data[55][15];//????????????????????????????????????????????£????????????????????????????????????????¬¬??????,??????????????????
    REP(i,0,n+1){
      int dir=-1, len=-1;
      REP(j,1,m-1){//j-1??¨j?????????j+1??????????????????j???????????\??????
        /*??????*/
        if(lines[i][j-1].X == lines[i][j].X){
          if(lines[i][j-1].Y < lines[i][j].Y){//??????????????????
            if(lines[i][j].X < lines[i][j+1].X ) dir = 1;
            else dir = 0;
          }else{//?????????????????????
            if(lines[i][j].X > lines[i][j+1].X ) dir = 1;
            else dir = 0;
          }
          len = abs(lines[i][j-1].Y - lines[i][j].Y);
        /*?¨????*/
        }else{
          if(lines[i][j-1].X < lines[i][j].X){ //??????????????????
            if(lines[i][j].Y > lines[i][j+1].Y ) dir = 1;
            else dir = 0;
          }else{//?????????????????????
            if(lines[i][j].Y < lines[i][j+1].Y ) dir = 1;
            else dir = 0;
          }
          len = abs(lines[i][j-1].X - lines[i][j].X);
        }
        data[i][j] = make_pair(len,dir);
      }
      //data[i][0] = make_pair(-1,-1);
      data[i][0] = make_pair(max(abs(lines[i][0].Y-lines[i][1].Y),abs(lines[i][0].X-lines[i][1].X)),-1);
      data[i][m-1] = make_pair(max(abs(lines[i][m-1].Y-lines[i][m-2].Y),abs(lines[i][m-1].X-lines[i][m-2].X)),-1);
    }
    //test
    /*
    REP(i,0,n+1){
      cout<<"i : "<<i<<endl;
      REP(j,0,m){
        cout<<"( "<<data[i][j].first<<", "<<data[i][j].second<<" ), ";
      }
      cout<<endl;
    }
    */
    //check
    REP(i,1,n+1){
      bool flag[] = {true,true};
      REP(j,0,m){
        if(data[0][j] != data[i][j]) flag[0] = false;
      }
      REP(j,1,m-1){
        if(data[0][j].first != data[i][m-j].first ||
          data[0][j].second == data[i][m-j-1].second  ) flag[1] = false;
      }
      if(ms[0] != ms[i]) flag[0]=false, flag[1]=false;
      if(flag[0] || flag[1]) cout<<i<<endl;
    }
    cout<<"+++++"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3012
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    if (a+b < c){
        cout << "NA";
    }
    else if (a < c){
        cout << (c-a);
    }
    else if (a > c){
        cout << "0";
    }
    cout << endl;
}


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

using namespace std;

int main()
{
  int n, k, x, y;
  scanf("%d %d %d %d", &n, &k, &x, &y);
  if (n < k)
    printf("%d", n * x);
  else
    printf("%d", k * x + (n - k) * y);
}

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;
using p = pair<int, int>;
typedef vector<int> vi;
using Graph = vector<vector<int>>;

int main() {
  int a, b;
  cin >> a >> b;
  int num_min = min(a, b);
  int num_max = max(a, b);

  rep (i, num_max) cout << num_min;
  cout << endl;
  // char in[110];
  // rep (i, b) in[i] = '0' + a;
  // cout << in << endl;
  // string L = in;
  // rep (i, a) in[i] = '0' + b;
  // cout << in << endl;
  // in[a] = 0;
  // cout << in << endl;
  // string R = in;
  // cout << min(L, R).c_str() << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=100005;
const int mo=1000000007;
int n,ans;
char s[N];
int las[N],S[N];
int suf[N][3],f[N];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	bool fl=0;
	For(i,1,n-1) if (s[i]==s[i+1]) fl=1;
	if (!fl) return puts("1"),0;
	For(i,1,n) S[i]=(S[i-1]+s[i]-'a'+1)%3;
	For(i,0,2) suf[n+1][i]=n+1;
	Rep(i,n,1){
		For(j,0,2)
			suf[i][j]=suf[i+1][j];
		suf[i][S[i]]=i;
	}
	f[0]=1;
	For(i,1,n+1){
		if (S[i-1]==S[n]&&i!=1) ans=(ans+f[i-1])%mo;
		int nx=suf[i+1][3-S[i-1]-S[i]];
		f[i]=(f[i]+f[i-1])%mo;
		f[nx]=(f[nx]+f[i-1])%mo;
	}
	printf("%d\n",ans);
}
/*
babba
baaa
bba
aa
b
*/

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

//ライブラリ始まり

//定数
//円周率
const double pi = 3.1415926535897932384;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数
//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}
//to_char
char to_char(int i){
  if (i == 0) {
    return '0';
  }
  if (i == 1) {
    return '1';
  } 
  if (i == 2) {
    return '2';
  } 
  if (i == 3) {
    return '3';
  }
  if (i == 4) {
    return '4';
  } 
  if (i == 5) {
    return '5';
  } 
  if (i == 6) {
    return '6';
  }
  if (i == 7) {
    return '7';
  } 
  if (i == 8) {
    return '8';
  } 
  if (i == 9) {
    return '9';
  }
  return ' ';  
}
//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false; // 1や0,-1は素数ではない
  }
  if (x == 2) {
    return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false; // 割れたら素数じゃない
    }
  }
  return true;
}

//ライブラリ終わり
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int> A(N, 0);
  for (int i = 1; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      A.at(min(abs(X - j) + abs(Y - i) + 1, 
               min(abs(i - j), abs(X - i) + abs(Y - j) + 1)))++;
    }
  }
  for (int i = 1; i < N; i++) {
    cout << A.at(i) << endl;
  }
}

Measured memory_bytes: 3604
var
	n,s,b,t,c,ans,i:int64;
function f(b,n:int64):int64;
var t,c:int64;
begin
	t:=n;
	c:=0;
	while t>0 do begin
		c:=c+t mod b;
		t:=t div b;
	end;
	f:=c;
end;
begin
	read(n,s);
	if n=s then begin
		writeln(n+1);
		exit;
	end;
	i:=1;
	ans:=n+s;
	while i*i<=n do begin
		if(i>1)and(f(i,n)=s)and(ans>i)then ans:=i;
		if n div i>1 then begin
			t:=f(n div i,n);
			if(t<=s)and((s-t)mod i=0)then begin
				b:=n div i-(s-t)div i;
				if(b>1)and(f(b,n)=s)and(ans>b)then ans:=b;
			end;
		end;
		inc(i);
	end;
	if ans=n+s then writeln(-1)else writeln(ans);
end.


Measured memory_bytes: 128
n=int(input())
A=[{} for _ in range(n)]
for i in range(n):
  for _ in range(int(input())):
    x,y=map(int,input().split())
    A[i][x]=y
a=0
for i in range(2**n):
  t=0
  for j in range(n):
    if i>>j&1:
      if A[j] and any(i>>~-k&1!=A[j][k] for k in A[j]): break
      else: t+=1
  else: a=max(a,t)
print(a)

Measured memory_bytes: 9128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  LL k, a, b;
  cin >> k >> a >> b;

  if (a >= b || b - a < 2) {
    cout << 1 + k << endl;
    return 0;
  }

  LL biscuits = 1;
  LL money = 0;

  for (int i = 0; i < k; i++) {
    if (money == 0) {
      if (i+1 >= k || biscuits < a) {
        biscuits ++;
      } else {
        biscuits -= a;
        money ++;
      }
    } else if (money > 0) {
      biscuits += b;
      money --;
    }
    // cout << "INDEX " << i << ": " << biscuits << endl;
  }

  cout << biscuits << endl;

  return 0;
}

Measured memory_bytes: 256