akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
using namespace std;

int n, q;
map<int, int> mp;
long long sum;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if(mp.find(x) != mp.end()) mp[x]++;
        else mp[x] = 1;
        sum += 1LL*x;
    }

    cin >> q;
    while(q--) {
        int b, c;
        cin >> b >> c;
        if(mp.find(b) != mp.end()) {
            sum -= 1LL*mp[b]*b;
            sum += 1LL*mp[b]*c;
            if(mp.find(c) != mp.end()) mp[c] += mp[b];
            else mp[c] = mp[b];
            mp.erase(mp.find(b));
        }
        cout << sum << '\n';
    }

}


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

int main() {
    ll N, R = 0, G = 0, B = 0, count = 0;
    string S;
    cin >> N >> S;
    REP(i,N){
        if(S[i] == 'R'){
            R++;
        } else if(S[i] == 'G'){
            G++;
        } else {
            B++;
        }
    }

    int M = round(N / 2.0 - 1);

    REP(i, M) { //iは等差の間隔
        REP(j, N - 2){ //jは一番小さいやつ（左のやつ）
            if(j + 2 * i + 2 > N-1){
                break;
            }

            if(S[j] != S[j + i + 1] && S[j + i + 1] != S[j + 2 * i + 2] && S[j + 2 * i + 2] != S[j]) {
                count++;
            }
        }
    }

    cout << R * G * B - count << endl;
}

Measured memory_bytes: 3636
str = input().split()
N = int(str[0])
M = int(str[1])

if N == 1 and M >=2:
    print(M-2)
elif M == 1 and N>=2:
    print(N-2)
elif N == 1 and M == 1:
    print(1)
else:
    print((N-2)*(M-2))

        

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    double by=380000.0,cur,ans=0;
    ll n;cin>>n;
    string s;
    for(ll i=0;i<n;i++){
        cin>>cur>>s;
        if(s=="JPY")ans+=cur;
        else ans+=(cur*by);
    }
    cout<<fixed<<setprecision(18)<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

