akhauriyash/Code-Regression huggingface dataset:
//Amazing Graze
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define ABS(x) ((x)<0 ? -(x) : x)
#define POW(x) ((x)*(x))

struct Mech{
	int x, y;
	int power;
};

struct Bullet{
	int x, y;
	bool operator<(const Bullet& var) const{ return x < var.x; };
};

int AN, BN, R;
vector<Mech> mech;
vector<Bullet> bullet;

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

	int totalpower = 0;
	int i = 0;
	Mech tm1 = {};
	Bullet tb1 = {}, tb2 = {};
	vector<Bullet>::iterator sortbeg, sortend;
	mech.reserve(100000);
	bullet.reserve(100000);
	while (1){
		cin >> AN >> BN >> R;
		if (AN == 0 && BN == 0)break;
		R *= 4;//R4倍
		mech.clear();
		bullet.clear();
		//代入
		for (i = 0; i < AN; ++i){
			cin >> tm1.x >> tm1.y;
			tm1.power = 0;
			mech.push_back(tm1);
		}
		for (i = 0; i < BN; ++i){
			cin >> tb1.x >> tb1.y;
			bullet.push_back(tb1);
		}
		sort(bullet.begin(), bullet.end());

		//戦闘力計算
		totalpower = 0;
		for (i = 0; i < AN; ++i){//各戦闘機について
			//Xソートで範囲確認
			tb1.x = mech[i].x - R; tb2.x = mech[i].x + R;
			if ( tb1.x > 0 )sortbeg = lower_bound(bullet.begin(), bullet.end(), tb1);
				else sortbeg = bullet.begin();
			if (sortbeg == bullet.end())continue;
			sortend = upper_bound(sortbeg, bullet.end(), tb2);
			for (; sortbeg != sortend; ++sortbeg){
				if (ABS(mech[i].y - sortbeg->y) > R)continue;
				if (POW(mech[i].x - sortbeg->x) + POW(mech[i].y - sortbeg->y) <= POW(R)){
					++mech[i].power;
				}
			}
			totalpower += mech[i].power;
		}

		cout << totalpower << endl;
	}

	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

