akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl
 
//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)
 
constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;
 
int main(){
 
    long long int n;
    cin>>n;
    long long int k = 1;
    REP(i,n){
        k *= 2;
 
    }
    vector<long long int> v(k);
    REP(i,k){
        scanf("%lld",&v[i]);
    }
    sort(v.begin(),v.end(),greater<long long int>());
    vector<bool> w(k, false);
    w[0] = true;
   
    long long int l = 1, m;
    bool f;

    REP(i,n){
        map<long long int, long long int> mp;
        vector<long long int> kill;
        m = l;
        REP(j,k){
            if(w[j]){
                mp[-v[j]]++;
            }else{
                f = false;
                for(auto x:mp){
                    if(f){
                        break;
                    }else{
                        if(x.second!=0){
                            if(-x.first>v[j]){
                            mp[x.first]--;
                            w[j] = true;
                           // cout <<i<<" "<< -x.first<<" "<<x.second << " " << v[j]<<" "<<j << endl;
                            m--;
                            }
                            
                            f = true;
                        }else{
                            kill.push_back(x.first);
                        }
                        
                            
                    }
 
                }
            }
              for(auto x:kill){
            mp.erase(x);
        }
        kill.resize(0);
        if (m == 0)
        {
            break;
            }

        }
        if(m!=0){
            cout << "No" << endl;
            return 0;
        }else{
            l *= 2;
        }
      
    }
    REP(i,n){
        //cout << w[i] << endl;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
using namespace std;

int main() {
	int N;
	vector<vector<int>> h;
	vector<array<int,3>> val;
	array<int,3> reg;

	cin >> N;
	bool flag = true;
	for (int i=0; i<N; i++) {
		array<int,3> tmp;
		cin >> tmp[0] >> tmp[1] >> tmp[2];
		val.push_back(tmp);
		if (flag && tmp[2]>=1) {
			for (int j=0; j<3; j++) reg[j] = tmp[j];
			flag = false;
		}
	}
	for (int i=0; i<=100; i++) {
		for (int j=0; j<=100; j++) {
			int cnt = 0;
			int hh = reg[2]+abs(reg[0]-i)+abs(reg[1]-j);
			for (int k=0; k<N; k++) {
				if (max(hh-abs(val[k][0]-i)-abs(val[k][1]-j),0)==val[k][2]) cnt++;
			}
			if (cnt==N) {
				cout << i << " " << j << " " << abs(reg[0]-i)+abs(reg[1]-j)+reg[2] << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 384
# ABC 050 B
N = int(input())
T = [int(x) for x in input().split()]
#print(N)#
#print(T)#

M = int(input())
#print(M)#
for i in range(M):
    p, x = [int(i) for i in input().split()]
    #print(p,x)#
    w = T[p-1]
    T[p-1] = x
    print(sum(T))
    T[p-1] = w
        

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

ll f(ll n)
{
    ll res = 1;
    for (ll i = n; i >= 1; i--)
    {
        (res *= i) %= MOD;
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin >> n >> s;
    vector<bool> check(2 * n, false);
    for (ll i = 0; i < 2 * n; i++)
    {
        if (i % 2 == 0 && s[i] == 'W')
        {
            check[i] = true;
        }
        if (i % 2 && s[i] == 'B')
        {
            check[i] = true;
        }
    }
    ll ans = 1;
    ll lsum = 0;
    for (ll i = 0; i < 2 * n; i++)
    {
        if (check[i])
        {
            if (lsum == 0)
            {
                cout << 0 << endl;
                return 0;
            }
            (ans *= lsum) %= MOD;
            lsum--;
        }
        else
        {
            lsum++;
        }
    }
    if (lsum > 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << ans * f(n) % MOD << endl;
    }
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n,a[200005];
int k=1;
int ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==k){
            k++;
        }else{
            ans++;
        }
    }
    if(k==1){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 4368
n = int(input())
s = [0]*n
t = [0]*n
for i in range(n):
    a, b = map(str, input().split())
    b = int(b)
    s[i], t[i] = a, b
k = input()

for i in range(n):
    if s[i] == k:
        key = i+1
        
ans = sum(t[key:])
print(ans)    

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

using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	set<int> st;
	for (int i = 0; i < k; i++){
		int d;
		cin >> d;
		for (int j = 0; j < d; j++){
			int a;
			cin >> a;
			st.insert(a);
		}
	}

	cout << n - st.size() << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll A(N);
    for(ll i=0;i<N;i++)cin>>A[i];
    
    sort(ALL(A));
    
    ll count=0;
    ll count_sub=1;
    for(ll i=1;i<N;i++){
        if(A[i]==A[i-1])count_sub++;
        else{
            count+=count_sub-1;
            count_sub=1;
        }
    }
    count+=count_sub-1;
    
    if(count%2==0)cout<<N-count<<endl;
    else cout<<N-count-1<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for(int i = 0; i < N; i++){
        ll h;
        cin >> h;
        if(h >= K) ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
                                Bismillahi-r-Rahmani-r-Rahim
                                        RhIeyAaD
                                    IIT-7th Batch,JU
*/
#include<bits/stdc++.h>
using namespace std;

#define ll              long long int
#define MAX             2134567891
#define fr(i,n)         for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define rev(i,a,n)      for(i=n;i>=a;i--)
#define FOR(i,a,n)      for(i=a;i<=n;i++)
#define ALL(n)          n.begin(),n.end()
#define mem(x,n)        memset(x,n,sizeof(x))
#define TC(t)           printf("Case %lld: ",t)
#define ans(t,c)        printf("Case %lld: %lld\n",t,c)
#define SETP(n)         cout<<setprecision(n)<<fixed
#define READ            freopen("F:\\Project\\Test_Case.txt","r",stdin)
#define WRITE           freopen("F:\\Project\\Output_Test.txt","w",stdout)
#define IO              ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define PAIR            pair<ll,ll>
#define MP              make_pair
#define pb(a)           push_back(a)
#define ff              first
#define ss              second
#define NL              printf("\n");
#define debug(a)        cout<<a<<" ";
#define hlw             printf("hlw\n");
#define NN              111
#define MOD             1000000007///10^9
#define N               1000007 ///10^6->6 zero after 1 **

ll x[N],y[N],z[N],n;
string s,S;
vector<ll>v;
//map <ll,ll> mp;

int main()
{
    //IO;
    //while(1)
    //READ;WRITE;
{
    ll a=0,b=0,c=0,d,e,f,g,i,j,k,l,m,p,q,r,u,w,t,tc,in,mod,loc,diff,val,sz,lo,hi,mid,mn=MAX,mx=0,sum=0,ans=0;
    cin>>s;
    fr(i,3)
    {
        if(s[i]=='7')
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
}
    return 0;
}

/*

*/
/// Check for constraint 0 or 1?
/// long long or double? sqrt or division will work fine??


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

int main(){
    int n, k;
    cin>>n>>k;
    double ans = 0.0;
    for (int i=1; i<=n; i++){
        ll point = i;
        int p=0;
        while (point<k){
            point*=2;
            p++;
        }
         ans += 1.0 / n * pow(0.5, p);
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){ 
    ll n,a,b;
    cin >> n >> a >> b;
    ll h[n] = {};
    rep(i,0,n) cin >> h[i];

    ll ok = (ll)1e9,ng = 0;

    while(abs(ok-ng) > 1){ //mid 回で成功するか
        ll mid = (ok+ng)/2;

        ll cnt = mid;
        rep(i,0,n){
            if(mid*b >= h[i]) continue;
            cnt -= (ll)ceil((double)(h[i] - mid*b)/(double)(a-b));
        }

        if(cnt < 0) ng = mid;
        else ok = mid;
    }

    cout << ok << endl;
    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;

  if (L > R){
    cout << "Left" << endl;
  }
  
  if (L == R){
    cout << "Balanced" << endl;
  }
  
  if (L < R){
    cout << "Right" << endl;
  }
  
}

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

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

const ll INF = 1e12;

ll N;
vector<ll> v;

int main()
{
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i)
        cin >> v[i];
    sort(v.begin(), v.end());
    cout << v[N / 2] - v[N / 2 - 1] << endl;
}

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

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	int nowm = 1e9, flag = 0;
	long long ans = 0;
	for(int i = 1; i <= n; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		ans += x;
		if(x > y)nowm = min(nowm, y);
		if(x != y)flag = 1;
	}
	if(!flag)puts("0");
	else printf("%lld\n", ans - nowm);
}

Measured memory_bytes: 256
#include<stdio.h>
  main(){
  int a,b,c,x;
   scanf("%d%d%d",&a,&b,&c);
    if(a>b){
     x=a;
     a=b;
     b=x;
    }
    if(b>c){
     x=b;
     b=c;
     c=x;
    }
    if(a>b){
     x=a;
     a=b;
     b=x;
    }
   printf("%d %d %d\n",a,b,c);
  return 0;
 }

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

Measured memory_bytes: 128
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;

	cin >> a >> b >> c;

	if(a == b && b == c) cout << 1 << endl;
	else if((a == b ) || (b == c )||(c == a ) ) cout << 2 << endl;
	else cout << 3 << endl;

	return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;

    string s[h];

    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    int hnum[h][w] = {};
    int wnum[h][w] = {};

    int len, i1, i2, j1, j2;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                continue;
            }

            if (hnum[i][j] == 0) {
                len = 1;
                i1 = i;
                while (--i1 >= 0) {
                    if (s[i1][j] == '#') {
                        break;
                    }
                    len++;
                }

                i2 = i;
                while (++i2 < h) {
                    if (s[i2][j] == '#') {
                        break;
                    }
                    len++;
                }

                for (int ii = i1 + 1; ii < i2; ii++) {
                    hnum[ii][j] = len;
                }
            }

            if (wnum[i][j] == 0) {
                len = 1;
                j1 = j;
                while (--j1 >= 0) {
                    if (s[i][j1] == '#') {
                        break;
                    }
                    len++;
                }

                j2 = j;
                while (++j2 < w) {
                    if (s[i][j2] == '#') {
                        break;
                    }
                    len++;
                }

                for (int jj = j1 + 1; jj < j2; jj++) {
                    wnum[i][jj] = len;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            ans = max(ans, hnum[i][j] + wnum[i][j] - 1);
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int n, i, flag, flag2, count = 0, mem = -1;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    flag = n%2;
    flag2 = 1^flag;
    for(i=0; i<n; i++){
        if(((i+flag)/2)*2 + flag2 != a[i]){
            cout << 0;
            return 0;
        }
    }
    ll res = 1;
    for(int i=0; i<n/2; i++){
        res *= 2;
        res %= MOD;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 640
package main
import "fmt"

const mod int64 = 1000000007
const size int64 = 50

func main() {
  var h,w,a,b int64
  fmt.Scan(&h,&w,&a,&b)
  var c0,c1 int64 = f(h-a-1),f(a-1)
  var d0,d1 int64 = f(b-1),f(w-b)
  var n0,n1 int64 = f(h-a+b-2),f(a+w-b-1)
  var c int64
  for i:=b;i<w;i++ {
    d0 *= i
    d0 %= mod
    d1 *= inv(w-i)
    d1 %= mod
    n0 *= h-a+i-1
    n0 %= mod
    n1 *= inv(a+w-i-1)
    n1 %= mod
    c += (((((n0*inv(d0))%mod)*inv(c0))%mod)*
          ((((n1*inv(d1))%mod)*inv(c1))%mod))%mod
    c %= mod
  }
  fmt.Println(c)
}

func f(n int64) int64 {
  var m int64 = 1
  for i:=n;i>0;i-- {
    m *= i
    m %= mod
  }
  return m
}

func inv(n int64) int64 {
  if n == int64(1) { return int64(1) }
  var k []int64 = make([]int64,size)
  var t,a,b,ubnd,i,y0,y1 int64
  a,b,t = mod,n,n
  for i=0;i<size;i++ {
    k[i],t = a/b,a%b
    if t == 0 {
      ubnd = i
      break
    }
    a,b = b,t
  }
  y0,y1 = 1,-k[0]
  for i=1;i<ubnd;i++ {
    y0,y1 = y1,y0-k[i]*y1
  }
  for y1 < 0 { y1 += mod }
  return y1%mod
}

Measured memory_bytes: 512
def resolve():
    N = int(input())
    L = [[] for i in range(N)]
    for i in range(N):
        A = int(input())
        for j in range(A):
            x, y = map(int, input().split())
            L[i].append((x, y))

    ans = 0
    for p in range(1, 2**N):
        isOk = True
        for i in range(N):
            for x, y in L[i]:
                if p & (1 << i):
                    if p & 1 << (x-1) and not y:
                        isOk = False
                        break
                    elif not(p & 1 << (x-1)) and y:
                        isOk = False
                        break

                if not isOk:
                    break

        if isOk:
            ans = max(ans, bin(p).count('1'))

    print(ans)

if __name__ == '__main__':
    resolve()


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

int main(){
    string s, t;
    cin >> s >> t;
    int ans = t.size();
    for(int i = 0; i <= (int)(s.size() - t.size()); i++){
        int tmp = 0;
        for(int j = 0; j < (int)t.size(); j++){
            if(s[i + j] != t[j]) tmp++;
        }
        if(tmp < ans) ans = tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

template <class T> struct Dijkstra {

    struct Edge{
        int to;
        T cost;
        Edge(int _to, T _cost) : to(_to), cost(_cost) {}
    };
    
    const T INF = numeric_limits<T>::max() / 2;
    vector< vector< Edge > > G;
    vector< T > d;
    Dijkstra (int n) : G(n), d(n) {}

    void add_directed_edge(int a, int b, T c) {
        G[a].push_back(Edge(b,c));
    }
    
    void add_undirected_edge(int a, int b, T c) {
        G[a].push_back(Edge(b,c));
        G[b].push_back(Edge(a,c));
    }

    void init(int s) {
        priority_queue< pair<T,int>,vector< pair<T,int> >, greater< pair<T,int> > > que;
        fill(d.begin(), d.end(), INF);
        d[s] = 0;
        que.push(make_pair(0,s));
        while (!que.empty()){
            pair<T,int> p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first) continue;
            for (int i = 0; i < G[v].size(); i++) {
                Edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
    
    T dist(int a) {
        return d[a];
    }
    
}; 

int H,W;
int cost[10][10];
int min_cost[10];

int main() {

	cin >> H >> W;
	REP(i,10) REP(j,10) cin >> cost[i][j];

	REP(i,10) {
		Dijkstra < int > inst(10);
		REP(x,10) REP(y,10) inst.add_directed_edge(x, y, cost[x][y]);
		inst.init(i);
		min_cost[i] = inst.dist(1);
	}

	int ans = 0;
	REP(i,H) REP(j,W) {
		int A; cin >> A;
		ans += min_cost[A];
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 256
"""
kari1 = '01B0' #00
kari1 = '0BB1' #1
in1 = kari1
"""
in1 = input()

RC = ''
for idx1 in range(len(in1)):
    if in1[idx1] == '0':
        RC = RC + '0'
    elif in1[idx1] == '1':
        RC = RC + '1'
    elif in1[idx1] == 'B':
        if RC != '':
            RC = RC[0:len(RC) - 1]

print(RC)


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

int main(){
  int h,w;
  cin>>h>>w;
  char s[52][52];
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>s[i][j];
    }
  }
  int count=0;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(s[i][j]=='#'&&s[i][j-1]!='#'&&s[i-1][j]!='#'&&s[i][j+1]!='#'&&s[i+1][j]!='#'){
        count++;
      }
    }
  }
  if(count==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
        

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

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

        int[] cnt = new int[2]; //0: even numbers, 1: odd numbers
        for (int i = 0; i < N; i++) {
            cnt[(int) (sc.nextLong() % 2)]++;
        }

        int restOdd = cnt[1] % 2;
        cnt[0] += cnt[1] / 2;

        if ((restOdd == 0 && cnt[0] > 0) || (restOdd == 1 && cnt[0] == 0)) {
            out.println("YES");
        } else {
            out.println("NO");
        }
    }
}

Measured memory_bytes: 48720
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      String[] S = br.readLine().split(" ");
      int N = Integer.parseInt(S[0]);
      int M = Integer.parseInt(S[1]);
      
      S = br.readLine().split(" ");
      int sum = 0;
      int[] nums = new int[N];
      for(int i = 0; i < N; i++){
        nums[i] = Integer.parseInt(S[i]);
        sum += nums[i];
      }
      
      double d = sum*(1.0/(4*M));
      int count = 0;
      for(int i = 0; i < N; i++){
        if(nums[i] >= d){
          count++;
        }
      }
      System.out.println(count >= M ? "Yes" : "No"); 
    }catch(Exception e){
    }
  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    ld a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
    int sugar = 0; int sum = 0; ld prc = -1;

    rep(x1, (100*a + 2*f)/f) {
        rep(x2, (100*b + 2*f) / f) {
            if(x1 == 0 and x2 == 0) continue;
            rep(y1, (f + 2*c) / c) {
                int l = ( e * (a * x1 + b * x2 ) - c * y1 ) / d;
                rep(y2,l+1) {
                    if(y2 < 0) y2 = 0;
                    int g = 100 * ( a * x1 + b * x2) + c * y1 + d * y2;
                    ld temp = (ld) (c * y1 + d * y2) / (a * x1 + b * x2);
                    if(g <= f and temp <= e) {
                        if(temp > prc) {
                            sugar = c * y1 + d * y2;
                            sum = g;
                            prc = temp;
                        }
                    }
                }
            }
        }
    }
    cout << sum << " " << sugar << endl;
    return 0;
}

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

int main(){
	int n;cin>>n;
	int m;cin>>m;
	ll mat[110][110], dp[110][110];
	for(int i=1; i<=n; i++)
	for(int j=1; j<=n; j++)
		dp[i][j] = mat[i][j] = INT_MAX;
	int x[1010], y[1010], w[1010];
	for(int i=1; i<=m; i++){
		int a, b, c;
		cin>>a>>b>>c;
		x[i] = a;
		y[i] = b;
		w[i] = c;
		dp[a][b] = dp[b][a] = mat[a][b] = mat[b][a] = c;
	}
	for(int k=1; k<=n; k++)
	for(int i=1; i<=n; i++)
	for(int j=1; j<=n; j++)
		dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
	for(int i=1; i<=n; i++)
	dp[i][i] = 0;
	int cnt = 0;
	for(int i=1; i<=m; i++){
		int flag = 0;
		for(int j=1; j<=n and !flag; j++)
		for(int k=1; k<=n and !flag; k++)
		if(j!=k){
			if(dp[j][k] == dp[j][x[i]]+w[i]+dp[y[i]][k] or dp[j][k] == dp[j][y[i]]+w[i]+dp[x[i]][k]){
				flag = 1;break;
			}			
		}
		if(!flag)cnt++;
	}	
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 384
from math import factorial
N = int(input())
line = input()
l = []
counts = {}
for n in line.split(' '):
  n = int(n)
  if n not in counts:
    counts[n] = 0
  counts[n] += 1
  l.append(n)

comb = {}

for n in counts:
  comb[n] = 0
  count = counts[n]
  if count > 1:
    comb[n] += int(factorial(count)) // 2 // int(factorial(count - 2))

total = sum([comb[n] for n in comb])

for n in l:
  count = counts[n]
  result = total - comb[n]
  if count - 1 > 1:
    result += comb[n] * (count - 2) // count
  print(result)

Measured memory_bytes: 33164
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<vector<int>>place(N + 1,vector<int>(3,0));
  for(int i=1;i<N + 1;i++){
    for(int j=0;j<3;j++){
      cin >> place[i][j];
    }
  }
  
  bool reachable = true;
  
  for(int i=0;i<N;i++){
    int distance = abs(place[i + 1][1] - place[i][1])
      + abs(place[i + 1][2] - place[i][2]);
    
    int time = place[i + 1][0] - place[i][0];
    
    if(distance > time || distance % 2 != time % 2)
      reachable = false;
  }
  
  if(reachable)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

    
  

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repe(i, n) for(int i = 0; i <= (n); i++)
#define fo(i, a, b) for(int i = (a); i < (b); i++)
#define foe(i, a, b) for(int i = (a); i <= (b); i++)
#define NL << endl

using namespace std;
using ll = long long;
const int INFINT = numeric_limits<int>::max();
const ll INFLL = numeric_limits<long long>::max();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;


int main() {

	ll n, k;

	cin >> n >> k;

	ll r = n / k;
	ll ans = r * r * r;

	if (!(k & 1) && n - k / 2 >= 0) {
		r = n / (k / 2) - n / k;
		ans += r * r * r;
	}

	cout << ans NL;
	

	return 0;

}

Measured memory_bytes: 256
a, b, c, d = gets.split.map(&:to_i)


while (0 < a) && (0 < b) do  
  c = c - b
  a = a - d

  if (c <= 0) && (a <= 0)
    puts 'Yes'
    break
  elsif (c <= 0) && (a > 0)
    puts 'Yes'
    break
  elsif (a <= 0) && (c > 0)
    puts 'No'
    break
  end
end

Measured memory_bytes: 14344
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
if(b>d){
    cout<<1<<endl;
}
else cout<<0<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

	
int main(){
		ios::sync_with_stdio(false);
		cin.tie(0);
		ll a,b;
		cin >> a >> b;
		ll c = b-a;
		ll w = 0;
		FOR(i,1,c+1){
			w += i;
		}
		cout << w - b << endl;
}

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

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<ll> l, r;
  l.push_back(0);
  r.push_back(0);
  rep(i, n){
    ll tmp;
    cin >> tmp;
    if(tmp > 0) r.push_back(tmp);
    else if(tmp < 0) l.push_back(tmp*(-1));
    else k--;
  }
  sort(l.begin(), l.end());
  if(k <= 0){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1e10;
  int rnum = r.size()-1;
  int lnum = l.size()-1;
  for(int i = min(k, rnum); i >= k-min(k, lnum); i--){
    int j = k - i;
    ans = min(ans, 2*l[j]+r[i]);
    ans = min(ans, l[j]+2*r[i]);
  }
  cout << ans << endl; 
  
}

Measured memory_bytes: 1656
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String a = sc.next();
        // スペース区切りの整数の入力

        String b = sc.next();

        String c = sc.next();

        {
            String tmp = a;

            a = b;

            b = tmp;
        }

        {
            String tmp = a;

            a = c;

            c = tmp;
        }

        System.out.println(a + " " + b + " " + c);
    }
}

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

using namespace std;

int main()
{
    string S;

    cin >> S;

    int N = S.size();

    for (int i = 0, j = N - 1; i < j; i++, j--)
    {
        if (S[i] != S[j])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = 0, j = (N - 1) / 2 - 1; i < j; i++, j--)
    {
        if (S[i] != S[j])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = (N + 3) / 2 - 1, j = N - 1; i < j; i++, j--)
    {
        if (S[i] != S[j])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
//***___********* ___*****___****___***___*********//
/*  |   \  |   | |   |   |   \  |     |     |   |  **
/*  |   |  |   | |___|   |   _  |__   |___  |___|  **
/*  |   |  |   | |   \   |  | | |         | |   |  **
/*  |___/  |___| |    \  |__| | |___  ____| |   |  **
//*************************************************/
#include<bits/stdc++.h>
#define ff double
#define endl "\n"
#define M 1000000007
#define forever while(1)
#define ll long long
#define pb push_back
#define vi vector<long long>
#define mii map<int,int>
#define pii pair<int,int>
#define set_zero(arr) memset(arr,0,sizeof(arr))
#define test ll t;cin>>t;while(t--)
#include <ext/pb_ds/tree_policy.hpp>
#define REP(i,n) for(int i=0;i<(n);i++)
#include <ext/pb_ds/assoc_container.hpp>
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;

int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
	return f;
}
bool comp(string a,string b){return a<b;}

int main()
{
ll n;
cin>>n;
ll sum=0;
ll a=1;
while(n>0){
    sum+=a;
    a=a*2;
    n=floor(n/2);
}
cout<<sum<<endl;

return 0;
}





Measured memory_bytes: 256
MAX_REMAINDER = 10 ** 9 + 7
N, M = map(int, raw_input().split())
if abs(N - M) >= 2:
  print 0
elif abs(N - M) == 1:
  print reduce(lambda x, y: x * y % MAX_REMAINDER, (i + 1 for i in range(N))) \
    * reduce(lambda x, y: x * y % MAX_REMAINDER, (i + 1 for i in range(M))) \
    % MAX_REMAINDER
else:
  print (reduce(lambda x, y: x * y % MAX_REMAINDER, (i + 1 for i in range(N))) \
    * reduce(lambda x, y: x * y % MAX_REMAINDER, (i + 1 for i in range(M)))) \
    * 2 \
    % MAX_REMAINDER
    


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

int N, Q;
std::vector<int> edges[200000];
int64_t num[200000];

void dfs(int i, int p){
  for (int j: edges[i]) if (j != p){
    num[j] += num[i];
    dfs(j, i);
  }
}

int main(){
  std::cin >> N >> Q;
  for (int i = 0; i < N - 1; i++){
    int a, b;
    std::cin >> a >> b;
    edges[a-1].push_back(b-1);
    edges[b-1].push_back(a-1);
  }
  for (int i = 0; i < Q; i++){
    int p, x;
    std::cin >> p >> x;
    num[p-1] += x;
  }
  
  dfs(0, -1);
  for (int i = 0; i < N; i++){
    std::cout << num[i] << " ";
  }
  return 0;
}


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

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

bool ok(int first, long long len, const vector<long long> &a) {
  const int second = lower_bound(a.begin() + first, a.end(), a[first] + len) - a.begin();
  const int third  = lower_bound(a.begin() + second, a.end(), a[second] + len) - a.begin();
  return third < a.size() && len <= a[first] + a.back() - a[third];
}

bool check(long long len, const vector<long long> &a) {
  rep(i, a.size()) {
	if(ok(i, len, a)) return true;
  }
  return false;
}

int main(){
  constexpr long long MAX_A = 1000000000;

  int n;
  cin >> n;

  vector<long long> a(n + 1, 0);
  REP(i, 1, n + 1) {
	cin >> a[i];
  }

  partial_sum(ALL(a), a.begin());

  long long L = 0, R = n * MAX_A;
  while(L + 1 < R) {
	const long long M = (L + R) / 2;
	if(check(M, a)) {
	  L = M;
	}
	else {
	  R = M;
	}
  }

  cout << L << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <numeric>
#include <vector>
#include <algorithm>


typedef uint_fast64_t u64;
int main() {
  u64 n, res=0;
  std::cin>>n;
  std::vector<u64> l(2*n,0);
  for (u64 i=0;i<2*n;++i) std::cin>>l[i];
  std::sort(l.begin(),l.end());
  for (u64 i=0; i<2*n;i+=2)
    res+=l[i];
  std::cout<<res<<std::endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		// ??\???
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		// ???????????£?¨?
		int A[][] = new int[n][m];
		int b[] = new int[m];
		// ?????????????´?
		for(int i=0; i<n; i++){
			for(int i2=0; i2<m; i2++){
				int x = scan.nextInt();
				A[i][i2] = x;
			}
		}
		for(int i=0; i<m; i++){
			int x = scan.nextInt();
			b[i] = x;
		}
		
		
		// 	A ??¨ b ??????????±???????
		for(int i=0; i<n; i++){
			int Ci = 0;
			int y = 0;
			for(int i2=0; i2<m; i2++){
				y = A[i][i2]*b[i2];
				Ci = Ci + y;
			}
			// ??????
			System.out.println(Ci);
		}
	
		
	}

}

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

using namespace std;

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

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int n, c;
int a[400], b[400];
ll dp[401][401];
ll pw[400][401], tmp[401];

ll dfs(int pos, int cnt) {
	if (pos == n) return cnt == c;
	if (~dp[pos][cnt]) return dp[pos][cnt];
	
	ll res = 0, p = 1;
	
	REP(i, c - cnt + 1)
		(res += dfs(pos + 1, cnt + i) * pw[pos][i] % MOD) %= MOD;
	
	return dp[pos][cnt] = res;
}

int main() {
	cin >> n >> c;
	REP(i, n) scanf("%d", a + i);
	REP(i, n) scanf("%d", b + i);
	
	REP(i, n) {
		REP(j, a[i]) tmp[j] = 0;
		FOR(j, a[i], b[i] + 1) tmp[j] = 1;
		
		REP(j, c + 1) {
			ll now = 0;
			FOR(k, a[i], b[i] + 1) (now += tmp[k]) %= MOD;
			pw[i][j] = now;
			
			FOR(k, a[i], b[i] + 1) tmp[k] = tmp[k] * k % MOD;
		}
	}
	
	fill(dp[0], dp[n + 1], -1);
	
	cout << dfs(0, 0) << endl;
	
	return 0;
}

Measured memory_bytes: 2816
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;


Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  y = NIL;
  x = root;

  while(x != NIL)
    {

      y = x;

      if( z->key < x->key ) {
	x = x->left;
      }
      else {
	x = x->right;
      }

    }

  z->parent = y;

  if(y == NIL) {
    root = z;
  } //if T is empty
  else if( z->key < y->key ) {
    y->left = z;
  }
  else {
    y->right = z;
  }

}

void inorder(Node u){

  if(u == NIL) {
    return;
  }
  else {
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }

}
void preorder(Node u){

  if(u == NIL) {
    return;
  }
  else {
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 24040
#include <iostream>
#include <cassert>
#include <cmath>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;


typedef complex<double> P;
typedef vector<P> G;

#define EPS			(1e-10)
#define PI			(3.14159265358979323846)


#define X(a)		( (a).real() )
#define Y(a)		( (a).imag() )
#define EQ(a,b)		( -EPS<(a)-(b) && (a)-(b)<EPS )
#define EQV(a,b)	( EQ(X(a),X(b)) && EQ(Y(a),Y(b)) )

#define unit(a)		( (a)/abs(a) )
#define normal(a)	( (a)*P(0,1) )
#define dot(a,b)	( X((a)*conj(b)) )
#define cross(a,b)	( Y(conj(a)*(b)) )

bool intersectCC(P a, double ra, P b, double rb)
{
	double v=abs(a-b);
	return ( !(v>ra+rb || v<abs(ra-rb)) );
}

pair<P,P> crosspointCC(P c, double r, P d, double s)
{
	P v = d-c;  double dv=abs(v);
	assert( !(dv>r+s || dv<abs(r-s)) );
 
	double l = ((r*r-s*s)/dv+dv)/2.0;

	P e = c + l*v/dv;
	P p = normal(sqrt(r*r-l*l) * v/dv);

	return make_pair(e+p,e-p);
}


int main()
{
	int n; char c; P p;
	while(cin >> n, n)
	{
		G g;
		for(int i=0; i<n; i++)
		{
			cin >> X(p) >> c >> Y(p);
			g.push_back(p);
		}

		int c1,c2,mx=1;
		for(int i=0; i<n-1; i++)
		for(int j=i+1; j<n; j++)
		{
			if(intersectCC(g[i],1,g[j],1))
			{
				c1=c2=0;
				pair<P,P> s = crosspointCC(g[i],1,g[j],1);
				for(int k=0; k<n; k++)
				{
					if(abs(g[k] - s.first ) <= 1.0+EPS) c1++;
					if(abs(g[k] - s.second) <= 1.0+EPS) c2++;
				}
				mx = max(mx,max(c1,c2));
			}
		}

		cout << mx << endl;
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[200100];

ll solve() {
    ll res = 0;
    int b = 0;
    int j = 0;
    for (int i = 0; i < n; i++) {
        while (j < n && (b & a[j]) == 0) {
            b |= a[j];
            j++;
        }
        res += j - i;
        b ^= a[i];
    }
    return res;
}

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

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 1024
//クドイやり方しか見つけられず
#include <bits/stdc++.h>
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    sort(S.begin(),S.end());
    puts((S[0] == S[1] && S[1] != S[2]&&S[2] ==S[3]) ? "Yes" : "No");
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main() {
  cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
  int X;
  cin >> X;
  auto is_prime = [](int X) {
    bool res = true;
    for (int i = 2; i * i <= X; ++i) {
      if (X % i != 0)continue;
      res = false;
      break;
    }
    return res;
  };
  for (; !is_prime(X); ++X);
  cout << X << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << "\n";
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << "\n";
	}

	return 0;
}


Measured memory_bytes: 3636
from collections import deque
import sys
input = sys.stdin.readline

h, w, k = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
x1-=1
y1-=1
x2-=1
y2-=1

dist = [input() for _ in range(h)]
ans = [[-1]*w for _ in range(h)]
ans[x1][y1] = 0

que = deque()
que.append((x1, y1))
direction = ((1, 0), (-1, 0), (0, -1), (0, 1))
while que:
  x, y = que.popleft()

  if x == x2 and y == y2:
      print(ans[x][y])
      exit()

  for dx, dy in direction:
    for i in range(1, k+1):
      kx = x + dx*i
      ky = y + dy*i

      if not(0 <= kx < h and 0 <= ky < w) or dist[kx][ky] == "@":
          break

      if 0 <= ans[kx][ky] <= ans[x][y]:
          break

      if ans[kx][ky] == -1:
          que.append((kx, ky))

      ans[kx][ky] = ans[x][y]+1

print(-1)

Measured memory_bytes: 36596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
 
public class Hello{
    static public int mod = 1000000007;
    public static void Main(){
        // 方針
        // なし
        int[] num = inta();
        if(num[0] < num[2] && num[2] < num[1] || num[1] < num[2] && num[2] < num[0]){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }

        
    

        
        
        
        
    }
    static int ncr(int n,int r){r = Min(r,n-r);long nn = 1;for(int i=n-r+1;i<=n;i++){nn = nn*i%mod;}long rr = 1;for(int i=1;i<=r;i++){rr = rr*i%mod;}rr = square((int)rr,mod-2);nn = nn * rr %mod;return (int)nn;}
    // a^b mod
    static int square(int a,int b){string binary = Convert.ToString(b,2);int bileng = binary.Length;long a_power = a;long value = 1;for(int i=bileng-1;i>=0;i--){if(binary[i] == '1'){value = value*a_power%mod;}a_power = a_power*a_power%mod;}return (int)value;}
    //static int square2(long a,long b,long m){var list = new List<int>();int temp = 1;long n2 = a;list.Add(1);int count = 1;while(temp < b){list.Add((int)n2);temp*=2;count++;n2 = n2*n2%m;}long ret = 1;while(b > 0){if(temp <= b){b -= temp;ret = ret*list[count]%1000000007;}count--;temp/=2;}return(int)ret;}
    //各種読取
    static string rstr(){ return ReadLine(); }
    static int rint(){ return int.Parse(ReadLine()); }
    static long rlong(){ return long.Parse(ReadLine()); }
    static string[] stra(){ return ReadLine().Split(' '); }
    static int[] inta(){ string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){ return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static int[,] inta2(int num_array,int in_array){ int[,] int_array2 = new int[num_array,in_array]; for(int i=0;i<num_array;i++){ int[] temp_array = inta(); for(int j=0;j<in_array;j++){ int_array2[i,j] = temp_array[j]; } } return int_array2; }
    static long[] longa(){ string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){ return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea(){ string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){ return_double_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_double_array; }
    // -----------------------------
    static long divideup(long divided,long divid){ long temp_divide = divided/divid; if(divided % divid > 0){ temp_divide++; } return temp_divide; }
    static long GCD(long a,long b){ if(a < b){ long temp = a; a = b; b = temp; } if(a % b == 0){ return b; } else{ long temp = b; b = a%b; a = temp; return GCD(a,b); } }
    static long LCM(long a,long b){ return a * b / GCD(a,b); }
}

Measured memory_bytes: 13140