akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = b/a;
		if(ans > c) {
			ans = c;
		}
		System.out.println(ans);
		sc.close();
	}
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int a,b;
	int h[1001];
	REP(i,1001) h[i] = 0;
	while(true){
	    cin >> a;
	    if(cin.eof()) break;
	    cin >> b;
	    if(a == 0 && b == 0) break;
	    h[a]++;
	    h[b]++;
	}
	if(cin.eof()) break;
	int od = 0;
	REP(i,1001){
	    if(h[i] % 2 == 1){
		od++;
	    }
	}
	if(od == 2 && h[1] % 2 == 1 && h[2] % 2 == 1) cout << "OK" << endl;
	else cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main(void)
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);

    rep(i, m) cin >> a[i];
    int sum = 0;
    rep(i, m) {
        sum += a[i];
    } 
    if (n - sum >= 0) cout << n - sum << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3636
#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;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 100005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int num_nodes,M,cnt,label[MAXN];
ll dp[MAXN],ans[MAXN],pref[MAXN],suff[MAXN],v[MAXN];
vector<int> connections[MAXN];
//vector<ll> v[MAXN];

ll dfs(int node, int prev){
	dp[node] = 1;
	for(int check:connections[node]){
		if(check == prev) continue;
		dp[node] = (dp[node]*(dfs(check,node)+1))%M;
	}
	return dp[node];
}

ll solve(int node, int prev){
	ans[node] = dp[node];
	pref[0] = suff[connections[node].size()+1] = 1;

	for(int i=1; i<=connections[node].size(); i++){
		int check = connections[node][i-1];
		pref[i] = (pref[i-1]*(dp[check]+1))%M;
	}
	for(int i=(int)connections[node].size(); i>=1; i--){
		int check = connections[node][i-1];
		suff[i] = (suff[i+1]*(dp[check]+1))%M;
	}
//	v[node].resize(connections[node].size()+2);
	for(int i=1; i<=connections[node].size(); i++){
		int check = connections[node][i-1];
		if(!label[check]) label[check] = ++cnt;
		v[label[check]] = (pref[i-1]*suff[i+1])%M;
	}
//		v[node][i] = (pref[i-1]*suff[i+1])%M;
	ll ov1 = dp[node];
	for(int i=1; i<=connections[node].size(); i++){
		int check = connections[node][i-1];
		if(check == prev) continue;
		ll o_v = dp[check];

		ll n_v = v[label[check]]; //v[node][i];
		dp[node] = n_v;

		n_v = ((n_v+1)*dp[check])%M;
		dp[check] = n_v;

		solve(check,node);
		dp[check] = o_v;
		dp[node] = ov1;
	}
//	v[node].clear();
}

int main(){
	scanf("%d %d",&num_nodes,&M);
	for(int i=1; i<num_nodes; i++){
		int a,b; scanf(" %d %d",&a,&b);
		connections[a].pb(b);
		connections[b].pb(a);
	}
	dfs(1,-1);
	solve(1,-1);
	for(int i=1; i<=num_nodes; i++)
		printf("%lld\n",ans[i]);
}

Measured memory_bytes: 16640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
const int MaxN = 50;
LL a[MaxN + 5];
LL cnt[MaxN + 5];
int n;