bool isok(string s) {
    int n = s.size();
    if (n%2 == 0) {
        rep(i, n/2) {
            if (s[i] != s[n/2+i]) {
                return false;
            }
        }
        return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n) {
        s.pop_back();
        if (isok(s)) {
            cout << s.size() << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    long long X, Y; cin >> X >> Y;
    if (X * 2 > Y) {
        cout << 1 << endl;
        return 0;
    }
    REP(i, 10000000) {
        X *= 2;
        if (X * 2 > Y) {
            cout << i+1 << endl;
            break;
        }
    }
}

Measured memory_bytes: 3532
/*
样例大良心 qvq
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 1e5 + 10;
int n, a[N], mn = 1e9, mx = -1e9;

int main() {
    cin >> n;
    rep(i, 1, n) {
        scanf("%d", &a[i]);
        mx = max(mx, a[i]), mn = min(mn, a[i]);
    }
    if (mn < mx - 1 || mx > n - 1) return puts("No"), 0;
    if (mn == mx) {
        if (mn == n - 1) puts("Yes");
        else {
            if (mn * 2 > n) puts("No");
            else puts("Yes");
        }
    } else {
        int cnt = 0;
        rep(i, 1, n) if (a[i] == mn) ++cnt;
        if (mn < cnt) puts("No");
        else if ((mx - cnt) * 2 > (n - cnt)) puts("No");
        else puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 4072
from collections import Counter
N = int(input())
ans = 0
even = 0
cnt = Counter(map(int, input().split()))
for k, v in cnt.items():
    if v % 2 == 0:
        ans += (v - 2) // 2
        even += 1
    else:
        ans += v // 2
ans += even // 2 + even % 2
print(N - ans * 2)


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/27  Problem: 083_arc_b / Link: https://arc083.contest.atcoder.jp/tasks/arc083_b?lang=en  ----- */
/* ------問題------

かつて存在した高橋王国には N 個の都市があり、いくつかの都市の組は道路で双方向に結ばれていました。 道路の構造は以下のようであったことがわかっています。
都市間の移動は道路を通ってのみ行われ、どの都市からどの都市へも必要なら他の都市を経由することで移動できるようになっていた。
道路の長さは道路によって異なっていたかもしれないが、全て正整数であった。
考古学者のすぬけ君は、高橋王国の遺跡で整数からなる N×N の表 A を発見しました。 すぬけ君は、この表は高橋王国における都市間の道路に沿った最短距離を表した表ではないかと考えました。
すべての u,v について、A の u 行目 v 列目の整数 Au,v が都市 u から都市 v への最短経路の長さとなるような 道路の構造が存在するかどうか判定してください。 さらに、存在する場合、そのような道路の構造のうち、存在する道路の長さの和が最小となるようなものについて、その和を求めてください。

-----問題ここまで----- */
/* -----解説等-----

-1の判定はもう一回ワーシャルフロイドをすればよさそう
最小の道路の構成は最短路を考えたとき、ある点を経由してつくられる最短路、
つまり最短路でつくられる最短路は数える必要がない。

----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VVI a(N, VI(N));
	FOR(i, 0, N) {
		FOR(j, 0, N) {
			cin >> a[i][j];
		}
	}
	VVI m_use(N, VI(N, 1));
	FOR(k, 0, N)FOR(i, 0, N)FOR(j, 0, N) {
		if (a[i][j] > a[i][k] + a[k][j]) {
			cout << -1 << endl;
			return 0;
		}
		if ((!((i==j)||(j==k)||(k==i))) &&a[i][j] == a[i][k] + a[k][j]) {
			m_use[i][j] = 0;
		}
	}
	FOR(i, 0, N) {
		FOR(j, i, N) {
			ans += m_use[i][j] * a[i][j];
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
import bisect
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort()


two_bekis = []
tmp = 1
while tmp < 2*10**9:
    two_bekis.append(tmp)
    tmp *= 2

ans = 0
cnt = Counter(A)
seta = set(A)
for i, a in enumerate(reversed(A)):
    idx = bisect.bisect_right(two_bekis, a)
    two_beki = two_bekis[idx]
    b = two_beki - a
    if b not in seta:
        continue

    if a == b and cnt[a] >= 2:
        ans += 1
        cnt[a] -= 2
    elif a != b and cnt[a] >= 1 and cnt[b] >= 1:
        ans += 1
        cnt[a] -= 1
        cnt[b] -= 1
print(ans)


Measured memory_bytes: 117332
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	while (k--) {
		vector<int> s(n + 1);
		rep(i, n) {
			s[max(0ll, i - a[i])]++;
			s[min(n, i + a[i] + 1)]--;
		}
		rep(i, n) s[i + 1] += s[i];
		bool flag = true;
		rep(i, n) {
			a[i] = s[i];
			if (a[i] != n) flag = false;
		}
		if (flag) break;
	}
	rep(i, n) cout << a[i] << ' ';
	cout << '\n';
}

Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A == B && C != A){
    
    cout << "Yes" << endl;
    
  }
  
   else if(B == C && A != B){
    
    cout << "Yes" << endl;
    
  }
  
   else if(C == A && B != C){
    
    cout << "Yes" << endl;
    
  }
  
  else{
    
    cout << "No" << endl;
    
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define endl "\n"
#define ar array
#define deb(x) cout << #x << " = " << x << endl
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll N = 2e5 + 1;

template <class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
inline ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }
inline ll sub(ll a, ll b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline ll mul(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }
struct comp
{
    bool operator()(const pair<ll, ll> &x, const pair<ll, ll> &y) const
    {
        return x.first < y.first;
    }
};
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll pwr(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n & 1)
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    else
        return pwr(mul(x, x), n / 2);
}
ll modInv(ll n)
{
    return pwr(n, mod - 2);
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}
int main()
{
    IOS;
    int t = 1;
   // cin >> t;
    while (t--)
    {
        ll n, x, y;
        cin >> n;
        ll summax = INT_MIN, summin = INT_MAX, diffmax = INT_MIN, diffmin = INT_MAX;
        for (int i = 0; i < n; i++)
        {
            cin >> x >> y;
            summax = max(summax, x + y);
            summin = min(summin, x + y);
            diffmax = max(diffmax, x - y);
            diffmin = min(diffmin, x - y);
        }
        ll ans = max(abs(summax - summin), abs(diffmax - diffmin));
        cout << ans << endl;
    }
}

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

int main() {
  int x[5], num;
  for(int i =1; i<=5; i++){
    cin>> x[i];
  }
  for(int i =1; i<=5; i++){
    if(x[i]==0){
      num =i;
    }
  }
  cout<< num<< endl;
  return 0;
}

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

#define fr first
#define sc second
#define mk make_pair

using namespace std;

long long n, k, ar[1000001];

bool ok(long long a, long long b)
{
    long long h = 1;
    for(int i = 1; i <= b; i++)
    {
        h = h * a;
        if(n <= h)
            return 1;
    }
    return 0;
}

int main()
{
    cin >> n >> k;
    long long ans = n;
    for(long long i = 1; i <= 40; i++)
    {
        long long x = i * k;
        long long l = 1, r = 1e6;
        while(r - l > 1)
        {
            long long mid = (r + l) / 2;
            if(ok(mid, i + 1))
                r = mid;
            else
                l = mid;
        }
        long long u = 1;
        for(int j = 1; j <= i + 1; j++)
            u *= l;

        x += (i + 1) * l;
        for(int j = 1; j <= i + 1; j ++)
        {
            u /= l;
            u *= r;
            x++;
            if(u >= n)
                break;
        }
        ans = min(ans, x);
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val s = (1..h).map { readLine()!! }

    val hs = listOf(-1, -1, 0, 1, 1, 1, 0, -1)
    val ws = listOf(0, 1, 1, 1, 0, -1, -1, -1)

    for (i in (0..(h - 1))) {
        var sb = StringBuilder(w)

        for (j in (0..(w - 1))) {

            if (s[i][j] == '#') {
                sb.append('#')
                continue
            }

            var c = 0

            for (k in 0..7) {
                if (i + hs[k] !in (0..(h - 1))) {
                    continue
                }

                if (j + ws[k] !in (0..(w - 1))) {
                    continue
                }

                if (s[i + hs[k]][j + ws[k]] == '#') {
                    c++
                }
            }

            sb.append(c)
        }

        println(sb)
    }

}

Measured memory_bytes: 37904
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    unordered_set<int> s;
    for (uint b = 0; ((b >> n) & 1) != 1; ++b) {
        int sum = 0;
        rep(i, n) if (((b >> i) & 1) == 1) sum += a[i];
        s.insert(sum);
    }
    int q; 
    cin >> q;
    rep(i, q) {
        int m;
        cin >> m;
        cout << (s.count(m) == 1 ? "yes" : "no") << endl;
    }
    return 0;
}




Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
long long min(long long x,long long y){
    if(x>=y) return y;
    else return x;
}
int main() {
	long long int n,w;
	cin>>n>>w;
	long long int wei[n],val[n];
	for(auto i=0;i<n;i++){
	    cin>>wei[i]>>val[i];
	}
    int vv=1e5;
    vector<vector<int>>dp (n+1,vector<int>(vv+1,INT_MAX));
    for(int i=0;i<=n;i++)dp[i][0]=0;
    for (int i = 1; i<=n; i++)
        for (int j =1; j<=100000; j++)
        {
            dp[i][j] = dp[i-1][j];
            if (j>=val[i-1])
                dp[i][j] = min(dp[i][j],dp[i-1][j-val[i-1]]+wei[i-1]);
        }
    int ans=0;
    for(int i=0;i<=100000;i++){
        if(dp[n][i]<=w) ans=i;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 40320
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=100005;
char ch[MAXN];
int SA[2][MAXN];
int main()
{
	scanf("%s",ch+1);int len=strlen(ch+1);
	for(int i=1;i<=len;i++)SA[0][i]=SA[0][i-1]+(ch[i]=='A');
	scanf("%s",ch+1);len=strlen(ch+1);
	for(int i=1;i<=len;i++)SA[1][i]=SA[1][i-1]+(ch[i]=='A');
	int Q=read();while(Q--)
	{
		int l=read(),r=read(),u=read(),v=read();
		int b1=(r-l+1-(SA[0][r]-SA[0][l-1]))+2*(SA[0][r]-SA[0][l-1]);
		int b2=(v-u+1-(SA[1][v]-SA[1][u-1]))+2*(SA[1][v]-SA[1][u-1]);
		if(abs(b1-b2)%3==0)puts("YES");
		else puts("NO");
	}
	return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main() {
  int n;
  vector<pair<string, int>> data;
  cin >> n;
  vector<int> order(n);
  REP(i, n) {
    string s;
    int p;
    cin >> s >> p;
    data.push_back(make_pair(s, p));
  }
  REP(i, n) {
    int num = 0;
    auto target = data[i];
    REP(j, n) {
      if (i == j) continue;
      int comp = target.first.compare(data[j].first);
      if (comp < 0 || (comp == 0 && data[j].second < target.second)) continue;
      num++;
    }
    order[num] = i + 1;
  }
  REP(i, n) cout << order[i] << endl;
}

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

using namespace std;

int solve(int n, int x) {
	int cnt;

	cnt = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			for (int k = j + 1; k <= n; ++k) {
				if (i + j + k == x) {
					++cnt;
				}
			}
		}
	}

	return cnt;
}

int main() {
	int n, x;

	while (cin >> n >> x, n) {
		cout << solve(n, x) << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
  if (D == 25) {
    cout << "Christmas" << endl;
  }
  if (D == 24) {
    cout << "Christmas Eve" << endl;
  }
  if (D == 23) {
    cout << "Christmas Eve Eve" << endl;
  }
  if (D == 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  }
}
  

Measured memory_bytes: 256
// AGC 009 A
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n; cin >> n;
    ll a[n], b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }

    ll ans = 0;

    for(int i = n-1; i >= 0; i--){
        a[i] += ans;
        if(a[i] % b[i] != 0)ans += (a[i]/b[i]+1) * b[i] - a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll; 
typedef long double ld;
#define PB push_back
#define MP make_pair
#define F first 
#define S second 
#define P push
#define vvi vector<vector<ll> >
#define vi vector<ll>  
#define vpi vector< pair<ll,ll> >  
#define sz(a) (ll)a.size()
const ll N = 1e9 + 7 , N1 =  1e6+4;              
signed main()
{   
string t;
cin>>t;
cout<<t[0]<<t[1]<<t[2];
return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
int main(void){
	int n,d1,d2,i,a,b,c,p;
	while(1){
		b=0;
	scanf("%d",&n);
	if(n==0){
		break;
	}
	for(i=1;i<=n;i++){
		scanf("%d%d%d",&p,&d1,&d2);
		a=d1+d2;
		if(b<a){
			b=a;
			c=p;
		}
	}
	
	printf("%d %d\n",c,b);
	}
	return 0;

}

Measured memory_bytes: 2708
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int h,w;
string s[51];
int dx[8] = { 1, 1, 0,-1,-1,-1, 0, 1};
int dy[8] = { 0, 1, 1, 1, 0,-1,-1,-1};

int main() {
    cin >> h >> w;
    vector<string> s(h);
    vector<string> res(h);
    REP(i,h){
        cin >> s[i];
    }
    REP(i,h){
        REP(j,w){
            int cnt = 0;
            if(s[i][j]=='.'){
                REP(l,8){
                    if(0<=i+dy[l]&&i+dy[l]<h&&0<=j+dx[l]&&j+dx[l]<w){
                        if(s[i+dy[l]][j+dx[l]]=='#'){
                            cnt++;
                        }
                    }
                }
                res[i] += '0'+cnt;
            }else{
                res[i] += '#';
            }
        }
    }
    
    REP(i,h){
        put(res[i]);
    }
    return 0;
}


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

int main() {
  while(true) {
    int N, M; cin >> N >> M;
    if(N == 0 && M == 0) break;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
      cin >> A[i];
    }

    A.push_back(0);
    vector<int> B(N*N);
    for(int a : A) {
      for(int b : A) {
        B.push_back(a+b);
      }
    }
    sort(B.begin(), B.end());
    B.erase(unique(B.begin(), B.end()), B.end());

    int ans = 0;
    for(int i = 0; i < (int)B.size(); i++) {
      if(B[i] > M) continue;
      if(B[i] == M) { ans = M; continue; }
      ans = max(ans, B[i] + *(lower_bound(B.begin(), B.end(), M - B[i]) - 1));
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 22672
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  int N = s.size();

  for(int i = 0; i < N; i++){
    if(s[i] == ',') s[i] = ' ';
  }

  cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    ll x, a = 100, ans = 0;
    cin>>x;
    while(a<x) {
        a = a/100 + a;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
} 


Measured memory_bytes: 3668
#include <vector>
#include <stack>
#include <cstddef>
#include <algorithm>

struct strongly_connected_component {
	using size_type = std::size_t;
private :
	size_type num;
	std::vector<std::vector<size_type>> g, scc;
	std::vector<size_type> low, order, index;
	std::vector<bool> instack;
	std::stack<size_type> sta;

	void chmin (size_type &a, const size_type &b) noexcept {
		if (a > b) a = b;
	}

	void dfs (size_type v) noexcept {
		low[v] = order[v] = ++num;
		sta.push(v); instack[v] = true;
		for (const size_type &u : g[v]) {
			if (order[u] == 0) {
				dfs(u);
				chmin(low[v], low[u]);
			} else if (instack[u]) {
				chmin(low[v], order[u]);
			}
		}
		if (low[v] == order[v]) {
			scc.push_back(std::vector<size_type>());
			while (true) {
				const size_type u = sta.top();
				sta.pop(); instack[u] = false;
				scc.back().push_back(u);
				if (u == v) break;
			}
		}
	}

public :
	explicit strongly_connected_component (size_type n)
	noexcept : num(0), g(n), scc(), low(n, 0), order(n, 0), index(n), instack(n, false), sta() { }

	void add_edge (size_type v, size_type u) noexcept {
		g[v].push_back(u);
	}

	size_type solve () noexcept {
		for (size_type v = 0; v < g.size(); v++) if (not order[v]) dfs(v);
		std::reverse(scc.begin(), scc.end());
		for (size_type i = 0; i < scc.size(); i++) {
			for (const size_type &v : scc[i]) index[v] = i;
		}
		return scc.size();
	}

	const std::vector<std::vector<size_type>> &get_scc () const noexcept {
		return scc;
	}

	size_type size () const noexcept {
		return scc.size();
	}

	const size_type &operator[] (size_type v) const noexcept {
		return index[v];
	}

};


#include <vector>
#include <cstddef>

struct two_sat {
	using size_type = std::size_t;
private :
	strongly_connected_component scc;
	std::vector<bool> answer;

public :
	two_sat (size_type n) noexcept : scc(n << 1), answer(n) { }

	void add_clause (size_type a, bool f, size_type b, bool g) noexcept {
		scc.add_edge(a << 1 | not f, b << 1 | g);
		scc.add_edge(b << 1 | not g, a << 1 | f);
	}

	bool satisfiable () noexcept {
		scc.solve();
		for (size_type i = 0; i < answer.size(); i++) {
			if (scc[i << 1 | 0] == scc[i << 1 | 1]) return false;
			answer[i] = (scc[i << 1 | 0] < scc[i << 1 | 1]);
		}
		return true;
	}

	bool get (const size_type i) const noexcept {
		return answer[i];
	}

};



#include <vector>
#include <cmath>
#include <iostream>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n, d;
	std::cin >> n >> d;
	std::vector<int> x(n), y(n);
	for (int i = 0; i < n; i++) {
		std::cin >> x[i] >> y[i];
	}
	
	two_sat sat(n);
	
	auto f = [&] (int a, int b) {
		return std::abs(a - b) < d;
	};
	
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (f(x[i], x[j])) sat.add_clause(i, 1, j, 1);
			if (f(x[i], y[j])) sat.add_clause(i, 1, j, 0);
			if (f(y[i], x[j])) sat.add_clause(i, 0, j, 1);
			if (f(y[i], y[j])) sat.add_clause(i, 0, j, 0);
		}
	}
	
	if (sat.satisfiable()) {
		std::cout << "Yes" << '\n';
		for (int i = 0; i < n; i++) {
			std::cout << (sat.get(i) ? y[i] : x[i]) << '\n';
		}
	} else {
		std::cout << "No" << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 3900
#include <stdio.h>

int a[100000];

int main(){
    int k;
    long long min = 2, max = 2;
    scanf("%d", &k);
    for(int i=0; i<k; i++){
        scanf("%d", &a[i]);
    }
    for(int i=k-1; i>=0; i--){
        min = ((min - 1) / a[i] + 1) * a[i];
        max = (max / a[i] + 1) * a[i] - 1;
        if(max < min){
            puts("-1");
            return 0;
        }
    }
    printf("%lld %lld\n", min, max);
}

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

int main() {
    int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    int ans = a * x + b * y;
    for (int i = 1; i <= max(x, y) * 2; i++) {
        chmin(ans, 2 * i * c + a * max(0, x - i) + b * max(0, y - i));
    }

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

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

int main () {
  int N;
  cin >> N;
  int x = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    x += r - l + 1;
  }
  
  cout << x << endl;

}

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

using namespace std;

using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }

template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());

    int n, a;
    while (read(n, a)) {
        ivec x(n);
        read(x);
        i64 ans = 0;
        forr(c, 1, n + 1) {
            int m = a * c;
            auto dp = make_vec(0ll, c + 1, m + 1);
            dp[0][0] = 1;
            fore(xi, x)  {
                for (int i = c - 1; i >= 0; i--) {
                    forn(sum, m) if (sum + xi <= m){
                        dp[i + 1][sum + xi] += dp[i][sum];
                    }
                }
            }
            // logs(c);
            // logvv(dp);
            ans += dp[c][m];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4272
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void)
{		
	for (int i = 1; i <= 10000; i++) {
		int x;
		cin >> x;
		if (x == 0) break;
		cout << "Case " << i << ": " << x << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>

int main() {
  const unsigned long long MOD = 1000000007;
  unsigned N, C;
  std::cin >> N >> C;
  std::vector<std::vector<unsigned long long>> fact_sum(401ul, std::vector<unsigned long long>(401));
  for (auto &i : fact_sum) { i[0] = 1; }
  for (unsigned i = 0; i < 401u; ++i) {
    for (unsigned j = 1; j < 401u; ++j) {
      fact_sum[i][j] = fact_sum[i][j - 1] * i;
      fact_sum[i][j] %= MOD;
    }
  }
  for (unsigned i = 1; i < 401u; ++i) {
    for (unsigned j = 0; j < 401u; ++j) {
      fact_sum[i][j] += fact_sum[i - 1][j];
      fact_sum[i][j] %= MOD;
    }
  }
  std::vector<unsigned> A(N + 1);
  std::vector<unsigned> B(N + 1);
  for (unsigned i = 1; i <= N; ++i) { std::cin >> A[i]; }
  for (unsigned i = 1; i <= N; ++i) { std::cin >> B[i]; }
  std::vector<std::vector<unsigned long long>> dp(N + 1, std::vector<unsigned long long>(C + 1, 0));
  dp[0][0] = 1;
  for (unsigned i = 1; i <= N; ++i) {
    for (unsigned j = 0; j <= C; ++j) {
      for (unsigned k = 0; k <= j; ++k) {
        auto x = fact_sum[B[i]][k] > fact_sum[A[i] - 1][k] ? fact_sum[B[i]][k] : fact_sum[B[i]][k] + MOD;
        x -= fact_sum[A[i] - 1][k];
        dp[i][j] += dp[i - 1][j - k] * x;
        dp[i][j] %= MOD;
      }
    }
  }
  std::cout << dp[N][C] << std::endl;
  return 0;
}

Measured memory_bytes: 2816
#include <iostream>
using namespace std;
int main(void){
    int all, a, b;
    cin >> all >> a >> b;
    int max, min;
    max = a < b ? a : b;
    min = 0 > (all - a - b) * -1 ? 0 : (all - a - b) * -1;
    cout << max << " " << min << endl;
    return 0;
}


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

bool cmp(ll a,ll b){
  return a>b;
}

int main(){
  ll n,w;cin >> n >> w;
  ll sum = 0;
  vector<ll> we(n);vector<ll> v(n);
  for(ll i=0;i<n;i++){
    cin >> we[i] >> v[i];
    sum += v[i];
  }

  vector<ll> dp(sum+1,INT_MAX);
  dp[0] = 0;
  for(ll i=0;i<n;i++){
    for(ll j=sum-v[i];j>=0;j--){
      dp[j+v[i]] = min(dp[j+v[i]],dp[j]+we[i]);
    }
  }

  ll ans = INT_MIN;
  for(ll i=0;i<dp.size();i++){
    if(dp[i] <= w) ans = max(ans,i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
int D, T, S;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> D >> T >> S;
    int ans;
    if(S * T >= D) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
H, W = map(int, input().split())
S = (
    [["."] * (W + 2)]
    + [["."] + [i for i in input()] + ["."] for j in range(H)]
    + [["."] * (W + 2)]
)
ans = []
for i in range(1, H + 1):
    i_ans = []
    for j in range(1, W + 1):
        if S[i][j] == "#":
            i_ans.append("#")
            continue
        num = 0
        arrows = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
        for arrow in arrows:
            if S[i + arrow[0]][j + arrow[1]] == "#":
                num += 1
        i_ans.append(num)
    ans.append(i_ans)
for i in ans:
    print(*i, sep="")


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

int main(){
	string str;
	string rev_all;
	cin>>str;
	rev_all=str;
	reverse(rev_all.begin(),rev_all.end());
	if(str!=rev_all){
		cout<<"No"<<endl;
		// cout<<rev_all<<endl;
		// cout<<1<<endl;
		return 0;
	}
	string front=str.substr(0,(str.size()-1)/2);
	string front_rev=front;
	reverse(front_rev.begin(),front_rev.end());
	if(front!=front_rev){
		cout<<"No"<<endl;
		// cout<<front_rev<<endl;
		// cout<<front_rev<<endl;
		// cout<<2<<endl;
		return 0;
	}
	string back=str.substr((str.size()+3)/2-1,str.size()-(str.size()+3)/2+2);
	string back_rev=back;
	reverse(back_rev.begin(),back_rev.end());
	if(back!=back_rev){
		cout<<"No"<<endl;
		// cout<<back_rev<<endl;
		// cout<<3<<endl;
		return 0;
	}
	else{
		cout<<"Yes"<<endl;
		// cout<<4<<endl;
		return 0;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={-1,0,1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    
    if(a[n-1]==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    
    if(n%3!=0) {
        cout<<"No"<<endl;
        return 0;
    }
    
    if(a[n/3-1]==0 && a[n/3]==a[n-1]) {
        cout<<"Yes"<<endl;
        return 0;
    }
    
    int x=a[0],y=a[n/3],z=a[2*n/3];
    if(a[n/3-1]!=x || a[2*n/3-1]!=y || a[n-1]!=z) {
        cout<<"No"<<endl;
        return 0;
    }
    
    if((x^y^z)!=0) {
        cout<<"No"<<endl;
        return 0;
    }
    
    cout<<"Yes"<<endl;
    
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
const int maxn = 200200;
const int mod = 998244353;
typedef long long ll;
inline ll pow(ll a,int b,ll ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1) ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
inline void reduce(int & x){ x += x >> 31 & mod; }
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
struct T { int to,nxt; }way[maxn << 1];
int h[maxn], num;
inline void link(int x,int y) {
	way[++num] = {y,h[x]}, h[x] = num;
	way[++num] = {x,h[y]}, h[y] = num;
}
int n;
char s[maxn];
int size[maxn];
ll dep[maxn];
ll ans = 1e18;
inline void dfs0(int x,int f = 0) {
	size[x] = s[x] & 1, dep[x] = 0;
	for(int i = h[x];i;i = way[i].nxt) if(way[i].to != f) {
		dfs0(way[i].to, x);
		size[x] += size[way[i].to];
		dep[x] += dep[way[i].to];
	}
	dep[x] += size[x];
}
inline int get(int x,int fa = 0) {
	if(x == 0) return 0;
	int son = 0, sum = 0;
	for(int i = h[x];i;i = way[i].nxt) if(way[i].to != fa) {
		if(dep[way[i].to] > dep[son]) son = way[i].to;
		sum += dep[way[i].to];
	}
	int k = get(son, x) + size[son];
	return k <= sum - dep[son] ? sum & 1 : k - (sum - dep[son]);
}
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> s + 1;
	for(int i = 1,x,y;i < n;++i) {
		std::cin >> x >> y, link(x, y);
	}
	for(int i = 1;i <= n;++i) {
		dfs0(i);
		ll sum = 0;
		for(int j = h[i];j;j=way[j].nxt) sum += dep[way[j].to];
		if(get(i) == 0) ans = std::min(ans, sum / 2);
	}
	std::cout << (ans < 1e17 ? ans : -1) << '\n';
}


Measured memory_bytes: 2432
#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase
#include <ctime>    // clock

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << s.substr(0,3) << endl;
    return 0;
}


Measured memory_bytes: 3652
import copy

k, n = map(int, input().split())
a = list(map(int, input().split()))

now = 0
ans = 2000000000000000000000000

for i in range(1, n):
    now = k-a[i]+a[i-1]
    if now < ans:
      ans = now

if a[n-1]-a[0] < ans:
  ans = a[n-1]-a[0]
        
print(ans)

Measured memory_bytes: 25420
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		double x1,x2,x3,y1,y2,y3,xp,yp;
		double px[]=new double[2];
		double py[]=new double[2];
		double ans[]=new double[3];
		int i;
		while(s.hasNext()){
			x1=s.nextDouble();
			y1=s.nextDouble();
			x2=s.nextDouble();
			y2=s.nextDouble();
			x3=s.nextDouble();
			y3=s.nextDouble();
			xp=s.nextDouble();
			yp=s.nextDouble();

			px[0]=x2-x1;py[0]=y2-y1;
			px[1]=xp-x1;py[1]=yp-y1;
			ans[0]=px[0]*py[1]-py[0]*px[1];

			px[0]=x3-x2;py[0]=y3-y2;
			px[1]=xp-x2;py[1]=yp-y2;
			ans[1]=px[0]*py[1]-py[0]*px[1];

			px[0]=x1-x3;py[0]=y1-y3;
			px[1]=xp-x3;py[1]=yp-y3;
			ans[2]=px[0]*py[1]-py[0]*px[1];

			if(ans[0]>0 && ans[1]>0 && ans[2]>0)
				System.out.println("YES");
			else if(ans[0]<0 && ans[1]<0 && ans[2]<0)
				System.out.println("YES");
			else{
				System.out.println("NO");
			}
		}//while
	}//main
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	string s;cin>>s;
	For(i,1,4){
		if(s[i]==s[i-1]){
			cout<<"Bad"<<endl;
			return 0;
		}
	}
	cout<<"Good"<<endl;











	
}

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

int main(void) {
    int L, R, d;
    int num = 0;

    scanf("%d %d %d", &L, &R, &d);

    for(int i = L; i <= R; i++) {
        if(i % d == 0)  num++;
    }

    printf("%d\n", num);
    
    return 0;
}


Measured memory_bytes: 1684
#include <iostream>

using namespace std;

int main() {
    int n, m, X, Y; cin >> n >> m >> X >> Y;

    int m_x = -100, m_y = 100;

    int i, x, y;
    for (i = 0; i < n; i++) {
       cin >> x;
       m_x = max(x, m_x); 
    }
    for (i = 0; i < m; i++) {
        cin >> y;
        m_y = min(y, m_y);
    }

    bool can = false;

    for (i = m_x+1; i <= m_y; i++) {
        if (X < i && i <= Y)    
            can = true;
    }

    if(can)
        cout << "No War" << endl;
    else
        cout << "War" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<queue>
#include<ctime>
#include<cassert>
#include<complex>
#include<string>
#include<cstring>
#include<chrono>
#include<random>
#include<bitset>

#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define sz(v) (int) v.size()

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

typedef long long lox;
typedef long double lod;
typedef unsigned long long pox;
typedef pair<int, int> pii;

const int MAX_N = 1e5 + 5;

int n, m;
vector<pii> g[MAX_N];
int x[MAX_N], deg_in[MAX_N];
bool used[MAX_N];

void dfs(int v) {
	used[v] = true;
	for (auto &e : g[v]) {
		int u = e.fi, w = e.se;
		if (!used[u]) {
			x[u] = x[v] + w;
			dfs(u);
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int l, r, d;
		cin >> l >> r >> d;
		g[l].eb(r, d);
		deg_in[r]++;
	}
	for (int i = 1; i <= n; ++i) {
		if (!deg_in[i]) {
			dfs(i);
		}
	}
	for (int v = 1; v <= n; ++v) {
		for (auto &e : g[v]) {
			int u = e.fi, w = e.se;
			if (x[u] != x[v] + w) {
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 9728
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;

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

	double sum = 0;
	for (int i = 0;i < k;i++) {
		sum += p[i];
	}

	double max = sum;
	
	for (int i = 0;i < n - k;i++) {
		sum += p[i + k];
		sum -= p[i];
		if (max < sum) max = sum;
	}
	double ans = (max + (double)k) / 2;
	printf("%lf", ans);
	return 0;
}

Measured memory_bytes: 4008
s = input()
ls = len(s)
sl = list(s)
ol = [0 if i%2 ==0 else 1 for i in range(ls)]
el = [1 if i%2 ==0 else 0 for i in range(ls)]
#print(sl)
#print(ol)
#print(str(el))
#for c in s:
go = 0
for c,i in zip(sl,ol):
    if int(c) != i:
        go += 1
#print(go)
ge = 0
for c,i in zip(sl,el):
    if int(c) != i:
        ge += 1
#print(ge)
print(min(go,ge))

Measured memory_bytes: 5620
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
int n;
LL A,B,C,mul,t,ans,fac[500010],inv[500010];
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}
LL Co(int x,int y){
	return fac[x]*inv[y]%MO*inv[x-y]%MO;
}
int main(){
	fac[0]=1;
	FOR(i,1,500000) fac[i]=fac[i-1]*i%MO;
	inv[500000]=pw(fac[500000],MO-2);
	FORD(i,499999,0) inv[i]=inv[i+1]*(i+1)%MO;
	cin>>n>>A>>B>>C;
	mul=1ll*(A+B+C)*pw(A+B,MO-2)%MO;
	t=A+B;
	A=A*pw(t,MO-2)%MO;
	B=B*pw(t,MO-2)%MO;
	FOR(i,n,n+n-1) (ans+=Co(i-1,n-1)*pw(A,n)%MO*pw(B,i-n)%MO*i)%=MO;
	FOR(i,n,n+n-1) (ans+=Co(i-1,n-1)*pw(B,n)%MO*pw(A,i-n)%MO*i)%=MO;
	ans=ans*mul%MO;
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF ll(1e18)
#define MOD (ll)1e9+7
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)sum+=i;
    }
    cout<<sum<<"\n";
}


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

int main(void){
 int n,m;
 cin >> n >> m;
 int a[100][100],b[100],c[100]={0};
 int i,j;
 for (i = 0; i < n; i++){
     for (j = 0; j < m; j++){
         cin >> a[i][j];
     }
 }
 for(i = 0; i < m; i++){
     cin >> b[i];
 }    
 for (i = 0; i < n; i++){
     c[i] = 0;
     for (j = 0; j < m; j++){
         c[i] += b[j] * a[i][j];
     }
 }
 for (i = 0; i < n; i++){
 cout << c[i] << endl;
 }
}


Measured memory_bytes: 3128