void solve(){
    int N, K, C;
    string S, T;
    cin >> N >> K >> C >> S;
    T = S;
    reverse(T.begin(), T.end());
    vector<int> left(N+1), right(N+1);
    int pre = -C - 1;
    int cur = 0;
    REP(i,N){
        if(i - pre > C && S[i] == 'o') cur++, pre = i;
        left[i+1] = cur;
    }
    cur = 0, pre = -C - 1;
    REP(i,N){
        if(i - pre > C && T[i] == 'o') cur++, pre = i;
        right[i+1] = cur;
    }
    REP(i,N){
        if(S[i] == 'x') continue;
        if(left[i] + right[N-i-1] < K) cout << i + 1 << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 5176
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    vector<string> word;
    
    cin >> N;
    rep(i,N){
        string inp;
        cin >> inp;
        word.pb(inp);
    }
    
    rep(i,N){
        if(i == 0) continue;
        if(word[i][0] != word[i-1][word[i-1].size()-1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    rmsame(word);
    if(word.size() != N) cout << "No" << endl;
    
    else cout << "Yes" << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 5e3 + 5;

ll f[MAXN], f_inv[MAXN];

ll dp0[MAXN], dp0_tmp[2][MAXN];

ll pow_mod(ll a, ll st){
	ll ans = 1ll;
	for(; st; st /= 2ll){
		if (st & 1){
			ans = (ans * a) % MOD;
		}
		a = (a * a) % MOD;
	}
	return ans;
}

void init_c(){
	f[0] = 1;
	REP(i, 1, MAXN){
		f[i] = (f[i - 1] * i) % MOD;
	}
	f_inv[MAXN - 1] = pow_mod(f[MAXN - 1], MOD - 2);
	for(int i = MAXN - 2; i >= 0; i--){
		f_inv[i] = (f_inv[i + 1] * (i + 1)) % MOD;
	}
}

ll get_c(int i, int j){
	if (i < 0 || j < 0 || j > i){
		return 0ll;
	}
	ll ans = (f[i] * f_inv[j]) % MOD;
	ans = (ans * f_inv[i - j]) % MOD;
	return ans;
}

char s[MAXN];

void solve(){
	init_c();
	
	int n, len;
	scanf("%d%s", &n, &s[0]);
	len = strlen(s);
	
	dp0_tmp[0][0] = 1;
	dp0[0] = 1;
	REP(i, 0, n){
		int ind = i & 1;
		REP(j, 0, n){
			dp0_tmp[ind ^ 1][j] = 0;
		}
		REP(j, 0, n){
			int j1 = max(j - 1, 0);
			dp0_tmp[ind ^ 1][j1] = (dp0_tmp[ind ^ 1][j1] + dp0_tmp[ind][j]) % MOD;
			
			dp0_tmp[ind ^ 1][j + 1] = (dp0_tmp[ind ^ 1][j + 1] + 2ll * dp0_tmp[ind][j]) % MOD;
		}
		dp0[i + 1] = dp0_tmp[ind ^ 1][0];
	}
	
	ll ans = 0ll;
	REP(i, 0, n){
		ll cur = dp0[i];
		int i1 = n - (i + 1);
		int j1 = len - 1;
		if ((i1 + j1) & 1){
			continue;
		}
		int up_moves = (i1 + j1) / 2;
		int down_moves = i1 - up_moves;
		if (up_moves < 0 || down_moves < 0){
			continue;
		}
		ll mul = get_c(i1, up_moves) - get_c(i1, up_moves + 1);
		if (mul < 0){
			mul += MOD;
		}
		
		//printf("%d %d %lld %lld %lld\n", i1, j1, dp0[i], mul, pow_mod(2ll, down_moves));
		
		mul = (mul * pow_mod(2ll, down_moves)) % MOD;
		
		ans = (ans + cur * mul) % MOD;
	}
	
	printf("%lld\n", ans);
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
    int x,a,b,temp,save;
    scanf("%d",&x);
    scanf("%d",&a);
    scanf("%d",&b);

    if(x>=(a+b) && x<=10000 && a<=1000 && b<=1000 && x>=1 && a>=1 && b>=1){



    temp=x-a;
    save=temp%b;

    printf("%d",save);

    }



return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define du double
#define jmp cout<<"\n"
#define vl vector<ll>
#define vi vector<int>
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define printv(v) for(auto x:v) cout<<x<<" "; jmp;
#define endll "\n"
#define SORT(v) sort(v.begin(),v.end())
#define REV(x)  reverse(x.begin(),x.end())
#define UNI(a) a.erase( unique( a.begin(), a.end() ), a.end() )
#define si(x) x.size()
#define ff first
#define ss second
#define iin insert
using namespace std;

void solve()
{

	ll n;
	cin >> n;
	du p[n];
	for (ll i = 0; i < n; i++) cin >> p[i];
	du dp[n + 1][n + 1];
	memset(dp, 0.0, sizeof(dp));
	dp[0][0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		for (ll j = 0; j <= i; j++)
		{
			if (j == 0)
				dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]);
			else dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]) + dp[i - 1][j - 1] * p[i - 1];
		}
	}
	cout << fixed << setprecision(10);
	du sum = 0;
	for (ll i = n; i > n / 2; i--)
	{
		sum += dp[n][i];
	}
	cout << sum;

}

int main() {
	fast;
	solve();

}


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

using namespace std;

#define run_forrest_run ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define fi first
#define se second
#define si set <int>
#define all(x) (x).begin(),(x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
int gcd(int a,int b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);} 

const int inf = 1e9;	
const int mod = inf + 7;

const int N = 205000;
vector <int> g[N];
vector <bool> visited(N);
vector <int> color(N);
double dp[3010][3010];

int main()
{
	run_forrest_run;
	int n;
	cin >> n;
	double p[n+1];
	for (int i = 1; i <= n; i++)
		cin >> p[i];

	dp[1][1] = p[1];
	dp[1][0] = 1 - p[1];
	for (int i = 2; i <= n; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			if (j == 0)
				dp[i][j] = dp[i-1][j] * (1 - p[i]);
			else if (i == j)
				dp[i][j] = dp[i-1][j-1] * (p[i]);
			else dp[i][j] = dp[i-1][j] * (1 - p[i]) + dp[i-1][j-1] * (p[i]);
		}
	}
	double ans = 0;
	for (int i = (n+1)/2; i <= n; i++)
		ans+=dp[n][i];
	cout << setprecision(10) << fixed  << ans;
}