int main(){
	while(~scanf("%d", &n)){
		for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
		LL tot = 0, ans = 0;
		bool flag = true;
		while(flag){
			flag = false;
			tot = 0;
			for(int i = 1; i <= n; i++){
				cnt[i] = a[i] / n;
				a[i] = a[i] % n;
				tot += cnt[i];
			}
			ans += tot;
			for(int i= 1; i <= n; i++){
				a[i] += tot - cnt[i];
				if(a[i] >= n) flag = true;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
using namespace std;
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)

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

    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> graph(N, vector<ll>());

    REP (i, M) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<ll> island0(N, 0), islandL(N, 0);
    for (auto e : graph[0]) island0[e]++;
    for (auto e : graph[N-1]) islandL[e]++;

    string ans = "IMPOSSIBLE";

    REP (i, N) {
        if ((island0[i] == 1) && (islandL[i] == 1)) {
            ans = "POSSIBLE";
        }
    }

    cout << ans << "\n";
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template<class A, class B>
inline bool chmax(A &a, const B &b) { return b > a ? a = b, 1 : 0; }

template<class A, class B>
inline bool chmin(A &a, const B &b) { return b < a ? a = b, 1 : 0; }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

//IN
void IN() {}
template<class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

//OUTS
template<size_t> struct int_{};
template<class Tuple, size_t Pos>
ostream& print_tuple(ostream& out, const Tuple& t, int_<Pos>) {
  out << get<tuple_size<Tuple>::value-Pos>(t) << " ";
  return print_tuple(out, t, int_<Pos-1>());
}

template <class Tuple>
ostream& print_tuple(ostream& out, const Tuple& t, int_<1>) {
  return out << get<tuple_size<Tuple>::value-1>(t);
}

template<class... Args>
ostream& operator<<(ostream& out, const tuple<Args...>& t) {
  return print_tuple(out, t, int_<sizeof...(Args)>());
}

#define OUTS(...) cout << make_tuple(__VA_ARGS__) << "\n";

//OUTL
void OUTL() {}
template<class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  VAR(int, a, b);
  OUTL(max({a + b, a - b, a * b}));
  return 0;
}


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

int main() {
  int n, q;
  cin >> n >> q;
  vector<ll> a(n + 1), s(n + 1), e(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
    s[i + 1] = s[i] + a[i + 1];
    e[i + 1] = e[i] + ((n - i) % 2 ? a[i + 1] : 0);
  }
  for (; q > 0; q--) {
    int x;
    cin >> x;
    int ok = 0, ng = 1e9;
    while (ok + 1 < ng) {
      int w = (ok + ng) / 2;
      int head = lower_bound(begin(a) + 1, end(a), x - w) - begin(a);
      int tail = lower_bound(begin(a) + 1, end(a), x + w) - begin(a);
      int second = tail - head, first = n + 1 - tail;
      if (second + 1 <= first) {
        ok = w;
      } else if (second + 1 > first) {
        ng = w;
      }
    }
    {
      int head = lower_bound(begin(a) + 1, end(a), x - ok) - begin(a);
      int tail = lower_bound(begin(a) + 1, end(a), x + ok) - begin(a);
      int second = tail - head, first = n + 1 - tail;
      if (second + 1 < first) {
        tail++;
      }
      // cerr << ok << " " << ng << endl;
      // cerr << head << " " << tail << ": " << s[n] - s[tail - 1] << " " << e[head - 1] << endl;
      cout << (s[n] - s[tail - 1]) + e[head - 1] << endl;
    }
  }
}


Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

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

	int n;
	while(cin >> n && n){

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

		int q[65010];
		for(int i = 0; i < n - 1; ++i){
			cin >> q[i];
		}
		sort(q, q + n - 1, greater<int>());

		int a = 0;
		unsigned int m = 0;
		for(int i = n; i >= 0; --i){
			m = max(m, (unsigned int)sum * i);
			sum += q[a];
			++a;
		}

		cout << m << endl;
	}

	return 0;
}
/*
1 2 3
3 3
(8+1)*2=24
*/

Measured memory_bytes: 1716
#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>;

int main() {
    int n, y;
    cin >> n >> y;
    rep(i, n+1) {
        rep(j, n+1) {
            int k = n - i - j;
            if (k >= 0 && i * 10000 + j * 5000 + k * 1000 == y) {
                cout << i << " " << j <<  " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  double p[4][2];
  while(cin>>p[0][0]>>p[0][1]){
    for(int i=1; i<4; i++)
      for(int j=0; j<2; j++)
	cin >>p[i][j];
    for(int i=1; i<4; i++)
      for(int j=0; j<2; j++)
	p[i][j]-=p[0][j];
    double det,im[2][2],s[2];
    det = p[1][0]*p[2][1]-p[1][1]*p[2][0];
    im[0][0] = p[2][1]/det;
    im[1][0] = -p[1][1]/det;
    im[0][1] = -p[2][0]/det;
    im[1][1] = p[1][0]/det;
    for(int i=0; i<2; i++)
      s[i] = im[i][0]*p[3][0]+im[i][1]*p[3][1];
    if(s[0]>0 && s[1]>0 && s[0]+s[1]<1) cout <<"YES"<<endl;
    else cout <<"NO"<<endl;
  }
  return 0;
}

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



int main()
{
    string s[10]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string p;
    cin>>p;
    int idx;
    if(p=="SAT")
    {
        cout<<"1\n";
        return 0;
    }
    for(int i=0;i<7;i++)
    {
        if(p==s[i])
        {
            idx=i;
        }
    }
    int num=0;
    while(1)
    {
        if(s[idx]=="SUN")
        {
            if(num==0)
            {
                cout<<"7\n";
            }
            else
            {
              cout<<num<<endl;
            }
            break;
        }
        else
        {
            num++;
            idx++;
        }
        if(idx>=6)
        {
            idx=0;
            num++;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
 
using namespace std;
 
typedef long long ll;


int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  int x = 0;
  vector <int> a(n);
  multiset <int> have;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    x ^= a[i];
    have.insert(a[i]);
  }
  have.insert(x);
  vector <int> c(have.begin(), have.end());
  c.resize(unique(c.begin(), c.end()) - c.begin());
  vector <int> b(n);
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 0; i < n; ++i) {
    if (have.find(b[i]) == have.end()) {
      cout << "-1\n";
      return 0;
    }
    have.erase(have.find(b[i]));
  }
  auto get = [&] (int id) {
    return lower_bound(c.begin(), c.end(), id) - c.begin();
  };
  int k = c.size();
  vector <vector <int>> g(k);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] != b[i]) {
      g[get(a[i])].push_back(get(b[i]));
      g[get(b[i])].push_back(get(a[i]));
      ++ans;
    }
  }
  vector <int> used(k);
  for (int i = 0; i < k; ++i) {
    if (!used[i] && g[i].size() > 0) {
      ++ans;
      queue <int> q;
      q.push(i);
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto v : g[u]) {
          if (!used[v]) {
            used[v] = 1;
            q.push(v);
          }
        }
      }
    }
  }   
  if (g[get(x)].size() > 0) --ans; 
  cout << ans << '\n';
}


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

