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

const int N=1e5+5;
typedef long long ll;

pair<int ,int> d[N];
int main()
{
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++) cin >> d[i].first >> d[i].second;
    sort(d,d+m);
    int l,r;
    int ans=0;
    l=d[0].first;
    r=d[0].second;
    for(int i=1;i<m;i++)
    {

        if(d[i].first==d[i-1].first) continue;
        else if(d[i].first>=r)
        {
            ans++;
            l=d[i].first;
            r=d[i].second;
        }
        else
        {
            r=min(r,d[i].second);
        }
    }
    if(l!=-1) ans++;
    cout << ans << endl;
    return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

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

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

struct UnionFind {
public:
    vector <ll> par; // 
    vector <ll> siz; // 

    UnionFind() {}

    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }

    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    ll h, w, m;
    cin >> h >> w >> m;
    vector<P> bs(m);
    rep(i, m) {
        cin >> bs[i].second >> bs[i].first;
        bs[i].second--;
        bs[i].first--;
    }
    vector<P> sys(h);
    rep(i, h) sys[i] = { 0, i };
    vector<P> sxs(w);
    rep(i, w) sxs[i] = { 0, i };
    rep(i, m) {
        sys[bs[i].second].first++;
        sxs[bs[i].first].first++;
    }
    auto ys = sys;
    auto xs = sxs;
    sort(ys.begin(), ys.end(), std::greater<P>());
    sort(xs.begin(), xs.end(), std::greater<P>());
    const ll maxY = ys[0].first;
    const ll maxX = xs[0].first;
    const ll u = maxY + maxX;
    ll maxYCount = 0, maxXCount = 0;
    rep(i, h) {
        if (ys[i].first == maxY) maxYCount++;
        else break;
    }
    rep(i, w) {
        if (xs[i].first == maxX) maxXCount++;
        else break;
    }
    ll cand = 0;
    rep(i, m) {
        auto p = bs[i];
        auto count = sys[p.second].first + sxs[p.first].first;
        if (count == u) {
            cand++;
        }
    }
    if (cand == maxYCount * maxXCount) {
        cout << u - 1 << endl;
        return 0;
    }
    cout << u << endl;

    return 0;
}


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

Flag = [False]*(N+1)
Flag[0] = True

num = 3
while num <= N:
    Flag[num] = True
    num += 3

num = 5
while num <= N:
    Flag[num] = True
    num += 5

count = 0
for f in range(1, N+1):
    if Flag[f] == False:
        count += f

print(count)

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

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int c,a,n;
    cin>>c>>a>>n;
    int count=0;
    while(1){
      if(a>=1&&n>=1&&c>=1){
	a-=1;
	n-=1;
	c-=1;
	count++;
      }
      else break;
    }
    while(1){
      if(a>=1&&c>=2){
	a-=1;
	c-=2;
	count++;
      }
      else break;
    }
    while(1){
      if(c>=3){
	c-=3;
	count++;
      }
      else break;
    }
    cout<<count<<endl;
  }
    
  return 0;
}



Measured memory_bytes: 3084
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c = [a+b,a-b,a*b];
    let ans = c.iter().max().unwrap();
    println!("{}", ans);
}


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

