akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll k, n;
vector<ll> a, dif;
int main (){
  cin >> k >> n;
  cin.ignore();
  ll tmp;
  for(ll i = 0; i < n; i++){
    cin >> tmp;
    a.push_back(tmp);
  }

  // 最大の差をひけばいい！
  for(ll i = 0; i < n - 1; i++){
    tmp = a[i+1] - a[i];
    dif.push_back(tmp);
  }
  tmp = a[0] + k - a[n-1];
  dif.push_back(tmp);

  ll max = 0;
  for(ll i = 0; i < n; i++){
    tmp = dif[i];
    if(max < tmp){
      max = tmp;
      //      cout << "max =" << max << endl;
    }
  }

  cout << k - max << endl;
  return 0;
}


  
  


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    ll h, w; cin >> h >> w;

    vector<string> c(h);
    for (ll i = 0; i < h; ++i) {
        cin >> c[i];

        cout << c[i] << endl;
        cout << c[i] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int solution(int n){
    if(n==0) return 1;
    if(n==1) return 1;
    int one=1,two=1,tmp;
    for(int i=1;i<n;i++){
    tmp = two;
    two = two+one;
    one = tmp;
}
    return two;
}

int main(){
    int n;
    cin>>n;
    cout<<solution(n)<<endl;
return 0;
}

Measured memory_bytes: 3036
a_hp,a_at,b_hp,b_at = map(int,input().split())
An = b_hp//a_at
Blit = b_hp%a_at
Bn = a_hp//b_at
Alit = a_hp%b_at
if Blit != 0:
    An += 1
if Alit != 0:
    Bn += 1
print('Yes' if An<=Bn else 'No')

Measured memory_bytes: 9176
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>



int main()
{
    long long int i,j;

    char a[1000];

    while(gets(a))
    {
        for(i=0;i<strlen(a);i++)
        {
            if(a[i]==','){printf(" ");}
            else{printf("%c",a[i]);}
        }
        printf("\n");
    }
            return 0;
        }


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;

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

  if(a > 8 || b > 8){
    cout << ":(" << endl;
  }
  else{
    cout << "Yay!" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//aのMODbでの逆元
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//nCk
long long combi(long long n,long long k){
    k = min(k,n-k);
    long long p = 1;
    for(int i = n;i>=n-k+1;i--){
        p*=i;
        p%=MOD;
    }
    for(int i = 0;i<k;i++){
        p*=modinv(i+1,MOD);
        p%=MOD;
    }
    return p;
}
int main(){
    long long x,y;
    cin >> x >> y;
    if( 2*x/y < 1 || 2*y/x < 1 ){
        cout << 0 << endl;
        return 0;
    }
    if( ((x+y)%3) != 0 ){
        cout << 0 << endl;
        return 0;
    }
    long long a = ((x+y)/3);
    long long b = (x-(x+y)/3);
    long long ans ;
    ans = combi(a,b);
    cout << ans << endl;
    return 0;

}


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

int main() {

    int x, y, z;
    scanf("%d",&x);
    scanf("%d", &y);
    scanf("%d", &z);
    
    
    x -= y;
    int num = x / z;
    x -= z*num;
    printf("%d", x);

    return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
ll n, a, b;
bool solve(ll x, vector<ll>v) {
	ll needed = 0;
	for (int i = 0; i < int(v.size()); i++) {
		ll left = v[i] - b * x;
		if (left < 0)continue;
		needed += (left + (a - b - 1)) / (a - b);
	}
	if (needed > x)return false;
	return true;
}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> a >> b;
	vector<ll>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	int left = 0, right = 1e9;
	while (right - left > 1) {
		ll mid = (right + left) / 2;
		if (solve(mid, v))
			right = mid;
		else
			left = mid;
	}
	cout << left + 1 << endl;
}

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

int main() {
    ll n, span;
    cin >> n >> span;
    ll ans = span;
    ll t, prev = 0;
    rep(i,n) {
        cin >> t;
        ans += min(t-prev, span);
        prev = t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	fmt.Println(math.Min(float64(b/a), float64(c)))
}


Measured memory_bytes: 640
void change(char *str){
  int len=strlen(str);
  int i;
  for(i=0;i<len;i++){
    if('a'<=str[i]&&str[i]<='z'){
      str[i]-=32;
    }
  }
}
 
int main(){
  char t[10000];
  char key[10000];
  char eofstr[]={"END_OF_TEXT"};
  int ans=0;
 
  scanf("%s",key);
  change(key);
 
  while(1){
    scanf("%s",t);
    if(strcmp(t,eofstr)==0){
      break;
    }
    change(t);
    if(strcmp(t,key)==0){
      ans++;
    }
  }
 
  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;

int main(void) {
  ll x;
  cin >> x;
  if (x >= 30)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int mi = INF, ma = -INF;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        chmax(ma, l);
        chmin(mi, r);
    }
    cout << max(0, mi - ma + 1) << endl;
}

Measured memory_bytes: 896
import itertools
n = int(input())
x, y = [], []
f = 1
for i in range(n):
    f *= i + 1
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)
p = [i for i in range(n)]
d = 0
for perm in itertools.permutations(p):
    for i in range(n - 1):
        d += ((x[perm[i]] - x[perm[i + 1]]) ** 2 + (y[perm[i]] - y[perm[i + 1]]) ** 2) ** 0.5
print(d / f)
    



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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    string S; cin >> S;

    int sum1 = 0, sum2 = 0;
    rep(i, S.size()) {
        int n = S[i] - '0';
        sum1 += n;
        if (i == 0) sum2 += n-1;
        else        sum2 += 9;
    }
    cout << max(sum1, sum2) << endl;
}

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

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    for (auto& c : s) {
        c = 'x';
    }
    
    cout << s << "\n";
    
    return 0;
}


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

