akhauriyash/Code-Regression huggingface dataset:
///int ->(-2147483648<->2147483647)
///unsigned int(0<->4294967295)
///long long int (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
///unsigned long long int (0 to 18,446,744,073,709,551,615)
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<stack>
#include<cstring>
#include<iterator>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<iomanip> ///setprecision
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define OPEN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","r",stdin)
#define INF 1000000000
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define pdd pair<double,double>
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vd vector<double>
#define sci(value) scanf("%d%*c",&value)
#define scl(value) scanf("%lld%*c",&value)
#define pi  (2*acos(0))
#define pb push_back
#define valid(value123,value234,limitrow,limitcol) value123>=0&&value123<limitrow&&value234>=0&&value234<limitcol
//int fx[]= {0,0,1,-1,-1,1,-1,1};//kings move
//int fy[]= {1,-1,0,0,-1,1,1,-1};//kings move
//int fx[]={-2,-2,-1,-1, 1,1, 2,2};  // Knights Move
//int fy[]={-1, 1,-2, 2,-2,2,-1,1}; // Knights Move
//ll powFunction(ll a,ll b){if(b==0)return 1;ll re=powFunction(a,b/2);re=(re*re);if(b&1)re=(re*a);return re;}
///ll digitSum(ll a){ll ans=0;while(a){ans+=(a%10);a/=10;}return ans;}

#define MX 100005
#define mod 1000000007
ll dp[102][MX],MAX=10000000000000;
ll n,knapsack,a,b;
vector<pll>vec;
bool state[102][MX];
ll minimumweight(ll i,ll value)
{
    if(value<=0)
        return 0;
    if(i==n)
        return MAX;
    if(state[i][value])
        return dp[i][value];
    state[i][value]=1;
    ll q1=MAX,q2=MAX;
    q1=minimumweight(i+1,value);
    q2=minimumweight(i+1,value-vec[i].second)+vec[i].first;

    return dp[i][value]=min(q1,q2);
}

int main()
{
   for(int i=0;i<102;i++)
   {
       for(int j=0;j<MX;j++)
       {
           dp[i][j]=MAX;
       }
   }
    scl(n),scl(knapsack);

    ll val=0;
    for(int i=0;i<n;i++)
    {
        scl(a),scl(b);
        vec.push_back({a,b});
        val+=b;
    }
    for(ll i=val;i>=1;i--)
    {
        if(minimumweight(0,i)<=knapsack)
        {
            printf("%lld\n",i);
            break;
        }
    }
    return 0;
}




