akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
using namespace std;

struct point { double x, y; };

int koch(int d,struct point l,struct point r) {
	if (d == 0)return 0;
	struct point s, u, t;
	double th = M_PI*60.0 / 180.0;
	
	s.x = (2 * l.x + r.x) / 3;
	s.y = (2 * l.y + r.y) / 3;
	t.x = (l.x + 2 * r.x) / 3;
	t.y = (l.y + 2 * r.y) / 3;
	u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
	u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

	koch(d - 1, l, s);
	cout << fixed << setprecision(8) << s.x << " " << s.y << endl;
	koch(d - 1, s, u);
	cout << fixed << setprecision(8) << u.x << " " << u.y << endl;
	koch(d - 1, u, t);
	cout <<fixed << setprecision(8) << t.x << " " << t.y << endl;
	koch(d - 1, t, r);
}
int main() {
	int n;
	struct point p1, p2;
	p1.x = 0, p1.y = 0;
	p2.x = 100, p2.y = 0;
	cin >> n;
	cout << fixed << setprecision(8) << p1.x << " " << p1.y << endl;
	koch(n, p1, p2);
	cout << fixed << setprecision(8) << p2.x <<" "<< p2.y << endl;
	return 0;
}

Measured memory_bytes: 3288
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<vector>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, int> pli;
 
const int MX = 1<<19;
 
ll ans[MX];
vector<pii> T[MX];
 
int cnt[MX];
ll A[MX];
int N;
 
__int128 total;
int rm;
 
int dfs(int x, int p = -1)
{
	cnt[x] = 1;
	for(pii e : T[x]){
		if( e.second == p ) continue;
		int v = dfs(e.second, x);
		if( v*2 == N ){
			rm = e.first;
		}
		else{
			ans[e.first] = (A[x] - A[e.second]) / (2*v-N);
			total -= (__int128) ans[e.first] * (N-v) * v;
		}
		cnt[x] += v;
	}
	return cnt[x];
}
 
