akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1e9 + 7
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
bool check(string ss) {
    ll n = ss.size();
    bool ans = true;
    for(int i = 0; i < n / 2; ++i) {
        if(ss[i] != ss[n - i - 1]) {
            ans = false;
            break;
        }
    }
    return ans;
}
int main() {
    string ss;
    cin >> ss;
    ll sz = ss.size();
    if(check(ss) && check(ss.substr(0, sz / 2)) && check(ss.substr(sz / 2 + 1, sz / 2)))
         cout << "Yes";
    else
         cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
str s,t;
int main(){

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin>>n;
    cin>>s;
    cin>>t;
    for(int i=0;i<s.size();i++) cout<<s[i]<<t[i];
    cout<<newl;
}


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

using namespace std;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int X = tx - sx, Y = ty - sy;
    for (int i = 0; i < Y; i++)
        cout << 'U';
    
    for (int i = 0; i < X; i++)
        cout << 'R';

    for (int i = 0; i < Y; i++)
        cout << 'D';

    for (int i = 0; i < X + 1; i++)
        cout << 'L';

    for (int i = 0; i < Y + 1; i++)
        cout << 'U';

    for (int i = 0; i < X + 1; i++)
        cout << 'R';

    cout << "DR";
    
    for (int i = 0; i < Y + 1; i++)
        cout << 'D';

    for (int i = 0; i < X + 1; i++)
        cout << 'L';

    cout << "U\n";

    return 0;   
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    ll H[N], P[N];
    pli p[N];
    rep(i, N){
        cin >> H[i] >> P[i];
        p[i] = pli(H[i]+P[i], i);
    }
    sort(p, p+N);
    ll dp[N+1][N+1];
    fill(dp[0], dp[N+1], INF);
    dp[0][0] = 0;
    rep(i, N){
        int k = p[i].second;
        rep(j, N+1) dp[i+1][j] =  dp[i][j];
        rep(j, N){
            if(dp[i][j] > H[k]) continue;
            chmin(dp[i+1][j+1], dp[i][j]+P[k]);
        }
    }
    int ans;
    rep(j, N+1) if(dp[N][j] != INF) ans = j;
    cout << ans << endl;
}

Measured memory_bytes: 195840
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
 