Measured memory_bytes: 75008
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

long long N, M;
int main() {
	while (cin >> N >> M) {
		cout << min(M / 2, (N * 2 + M) / 4) << endl;
	}
}


Measured memory_bytes: 256
#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 double eps = 1e-10;
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;
}

map<P, int> edge_num;

ll dfs(int now, int prev, int v, ll cons, const vvi &tr) {
  if(now == v) return cons;

  for(int i=0;i<SZ(tr[now]);++i) {
    int nxt = tr[now][i];
    if(nxt == prev) continue;
    P tmp = {now, nxt};
    if(now > nxt) swap(tmp.first, tmp.second);
    int num = edge_num[tmp];
    ll res = dfs(nxt, now, v, cons | (1ll<<num), tr);
    if(res != -1) return res;
  }
  return -1;
}

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

  int n; cin >> n;
  vvi tr(n);
  int id = 0;
  for(int i=0;i<n-1;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    tr[a].push_back(b);
    tr[b].push_back(a);
    if(a < b) edge_num[{a, b}] = id;
    else edge_num[{b, a}] = id;
    id++;
  }
  
  int m; cin >> m;
  vll cons(m);
  vector<P> v(m);
  for(int i=0;i<m;++i) {
    cin >> v[i].first >> v[i].second;
    v[i].first--;
    v[i].second--;
    vector<int> pr(n, -1);
    cons[i] = dfs(v[i].first, -1, v[i].second, 0, tr);
  }

  ll ans = 0;
  for(int i=0;i<(1<<m);++i) {
    ll ncons = 0;
    for(int j=0;j<m;++j) {
      if((i>>j)&1) {
        ncons |= cons[j];
      }
    }
    int cnt = n - 1 - __builtin_popcountll(ncons);
    ans += (__builtin_popcount(i) % 2 ? -1 : 1) * (1ll<<cnt);
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

bool dfs(vi &a, int pos,int l,int r){
	if(pos==10){
		return true;
	}
	REP(i,2){
		if(i==0&&a[pos]>l&&dfs(a,pos+1,a[pos],r)){
			return true;
		}
		if(i==1&&a[pos]>r&&dfs(a,pos+1,l,a[pos])){
			return true;
		}
	}
	return false;
}

int main(){
	int n;
	cin>>n;
	REP(i,n){
		vi a(10);
		REP(i,10){
			cin>>a[i];
		}
		cout<<(dfs(a,0,0,0)?"YES":"NO")<<endl;
	}
}

Measured memory_bytes: 1184
from itertools import groupby
from operator import itemgetter
N, M = map(int, input().split())
IPY = []
for i in range(M):
    p, y = map(int, input().split())
    IPY.append([i, p, y])
IPY.sort(key=itemgetter(1, 2))
Ans = [-1] * M
for v, g in groupby(IPY, key=itemgetter(1)):
    for i, (idx, p, y) in enumerate(g, 1):
        Ans[idx] = "{:06d}{:06d}".format(p, i)
print("\n".join(Ans))


Measured memory_bytes: 33888
//https://atcoder.jp/contests/arc070/tasks/arc070_b
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

constexpr int mod=(int)1e9+7;
using V=vector<LL>;
inline void chadd(LL& a,const LL b){
    a+=b;
    if(a>=mod)a-=mod;
}

LL dp[5123];
LL pr[5123];
int main(){
    int N,K;
    cin>>N>>K;
    vector<int> A(N);
    cin>>A;
    int ret=N;
    dp[0]=1;
    for(int i:range(N)){
        const int a= min(A[i],K);
        for(int j=K-1;j>=a;j--){
            chadd(dp[j],dp[j-a]);
        }
    }
    //for(int i:range(K))cout<<dp[i]<<" ";cout<<endl;
    for(int i:range(N)){
        const int a= min(A[i],K);
        for(int j:range(K)){
            pr[j]=dp[j];
            if(j>=a)chadd(pr[j],mod-pr[j-a]);
        }
        for(int j:range(K-a,K)){
            if(pr[j]){
                ret--;break;
            }
        }
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	char c;

	cin >> c;

	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        a = list(map(int, input().split()))

        broken = 0
        next_target = 1
        for i in range(N):
            if a[i] != next_target:
                broken += 1
            else:
                next_target += 1

        if broken < N:
            print(broken)
        else:
            print(-1)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 72012
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;

void dfs(const vector<vector<int> >& e, int node, vector<int>& visited) {
    visited[node] = 1;

    auto& c = e[node];
    rep(i, c.size()) {
        if (visited[c[i]] <= 0) {
            dfs(e, c[i], visited);
        }        
    }
}


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

    vector<int> a(m), b(m);
    rep(i, m) cin >> a[i] >> b[i];
    
int            bridge = 0;
    rep(ei, m) {
        vector<vector<int> > e(n, vector<int>());
        rep(i, m) {
            if (i == ei) {
                continue;
            }
            e[a[i] - 1].push_back(b[i] - 1);
            e[b[i] - 1].push_back(a[i] - 1);
        }

        vector<int> visited(n);
        dfs(e, 0, visited);

        bool ok = true;
        rep(i, n) {
            if (visited[i] <= 0){
                ok = false;
                break;
            }
        }

        if (ok == false) {
            bridge++;
        }

    }

    put(bridge);

    return 0;
}

Measured memory_bytes: 3636
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	String s = sc.next();
	boolean flagA = false;
	boolean flagB = false;
	boolean flagX = false;
	for(int i = 0; i < a; i++) {
		for(int j = 0; j <= 9; j++) {
			if(Character.getNumericValue(s.charAt(i)) == j) {
				flagA = true;
				break;
			} else {
				flagA = false;
			}
		}
	}
	if(s.charAt(a) == '-') {
		flagX = true;
	}
	for(int i = a + 1; i < a + b + 1; i++) {
		for(int j = 0; j <= 9; j++) {
			if(Character.getNumericValue(s.charAt(i)) == j) {
				flagB = true;
				break;
			} else {
				flagB = false;
			}
		}
	}
	if(flagA == true && flagX == true && flagB == true) {
		System.out.println("Yes");
	} else {
		System.out.println("No");
	}
}
}