int main()
{
	scanf("%d", &N);
	for(int i = 1; i < N; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		T[a].emplace_back(i, b);
		T[b].emplace_back(i, a);
	}
	for(int i = 1; i <= N; i++) scanf("%lld", A+i), total += A[i];
	total /= 2;
	dfs(1);
	total /= (N/2);
	total /= (N/2);
	ans[rm] = total;
	for(int i = 1; i < N; i++) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 28928
#include <bits/stdc++.h>
using namespace std;
#define MAX 30
#define NIL -1
int n, D[MAX], H[MAX];

struct node{
    int p, l, r;
};
node T[MAX];

void printTree(){
    int parent;
    for(int i=0;i<n;++i){
        printf("node %d: parent = %d, ",i,T[i].p);

        if(T[i].p==NIL) printf("sibling = -1, ");
        else{
            parent = T[i].p;
            if(T[parent].l==i){
                if(T[parent].r==NIL) printf("sibling = -1, ");
                else printf("sibling = %d, ",T[parent].r);
            }
            else if(T[parent].r==i){
                if(T[parent].l==NIL) printf("sibling = -1, ");
                else printf("sibling = %d, ",T[parent].l);
            }
        }

        if(T[i].l==NIL && T[i].r==NIL) printf("degree = 0, ");
        else if(T[i].l!=NIL && T[i].r!=NIL) printf("degree = 2, ");
        else if(T[i].l!=NIL && T[i].r==NIL) printf("degree = 1, ");
        else if(T[i].l==NIL && T[i].r!=NIL) printf("degree = 1, ");

        printf("depth = %d, height = %d, ",D[i],H[i]);

        if(T[i].p == NIL) printf("root");
        else{
            if(T[i].l == NIL && T[i].r == NIL ) printf("leaf");
            else printf("internal node");
        }
        printf("\n");
    }
}


void recDepth(int pos, int depth){
    D[pos] = depth;
    if(T[pos].l != NIL){
        recDepth(T[pos].l,depth+1);
    }
    if(T[pos].r != NIL){
        recDepth(T[pos].r,depth+1);
    }
}

int recHeight(int pos){
    int h1=0, h2=0;
    if(T[pos].l != NIL){
        h1 = recHeight(T[pos].l)+1;
    }
    if(T[pos].r != NIL){
        h2 = recHeight(T[pos].r)+1;
    }
    H[pos] = (h1>h2)?h1:h2;
    return H[pos];
}

int main(){

    scanf("%d",&n);
    for(int i=0;i<n;++i){
        T[i].l = T[i].p = T[i].r = NIL;
        D[i] = 0;
    }
    int id, lchild, rchild, sib, root;

    for(int i=0;i<n;++i){
        scanf("%d %d %d",&id,&lchild,&rchild);
        T[id].l = lchild;
        T[id].r = rchild;
        T[lchild].p = id;
        T[rchild].p = id;
    }
    for(int i=0;i<n;++i){
        if(T[i].p==NIL) root=i;
    }
    recDepth(root,0);
    recHeight(root);
    printTree();
    return 0;
}




Measured memory_bytes: 3204
#include<iostream>
using namespace std;
int main(){
  int i;
  int a,b,c,ans;
  cin>>a>>b>>c;
  for(i=0;;++i){
    c-=a;
    if((i+1)%7==0)c-=b;
    if(c<=0){
      cout<<i+1<<endl;
      break;
    }
  }
}


Measured memory_bytes: 3100
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int n;
map<string,bool> mp;
int main() {
	mp.clear();
	char last;
	scanf("%d",&n);
	for (int i=1;i<=n;++i) {
		char ss[12];
		scanf("%s",ss);
		if (i^1&&ss[0]^last) {puts("No");return 0;}
		else if (mp[ss]) {puts("No");return 0;}
		last=ss[strlen(ss)-1];
		mp[ss]=true;
	}
	puts("Yes");
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<tuple<int, string, int>> pr(N);
    rep(i, N) {
        string s;
        int p;
        cin >> s >> p;
        pr[i] = make_tuple(i+1, s, p);
    }

    rep(i, N-1) {
        int tj = i;
        for(int j=i+1; j<N; j++) {
            int a = get<1>(pr[j]).compare(get<1>(pr[tj]));
            if(a == 0) {
                if(get<2>(pr[tj]) < get<2>(pr[j])) tj = j;
            }
            if(a < 0) {
                tj = j;
            }
        }
        swap(pr[i], pr[tj]);
    }

    rep(i, N) {
        cout << get<0>(pr[i]) << endl;
    }

    return 0;

}

Measured memory_bytes: 256
n,m = map(int,input().split())
s = []
for i in range(m):
  ks = list(map(int,input().split()))
  s.append(ks)
p = list(map(int,input().split()))
ans = 0
for i in range(2**n):
  flag = True
  for j in range(m):
    count = 0
    for k in range(s[j][0]):
      if i & (1<<(s[j][k+1]-1)): count += 1
    if count%2!=p[j]: flag = False
  if flag==True: ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int k, n;
	cin>>k>>n;
	int fi=0, la=0, lala;
	int maxdif=-1;
	for(int i=0; i<n; i++){
		cin>>la;
		if(i==0) fi=la;
		if(i>0) maxdif=max(maxdif, la-lala);
		lala=la;
	}
	fi+=k; maxdif=max(maxdif, fi-la);
	printf("%d\n", k-maxdif); return 0;
}

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