using namespace std;

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

    if(a+b<=k)
        cout<<0<<' '<<0<<endl;
    else
    {
        if(a<k)
        {
            k=k-a;
            if(k>=b)
                b=0;
            else b-=k;
            cout<<0<<" "<<b<<endl;
        }
        else
        cout<<a-k<<" "<<b<<endl;


    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int A[200010], result[200010];
int main()
{
  int N;

  int sum=0;
  scanf("%d",&N);
  for(int i=2;i<=N;i++){
    scanf("%d",&A[i]);
    result[A[i]]++;
  }
  for(int i=1;i<=N;i++){
    printf("%d\n",result[i]);
  }
}

Measured memory_bytes: 3228
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

        Set<Integer> s = new HashSet<>();
        s.add(sc.nextInt());
        s.add(sc.nextInt());
        s.add(sc.nextInt());

        System.out.println(s.size() == 2 ? "Yes" : "No");
    }
}


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

int main() {
	string a, b;
	cin >> a >> b;
	for (int i = 0; i < a.length() + b.length(); ++i) {
		if (i % 2 == 0) {
			cout << a[i / 2];
		}
		else {
			cout << b[i / 2];
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io;
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::mem::{replace, swap};

// [NOTE] つかうときには trim() 入れないと RE になるので注意
// abcde
fn read_as_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line
}

// -3.2
fn read_as_primitive<T: FromStr>() -> T {
    let s = read_as_line();
    s.trim().parse().ok().expect("failed to parse input")
}

// 1 -3 0 999
fn read_as_collection<U: FromStr, T: FromIterator<U>>() -> T {
    let s = read_as_line();
    s.trim().split_whitespace().map(|s| s.parse().ok().expect("failed to parse")).collect()
}

// #.#.###..
fn read_as_chars<T: FromIterator<char>>() -> T {
    let s = read_as_line();
    s.trim().chars().collect()
}

// 1 abc
fn read_as_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let s = read_as_line();
    let mut it = s.trim().split_whitespace();
    (
        it.next().unwrap().parse().ok().expect("failed to parse"),
        it.next().unwrap().parse().ok().expect("failed to parse"),
    )
}

// 1.5 -2 abc
fn read_as_triple<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let s = read_as_line();
    let mut it = s.trim().split_whitespace();
    (
        it.next().unwrap().parse().ok().expect("failed to parse"),
        it.next().unwrap().parse().ok().expect("failed to parse"),
        it.next().unwrap().parse().ok().expect("failed to parse"),
    )
}

// Sorting ParitialOrd primitives like f64
// let mut v: Vec<f64> = vec![0.1, 1.0, 2.0];
// v.sort_by_key(|&x| Total(x));
// 
// src: https://qiita.com/hatoo@github/items/fa14ad36a1b568d14f3e
//      https://github.com/rust-lang/rust/pull/53938
//
#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}


