akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int X; cin >> X;
    if(X <= 599) cout << 8 << endl;
    else if(X <= 799) cout << 7 << endl;
    else if(X <= 999) cout << 6 << endl;
    else if(X <= 1199) cout << 5 << endl;
    else if(X <= 1399) cout << 4 << endl;
    else if(X <= 1599) cout << 3 << endl;
    else if(X <= 1799) cout << 2 << endl;
    else if(X <= 1999) cout << 1 << endl;



}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_3_C-in10.txt"));
		// while (scan.hasNext()) {

		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();

		int q = scan.nextInt();
		for (int i = 0; i < q; i++)
			if (isP(a, 0, scan.nextInt()))
				System.out.println("yes");
			else
				System.out.println("no");

		scan.close();
		System.exit(0);
	}

	private static boolean isP(int[] a, int i, int m) {
		if (i == a.length)
			return false;
		
		if (a[i] == m)
			return true;
		else if (a[i] > m)
			return isP(a, i + 1, m);
		else if (isP(a, i + 1, m - a[i]))
			return true;
		else
			return isP(a, i + 1, m);
	}
}

Measured memory_bytes: 26820
#include<stdlib.h>
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
main()
{
    int a,b,i,c[55],j,sum;
    while(scanf("%d%d",&a,&b)!=EOF)
   {   sum=0;
       for(i=0;i<a;i++)
        scanf("%d",&c[i]);
        sort(c,c+a);
      for(j=a-b;j<a;j++)
        sum=sum+c[j];
      printf("%d\n",sum);
   }


}


Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    string a,b,c;
    
    cin>>a>>b>>c;
    
    if(a.substr(a.size()-1,1)==b.substr(0,1) &&b.substr(b.size()-1,1)==c.substr(0,1)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


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

int32_t main() {
    ios_base::sync_with_stdio(0);
    string s;

    cin >> s;

    int res = 0;

    int bs = 0;

    for (auto c: s) {
        if (c == 'B') ++bs;
        else res += bs;
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 720
from collections import deque
N, M = map(int, input().split())
G = [[[] for j in range(3)] for i in range(N+1)]
for _ in range(M):
    u, v = map(int, input().split())
    for i in range(3):
        G[u][i].append((v, (i+1) % 3))
S, T = map(int, input().split())


visited = [[-1] * 3 for _ in range(N+1)]

que = deque([(S, 0, 0)])
visited[S][0] = 0

while que:
    ci, l, d = que.popleft()

    for ni, nl in G[ci][l]:
        if visited[ni][nl] == -1:
            que.append((ni, nl, d+1))
            visited[ni][nl] = d+1

print(visited[T][0]//3)


Measured memory_bytes: 109660
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  string s;
  cin >> s;
  int flag = 1;
  rep (i, s.size() - 1) {
    if (s[i] == s[i + 1]) flag = 0;
  }
  if (flag == 0) P("Bad");
  else P("Good");
  return 0;

}

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

using namespace std;

int main(){

	int a[4];
	int b[4];
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
		for(int i = 0; i < 4; i++)
			cin>>b[i];
		
		int hit=0;
		int blow=0;
		for(int i = 0; i < 4; i++){
			if(a[i]==b[i])
				hit++;
			else{
				for(int j = 0; j < 4; j++){
					if(a[i]==b[j]){
						blow++;
					}
				}
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
import sys

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

import heapq


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

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

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

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

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

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

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

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

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

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


def main():
    from collections import deque, defaultdict
    N, M = map(int, readline().split())

    edge = defaultdict(list)

    for _ in range(M):
        l, r, c = map(int, readline().split())
        edge[l].append((r, c))
        edge[r].append((l, c))

    for i in range(1, N):
        edge[i + 1].append((i, 0))

    pq = PriorityQueue()
    pq.push((0, 1))
    dist = defaultdict(lambda: INF)

    while pq:
        cur, u = pq.pop()
        for v, c in edge[u]:
            nc = cur + c
            if nc < dist[v]:
                dist[v] = nc
                pq.push((nc, v))

    if dist[N] != INF:
        print(dist[N])
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 119320
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<tuple>
#include<stack>
#include<iomanip>
#include<map>
using namespace std;

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

Measured memory_bytes: 256
/*Hatsune Miku 4ever!*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _for(i,a,b) for(int i = (a);i < b;i ++)
#define _rep(i,a,b) for(int i = (a);i > b;i --)
#define INF 0x3f3f3f3f
#define mod 1000000007
#define lowbit(x) ((x)&(-x))
#define pb push_back
#define MIKU 39
#define Design ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug() printf("Miku Check OK!\n")
#define maxn 200039

struct pres
{
	//数组长度 
	ll n;
	ll a[maxn];
	ll s[maxn];
	void getsum()
	{
		_for(i,1,n+1)
		{
			s[i] = s[i-1]+a[i];
			s[i] %= mod;
		}
	}
	ll asksum(ll l,ll r)
	{
		if(l>r)
			return 0; 
        return (s[r] - s[l-1] + mod) % mod;
	}
} P;

int main()
{
	scanf("%d",&P.n);
	_for(i,1,P.n+1)
		scanf("%lld",&P.a[i]);
	P.getsum();
	ll ans = 0;
	_for(i,1,P.n)
	{
		ans += P.a[i]*P.asksum(i+1,P.n);
		ans %= mod;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 6928
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {

    int N;
    cin >> N;
    int d[N];
    for(int i=0;i<N;i++) cin >> d[i];
    int D[N];
    int out = 0;
    for(int i=0;i<N;i++){
        int max = 0;
        int num = 0;
        for(int j=0;j<N;j++){
            if(d[j] > max){
                max = d[j];
                num = j;
            }
        }
        d[num] = 0;
        if(i == 0 || D[out-1] != max){
            D[out] = max;
            out++;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
package main

/*
二分探索
*/

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func binsearch(i int, arr []int) bool {
	if len(arr) == 0 {
		return false
	}
	ci := len(arr) / 2
	center := arr[ci]
	if center == i {
		return true
	}
	if i < center {
		return binsearch(i, arr[0:ci])
	}
	return binsearch(i, arr[ci+1:len(arr)])
}

func main() {
	scanner := makeScanner(11 * 100000)
	eGetInt(scanner)
	s := eGetInts(scanner)
	eGetInt(scanner)
	t := eGetInts(scanner)
	c := 0
	for _, et := range t {
		if binsearch(et, s) {
			c++
		}
	}
	fmt.Println(c)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(max int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), max)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	var ints []int
	for _, f := range fields {
		ints = append(ints, eAtoi(f))
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = " "
	}
	return buf.String()
}

func reverse(a ints) ints {
	r := make(ints, len(a))
	for i := 0; i < len(a); i++ {
		r[i] = a[len(a)-1-i]
	}
	return r
}



Measured memory_bytes: 10504
# 入力
N = int(input())

S1 = [] # 増えるシーケンス用
S2 = [] # 減るシーケンス用

# 入力その２
for i in range(N):

    S = input()  # シーケンス
    mid, end = 0, 0    

    for s in S:
        if s == '(':
            end += 1
        else:
            end -= 1
            
        mid = min(mid, end)  # 途中経過で一番減るところを探す

    if end > 0:
        S1.append((mid, end))
    else:
        S2.append((mid-end, -end))

S1.sort(reverse=True)
# S2.sort(key = lambda x : (x[0], -x[1]))
S2.sort(reverse=True)


mid = end1 = 0  # スタート
out = False

for t in S1:
    a, b = t
    mid = end1 + a
    end1 = end1 + b
    if mid < 0 or end1 < 0:  # 途中で左カッコの数が右を上回る
        out = True
        break

mid = end2 = 0  # スタート
for t in S2:
    a, b = t
    mid = end2 + a
    end2 = end2 + b
    if mid < 0 or end2 < 0:  # 途中で左カッコの数が右を上回る
        out = True
        break
        
if (not end1 == end2) or out:  # 右、左 の数が合わない
    print('No')
else:
    print('Yes')

Measured memory_bytes: 80396
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
#define SQ 320
#define N 8388607
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,h,l,timer;
ll a[100500];
string s;
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n >> m >> k;
    if (k%m == 0 || k%n == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    for (i = 0; i <= n; i++)
        for (j = 0; j <= m; j++)
            if (k == i*m + j*n - 2*i*j)
            {
                cout << "Yes" << endl;
                return 0;
            }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define LL long long
using namespace std;

const int maxn=1e6;
int n,cnt,is_prime[maxn+10],prime[maxn+10],sum[maxn+10];

void init(){
    int i,j;
    for(i=2;i<=maxn;i++){
        if(!is_prime[i]){
        	prime[cnt++]=i;
        }
        for(j=0;j<cnt && i*prime[j]<=maxn;j++){
        	is_prime[i*prime[j]]=1;
        	if(i%prime[j]==0) break;
        }
        sum[i]=cnt;
    }
}

int main(void){
	init();
	while(scanf("%d",&n)!=EOF){
        printf("%d\n",sum[n]);
    }
    return 0;
}


Measured memory_bytes: 11328
#!/usr/bin/env python3
import sys
from bisect import bisect_right

INF = float("inf")


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    dp = [INF]*N
    for i in range(N):
        j = bisect_right(dp, -A[i])
        dp[j] = -A[i]

    print(sum([1 for d in dp if d < INF]))
    # print(dp)


if __name__ == '__main__':
    main()


Measured memory_bytes: 17680
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    loop {
        let t: usize = sc.read();
        let d: usize = sc.read();
        let l: usize = sc.read();
        if t == 0 {
            return;
        }

        let mut x: Vec<i32> = vec![0; t];
        for i in 0..t {
            let z: usize = sc.read();
            if z >= l {
                x[i] += 1;
                if i + d < t {
                    x[i + d] -= 1;
                }
            }
        }

        let mut ans = 0;
        let mut sum = 0;
        for i in 0..(t - 1) {
            sum += x[i];
            if sum > 0 {
                ans += 1;
            }
        }
        println!("{}", ans);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .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: 5048
import java.util.*;
public class Main {

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

        int x, a;
        x = sc.nextInt();
        a = sc.nextInt();

        if(x < a){
            System.out.println(0);
        }
        else{
            System.out.println(10);
        }
        
        
    }
}

Measured memory_bytes: 23892
/*
   Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c) (c).begin(), (c).end()
#define pii pair < ll, ll >
#define vi vector < ll >
#define vb vector < bool >
#define vvi vector < vector < ll > >
#define vvb vector < vector < bool > >
#define vpii vector < pair < ll, ll > >
#define vvpii vector < vector < pair < ll, ll > > >
#define pb push_back
#define f first
#define s second
#define mp make_pair

ll solve(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(true){
        c -= b;
        if(c<=0)
            break;
        a -= d;
        if(a <= 0)
            break;
    }
    if(a>0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

int main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}


Measured memory_bytes: 3660
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e9
#define max_n 123456
#define mod 1000000007

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

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

int dp[123456];
vector <int> g[123456];

int memo(int idx) {
	if(sz(g[idx]) == 0) return 0;
	if(dp[idx] != -1) return dp[idx];
	int mx = 0;
	for(int v : g[idx]) mx = max(mx, 1 + memo(v));
	return dp[idx] = mx;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; i++) {
		int a, b;
		cin >> a >> b;
		g[b].pb(a);
	}
	memset(dp, -1, sizeof dp);
	int mx = 0;
	for(int i=1; i<=n; i++) {
		mx = max(mx, memo(i));
	}
	cout << mx;
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
/*const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};*/
const int dx[6] = {1, 0, -1, 1, -1, 0};
const int dy[6] = {1, 1, 1, 0, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Graph = vector<vector<int>>;
Graph G;
  
/*------------------------------------------------------------------*/
int main(){
    int a, b; cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<queue>

typedef long long int ll;

using namespace std;

int main(void){

    ll a, b, k;

    cin >> a >> b >> k;

    cout << (a <= k ? 0 : a-k) << " ";

    ll tmp = (a <= k ? k-a : 0);

    cout << (b - tmp >= 0 ? b-tmp : 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

struct process{
  char name[10];
  int time;
};

void enqueue(struct process);
struct process dequeue();

int head=0,tail=0;
struct process Q[MAX];

int main(){
  int i,n,q,ttime=0;
  struct process p;

  scanf("%d%d",&n,&q);

  for(i=0;i<n;i++){
    scanf("%s%d",p.name,&p.time);
    enqueue(p);
  }

  while(head!=tail){
    p=Q[head];
    dequeue();

    if(p.time<=q){
      ttime+=p.time;
      printf("%s %d\n",p.name,ttime);
    }
    else{
      ttime+=q;
      p.time-=q;
      enqueue(p);
    }
  }
  
  return 0;
}

void enqueue(struct process p){
  Q[tail]=p;
  if(tail+1==MAX) tail=0;
  else tail++;
}

struct process dequeue(){
  struct process p;

  p=Q[head];
  if(head+1==MAX) head=0;
  else head++;

  return p;
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  string s;cin>>s;
  int res=0;
  for(char c:s){
    res+=c-'0';
    res%=3;
  }
  if(res==0)cout<<"Yes";
  else cout<<"No";
  return 0;
}
//2020.08.22 20:00:48


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

int main() {
  int N;
  int A;
  int x;
  cin >> N >> A;
  x = N%500;
  if (A >= x) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3552
#include <stdio.h>

int main() {
  int n, i;

  scanf("%d", &n);

  for(i=1;i<=n;i++) {
    int x = i;
    if(x%3==0) printf(" %d",i);
    else if(x%10==3) printf(" %d",i);
    else {
      while(x!=0){
        x/=10;
        if(x%10==3) {
          printf(" %d",i);
          break;
        }
      }
    }

  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(void){
    int a[100];
    int b,c;
    cin>>b>>c;
    for(int i=0;i<b;i++){
        cin>>a[i];
    }
    sort(a,a+b);
    int sum=0;
    for(int i=0;i<c;i++){
        sum+=a[b-i-1];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
using namespace std;
namespace IO{
	const int BS=(1<<21)+3; LL Top=0; char Buffer[BS],*HD,*TL,SS[20];
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	void write(LL x){
		if(!x){putchar('0');return;} if(x<0) x=-x,putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) putchar(SS[Top]+'0'),--Top;
	}
	LL read(){
		LL nm=0,fh=1; char cw=Getchar();
		for(;!isdigit(cw);cw=Getchar()) if(cw=='-') fh=-fh;
		for(;isdigit(cw);cw=Getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}
using namespace IO;
struct seg{
	LL ls,rs; seg(){}
	seg(LL _ls,LL _rs){ls=_ls,rs=_rs;}
	bool operator <(const seg&ot)const{return rs>ot.rs;}
}q[M<<2];
LL K,n,m,rt[M<<2],L[M*21],R[M*21],cnt,ct[M*21]; LL maxn,tot,ans,sum[M*20];
void ins(LL &x,LL pre,LL l,LL r,LL pos){
	x=++cnt,L[x]=L[pre],R[x]=R[pre];
	sum[x]=sum[pre]+pos,ct[x]=ct[pre]+1;
	if(l==r) return; LL mid=((l+r)>>1);
	if(pos<=mid) ins(L[x],L[pre],l,mid,pos);
	else ins(R[x],R[pre],mid+1,r,pos);
}
void qry(LL x,LL l,LL r,LL pos,LL &CT,LL &NUM){
	if(l>=pos||!ct[x]) return; if(r<pos){CT+=ct[x],NUM+=sum[x];return;}
	LL mid=((l+r)>>1); qry(L[x],l,mid,pos,CT,NUM),qry(R[x],mid+1,r,pos,CT,NUM);
}
int main(){
	n=read(),m=read();
	for(LL i=2,x=read();i<=n;i++){
		LL y=read();
		if(x<y) tot+=y-x,q[++K]=seg(x,y),q[++K]=seg(x+m,y+m),q[++K]=seg(x+m+m,y+m+m);
		else tot+=(y+m-x),q[++K]=seg(x,y+m),q[++K]=seg(x+m,y+m+m); x=y;
	}sort(q+1,q+K+1),ans=tot;
//	return 0;
//	printf(" tot = %lld\n",tot);
//	for(LL i=1;i<=K;i++) printf("[ %d , %d ]\n",q[i].ls,q[i].rs);
	for(LL i=1;i<=K;i++) ins(rt[i],rt[i-1],1,m*3,q[i].ls);
	for(LL now=0,i=m*3;i;i--){
		while(now<K&&q[now+1].rs>=i) now++;
		LL Cnt=0,Sum=0;
		qry(rt[now],1,m*3,i,Cnt,Sum);
		ans=min(ans,tot-(Cnt*i-Sum)+Cnt);
//		if(ans==3) printf(" i = %d    Cnt = %d   Sum = %lld\n",i,Cnt,Sum );
	} write(ans),putchar('\n'); return 0;
}

Measured memory_bytes: 133376
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef pair<int,int> P;
signed main(){
  int N,C;
  cin >> N >> C;
  vector<P>xy(N);
  for(int i = 0; i < N; i++) {
    cin >> xy[i].first >> xy[i].second;
  }
  int ans = 0;
  vector<int>cnt1(N+1);
  vector<int>sum1(N+1);
  for(int i = 0; i < N; i++) {
    cnt1[i+1] = cnt1[i] + xy[i].second;
    ans = max(ans,cnt1[i+1]-xy[i].first);
    sum1[i+1] = max(cnt1[i+1]-xy[i].first,sum1[i]);
  }
  vector<int>cnt2(N+1);
  vector<int>sum2(N+1);
  for(int i = 0; i < N; i++) {
    cnt2[i+1] = cnt2[i] + xy[N-i-1].second;
    ans = max(ans,cnt2[i+1] - (C-xy[N-i-1].first));
    sum2[i+1] = max(cnt2[i+1] - (C-xy[N-i-1].first),sum2[i]);
  }
  for(int i = 0; i < N; i++) {
    ans = max(ans,cnt1[i+1]-xy[i].first*2+sum2[N-i-1]);
  }
  for(int i = 0; i < N; i++) {
    ans = max(ans,cnt2[i+1]-(C-xy[N-i-1].first)*2+sum1[N-i-1]);
  }
  cout << ans << endl;
}

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

const int MAX_V = 100000;
int par[MAX_V];
int depth[MAX_V];
int num[MAX_V];

void init(int n) {
    for(int i = 0; i < n; i++) {
        par[i] = i;
        depth[i] = 0;
        num[i] = 1;
    }
}

int root(int x) {
    if (par[x] == x) return x;
    else return par[x] = root(par[x]);
}

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    num[x] += num[y];
    num[y] = num[x];

    if (depth[x] < depth[y]) par[x] = y;
    else {
        par[y] = x;
        if (depth[x] == depth[y]) depth[x]++;
    }
}

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

int get_num(int x) {
    return num[root(x)];
}

int main() {
    int n, m;
    cin >> n >> m;
    if (m == n - 1) {
        cout << 0 << endl;
        return 0;
    }

    vector<pair<long long, int>> a(n);
    for (int i = 0; i < n; i++) {
        long long x;
        cin >> x;
        a.at(i) = make_pair(x, i);
    } 
    sort(a.begin(), a.end());

    if (n == 2) {
        cout << a.at(0).first + a.at(1).first << endl;
        return 0;
    }

    init(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        unite(x, y);
    }

    if (m < n - m - 2) {
        cout << "Impossible" << endl;
        return 0;
    }

    long long ans = 0;
    vector<bool> done_group(n);
    vector<bool> done_v(n);
    for (int i = 0; i < n; i++) {
        int p = root(a.at(i).second);
        if (!done_group.at(p)) {
            ans += a.at(i).first;
            done_group.at(p) = true;
            done_v.at(a.at(i).second) = true;
        }
    }

    int c = n - m - 2;
    for (int i = 0; i < n; i++) {
        if (c <= 0) break;
        if (!done_v.at(a.at(i).second)) {
            ans += a.at(i).first;
            c--;
        }
    }

    cout << ans << endl;
}

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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2*N-1], dneg[2*N-1];

bool X[N][N];

void initialize(){
  for(int i = 0;i < N; i++){
    row[i] = FREE;
    col[i] = FREE;
  }

  for(int i = 0; i < 2*N-1;i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}

void printBoard(){
  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      if(X[i][j]){
        if(row[i] != j)return;
      }
    }
  }

  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      cout << ( (row[i] == j) ? "Q" : "." );
    }
    cout << endl;
  }
}

void recursive(int i){
  if(i == N){
    printBoard();
    return;
  }

  for(int j = 0;j < N;j++){
    if(NOT_FREE == col[j] || NOT_FREE == dpos[i+j] || NOT_FREE == dneg[i - j + N - 1])continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i - j + N - 1] = NOT_FREE;
    recursive(i + 1);
    row[i] = col[j] = dpos[i+j] = dneg[i - j + N - 1] = FREE;
  }
}

int main(){
  initialize();

  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      X[i][j] = false;
    }
  }

  int k;
  cin >> k;

  for(int i = 0 ;i < k;i++){
    int r,c;
    cin >> r >> c;
    X[r][c] = true;
  }

  recursive(0);

  return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
#define int long long;
using namespace std;
signed main()
{
    long long a,b,k;
    cin >> a >> b >> k;
    if(k<=a)
        cout << a-k <<" "<< b <<endl;
    else if(k<=a+b)
        cout << 0 << " " <<b-(k-a) << endl;
    else
        cout << 0 << " " << 0 << endl;

}

Measured memory_bytes: 256
//#include <stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
#define PI 3.14159265359;

class Hoge{
  public:
					long long i0;
	int iN;
	int N0;
			
					long long* iarray0;
					Hoge(int);
					void func0();
				

	~Hoge();
  private:
	

	void inputarray3(long long*,int);

	void multiple0();
					};


Hoge::Hoge(int itemp){
	
	i0=itemp;

	
									}

void Hoge::func0(){

	cin>>iN;
	
	iarray0=new long long[iN];

	inputarray3(iarray0,iN);

	multiple0();

	
								}
void Hoge::multiple0(){
	long long ianswer=1;
	
	for(int i0=0;i0<iN;i0++){
		//cout<<"now"<<endl;
		//cout<<"iarray0[i0]"<<iarray0[i0]<<endl;
		if(iarray0[i0]==0){ianswer=0;break;}
		
		
		long long itemp=1000000000000000000/iarray0[i0];
		//cout<<"itemp"<<itemp<<endl;
		if(itemp<ianswer){ianswer=-1;break;}
		   ianswer=ianswer*iarray0[i0];
				if(ianswer>1000000000000000000){
		//	cout<<"ianswer"<<ianswer<<endl;	
		ianswer=-1;break;}
	}
	for(int i0=0;i0<iN;i0++){
		if(iarray0[i0]==0){ianswer=0;break;}
	}
	cout<<ianswer<<endl;
	//cout<<pow(10,18)<<endl;
}


void Hoge::inputarray3(long long* itemp,int itempn){
	
	long long* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		//cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
	}
}

Hoge::~Hoge(){
	
	delete [] iarray0;
							}
int main(){
				int N=0;
				//cin>>N;
	Hoge* hoge=new Hoge(N);
	hoge->func0();
	
	return 0;
	delete hoge;
}//end of main

Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,x;
    scanf("%d%d",&n,&k);
    for(int w=0;w<n;w++)scanf("%d",&x);
    int j=0;
    for(int w=0;w<n-1;w+=k)
    {
        j++;
        w--;
    }
    printf("%d\n",j);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k,t;
    cin>>a>>b;
    if(a<b)
    {
        t=a;a=b;b=t;
    }
    k=(a+b)/2;
    int i,j;
    i=abs(a-k);j=abs(b-k);
    if(i==j) printf("%d\n",k);
    else printf("IMPOSSIBLE\n");

    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	long a[300000];
	for (int i = 0; i < 3 * N; i++) {
		cin >> a[i];
	}
	sort(a, a + 3 * N, greater<int>());
	for (int i = 0; i < 3 * N; i++) {
    }
	long max = 0;
	for (int i = 1; i <= 2 * N; i += 2) {
		max += a[i];
	}
	cout << max << endl;
}

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

#define F first
#define S second

using ll = long long;
using pii = pair <int, int>;

const int oo = 1e9 + 4;
const int SZ = 2e5 + 4;

int n, m, sum;

void read() {
    cin >> n >> m;
    while (m--) {
        int t;
        cin >> t;
        sum += t;
    }
}

void solve() {
    cout << (n - sum < 0 ? -1 : n - sum);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    read();
    solve();
}


Measured memory_bytes: 3616
package main

import (
	"fmt"
)

func pop(s string) (string, string) {
	r := string(s[0])
	s = string(s[1:])
	return s, r
}

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)

	a, t := pop(a)
	for {
		switch t {
		case "a":
			if len(a) == 0 {
				fmt.Println("A")
				return
			}
			a, t = pop(a)
		case "b":
			if len(b) == 0 {
				fmt.Println("B")
				return
			}
			b, t = pop(b)
		case "c":
			if len(c) == 0 {
				fmt.Println("C")
				return
			}
			c, t = pop(c)
		}
	}
}


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

using namespace std;

int mod=1e9+7;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int prime[100010];
bool is_prime[100010];

void sieve(int n){
    int p=0;
    for(int i=0;i<=n;i++)is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
        }
    }
    return ;
}

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

    int n;
    cin>>n;

    sieve(100000);

    int sum=1;

    cout<<"11";

    for(int i=5;i<100000;i++){
        if(prime[i]%5==1){
            cout<<" "<<prime[i];
            sum++;
        }
        if(sum==n){
            cout<<endl;
            break;
        }
    }

}

Measured memory_bytes: 384
def main():

    K = int(input())
    def gcd(a, b):
        if a > b: a, b = b, a
        if a == 0: return b
        return gcd(b%a, a)
    # print("here")
    ans = 0
    for a in range(1, K+1):
        for b in range(1, K+1):
            v = gcd(a, b)
            for c in range(1, K+1):
                ans += gcd(v, c)
                # print(ans)
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 72844
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using Pdi = pair<double, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N; cin >> N;
    int ans = 0;

    FOR(i, 2, 1000001){
        int c = 0;
        while(N % i == 0){
            N /= i;
            c++;
        }

        int k = 1;
        while(c >= k){
            c -= k;
            ans++;
            k++;
        }
    }
    if(N > 1) ans++;
    Out(ans);

    return 0;
}


Measured memory_bytes: 3636
using System;
namespace CSsample
{
    class Bmondai
    {
        static void Main(string[] args)
        {
          	int N = int.Parse(Console.ReadLine());
            string input = Console.ReadLine();
            int R = 0;
            int B = 0;
            for (int i = 0; i < input.Length; i++){
                if(input[i] == 'R') {
                    R++;
                }else if(input[i] == 'B') {
                    B++;
                }
            }
            if(R>B) {
                Console.WriteLine("Yes");
            }else {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h>

int main(void) {
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if (a == b && b == c)
		puts("No");

	else if (a == b || b == c || c == a)
		puts("Yes");

	else
		puts("No");

	return 0;
}

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

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

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

k,q=map(int,input().split())
D=list(map(int,input().split()))
A=[]
for i in range(q):
    n,x,m=map(int,input().split())
    mD=list(map(lambda i: i%m, D)) #元の列のmodを取る
    ans=0
    cnt=x%m
    a=(n-1)//k
    b=(n-1)%k
    for d in mD[:b]: #mod kで余る部分
        if d==0:
            ans+=a+1
        cnt+=d*(a+1)
    for d in mD[b:]: #余らない部分
        if d==0:
            ans+=a
        cnt+=d*a
    ans+=cnt//m
    print(n-1-ans)

Measured memory_bytes: 67548
//Totka hai dosto
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

int32_t main()
{
	string s,t;
	cin>>s>>t;
	
	if(s.length()==(t.length()-1))
	{
		char c=t.back();
		s+=c;
		if(s==t)
		{
			cout<<"Yes";
		}
		else
		{
			cout<<"No";
		}
	}
	else cout<<"No";
}

Measured memory_bytes: 3608
use strict;
use warnings;
use utf8;

# 2015/09/01

my $in;

$in = <STDIN>;
$in =~ s/\r\n$|\r$|\n$//;
my ($k, $t) = split(/ /, $in);


$in = <STDIN>;
$in =~ s/\r\n$|\r$|\n$//;
my @As = split(/ /, $in);

my $max = &max(@As);


my $temp = $k / 2.0 + 0.51;
if ($max <= $temp) {
	&p(0);
	exit;
}

$temp = ($k - $max) * 2;
$temp = $k - $temp;


# &p(@As);
# &pjoin(@As);
&p($temp - 1);


exit;



sub p{
	my ($str) = @_;
	print $str, "\n";
	return 1;
}


sub pjoin{
	my @Str = @_;
	print join("_", @Str), "\n";
	return 1;
}


sub max{
	my @nums = @_;

	my $max_num;
	foreach my $num (@nums) {
		if (!defined $max_num) {
			$max_num = $num;
		} else {
			if ($num > $max_num) {
				$max_num = $num;
			}
		}
	}
	return $max_num;
}


sub min{
	my @nums = @_;

	my $min_num;
	foreach my $num (@nums) {
		if (!defined $min_num){
			$min_num = $num;
		} else {
			if ($num < $min_num){
				$min_num = $num;
			}
		}
	}
	return $min_num;
}



Measured memory_bytes: 768
#!/usr/bin/env python3
from copy import deepcopy
from itertools import product
h, w, push = map(int, input().split())
ans = 0
an = []
a = ['@'] * w
c = []
d = []
for q in range(h):
    _ = list(input())
    c.append(_)
    d.append(_)
for H in product([0, 1], repeat=h):
    for W in product([0, 1], repeat=w):
        c = deepcopy(d)
        count = 0
        for i, j in enumerate(H):
            if j:
                c[i] = a
        for k, l in enumerate(W):
            if l:
                for x in range(h):
                    c[x][k] = '@'
        for hi in c:
            for wi in hi:
                if wi == '#':
                    count += 1
        an += [count]
for answer in an:
    if answer == push:
        ans += 1
print(ans)


Measured memory_bytes: 9264
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  ll a,b; cin >> a >> b;
  cout << a*b-a-b+1;
  return 0;
}


Measured memory_bytes: 3600
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
st = [readline().rstrip().decode().split() for _ in range(n)]
x = readline().rstrip().decode()
cnt = 0
flag = False
for s, t in st:
    if flag:
        cnt += int(t)
    if x == s:
        flag = True
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

ll f(ll n, ll d){
  if(n == - 1) return 0;
  else return n / d + 1;
}

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

  ll a, b, x;
  cin >> a >> b >> x;

  cout << (f(b, x) - f(a - 1, x)) << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from math import ceil

D, G = [int(t) for t in input().split()]
p = []
c = []
for i in range(D):
    p_, c_ = [int(t) for t in input().split()]
    p.append(p_)
    c.append(c_)

cache = {}

def minsolve(G, i):
    """100i点以下の問題だけでGを達成する最小問題数"""
    if i <= 0:
        return float('inf')
    n = min(ceil(G / (100 * i)), p[i-1])
    s = 100 * i * n
    if n == p[i-1]:
        s += c[i-1]
    m = n if s >= G else n + minsolve(G - s, i-1)
    return min(m, minsolve(G, i-1))

print(minsolve(G, D))

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

using namespace std;

vector<int64_t> counter;
unordered_map<int, vector<int>> edges;

void recur(int prev, int cur) {
  counter[cur] += counter[prev];
  for (auto next : edges[cur]) {
    if (prev != next) {
      recur(cur, next);
    }
  }
}

int main() {
  int N, Q;
  cin >> N >> Q;
  edges.reserve((N - 1) * 2);
  for (int i = 0; i < N - 1; ++i) {
    int ai, bi;
    cin >> ai >> bi;
    edges[ai].push_back(bi);
    edges[bi].push_back(ai);
  }
  counter.resize(N + 1);
  for (int i = 0; i < Q; ++i) {
    int pi, xi;
    cin >> pi >> xi;
    counter[pi] += xi;
  }
  recur(0, 1);
  bool first = true;
  for (auto it = counter.cbegin() + 1; it != counter.cend(); ++it) {
    if (first)
      first = false;
    else
      cout << " ";
    cout << *it;
  }
  cout << endl;
}


Measured memory_bytes: 32128
a = list(map(int, input().split()))
sum_t = a[0]
sum_a = a[2]
flag = 1
winner = 0
while flag:
  sum_a = sum_a - a[1]
  if(sum_a <= 0):
    flag = 0
    break    
  sum_t = sum_t - a[3]
  if(sum_t <= 0):
    winner = 1
    flag = 0
    break   

if winner == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9220
#include<stdio.h>
#include<string.h>

int main(){
    int n;
    int Taro = 0;
    int Hanako = 0;
    scanf("%d", &n);
    char s1[100], s2[100];
    
    for (int i = 0; i < n; i++){
        scanf("%s %s", s1, s2);
        if (strcmp(s1, s2) == 0) {Taro++; Hanako++;}
        else if (strcmp(s1, s2) > 0) {Taro+=3;}
        else if (strcmp(s1, s2) < 0) {Hanako+=3;}
    }
    printf("%d %d\n", Taro, Hanako);
  return 0;
}


Measured memory_bytes: 2052
from sys import setrecursionlimit
from operator import itemgetter

def main():
    N = int(input())
    XYH = [list(map(int,input().split())) for _ in range(N)]
    XYH.sort(key = itemgetter(2),reverse = True)
    ansx = -1
    ansy = -1
    for cx in range(0,101):
        for cy in range(0,101):
            H = -1
            flag = True
            for x,y,h in XYH:
                if H >= 0:
                    if h != max(H - abs(x - cx) - abs(y - cy),0):
                        flag = False
                        break
                elif h > 0:
                    H =  h + abs(x - cx) + abs(y - cy)
            if flag:
                ansx = cx
                ansy = cy
                print(ansx,ansy,H)
                return
    return   

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
N, M = map(int, input().split())
s = [0] * M
c = [0] * M
for i in range(M):
    s[i], c[i] = map(int, input().split())
    
A = []
x = 0

for i in range(M):
  if s[i] == 1 and c[i] == 0:
    x = 1
  for j in range(i+1,M):
    if s[i] == s[j] and c[i] != c[j]:
      x = 2
      
import numpy as np
import math
from functools import reduce
B = np.zeros(N)
B[0] = 1

if M == 0:
  if N == 1:
    print(0)
  else:
    ans = reduce( lambda a,b:10*a+b, B)
    print(math.floor(ans))

elif N == 1 and max(s) == 1 and max(c) == 0:
  print(0)

elif x == 1 or x == 2:
  print("-1")
  
else:
  for i in range(M):
    B[s[i]-1] = c[i]
  ans = reduce( lambda a,b:10*a+b, B)
  print(math.floor(ans))

Measured memory_bytes: 12444
s = int(input())

a = []
a.append(s)

i = 0
while True:
    if a[i] % 2 == 0:
        tmp = a[i]/2
    else:
        tmp = a[i]*3+1

    if tmp in a:
        print(i+2)
        break
    else:
        a.append(tmp)
        i += 1


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N, M, L;
    cin >> N >> M >> L;

    vector<vector<ll>> d(N, vector<ll>(N, INF));
    rep (i, N) {
        d[i][i] = 0;
    }
    rep (i, M) {
        ll A, B, C;
        cin >> A >> B >> C;
        A--;
        B--;
        d[A][B] = C;
        d[B][A] = C;
    }

    rep (k, N) {
        rep (i, N) {
            rep (j, N) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    vector<vector<ll>> d2(N, vector<ll>(N, INF));
    rep (i, N) {
        rep (j, N) {
            if (d[i][j] <= L) {
                d2[i][j] = 1;
            }
        }
    }

    rep (k, N) {
        rep (i, N) {
            rep (j, N) {
                d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
            }
        }
    }

    ll Q;
    cin >> Q;

    vector<ll> s(Q), t(Q);
    rep (i, Q) {
        cin >> s[i] >> t[i];
        s[i]--;
        t[i]--;
    }

    rep (i, Q) {
        ll ans = d2[s[i]][t[i]]-1;
        if (d2[s[i]][t[i]] == INF) {
            ans = -1;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3328
N = int(input())
S = list(input().split())
res = [0] * 4

for s in S:
    if s == 'G' and res[0] == 0:
        res[0] += 1
    elif s == 'W' and res[1] == 0:
        res[1] += 1
    elif s == 'Y' and res[2] == 0:
        res[2] += 1
    elif s == 'P' and res[3] == 0:
        res[3] += 1

if sum(res) == 3:
    print('Three')
else:
    print('Four')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ARB ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pp __builtin_popcount
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;

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


Measured memory_bytes: 256