akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] ={ 1,0,-1,0 };
int dy[4] ={ 0,1,0,-1 };

inline vector<int> Z_algorithm(string S) {
	vector<int> Z(S.size());
	Z[0] = S.size();
	int i = 1, j = 0;
	while(i < S.size()){
		while(i + j < S.size() && S[j] == S[i + j]) j++;
		Z[i] = j;

		if(j == 0){
			i++;
			continue;
		}
		int k = 1;
		while(k < j && k + Z[k] < j){
			Z[i + k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}
	return Z;
}

string s, t, tmp1, tmp2;

signed main() {
	cin >> s >> t;
	tmp1 = s;
	while(tmp1.size() < t.size()) tmp1 += s;
	tmp1 += s;

	tmp2 = t + tmp1 + tmp1;
	vector<int> Z = Z_algorithm(tmp2);
	reverse(Z.begin(), Z.end());
	rep(i, t.size()) Z.pop_back();
	reverse(Z.begin(), Z.end());
	rep(i, Z.size()) Z[i] = min(Z[i], (int)t.size());

	//rep(i, Z.size()) cout << Z[i] << " ";
	//cout << endl;

	int ans = 0;
	rep(i, t.size()){
		vector<bool> v;
		int j = 0;
		while(i+j*t.size() < Z.size()){
			v.pb(Z[i+j*t.size()] == t.size());
			j++;
		}
		int c = 0;
		rep(j, v.size()){
			if(v[j]) c++;
			else c = 0;
			ans = max(ans, c);
		}
	}
	cout << ((ans <= tmp1.size()/t.size())? ans : -1) << endl;
}


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

bool comp(int a, int b){
	return a>b;
}

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

	int n;
	cin >> n;
	int v[n]; int c[n];
	for(int i=0; i<n; i++) cin >> v[i];
	for(int i=0; i<n; i++) cin >> c[i];

	int ans[n];
	for(int i=0; i<n; i++) ans[i] = v[i]-c[i];
	sort(ans,ans+n,comp);
	int res = 0; int i=0;
	while(ans[i]>0 and i<n){
		res += ans[i];
		i++;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3608
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll score=0;
  string s;cin>>s;
  ll n=s.size();
  rep(i,n){
    if(i%2==0){
      if(s[i]=='p')score--;
    }
    else {
      if(s[i]=='g')score++;
    }
  }
  cout<<score<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];
    ll S = 0;
    REP(i, N) S += a[i];

    ll x = 0;
    ll res = (1ll<<60);
    REP(i, N-1){
    	x += a[i];
    	chmin(res, abs(2*x-S));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

string s;
int ans = 0;

int main() {
	cin >> s;

	for (int i = 0; i < s.size(); ++i)
	{
		if (i%2)
		{
			if (s.at(i) == 'g') ans ++;
		} else {		
			if (s.at(i) == 'p') ans --;
		}
	}

	cout << ans << endl;
}

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

string regist()
{
  int count;
  count = 0;
  string id, replace;
  getline(cin, id);
  getline(cin, replace);

//카운트 개념 생각났다
  for (int i = 0; i < id.length(); i++)
  {
    if(id[i] == replace[i])
    count++;
  }
  if(count == id.length())
  {
    return "Yes";
  }
  else
  {
    return "No";
  }
}

int main()
{
  cout << regist() << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

int n, u, v;
vector<int> g[100100];
vector<int> deptht, deptha;

int ans;

void dfs(int v, int p, int d, vector<int> &depth) {
    depth[v] = d;
    for(auto&nv : g[v]) {
        if(nv == p) continue;
        dfs(nv, v, d + 1, depth);
    }
}

int cnt;

void dfstk(int v, int p) {
    if(deptht[v] >= deptha[v]) {
        chmax(ans, deptha[v]);
    } else {
        if((int)g[v].size() == 1 && g[v][0] == p) {
            int x = deptht[v], y = deptha[v];
            chmax(ans, y - 1);
        } else {
            for(auto& nv: g[v]) {
                if(nv == p) continue;
                ++cnt;
                dfstk(nv, v);
                --cnt;
            }
        }
    }
}

void solve() {
    ans = 0;
	cin >> n >> u >> v;
    --u; --v;
    rep(i, n - 1) {
        int a, b; cin >> a >> b; --a; --b;
        g[a].pb(b);
        g[b].pb(a);
    }
    deptht.assign(n, -1);
    deptha.assign(n, -1);
    dfs(u, -1, 0, deptht);
    dfs(v, -1, 0, deptha);
    cnt = 0;
    dfstk(u, -1);
    if((int)g[u].size() == 1) {
        chmax(ans, deptha[u] - 1);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}



Measured memory_bytes: 11648
#include<iostream>                                                                            
using namespace std;                                                                          
int main(){                                                                                   
  int h, w;                                                                                   
  cin >> h >> w;                                                                              
  while(h!=0 or w!=0){                                                                        
    for (int i=0; i<h; i++){                                                                  
      for (int j=0; j<w; j++){                                                                
        if ((i+j)%2==0){                                                                      
          cout << "#";                                                                        
        } else {                                                                              
          cout << ".";                                                                        
        }                                                                                     
      }                                                                                       
      cout << endl;                                                                           
    }                                                                                         
    cout << endl;                                                                             
    cin >> h >> w;                                                                            
  }                                                                                           
}                                                                                             
                                                                                              
                           


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main(){
    string s, t;

    cin >> s;
    cin >> t;

    string ret = "Yes";
    for(int i = 0; i < s.length(); i++){
        if(s.at(i) != t.at(i)){
            ret = "No";
            break;
        }
    }

    cout << ret << endl;

    return 0;

}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
	int N, D;
	cin >> N >> D;
	vector<vector<int>> X(N, vector<int>(D));

	rep(i, N) rep(j, D) cin >> X[i][j];

	int ans = 0;
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			int dist = 0; 
			for(int d = 0; d < D; d++){
				dist += (X[i][d] - X[j][d]) * (X[i][d] - X[j][d]);
			}
			for(int k = 1; k*k <= dist; k++){
				if(k*k == dist) ans++;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

char a[15];
int main()
{
	scanf("%s", &a);
	if(a[0] == 'Y' && a[1] == 'A' && a[2] == 'K' && a[3] == 'I') printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 30

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}
#define VERTEX_MAX 100000
#define EDGE_MAX 100000

struct ufind {
    int parent;
    int depth;
};

struct ufind *create_ufind(int vs) {
    struct ufind *ufind = malloc(vs * sizeof(struct ufind));
    int i;
    for(i = 0; i < vs; i++) {
        ufind[i].parent = i;
        ufind[i].depth = 0;
    }
    return ufind;
}

int find_root(struct ufind *ufind, int v) {
    struct ufind *elem = &ufind[v];
    int base = v;
    while(base != elem->parent) {
        base = elem->parent;
        elem = &ufind[base];
    }
    return base;
}

int is_connect(struct ufind *ufind, int v1, int v2) {
    int bv1 = find_root(ufind, v1);
    int bv2 = find_root(ufind, v2);
    return bv1 == bv2;
}

void unify(struct ufind *ufind, int v1, int v2) {
    int bv1 = find_root(ufind, v1);
    int bv2 = find_root(ufind, v2);
    struct ufind *uv1 = &ufind[bv1];
    struct ufind *uv2 = &ufind[bv2];
    if(uv1->depth >= uv2->depth) {
        if(uv1->depth == uv2->depth) uv1->depth++;
        uv2->depth = uv1->depth;
        uv2->parent = uv1->parent;
    } else {
        uv1->depth = uv2->depth;
        uv1->parent = uv2->parent;
    }
    return;
}

enum {
    ENUM_EVEN,
    ENUM_ODD
};

int main(void) {
    int vs, es;
    get_int2(&vs, &es);

    int i;
    struct ufind *ufind = create_ufind(vs*2);
    for(i = 0; i < es; i++) {
        int v1, v2;
        get_int2(&v1, &v2);
        v1--; v2--;
        unify(ufind, v1*2+ENUM_EVEN, v2*2+ENUM_ODD);
        unify(ufind, v1*2+ENUM_ODD, v2*2+ENUM_EVEN);
    }

    int both = 0;
    int even = 0;
    int odd = 0;
    for(i = 0; i < vs; i++) {
        int flag1 = is_connect(ufind, 0, i*2+ENUM_EVEN);
        int flag2 = is_connect(ufind, 0, i*2+ENUM_ODD);
        if(flag1 && flag2) {
            both++;
        } else if(flag1 && !flag2) {
            even++;
        } else {
            odd++;
        }
    }
#ifdef DEBUG
    printf("result: %d, %d %d\n", both, even, odd);
#endif
    uint64_t ans = (uint64_t)even*odd + (uint64_t)both*(both-1)/2;
    ans = ans - (uint64_t)es;
    printf("%llu\n", ans);
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005;
const int MOD=1e9+7; 
ll x[N];
int n,m;
int main()
{
	int n;
	scanf("%d",&n);

	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x[i]);
	
	}
	ll sum=0;
	ll ans1=0;
	for(int i=1;i<=n;i++) //奇正偶负
	{
		sum+=x[i];
		if(i%2==1)
		{
			if(sum<=0)
			{
				ans1+=(1-sum);
				sum=1;
			}
		}
		else
		{
			if(sum>=0)
			{
				ans1+=(sum+1);
				sum=-1;
			}
		}
		//cout<<sum<<endl;
			
	}
	   // cout<<endl;
	ll ans2=0;
	sum=0;
	for(int i=1;i<=n;i++) 
	{
		sum+=x[i];
		if(i%2==0)
		{
			if(sum<=0)
			{
				ans2+=(1-sum);
				sum=1;
			}
		}
		else
		{
			if(sum>=0)
			{
				ans2+=(sum+1);
				sum=-1;
			}
		}
	   // cout<<sum<<endl;
	}
	cout<<min(ans1,ans2)<<endl;
	
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int64_t N, X, D;
  cin >> N >> X;
  vector<int64_t> x(N);
  vector<int64_t> y(N);
  for (int64_t i=0; i<N; i++) {
    cin >> x[i];
    y[i]=abs(X-x[i]);
  }
  sort(y.begin(),y.end());
  reverse(y.begin(),y.end());
  D=y[0];
  for (int64_t i=0; i<N; i++) {
    if (y[i]!=0) {
      D=gcd(D,y[i]);
    }
  }
  cout << D << endl;
}

Measured memory_bytes: 4752
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define eps 1e-9

int a,b,c;

int main () {

	scanf("%d %d",&a,&b);
	c=a+b;
	if (c>=24) c=c-24;
	printf("%d\n",c);
	
	return 0;	
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

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

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

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

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int train = min(a, b);
  int bus = min(c, d);

  cout << train + bus << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1000000005
#define MOD 1000000007
#define N 200005
#define M 27000
#define LOG 1000000
#define KOK 650
#define EPS 0.000000001
using namespace std;

int n,m,l,r,x;
ll ans;
ll S[N<<2],lazy[N<<2],dp[N];
vector<ii> v[N];

void push(int node) {

	S[node<<1]+=lazy[node];
	S[node<<1|1]+=lazy[node];	

	lazy[node<<1]+=lazy[node];
	lazy[node<<1|1]+=lazy[node];

	lazy[node]=0;
}

ll get(int node,int bas,int son,int x,int y) {

	if(bas>=x && son<=y) return S[node];

	push(node);

	bool l=(orta>=x);
	bool r=(orta+1<=y);

	if(l&r) return max(get(node<<1,bas,orta,x,y),get(node<<1|1,orta+1,son,x,y));

	if(l) return get(node<<1,bas,orta,x,y);

	return get(node<<1|1,orta+1,son,x,y);

}

void up(int node,int bas,int son,int x,int y,ll val) {

	if(bas>y || son<x) return ;

	if(bas>=x && son<=y) {

		S[node]+=val;

		lazy[node]+=val;

		return ;

	}

	push(node);

	up(node<<1,bas,orta,x,y,val);
	up(node<<1|1,orta+1,son,x,y,val);

	S[node]=max(S[node<<1],S[node<<1|1]);

}

int main() {

	//freopen("input.txt","r",stdin);	

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

	for(int i=1;i<=m;i++) {

		scanf("%d %d %d",&l,&r,&x);

		ans+=x;

		v[r].pb({l,-x});

	}

	for(int i=1;i<=n;i++) {

		int bef=i-2;

		umax(bef,0);

		up(1,1,n,i,i,dp[bef]);

		dp[i]=dp[i-1];

		for(auto x:v[i]) {

			up(1,1,n,1,x.st,x.nd);

		}

		umax(dp[i],get(1,1,n,1,i));

	}

	printf("%lld",dp[n]+ans);

}


Measured memory_bytes: 24960
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int N;

int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin>>N;
    out(180*(N-2));
    
    
}


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

#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}

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


int main() {
  int n; cin >> n;
  vector<ll> T(n);
  REP(i,n) cin >> T[i];
  whole(sort, T, greater<ll>());
  ll ans = T[0];
  REP(i,n) {
    ans = lcm(T[i], ans);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(x) x.begin(), x.end()

void Main() {
    int a,b;
    cin >> a >> b;
    int k = (a+b)/2;
    if(floor((a+b)/2.0) != ceil((a+b)/2.0)){
        cout << "IMPOSSIBLE" << endl;
        return;
    }
    cout << (a+b)/2 << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

constexpr long M = 2*1000+1;
int b[2000][1000];
int s[2001][1001];

inline long calc(long x, long y, long w, long h){
    return s[x+w][y+h] - s[x+w][y] - s[x][y+h] + s[x][y];
}

int main(void){
    long n, k;
    /*
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    */
    cin >> n >> k;
    for(long i=0; i<n; i++){
        int x, y;
        char c;
        //cin >> x >> y >> c;
        scanf("%d %d %c", &x, &y, &c);
        y %= 2*k;
        if(c=='W'){
            x += k;
        }
        if(y>=k){
            y-=k;
            x+=k;
        }
        x %= 2*k;
        b[x][y]++;
    }
    s[1][1] = b[0][0];
    for(long i=1; i<2*k; i++){
        s[i+1][1] = s[i][1] + b[i][0];
    }
    for(long i=1; i<k; i++){
        s[1][i+1] = s[1][i] + b[0][i];
    }
    for(long x=1; x<2*k; x++){
        for(long y=1; y<k; y++){
            s[x+1][y+1] = b[x][y] + s[x][y+1] + s[x+1][y] - s[x][y];
        }
    }
    long max = 0;
    for(long x=0; x<k; x++){
        for(long y=0; y<k; y++){
            long t = calc(x, y, k, k-y);
            t += calc(0, 0, x, y);
            t += calc(x+k, 0, k-x, y);
            t = t<n/2 ? n-t : t;
            max = t>max ? t : max;
        }
    }
    cout << max;
    return 0;
}


Measured memory_bytes: 15872
area=[list(map(int,input().split())) for i in range(3)]
count=0
for a1 in range(area[0][0]+1):
  b1=area[0][0]-a1
  b2=area[0][1]-a1
  b3=area[0][2]-a1
  a2=area[1][0]-b1
  a3=area[2][0]-b1
  if b1>=0 and b2>=0 and b3>=0 and a2>=0 and a3>=0:
    if a2+b2== area[1][1]:
      if a2+b3==area[1][2]:
        if a3+b1==area[2][0]:
          if a3+b2==area[2][1]:
            if a3+b3==area[2][2]:
              print('Yes')
              exit()
print('No')

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

struct Edge {
  int src, dst;
  double w;
};

typedef vector<vector<Edge> > Graph;
typedef pair<double,int> Pair;

const double inf = 1e20;

vector<int> dijkstra(int src, int dst, const Graph &g) {
  int n = g.size();
  priority_queue< Pair,vector<Pair>,greater<Pair> > que;
  vector<double> cost(n, inf);
  vector<int> prev(n);
  cost[src] = 0;
  que.push(Pair(0, src));
  while(que.size()) {
    const Pair s = que.top();
    que.pop();
    if(cost[s.second] < s.first) continue;
    if(s.second == dst) {
      vector<int> path;
      int p = dst;
      while(1) {
        path.push_back(p);
        if(p == src) break;
        p = prev[p];
      }
      reverse(path.begin(), path.end());
      return path;
    }
    for(int i = 0; i < g[s.second].size(); ++i) {
      const Edge &e = g[s.second][i];
      Pair t(s.first + e.w, e.dst);
      if(cost[t.second] <= t.first) continue;
      que.push(t);
      cost[t.second] = t.first;
      prev[t.second] = s.second;
    }
  }
  return vector<int>();
}

int main() {
  int n;
  while(cin >> n && n) {
    map<int,int> id, rid;
    vector<int> x(n), y(n);
    for(int i = 0; i < n; ++i) {
      int b;
      cin >> b >> x[i] >> y[i];
      id[b] = i;
      rid[i] = b;
    }
    Graph g(n);
    for(int i = 0; i < n; ++i) {
      for(int j = i+1; j < n; ++j) {
        int cost = (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
        if(cost <= 50*50) {
          g[i].push_back((Edge){i,j,sqrt(cost)});
          g[j].push_back((Edge){j,i,sqrt(cost)});
        }
      }
    }
    int m;
    cin >> m;
    while(m--) {
      int src, dst;
      cin >> src >> dst;
      vector<int> v = dijkstra(id[src], id[dst], g);
      if(v.empty()) {
        cout << "NA" << endl;
      } else {
        for(int i = 0; i < v.size(); ++i) {
          if(i) cout << " ";
          cout << rid[v[i]];
        }
        cout << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;


long gcd( long a, long b )
{
	if( b == 0 )
		return a;
	else
		return gcd( b, a % b );
}
int main()
{
	long long a, b, c, d;
	
	cin >> a >> b >> c >> d;
	long long divc = b / c - (a-1) / c;
	long long divd = b / d - (a-1) / d;
	long long lcm = c * d / gcd( c, d );
	long long divlcm = b / lcm - (a-1) / lcm;
	cout << (b - a+1) - (divc + divd - divlcm) << endl;
}


Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt(), q = sc.nextInt();
			if( (n|q) == 0 ) break;
			int[] cnt = new int[101];
			for(int i=0;i<n;i++) {
				int m = sc.nextInt();
				for(int j=0;j<m;j++) cnt[sc.nextInt()]++;
			}
			int ans = 0; cnt[0] = q-1;
			for(int i=1;i<101;i++) if(cnt[i] > cnt[ans]) ans = i;
			System.out.println( ans );
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 62608
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long N, std::string S){
  set<ll> r,g,b;
  for (int i = 0; i < N; i++) {
    if(S[i] == 'R')r.insert(i);
    else if (S[i] == 'G')g.insert(i);
    else b.insert(i);
  }
  ll ans = r.size()*g.size()*b.size();
  for (int i = 1; i <= N; i++) {
    for (int j = i+1; j <= N; j++) {
      ll k = 2*j - i;
      if(k > N)break;
      set<char> x;
      x.insert(S[i-1]);
      x.insert(S[j-1]);
      x.insert(S[k-1]);
      if(x.size() == 3)ans--;
    }
  }
  cout << ans << endl;
}

int main(){
    long long N;
	scanf("%lld",&N);
	std::string S;
	std::cin >> S;
    solve(N, S);
}


Measured memory_bytes: 3852
#include <iostream>
using namespace std;
int main()
{
	long double a,b;
	cin>>a>>b;
	if(a>b)
	{
		cout<<"GREATER";
	}
	else if(a<b)
	{
		cout<<"LESS";
	}
	else
	{
		cout<<"EQUAL";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end()); 
    reverse(t.begin(), t.end());
    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    ll q = 7 + 1e9;
    vector<ll> subsum(N);
    subsum[N-1] = 0;
    for( int i=N-1; i>0; --i ){
        subsum[i-1] = subsum[i] + A[i];
        subsum[i-1] %= q;
    } 
    ll ans = 0;
    for( int i=0; i<N-1; ++i){
        ans += A[i]*subsum[i];
        ans %= q;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6372
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    int ans=0;
    rep(i,n){
        if(a[i]==i+1){
            ans++;
            i++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define Sim template<class n
Sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
Sim> auto operator << (ostream &p, n y) -> 
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
Sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
Sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
Sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "

int n, a, b;

vector<int> cycle(int add, int len)
{
	if (len == 0)
	{
		return {add};
	}
	VI V1 = cycle(add + (1<<(len - 1)), len - 1);
	VI V2 = cycle(add, len - 1);
	reverse(ALL(V2));
	for (auto x : V2)
	{
		V1.PB(x);
	}
	return V1;
}

VI mov(VI V, int ind)
{
	VI R;
	FOR(i, ind, ind + SIZ(V) - 1)
	{
		R.PB(V[i % SIZ(V)]);
	}
	return R;
}

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(NULL);
	scanf("%d%d%d", &n, &a, &b);
	if (__builtin_popcount(a) % 2 == __builtin_popcount(b) % 2)
	{
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	if (n == 1)
	{
		printf("%d %d\n", a, b);
		return 0;
	}
	
	vector<int> V1 = cycle((1<<(n - 1)), n - 1);
	vector<int> V2 = cycle(0, n - 1);
	debug(V1, V2);
	int tmp = 0;
	while (V1[tmp] != a && V2[tmp] != a)
	{
		tmp++;
	}
	V1 = mov(V1, tmp);
	V2 = mov(V2, tmp);
	if (V2[0] == a)
	{
		swap(V1, V2);
	}
	tmp = 0;
	VI res;
	debug(V1, V2);
	while (V1[tmp] != b && V2[tmp] != b && V1[tmp + 1] != b && V2[tmp + 1] != b)
	{
		res.PB(V1[tmp]);
		res.PB(V2[tmp]);
		res.PB(V2[tmp + 1]);
		res.PB(V1[tmp + 1]);
		tmp += 2;
	}
	debug(tmp, res);
	if (V1[tmp + 1] == b)
	{
		res.PB(V1[tmp]);
		res.PB(V2[tmp]);
		tmp++;
		while (tmp < SIZ(V2))
		{
			res.PB(V2[tmp]);
			tmp++;
		}
		do
		{
			tmp--;
			res.PB(V1[tmp]);
		} while (V1[tmp] != b);
	}
	else
	{
		while (tmp < SIZ(V1))
		{
			res.PB(V1[tmp]);
			tmp++;
		}
		do
		{
			tmp--;
			res.PB(V2[tmp]);
		} while (V2[tmp] != b);
	}
	for (auto x : res)
	{
		printf("%d ", x);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2540
# -*- coding: utf-8 -*-

N,T = map(int,input().split())
t = list(map(int,input().split()))

waterbegin = 0
waterend = 0
water = 0

for i in range(N):
    if waterend < t[i]:
        water += waterend - waterbegin
        waterbegin = t[i]
        waterend = t[i] + T
    else:
        waterend = t[i] + T

water += waterend - waterbegin

print(water)


Measured memory_bytes: 26836
//package atcoder.tokio_marine_insurance_2020;

import java.io.*;
import java.util.StringTokenizer;

public class Main {

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

        String s = "-1000000000 1000000000\n" +
                "0 -999999999\n" +
                "1000000000";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); long A = nlo(), V=nlo();
        rl(); long B = nlo(), W=nlo();
        rl(); long T = nlo();

        long m = Long.MAX_VALUE;
        long k = A+V*T;
        boolean _c = m > k;
        boolean c = false;
        if (A<=B && (A+V*T) >= (B+W*T)) c=true;
        if (A>B && (B-W*T)>=(A-V*T)) c=true;
        bw.write(c ? "YES" : "NO");
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
}

Measured memory_bytes: 32772
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Read();
		int d = int.Parse(input[0]);
		int t = int.Parse(input[1]);
		int s = int.Parse(input[2]);

		Write(d<=t*s ? "Yes" : "No");
	}

	static string[] Read()
	{
		return Console.ReadLine().Split(' ');
	}

	static void Write(object o)
	{
		Console.WriteLine(o.ToString());
	}
}


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

int main(void) {
  int a,b;
  cin >> a >> b;
  if(a * b % 2 <= 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
  return 0;
}

Measured memory_bytes: 3560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToList();
			var n = firstLine[0];
			var k = firstLine[1];

			long count = k;

			for(int i = 0; i < n - 1; i++)
			{
				count *= k - 1;
			}
			
			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 11348
x, y = map(int, input().split())

a = x
b = 0
ans = 'No'
if y%2 != 0:
    pass
else:
    while a >= 0:
        c = a*2 + b*4
        if c == y:
            ans = 'Yes'
        a -= 1
        b += 1
print(ans)

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

int getMinCost(vector<int> A){
    if(A.size() < 2) return 0;
    if(A.size() == 2) return abs(A[1] - A[0]);

    vector<int> dp(A.size(), INT_MAX);

    dp[0] = 0;
    dp[1] = abs(A[1] - A[0]);

    for(int i=2;i<A.size();i++){
        int op1 = dp[i-1] + abs(A[i] - A[i-1]);
        int op2 = dp[i-2] + abs(A[i] - A[i-2]);

        dp[i] = min(dp[i], min(op1, op2));
    }

    return dp[A.size()-1];

}

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

    cout<<getMinCost(A);
}


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

using namespace std;

int main ()
{
    int a,b;
    cin>>a>>b;
    if(a<b)
    {
        cout<<"a < b"<<endl;
    }
    else if(a>b)
    {
        cout<<"a > b"<<endl;
    }
    else
    {
        cout<<"a == b"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <queue>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
struct point {
	int h, w,s;
	point(int _h, int _w,int _s) {
		h = _h, w = _w,s = _s;
	}
};
void  GridRepainting() {

	int H, W;
	cin >> H >> W;
	char t[51][51];
	int b = 0;
	for (size_t i = 0; i < H; i++)
	{
		for (size_t j= 0; j < W; j++) 
		{
			cin >> t[i][j];
			if (t[i][j] == '#') b++;
		}
	}

	queue<point> q;
	q.push(point(0, 0, 1));
	const int INF = 100000;
	int dp[51][51];
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++) dp[i][j] = INF;
	int nx[4] = { 0,1,0,-1 };
	int ny[4] = { 1,0,-1,0 };

	while (!q.empty())
	{
		point p = q.front(); q.pop();
		if (dp[p.h][p.w] <= p.s) continue;
		dp[p.h][p.w] = p.s;
		for (size_t i = 0; i < 4; i++)
		{
			int nex = p.h + nx[i];
			int ney = p.w + ny[i];
			if (nex < 0 || nex >= H || ney < 0 || ney >= W) continue;
			if (t[nex][ney] == '#') continue;
			q.push(point(nex, ney, p.s + 1));
		}
 	}
	if (dp[H - 1][W - 1] == INF) {
		cout << -1 << endl;
	}
	else {
		cout << (H * W - dp[H - 1][W - 1] - b) << endl;
	}
}

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


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

int main(void) {
    int input, ans = 0, flag;
    cin >> input;

    vector<int> side(input);
    for (int i = 0; i < input; i++) {
        cin >> side.at(i);
    }

    sort(side.begin(), side.end());
    reverse(side.begin(), side.end());

    vector<int> num;
    num.push_back(0);
    for (int i = 0; i < input; i++) {
        flag = 0;
        for (int j = i + 1; j < input; j++) {
            for (int k = j + 1; k < input; k++) {
                if (side.at(i) < side.at(j) + side.at(k) && side.at(j) < side.at(k) + side.at(i) && side.at(k) < side.at(i) + side.at(j)) {
                    ans++;
                    int temp = num[0];
                    int temp2 = num[0];
                }
                else {
                    break;
                    flag++;
                }
            }
            if (flag != 0) {
                break;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define LL long long
using namespace std;
struct node
{
	LL id, dir, val, rk;
}A[100000 + 100];
LL N, L, T;
inline int cmp(node x, node y)
{
	return x.val < y.val;
}
inline int cmp1(node x, node y)
{
	return x.rk < y.rk;
}
int main()
{
	scanf("%lld%lld%lld", &N, &L, &T);
	for (LL i = 1; i <= N; ++i)
		scanf("%lld%lld", &A[i].val, &A[i].dir), A[i].id = i;
	LL now = 0;
	for (LL i = 1; i <= N; ++i)
	{
		if (A[i].dir == 1)
		{
			now += T / L + (T % L + A[i].val >= L);
			A[i].val = (A[i].val + T) % L;
		}
		else 
		{
			now -= T / L + (A[i].val - T % L < 0);
			A[i].val = (A[i].val - T % L + L) % L;
		}
	}
	sort(A + 1, A + N + 1, cmp);
	now = (now % N + N) % N;
	now ++;
	for (LL i = now; i <= N; ++i)
		printf("%lld\n", A[i].val);
	for (LL i = 1; i < now; ++i)
		printf("%lld\n", A[i].val);
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int a, b, k;
   cin >> a >> b >> k;
   set<int> ans;

   for(int i = 0; i < k; i++){
      if(a + i <= b){
         ans.insert(a + i);
      }
   }

   for(int i = k-1; i >= 0; i--){
      if(b - i >= a){
         ans.insert(b - i);
      }
   }

   for(auto ans_ : ans){
      cout << ans_ << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
const int N = 1000000;

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

   int ans = -1;

    for (int i = 0; i < 12501; ++i) {
        if(int(0.08 * i) == a && int(0.10 * i) == b) {
            ans = i;
            break;
        }
    }
    print(ans);
}

Measured memory_bytes: 256
a,b,c = (int(x) for x in input().split())
ans = abs(a*b*(c//2)-a*b*(c-c//2))
ans = min(ans, abs(a*c*(b//2)-a*c*(b-b//2)))
ans = min(ans, abs(b*c*(a//2)-b*c*(a-a//2)))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

typedef struct Point {
    Int x,y;
}point;

vector<point> ans;

Int cx,cy;
void move(Int x,Int y) {
    cx += x;
    cy += y;

    ans.push_back({cx,cy});
    return;
}

int main(void) {
    Int k,x,y;
    cin>>k>>x>>y;

    Int X = abs(x);
    Int Y = abs(y);

    if(X > Y)
        swap(X,Y);

    if((k%2 == 0) && ((X+Y)%2 == 1)) {
        cout<<-1<<endl;

        return 0;
    }

    if(X+Y == k) {
        cout<<1<<endl;
        cout<<x<<" "<<y<<endl;

        return 0;
    }

    Int a = -1;
    for(Int i = 2*k-(X+Y);a < 0;i += k)
        if(i % 2 == 0)
            a = i / 2;

    while(a >= k)
        move(0,-k),a -= k;

    move(-a,k-a);

    while(cx+k<=X)
        move(k,0);
    while(cy+k<=Y)
        move(0,k);
    if(cx != X || cy != Y)
        ans.push_back({X,Y});

    cout<<ans.size()<<endl;
    for(auto r:ans) {
        Int ansx = r.x;
        Int ansy = r.y;
        
        if(abs(x) > abs(y)) 
            swap(ansx,ansy);
        if(x < 0)
            ansx *= -1;
        if(y < 0)
            ansy *= -1;

        cout<<ansx<<" "<<ansy<<endl;
    }


    return 0;
}




Measured memory_bytes: 5484
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
string s;

int main(){
	cin>>n>>s;
	int t=1;
	for(int i=1;i<n;i++) if(s[i]!=s[i-1]) t++;
	cout<<t<<endl;
}

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

int main() {
    int n;
    int a[110];

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

  	int min_a = 1<<30, max_a = 0;
    for (int i = 0; i < n; i++) {
        min_a = min(min_a, a[i]);
        max_a = max(max_a, a[i]);
    }

    cout << max_a - min_a << endl;

}

Measured memory_bytes: 3632
n=int(input())
p=list(map(int,input().split()))

lis=[0]*n
ans=0
i=0
while i<n-1:
    if i+1==p[i]:
        lis[i]=1
        if i+2==p[i+1]:
            lis[i+1]=1
            i+=1
        ans+=1
    i+=1
if lis[n-1]==0 and p[n-1]==n:
    ans+=1
print(ans)

Measured memory_bytes: 14008
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
class Main {
	public static void main (String[] args)   {
	   Scanner s=new Scanner(System.in); 
        // String str=s.next();
        // if(str.charAt(5)==str.charAt(4) && str.charAt(3)==str.charAt(2))
        // System.out.println("Yes");
        // else
        // println("No");
        long n=s.nextLong();
        long ans=0;
        if(n>=500)
        {
            ans+=(n/500)*1000;
            //System.out.println(ans);
            n=(n%500);
            if(n>=5)
            {
                ans+=(n/5)*5;
                //System.out.println(ans);
            }
        }
        else
        {
            ans+=(n/5)*5;
        }
        System.out.println(ans);
	   
	    
 
	}
	
}


Measured memory_bytes: 22740
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	A, B,C = inputMap()

	tmp = A-B


	print(max(0,C-tmp))


if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

struct UnionFind{
private:
    vector<int> par;
    vector<int> rank;

public:
    //n要素で親を初期化、par[x]はxの親を表す
    UnionFind(int n){
        par.resize(n,0);
        rank.resize(n,0);
        rep(i,n){
            par[i] = i;
        }
    }

    //木の根を求める
    int root(int x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    //xとyの属する集合を併合
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //xとyが同じ集合に属するか否か
    bool same(int x, int y){
        return root(x) == root(y);
    }

};

int main(){
    int n,m;cin >> n >> m;
    vector<int> p(n);
    rep(i,n)cin >> p[i];
    UnionFind xy(n);
    rep(i,m){
        int x,y;cin >> x >> y;
        x--;y--;
        xy.unite(x,y);
    }
    int count = 0;
    rep(i,n){
        if(xy.same(p[i]-1,i))count++;
    }
    cout << count << endl;
    return 0;
    
}

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

int main() {
  int h, w;
	cin >> h >> w;
	vector<string> c(h);
	rep(i,h){
		cin >> c[i];
		cout << c[i] << endl;
		cout << c[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int min = Math.min(a*n, b);
        System.out.println(min);
    }
}

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

using namespace std;

void solve(){
    int A, B;
    cin >> A >> B;
    cout << max(max(A-B, A+B), A*B) << endl;
}

void solve1(){
    int A, B, C; cin >> A >> B >> C;
    if(C <= A - B){
        cout << 0 << endl;
    }
    else{
        cout << C - (A -B ) << endl;
    }
}

int main(){
    solve1();
}




Measured memory_bytes: 256