fn main() {

    let (a, b): (usize, usize) = read_as_pair();
    if (a + b) % 2 == 1 {
        println!("IMPOSSIBLE")
    } else {
        println!("{}", (a + b) / 2);
    }
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int n = b - a;
  int ans = 0;
  for(int i = 0; i < n; i++)
    ans += i;
  ans -= a;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
class Node:
    def __init__(self, num, parent, *children):
        self.id = num
        self.parent = parent
        self.children = list(children)
        self.depth = 0
        
    def show_info(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print(self.children)


def set_node(i_p):
    i_p = list(map(int, i_p.split()))
    num = i_p[0]
    children = i_p[2:]
    if children:
        T[num].children = children
        for n in children:
            T[n].parent = num

def find_root(node):
    while node.parent != -1:
        node = T[node.parent]
    return node

def set_depth(node, depth):
    node.depth = depth
    for n in node.children:
        set_depth(T[n], depth + 1)



import sys

n = int(sys.stdin.readline())

T = [Node(i, -1) for i in range(n)]

for x in sys.stdin.readlines():
    set_node(x)

r_n = find_root(T[0])

set_depth(r_n, 0)

for n in T:
    n.show_info()

Measured memory_bytes: 61916
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1 == p2)?EOF:*p1++)
using namespace std ;
//char buf[(1 << 22)] , *p1 = buf , *p2 = buf ;
inline int read ()
{
    char c = getchar () ; int x = 0 , f = 1 ;
    while (c < '0' || c > '9') { if (c == '-') f = -1 ; c = getchar () ; }
    while (c >= '0' && c <= '9'){ x = x * 10 + c - '0' ; c = getchar () ; }
    return x * f ;
}
int n , ans , l[2005] , bian ;
priority_queue <int> L , q , p ;
int main ()
{
//    freopen (".in" , "r" , stdin) ; freopen (".out" , "w" , stdout) ;
	cin >> n ;
	for (int i = 1 ; i <= n ; i ++) scanf ("%d" , &l[i]) ;
	sort (l + 1 , l + n + 1) ;
	for (int i = 1 ; i <= n ; i ++)
		for (int j = i + 1 ; j <= n ; j ++)
		{
			ans += lower_bound (l + 1 , l + n + 1 , l[i] + l[j]) - l - j - 1 ;
		}
	cout << ans ;
}




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

int main()
{
	int a, b, n, x, y;
	while (cin >> a >> b, a || b) {
		vector< vector<int> > map(a + 1, vector<int>(b + 1, 1));
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> x >> y;
			map[x][y] = 0;
		}
		for (int i = 0; i <= a; i++)
			map[i][0] = 0;
		for (int j = 0; j <= b; j++)
			map[0][j] = 0;
		for (int i = 1; i <= a; i++) {
			for (int j = 1; j <= b; j++) {
				if ((i != 1 || j != 1) && map[i][j])
					map[i][j] = map[i - 1][j] + map[i][j - 1];
			}
		}
		cout << map[a][b] << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <limits>
using namespace std;
typedef long long ll;

float inf = std::numeric_limits<float>::infinity();

/* 二次元配列の宣言
  vector<vector<int>> tb;
  tb.resize(H);
  for (size_t i = 0; i < H; i++) {
    tb[i].resize(W);
  }
*/
/*
  A.resize(N);
  for (int i = 0; i < N; i++) {scanf("%d",&A[i]);}
*/

int main(void) {
  ll N,ans=0;
  vector<int> T;
  cin >> N;
  T.resize(N);
  for (size_t i = 0; i < N; i++) {
    cin >> T[i];
    ans += T[i];
  }

  ll M;
  cin >> M;
  ll P,X;
  for (size_t i = 0; i < M; i++) {
    cin >> P >> X;
    cout << ans - T[P-1] + X << '\n';
  }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    vec<plint> tasks(N);
    range(i, 0, N) {
        lint A, B; cin >> A >> B;
        tasks.at(i) = {B, A};
    }
    sort(tasks.begin(), tasks.end());
    lint past_time = 0;
    for (const auto& task : tasks) {
        lint time_to_take = task.second, deadline = task.first;
        if (past_time + time_to_take > deadline) {
            cout << "No" << "\n";
            return 0;
        }
        past_time += time_to_take;
    }
    cout << "Yes" << '\n';
}

Measured memory_bytes: 3328
N = int(input())
s = str(input())
answer = [0,0]
for i in range(N):
    if s[i] == 'R':
        answer[0] += 1
    elif s[i] == 'B':
        answer[1] += 1
if answer[0] > answer[1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
//#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};


template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

int main(){
    int n,m; cin >> n >> m;
    long long sec = 1900*m+100*(n-m),num = pow(2,m);
    cout << sec*num << endl;
}

Measured memory_bytes: 504
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
       s: String,
       t: String,
    }
    println!("{}{}", t, s);
}


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