Measured memory_bytes: 23764
#include <stdio.h>

int main(void)
{
	long long n, i, sum;

	scanf("%lld", &n);
	sum = 0;
	for (i = 0; i < n; i++){
		int d;
		scanf("%d", &d);
		sum += d;
	}
	printf("%lld\n", sum / n);

	return (0);
}

Measured memory_bytes: 596
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n, m;
    cin >> n >> m;
    VVI e(n);
    REP(i,m){
        int u = in() - 1, v = in() - 1;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    VI ans(n), visit(n);
    queue<int> que;
    que.push(0);
    visit[0] = 1;
    while (!que.empty()){
        int now = que.front();
        que.pop();
        for (int next : e[now]){
            if (visit[next]) continue;
            visit[next] = 1;
            que.push(next);
            ans[next] = now;
        }
    }
    cout << "Yes" << endl;
    FOR(i,1,n-1) printf("%d\n", ans[i] + 1);
    return 0;
}


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

int main() {
  long ct, N;
  char cc;
  cin >> N;
  vector <char> d(N);
  for (long i=0; i<N; i++) {
    cin >> d.at(i);
  }
  ct = 1;
  cc = d.at(0);
  for (long i=1; i<N; i++) {
    if (cc != d.at(i)) {
      ct = ct + 1;
      cc = d.at(i);
    }
  }
  cout << ct << endl;
}


Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