int main(){
    int n,m,l;
    long long A[100][100],B[100][100],C[100][100];
    
    cin >> n >> m >> l;
    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++) cin >> A[i][j];
    for (int i=0; i<m; i++)
        for(int j=0; j<l; j++) cin >> B[i][j];
        
    for (int i=0; i<n; i++){
        for (int j=0; j<l; j++){
            C[i][j]=0;
            for (int k=0; k<m; k++){
                C[i][j] += A[i][k]*B[k][j];
            }
        }
    }
    
    for (int i=0; i<n; i++){
        for (int j=0; j<l; j++){
            if (j) cout << " ";
            cout << C[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3340
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int r, g, b;

int main()
{
    cin >> r >> g >> b;
    if((r*100+g*10+b)%4==0){
		cout << "YES\n";
	}
	else{
		cout << "NO\n";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    vector<double> t(n), v(n), s(n);
    REP(i,0,n) cin >> t[i];
    REP(i,0,n) cin >> v[i];
    /*
    s[0] = min({v[0], t[0], v[1]});
    REP(i,1,n-1) {
        s[i] = min({s[i-1]+t[i],v[i],v[i+1]});
        if (s[i] + t[i] < s[i-1]) {
            RREP(j,0,i-1) {
                s[j] = min(s[j], s[j+1] + t[j+1]);
            }
        }
    }
    */
    int ti = 0;
    VI ru(n);
    ru[0] = t[0];
    REP(i,1,n) ru[i] = ru[i-1] + t[i];
    REP(i,0,n) {
        ti += t[i];
        s[i] = ti;
        REP(j,0,n) {
            if (j == 0) {
                if (ti <= t[0]) s[i] = min(s[i], v[0]);
                else s[i] = min(s[i], v[0] + ti - t[0]);
            } else {
                if (ti <= ru[j-1]) s[i] = min(s[i], v[j] + ru[j-1] - ti);
                else if (ti <= ru[j]) s[i] = min(s[i], v[j]);
                else s[i] = min(s[i], v[j] + ti - ru[j]);
            }
        }
        s[i] = min(s[i], 0.0 + ru[n-1] - ti);
    }
    // REP(i,0,n) cerr << s[i] << endl;
    double ans = 0.0;
    double y = min(0.5 * (t[0] + s[0]), 1.0 * v[0]);
    ans += 1.0 * t[0] * y - 0.5 * (y * y + (y - s[0]) * (y - s[0]));
    //cerr << 1.0 * t[0] * y - 0.5 * (y * y + (y - s[0]) * (y - s[0])) << endl;
    REP(i,1,n) {
        y = min(0.5 * (t[i] + s[i] + s[i-1]), 1.0 * v[i]);
        ans += 1.0 * t[i] * y - 0.5 * ((y - s[i-1]) * (y - s[i-1]) + (y - s[i]) * (y - s[i]));
        //cerr << 1.0 * t[i] * y - 0.5 * (y * y + (y - s[i]) * (y - s[i])) << endl;
    }
    printf("%.12lf\n", ans);
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int a[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int l=1,r=1,s1=a[1],s2=a[1];
	long long ans=0;
	while(l<=n)
	{
		while(s1==s2&&r<=n)
		{
			r++;
			s1^=a[r];
			s2+=a[r];
		} 
		ans+=r-l;
		s1^=a[l];
		s2-=a[l];
		l++;
	}
	printf("%lld\n",ans);
	return 0;
}


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

#define N 300005
#define mod 998244353
#define ll long long

int add(int x, int y) {
	int ret = (x + y);
	if (ret < 0) {
		return ret + mod;
	}
	else if (ret >= mod) {
		return ret -= mod;
	}
	return ret;
}
int mul(int x, int y) {
	return (ll)x*y%mod;
}
void solve() {
	int n;
	char s[N];
	scanf("%d", &n);
	scanf(" %s", s);
	int sz = n * 3;
	int num[3] = { 0,0,0 }, mid = 0;
	int ret = 1;
	for (int i = 0; i < sz; ++i) {
		int id;
		switch (s[i])
		{
		case 'R':
			id = 0;
			break;
		case 'B':
			id = 1;
			break;
		case 'G':
			id = 2;
			break;
		default:
			break;
		}
		//지금 begin을 결정해야되는데 조건이 뭐지?
		//완성본은 사실 더 이상 뭐 할게 없긴하다.
		//완성본은 mid 를 곱해주고 mid를 감소시켜주면 된다.
		//완성본인 경우는 어떻게 파악하지? num으로 파악하면 될듯한데...
		//완성본이 아닌 경우에는 사실 begin또는 mid가 된다. 
		//완성본이 아니라면 색은 많아봐야 2개의 색이 차있을 거다.
		int &numA = num[(id + 1) % 3], &numB = num[(id + 2) % 3];
		int &my = num[id];
		if (numA > 0 && numB > 0) {
			ret = mul(ret, mid);
			--numA, --numB;
			--mid;
		}
		else {
			int *g;
			if (numA == 0) {
				g = &num[(id + 2) % 3];
			}
			else {
				g = &num[(id + 1) % 3];
			}
			if (my >= *g) {
				++my;
			}
			else {
				ret = mul(ret, *g - my);
				++mid;
				++my;
			}
		}
	}
	for (int i = n; i; --i) {
		ret = mul(ret, i);
	}
	printf("%d\n", ret);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	solve();
	return 0;
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
a.sort()
f=1
for i in range(n):
  if i%2==n%2 and i+1!=a[i] or i%2==(n+1)%2 and i!=a[i]:
    f=0
    break
if f==0:print(0)
else:print((2**(n//2))%(10**9+7))

Measured memory_bytes: 14004
//Takahashi's Information

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<int>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    bool flag = true;
    int a,b,c;
    cin>>a>>b>>c;
    b=b-a;c=c-a;
    rep(i,0,2){
        int aa,bb,cc;
        cin>>aa>>bb>>cc;
        if(aa+b!=bb)flag=false;
        if(aa+c!=cc)flag=false;
    }
    cout << (flag?"Yes":"No")<<nnn;
    return 0;
}

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

const int maxn = 5e5, mod = 998244353;
int n, m, fact[maxn + 3], finv[maxn + 3];

int qpow(int a, int b) {
	int c = 1;
	for (; b; b >>= 1, a = 1ll * a * a % mod) {
		if (b & 1) c = 1ll * a * c % mod;
	}
	return c;
}

void prework(int n) {
	fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = 1ll * fact[i - 1] * i % mod;
	}
	finv[n] = qpow(fact[n], mod - 2);
	for (int i = n; i; i--) {
		finv[i - 1] = 1ll * finv[i] * i % mod;
	}
}

int C(int n, int m) {
	return 1ll * fact[n] * finv[m] % mod * finv[n - m] % mod;
}

int main() {
	prework(maxn);
	scanf("%d %d", &n, &m);
	int ans = 0;
	for (int i = 0; i <= min(n, m); i++) {
		ans = (ans + 1ll * (i & 1 ? mod - 1 : 1) * qpow(m + 1, n - i) % mod * qpow(n + 1, m - i) % mod * C(n, i) % mod * C(m, i) % mod * fact[i]) % mod;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4096
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    s = input()
    t = input()
    ls = len(s)
    lt = len(t)
    txt=""
    dp = [[0] * (lt + 1) for _ in range(ls + 1)]
    for i in range(1, ls + 1):
        for j in range(1, lt + 1):
            if s[i - 1] == t[j - 1]:
                dp[i][j] = dp[i - 1][j - 1] + 1
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])

    while lt != 0 and ls != 0:
        if dp[ls][lt] == dp[ls - 1][lt]:
            ls -= 1
        elif dp[ls][lt] == dp[ls][lt - 1]:
            lt -= 1
        else:
            ls -= 1
            lt -= 1
            txt = txt +s[ls]

    print(txt[::-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 144544
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i > 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t int64;

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

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }


class A {
	int n, i;
public:
	A()
	{
		cin >> n >> i;
	}
	void solve()
	{
		cout << n - i + 1 << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int N;
    ll T;
    vector<ll> A;
    void input() {
        cin >> N >> T;
        A.resize(N);
        REP(i, N) { cin >> A[i]; }
    }
    void output() {
        vector<ll> cmin(N + 1);
        cmin[0] = 1e9;
        ll mx = -1;
        int res = 0;
        REP(i, N) {
            cmin[i + 1] = min(cmin[i], A[i]);
            ll x = A[i] - cmin[i + 1];
            if (mx == x) {
                ++res;
            } else if (mx < x) {
                mx = x;
                res = 1;
            }
        }
        cout << res << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 4752
card = [list(map(int, input().split())) for i in range(3)]
N = int(input())

for i in range(N):
    b = int(input())
    for row in card:
        if b in row:
            row[row.index(b)] = 0

def f():
    for row in card:
        if sum(row) == 0:
            return True
    
    for x in range(3):
        if sum([card[0][x], card[1][x], card[2][x]]) == 0:
            return True
    
    if sum([card[0][0], card[1][1], card[2][2]]) == 0:
        return True
    
    if sum([card[2][0], card[1][1], card[0][2]]) == 0:
        return True

    return False

if f():
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    string n;
    cin >> n;
    if(n[0]==n[2])cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
A =[]
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
B = [0]*N
for i in range(N):
    B[i] = int(input())

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j] = 0

for i in range(3):
    if (A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0):
        print('Yes')
        exit()
    elif (A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0):
        print('Yes')
        exit()

if (A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0):
    print('Yes')
    exit()
if (A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0):
    print('Yes')
    exit()

print('No')

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

const ll INF = 2e18;
const int MAX_V = 100001;
ll dp[MAX_V];

int main() {
  int n, W;
  cin >> n >> W;
  vector<int> v(n), w(n);
  rep(i, n) cin >> w[i] >> v[i];

  rep(j, MAX_V + 1) dp[j] = INF;
  dp[0] = 0;
  rep(i, n + 1) for (int j = MAX_V; j >= 0; j--) {
    if (j - v[i] >= 0) dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
  }
  ll ans = 0;
  rep(j, MAX_V) if (dp[j] <= W) ans = max(ans, (ll)j);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
<?php
$a = (int)trim(fgets(STDIN));
$b = (int)trim(fgets(STDIN));
$c = (int)trim(fgets(STDIN));
$d = (int)trim(fgets(STDIN));

$total = 0;
if ($a <= $b) {
    $total += $a;
} else {
    $total += $b;
}

if ($c <= $d) {
    $total += $c;
} else {
    $total += $d;
}

echo $total . PHP_EOL;

Measured memory_bytes: 4856
def main():
	# s = list(map(str,input().split()))
	# a = list(map(int,input().split()))
	u = str(input())
	#List=list(map(int,input().split()))
	
	print("x"*int(len(u)))
 
	
 
if __name__ == '__main__':
	main()


Measured memory_bytes: 38256
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$K) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
$h = array_map("intval", explode(" ", trim(fgets(STDIN))));
 
$dp[0]=0;
for($i=1;$i<$N;$i++) {
  $dp[$i]=10**18;
  $limit = min($i,$K);
  for($j=1;$j<=$limit;$j++) {
    $dp[$i]=min($dp[$i],$dp[$i-$j]+abs($h[$i]-$h[$i-$j]));
  }
}
printf("%d\n",$dp[$N-1]);

Measured memory_bytes: 18932
import java.util.HashMap;
import java.util.Map;

//What Color Is The Universe?
public class Main{

	public static class Scanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-') return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}
		long nextLong() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-') return -nextLong();
				long res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
		String nextLine(){
			try{
				StringBuilder res =new StringBuilder("");
				int c = System.in.read();
				while (c=='\r' || c=='\n')
					c = System.in.read();
				do {
					res.append((char) c);
					c = System.in.read();
				} while (c!='\r' && c!='\n');
				return res.toString();
			}catch (Exception e) {
				return null;
			}
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner();
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			String a = "NO COLOR";
			boolean f = false;
			int[] c = new int[n];
			int id = 0;
			Map<Integer, Integer> m = new HashMap<Integer, Integer>();
			for(int i=0;i<n;i++){
				int x = sc.nextInt();
				if(!f){
					if(!m.containsKey(x)){
						m.put(x, id++);
					}
					int ref = m.get(x);
					c[ref]++;
					if(!f && c[ref]>n>>1){
						f = true;
						a = x+"";
					}
				}
			}
			System.out.println(a);
		}
	}
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

const int MAX_N = 100010;
int n, q;
int par[MAX_N];
char t[MAX_N];
int v[MAX_N];
int cnt[MAX_N];

int lma(int x) {
    if (cnt[x]) return x;
    return par[x] = lma(par[x]);
}

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

    while (cin >> n >> q, n) {
        fill(par, par + n, -1);
        rep2(i, 1, n) {
            int p;
            cin >> p;
            p--;
            par[i] = p;
        }

        fill(cnt, cnt + n, 0);
        cnt[0] = 1;
        rep(i, q) {
            cin >> t[i] >> v[i];
            v[i]--;
            if (t[i] == 'M') {
                cnt[v[i]]++;
            }
        }

        int ans = 0;
        rrep(i, q) {
            if (t[i] == 'M') {
                cnt[v[i]]--;
            }
            else {
                ans += lma(v[i]) + 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5704
def resolve():
    N, M, K = map(int, input().split())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]

    # a,bをA,Bの累積和のリストとして作成
    a, b = [0], [0]
    for i in range(N):
        a.append(a[i] + A[i])
    for i in range(M):
        b.append(b[i] + B[i])

    # i+jの最大値をiをインクリメントとしながら全探索
    ans, j = 0, M
    for i in range(N + 1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:  # i,Kの値が定まればjは一位に定まる
            j -= 1
        ans = max(ans, i + j)
    print(ans)



if __name__ == "__main__":
    resolve()

Measured memory_bytes: 47424
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Long a = sc.nextLong();
        Long b = sc.nextLong();
		Long c = sc.nextLong();
        if(a<c){b=Math.max(0,a+b-c);}
        a=Math.max(0,a-c);       
		System.out.println(a + " " + b);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    string s,t,u;cin >> s >> t >> u;
    cout << s[0] << t[0] << u[0] << endl;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=5e5+7;
const ll mod=1e9+7;
int N;
vector<int> A;
ll power(ll x,ll n)
{
	ll ans=1;
	while(n>0)
	{
		if(n&1) (ans*=x)%=mod;
		(x*=x)%=mod;
		n>>=1;
	}
	return ans;
 } 
int main()
{
	cin>>N;A.resize(N);
	for(int i=0;i<N;i++)
	{
		//int tmp
		scanf("%d",&A[i]);
	}
	vector<int> rui(N+1);
	for(int i=0;i<N;i++) rui[i+1]=(rui[i] xor A[i]);
	vector<int> zero_cnt(N+1);
	for(int i=0;i<N;i++) zero_cnt[i+1]=zero_cnt[i]+(rui[i+1]==0);
	map< int,vector<int> > shown;
	for(int i=0;i<N;i++)
		if(rui[i+1]) shown[rui[i+1]].push_back(i+1);
	if(rui.back()==0)
	{
		ll ret=0;
		for(auto & pa:shown)//枚举每一个出现的异或前缀值 
		{
			vector<int> pos=pa.second;
			ll z=1,o=0;
			int now=0;
			for(auto nxt:pos)
			{
				ll bet_zero=zero_cnt[nxt]-zero_cnt[now];//计算每一个异或前缀值之间的0 
				ll z_nxt=(o*bet_zero+z)%mod;//这中间的每一个0，对答案的贡献是上一个x的方案数，即o
				ll o_nxt=(z_nxt+o)%mod;//这个新的x的方案数，等于上一个0的方案数z_nxt，加上若不选这些0，那么这个x就是之前那个x，所以加上之前的o
				z=z_nxt;o=o_nxt;
				now=nxt; 
			}//这个z是以0结尾，但是前面必须要有x的，故只用z来计算结果，是错误的。我们可以考虑在最后再加一个x，这个x是必取的。然后计算这个x的方案数即可 
			(ret+=o)%=mod;//对于每一个x， 
		}
		(ret+=power(2,zero_cnt[N]-1))%=mod;
		cout<<ret<<endl;
		return 0; 
	}
	else
	{
		int tgt=rui.back();ll z=1,o=0;
		for(int i=1;i<N;i++)
		{
			if(rui[i]==0) (z+=o)%=mod;
			else if(rui[i]==tgt) (o+=z)%=mod;
		}
		cout<<z<<endl;
		return 0;
	}
	
 } 

Measured memory_bytes: 37504
for i in range(100):
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    #print(h*w)
    #print(h)
    #print(w)
    else:
        for j in range(1,h+1):
            for k in range(1,w):
                print('#',end='')
            print('#')
    print('')




Measured memory_bytes: 7036
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int X;
int Y;
int A[80][80];
char vis[80][80][6400];
int main(){
  int i;
  int v;
  int res;
  rd(X);
  rd(Y);
  for(i=(0);i<(X);i++){
    int j;
    for(j=(0);j<(Y);j++){
      A[i][j] += rd_int();
    }
  }
  for(i=(0);i<(X);i++){
    int j;
    for(j=(0);j<(Y);j++){
      A[i][j] -= rd_int();
    }
  }
  for(i=(0);i<(X);i++){
    int j;
    for(j=(0);j<(Y);j++){
      A[i][j] = abs(A[i][j]);
    }
  }
  vis[0][0][A[0][0]] = 1;
  for(i=(0);i<(X);i++){
    int j;
    for(j=(0);j<(Y);j++){
      int k;
      for(k=(0);k<(6400);k++){
        if(vis[i][j][k]){
          if(i+1 < X){
            v = abs(k-A[i+1][j]);
            if(v < 6400){
              vis[i+1][j][v] = 1;
            }
            v = k+A[i+1][j];
            if(v < 6400){
              vis[i+1][j][v] = 1;
            }
          }
          if(j+1 < Y){
            v = abs(k-A[i][j+1]);
            if(v < 6400){
              vis[i][j+1][v] = 1;
            }
            v = k+A[i][j+1];
            if(v < 6400){
              vis[i][j+1][v] = 1;
            }
          }
        }
      }
    }
  }
  for(res=(0);res<(6400);res++){
    if(vis[X-1][Y-1][res]){
      break;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191208-1 [beta]

// --- original code ---
// int X, Y, A[80][80];
// char vis[80][80][6400];
// 
// {
//   int v, res;
//   rd(X,Y);
//   rep(i,X) rep(j,Y) A[i][j] += rd_int();
//   rep(i,X) rep(j,Y) A[i][j] -= rd_int();
//   rep(i,X) rep(j,Y) A[i][j] = abs(A[i][j]);
// 
//   vis[0][0][A[0][0]] = 1;
//   rep(i,X) rep(j,Y) rep(k,6400) if(vis[i][j][k]){
//     if(i+1 < X){
//       v = abs(k-A[i+1][j]);
//       if(v < 6400) vis[i+1][j][v] = 1;
//       v = k+A[i+1][j];
//       if(v < 6400) vis[i+1][j][v] = 1;
//     }
//     if(j+1 < Y){
//       v = abs(k-A[i][j+1]);
//       if(v < 6400) vis[i][j+1][v] = 1;
//       v = k+A[i][j+1];
//       if(v < 6400) vis[i][j+1][v] = 1;
//     }
//   }
// 
//   rep(res,6400) if(vis[X-1][Y-1][res]) break;
//   wt(res);
// }


Measured memory_bytes: 40192
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s;
    cin>>s;
    int n = s.length();
    
    vi x(n+1,0);
    for(int i=0;i<n;i++){
        if(s[i]=='<'){
            x[i+1] = max(x[i+1], x[i]+1);
        }
    }

    for(int i=n-1;i>=0;i--){
        if(s[i]=='>'){
            x[i] = max(x[i+1]+1, x[i]);
        }
    }

    i64 sum=0;
    for(int i=0;i<=n;i++)
        sum += x[i];
    cout<<sum<<endl;
    /*
    string r="";
    for(int i=0;i<n;i++){
        r += 'a';
        r += s[i];
    }
    r += 'a';
    //cout<<r<<endl;
    //cout<<r.length()<<endl;

    //vpi x(n+1);
    
    i64 sum = 0;
    for(int i=0;i<r.length();i+=2){
        int cnt_left=0, cnt_right=0;
        if(r[i-1]=='<'){
            cnt_left = 1;
            for(int j=i-1;j>=0;j-=2){
                if(r[j]==r[j-2])
                    cnt_left++;
                else
                    break;
            }
        }
        if(r[i+1]=='>'){
            cnt_right=1;
            for(int j=i+1;j<r.length();j+=2){
                if(r[j]==r[j+2])
                    cnt_right++;
                else
                    break;
            }
        }
        //cout<<"For position: "<<i<<"--> Left: "<<cnt_left<<", Right: "<<cnt_right<<", Value: "<<max(cnt_left, cnt_right)<<endl;
        sum += max(cnt_left, cnt_right);
    }
    cout<<sum<<endl;
    */
    return 0;
}



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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

struct Elm {
  int x, y, t;
};

bool operator<(const Elm &e1, const Elm &e2) {
  return e1.t < e2.t;
}

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

  int n; cin >> n;
  vector<Elm> v;
  v.push_back({0, 0, 0});
  for(int i=0;i<n;++i) {
    int x, y, t; cin >> t >> x >> y;
    v.push_back({x, y, t});
  }

  sort(v.begin(), v.end());

  bool ok = true;
  for(int i=0;i<n;++i) {
    ok &= (v[i+1].t - v[i].t >= abs(v[i+1].x - v[i].x) + abs(v[i+1].y - v[i].y)) && ((v[i+1].t-v[i].t) - abs(v[i+1].x - v[i].x) - abs(v[i+1].y - v[i].y)) % 2 == 0;
  }
  cout << (ok ? "Yes" : "No") << endl;

}


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

typedef long long int ll;




int main(){

    ll N;
    ll K;

    cin >> N >> K;
    //int prev = N;

    /*while(abs(N-K) < N){
        //prev = abs(N-K);
        N = abs(N-K);
    }*/

    ll t = N % K;
    ll s = K - t;

    cout << min(t, s) << endl;

    //cout << N << endl;
}

Measured memory_bytes: 256
var A,B,C,D,count,Pa,Pb,dCD:int64;
function gcd(C,D:int64):int64;
begin
if D=0 then gcd:=C else gcd:=gcd(D,C mod D)
end;
begin
read(A,B,C,D);
dCD:=C*D div gcd(C,D);
Pa:=(A-1) div C + (A-1) div D - (A-1) div dCD;
Pb:=B div C +B div D - B div dCD;
write(B-A-Pb+Pa+1)
end.

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
using namespace std;
const double eps=1.0e-12;

int main() {
  double xa, ya, xb, yb, xc, yc, xd, yd, dp;
  while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) == 8) {
    dp = (xb-xa)*(xd-xc)+(yb-ya)*(yd-yc);
    if (abs(dp) < eps) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

int main(){
  int card[2];
  cin >> card[0] >> card[1];
  int ans = 0;

  if (card[0] > card[1]) {
    ans = 0;
  }else{
    if (card[0] < card[1]) {
      ans = 1;
    }
  }

  if (card[0] == 1) {
    ans = 0;
  }
  if (card[1] == 1) {
    ans = 1;
  }
  if (card[0] == card[1]) {
    ans =2;
  }

  switch (ans) {
    case 0:
             cout << "Alice" << endl;
               break;
    case 1:
             cout << "Bob" << endl;
               break;
    case 2:
             cout << "Draw" << endl;
               break;
  }
  return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]
for i in range(h):
    if set(a[h-i-1]) == {'.'}:
        del(a[h-i-1])
for i in range(w):
    if set([j[w-i-1] for j in a]) == {"."}:
        for j in a:
            del(j[w-i-1])
for i in a:
    print(''.join(i))

Measured memory_bytes: 3064
s = input()
t = input()
ans = []
for i in range(len(s)-len(t)+1):
    flag = True
    for j in range(len(t)):
        if not (s[i+j] == t[j] or s[i+j] == '?'):
            flag = False
            break
    if flag:
        ans.append(i)
if ans:
    ans2 = []
    for i in ans:
        ans2.append(s[:i].replace('?','a') + t + s[i+len(t):].replace('?','a'))
    ans2.sort()
    print(ans2[0])
else:
    print('UNRESTORABLE')

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

int main(){
  int M,N;
  int X,C,A;
  vector<vector<int>> study(N);
  cin >> N>>M>>X;
  for(int i=0;i<N;i++){
    cin>>C;
    study.at(i).push_back(C);
    for(int j=0;j<M;j++){
      cin>>A;
      study.at(i).push_back(A);
    }
  }
  
  int n=N;
  int ans=12*100000+1,cost=0;
    for (int bit = 1; bit < (1<<n); ++bit)
    {
      cost=0;
        /* bit で表される集合の処理を書く */


        /* きちんとできていることを確認してみる */
        // bit の表す集合を求める
        vector<int> S;
        vector<int> understand(M);
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
            }
        }
        for(int j=0;j<S.size();j++){
          for(int i=0;i<M;i++){
            understand.at(i)+=study.at(S.at(j)).at(i+1);
          }
          cost+=study.at(S.at(j)).at(0);
        }
        sort(understand.begin(),understand.end());
        if(understand.at(0)>=X){
          if(cost<ans){
            ans=cost;
          }
        }
        // bit の表す集合の出力
        
    }
  if(ans==12*100000+1)
    ans=-1;

  cout<<ans<<endl;
  


  
}


Measured memory_bytes: 3872
#include <stdio.h>
#include <math.h>

int main()
{
	long long  n,k;
	scanf("%lld %lld",&n,&k);
	n=n%k;
	while(abs(n-k)<n)
	{
		n=abs(n-k);
	}
	printf("%lld\n",n);
	
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int n;
    scanf("%d", &n);
    char s[n];
    rep(i, n) cin >> s[i];
    rep(i, n) if(s[i] == 'Y') {
        cout << "Four" << endl;
        return 0;
    } 
    cout << "Three" << endl;
    return 0;
}

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

using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  long long sum = 0;
  vector<long long> a(100001, 0);
  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    a[b]++;
    sum += b;
  }

  int q;
  cin >> q;
  vector<long long> ans;

  for (int i = 0; i < q; i++) {
    int b, c;
    cin >> b >> c;
    sum -= a[b] * b;
    sum += a[b] * c;
    a[c] += a[b];
    a[b] = 0;
    ans.push_back(sum);
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 5012
using System;
class Program
{
    static void Main(string[] args)
    {
        string S = Console.ReadLine();
        string[] s = new string[4];
        int i = 0;
        foreach(char c in S)
        {
            s[i] = c.ToString();
            i++;
        }
        if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
        {
            Console.WriteLine("Bad");
        }
        else
        {
            Console.WriteLine("Good");
        }
    }
}

Measured memory_bytes: 13140
using System;
using System.Collections.Generic;

class Program {
  static void Main (string[] args) {
    string[] str = Console.ReadLine().Split(' ');
    int r = int.Parse(str[0]);
    int D = int.Parse(str[1]);
    int x2000 = int.Parse(str[2]);
    int past = x2000;
    int now = -1;
    for (int cnt = 1; cnt <= 10; cnt++) {
      now = (r * past) - D;
      Console.WriteLine(now);
      past = now;
    }
  }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int N = 1e4+5;
const int M = 1e9+7;
#define pi acos(-1)
#define INF 1e8
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
/*
首先,注意这里的取模是对于方案数的取模,并不是对这些值取模.
那么就不会具有循环性。
其次,注意到10^100是非常大的数.
所以如果取k个数,k+1个数,k+2个数..
那么k+1肯定不会和k有重叠的答案,k+2不会和k有重叠的答案...以此类推.
我们可以明白对于选[k,n]个数,在任何一个取个个数限制内,能得到的值都不会再其他取的个数内重叠.
然后因为这个数是+1递增的,那么我们只需要计算出最大值和最小值,那么其他数肯定都在这个区间内,且区间内的所有数都可取得.
我们不需要去算出最大值和最小值,只要算出这个区间的大小即可.
例：
6   3
0 1 2  - 3
...
1 2 3  
3 4 5
...
4 5 6  - 15
(n-(k-1))*k+1 = 12 +1 = 13

7   4
0 1 2 3  - 6
...
1 2 3 4
2 3 4 5
3 4 5 6
...
4 5 6 7  - 22
我们可以发现,最小值排列的每个数都和最大值排列的对应的数差相同的值.
那么很明显最小值的最后一个位置是(k-1) [0,k-1].
最大值的最后一个位置是n.
那么这个差距就是(n-k+1),然后乘上个数 (n-k+1)*k;
注意我们这样就想相当于求[3,15]内有多少个数
15-3 = 12,很明显少了一个,有一个边界没统计.所以最后的结果要加上1
那么区间值就是(n-k+1)*k+1;
*/
LL cal(LL k,LL n)
{
	return ((n-k+1)*k+1)%M;
}
int main()
{
	LL ans = 0,n,k;sldd(n,k);
	for(LL i=k;i<=n+1;++i)
	{
		ans = (ans+cal(i,n))%M;
	}
	plr(ans);
	//system("pause");
	return 0;
}

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

int main() {
  string X, Y;
  cin >> X >> Y;

  if (X > Y)
    cout << '>' << endl;
  else if (X < Y)
    cout << '<' << endl;
  else
    cout << '=' << endl;
  return 0;
}

Measured memory_bytes: 3584
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a,b,c,d;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		
		int cnt = 0;
		
		for(int i=0 ; i<=a ; i++) {
			for(int j=0 ; j<=b ; j++) {
				for(int k=0 ; k<=c ; k++) {
					if(500*i+100*j+50*k == d) {
						cnt++;
					}
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 22100
/**
 *    author:  tourist
 *    created: 14.07.2019 15:46:31       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ++cnt[a[i]];
  }
  if (cnt[0] == n) {
    cout << "Yes" << '\n';
    return 0;
  }
  if (n % 3 != 0) {
    cout << "No" << '\n';
    return 0;
  }
  vector<int> all;
  for (auto& p : cnt) {
    for (int i = 0; i < p.second / (n / 3); i++) {
      all.push_back(p.first);
    }
  }
  if (all.size() == 3 && (all[0] ^ all[1] ^ all[2]) == 0) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 4224
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }

        int sum = 0;
        int wait = 10;
        for (int i = 0; i < a.length; i++) {
            int mod = a[i] % 10;
            if (mod < wait && mod != 0) {
                wait = mod;
            }

            if (mod != 0) {
                sum += (a[i] / 10 + 1) * 10;
            } else {
                sum += a[i];
            }
        }

        if (wait != 10) {
            sum -= 10 - wait;
        }

        out.println(sum);
    }
}

Measured memory_bytes: 22868
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	string s;
	cin >> s;

	if (s != "AAA" && s != "BBB") cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}



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

using namespace std;

int main()
{
        ios::sync_with_stdio(false);

        int a, b;

        cin >> a >> b;

        int sum, sub, m;

        sum = a+b;
        sub = a-b;
        m = a*b;

        if(sum >= sub && sum >= m)
                cout << sum << endl;
        else if(sub >= sum && sub >= m)
                cout << sub << endl;
        else
                cout << m << endl;

        return 0;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        Console.WriteLine("{0} {1} {2}", c, a, b);
    }
}


Measured memory_bytes: 13140
import java.util.*;
import java.math.*;
import java.io.*;


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

        int ans = n / (2 * d + 1) + (n%(2 * d + 1)!=0?1:0);
        System.out.println(ans);
    } 
}

Measured memory_bytes: 21844
N, A, B = map(int, input().split())

if A == 1:
  print(B//2)
  exit()

if B == N:
  print((N-A+1)//2)
  exit()

distance = B - A
if distance % 2 == 0:
  print(distance//2)
else:
  print(min(N-A, B-1, N-B+1+(B-A-1)//2, A + (B-A-1)//2))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll ans=0;
//#define ROW 20
//#define COL 20
int ROW,COL,N1,M1;
struct Point
{
    int x;
    int y;
};
struct queueNode
{
    Point pt;  // The cordinates of a cell
    int dist;  // cell's distance of from the source
};
bool isValid(int row, int col)
{
    // return true if row number and column number
    // is in range
    return (row >= 0) && (row < ROW) &&
           (col >= 0) && (col < COL);
}
int rowNum[] = {-1, 0, 0, 1};
int colNum[] = {0, -1, 1, 0};
ll BFS(int mat[][20], Point src, Point dest)
{
    if (!mat[src.x][src.y] || !mat[dest.x][dest.y])
        return -1;

    bool visited[ROW][COL];
    memset(visited, false, sizeof visited);

    // Mark the source cell as visited
    visited[src.x][src.y] = true;

    // Create a queue for BFS
    queue<queueNode> q;

    // Distance of source cell is 0
    queueNode s = {src, 0};
    q.push(s);  // Enqueue source cell

    while (!q.empty())
    {
        queueNode curr = q.front();
        Point pt = curr.pt;
        if (pt.x == dest.x && pt.y == dest.y)
            return curr.dist;
        q.pop();

        for (int i = 0; i < 4; i++)
        {
            int row = pt.x + rowNum[i];
            int col = pt.y + colNum[i];
            if (isValid(row, col) && mat[row][col] &&
               !visited[row][col])
            {
                visited[row][col] = true;
                queueNode Adjcell = { {row, col},
                                      curr.dist + 1 };
                q.push(Adjcell);
            }
        }
    }
    return -1;
}
int main()
{
	//int N,M,i;
	int i,j;
	int mat[20][20];
	for(i=0;i<20;i++)
    {
        for(j=0;j<20;j++)
        {
            mat[i][j]=0;
        }
    }
  //  int N1,M1;

	cin>>N1>>M1;
	 ROW=N1;
    COL=M1;
	char ch;
	for(i=0;i<N1;i++)
    {
        for(j=0;j<M1;j++)
        {
            cin>>ch;
            if(ch=='.')
                mat[i][j]=1;
        }
    }
    int k,k1;
    ll ans1=0;
    int st1,st2,en1,en2;
    for(i=0;i<N1;i++)
    {
        st1=i;
        for(j=0;j<M1;j++)
        {
            st2=j;
            Point pt={st1,st2};
            for(k=0;k<N1;k++)
            {
                en1=k;
                for(k1=0;k1<M1;k1++)
                {
                    en2=k1;
                    Point pt1={en1,en2};
                    //cout<<ans<<e;
                ans=BFS(mat, pt,pt1);
                if(ans!=-1)
                    ans1=max(ans1,ans);
                }
            }
        }
    }
    cout<<ans1<<e;
	return 0;
}


Measured memory_bytes: 256