#define vl vector<ll>
#define vi vector<int>

#define ff first
#define ss second

#define pb push_back
#define MOD 1e9+7 
const int nax = 1e6+5;
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "

inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }


int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k; 
    cin>>n>>k;
    vl v(n); 
    for(int i =0;i<n;++i)cin>>v[i];
    sort(v.begin(),v.end(),greater<ll>());
    ll ans  = 0;
    for(int i = k;i<n;++i)ans += v[i];
    cout << ans;


    return 0;
 }

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


void dfs(int v, vector <bool>& used, vector <vector <int>>& g, vector <int>& order) {
	used[v] = 1;
	for (int to: g[v])
		if (!used[to])
			dfs(to, used, g, order);
	order.push_back(v);
	
}


int getMaxPathLenght(int n, vector <vector <int>>& edges) {
	vector <vector <int>> g(n + 1), inv(n + 1);
	for (auto& edge : edges) {
		g[edge[0]].push_back(edge[1]);
		inv[edge[1]].push_back(edge[0]);
	}
	vector<int> order;
	vector <bool> used(n + 1, 0);
	for (int i = 1; i <= n; ++i)
		if (!used[i])
			dfs(i, used, g, order);
	vector <int> dp(n + 1, 0);
	int ans = 0;
	for (int i = 0; i < n ; ++i) {
		for (int from : inv[order[i]]) {
			dp[from] = max(dp[from], 1 + dp[order[i]]);
		}
		ans = max(ans, dp[order[i]]);
	}
	return ans;
}


int main() {
	int n, m, a, b;
	cin >> n >> m;
	vector <vector <int>> edges;
	for(int i = 0; i < m; ++i)
		cin >> a >> b, edges.push_back({a, b});
	cout << getMaxPathLenght(n, edges) << endl;
	return 0;
}

Measured memory_bytes: 21424
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> data(N, vector<int> (N));
  int a, b, ans = 0;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    a--;
    b--;
    data.at(a).at(b) = 1;
    data.at(b).at(a) = 1;
  }
  int flag;
  vector<int> sub(N);
  for(int i = 0; i < N; i++)sub.at(i) = i;
  do {
    flag = 1;
    for(int i = 0; i < N - 1; i++){
      if(data.at(sub.at(i)).at(sub.at(i + 1)) == 0){
        flag = 0;
        break;
      }
    }
    if(flag == 1)ans++;
  } while(next_permutation(sub.begin() + 1, sub.end()));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;

    bool flag = true;
    for (int i = 0; i < s.size(); i += 2) {
        if (s[i] == 'L') flag = false;
    }

    for (int i = 1; i < s.size(); i += 2) {
        if (s[i] == 'R') flag = false;
    }

    if (flag)
        print("Yes");
    else
        print("No");

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