int main() {
 

  int n;
  cin>>n;

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

  int cnt4=0,cnt2=0;
  //4の倍数
  //4の倍数出ないが、2の倍数/2
  //の合計がn/2より大きい
  for(int i=0;i<n;i++){
    if(a.at(i)%4==0)
      cnt4++;
    else if(a.at(i)%2==0)
      cnt2++;
  }

  if(cnt4+cnt2/2>=n/2)
    cout<<"Yes"<<endl;
  else 
    cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 3780
#!/usr/bin/ruby 
#encoding: utf-8

s = gets.chomp

cnt = 0
(2..s.size-2).each do |i|
  if s[i] == 'C'
    cnt += 1
  end
end

if cnt != 1 or s[0] != 'A'
  puts "WA"
  exit
end

(0..s.size-1).each do |i| 
  if s[i] != 'A' and s[i] != 'C'
    if s[i].ord < 97 or s[i].ord > 122 
      puts "WA"
      exit
    end
  end
end

puts "AC"


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

int main(){
    int r, D;
    long x[11];
    cin >> r >> D >> x[0];

    for(int i = 1; i < 11; i++){
        x[i] = r * x[i-1] - D;
        cout << x[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define RANGE(a) (a),(a+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 20
//---------------------

int n,p[MAXN];

int main(){
  	ZERO(p);
  	cin>>n;
  	REP(i,n) cin>>p[i];
  	int cache[3];
  	int sortcache[3];
  	int ct=0;
  	REP(i,n-2){
  		REP(j,3) cache[j]=p[i+j];
  		memcpy(sortcache,cache,3*sizeof(int));
  		sort(sortcache,sortcache+3);
  		if(cache[1]==sortcache[1]) ct++;
  	}
  	PRT(ct);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<functional>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int N, M;
P BC[100000];
ll ans = 0;
priority_queue<ll, vector<ll>, greater<ll>> pq;


int main() {
	
	cin >> N >> M;

	for (int i = 0; i < N; i++) {
		ll a;
		cin >> a;
		pq.push(a);
		ans += a;
	}
	for (int i = 0; i < M; i++) {
		cin >> BC[i].second >> BC[i].first;
	}
	sort(BC, BC + M, greater<P>());
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < BC[i].second && BC[i].first > pq.top(); j++) {
			ll tmp = pq.top(); pq.pop();
			ans += (BC[i].first - tmp);
			pq.push(BC[i].first);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
#define int         int64_t
#define pb          push_back
#define endl        '\n'
#define pll         pair<int,int>
#define vll          vector<int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mi        map<int,int>
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
int n,i,j,k,l,sum=0,flag=0,t,a[200005],ans=0;
bitset<4000001> dp;
void solve(){
    dp[0]=1;
    cin>>n;
    int sum = 0;
    for(int i=0;i<n;i++){
        cin>>j;
        sum+=j;
        dp|=(dp<<j);
    }
    for(int i=0;i<=sum;i++){
        if(dp[i]&& i>=(sum+1)/2) {
            cout<<i<<endl;
            return;
        }
    }
}
signed main()
{
    ios
    int test=1;
    //cin>>test;
    while(test--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

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

}

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

int main() {

  int N;
  cin >> N;
  int z=0;
  int a;
   cin >> a;
   for(int i=0;;i++){
     z++;
     if(a%2==1){
       break;
     }
     else{
       a=a/2;
     }
   }
   for(int i=0;i<N-1;i++){
     int x;
     cin >> x;
     int y = 0;
     for(int j=0;;j++){
       y++;
     if(x%2==1){
       break;
     }
       else{
         x = x/2;
     }
     }
     if(y<z){
       z=y;
     }
   }
  cout << z-1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    string s;
    cin >> s;
    bool north = false;
    bool south = false;
    bool west = false;
    bool east = false;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'N') north = true;
        if(s[i] == 'S') south = true;
        if(s[i] == 'W') west = true;
        if(s[i] == 'E') east = true;
    }
    if(north != south || east != west) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3604
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // input
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        HashMap<Integer, Integer> h = new HashMap<>();
        for (int i = 0; i < k; i++) {
            int d = sc.nextInt();
            for (int j = 0; j < d; j++) {
                int a = sc.nextInt();
                h.put(a, 1);
            }
        }

        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (h.get(i) == null) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 46252
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
int n, m;
vector<int> a[100001];
int d[100001];
void go(int x) {
	queue<int> q;
	q.push(x);
	while (!q.empty()) {
		int x = q.front(); q.pop();
		for (int next : a[x]) {
			if (next != 1 && d[next] == 0) {
				d[next] = x;
				q.push(next);
			}
		}
	}
}
int main() {
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(NULL);
	
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	go(1);
	for (int i = 2; i <= n; i++) {
		if (d[i] == 0) {
			cout << "No" << '\n'; return 0;
		}
	}
	cout << "Yes" << '\n';
	for (int i = 2; i <= n; i++) {
		cout << d[i] << '\n';
	}

	

	




} 

Measured memory_bytes: 10536
#include <iostream>
using namespace std;
int main(void){
  string s,t;
  cin >> s;
  cin >> t;
  int ans = 0;
  for(int  i = 0;i < s.size();i++){
    if(s[i]!=t[i]){
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3920
class OddProblem
  def initialize(aa)
    @aa = aa
  end

  def solve
    ct = 0
    @aa.each_slice(2) do |x|
      ct += 1 if x[0].odd?
    end
    ct
  end
end

def run
  gets
  aa = gets.scan(/\d+/).map(&:to_i)
  puts OddProblem.new(aa).solve
end

run


Measured memory_bytes: 14376
N = int(input())
S = input()
result = S[1:].count("E")
cost = result
l0 = S[0]
for n in range(1, N):
    l1 = S[n]
    if l0 != l1:
        l0 = l1
        continue
    if l0 == "W":
        cost += 1
        continue
    cost -= 1
    if cost < result:
        result = cost

print(result)

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int a, b, n;
    cin >> a >> b;
    n = b-a;
    cout << (1+n)*n/2 - b << endl;
    return 0;
}




Measured memory_bytes: 256
use input::Input;

fn main() {
    let mut input = Input::default();

    let l = input.parse::<u32>();
    let r = input.parse::<u32>();
    let d = input.parse::<u32>();

    let ans = r / d - (l - 1) / d;
    println!("{}", ans);
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


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

int n, m, p, d;
vector<string> ls;

bool check() {
    int c = m;
    for (int i = 0; i < d; i++) {
        if (ls[i][c] == '1') {
            c++;
        } else if (0 <= c-1 && ls[i][c-1] == '1') {
            c--;
        }
    }
    return c == p;
}

int main() {
    while (cin >> n, n != 0) {
        cin >> m >> p >> d;
        m--, p--;
        ls.clear();
        for (int i = 0; i < d; i++) {
            string s;
            cin >> s;
            ls.push_back(s);
        }

        if (check()) {
            cout << 0 << endl;
            continue;
        }

        int y, x;
        for (int i = 0; i < d; i++) {
            for (int j = 0; j < n-1; j++) {
if (ls[i][j] == '0' && ((n == 2) ||(j == 0 && ls[i][j+1] == '0') ||(j == n-2 && ls[i][j-1] == '0') ||(ls[i][j-1] == '0' && ls[i][j+1] == '0'))) {
                    ls[i][j] = '1';
                    if (check()) {
                        y = i+1;
                        x = j+1;
                        goto found;
                    }
                    ls[i][j] = '0';
                }
            }
        }
        cout << 1 << endl;
        continue;
found:
        cout << y << ' ' << x << endl;
        continue;
    }
    return 0;
}

Measured memory_bytes: 3156
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k = map(int,readline().split())
a = list(map(int,readline().split()))
mod = 10**9+7

p = []
P = 0
z = False
t = 0
for i in a:
  if i > 0:
    p.append((i,1))
    P += 1
  elif i == 0:
    p.append((0,0))
    z = True
  else:
    p.append((-i,-1))

if P == 0 and k%2 == 1:
  if z:
    print(0)
  else:
    ans = 1
    p.sort()
    for i in range(k):
      ans *= -p[i][0]
      ans %= mod
    print(ans)
  exit()

p.sort(reverse=True)
mi_p = 0
ma_m = 0
c = 0

for i in range(k):
  if p[i][1] > 0:
    mi_p = i
  elif p[i][1] == 0:
    print(0)
    exit()
  else:
    ma_m = i
    c += 1
    
if c%2 == 0:
  ans = 1
  for i in range(k):
    ans *= p[i][0]
    ans %= mod
  print(ans)
elif n == k:
  ans = 1
  for i in a:
    ans *= i
    ans %= mod
  print(ans)
else:
  ma_p = 0
  mi_m = 0
  for i in range(n-k):
    L = p[k+i]
    if L[1] > 0 and ma_p == 0:
      ma_p = p[k+i][0]
    if L[1] < 0 and mi_m == 0:
      mi_m = p[k+i][0]
    if ma_p*mi_m != 0:
      break
  ans_p = 1
  ans_m = 1
  for i in range(k):
    if i == ma_m:
      ans_p *= p[i][0]
    elif i == mi_p:
      ans_m *= p[i][0]
    else:
      ans_p *= p[i][0]
      ans_m *= p[i][0]
    ans_p %= mod
    ans_m %= mod
  if k-c > 1 and mi_m*p[ma_m][0] > ma_p*p[mi_p][0]:
    print(ans_p*mi_m%mod)
  else:
    print(ans_m*ma_p%mod)

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

using namespace std;

#define pos first
#define health second

struct BIT {
    vector<long long> tree;
    BIT(int n) : tree(n + 2){}

    void upd(int p , long long v) {
        for (int i = ++p ;i < tree.size() ; i += i & -i)
            tree[i] += v;
    }

    long long get(int p) {
        long long sum = 0;
        for (int i = ++p; i ; i -= i & -i)
            sum += tree[i];
        return sum;
    }

    long long query(int l , int r) {
        if (r < l) return 0;
        return get(r) - get(l - 1);
    }
};

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int n , D , A;
    cin >> n >> D >> A;

    map<long long , int> NEW;

    vector<pair<int , int> > mon(n);
    for (int i = 0 ;i < n ;i++) {
        cin >> mon[i].pos >> mon[i].health;
        NEW[mon[i].pos];
        NEW[mon[i].pos + 2ll * D];
    }

    int sz = 0;
    for (auto &p : NEW)
        p.second = sz++;

    BIT bit(sz);

    sort(mon.begin() , mon.end());

    long long ans = 0;
    for (int i = 0 ;i < n ;i++) {
        long long damage = bit.query(NEW[mon[i].pos] , sz);
        if (damage >= mon[i].health) continue;
        int rem = mon[i].health - damage;
        int need = (rem + A - 1) / A;
        ans += need;
        bit.upd(NEW[mon[i].pos + 2ll * D] , need * 1ll * A);
    }

    cout << ans;
}


Measured memory_bytes: 33028
#include <stdio.h>
int main()
{
    int n, a[100];
    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = n - 1; i >= 0; i--)
    {
        printf("%d", a[i]);
        if (i != 0)
            printf(" ");
        else
        {
            break;
        }
    }

    printf("\n");

    return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>
#include<string.h>

#define ATOZ_CNT 26

int main(){
    char input[5];
    int  appear[ATOZ_CNT]={0,};
    scanf("%s",input);
    for(int i=0;i<4;i++){
        appear[input[i]-'A']+=1;
    }
    int doubleAppearCnt=0;
    for(int i=0;i<ATOZ_CNT;i++){
        if(appear[i]==2)doubleAppearCnt+=1;
    }
    if(doubleAppearCnt==2)printf("Yes\n");
    else                  printf("No\n");
    
    return 0;
}

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

#define mod 1000000007
#define MAX_N 200010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}
void GetFactorial(){
    factorial[0] = 1; inv_factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= mod;
        inv_factorial[i] = inv_factorial[i-1] * inv[i];
        inv_factorial[i] %= mod;
    }
}

long long combination(int n, int r) {
    if (n < 0 || r < 0 || n < r) return 0; 
    long long ret = factorial[n] * inv_factorial[r];
    ret %= mod;
    ret *= inv_factorial[n-r];
    return ret % mod;
}

long long modpow(int n, int r) {
    long long ret = 1; long long tmp = (long long) n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}

long long dp[21][1010];

int main() {
    GetInv(); GetFactorial();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    vector<int> a(k);
    for (int i = 0; i < k; i++) cin >> a[i];
    dp[0][n] = 1;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= j; k++) {
                dp[i+1][j-k] += dp[i][j] * combination(n-k, a[i]-k) % mod * inv_factorial[k] % mod;
                dp[i+1][j-k] %= mod;
            }
        }
    }
    cout << dp[k][0] * factorial[n] % mod << "\n";
    return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 50
#define MOD 1000000007

ll n, k;
ll a[N][N], b[N][N];
ll r1[N][N], r2[N][N];

void multi(ll a[N][N], ll b[N][N], ll c[N][N]) {
  rep(i, n) {
    rep(j, n) {
      c[i][j] = 0;
      rep(k, n) {
        c[i][j] += a[i][k] * b[k][j] % MOD;
      }
      c[i][j] %= MOD;
    }
  }
}

ll solve(ll k) {
  rep(i, n) rep(j, n) r1[i][j] = (i == j ? 1 : 0);
  while(k) {
    if(k & 1) {
      multi(r1, a, r2);
      rep(i, n) rep(j, n) r1[i][j] = r2[i][j];
    }
    multi(a, a, b);
    rep(i, n) rep(j, n) a[i][j] = b[i][j];
    k >>= 1;
  }
  ll res = 0;
  rep(i, n) rep(j, n) {
    res += r1[i][j];
    res %= MOD;
  }
  return res;
}

int main() {
  cin >> n >> k;
  rep(i, n) rep(j, n) cin >> a[i][j];
  cout << solve(k) << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define deb(x) cout<<#x<<" "<<x<<endl;
#define print(arr,n) for(int i=0;i<n;++i) { cout<<arr[i]<<" "; } cout<<endl;
#define ub(x,el) upper_bound(x.begin(),x.end(),el) - x.begin()
#define lb(x,el) lower_bound(x.begin(),x.end(),el) - x.begin();
#define bs(x,el) binary_search(x.begin(),x.end(),el)
#define MOD 1000000007
#define finish return 0
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds; 
typedef long long int ll;
typedef tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!"); template<typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) { }}; template<typename T> struct Vec<1, T> : public vector<T> { Vec(int n = 0, T val = T()) : vector<T>(n, val) { } };
inline ll mod(ll x) { return (x%MOD + MOD)%MOD; }
ll gcd(ll a, ll b, ll &x, ll &y){if(a == 0){x = 0, y = 1; return b;} ll x1, y1;  ll d = gcd(b%a, a, x1, y1); x = y1 - (b/a) * x1; y = x1; return d;}
ll power(ll x,ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;   } return res; } 
ll power(ll x,ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res*x); y = y>>1; x = (x*x);   } return res; } 
ll mod(ll num, ll den){ return mod(mod(num) * power(den,MOD-2,MOD)); }
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,m;
    cin>>n>>m;
    vector< vector<ll> > G(n+1);
    for(ll i=0;i<m;++i)
    {
        ll a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> par(n+1,-1);
    vector<bool> vis(n+1);
    vis[1] = true;
    queue<ll> q;
    q.push(1);
    while(!q.empty())
    {
        auto u = q.front();
        q.pop();
        for(auto v:G[u])
        {
            if(!vis[v])
            {
                vis[v] = true;
                par[v] = u;
                q.push(v);
            }
        }
    }
    for(ll i=2;i<=n;++i)
    {
        if(par[i] == -1)
        {
            cout<<"No"<<endl;
            finish;
        }
    }
    cout<<"Yes"<<endl;
    for(ll i=2;i<=n;++i)
    {
        cout<<par[i]<<endl;
    }

}

Measured memory_bytes: 12948
inp = input().split(" ")
N = int(inp[0])
A = int(inp[1])
B = int(inp[2])

# print(N, A, B)

f1 = N // (A + B) * A
# print(f1)
f2 = N % (A + B)
# print(f2)

if f2 > A:
  print(f1 + A)
else:
  print(f1 + f2)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi p;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    p.resize(n);
    rep(i,n){
        cin>>p[i];
    }
    ll a,b,c;
    ll ans = 0;
    rep(i,n-2){
        Vi v(3,0);
        v[0] = p[i];
        v[1] = p[i+1];
        v[2] = p[i+2];
        sort(all(v));
        if(v[1]==p[i+1])ans++;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans = -LINF;

int main(void) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = max(a*c, a*d);
    ll y = max(b*c, b*d);
    ans = max(x, y);
    if ((a<=0&&b>=0) || (c<=0&&d>=0)) ans = max(ans, 0LL);

    
    cout << ans << endl;
    return 0;
}





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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

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

    if (a == b) {
        cout << c << endl;
        return 0;
    }

    if (a == c) {
        cout << b << endl;
        return 0;
    }

    if (b == c) {
        cout << a << endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve (void)
{

  int N; cin>>N;
  vector<string> vec (N);
  for (int i = 0; i < N; i++)
  {
    string str;
    cin>>str;
    sort(ALL(str));
    vec[i] = str;
  }
  sort(ALL(vec));
  int ANS = 0;
  for (int i = 0; i < N-1; i++)
  {
    static int cnt = 1;
    if(vec[i] == vec[i+1])cnt++;
    else
    {
      ANS += cnt*(cnt-1)/2;
      cnt = 1;

    }

    if(i == N-2 && cnt != 1)      ANS += cnt*(cnt-1)/2;
  }
  // DEBUG(vec);
  cout<<ANS<<endl;
  
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 5760
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

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

	int m;
	cin >> m;

	for (int i = 0; i < m; i++)
	{
		int b, e, k;
		cin >> b >> e >> k;

		println(count(a.begin() + b, a.begin() + e, k));
	}
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k, q; cin >> n >> k >> q;
  V<> p(n, k - q);
  while (q--) {
    int a; cin >> a, --a;
    ++p[a];
  }
  for (int i = 0; i < n; ++i) {
    cout << (p[i] > 0 ? "Yes" : "No") << '\n';
  }
}

Measured memory_bytes: 1024
n,m = map(int, input().split())

import math
mod = 10**9+7
if n==m:
    ans = math.factorial(n) * math.factorial(m) *2
    print(ans%mod)
elif abs(n-m)<2:
    ans = math.factorial(n) * math.factorial(m)
    print(ans%mod)
else:
    print(0)

Measured memory_bytes: 5184
//#include <bits/stdc++.h>
#include<iostream>
#include <iosfwd>
#include<limits.h>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <limits>
#include<stdio.h>
#include <queue>
#include <stack>
#include <math.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include<vector>
#include <chrono>
#include <random>
using namespace std;
using namespace std::chrono;
#define fr(i,j,n)   for(lli i=j;i<(n);++i)
#define bk(i,j,n)   for(lli i=j;i>=n;--i)
#define pb push_back
#define m_p make_pair
#define Fs first
#define Sc second
#define endl "\n"
#define MOD 1000000007
#define present(c,x)    ((c).find(x) != (c).end())
#define count1 __builtin_popcount
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define mem(p,v) memset(p,(lli)v,sizeof p);
#define ub upper_bound
#define lb lower_bound
typedef long long int lli;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<lli> vl;
typedef pair<lli,lli> pl;
inline lli max(lli a,lli b){ return a>b?a:b;}
inline lli min(lli a,lli b){ return a<b?a:b;}
void show(vector<lli> v)
{
    fr(i,0,v.size())
    cout<<v[i]<<" ";
    cout<<endl;
}
void show(vector<int> v)
{
    fr(i,0,v.size())
    cout<<v[i]<<" ";
    cout<<endl;
}
void show(int a[], int arraysize)
{
    for (int i = 0; i < arraysize; ++i)
        cout << a[i] << " ";
    cout<<endl;
}
void show(lli a[], lli arraysize)
{
    for (lli i = 0; i < arraysize; ++i)
        cout << a[i] << " ";
    cout<<endl;
}
void show(unordered_set<int> s)
{
    for (auto it = s.begin(); it != s.end(); it++)
    {
        cout << *it << " ";
    }
    cout<<endl;
}
void show(unordered_map<int,int> mp)
{
    for (auto it = mp.begin(); it != mp.end(); it++)
    {
        cout << it->first << " "<<it->second<<endl;
    }
    cout<<endl;
}


int main()
{
    lli t,n,k,ans;
    t=1;
    while(t)
    {
        lli x,y;
        cin>>x>>y;
        lli a=(y-2*x),b=(4*x-y);
        if(a>=0&&b>=0&&a%2==0&&b%2==0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
        t--;
    }
    return 0;
}



Measured memory_bytes: 3640
N, M = map(int, input().split())

ans_list = []
for i in range(N):
    k, *A = map(int, input().split())
    for a in A:
        ans_list.append(a)
        
ans = 0
for i in range(1, M+1):
    if ans_list.count(i) == N:
        ans += 1
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    string s, t; cin >> s >> t;
    t += t;
    int l = s.size();
    rep(i, l) {
        if(s == t.substr(i, l)) {
            yes();
        }
    }
    no();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=105;

struct edge{int to,cap,rev;};

int n,m;
int iter[maxn];
int level[maxn];
vector<edge>G[maxn];

void add_edge(int u,int v,int c) {
	G[u].pb(edge{v,c,int(G[v].size())});
	G[v].pb(edge{u,0,int(G[u].size()-1)});
}

bool bfs(int s,int t) {
	memset(level,0,sizeof(level));
	level[s]=1;
	int qh=0,qt=0,q[maxn];
	q[qt++]=s;
	while (qh<qt) {
		int u=q[qh++];
		for (edge e:G[u]) {
			if (!level[e.to] && e.cap) {
				level[e.to]=level[u]+1;
				if (level[t]) break;
				q[qt++]=e.to;
			}
		}
		if (level[t]) break;
	}
	return level[t];
}

int dfs(int u,int t,int f) {
	if (!f) return 0;
	if (u==t) return f;
	for (int& i=iter[u];i<G[u].size();i++) {
		edge& e=G[u][i];
		if (level[e.to]>level[u] && e.cap) {
			int d=dfs(e.to,t,min(f,e.cap));
			if (d) {
				G[u][i].cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int dinic(int s,int t) {
	int res=0;
	while (bfs(s,t)) {
		memset(iter,0,sizeof(iter));
		while (int flow=dfs(s,t,INF))
			res+=flow;
	}
	return res;
}

int main() {
	cin>>n>>m;
	for (int i=0;i<m;i++) {
		int u,v,c; cin>>u>>v>>c;
		add_edge(u,v,c);
	}
	cout<<dinic(0,n-1)<<'\n';
}


Measured memory_bytes: 3212
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
const long long mod_const = 1000000007;
using MIte = multimap<vector<long>, int>::iterator;

int main() {
	long N;
	cin >> N;

	string S;
	cin >> S;

	if (S[0] == 'W') {
		cout << "0" << endl;
		return 0;
	}

	vector<int> vLeft(2 * N, 0);
	long cnt1 = 0;
	for (int i = 0; i != 2 * N; ++i) {
		if (i % 2 == 1) {
			if (S[i] == 'B') {
				vLeft[i] = 0;
			}
			else if (S[i] == 'W') {
				vLeft[i] = 1;
				cnt1++;
			}
		}
		else {
			if (S[i] == 'B') {
				vLeft[i] = 1;
				cnt1++;
			}
			else if (S[i] == 'W') {
				vLeft[i] = 0;
			}
		}
	}

	vector<int> vRight(2 * N, 0);
	long cnt2 = 0;
	for (int i = 0; i != 2 * N; ++i) {
		if (i % 2 == 0) {
			if (S[i] == 'B') {
				vRight[i] = 0;
			}
			else if (S[i] == 'W') {
				vRight[i] = 1;
				cnt2++;
			}
		}
		else {
			if (S[i] == 'B') {
				vRight[i] = 1;
				cnt2++;
			}
			else if (S[i] == 'W') {
				vRight[i] = 0;
			}
		}
	}

	// vLeft[i] == vRight[i]となるiが一つでも存在したら答えは0通り
	bool fail = false;
	for (int i = 0; i != 2 * N; ++i) {
		if (vLeft[i] == vRight[i]) {
			fail = true;
			break;
		}
	}
	// vLeftとvRightで1となる数がNで同じにならなければ答えは0通り
	if ((cnt1 != N) || (cnt2 != N)) {
		fail = true;
	}
	if (fail) {
		cout << "0" << endl;
		return 0;
	}

	vector<long> v1(2 * N, 0);
	for (int i = (2 * N - 2); i >= 0; --i) {
		v1[i] = v1[i + 1] + vRight[i + 1];
	}

	long long ans1 = 1;
	long long used = 0;
	for (int i = (2 * N - 2); i >= 0; --i) {
		if (vLeft[i] == 1) {
			ans1 *= (v1[i] - used);
			ans1 = ans1 % mod_const;
			used++;
		}
	}

	for (int i = 1; i != N+1; ++i) {
		ans1 *= i;
		ans1 = ans1 % mod_const;
	}

	cout << ans1 << endl;

	return 0;
}

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

using namespace std;

#define foru(i, l, r) for (register int i = l; i <= r; i++)
#define ford(i, r, l) for (register int i = r; i >= l; i--)

int N;
char S[100002];
char T[100002];

int main() {
  scanf("%d%s%s", &N, S + 1, T + 1);
  for (int len = N; len >= 1; len--) {
    bool flag = true;
    for (int i = N - len + 1, j = 1; i <= N && flag; i++, j++)
      if (S[i] != T[j]) flag = false;
    if (flag) return printf("%d\n", (N << 1) - len), 0;
  }
  printf("%d\n", N << 1);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  char str[27],temp;
  int i=0,j=0;
  scanf("%s",str);
  while(str[i] != '\0')
    {
      temp = str[i];
      while(str[j] != '\0')
	{
	  if(temp == str[j] && i != j)
	    {
	      printf("no\n");
	      return 0;
	    }
	  j++;
	}
      j=0;
      i++;
    }
  printf("yes\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  string s,t;
  cin>>s>>t;
  int n=s.size();
  rep(i,n){
    if(s==t){
      cout<<"Yes"<<endl;
      return 0;
    }
    string u=s.substr(0,n-1);
    char c=s.back();
    s=c+u;
  }
  cout<<"No"<<endl;
}

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

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d) {
        cout << "Left";
    } else if (a + b == c + d) {
        cout << "Balanced";
    } else {
        cout << "Right";
    }
}


Measured memory_bytes: 3608
import java.util.Arrays;
import java.util.Scanner;
 
public class Main
{
    public static void main(String arg[])
    {
        Scanner scan = new Scanner(System.in);
        int a[]=new int[100+1];
        Arrays.fill(a, 0);
 
        while(scan.hasNext())
        {
            int in = scan.nextInt();
            a[in]++;
        }
 
        int max = 0;
        for(int i=1; i<a.length; i++)
        {
            if(max <=a[i])
                max=a[i];
        }
        for(int i=0; i<a.length; i++)
        {
            if(a[i]==max)
                System.out.println(i);
        }
 
    }
 
}


Measured memory_bytes: 26008
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
string s,t;
int q;
int sums[2][200000];
int sumt[2][200000];
signed main(){
  cin>>s>>t;
  cin>>q;
  rep(i,200000){
    sums[0][i]=0;
    sums[1][i]=0;
    sumt[0][i]=0;
    sumt[1][i]=0;
  }
  int sn=s.size();int tn=t.size();
  sums[s[0]-'A'][1]++;
  sumt[t[0]-'A'][1]++;
  rep1(i,sn){
    sums[0][i]=sums[0][i-1];
    sums[1][i]=sums[1][i-1];
    sums[s[i-1]-'A'][i]++;
  }
  rep1(i,tn){
    sumt[0][i]=sumt[0][i-1];
    sumt[1][i]=sumt[1][i-1];
    sumt[t[i-1]-'A'][i]++;
  }
  vector<int> res(q);
  rep(i,q){
    int a,b,c,d;cin>>a>>b>>c>>d;
    int k=sumt[0][d]-sumt[0][c-1]+1000000;
    int l=sumt[1][d]-sumt[1][c-1]+1000000;
    k-=sums[0][b]-sums[0][a-1];
    l-=sums[1][b]-sums[1][a-1];
    bool flag=false;
    if((2*k+l)%3==0&&(2*l+k)%3==0){
      flag=true;
    }
    	if(flag){
        cout<<"YES"<<endl;
      }
      else{
        cout<<"NO"<<endl;
      }
  }
  return 0;
}


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

int main() {
 
  int n;
  
  cin >> n;
  
  int ans = (n / 500) * 1000;
  int r = n % 500;
  ans += (r / 5) * 5;
  
  cout << ans << endl;
  
  return 0;
  
  
}

Measured memory_bytes: 256