int main() {
    ll n;
    cin>>n;
    ll a,b;
    cin>>a>>b;
    
    int p=n%12;
    
    for(int i=1;i<=p;i++){
        if(i%2==1){
            a=a-b;
        }
        else{
            b=a+b;
        }
    }
    
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long
using  namespace std;
ll binpow(ll a, ll b,ll MOD) {
    ll res = 1;
    a%=MOD;
    while (b > 0) {
        if (b & 1)
            res = res * a %MOD;
        a = a * a%MOD;
        b >>= 1;
    }
    return res;
}
ll inv(ll n,ll p){
    return binpow(n,p-2,p);
}
ll cal_ncr(ll n,ll r,ll mod){
    ll res=1;
    for(ll i=n;i>n-r;i--){
        res*=i;
        res%=mod;
    }
    // cout<<res<<'\n';

    ll down=1;
    for(ll i=2;i<=r;i++){
        res*=inv(i,mod);
        res%=mod;
    }
    return res;
}
ll mod= 1000000007;
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    if(n==2){
        cout<<"0";
    }else{
        ll k = binpow(2,n,mod)-1-cal_ncr(n,a,mod)-cal_ncr(n,b,mod)+1000*mod;
        cout<<k%mod;
    }


    //cout<<cal_ncr(5,2,1000000007);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <cfenv>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
typedef long long ll;
int main() {
	ll N, M;
	cin >> N >> M;
	ll ans;
	if (N*2 >= M) {
		ans = M/2;
	}
	else {
		ll d = M - N * 2;
		ans = N + d / 4;
	}
	cout << ans;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n)cin >> a[i];
    //a[0]を正の数とした場合
    ll count = 0,ans = 0;
    REP(i,n){
        ans += a[i];
        if(i%2==0){
            if(ans>0)continue;
            else {
                count+=abs(ans)+1;
                ans = 1;
            }
        }
        else{
            if(ans<0)continue;
            else {
                count+=abs(ans)+1;
                ans = -1;
            }
        }
    }
    //a[0]を負の数とした場合
    ll count1 = 0,ans1 = 0;
    REP(i,n){
        ans1 += a[i];
        if(i%2!=0){
            if(ans1>0)continue;
            else {
                count1+=abs(ans1)+1;
                ans1 = 1;
            }
        }
        else{
            if(ans1<0)continue;
            else {
                count1+=abs(ans1)+1;
                ans1 = -1;
            }
        }
    }
    COUT(min(count,count1));
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
int ans=0,a[100],b[100];
bool niko[100];
vector<vector<int> > v(100);
void dfs(int n){
	if(a[n])return;
	a[n]=++ans;
	for(auto& i:v[n])dfs(i);
	b[n]=++ans;
	return;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(a,0,sizeof(a));
    int n;
    cin>>n;
    int k,c;
    for(int i=0;i<n;i++){
    	cin>>c>>k;
    	for(int j=0;j<k;j++){
    		cin>>c;
    		v[i].pb(--c);
    	}
    }
    for(int i=0;i<n;i++)sort(be(v[i]));
    for(int i=0;i<n;i++)dfs(i);
    for(int i=0;i<n;i++){
    	cout <<i+1<<" "<<a[i]<<" "<<b[i]<<endl; 
    }
    return 0;
}




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

int mod = 1e9+7;
int main(){
  string s;cin>>s;
  int k;cin>>k;
  vector< vector<int> > dp(k,vector<int>(2,0));
  dp[0][1] = 1;
  
  for(int i=0;i<s.length();++i){
    vector< vector<int> > currDP(k,vector<int>(2,0));
    for(int m=0;m<k;++m){ 
      for(int n=0;n<2;++n){
      // n == 1 equal 
      // n == 0 smaller
        for(int j=0;j<10;++j){
          if(j>(s[i]-'0') && (n==1)){
            break;
          }
          currDP[(m+j)%k][n&&j==(s[i]-'0')] += dp[m][n];
          currDP[(m+j)%k][n&&j==(s[i]-'0')] %= mod;
        }      
      }
    }
    dp = currDP;
  }
  
  int result = (dp[0][0]+dp[0][1])%mod;
  result--;
  
  if (result < 0){
    result = mod -1;
  }
  
  cout<<result<<endl;
  
  return 0;
}

Measured memory_bytes: 256
/*input

*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;

int main()
{
  ifalse;
  int n, d;
  cin >> n >> d;
  d = 2 * d + 1;
  int x = ceil(n * 1.0 / d);
  cout << x;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long N, std::vector<long long> T, long long M, std::vector<long long> P, std::vector<long long> X){
    REP(i, M) {
        long long ans = 0;
        REP(j, N) {
            if (j == P[i] - 1) ans += X[i];
            else ans += T[j];
        }
        cout << ans << '\n';
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    std::vector<long long> T(N);
    REP(i, N) cin >> T[i];
    long long M;
    cin >> M;
    std::vector<long long> P(M);
    std::vector<long long> X(M);
    REP(i, M) cin >> P[i] >> X[i];
    solve(N, std::move(T), M, std::move(P), std::move(X));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
//------------------------------------------------------------
ll n,ans=0;

void solve() {
  cin>>n;
  set<string> s;

  rep(i,0,n)
  {
    string item;
    cin>>item;

    s.insert(item);
  }

  print(s.size());

  return;
}


Measured memory_bytes: 19180
#include <bits/stdc++.h>
#define MAX (ll)(1e5 + 7)
#define INF (ll)(1e18)
#define MOD (ll)(998244353)

using namespace std;
using ll = long long;
using cd = complex<double>;

const ll bc = 18, nn = 51;

ll nck[nn][nn];

ll solve (ll n, ll k) {
	if (k > n || n < 0 || k < 0) {
		nck[n][k] = 0;
		return 0;
	}
	if (nck[n][k] != -1) {
		return nck[n][k];
	}
	nck[n][k] = solve (n - 1, k) + solve (n - 1, k - 1);
	return nck[n][k];
}

int main () {
	ll n, k, s, t, lim = 0;
	cin >> n >> k >> s >> t;
	vector<ll> ve, ev, v;
	ll x = (1 << bc) - 1;
	for (ll i = 0; i < n; i++) {
		ll vv;
		cin >> vv;
		if ((vv & s) >= s && (vv | t) <= t) {
			v.push_back (vv);
		}
	}
	if (s & t < s) {
		cout << "0\n";
		return 0;
	}
	for (ll xx : v) {
		ll val = 0, i = 0;
		for (ll j = 0; j < bc; j++) {
			if (((s >> j) & 1) != ((t >> j) & 1)) {
				val |= ((xx >> j) & 1) << i;
				i++;
			}
		}
		lim = i;
		ve.push_back (val);
	}
	n = ve.size ();
	for (ll i = 0; i <= n; i++) {
		for (ll j = 0; j <= k; j++) {
			nck[i][j] = -1;
		}
	}
	nck[0][0] = 1;
	for (ll i = 0; i <= n; i++) {
		for (ll j = 0; j <= k; j++) {
			solve (i, j);
		}
	}
	for (ll i = 0; i <= n; i++) {
		for (ll j = 2; j <= k; j++) {
			nck[i][j] += nck[i][j - 1];
		}
	}
	ll all = nck[n][k], cc[1 << bc] = {};
	for (ll i = 1; i < (1 << lim); i++) {
		ll an = 0;
		for (ll x : ve) {
			cc[i & x]++;
		}
		for (ll x : ve) {
			if (cc[i & x]) {
				an += nck [cc[i & x]][k];
			}
			cc[i & x] = 0;
		}
		all += ((__builtin_popcount (i) & 1) ? -an : an);
	}
	cout << all << "\n";
}


Measured memory_bytes: 5668
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


class BipartiteMatching:
    def __init__(self, N, M):
        self.N = N
        self.M = M
        self.pairA = [-1] * N
        self.pairB = [-1] * M
        self.edge = [[] for _ in range(N)]
        self.was = [0] * N
        self.iter = 0

    def add(self, s, t):
        self.edge[s].append(t)

    def _DFS(self, s):
        self.was[s] = self.iter
        for t in self.edge[s]:
            if self.pairB[t] == -1:
                self.pairA[s] = t
                self.pairB[t] = s
                return True
        for t in self.edge[s]:
            if self.was[self.pairB[t]] != self.iter and self._DFS(self.pairB[t]):
                self.pairA[s] = t
                self.pairB[t] = s
                return True
        return False

    def solve(self):
        res = 0
        while True:
            self.iter += 1
            found = 0
            for i in range(self.N):
                if self.pairA[i] == -1 and self._DFS(i):
                    found += 1
            if not found:
                break
            res += found
        return res


if __name__ == "__main__":
    N = int(input())
    AB = tuple(tuple(map(int, input().split())) for _ in range(N))
    CD = tuple(tuple(map(int, input().split())) for _ in range(N))
    match = BipartiteMatching(N + 5, N + 5)

    for i, (a, b) in enumerate(AB):
        for j, (c, d) in enumerate(CD):
            if a < c and b < d:
                match.add(i, j)
    print(match.solve())

Measured memory_bytes: 3064
#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);
	
	long long n, i, j, k, x;
	bool valid = true;

	cin >> n;
	while (n--) {
		cin >> x;
		if (x % 2 != 0) valid = false;
	}

	if (valid) cout << "second\n";
	else cout << "first\n";

	return 0;
}


Measured memory_bytes: 256
// -> limitless <- //
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define read(n) scanf ("%d", &n)
using namespace std;
typedef unsigned long long ll;
    const int N = 1e4 + 2;
    const int mod = 1e9 + 7;

int main()
{
    int n;
    read(n);
    int ans = 0, x = n;
    while(n){
        ans += n%10;
        n/=10;
    }
    printf("%s", (x%ans == 0 ?"Yes":"No"));
	return 0;
}


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

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 6;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 3;
const int SM = 1e3 + 7;
const double EPS = 3e-16;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	long long n; cin >> n;
	
	vector<long long> v(n);
	for(long long i = 0; i < n; i++){
		cin >> v[i];
	}

	sort(v.begin(), v.end());
	
	long long ans = 0;
	for(long long i = 0; i < n; i++){
		for(long long j = i + 1; j < n; j++){
			for(long long k = j + 1; k < n; k++){
				long long a = v[i], b = v[j], c = v[k]; 
				if(a < b + c && b < c + a && c < a + b){
					ans++;
				}
				else {
					break;
				}
			}
		}
	}
	
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())

cnt = 0
for n in range(1, len(str(N)) + 1):
    for c in itertools.product('753', repeat=n):
        c = ''.join(c)
        if '7' in c and '5' in c and '3' in c and int(c) <= N:
            cnt += 1
print(cnt)


Measured memory_bytes: 13444
// atcoder/arc080/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int h, w, n;
  while (cin >> h >> w >> n) {
    vec<int> a(n);
    cin >> a;

    vec<pair<int, int>> v;
    for (int i = 0; i < h; ++i) {
      if (i%2 == 0) {
        for (int j = 0; j < w; ++j) {
          v.push_back({i, j});
        }
      } else {
        for (int j = w-1; 0 <= j; --j) {
          v.push_back({i, j});
        }
      }
    }

    int g[h][w];
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (a.back() == 0) a.pop_back();
        --a.back();
        g[v.back().first][v.back().second] = a.size();
        v.pop_back();
      }
    }

    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (j) cout << ' ';
        cout << g[i][j];
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200001,INF=1<<30;

int par[MAX];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
    }
}

int root(int a){
    if(par[a]==a) return a;
    else return par[a]=root(par[a]);
}

void unite(int a,int b){
    if(root(a)!=root(b)) par[root(b)]=root(a);
}

bool check(int a,int b){
    return root(a)==root(b);
}



int main(){
    
    int N,K,L;cin>>N>>K>>L;
    vector<int> S(N),T(N);
    
    init(N);
    
    for(int i=0;i<K;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        unite(a,b);
    }
    
    for(int i=0;i<N;i++){
        S[i]=root(i);
    }
    
    init(N);
    
    for(int i=0;i<L;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        unite(a,b);
    }
    
    for(int i=0;i<N;i++){
        T[i]=root(i);
    }
    
    map<pair<int,int>,int> M;
    
    for(int i=0;i<N;i++){
        M[make_pair(S[i],T[i])]++;
    }
    
    for(int i=0;i<N;i++){
        if(i) cout<<" ";
        cout<<M[make_pair(S[i],T[i])];
    }
    
    cout<<endl;
    
}


Measured memory_bytes: 14336
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;
const ll INF = 1e18;
const int NODE_SIZE = 310;


int N,L;
int a[100010];
int mx;
int main(){
    cin>>N>>L;
    REP(i,0,N){
        cin>>a[i];
    }
    int ind;
    REP(i,0,N-1){
        if(mx < a[i]+a[i+1]){
            mx = a[i]+a[i+1];
            ind = i;
        }
    }
    if(mx >= L){
        p("Possible");
        REP(i,1,ind+1){
            p(i);
        }
        RREP(i,ind+1, N){
            p(i);
        }

    }
    else p("Impossible");

    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
struct segment_tree {
  public:
    int n, ht, N;
    vector<int> dat;
    segment_tree(int sz) {
      n = sz;
      ht = 1;
      N = 1;
      while (N < n) {
        ht++;
        N <<= 1;
      }
      dat.resize(2 * N, 0);
    }
    void add (int i, int x) {
      i += N;
      dat[i] += x;
      i >>= 1;
      for (; i; i >>= 1) {
        dat[i] = dat[2 * i] + dat[2 * i + 1];
      }
    }
    int getSum (int l, int r, int k = 1, int L = 0, int R = -1) {
      if (R == -1) R = N;
      if (R <= l || r <= L) {
        return 0;
      } else if (l <= L && R <= r) {
        return dat[k];
      } else {
        int C = (L + R) >> 1;
        return getSum(l, r, 2 * k, L, C) + getSum(l, r, 2 * k + 1, C, R);
      }
    }
};
int main() {
  int n, q;
  cin >> n >> q;
  segment_tree sgt(n);
  while (q--) {
    int c;
    cin >> c;
    if (c == 0) {
      int i, x;
      cin >> i >> x;
      sgt.add(--i, x);
    } else {
      int s, t;
      cin >> s >> t;
      cout << sgt.getSum(--s, t) << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 3800
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	long long N;
	scanf("%lld",&N);
	
	long long sum = 1;
	long long A[N];
	
	for(long long i=0;i<N;i++) {
		scanf("%lld",&A[i]);
		if(A[i] == 0){
			printf("0");
			return 0;
		}
	}
	for(long long i=0;i<N;i++){
		if(1000000000000000000/sum < A[i] ){
			printf("-1");
			return 0;
		}
		sum*=A[i];
	}
	
	printf("%lld",sum);
	return 0;			
}



Measured memory_bytes: 2512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define mod 1000000007
#define mod 998244353
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k,a,b;
    cin>>k>>a>>b;
    int i,flag=0;
    for(i=a;i<=b;i++)
    {
    	if(i%k==0)
    	{
    		flag=1;
    		break;
		}
	}
	if(flag==1)
	cout<<"OK";
	else
	cout<<"NG";

}

Measured memory_bytes: 3652
N = int(input())
arr = list(map(int, input().split()))
dp = [0 for _ in range(N)]

for i in range(1, N):
	if i == 1:
		dp[i] = abs(arr[i] - arr[i-1])
	else:
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]))
print(dp[-1])

Measured memory_bytes: 13980
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
static const int MAX = 200000;
int main(){
    int n,r[MAX];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> r[i];
    }

    int maxv = -2000000000;
    int minv = r[0];

    for(int i=1;i<n;i++){
        maxv = max(maxv, r[i]-minv);
        minv = min(minv, r[i]);
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3892
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    #define f(a) for (ll i = 0; i < a; i++)
    #define fio                  \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);


    int main()
    {
        string a,b;
        cin>>a>>b;
        int x=min(a.size(),b.size());
        int y=max(a.size(),b.size());
        if(a.size()<b.size())
        {swap(a,b);}

        int arr[y+1][x+1];
        for(int i=0;i<x+1;i++)
        {arr[0][i]=0;}
        for(int i=0;i<y+1;i++)
        {arr[i][0]=0;}

        for(int i=1;i<y+1;i++)
        {
            for(int j=1;j<x+1;j++)
                {if(a[i-1]==b[j-1]){arr[i][j]=arr[i-1][j-1]+1;}
                 else {arr[i][j]=max(arr[i-1][j],arr[i][j-1]);}
                }

        }


        // cout<<arr[x][y];


        vector<char>lcs;
        int j=x;
        for(int i=y;i>0;i--)
        {
            if((arr[i][j]==arr[i][j-1])&&(arr[i][j]!=arr[i-1][j])){j--;i++;continue;}
            if((arr[i][j]==arr[i-1][j-1]+1)&&(arr[i][j]!=arr[i-1][j])){lcs.push_back(b[j-1]);if(arr[i-1][j-1]==0){break;}j--;}
        }


        for(int i=(lcs.size()-1);i>=0;i--)
        {
            cout<<lcs[i];
        }

        return 0;
    }


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

using namespace std;

#define ll long long

struct UnionFind {
	vector< int > data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return (false);
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return (true);
	}

	int find(int k) {
		if (data[k] < 0) return (k);
		return (data[k] = find(data[k]));
	}

	int size(int k) {
		return (-data[find(k)]);
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	for (int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		uf.unite(x-1,y-1);
	}
	set<int> st;
	for (int i = 0; i < n; i++)
		st.insert(uf.find(i));
	cout << st.size() << endl;
	return 0;
}


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int s = number.nextInt();
		int h = s / 3600;
		int m = (s % 3600) / 60;
		s = s - (h * 3600 + m * 60);
		System.out.println(h + ":" + m + ":" + s);
	}
}



Measured memory_bytes: 26208
import statistics
N = int(input())
a = list(input().split())
a = [int(i) for i in a]
res = []
for i in range(min(int(statistics.mean(a)),int(statistics.median(a))), max(int(statistics.mean(a))+1,int(statistics.median(a))+1+1)):
    res.append(0)
    for j in a:
        res[-1] += (j-i)**2
print(min(res))

Measured memory_bytes: 5392
#include <stdio.h>
#define N 200

int main(){
  int i,j,n,m,k,a;
  int Adj[N][N];

  scanf("%d",&n);
  for( i=1 ; i<=n ; i++ ){
    for( j=1 ; j<=n ; j++){
      Adj[i][j]=0;
    }
  }

  for( i=1 ; i<=n ; i++ ){
    scanf("%d%d",&a,&m);
    for( j=1 ; j<=m ; j++){
      scanf("%d",&k);
      Adj[i][k] = 1;
    }
  }

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

      if( j == n )printf("%d",Adj[i][j]);
      else printf("%d ",Adj[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 684
import sys 

N,M  = map(int,input().split())
     
a = [[0 for i in range(2)] for j in range(M)]
b = [] 
c = []

for i in range(M):
  a[i][0] , a[i][1] = map(int,input().split())
  first, second = a[i][0],a[i][1]
  if first == 1:
    b.append(second)
  if second == N:
    c.append(first)

b_set = set(b)
c_set = set(c)

if list(b_set & c_set) is None or len(list(b_set & c_set)):
  res = ('POSSIBLE')
else:
  res = ('IMPOSSIBLE')

print(res)
  
  

Measured memory_bytes: 48584
A,B,K=map(int,input().split())
for i in range(K):
	if i%2==0:
		if A%2==1:
			A-=1
		A=A//2
		B+=A
	else:
		if B%2==1:
			B-=1
		B=B//2
		A+=B
print(A,end=" ")
print(B)

Measured memory_bytes: 2940
# include <algorithm>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <string>
# include <vector>

typedef long long ll;
using namespace std;

const ll mod = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    string s[h];
    int L[h][w];
    int R[h][w];
    int U[h][w];
    int D[h][w];
    for (int i = 0; i < h; i++) {
        fill(L[i], L[i] + w, 0);
        fill(R[i], R[i] + w, 0);
        fill(U[i], U[i] + w, 0);
        fill(D[i], D[i] + w, 0);
    }
    for (int i = 0; i < h; i++) cin >> s[i];
    for (int i = 0; i < h; i++) {
        for (int k = 0; k < w; k++) {
            if (s[i][k] == '.') {
                if (k == 0) {
                    L[i][k] = 1;
                } else {
                    L[i][k] = L[i][k-1] + 1;
                }
                if (i == 0) {
                    D[i][k] = 1;
                } else {
                    D[i][k] = D[i-1][k] + 1;
                }
            }
            if (s[h-1-i][w-1-k] == '.') {
                if (k == 0) {
                    R[h-1-i][w-1-k] = 1;
                } else {
                    R[h-1-i][w-1-k] = R[h-1-i][w-k] + 1;
                }
                if (i == 0) {
                    U[h-1-i][w-1-k] = 1;
                } else {
                    U[h-1-i][w-1-k] = U[h-i][w-1-k] + 1;
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int l = 0; l < w; l++) {
            if (s[i][l] == '.') {
                ans = max(ans, L[i][l] + R[i][l] + U[i][l] + D[i][l] - 3);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n,m,l;

    cin >> n >> m >> l;
    
    vector<vector<int> > matA(n, vector<int>(m));
    vector<vector<int> > matB(m, vector<int>(l));
    vector<vector<long int> > matC(n, vector<long int>(l,0));
    
    for(int row=0; row<n; row++){
        for(int column=0; column<m; column++){
            cin >> matA[row][column];
        }
    }
    
    for(int row=0; row<m; row++){
        for(int column=0; column<l; column++){
            cin >> matB[row][column];
        }
    }
    
    
    for(int i=0; i<l; i++){
        for(int j=0; j<n; j++){
            for (int k=0; k<m; k++){
                matC[j][i] += (matA[j][k]*matB[k][i]);
            }
        }
    }
    
    for(int row=0; row<n; row++){
        for(int column=0; column<l; column++){
            if(column!=l-1){
            cout << matC[row][column]<<' ';
            }else{
            cout << matC[row][column]<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 


int main() {
  int x; cin >> x;
  cout << (x ^ 1 ) << endl; 
  return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        String S = sc.next();
        String T = sc.next();
 
        System.out.println(solve(S, T) ? "Yes" : "No");
 
        sc.close();
    }
 
    static boolean solve(String S, String T) {
        return String.format("%s%s", S, S).contains(T);
    }
}

Measured memory_bytes: 21972
object Main {
  def main(args: Array[String]): Unit = {
    val piece_of_cakes = scala.io.StdIn.readLine.split(" ")
    if(piece_of_cakes(0).toInt <= 8 && piece_of_cakes(1).toInt <= 8) println("Yay!")
    else                                                             println(":(")
  }
}

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

using namespace std;

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

int data[100];
inline int root(int x) {
  return data[x] < 0 ? x : data[x] = root(data[x]);
}
typedef pair<int, pair<int, int> > edges;

int const INF = 1<<29;

int main() {
  
  int N, M;
  while(cin >> N >> M && (N|M)) {
    vector<edges> es;
    rep(i, M) {
      int a, b, c;
      cin >> a >> b >> c; a--, b--;
      es.push_back(make_pair(c, make_pair(a, b)));
    }
    sort(es.begin(), es.end());
    int ret = INF;
    
    for(; (int)es.size() >= N-1;) {
      memset(data, -1, sizeof data);
      int last = -1;
      int s = 0;
      rep(i, es.size()) {
	int u = root(es[i].second.first), v = root(es[i].second.second);
	if(u != v) {
	  data[u] += data[v]; data[v] = u;
	  last = i;
	  s++;
	  if(s == N-1) {
	    ret = min(ret, es[last].first-es[0].first);
	    goto next;
	  }
	}
      }
      break;
    next:;
      es.erase(es.begin());
    }
    
    cout << (ret < INF ? ret : -1) << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1328
N, K = [int(item) for item in input().split()]
S = [item for item in input()]

def compress(arr):
    """圧縮して消えた人はhappy"""
    cnt_h = 0
    new_arr = []
    comp_arr = ['L']

    #最初は先頭をLにする　この回転はノーカン
    if arr[0] == 'R':
        for item in arr:
            if item == 'L':
                new_arr.append('R')
            else:
                new_arr.append('L')

            prev_item = item
    else:
        new_arr = arr
    # 圧縮操作と圧縮されたかずを数える

    for i in range(1, N):
        if new_arr[i - 1] == new_arr[i]:
            cnt_h += 1
        else:
            comp_arr.append(new_arr[i])

    return [comp_arr, cnt_h] 


def execute(arr, cnt_h, K):
    # 境界を全て反転するために必要な操作回数
    max_rotation = len(arr)//2
    # 全てLになるか反転回数がKに到達するかで終了
    if max_rotation <= K:
        if arr[-1] == 'R':
            cnt_h += max_rotation*2 -1
        elif arr[-1] == 'L':
            cnt_h += max_rotation*2
    else:
        if arr[2*K] == 'R':
            cnt_h += 2*K - 1
        elif arr[2*K] == 'L':
            cnt_h += 2*K

    return cnt_h

arr, cnt_h = compress(S)
print(execute(arr, cnt_h, K))


Measured memory_bytes: 5532
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
char X,Y;
int main() {
	cin>>X>>Y;

	int R,L;
	if(X=='A')R=10;
	if(X=='B')R=11;
	if(X=='C')R=12;
	if(X=='D')R=13;
	if(X=='E')R=14;
	if(X=='F')R=15;
	if(Y=='A')L=10;
	if(Y=='B')L=11;
	if(Y=='C')L=12;
	if(Y=='D')L=13;
	if(Y=='E')L=14;
	if(Y=='F')L=15;

	if(R>L)cout<<">"<<endl;
	if(R==L)cout<<"="<<endl;
	if(R<L)cout<<"<"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int N; cin >> N;
	while(N--){
		int x,y,w,h,a,b,ret = 0;
		cin >> x >> y >> w >> h;
		w = x + w , h = y + h;
		int m; cin >> m;
		rep(i,m){
			cin >> a >> b;
			if(x <= a && a <= w && y <= b && b <= h)ret++;
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 0
#写経
#https://atcoder.jp/contests/abc172/submissions/14777611

def resolve():
    N = int(input())
    A = [int(a) for a in input().split()]
    x = 0
    for a in A[2:]:
        x ^= a                              # ^はXOR計算
    s = sum(A[:2])
    if s < x or (s ^ x) & 1:
        print(-1)
        return
    d = (s-x) // 2
    a = A[0]
    n = 0
    for i in range(40)[::-1]:
        b,c = (x >> i) & 1, (d >> i) & 1    # >> i は右方向iビットシフト
        if b == c == 1:
            print(-1)
            return
        if b == 0 and c == 1:
            n += 1 << i
    for i in range(40)[::-1]:
        b,c = (x >> i) & 1, (d >> i) & 1
        if b == 1 and c == 0:
            if n + (1 << i) <= a:
                n += 1 << i
    if n > a or n == 0:
        print(-1)
    else:
        print(a-n)
resolve()

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

int main(){
    int N;
    cin >> N;
    vector<string> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    int AC = 0;
    int WA = 0;
    int TLE = 0;
    int RE = 0;
    rep(i,N){
        if (vec[i] == "AC") AC++;
        if (vec[i] == "WA") WA++;
        if (vec[i] == "TLE") TLE++;
        if (vec[i] == "RE") RE++;
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T,class U>
ostream& operator<<(ostream& os,const map<T, U> & mp){
	os << "{";
	int i = 0;
	for(auto it : mp){
		if(i) os<<", ";
		os << it;
		i++;
	}
	os << "}";	
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 305;
int d[N][N];
int vis[N], col[N];
vector<int> con[N];
bool error = 0;
void dfs(int s, int c){
	if(error) return;
	col[s] = c;
	for(int v : con[s]){
		if(!col[v]) dfs(v, 3 - c);
		if(col[v] != 3 - col[s]){
			error = 1;
			return;
		}
	}
}

const int INF = 1e9;
char s[N][N];
int dist[N][N];
int main(){
	int n; sd(n);
	for(int i = 1; i <= n; i++){
		scanf("%s", s[i] + 1);
		for(int j = 1; j <= n; j++){
			if(j != i) dist[i][j] = INF;
			if(s[i][j] == '1'){
				dist[i][j] = 1;
				con[i].push_back(j);
			}
		}
	}
	dfs(1, 1);
	if(error){
		printf("-1\n"); return 0;
	}

	for(int k = 1; k <= n; k++)
	for(int i = 1; i <= n; i++)
	for(int j = 1; j <= n; j++)
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

	int ans = 0;
	for(int i = 1; i <= n; i++)
	for(int j = 1; j <= n; j++) ans = max(ans, dist[i][j]);
	printf("%d\n", ans + 1);
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <boost/format.hpp>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N_MAX = 1000000;

vector<int> tree[N_MAX];
int used[N_MAX];

int parent[N_MAX];
int sibl[N_MAX];
int deg[N_MAX];
int dep[N_MAX];
int height[N_MAX];
string type[N_MAX];

int find_depth(int node_id){
  if(node_id == -1) return 0;
  return 1 + max(find_depth(tree[node_id][0]),
		 find_depth(tree[node_id][1]));
}

void _height_dfs(int node_id, int h){
  if(node_id == -1) return;
  height[node_id] = max(h, height[node_id]);
  _height_dfs(parent[node_id], h+1);
}

void fill_height(int n){
  // find children
  rep(i, 0, n){
    if(type[i] == "leaf") _height_dfs(i, 0);
  }
}

void dfs(int node_id, int depth){
    int left_id = tree[node_id][0];
    int right_id = tree[node_id][1];

    deg[node_id] = (left_id != -1) + (right_id != -1);
    dep[node_id] = depth;

    // root
    if(depth==0){
      parent[node_id] = -1;
      sibl[node_id] = -1;
      type[node_id] = "root";
    }
    
    // if both children
    if(left_id != -1 && right_id != -1){
      parent[left_id] = node_id;
      parent[right_id] = node_id;
      sibl[left_id] = right_id;
      sibl[right_id] = left_id;
      if(depth > 0) type[node_id] = "internal node";

      dfs(left_id, depth+1);
      dfs(right_id, depth+1);
      
    }
    else if(left_id * right_id <= 0){
      int single_id = left_id < right_id ? right_id : left_id;
      parent[single_id] = node_id;
      sibl[single_id] = -1;
      if(depth > 0) type[node_id] = "internal node";
      dfs(single_id, depth+1);
    }
    
    else{
      if(depth != 0) type[node_id] = "leaf";
    }
    
}

int main(){
  int n;
  cin >> n;
  
  memset(used, 0, N_MAX*sizeof(used[0]));
  memset(height, 0, N_MAX*sizeof(height[0]));
  
  rep(i, 0, n){
    int node, left, right;
    cin >> node >> left >> right; 
    tree[node].push_back(left);
    tree[node].push_back(right);
    if(left >= 0) used[left] = 1;
    if(right >= 0) used[right] = 1;
  }
  
  int root_id = -1;
  rep(i, 0, n){
    root_id = (used[i] == 0 ? i : root_id);
  }

  // find depth
  // int t_height = find_depth(root_id);

  // fill infos
  dfs(root_id, 0);

  // fill height
  fill_height(n);

  // print array
  rep(i, 0, n){
    cout << boost::format("node %1%: parent = %2%, sibling = %3%, degree = %4%, depth = %5%, height = %6%, %7%")% i % parent[i] % sibl[i] % deg[i] % dep[i] % height[i] % type[i] << endl;
    
  }

  // node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {type}
  
  return 0;
}



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

const int SIZE = 100001;
vector<pair<int, int>> A[SIZE];
int max_distance = 0, farthest;
bool color[SIZE];
void dfs(int x = 0, int dist = 0){
    color[x] = true;
    for (int i = 0; i < A[x].size(); i++){
        if (max_distance < dist){
            farthest = x;
            max_distance = dist;
        }
        if (color[A[x][i].first]) continue;
        dfs(A[x][i].first, dist + A[x][i].second);
    }
}

int main(){
    int n, s, t, w;
    cin >> n;
    for (int i = 1; i < n; i++){
        cin >> s >> t >> w;
        A[s].push_back(make_pair(t, w));
        A[t].push_back(make_pair(s, w));
    }
    dfs();
    for (int i = 0; i < SIZE; i++)color[i] = false;
    dfs(farthest);
    cout << max_distance << endl;
}


Measured memory_bytes: 13308