int main() {
  LL H, N;
  cin >> H >> N;
  LL sum = 0;
  for (LL i = 0; i < N; i++) {
    LL a;
    cin >> a;
    sum += a;
  }
  if (H > sum) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


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

#define endl "\n"
#define pb push_back
#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T> inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int a[3], b[3];
	REP(i, 3){
		cin >> a[i] >> b[i];
	}
	bool use[3] = {0}; int pos = 1;
	while(1){
		bool all = 1;
		REP(i, 3){
			if(!use[i]) all = 0;
		}
		if(all) break;

		bool exist = 0;
		REP(i, 3){
			if(use[i]) continue;
			if(a[i] == pos){
				pos = b[i];
				use[i] = 1;
				cerr << a[i] << " -> " << b[i] << endl;
				exist = 1;
			}
			else if(b[i] == pos){
				pos = a[i];
				use[i] = 1;
				cerr << b[i] << " -> " << a[i] << endl;
				exist = 1;
			}
		}
		if(!exist){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int n; cin >> n;
    string s; cin >> s;
    
    for (int i = 0; i < s.size(); ++i) {
        s[i] = ((s[i] - 'A' + n) % 26) + 'A';
        
    }
    cout << s << endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    // cin >> t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    vector<int> deg(N, 0);
    for (int i = 0; i < N; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        deg[a]++;
        deg[b]++;
    }

    queue<int> que;
    for (int v = 0; v < N; v++) {
        if (deg[v] == 1) que.push(v);
    }

    vector<bool> is_pushed(N, false);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        is_pushed[v] = true;

        for (auto nv : G[v]) {
            deg[nv]--;
            if (deg[nv] == 1) que.push(nv);
        }
    }

    int Q; cin >> Q;
    for (int i = 0; i < Q; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        
        if (!is_pushed[a] && !is_pushed[b]) {
            cout << 2 << endl;
        } else {
            cout << 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<int> g[334334];
int dist[334334];
queue<int> q;

int main(void){
	int n,m,i,u,v,s,t;
	fill(dist,dist+334334,INF);
	cin >> n >> m;
	for(i=0; i<m; ++i){
		cin >> u >> v;
		--u; --v;
		g[u].push_back(v+n);
		g[u+n].push_back(v+n*2);
		g[u+n*2].push_back(v);
	}
	cin >> s >> t;
	--s; --t;
	dist[s] = 0ll;
	q.push(s);
	while(!q.empty()){
		u = q.front();
		q.pop();
		for(i=(g[u].l_ength()-1); i>=0; --i){
			v = g[u][i];
			if(dist[v] > dist[u] + 1){
				dist[v] = dist[u] + 1;
				q.push(v);
			}
		}
	}
	cout << ((dist[t]==INF)?(-1):(dist[t]/3)) << endl;
	return 0;
}


Measured memory_bytes: 18816
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
r=[0]*n
for i in range(n):
    if a[i]+i+1<n:
        l[a[i]+i+1]+=1
    if i+1-a[i]>0:
        r[i+1-a[i]]+=1
ans=0
for i in range(n):
    ans+=l[i]*r[i]

print(ans)

Measured memory_bytes: 92932
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#define LL long long
#define Max 100005
using namespace std;
LL  N,A,B,data[Max];
bool c(LL x)
{
	LL sum=0;
	for(int i=0;i<N;i++)
	{
		LL t=data[i]-(x*B);
		if(t>0)
		{
			sum+=ceil(t*1.0/(A-B));
			if(sum>x)
				return false;
		}
	}
	return true;
}
int main()
{
	scanf("%lld%lld%lld",&N,&A,&B);
	LL l=0,r=0;
	for(LL i=0;i<N;i++)
	{
		scanf("%lld",&data[i]);
		r=max(r,data[i]);
	}
	while(l<r)
	{
		LL mid=(l+r)/2;
		if(c(mid))
			r=mid;
		else
			l=mid+1;
	}
	printf("%lld\n",r);
	return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

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

  for (int i = 0; i < s.size(); i++) {
    if (s[i] + n > 'Z')
      cout << char(s[i] + n - 26);
    else
      cout << char(s[i] + n);
  }
  cout << endl;
}


Measured memory_bytes: 256
# B
N, A, B, K = map(int, input().split())

LARGE = 998244353
INVS = [0]*(N+1)
for i in range(1, N+1):
    INVS[i] = pow(i, LARGE-2, LARGE)
NCKL = [1]*(N+1)
for i in range(1, N+1):
    NCKL[i] = (NCKL[i-1] * (N+1-i) * INVS[i]) % LARGE

res = 0
for i in range(N+1):
    if (K - A*i) % B == 0:
        j = (K - A*i) // B
        if j >= 0 and j <= N:
            res += (NCKL[i] * NCKL[j]) % LARGE
print(res % LARGE)

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

/*連続する正の整数の組合せを求める*/
int Search_Consecutive_Integers(int n)
{
  int count = 0;

  for(int i = 1; 2 < n; i++) {
    n = n - i;
      if(n % (i + 1) == 0) {
        if(n >= 1)
          count++;
      }
  }
  return count;
}

int main()
{
  int num;

  while(1) {
    cin >> num;
    if(num <= 0)
      break;
    cout << Search_Consecutive_Integers(num) << endl;
  }

  return 0;
}



Measured memory_bytes: 2984
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int s = sc.nextInt();

        int cnt = s / 3;
        int remain = s % 3;
        int mod = (int)1e9 + 7;

        Comb comb = new Comb(s, mod);

        long res = 0;

        while (0 < cnt) {
            int div = cnt - 1;
            long tmp = comb.nCk2(div+remain, remain);
            res += tmp;
            res %= mod;
            cnt--;
            remain += 3;
        }

        System.out.print(res % mod);

    }


    public class Comb {
        int n;   //　要素数
        int MOD = (int)1e9+7;
        long[] facts;

        public Comb(int n, int MOD){
            this.n = n;
            this.MOD = MOD;
            facts = new long[n+1];
            facts[0] = 1;
            for (int i=1; i<n+1; i++){
                facts[i] = facts[i-1] * i % MOD;
            }
        }

        // O(log(MOD))
        public long modpow(long a, long b){
            if (b==0) return 1;
            else if (b==1) return a;
            long x = modpow(a, b/2);
            return b%2 == 0 ? x * x % MOD : x * (x*a%MOD) % MOD;
        }

        // 逆元。x^(-1)≡x^(p-2) (MOD p) xとpは互いに素。
        public long inv(long n){
            return modpow(n, MOD-2);
        }

        public long nCk1(int n, int k){
            return n < k ? 0: facts[n] * (inv(facts[n-k]) * inv(facts[k]) % MOD) % MOD;
        }

        // O(k)
        public long nCk2(int n, int k) {
            long ret = 1;
            for (int i=0; i<k; i++) {
                ret = ret * (n - i) % MOD * inv(k - i);
                ret %= MOD;
            }
            return ret % MOD;
        }

    }


}



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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  int score = 0;
  rep(i, n - 1) if (s[i] == s[i + 1]) score++;
  int ans = min(n - 1, score + 2 * k);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        long d = in.nl();
        int count = 0;
        for (int i = 0; i < n; i++) {
            long x = in.nl();
            long y = in.nl();
            if(x*x+y*y<=d*d) count++;
        }
        out.println(count);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 56124
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
const int MAXN = (1 << 20);

int n;
int a[MAXN];

void read()
{
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
}

int l[MAXN], r[MAXN];

void solve()
{
	stack<int> st;
	for(int i = 0; i < n; i++)
	{
		while(!st.empty() && a[st.top()] > a[i])
			st.pop();

		if(st.empty()) l[i] = -1;
		else l[i] = st.top();

		st.push(i);
	}
	while(!st.empty()) st.pop();

	for(int i = n - 1; i >= 0; i--)
	{
		while(!st.empty() && a[st.top()] > a[i])
			st.pop();

		if(st.empty()) r[i] = n;
		else r[i] = st.top();

		st.push(i);
	}
	while(!st.empty()) st.pop();

	long long res = 0;
	for(int i = 0; i < n; i++)
		res += (long long)(r[i] - i) * (long long)(i - l[i]) * a[i];

	cout << res << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	read();
	solve();
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const long long INF = INT_MAX;
const ll MOD = 998244353;

ll mod_pow(ll x,int n){
  return n? (n&1? x*mod_pow(x,n-1)%MOD:mod_pow(x*x%MOD,n/2)):1;
}

const int MAX_ROW = 310; // to be set appropriately
const int MAX_COL = 310; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};


int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int linear_equation(BitMatrix A, vector<int> b, vector<int> &res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);

    // check if it has no solution
    for (int row = rank; row < m; ++row) if (M[row][n]) return -1;

    // answer
    res.assign(n, -1);
    int j=0;
    for (int i = 0; i < rank; ++i){
        for(;!M[i][j];j++);
        res[j] = M[i][n];
    }
    return rank;
}

int main(){
  int N,M;cin>>N>>M;
  BitMatrix A(N,M);
  repeat(i,N){
    repeat(j,M){
      int a;cin>>a;
      A[i][j]=a;
    }
  }
  int rank=GaussJordan(A);
  cout<<(mod_pow(2,N+M-1)-mod_pow(2,N+M-rank-1)+MOD)%MOD<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  char num;
  int i, sum;

  while(1){
    sum=0;

    for(i=0;i<1001;i++){
      scanf("%c",&num);
      if(num==10) break;
      sum+=num-48;
    }
    if(sum==0) break;
    printf("%d\n",sum);
  }
  
  return 0;
}




Measured memory_bytes: 2064