int main(){

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<int> x(n);
    for(int i = 0; i < n; i++) x[i] = a[i];

    sort(a.begin(), a.end());
    int l = a[n/2 - 1];
    int u = a[n/2];
    //cout << l << " " << u << endl;
    
    for(int i = 0; i < n; i++){
        if(x[i] <= l) cout << u << endl;
        else cout << l << endl;
    }
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, num, digit, rev = 0;
     cin >> num;

     n = num;

     do
     {
         digit = num % 10;
         rev = (rev * 10) + digit;
         num = num / 10;
     } while (num != 0);

     if (n == rev)
         cout << "Yes";
     else
         cout << "No";


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int r, D, x[2011];

	cin >> r >> D;

	cin >> x[2000];

	for (int i = 2001; i <= 2010; i++) {
		x[i] = r * x[i-1] - D;
		cout << x[i] << "\n";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int a,b,c,t=0;
  cin >> a >> b >> c;
  if(a==b && b==c)  t=1;
  else if(a!=b && b!=c && a!=c) t=3;
  else  t=2;
  cout << t;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{ int n;
cin>>n;
int a[n][3],dp[n][3];
for(int i=0;i<n;i++)
{
	for(int j=0;j<3;j++)
{
		cin>>a[i][j];
		dp[i][j]=a[i][j];}
	
}
for(int i=1;i<n;i++)
{
	dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]+=max(dp[i-1][2],dp[i-1][0]);
			dp[i][2]+=max(dp[i-1][1],dp[i-1][0]);
}
cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll x = 0, ans = 0;
  for (ll i = 0; i < n; i++) {
    if (s[i] == 'I') x++;
    else x--;
    ans = max(ans, x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
    int n;cin>>n;
    for(int itr=1;itr<=n;itr++){
        if(itr<6) cout<<0<<'\n';
        else{
            int cnt=0;
            for(int x=1;x<=100;x++){
                for(int y=1;y<=100;y++){
                    for(int z=1;z<=100;z++){
                        int val=(x*x+y*y+z*z+x*y+y*z+z*x);
                        if(val>itr) break;
                        else if(x*x+y*y+z*z+x*y+y*z+z*x==itr) cnt++;
                    }
                }
            }
            cout<<cnt<<'\n';
        }
    }
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);	 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3556
'''
問題：
    あなたは AtCoder 王国の入国審査官です。
    入国者の書類にはいくつかの整数が書かれており、あなたの仕事はこれらが条件を満たすか判定することです。
    規約では、次の条件を満たすとき、またその時に限り、入国を承認することになっています。
        書類に書かれている整数のうち、偶数であるものは全て、3 または 5 で割り切れる。
    上の規約に従うとき、書類に N 個の整数 A1,A2,…,AN
    が書かれた入国者を承認するならば APPROVED を、しないならば DENIED を出力してください。
'''

'''
制約：
    入力はすべて整数
    1 ≤ N ≤ 100
    1 ≤ Ai ≤ 1000
'''
def is_even(num):  # 偶数判定
    if num % 2 == 0:
        return True
    else:
        return False

def is_fizzbuzz(num):  # 3 または 5で割り切れるか判定（※関数名はテキトーｗ）
    if num % 5 == 0:
        return True
    if num % 3 == 0:
        return True
    else:
        return False


# 標準入力から、N, A1,A2,...,AN の値を取得する
n = int(input())
numbers = list(map(int,input().split()))

result = 'APPROVED'
for i in numbers:
    if is_even(i):
        if is_fizzbuzz(i):
            result = 'APPROVED' # 偶数かつ、3でも5でも割り切れるので、APPROVED
        else:
            result = 'DENIED'   # 1つでも条件を満たさない場合、DENIEDしてfor文抜ける
            break

print(result)


Measured memory_bytes: 9196
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define f(i,x,z) for(int i=x;i<z;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"
#define srt(v) sort(v.begin(), v.end())

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c,co=0,k;
    cin>>a>>b>>c>>k;
    while(b<=a && co<=k)
    {
    	b=b*2;
    	co++;
    }
    while(c<=b && co<=k)
    {
    	c=c*2;
    	co++;
    }
    if(co<=k)
    {
    	cout<<"Yes";
    }
    else
    {
    	cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0,t=0,i,j;
	cin>>n;
	for(i=1;i<=(n-1);i++)
	{
		for(j=(i+1);j<=n;j++)
		{
			s=0;
			s=i+j;
			
			if(s%2==1)
			
			++t;

		}
		if(i==n-1)
		cout<<t;
	}
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int n = (int) s.length();
	long long curr = n-1, c = 0;
	for(int i=n-1;i>=0;i--)
	{
		if(s[i] == 'B')
		{
			c += curr - i;
			curr--;
		}
	}
	cout << c << "\n";
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <utility>

using namespace std;

int gcd(int m, int n) {
    /* Euclidean algorithm */
    while (n) {
        m %= n;
        swap(m, n);
    }
    return m;
}

int main() {
    int x, y;
    scanf("%d %d", &x, &y);

    printf("%d\n", gcd(x, y));
    return 0;
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;

int main() {
	int A, B;
	cin >> A >> B;
	int sum = A + B;
	if(sum%2==1) {
		cout << "IMPOSSIBLE" << endl;
	} else {
		cout << sum/2 << endl;
	}

	
  return 0;
}

Measured memory_bytes: 256
use std::cmp::min;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (_, a, b) = scan!(i64, i64, i64);
    let vs = scan!(i64;;);

    println!(
        "{}",
        vs.iter()
            .zip(vs[1..].iter())
            .map(|(v0, v1)| min(a * (v1 - v0), b))
            .sum::<i64>()
    )
}


Measured memory_bytes: 6524
import sys
from heapq import heappush, heappop, heapreplace
 
def solve():
    file_input = sys.stdin
    N, R, L = map(int, file_input.readline().split())
     
    pq = [[0, i] for i in range(1, N + 1)]
    m = dict(zip(range(1, N + 1), pq))
    time = [0] * (N + 1)
    INVALID = -1
     
    pre_t = 0
    for line in file_input:
        d, t, x = map(int, line.split())
        top_team = pq[0]
        time[top_team[1]] += t - pre_t
        pre_t = t
         
        if top_team[1] == d:
            top_team[0] -= x
            if x < 0:
                heapreplace(pq, top_team)
        else:
            scored_team = m[d][:]
            scored_team[0] -= x
            heappush(pq, scored_team)
            m[d][1] = INVALID
            m[d] = scored_team
         
        while pq[0][1] == INVALID:
            heappop(pq)
    time[pq[0][1]] += L - pre_t
    print(time.index(max(time)))
 
solve()


Measured memory_bytes: 85332
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	set<int> s;
	unordered_map<int,int> store;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		s.insert(x);
		store[x]++;
	}
	if((int)s.size()<k)
		cout<<0;
	else
	{
		vector<pair<int,int>> occ;
		for(auto it:store)
		{
			occ.push_back({it.second,it.first});
		}
		sort(occ.begin(),occ.end());
		int d=(int)s.size()-k;
		int ans=0;
		for(int i=0;i<d;i++)
			ans+=occ[i].first;
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 23716
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pb push_back
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> num(100, 0);
  for (ll i = 1; i <= N; ++i) {
    string s = to_string(i);
    num.at((s.at(0) - '0') + 10 * (s.at(s.size() - 1) - '0')) += 1;
  }
  ll ans = 0;
  for (ll i = 0; i < 10; ++i) {
    for (ll j = 0; j < 10; ++j) {
      ans += num.at(i + j * 10) * num.at(j + i * 10);
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3644
n, m = map(int, input().split())
sl = [0]*m
cl = [0]*m
for i in range(m):
    sl[i], cl[i] = map(int, input().split())

for t in range(1000):
    target = str(t)
    if len(target) == n:
        ok = True
        for i in range(m):
            if target[sl[i]-1] != str(cl[i]):
                ok = False
        if ok:
            print(t)
            exit()
print(-1)


Measured memory_bytes: 40688
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;
const int MOD = 1000000007;
const int MX = 777777 + 5;
int fac[MX+5],inv[MX+5];
 
int power(int x,int y,int p){
	int res=1;
	x=x%p;
	while(y){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void init(){
  int n=MX+4;
	fac[0] = 1;
  for(int i=0;i<n;++i)fac[i+1]=fac[i]*(i+1)%MOD;
  inv[n]=power(fac[n],MOD-2,MOD);
  for(int i=n-1;i>=0;--i)inv[i]=inv[i+1]*(i+1)%MOD;
}
// nPk = nCk * fac[k]
int comb(int n,int r){return (fac[n]*inv[r])%MOD*inv[n-r]%MOD;}
int H(int n,int r){
  return comb(n+r-1,r)%MOD;
}

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

    int X,Y; cin >> X >> Y;
    if(X>Y*2 || Y>X*2 || (X+Y)%3!=0){
        cout << 0 << endl;
        return 0;
    }
    int cnt = (X+Y)/3;
    int p = abs(X-cnt*2);
    cout << comb(cnt,p) << endl;

    
}

Measured memory_bytes: 12416
public class Main {

	private java.util.Scanner sc;
	private java.io.PrintStream out;
	
	public Main(java.io.InputStream in, java.io.PrintStream out) {
		this.sc = new java.util.Scanner(in);
		this.out = out;
	}
	
	public void run() {
		for (;;) {
			final int M = sc.nextInt();
			final int T = sc.nextInt();
			final int P = sc.nextInt();
			final int R = sc.nextInt();
			if (M == 0 && T == 0 && P == 0 && R == 0)
				break ;
			
			final Team[] teams = new Team[T];
			for (int i = 0; i < T; ++i)
				teams[i] = new Team(i + 1, P);
			for (int i = 0; i < R; ++i) {
				final int m = sc.nextInt();
				final int t = sc.nextInt();
				final int p = sc.nextInt();
				final int j = sc.nextInt();
				if (j == 0)
					teams[t - 1].accept(m, p - 1);
				else
					teams[t - 1].reject(m, p - 1);
			}
			java.util.Arrays.sort(teams, (new java.util.Comparator<Team>() {
				@Override
				public int compare(Team o1, Team o2) {
					final int det = o1.compareTo(o2);
					if (det != 0) return -det;
					if (o2.id < o1.id) return -1;
					if (o1.id < o2.id) return 1;
					return 0;
				}
			}));
			for (int i = 0; i < T; ++i) {
				if (i > 0) {
					if (teams[i-1].equals(teams[i]))
						out.print('=');
					else
						out.print(',');
				}
				out.print(teams[i].id);
			}
			out.println();
		}
	}
	
	public static void main(String[] args) {
		(new Main(System.in, System.out)).run();
	}
	
	private static class Team implements Comparable<Team> {
		public final int id;
		private final boolean[] solved;
		private final int[] penalty;
		
		public Team(int id, int n) {
			this.id = id;
			this.solved = new boolean[n];
			this.penalty = new int[n];
		}
		
		public void accept(int m, int p) {
			this.solved[p] = true;
			this.penalty[p] += m;
		}
		
		public void reject(int m, int p) {
			this.penalty[p] += 20;
		}
		
		@Override
		public boolean equals(Object obj) {
			if (obj == this) return true;
			if (!(obj instanceof Team)) return false;
			final Team o = (Team) obj;
			return this.getSolved() == o.getSolved() && this.getPenalty() == o.getPenalty();
		}

		@Override
		public int compareTo(Team o) {
			final int ss = this.getSolved();
			final int os = o.getSolved();
			if (ss < os) return -1;
			if (os < ss) return 1;
			final int sp = this.getPenalty();
			final int op = o.getPenalty();
			if (op < sp) return -1;
			if (sp < op) return 1;
			return 0;
		}
		
		private int getSolved() {
			int rval = 0;
			for (int i = 0; i < this.solved.length; ++i) {
				if (solved[i])
					++rval;
			}
			return rval;
		}
		
		private int getPenalty() {
			int rval = 0;
			for (int i = 0; i < this.solved.length; ++i) {
				if (this.solved[i])
					rval += this.penalty[i];
			}
			return rval;
		}
	}

}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int ans = 0;

  for (int i = 1; i <= N; i++) {
    int x = i, sum = 0;
    while (x > 0) {
      sum += x % 10;
      x /= 10;
    }
    if (sum >= A && sum <= B) ans += i;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

const int N = 1000009;
int dp[N];
int isprime[N];

int main()
{
    dp[1] = 0;
    for(int i=2;i<N;i++)
    {
        if(!isprime[i])
            for(int j=2*i;j<N;j+=i)
                isprime[j] = 1;
        dp[i] = dp[i-1] + ((isprime[i])?0:1);
    }

    int y;
    while(~scanf("%d",&y))
        printf("%d\n",dp[y]);
    return 0;
}

Measured memory_bytes: 8836
export default solve;

// =================================================
// ABC110C
// =================================================

// main
function main(lines) {
  console.log(solve(lines));
}

// interface
type Tuple = { value: number; count: number };

// solver
function solve(lines: string[]): string {
  const { N, evens, odds } = parseLines(lines);

  const evenTuples = getDescSortedTuplesByExistsNumberCount(evens);
  const oddTuples = getDescSortedTuplesByExistsNumberCount(odds);
  const steps: number[] = [];
  for (let i = 0; i < 2; i++) {
    for (let j = 0; j < 2; j++) {
      const evenTuple = evenTuples[i];
      const oddTuple = oddTuples[j];
      if (evenTuple && oddTuple && evenTuple.value === oddTuple.value) {
        steps.push(N - (evenTuple ? evenTuple.count : 0));
      } else {
        steps.push(N - (evenTuple ? evenTuple.count : 0) - (oddTuple ? oddTuple.count : 0));
      }
    }
  }
  return Math.min(...steps).toString();
}

// helpers
function getDescSortedTuplesByExistsNumberCount(nums: number[]): Tuple[] {
  const numsCountMap: Record<number, number> = nums.reduce((acc, v) => {
    !acc[v] ? (acc[v] = 1) : acc[v]++;
    return acc;
  }, {});
  const sortedTuples: Tuple[] = Object.keys(numsCountMap)
    .map(key => ({ value: +key, count: numsCountMap[key] }))
    .sort((x, y) => y.count - x.count);
  return sortedTuples;
}

function parseLines(lines: string[]) {
  const N = +lines[0];
  const nums = lines[1].split(' ').map(s => +s);
  const evens = nums.filter((v, i) => i % 2 === 0);
  const odds = nums.filter((v, i) => i % 2 !== 0);
  const obj = { N, nums, evens, odds };
  debug(obj);
  return obj;
}

// general helpers
function debug(message?: any, ...optionalParams: any[]) {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
}

// reader
if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume().setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}


Measured memory_bytes: 41796
BIG_NUM = 10**18

N = int(input())
H = list(map(int, input().split(" ")))

l = [BIG_NUM] * (N+10)
l[0] = 0

for i in range(1, N):
    l[i] = min(
        l[i-1] + abs(H[i] - H[i-1]),
        l[i-2] + abs(H[i] - H[i-2]),
    )

print(l[N-1])

Measured memory_bytes: 13924
import math
r,g,b,n=map(int, input().split()) 
count=0
k=[]
for i in range(n+1):
    for j in range(n+1):
        if n-(i*g+j*r)>=0:
            k.append(i*g+j*r)
        else:
            break
     
for i in range(len(k)):
    if (n-k[i])%b==0:
        count+=1
            
print(count)
            
    
    
            
                
    
        

     

    

     

    


Measured memory_bytes: 130660
import sys

N = int(input())

count = 0
ans = 'No'
for _ in range(N):
    D1, D2 = map(int, sys.stdin.readline().strip().split())

    if D1 == D2:
        count += 1
    else:
        count = 0

    if count >= 3:
        ans = 'Yes'
        break

print(ans)



Measured memory_bytes: 61832
import java.util.*;

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

        while ((h != 0) || (w != 0)) {
            for (int i = 0; i < h; i++) {

                if ((i % 2) == 0) {
                    for (int j = 0; j < w; j++) {
                        if ((j % 2) == 0) {
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }

                    }

                } else {
                    for (int j = 0; j < w; j++) {
                        if ((j % 2) == 1) {
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }

                    }
                }


                System.out.println("");
            }
            System.out.println("");
            h = scn.nextInt();
            w = scn.nextInt();


        }

        scn.close();


    }
}



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

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0);
    long long n, ans = LLONG_MAX;
    scanf("%lld", &n);
    
    for (long long i = 1; i * i <= n; i++)
        if (n % i == 0)
            ans = min(ans, i + n / i - 2);

    printf("%lld\n", ans);
    
    return 0;
}


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

int main() {
  int N,S;
  cin>>N;
  if(N%2==0){
    vector<char> former(N/2);
    vector<char> latter(N/2);
    for(int i =0; i<(N/2) ; i++){
      cin>>former.at(i);
    }
    for(int i=0; i<(N/2); i++){
      cin>>latter.at(i);
    }
    
    if(former==latter){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  else{
    cout<<"No"<<endl;
  }
}


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

int main(void)
{
	char p[200],s[100],a[100];
	
	scanf("%s",p);
	scanf("%s",s);
	strcpy(a,p);
	
	strcat(p,a);
	
	if(strstr(p,s) == NULL)
	printf("No\n");
	else
	printf("Yes\n");
	
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    set<string> s;
    cin >> N;
    long long count = 0;
    for(int i = 0; i < N; i++){
        string t;
        cin >> t;
        if(!s.count(t)){
            s.insert(t);
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 19176
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vint = vector<int>;

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

	int n, d, x, t;
	cin >> n;
	cin >> d >> x;
	int a[d] = {};
	REP(i, n){
		cin >> t;
		REP(j, d){
			if (j%t == 0){
				a[j]++;
			}
		}
	}
	int resu = 0;
	REP(i, d){
		resu += a[i];
	}
	cout << resu + x << "\n";
	return 0;
}

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

int a[7], n, x, m, l[10], r[10], s[10], b[7] = {-1}, bsum = -1, c[7] = {};

void dfs(int i){
    if(i == n+1){
        int tmpsum = 0;
        for(int j = 1; j <= n; j++) c[j] = c[j-1]+a[j], tmpsum+=a[j];
        if(tmpsum <= bsum)  return;
        bool valid = true;
        for(int j = 0; j < m; j++){
            valid &= s[j]==c[r[j]]-c[l[j]-1];
        }
        if(valid){
            for(int j = 1; j <= n; j++) b[j] = a[j];
            bsum = tmpsum;
        }
        return;
    }
    for(int j = 0; j <= x; j++){
        a[i] = j;
        dfs(i+1);
    }
}

int main(){
    cin >> n >> x >> m;
    for(int i = 0; i < m; i++){
        cin >> l[i] >> r[i] >> s[i];
    }
    dfs(1);
    if(bsum == -1){
        cout << -1 << endl;
    }else{
        for(int i = 1; i <= n; i++) cout << b[i] << " \n"[i==n];
    }
    return 0;
}


Measured memory_bytes: 3112
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace AtCoder_Beginner_Contest_128
{
    class Program
    {
        public struct Pair
        {
            public long T;
            public long E;
            public long X;
            public Pair(long t, long e, long x) { T = t; E = e; X = x; }
        }
        static public int[] SIn() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public string[] SInS() { return ReadLine().Split().ToArray(); }
        static void Main(string[] args)
        {
            var NQ = SIn();
            var N = NQ[0];
            var Q = NQ[1];
            var start = new long[N];
            var end = new long[N];
            var stx = new List<Pair>(2 * N);
            for (var i = 0; i < N; ++i)
            {
                var STX = SIn();
                stx.Add(new Pair(STX[0] - STX[2], 1, STX[2]));
                stx.Add(new Pair(STX[1] - STX[2], -1, STX[2]));
            }
            var orderd = stx.OrderBy(st => st.T).ToArray();
            var Di = new long[Q];
            var dst = new long[Q];
            for (var i = 0; i < Q; ++i)
            {
                Di[i] = SIn()[0];
                dst[i] = -1;
            }
            var Kouji = new SortedDictionary<long, long>();//x,なんでもいい
            int dcnt = 0;
            for (var i = 0; i < orderd.Length; ++i)
            {
                while (dcnt < Q && Di[dcnt] < orderd[i].T)
                {
                    if (0 != Kouji.Count)
                    { dst[dcnt] = Kouji.Keys.First(); }
                    ++dcnt;
                }
                if (orderd[i].E == 1)
                { Kouji[orderd[i].X] = 1; }
                else
                { Kouji.Remove(orderd[i].X); }
            }
            StringBuilder ans = new StringBuilder();
            foreach (var d in dst)
            {
                ans.Append($"{d}\n");
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 63236
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long ans,x=b*d,y=a*d,z=b*c,k=a*c;
    ans=max(x,max(y,max(z,k)));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int d;
    cin >> d;

    switch(d){
        case 22:
            cout << "Christmas Eve Eve Eve" << endl;
            break;
        case 23:
            cout << "Christmas Eve Eve" << endl;
            break;
        case 24:
            cout << "Christmas Eve" << endl;
            break;
        case 25:
            cout << "Christmas" << endl;
            break;
    }
    
    return 0;
}
    


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

int main(){
    ll n;
    cin >> n;
    n--;

    vector<char> ans;
    int a = 0;

    while(n>=0){
        ans.push_back((char)'a' + (n%26));
        n/=26;
        n--;
    }

  
    for(int i = ans.size() - 1; i >= 0; i--){
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3632
N = int(input())


def isPrime(n):
    if n == 2: return True
    elif n <= 1:return False
    i = 2
    while i ** 2 <= n:
        if n % i == 0:
            return False
        i += 1
    return True


cnt = 0
for i in range(N):
    a = int(input())
    if isPrime(a):
        cnt+= 1
print(cnt)




Measured memory_bytes: 5608
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } 
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } 

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())




    const int MAX_V = 2010;
    
    int V; // 左の頂点数。忘れずに設定すること。
    // ちなみに、Vは左右合わせた全部の頂点数でも問題ない。（左が終わった後に右からのをチェックしても、マッチ数は絶対増えない）
    
    
    VI G[MAX_V]; // ちゃんとGもケースごとに全部clear。
    int match[MAX_V];
    bool used[MAX_V];
    
    void add_edge(int u, int v){
        G[u].PB(v);
        G[v].PB(u);
    }
    
    bool dfs(int v){
        used[v] = true;
        REP(i, SZ(G[v])){
            int u = G[v][i], w = match[u];
            if(w < 0 || (!used[w] && dfs(w))){
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
    
    int bipartite_matching(){
        int res = 0;
        MSET(match, -1);
        REP(v, V){
            if(match[v] < 0){
                MSET(used, 0);
                if(dfs(v)) res++;
            }
        }
        return res;
    }
    
    
    
int INF = (1<<29);

int n, m, l;
int g[110][110];
int p[1010], t[1010];

void init() {
}

void input() {
	REP(i, 110) REP(j, 110) g[i][j] = INF;
	REP(i, n) g[i][i] = 0;
	REP(i, m){
		int u, v, d;
		cin >> u >> v >> d;
		g[u][v] = d, g[v][u] = d;
	}
	REP(k, n) REP(i, n) REP(j, n) chmin(g[i][j], g[i][k]+g[k][j]);
	REP(i, l) cin >> p[i] >> t[i];
}

void solve() {
	V = l*2;
	REP(i, V) G[i].clear();
	REP(i, l) REP(j, l) if(i != j){
		if(t[i] + g[p[i]][p[j]] <= t[j]) add_edge(i, j+l);
		if(t[j] + g[p[j]][p[i]] <= t[i]) add_edge(j, i+l);
	}
	cout << l - bipartite_matching() << endl;
}

int main() {
	init();
	while(cin >> n >> m >> l){
		if(n == 0) break;
		input();
		solve();
	}
	return 0;
}

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

using namespace std;

typedef long long LL;

const int N = 110;

int n, x;
int L[N];

int main()
{
    cin >> n >> x;
    for(int i = 1; i <= n; i++) cin >> L[i];

    int now = 0, res = 0;
    for(int i = 1; i <= n + 1; i++)
    {
        if(now <= x) res++;
        now += L[i];
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
void main()
{
	auto io = new IO();
	auto N = io.line!size_t()[0];
	auto input = io.line!size_t();
	size_t pair = 0;
	
	foreach( i,v ; input ){
		if( i<v-1 && i==input[v-1]-1 ){
			pair++;
		}
	}
	writeln(pair);
}



import std.stdio,std.string,std.conv;
class IO
{
	string str( size_t lines = 1 )
	{
		return readln().chomp();
	}
	T[] line( T = real , string sp = " "  )( size_t lines = 1 ) 
	{
		T[] ret;
		foreach( i ; 0..lines )
			ret ~= readln().chomp().split(sp).convert!T();
		return ret;
	}
	T[][] rect( T = real , string sp = " " )( size_t lines = 1 )
	{
		T[][] ret = new T[][](lines);
		foreach( i ; 0..lines )
			ret[i] = readln().chomp().split(sp).convert!T();
		return ret;
	}
}
R[] convert( R , T )( T[] args ) pure
{
	R[] ret = new R[](args.length);
	foreach( i ; 0..args.length )
		ret[i] = args[i].to!R();
	return ret;
}

T sum( T )( in T[] args ) pure nothrow
{
	T ret = 0;
	foreach( elm ; args )
		ret += elm;
	return ret;
}



Measured memory_bytes: 4156
//MinMaxSum.cpp
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    long n,i,m1,m2,sum;
    cin>>n;
    long a[n];
    sum=0;
    for ( i = 1; i <= n; i++) cin>>a[i];
    m1=a[1];
    m2=a[1];
    for ( i = 1; i < n; i++)
    {
        m1=max(m1,a[i+1]);
        m2=min(m2,a[i+1]);
        sum+=a[i];
    }
    sum+=a[n];
    cout<<m2<<" "<<m1<<" "<<sum<<endl;
}


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

int main(){
	int n,x,y;
	cin>>n>>x>>y;
	int ans[n+1];
	for(int i =1;i<n;i++)
		ans[i] = n - i;

	for(int i =1;i<=x;i++){
		for(int j = y-i;j<=n-i;j++){
			ans[j]--;
			ans[j - (y - x -1)]++;
		}
	}

	for(int i =1;i<=x;i++){
		//vertices
		for(int j = x + 1;j<= y - 1;j++){
			int z = x - i  + 1 + y - j;
			if(j - i > z)
			{
				ans[j-i]--;
				ans[z]++;
			}
		}
	}


	for(int i =x+1;i<=y-1;i++){
		//vertices
		for(int j = i+1;j<= y;j++){
			int z = i - x + 1 + y - j;
			if(j - i > z)
			{
				ans[j-i]--;
				ans[z]++;
			}
		}
	}

	for(int i =x+1;i<=y-1;i++){
		//vertices
		for(int j = y+1;j<= n;j++){
			int z = i - x + 1 + j - y;
			if(j - i > z)
			{
				ans[j-i]--;
				ans[z]++;
			}
		}
	}

	for(int i =1;i<n;i++)
		cout<<ans[i]<<"\n";
}

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

int pow(int n){

        int ans = 1;
        for(int i=0;i<n;i++){
            ans *= 10;
        }
    return ans;

}

int main()
{
    string s,t;
    int n,taro=0,hanako=0;
    cin >> n;

    rep(i,n){
        cin >> s >> t;

        if(s<t) hanako += 3;
        if(s>t) taro += 3;
        if(s==t) {hanako++;taro++;}
    }

    cout << taro << " " << hanako << endl;

    return 0;

}


Measured memory_bytes: 3148
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	x=0;char c=getchar();bool f=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
	if(x<0){putchar('-'),write(-x);}
	else{if(x>9)write(x/10);putchar('0'+x%10);}
}

const int N=2005;
int n,m,q,a[N][N],s[N][N],sx[N][N],sy[N][N];

void doit(){
	int x,y,xx,yy;
	read(x);read(y);read(xx);read(yy);
	int n=s[xx][yy]-s[xx][y-1]-s[x-1][yy]+s[x-1][y-1];
	int m=(sx[xx][yy-1]-sx[xx][y-1]-sx[x-1][yy-1]+sx[x-1][y-1])+(sy[xx-1][yy]-sy[x-1][yy]-sy[xx-1][y-1]+sy[x-1][y-1]);
	write(n-m);puts("");
}

signed main(){
	read(n);read(m);read(q);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) scanf("%1d",&a[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
			sx[i][j]=sx[i-1][j]+sx[i][j-1]-sx[i-1][j-1]+(a[i][j]+a[i][j+1]==2);
			sy[i][j]=sy[i-1][j]+sy[i][j-1]-sy[i-1][j-1]+(a[i][j]+a[i+1][j]==2);
		}
	while(q--) doit();
}

Measured memory_bytes: 64640
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
using namespace std;

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

	string s;

	cin >> s;

	cout << s.substr(0, 3) << endl;

	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,x;
  cin>>a>>b;
   x=a*b;
  if(x%2==0){
  cout<<"Even"<<endl;
  }
  else if(x%2>0){
 cout<<"Odd"<<endl; 
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  lli N;
  cin >> N;
  vector< lli > a(N + 1);
  vector< lli > b(N);
  REP(i, N + 1) { cin >> a[i]; }

  REP(i, N) { cin >> b[i]; }
  lli sum = 0;
  REP(i, N) {
    REP(j, 2) {
      lli minab = min(a[i + j], b[i]);
      a[i+j] -= minab;
      b[i] -= minab;
      sum += minab;
    }
  }
  cout << sum << endl;
}


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

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    int x[n];
    for (int i=0;i<n;i++) scanf("%d",&a[i]);
    for (int i=0;i<n;i++) x[i]=0;
    for (int j=0;j<n;j++){
        if (j%2==0){
            x[0]+=a[j];
        }else{
            x[0]-=a[j];
        }
    }
    for(int i=1;i<n;i++){
        x[i]=2*a[i-1]-x[i-1];
    }
    for(int i=0;i<n;i++) printf("%d ",x[i]);
}


Measured memory_bytes: 2048
#include<stdio.h>
int main()
{
	int n,a,b;
	scanf("%d",&n);
	a=n/100;
	n=n%100;
	b=n/10;
	n=n%10;
	if(a==7||b==7||n==7) printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

using namespace std;

long long Luca[87];

long long int L(int n) {
	Luca[0] = 2;
	Luca[1] = 1;
	if(n>1)
		for (int i = 2;i <=n;i++) {
			Luca[i] = Luca[i - 1] + Luca[i - 2];
	}
	return Luca[n];
}

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

Measured memory_bytes: 256
N,M=map(int, input().split())
G=[list() for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)
ans=0
index=-1
for i in range(1,N):
    for p in G[i]:
        if index<p<i:
            ans+=1
            index=i-1
import time
time.sleep(1)
print(ans)


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

int main() {
  int N;
  cin >> N;
  int A[N];
  A[0] = 0;
  int out[N];
  fill(out, out + N, 0);
  for (int i = 0; i < N - 1; i++) {
    cin >> A[i];
    out[A[i]-1]++;
  }

 for (int i = 0; i < N; i++) {
   cout << out[i] << endl;
 }
}



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


int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int cnt=0,m=a[0],t=0;
    for(int i=1;i<n;i++){
        if(a[i]-m>t){
            cnt=1;
            t=a[i]-m;
        }
        else if(a[i]-m==t){
            cnt++;
        }
        m=min(m,a[i]);
        
    }

    cout<<cnt;

}

Measured memory_bytes: 640