X,K,D = MI()
X = abs(X)

q = X//D
r = X % D

if K <= q:
    print(X-K*D)
    exit()

if (q-K) % 2 == 0:
    print(r)
else:
    print(D-r)


Measured memory_bytes: 61960
package main

import (
	"fmt"
)

var (
	finv, inv, fac [MAX]int
)

func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func init() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

const (
	MOD = 998244353
	MAX = 510000
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

func main() {
	var X, A int
	fmt.Scanf("%d %d\n", &X, &A)

	if X < A {
		fmt.Println(0)
	} else {
		fmt.Println(10)
	}
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;


int main(void){
    long long N;
    cin >> N;
    long f = log10(N)+1;
    
    for(long i=1; i*i<=N; i++){
        if(N%i==0){
            if(log10(N/i)+1<f)f=log10(N/i)+1;
        }
    }
    cout << f << endl;
    
}


Measured memory_bytes: 3896
def bubble_sort(a, n):
  for i in range(0,n):
    for j in range(n-1,i,-1):
      if a[j][1] < a[j-1][1]:
        a[j], a[j-1] = a[j-1], a[j]
  return a

def selection_sort(b, n):
  for i in range(0,n):
    minj = i
    for j in range(i, n):
      if b[j][1] < b[minj][1]:
        minj = j
    b[i], b[minj] = b[minj], b[i]
  return b

if __name__ == '__main__':
  n = int(input())
  a = list(map(str, input().split()))
  b = a[:]
  buble = bubble_sort(a,n)
  select = selection_sort(b,n)
  print(" ".join(map(str, buble)))
  print("Stable")
  print(" ".join(map(str, select)))
  if select == buble:
    print("Stable")
  else:
    print("Not stable")


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

LL a,b,c,d,g;

LL gcd(LL a,LL b)
{
	if(!b) return a;
	return gcd(b,a%b);
}

LL get(LL x)
{
	return x-x/c-x/d+x/g;
}

int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	g=gcd(c,d);g=c*d/g;
	LL ans=get(b)-get(a-1);
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<char> D(K);
    for (int i = 0; i < K; i++)
    {
        cin >> D[i];
    }
    int ans = N;
    while (true)
    {
        bool flag = true;
        string S = to_string(ans);
        for (char s : S)
        {
            if (count(D.begin(), D.end(), s) > 0)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            cout << S << endl;
            return 0;
        }
        else
        {
            ans++;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
void solve(long long N) {
  cout<<  (N-1) * N / 2 << endl;
  return;
}
 
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;

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

    string ans = "NG";
    for(int i = A; i <= B; ++i){
        if(i%K == 0){
            ans = "OK";
            break;
        }
    }
    cout << ans << endl;
    
}

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

int main(void){
    int x, y, z;
    cin >> x >> y >> z;
    
    x -= z;
    int cnt = 0;
    
    while(x >= y + z){
        x -= y + z;
        cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}


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

int main(){
    int n, x;
    cin >> n >> x;
    int ans = 0, cho = 1e9;
    for(int i=0; i<n; i++){
        int m;
        cin >> m;
        x -= m;
        ans++;
        cho = min(cho, m);
    }
    cout << ans + x/cho << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int N,K;
	scanf("%d%d",&N,&K);
	char S[N];
	int a;
	for(a=0;a<N+1;a++){
		scanf("%c",&S[a]);
	}
	if(S[K]=='A'){
		S[K]='a';
	}else if(S[K]=='B'){
		S[K]='b';
	}else if(S[K]=='C'){
		S[K]='c';
	}
	for(a=0;a<N+1;a++){
		printf("%c",S[a]);
	}
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int m1=b[n/2-1],m2=b[n/2];
    for(int i=0;i<n;i++)
    {
        if(a[i]<=m1)cout<<m2<<endl;
        else cout<<m1<<endl;
    }
    return 0;
}

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

template<class T> void chmax(T &a, T b) {
    if (a < b) {
        a = b;
    }
}

int main() {
    int N;
    long long W;
    cin >> N >> W;
    vector<int> weight(N), value(N);
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];
    
    vector<vector<long long>> dp(N+1, vector<long long>(W+1, 0));
    
    for (int i = 0; i < N; ++i) {
        for (int w = 0; w <= W; ++w) {
            if (w - weight[i] >= 0) {
                chmax(dp[i+1][w], dp[i][w-weight[i]] + value[i]);
            }
            chmax(dp[i+1][w], dp[i][w]);
        }
    }
    cout << dp[N][W] << endl;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> A(n);
  for(int i = 0;i<n;i++)cin >> A[i];
  int ans = 0;
  for(int i = 0;i<n;i++)
  {
    int k = i;
    int j = i;
    while(A[k]<=A[k+1])k++;
    while(A[j]>=A[j+1])j++;
    ans++;
    i = max(k,j);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
N=int(input())
count=0
if 1<=N<=9:
  print(N)
elif 10<=N<=99:
  print(9)
elif 100<=N<=999:
  print(9+N-100+1)
elif 1000<=N<=9999:
  print(9+999-100+1)
elif 10000<=N<=99999:
  print(9+999-100+1+N-10000+1)
else:
  print(9+999-100+1+99999-10000+1)

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=200010;
ll a[N],b[N];
int n,m;
ll k;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int res=0;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++) 
    {
        cin>>a[i];
        a[i]+=a[i-1];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>b[i];
        b[i]+=b[i-1];
    }
    for(int i=0,j=m;i<=n;i++)
    {
        while(j&&a[i]>k-b[j]) j--;
        if(a[i]<=k-b[j]) res=max(res,i+j);
    }
    cout<<res<<endl;
    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n,k;
    cin >> n >> k;
    vector<vector<int>> graph(n);
    vector<pii> edges;
    rep(i,0,n-1){
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
        edges.push_back({a,b});
    }

    int ans=inf;
    vector<int> dist(n);
    function<void(int,int,int)> dfs=[&](int v,int p,int d){
        dist[v]=d;
        for(int u:graph[v]){
            if(u==p) continue;
            dfs(u,v,d+1);
        }
    };
    if(k%2==0){
        rep(i,0,n){
            dfs(i,-1,0);
            int cnt=0;
            rep(j,0,n) if(dist[j]>k/2) ++cnt;
            ans=min(ans,cnt);
        }
    }else{
        for(auto &e:edges){
            dfs(e.first,e.second,0);
            dfs(e.second,e.first,0);
            int cnt=0;
            rep(j,0,n) if(dist[j]>(k-1)/2) ++cnt;
            ans=min(ans,cnt);
        }
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	string s,t;
	int n=0;
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
return 0;
}


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

int main(){
    long long N, n;
    long long ans = 0;

    std::cin >> N;

    for(int j = 1; j <= N; j++){
        n = (N - N%j)/j;
        ans = ans + (j + (N - N%j)) * n / 2;
    }

    std::cout << ans;
}

Measured memory_bytes: 3636
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll n=in();
    vector<vector<pair<ll,ll>>>shogen(n);
    for(ll i=0;i<n;++i){
        ll a=in();shogen[i].resize(a);
        for(ll j=0;j<a;++j){
            ll x=in(),y=in();
            shogen[i][j]=make_pair(x,y);
        }
    }

    ll ans=0;
    for(ll i=1;i<(1<<n);++i){
        vector<bool>honest(n);
        for(ll j=0;j<n;++j){
            honest[j]=(i>>j)&1==1;
        }
        for(ll j=0;j<n;++j){
            if(honest[j]){
                for(auto s:shogen[j]){
                    if(s.second==1){
                        if(!honest[s.first-1])goto CONTINUE;
                        honest[s.first-1]=true;
                    }else{
                        if(honest[s.first-1])goto CONTINUE;
                        honest[s.first-1]=false;
                    }
                }
            }
        }
        ans=max(ans,(ll)__builtin_popcountll(i));
        CONTINUE:;
    }
    cout<<ans<<endl;
}


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

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

    for(int k=0;k<B;k++){
        if(k*A%B==C){
            cout<<"YES"<<"\n";
            return 0;
        }    
    }
    cout<<"NO"<<"\n";

    return 0;
}



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

#define check cnt=0;for(j=0;j<6;j++)if(d1[j]==d2[j])cnt++;

int main(){
 int d1[6],d2[6],tmp,cnt,j,a=1;

 for(int i=0;i<6;i++){
  cin >> d1[i] ;
 }
 for(int i=0;i<6;i++){
  cin >> d2[i] ;
 }

 check
   if(cnt==6)a=0;

 while(a){
 for(int i=0;i<5;i++){
  for(int k=0;k<4;k++){
 check
   if(cnt==6)break;
   tmp=d2[1];
   d2[1]=d2[3];
   d2[3]=d2[4];
   d2[4]=d2[2];
   d2[2]=tmp;
  }
 check
   if(cnt==6)break;
  tmp=d2[0];
  d2[0]=d2[1];
  d2[1]=d2[5];
  d2[5]=d2[4];
  d2[4]=tmp;
 }
 
 check
   if(cnt==6)break;

  tmp=d2[0]; 
  d2[0]=d2[3];
  d2[3]=d2[5];
  d2[5]=d2[2];
  d2[2]=tmp;

  for(int k=0;k<4;k++){
 check
   if(cnt==6)break;
   tmp=d2[1];
   d2[1]=d2[3];
   d2[3]=d2[4];
   d2[4]=d2[2];
   d2[2]=tmp;
  }
 
 check
   if(cnt==6)break;

  tmp=d2[0]; 
  d2[0]=d2[3];
  d2[3]=d2[5];
  d2[5]=d2[2];
  d2[2]=tmp;
  tmp=d2[0]; 
  d2[0]=d2[3];
  d2[3]=d2[5];
  d2[5]=d2[2];
  d2[2]=tmp;

  for(int k=0;k<4;k++){
 check
   if(cnt==6)break;
   tmp=d2[1];
   d2[1]=d2[3];
   d2[3]=d2[4];
   d2[4]=d2[2];
   d2[2]=tmp;
  }
 check
   if(cnt==6)break;
   a=0;
 }


 if(cnt==6)cout << "Yes" << endl ;
 else cout << "No" << endl ;

 return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(a + b + c == 17 && max({a,b,c}) == 7 && min({a,b,c}) == 5)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3608
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

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

    vector<int> dp(n, inf+1);
    for(int i=0; i<n; i++){
        int id = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
        dp[id] = a[i];
    }

    for(int i=n-1; i>=0; i--){
        if(dp[i] != inf+1){
            cout << i + 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3616
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,(n))
typedef vector<int> vec;


class CTraveling {
public:
	void solve(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    vector<int> t(n);
    vec x(n), y(n);
    REP(i,n) {
      in >> t[i] >> x[i] >> y[i];
    }
    int oldt = 0,oldx = 0, oldy = 0;
    REP(i, n){
      int t1 = t[i] - oldt;
      int t2 = abs(x[i] - oldx + y[i] - oldy);
      if(t1 % 2 != t2 % 2 || t1 < t2){
        out << "No" << endl;
        return;
      }
      oldt = t[i]; oldx = x[i]; oldy = y[i];
    }
    out << "Yes" << endl;

	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	CTraveling solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 5488
#include <cstdlib>
#include <algorithm>
#include <array>
#include <iostream>


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

  std::array<int, 3> as;
  for (auto&& a : as) {
    std::cin >> a;
  }
  std::cout << (*std::max_element(std::cbegin(as), std::cend(as)) - *std::min_element(std::cbegin(as), std::cend(as))) << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
str K;
int D;
ll dp[100010][110][2];
int main(){
  cin>>K>>D;
  int s=K.size();
  vi n;
  rep(i,s){
    n.pb(K[i]-'0');
  }
  fill(dp,0);
  dp[0][0][0]=1;
  rep(i,s){
    rep(j,D){
      rep(k,2){
	rep(l,(k?10:n[i]+1)){
	  dp[i+1][(j+l)%D][k||l<n[i]]=(dp[i+1][(j+l)%D][k||l<n[i]]+dp[i][j][k])%MOD;
	}
      }
    }
  }
  prin((dp[s][0][0]+dp[s][0][1]-1+MOD)%MOD);
  return 0;
}


Measured memory_bytes: 172288
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
typedef long long LL;
const int N=110000;
const int P=1000000007;
int a[N],n;
int main(){
    scanf("%d",&n);
    rep(i,1,n)scanf("%d",&a[i]);
    int ans=1;
    int need=1;
    int pre=0;
    rep(i,1,n){
        ans=ans*1ll*(n-pre-(n-i))%P;
        if(a[i]<need)++pre;
        else need+=2;
    }
    printf("%d\n",ans);
    return 0;
}




Measured memory_bytes: 640
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  998244353ll
using namespace std;
int n,k;
ll c[4005][4005],ans[4005],b[2005];
int main(){
    cin>>k>>n;
    b[0]=1;
    for(int i=1;i<=2000;++i)b[i]=b[i-1]*2ll%orz;
    c[0][0]=1;
    for(int i=1;i<=4000;++i){
        c[i][0]=c[i][i]=1;
        for(int j=1;j<i;++j)c[i][j]=(c[i-1][j-1]+c[i-1][j])%orz;
    }
    for(int i=2;i<=k+1;++i){
        int o=(i-1)/2,p=k-i+1;
        for(int j=0;j<=o;++j)(ans[i]+=b[j]*c[o][j]%orz*c[n+p-1][j+p-1])%=orz;
        if(i%2==0){
                for(int j=0;j<=o;++j)(ans[i]+=b[j]*c[o][j]%orz*c[n+p-2][j+p-1])%=orz;
        }
        ans[k*2+2-i]=ans[i];
    }
    for(int i=2;i<=k*2;++i)cout<<ans[i]<<endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 123776
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)

#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long ll;
const int N = 3e5+1 , M = 5e5+1, OO = 0x3f3f3f3f,MOD = 1e9+7;
char str[101];
ll memo[101][2][4];
int n,K;
ll solve(int j=0,bool valid=true,int k=K)
{
  if(j==n) return !k;
  if(k<0) return 0;
  ll &ret = memo[j][valid][k];
  if(~ret) return ret;
  ret = 0;
  int m = valid? str[j]-'0':9;
  for(int i=0;i<=m;++i)
  {
    int nwvld = valid && i==m ;
    int nwk= k - (i!=0);

    error(i,nwvld,nwk);
    ret+=solve(j+1,nwvld,nwk);
  
  }
  return ret;

}
int main()
{
  memset(memo,-1,sizeof memo);
  scanf("%s%d",str,&K);
  n=strlen(str);
  printf("%lld",solve());
  #ifdef _LOCAL_DEFINE  
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        r: i64,
    }
    let r = r as f64;
    println!("{}", r * 2. * std::f64::consts::PI);
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int i = 0;
	while (1) {
		if ((c + b * i) % a == 0) {
			cout << "YES" << endl;
			return 0;
		}
		i++;
		if (c + b * i > a*b) {
			cout << "NO" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  vector<string> ss = {"maerd", "remaerd", "esare", "resare"};
  string s; cin >> s;
  reverse(s.begin(), s.end());

  int idx = 0;
  while(idx < s.size()) {
    bool flg = false;
    for(string t:ss) {
      if(t == s.substr(idx, t.size())) {
        idx += t.size();
        flg = true;
        break;
      }
    }
    if(!flg) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 512
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

int main(int argc, char const *argv[]) {
    int n, k; cin >> n >> k;
    int x = 0, y = 0; 
    for(int i = 1; i <= n; ++i) {
        if(i % k == 0) ++x; 
        if(i % k == k / 2) ++y; 
    }

    if(k & 1) cout << (ll) x * x * x << endl;
    else cout << (ll)x*x*x + (ll)y*y*y << endl;
}

Measured memory_bytes: 256