Measured memory_bytes: 89856
#include<bits/stdc++.h>
#include<algorithm>
#include<set>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stack>
using namespace std;
typedef long long int ll;
const int MOD=1e9+7;
// power function with a^b 
ll power(ll a, ll b){
    ll ans=1;
    while(b>0){
        if(b%2!=0)
        ans=ans*a;

        b/=2;
        a=a*a;
    }
    return ans;
}
// power function with modulo i.e (a^b)%mod
ll powermod(ll a,ll b, ll mod){
    ll ans=1;
    a=a%mod;
    if(a==0) return 0;
    while(b>0){
        if(b%2!=0)
        ans=(ans*a)%mod;

        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}
ll fact(ll n){
    ll ans=1;
    for(int i=n; i>=1; i--){
        ans*=i;
    }
    return ans;
}
int solve(){
   ll n;
   cin>>n;
   ll a[n],b[n],c[n];
   for(int i=0; i<n; i++){
       cin>>a[i]>>b[i]>>c[i];
   }
   ll dp[n][3];
   dp[0][0]=a[0];
   dp[0][1]=b[0];
   dp[0][2]=c[0];
   for(int i=1; i<n; i++){
       dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
       dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
       dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
   }
   return *max_element(dp[n-1],dp[n-1]+3);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    //ll tc;
    //cin >> tc;
    //for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        ll ans=solve();
        cout<<ans<<"\n";
    //}
}


Measured memory_bytes: 8268
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://onlinejudge.u-aizu.ac.jp/challenges/search/volumes/0300>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

bool check(vector<ll>& p){
    ll t = p[1];
    for(int i = 1; i <= 9;i++){
        if(t != p[i]) return false;
    }
    t = p[10];
    for(int i = 10; i <= 12;i++){
        if(t != p[i]) return false;
    }
    t = p[13];
    for(int i = 13; i <= 15;i++){
        if(t != p[i]) return false;
    }
    t = p[16];
    for(int i = 16; i <= 18;i++){
        if(t != p[i]) return false;
    }
    t = p[19];
    for(int i = 19; i <= 21;i++){
        if(t != p[i]) return false;
    }
    t = p[22];
    for(int i = 22; i <= 30;i++){
        if(t != p[i]) return false;
    }
    return true;
}

vector<ll> mode1(vector<ll> p){
    swap(p[7],p[22]);
    swap(p[8],p[23]);
    swap(p[9],p[24]);
    
    swap(p[18],p[13]);
    
    swap(p[10],p[12]);
    return p;
}
vector<ll> mode2(vector<ll> p){
    swap(p[1],p[28]);
    swap(p[2],p[29]);
    swap(p[3],p[30]);
    
    swap(p[15],p[16]);
    
    swap(p[19],p[21]);
    return p;
}
vector<ll> mode3(vector<ll> p){
    swap(p[1],p[24]);
    swap(p[4],p[27]);
    swap(p[7],p[30]);
    
    swap(p[10],p[21]);
    
    swap(p[16],p[18]);
    return p;
}
vector<ll> mode4(vector<ll> p){
    swap(p[3],p[22]);
    swap(p[6],p[25]);
    swap(p[9],p[28]);
    
    swap(p[12],p[19]);
    
    swap(p[13],p[15]);
    return p;
}
void rec(ll dep,vector<ll> p,ll& res){
    if(dep == 9) return;
    if(check(p)){
        res = min(res,dep);
        return;
    }
    rec(dep+1,mode1(p),res);
    rec(dep+1,mode2(p),res);
    rec(dep+1,mode3(p),res);
    rec(dep+1,mode4(p),res);
}
ll solve(){
    ll res = LINF;
    vector<ll> p(31);
    for(int i = 1; i <= 30;i++) cin >> p[i];
    rec(0,p,res);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll T; cin >> T;
    while(T--){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int r, g;
  cin >> r >> g;
  cout << 2*g - r << endl;
  return 0;
}

Measured memory_bytes: 256
//In The Name Of Godd
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef pair<ll, ll> ii;
typedef pair<int, ii> iii;
typedef pair<double, double> dd;
typedef pair<dd, double> ddd;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<dd> vdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;

#define forn(i, n) for (ll i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define inf 100000000000
#define eps 1e-9
const int maxn = 1010;
const int mod = 1e9 + 7;
string grid[maxn];
ll dp[maxn][maxn];

void add(ll &a, ll b) {
  (a += b) %= mod;
}

int main() {
  ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  forn(i, h) cin >> grid[i];
  dp[0][0] = 1;
  forn(i, h) forn(j, w) if(i != 0 || j != 0) {
    if(grid[i][j] == '#') continue;
    if(i - 1 >= 0) add(dp[i][j], dp[i - 1][j]);
    if(j - 1 >= 0) add(dp[i][j], dp[i][j - 1]);
  }
  cout << dp[h - 1][w - 1] % mod << endl;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//-----------------------------------------------------------

ll gcd(ll a,ll b) {
    ll r;
    if(a<b) swap(a,b);
    while((r=a%b)!=0) a=b,b=r;
    return b;
}
int main(int argc, char const *argv[]) {
    ll N,X;
    cin>>N>>X;
    cout<<3*(N-gcd(N,X))<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int P, Q, R;
    cin >> P >> Q >> R;
    cout << min({P+Q,Q+R,R+P,}) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(register int i = x ;i <= y; ++ i)
#define repd(i,x,y) for(register int i = x; i >= y; -- i)
using namespace std;
typedef long long ll;
template<typename T>inline bool chkmin(T&x,T y) { return x > y ? x = y , 1 : 0; }
template<typename T>inline bool chkmax(T&x,T y) { return x < y ? x = y , 1 : 0; }
template<typename T>inline void read(T&x)
{
    x = 0;char c;int sign = 1;
    do { c = getchar(); if(c  == '-') sign = -1; }while(!isdigit(c));
    do { x = x * 10 + c - '0'; c = getchar(); }while(isdigit(c));
    x *= sign;
}

const int N = 6e5+500;
int tot,head[N],nxt[N],to[N],val[N];
int n,m,d[N];
bool vis[N];

inline void add(int x,int y,int w)
{
    val[tot] = w;
    to[tot] = y;
    nxt[tot] = head[x];
    head[x] = tot++;
}

bool dfs(int x)
{
    vis[x] = 1;
    for(register int i = head[x];~i ; i = nxt[i])
        if(chkmin(d[to[i]],d[x] + val[i]))
        {
            if(vis[to[i]]) return false;
            if(!dfs(to[i])) return false;
        }
    vis[x] = 0;
    return true;
}

int main()
{
    memset(d,0x3f,sizeof d);
    memset(head,-1,sizeof head);
    read(n); read(m);
    rep(i,1,m)
    {
        int a,b,c;
         read(a); read(b);read(c);
        add(a,b,c),add(b,a,-c);
    }
    
    rep(i,1,n)
        add(0,i,1);
    
    d[0] = 0;
    puts(dfs(0)?"Yes":"No");
    
    return 0;
}

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

int main() {

  ll N;
  cin >> N;

  vector<ll> A(N);
  ll sum = 0;
  const ll mod = 1000000007;

  for(ll i = 0; i < N; i++){
    cin >> A[i];
    sum += A[i];
    sum = sum % (2 * mod);
  }

  ll ans = 0;
  for(ll i = 0; i < N; i++){
    if(sum > A[i]){
      ans += A[i] * (sum - A[i]);
    }else{
      ans += A[i] * (sum + 2 * mod - A[i]);
    }
    ans = ans % (2 * mod);
  }

  ans = ans / 2;
  ans = ans % mod;

  cout << ans << endl;
}

Measured memory_bytes: 4828
#include<stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d",&a ,&b);
    if((a+b)%2==0){
    c=(a+b)/2;
    }else{
        c=((a+b)/2)+1;
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

int main(){

	map<string,int> table;
	int num;
	char cm;
	string type;

	table["A"]=0;
	table["B"]=0;
	table["AB"]=0;
	table["O"]=0;
	while(cin>>num>>cm>>type){
		table[type]++;
	}
	cout<<table["A"]<<endl;
	cout<<table["B"]<<endl;
	cout<<table["AB"]<<endl;
	cout<<table["O"]<<endl;

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  string p;
  string q;
  char c;
  rep(i, n){
    cin >> c;
    p += c;
  }
  rep(i, n){
    cin >> c;
    q += c;
  }

  string s;
  rep(i, n) s += ((i + 1) + '0');
  vector<string> vs;
  do {
    vs.push_back(s);
  } while(next_permutation(s.begin(), s.end()));
  sort(vs.begin(), vs.end());
  auto fact = [](int k) {
    int f = 1;
    rep(i, k){
      f *= (i + 1);
    }
    return f;
  };
  int a, b;
  rep(i, fact(n)){
    if (vs[i] == p) a = i;
    if (vs[i] == q) b = i;
  }
  cout << abs(a - b) << endl;
  return 0;
}

Measured memory_bytes: 5364
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int m[30];
int w[30];
int dp[13][1<<12];
int ABS(int a){return max(a,-a);}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)scanf("%d",m+i);
		for(int i=0;i<b;i++)scanf("%d",w+i);
		for(int i=0;i<13;i++)for(int j=0;j<(1<<12);j++)
			dp[i][j]=-999999999;
		dp[0][0]=0;
		for(int i=0;i<a;i++){
			for(int j=0;j<(1<<b);j++){
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
				for(int k=0;k<b;k++){
					if(j&(1<<k))continue;
					dp[i+1][j+(1<<k)]=max(dp[i+1][j+(1<<k)],dp[i][j]+ABS(m[i]-w[k])*(ABS(m[i]-w[k])-30)*(ABS(m[i]-w[k])-30));
				}
			}
		}
		int ret=0;
		for(int i=0;i<(1<<b);i++)ret=max(ret,dp[a][i]);
		printf("%d\n",ret);
	}
}

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

int main(int argc, char const *argv[])
{
    int N[3];
    cin >> N[0] >> N[1] >> N[2];
    sort(N, N+3, greater<int>());
    int ans = 10*N[0]+N[1]+N[2];
    std::cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
// ver1.8
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n;
  cin >> n;
  int ans=0;
  int pre,now;
  cin >> now;
  ans += now;
  rep(i,0,n-2){
    pre = now;
    cin >> now;
    ans += min(pre,now);
  }
  ans += now;
  cout << ans << endl;
  return 0;
}


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

int main(){
    string S, T;
    cin >> S >> T;
    string T2 = T.substr(0, S.size());
    if(S == T2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
mae = -1
for i in range(n):
    a = A[i]
    ans += B[a-1]
    if a - 1 == mae:
        ans += C[mae-1]
    mae = a
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
////////////////////////////////////////////////////////////////////
int main()
{
    int a,b;
    cin >> a >> b;

    if(a<=5) cout << 0 << endl;
    else if(a<=12) cout << int(b/2) << endl;
    else cout << b << endl;

    return 0;

}


Measured memory_bytes: 256
from heapq import heappop,heappush
n,m = map(int,input().split())
lst = [[int(i) for i in input().split()] for _ in range(n)]
PQ = []
idx = 0
ans = 0
lst.sort(key = lambda x:x[0])
for i in range(1,m+1):
    while idx < n and lst[idx][0] <= i:
        heappush(PQ,-(lst[idx][1]))
        idx += 1
    if PQ: ans -= heappop(PQ)
print(ans)

Measured memory_bytes: 25736
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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



int N;
using Graph = vector<vector<Edge>>;
vector<bool> seen;
vector<int> color;

void dfs (Graph& g, int point, int col) {
  // cout << point << " ";

  seen[point] = true;
  color[point] = col;

  for (auto next_pair : g[point]) {
    int to = next_pair.to;
    ll d = next_pair.weight;

    if (seen[to]) continue;

    if (d % 2 == 0) {
      dfs(g, to, col);
    } else {
      dfs(g, to, (col+1)%2);
    }
  }
}

int main () {
  cin >> N;
  Graph G(N+1);

  Rep(i, N-1) {
    int u, v;
    ll w;

    cin >> u >> v >> w;

    G[u].push_back(Edge(v, w));
    G[v].push_back(Edge(u, w));
  }

  color.assign(N+1, 0);
  seen.assign(N+1, false);
  dfs(G, 1, 0);

  rep(i, N) {
    cout << color[i] << "\n";
  }
}

Measured memory_bytes: 10496
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */

    int n = sc.nextInt();

    os.println(180 * (n - 2));
  }
}

Measured memory_bytes: 20688
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N, M, Q = map(int, input().split())
    r_list = []
    for i in range(Q):
        r_list.append(list(map(int, input().split())))
    max_score = 0
    a1 = 1
    for a2 in range(a1, M+1):
        for a3 in range(a2, M+1):
            for a4 in range(a3, M+1):
                for a5 in range(a4, M+1):
                    for a6 in range(a5, M+1):
                        for a7 in range(a6, M+1):
                            for a8 in range(a7, M+1):
                                for a9 in range(a8, M+1):
                                    for a10 in range(a9, M+1):
                                        a_list = [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10]
                                        score = 0
                                        for r in r_list:
                                            if a_list[r[1]-1] - a_list[r[0]-1] == r[2]:
                                                score += r[3]
                                        max_score = max(score, max_score)
    print(max_score)

if __name__ == "__main__":
    main()




Measured memory_bytes: 68956
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	int turn=0;
	int ans;
	char buf;
	while(1)
	{
		if(turn%2==0)
		{
			int k;
			cin >> k;
			if(turn==0)
			{
				ans=k;
				goto end;
			}
			switch(buf)
			{
				case '+':ans+=k;break;
				case '-':ans-=k;break;
				case '*':ans*=k;break;
				case '/':ans/=k;break;
			}
		}
		else
		{
			cin >> buf;
			if(buf=='=')break;
		}
		end:;
		turn++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1160
function main(input) {
  input = input.trim();
  const [a,b] = input.split(" ").map(Number);
  const x = [1,3,5,7,8,10,12];
  const y = [4,6,9,11];
  const z = [2];
  if((x.includes(a)&&x.includes(b))||(y.includes(a)&&y.includes(b))||(z.includes(a)&&z.includes(b))){
    console.log("Yes");
  }else{
    console.log("No");
  }
    
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30340
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iomanip>


int main()
{
	double x1,y1, x2,y2;
	
	std::cin >> x1 >> y1 >> x2 >> y2;
	
	std::cout << std::setprecision(10) << sqrt(pow(x1-x2,2)+ pow(y1-y2, 2)) << std::endl;
	
	return 0;
}




Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
# ifdef DEB
# define debug(...) fprintf(stderr, __VA_ARGS__)
# else
# define debug(...)
#endif
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LL long long
#define LD long double
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define pb pop_back
#define VI vector<int> 
#define VPI vector<PII> 
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define ALL(x) (x).begin(), (x).end()
#define siz(V) ((int)V.size())
const int M = 500005;

int n, m, q;
int T[M], mi[M];
bool B[M];

int main()
{
  //ios_base::sync_with_stdio(0);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
  {
    scanf("%d", T + i);
  }
  mi[n] = 1;
  for (int i = n - 1; i >= 0; i--)
  {
    if (T[i] >= 2 * mi[i + 1])
    {
      mi[i] = mi[i + 1];
    }
    else
    {
      mi[i] = mi[i + 1] + T[i];
    }
    //printf("%d: %d\n", i, mi[i]);
  }
  for (int i = 0; i < n; i++)
  {
    if (mi[i + 1] <= m)
    {
      B[i] = true;
    }
    m = min(m, abs(m - T[i]));
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++)
  {
    int a;
    scanf("%d", &a);
    if (B[a - 1])
    {
      printf("YES\n");
    }
    else
    {
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 6272
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

h = Hash.new(0)
sum = 0

a.each do |e|
    h[e] += 1
end

if h.size <= k then
    puts "0"
exit 
end


H = h.sort_by { |_, v| v }

(h.size - k).times do |i|
    sum += H[i][1]
end

puts sum




Measured memory_bytes: 41472
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a+b>c+d)printf("Left\n");
	else if(a+b<c+d)printf("Right\n");
	else printf("Balanced\n");
	return 0;
}


Measured memory_bytes: 128
<?php
$stdin = trim(fgets(STDIN));
$num = explode(' ', $stdin);
if ($num[0] > $num[1]) {
    echo 'a > b'. "\n";
} elseif ($num[0] == $num[1]) {
    echo 'a == b'. "\n";
} else {
    echo 'a < b' . "\n";
}

Measured memory_bytes: 15312
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

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

	return 0;
}


Measured memory_bytes: 256
s = gets.chomp
n = s.length

correct = "Yes"
(n/2).times do |i| 
 if s[i] != s[(n/2)-1-i] ||
   s[n-1-i] != s[(n/2)+1+i] ||
   s[n-1-i] != s[i]
  correct = "No" 
  break
 end
end

puts correct

Measured memory_bytes: 1788
#include <iostream>
#include <cmath>

int solve(int window_width, int curtain_width)
{
    return std::max(0, window_width - 2 * curtain_width);
}

int main()
{
    int a, b;
    std::cin >> a >> b;
    std::cout << solve(a, b) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	int ll = max(a, c);
	int rr = min(b, d);
	if (rr >= ll) {
		cout << rr - ll << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
int a[MAXN],b[MAXN];

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d%d",&a[i],&b[i]);
	ll ret=0;
	for(int i=n-1;i>=0;--i) {
		ll cur=a[i]+ret;
		ll rem=cur%b[i];
		//printf("%d: cur=%lld rem=%lld\n",i,cur,rem);
		if(rem!=0) ret+=b[i]-rem;
	}
	printf("%lld\n",ret);
}

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


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

int N,i,j,k,c,t,R;
double P[100][2],y,x,p[2];
int dis(double a[2],double b[2])
{
	double x=a[0]-b[0],y=a[1]-b[1];
	return (x*x+y*y<=1.001)?1:0;
}

int main()
{
	for(;scanf("%d",&N),N;)
	{
		R=1;
		for(i=0;i<N;i++)
			scanf("%lf,%lf",&P[i][0],&P[i][1]);
		for(p[0]=0;p[0]<10.1;p[0]+=0.01)
			for(p[1]=0;p[1]<10.1;p[1]+=0.01)
			{
				for(i=t=0;i<N;i++)
					if(dis(p,P[i]))
						t++;
				R=t>R?t:R;
			}
		printf("%d\n",R);
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
#define Inf 123372036854775806ll
using namespace std;

string A[55];
string B[55];

int main() {
    int N,M;
    cin>>N>>M;
    for(int i=0;i<N;i++)
        cin>>A[i];
    for(int i=0;i<M;i++)
        cin>>B[i];
    bool yes=false;
    for(int i=0;i+M-1<=N-1;i++)
        for(int j=0;j+M-1<=N-1;j++) {
            bool ok=true;
            for(int x=i;x<=i+M-1;x++)
                for(int y=j;y<=j+M-1;y++)
                    ok &= (A[x][y]==B[x-i][y-j]);
            if (ok)
                yes=true;
        }
    if (yes) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 120
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e9 + 7;

int main (){
    ios_base::sync_with_stdio(false);
    int h, w;
    char m[MAXN][MAXN];
    cin >> h >> w;

    for (int i=1; i<=h; i++){
        for (int j=1; j<=w; j++){
            cin >> m[i][j];   
        }
    }

    for (int i=1; i<=2*h; i++){
        for (int j=1; j<=w; j++){
            cout << m[(i+1)/2][j];   
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;

int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;


//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        int d1 = n/100;
        n -=d1*100;
        int d2=n/10;
        n -= d2*10;
        if ((d1==7) || (d2==7) || (n==7)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


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

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

  if(a > k){
    cout << a - k << " " << b << endl;
  }
  else{
    if(b > (k - a)){
      cout << 0 << " " <<  b - (k - a) << endl;
    }
    else{
      cout << 0 << " " << 0 << endl;
    }
  }
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	readInt := func() int {
		sc.Scan()
		ans, _ := strconv.Atoi(sc.Text())
		return ans
	}
	n := readInt()
	al := make([]int, n)
	for i := 0; i < n; i++ {
		al[i] = readInt()
	}
	sort.Ints(al)

	alice := 0
	turn := true
	for i := n - 1; i >= 0; i-- {
		if turn {
			alice += al[i]
			turn = false
		} else {
			alice -= al[i]
			turn = true
		}
	}
	fmt.Println(alice)
}


Measured memory_bytes: 640
n,m = map(int,input().split(' '))
cost = 0
count = 0

mlist = list()
for i in range(n):
  mlist.append(list(map(int,input().split(' '))))
mlist.sort(key=lambda x: x[0])

for i in range(n):
  ablist = mlist[i]
  if count+ablist[1] <= m:
    count += ablist[1]
    cost += ablist[0]*ablist[1] 
  else:
    for j in range(ablist[1]):
      count += 1
      if count <= m:
        cost += ablist[0]
      else:
        break_t = True
        break
    if break_t:
      break
print(cost)



Measured memory_bytes: 29024
// Problem : B - Magic 2
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int cnt = 0;
    while(b <= a) b *= 2, cnt++;
    while(c <= b) c *= 2, cnt++;
    if(cnt <= k) cout<<"Yes\n";
    else cout<<"No\n";
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3632
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N;
string s[200010];
string s2[200010];
int a[26];

int main() {
	cin >> N;
	REP(i, N) cin >> s[i];
//	sort(s, s + N);
//	REP(i, N) cout << s[i] << endl;
	REP(i, N) {
//		REP(j, 26) a[j] = 0;
		REP(j, 10) {
			a[s[i][j] - 'a']++;
		}
		int k = 0;
		REP(j, 26) {
//			if (k == 10) break;
			while (a[j] > 0)
			{
//				if (k == 10) break;
				a[j]--;
				char c = 'a' + j;
				s2[i] += c;
				k++;
			}
		}
	}
	sort(s2, s2 + N);

//	cout << endl;
//	REP(i, N) cout << s2[i] << endl;
	
	ll n = 1;
	ll ans = 0;
//	s2[N] = "Owariowari";
	REP(i, N - 1) {
		if (s2[i + 1] == s2[i]) {
			n++;
		}
		else {
			ans += n * (n - 1) / 2;
			n = 1;
		}
	}
	ans += n * (n - 1) / 2;
	cout << ans << endl;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll n, ans = 0, val ;
    cin >> n ;
    for (int i = 1; i <= n; i++) {
        cin >> val ;
        if (i % 2 != 0 and val % 2 != 0)    ans++ ;
    }
    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;


/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> E(n + 2), W(n + 2);
    E[0] = 0; W[n + 1] = 0;
    rrep(i, n) {
        if(s[i - 1] == 'E') E[i] = E[i - 1] + 1;
        else E[i] = E[i - 1];
    }
    for(int i = n; i > 0; i--) {
        if(s[i - 1] == 'W') W[i] = W[i + 1] + 1;
        else W[i] = W[i + 1];
    }
    int ans = INF;
    rrep(i, n) {
        int minv;
        minv = (E[n] - E[i]) + (W[1] - W[i]);
        ans = min(minv, ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int N;
  cin>>N;
  long int a[N][3],dp[N][3],ans;
  for(int i=0;i<N;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  
  dp[0][0]=a[0][0];
  dp[0][1]=a[0][1];
  dp[0][2]=a[0][2];
  
  for(int i=1;i<N;i++)
  {
    dp[i][0]=max(dp[i-1][1],dp[i-1][2]) + a[i][0];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2]) + a[i][1];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0]) + a[i][2];
  }
  
  ans=dp[N-1][0];
  ans=max(ans,dp[N-1][1]);
  ans=max(ans,dp[N-1][2]);
  
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 4864
#include <stdio.h>
int main(void){
    long long int x;
    long long int ans=0;
    scanf("%lld",&x);
    ans+=x/11;
    x%=11;
    if(x==0)printf("%lld",2*ans);
    else if(x<=6)printf("%lld",2*ans+1);
    else printf("%lld",2*ans+2);
    return 0;
}

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

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

    int judge = 0;

    for(int i=A;i<=B;i++) {
        if(i%K==0) {
            judge = 1;
            break;
        }
    }

    if(judge==1) {
        cout << "OK" << endl;

    } else {
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int a;
    bool b[3][3]={};
    pair<int,int> v[101]={};
    Fr(i,3) Fr(j,3) in>>a,v[a]=make_pair(i,j);
    int n;
    in>>n;
    fr(i,n){
        in>>a;
        if(v[a].first){
            b[v[a].first-1][v[a].second-1]=true;
        }
    }
    bool f=false;
    fr(i,3){
        bool g=true;
        fr(j,3) if(!b[i][j]) g=false;
        if(g) f=true;
    }
    fr(j,3){
        bool g=true;
        fr(i,3) if(!b[i][j]) g=false;
        if(g) f=true;
    }
    bool g=true;
    fr(i,3) if(!b[i][i]) g=false;
    if(g) f=true;
    g=true;
    fr(i,3) if(!b[i][2-i]) g=false;
    if(g) f=true;
    puts(f?"Yes":"No");
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define INF 100000000000000
using namespace std;
//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す


int main() {
    string s;
    vector<long long> result;
    long long sum;
    char number;
    while(1){
        getline(cin, s);
        sum = 0;
        if(s.size()==1 && atoi(&s.at(0))==0){
            break;
        }
        for(int i=0; i<s.size(); i++){
            number = s.at(i);
            sum = sum + atoi(&number);
        }
        result.push_back(sum);
    }

    for(int i=0; i<result.size(); i++){
        cout << result.at(i) << endl;
    }
}


Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>


using namespace std;

struct work {long a, b;};

int main() {
    int n;
    cin >> n;
    work w[n];
    for (auto &wi:w) cin >> wi.a >> wi.b;
    sort(w, w+n, [](work l, work r) {
        return l.b < r.b || (l.b == r.b && l.a > r.a);
    });
    long t = 0;
    for (auto wi:w) {
        t += wi.a;
        if (t > wi.b) {
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << '\n';
    return 0;
}


Measured memory_bytes: 3456
n, y = [int(i) for i in input().split()]
flag = 0

for i in range(n+1):
    for j in range(n+1-i):
        for k in range(n-i-j, n+1-i-j):
            if 10000*i + 5000*j + 1000*k == y:
                flag = 1
                break
        else:
            continue
        break
    else:
        continue
    break

if flag == 1:
    print(i, j, k)
else:
    print(-1, -1, -1)


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    string s, t;
    cin >> s >> t;

    int ans = 0;
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

    int x;
    cin>>x;

    cout<<x/500*1000+(x%500)/5*5<<endl;


}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

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

	int n; cin >> n;

	vector<int> a(n, 0), b(n, 0), c(n, 0);

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

	vector<int> dp = {a[0], b[0], c[0]};
	
	for(int i = 1; i < n; i++) {
		int x = dp[0], y = dp[1], z = dp[2];
		dp[0] = a[i] + max(y, z);
		dp[1] = b[i] + max(z, x);
		dp[2] = c[i] + max(x, y);
	}

	cout << max(dp[0], max(dp[1], dp[2])) << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
using namespace std;
int main(void){
int n,d,x;
cin>>n>>d>>x;
vector<int> a(n);
for(int i=0;i<n;i++){
	cin>>a[i];
	x+=1+(d-1)/a[i];
}
cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(c>=a && c<=b) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		sc.close();

	}

}

Measured memory_bytes: 21716
//code by PARTH_4399 for competitive programming
#include<bits/stdc++.h>

using namespace std;

#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define vl vector<ll int>
#define pl pair<ll int,ll int>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll MOD = 1e9 + 7;
const double pie = 3.141592653589793;

#define setcount(x) __builtin_popcount(x) // counts set bits
#define parity(x) __builtin_parity(x) // checks parity of the number
#define lzcount(x) __builtin_clz(x) // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x) // count trailing zeros in binary representation of number

template<typename T> T inf() { return (T)__builtin_inf();} // syntax for use inf<datatype>();
template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M) { return ( mod(a,M ) + mod(b,M ))%M; }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M; }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

/************************** main program **************************/

int main()
{
	FASTIO
	//code
	ll int n;
	cin>>n;
	cout<<(n*(n-1))/2;
	return 0;
}

Measured memory_bytes: 256
a = input()
b = input()
c = input()

sa = []
sb = []
sc = []
for i in range(len(a)):
    sa.append(a[i])
for j in range(len(b)):
    sb.append(b[j])
for k in range(len(c)):
    sc.append(c[k])

tmp = sa.pop(0)    
ans = ""
for i in range(len(a)+len(b)+len(c)):
    if tmp == "a":
        if sa:
            tmp = sa.pop(0)
        else:
            ans = "A"
    elif tmp =="b":
        if sb:
            tmp = sb.pop(0)
        else:
            ans = "B"
    elif tmp =="c":
        if sc:
            tmp = sc.pop(0)
        else:
            ans = "C"
print(ans)

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

    cout<<max(arr[n-1][0] , max(arr[n-1][1] , arr[n-1][2]));
}



Measured memory_bytes: 1408
import sys
input = sys.stdin.readline
#n = int(input()) 
w,h,x1,y1 = (int(i) for i in input().split())

if w/2==x1 and h/2==y1:
    ans1=w*h/2
    ans2=1
else:
    ans1=w*h/2
    ans2=0    
    
print(ans1,ans2)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
double n;
int main(){
    cin>>n;
    printf("%f\n",(n/3)*(n/3)*(n/3));
    return 0;
}

Measured memory_bytes: 256