akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
    static final String YES = "Yes";
    static final String NO = "No";

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long A;
        A = sc.nextLong();
        long B;
        B = sc.nextLong();
        long C;
        C = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(A, B, C);
    }
}

class Solver {
    public void solve(long A, long B, long C) {
        if (A == B && B != C) {
            System.out.println("Yes");
            return;
        }
        if (A == C && B != C) {
            System.out.println("Yes");
            return;
        }
        if (B == C && A != C) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}



Measured memory_bytes: 22996
#A_list =list(map(int,input().split()))
A_list = [int(x) for x in list(input())]
OP_list = ["","",""]
answer = ""
#current = 1
#current_sum = A_list[0]

def solve(current, current_sum):
    if current == 4:
        return current_sum == 7
    
    if solve(current + 1 , current_sum + A_list[current]):
        OP_list[current-1] = "+"
        return True
    
    if solve(current + 1 , current_sum - A_list[current]):
        OP_list[current-1] = "-"
        return True
    
    return False

solve(1,A_list[0])
answer = str(A_list[0]) + OP_list[0] + str(A_list[1]) + OP_list[1] + str(A_list[2]) + OP_list[2] + str(A_list[3]) + "=7"
print (answer)

Measured memory_bytes: 3064
#include "stdio.h"
#include <string.h>

int main(){
  int num[3];
  memset(num, '\0', sizeof(num));
  int five=0, seven=0;

  scanf("%d %d %d", &num[0], &num[1], &num[2]);
  for(int i=0; i<3; i++){
    if(num[i] == 5){
      five++;
    }
    else if(num[i] == 7){
      seven++;
    }
  }
  if(five == 2 && seven == 1) printf("YES");
  else  printf("NO");

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef std::pair<int, int> ipair;
const int MAX_V = 100010;
const int MAX_LOG_V = 17;
vector<ipair> G[MAX_V];

class TREE {

   public:
      int parent[MAX_LOG_V][MAX_V];
      int depth[MAX_V];
      ll distance[MAX_V];
      // int begin[MAX_V * 2];
      // int end[MAX_V * 2];
      int k = 0;
      vector<int> eulerT;

      // vertex, parent, depth, distance
      void dfs(int v, int p, int d, ll l) {
         parent[0][v] = p;
         depth[v] = d;
         distance[v] = l;
         // begin[v] = k;
         eulerT.push_back(v);
         k++;
         for (auto& g : G[v]) {
            if (g.first != p) {
               dfs(g.first, v, d + 1, l + g.second);
               eulerT.push_back(v);
               k++;
            }
         }
         // end[v] = k;
      }

      void init(int V, int root) {
         dfs(root, -1, 0, 0);
         for (int k = 0; k + 1 < MAX_LOG_V; k++) {
            for (int v = 0; v < V; v++) {
               if (parent[k][v] < 0) parent[k + 1][v] = -1;
               else parent[k + 1][v] = parent[k][parent[k][v]];
            }
         }
      }

      int lca(int u, int v) {
         if (depth[u] > depth[v]) swap(u, v);
         for (int k = 0; k < MAX_LOG_V; k++) {
            // if k th digit of depth[v] - depth[u] is 1
            if ((depth[v] - depth[u]) >> k & 1) {
               v = parent[k][v];
            }
         }
         if (u == v) return u;
         for (int k = MAX_LOG_V - 1; k >= 0; k--) {
            if (parent[k][u] != parent[k][v]) {
               u = parent[k][u];
               v = parent[k][v];
            }
         }
         return parent[0][u];
      }
};

int main() {
   int N;
   cin >> N;
   int a, b, c;
   for (int i = 0; i < N - 1; i++) {
      cin >> a >> b >> c;
      a--;
      b--;
      G[a].push_back(ipair(b, c));
      G[b].push_back(ipair(a, c));
   }
   int Q, K;
   cin >> Q >> K;
   K--; 
   TREE tree;
   tree.init(N, K);
   /*
   for (int i = 0; i < N; i++) {
      cout << "depth: " << tree.depth[i] << endl;
      cout << "distance: " << tree.distance[i] << endl;
   }
   */
   int u, v;
   for (int q = 0; q < Q; q++) {
      cin >> u >> v;
      u--;
      v--;
      ll ans = 0;
      ans += tree.distance[u] + tree.distance[v];
      // cout << "lca: " << u << " " << v << " " << tree.lca(u, v) << endl;
      // ans -= 2 * tree.distance[tree.lca(u, v)];
      cout << ans << endl;
   }
   
   return 0;
}


Measured memory_bytes: 20084
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; cin>>n>>k;
	if ((n+1)/2>=k) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  int n;
  cin >> n;
  
  vector<int> v(n);
  for (int i = 0; i < n; i++)
    cin >> v.at(i);
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int a = 0, b = 0;
  for (int i = 0; i < n; i++)
    if (i % 2 == 0)
      a += v.at(i);
    else
      b += v.at(i);
  cout << a - b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <vector>

using llong = long long;
static const long long INF = 1LL << 60;

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

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

int main()
{
  // Input
  int numItem;
  int weightMax;
  std::cin >> numItem >> weightMax;
  assert(1 <= numItem and numItem <= 100);
  assert(1 <= weightMax and weightMax <= 1.0e+9);
  std::vector<int> weight(1 + numItem);
  std::vector<llong> value(1 + numItem);
  for (int i = 1; i <= numItem; ++i) {
    std::cin >> weight[i] >> value[i];
    assert(1 <= weight[i] and weight[i] <= weightMax);
    assert(1 <= value[i] and value[i] <= 1.0e+3);
  }
  int valueMax = 0;
  for (int i = 1; i <= numItem; ++i) {
    assert(value[i] >= 1);
    valueMax += value[i];
  }

  // Init
  std::vector<std::vector<llong>> dp(1 + numItem);
  for (int i = 0; i <= numItem; ++i) {
    dp[i].assign(1 + valueMax, INF);
  }
  dp[0][0] = 0;

  // DP main
  for (int i = 0; i < numItem; ++i) {
    for (int v = 0; v <= valueMax; ++v) {
      if (dp[i][v] == INF)
        continue;
      chmin(dp[i + 1][v], dp[i][v]);
      if (v + value[i + 1] > valueMax)
        continue;
      chmin(dp[i + 1][v + value[i + 1]], dp[i][v] + weight[i + 1]);
    }
  }

  // Output
  int result = -1;
  for (int v = 0; v <= valueMax; ++v)
    if (dp[numItem][v] <= weightMax)
      chmax(result, v);
  std::cout << result << std::endl;

  return 0;
}


Measured memory_bytes: 79488
N = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if a[i] % 4 == 0:
        cnt += 1
    elif a[i] % 2 == 0:
        cnt += 0.5
if cnt >= N // 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int c[3][3];

int main(){
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> c[i][j];
		}
	}
	if (c[0][0] - c[0][1] != c[1][0] - c[1][1] || c[1][0] - c[1][1] != c[2][0] - c[2][1] ||
		c[0][1] - c[0][2] != c[1][1] - c[1][2] || c[1][1] - c[1][2] != c[2][1] - c[2][2] ||
		c[0][0] - c[1][0] != c[0][1] - c[1][1] || c[0][1] - c[1][1] != c[0][2] - c[1][2] ||
		c[1][0] - c[2][0] != c[1][1] - c[2][1] || c[1][1] - c[2][1] != c[1][2] - c[2][2]) {
		puts("No");
	}
	else {
		puts("Yes");
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String args[]) {
        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        String T = scan.next();
        for(int i = 0;i < S.length();i++){
            if(S.charAt(i) != T.charAt(i)){
                System.out.println("No");
                break;
            }else if((i == S.length() - 1)&&(S.length() == T.length() -1 )){
                System.out.println("Yes");
            }else if(S.length() == T.length()){
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 35692
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<pii> v;
    REP(i,n) {
        int x, y;
        cin >> x >> y;
        v.push_back(make_pair(x,y));
    }
    int fact = 1;
    FOR(i,2,n+1) fact *= i;
    double distsum = 0;

    vector<int> p(n);
    iota(ALL(p),0);

    do {
        double dist = 0;
        FOR(i,1,n) {
            dist += sqrt(pow(abs(v[p[i]].first - v[p[i-1]].first),2) + pow(abs(v[p[i]].second - v[p[i-1]].second),2));
        }
        distsum += dist;
    } while (next_permutation(ALL(p)));
    double ans = distsum / fact;

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,x1,x2;
	scanf("%d",&x1);
	scanf("%d",&x2);
	if(x1==x2){
		a=0;
	}
	if(x1>=x2){
		a=x1-x2;
	}
	if(x1<=x2){
		a=x2-x1;
	}
	printf("%d\n",a);
	return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main()
{
	map<string,int>a;
	int n;
	cin>>n;
	int mx=0;
	for(int i=1;i<=n;i++){
		string t;
		cin>>t;
		a[t]++;
		mx=max(mx,a[t]);
	}
	for(auto i:a){
		if(i.second==mx){
			cout<<i.first<<'\n';
		}
	}
} 

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define nn 65536*4
vector<ll> ops;ll n,q; 
ll ans[nn];
ll chafen[nn];ll f[nn];
int main()
{
	scanf("%lld%lld",&n,&q);
	ops.push_back(n);
	while(q--)
	{
		ll x;scanf("%lld",&x);
		while(ops.size() and ops[ops.size()-1]>=x) ops.pop_back();
		ops.push_back(x);
	}
	f[ops.size()-1]=1;
	for(int i=ops.size()-1;i>=0;i--)
	{
		if(i==0) 
		{
			for(int j=1;j<=ops[i];j++) ans[j]+=f[i];
			continue;
		}
		f[i-1]+=f[i]*(ops[i]/ops[i-1]);
		ll lft=ops[i]%ops[i-1];
		
		while(1)
		{
			ll l=0,r=i-1;ll res=-1;
			while(l<=r)
			{
				ll mid=(l+r)/2;
				if(ops[mid]<=lft)
					l=mid+1,res=mid;
				else r=mid-1;
			}
			if(res==-1) 
			{
				chafen[1]+=f[i];
				chafen[lft+1]-=f[i];
				break;
			}
			f[res]+=(lft/ops[res])*f[i];
			lft%=ops[res];
		}
	}
	for(int i=1;i<=n;i++) chafen[i]+=chafen[i-1];
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]+chafen[i]);
	return 0;
} 


Measured memory_bytes: 7540
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if((a==b) && (a==c)){
        cout << "1" << endl;
    }else if((a == b) || (a == c) || (b == c)){
        cout << "2" << endl;
    }
    else{
        cout << "3" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  char op = 'a';
  
  while(op != '?'){
    cin >> a >> op >> b;
    if (op == '?'){
      break;
    }
    else if(op == '+'){
      cout << a + b << endl;
    }
    else if(op == '-'){
      cout << a - b << endl;
    }
    else if(op == '*'){
      cout << a * b << endl;
    }
    else{
      cout << a / b << endl;
    }
  }
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int) 1e9 + 7;
const double EPS = 1e-9;

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 (b < a) { a = b;return 1; }return 0; }
int main() {
    int h,w;
    cin >> h >> w;
    string s[110];
    rep(i,h){
        cin >> s[i];
    }
    //縦列での圧縮を考える
    bool uy[110] ={};
    bool ux[110] = {};
    rep(x,w){
        int y = 0;
        for(;y<h;y++){
            if(s[y][x]=='#') break;
        }
        if(y==h) ux[x] = true;
    }
    rep(y,h){
        int x = 0;
        for(;x<w;x++){
            if(s[y][x]=='#') break;
        }
        if(x==w) uy[y] = true;
    }
    rep(y,h){
        if(uy[y]) continue;
        rep(x,w){
            if(ux[x]) continue;
            cout << s[y][x];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

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

	vector<vector<long long> > dp(n+1,vector<long long>(6000,0));
	for(int i=0;i<=n;i++)
		dp[i][3000]=1;

	for(int i=1;i<=n;i++)
		for(int j=0;j<5700;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j+(x[i]-a)>=0 and j-(x[i]-a)<=5900)dp[i][j]+=dp[i-1][j-(x[i-1]-a)];
		}

	cout << dp[n][3000]-1 << endl;

/*
	for(int i=0;i<=n;i++)
	{
		for(int j=2990;j<=3010;j++)
			cout << dp[i][j] << "  ";
		cout << endl;
	}
*/	




}

Measured memory_bytes: 2688
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int n,l;
    
    cin >> n >> l;
    
    int sum = 0;
    int eat = 100000;
    
    for (int i = 1;i <= n;i++){
        sum += l+i-1;
        if (abs(eat)>abs(l+i-1)){
            eat = l+i-1;
        }
    }
    
    cout << sum-eat << endl;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  string *s = new string[h];
  for (int i = 0; i < h; i++)
    cin >> s[i];
  
  if (h == 1 && w == 1) {
    cout << ((s[0][0] == '#') ? '#' : '0') << endl;
    delete[] s;
    return 0;
  }
  
  if (h == 1) {
    for (int j = 0; j < w; j++) {
      if (s[0][j] == '#') {
        cout << s[0][j];
        continue;
      }
      if (j == 0)
        s[0][j] = (s[0][j+1]=='#');
      else if (j == w-1)
        s[0][j] = (s[0][j-1]=='#');
      else
        s[0][j] = (s[0][j-1]=='#')+(s[0][j+1]=='#');
      cout << (char)(s[0][j]+48);
    }
    cout << endl;
    delete[] s;
    return 0;
  }
  
  if (w == 1) {
    for (int i = 0; i < h; i++) {
      if (s[i][0] == '#') {
        cout << s[i][0] << endl;
        continue;
      }
      if (i == 0)
        s[i][0] = (s[i+1][0]=='#');
      else if (i == h-1)
        s[i][0] = (s[i-1][0]=='#');
      else
        s[i][0] = (s[i-1][0]=='#')+(s[i+1][0]=='#');
      cout << (char)(s[i][0]+48) << endl;
    }
    delete[] s;
    return 0;
  }
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        cout << s[i][j];
        continue;
      }
      if (i == 0 && j == 0)
        s[i][j] = (s[(i+1)%h][j]=='#')+(s[i][(j+1)%w]=='#')+(s[(i+1)%h][(j+1)%w]=='#');
      else if (i == 0 && j == w-1)
        s[i][j] = (s[(i+1)%h][j]=='#')+(s[i][(j-1)%w]=='#')+(s[(i+1)%h][(j-1)%w]=='#');
      else if (i == h-1 && j == 0)
        s[i][j] = (s[(i-1)%h][j]=='#')+(s[i][(j+1)%w]=='#')+(s[(i-1)%h][(j+1)%w]=='#');
      else if (i == h-1 && j == w-1)
        s[i][j] = (s[(i-1)%h][j]=='#')+(s[i][(j-1)%w]=='#')+(s[(i-1)%h][(j-1)%w]=='#');
      else if (i == 0)
        s[i][j] = (s[i][(j-1)%w]=='#')+(s[(i+1)%h][(j-1)%w]=='#')+(s[(i+1)%h][j]=='#')+(s[i][(j+1)%w]=='#')+(s[(i+1)%h][(j+1)%w]=='#');
      else if (j == 0)
        s[i][j] = (s[(i-1)%h][j]=='#')+(s[(i-1)%h][(j+1)%w]=='#')+(s[(i+1)%h][j]=='#')+(s[i][(j+1)%w]=='#')+(s[(i+1)%h][(j+1)%w]=='#');
      else if (i == h-1)
        s[i][j] = (s[i][(j-1)%w]=='#')+(s[(i-1)%h][(j-1)%w]=='#')+(s[(i-1)%h][j]=='#')+(s[i][(j+1)%w]=='#')+(s[(i-1)%h][(j+1)%w]=='#');
      else if (j == w-1)
        s[i][j] = (s[(i-1)%h][j]=='#')+(s[(i-1)%h][(j-1)%w]=='#')+(s[(i+1)%h][j]=='#')+(s[i][(j-1)%w]=='#')+(s[(i+1)%h][(j-1)%w]=='#');
      else
        s[i][j] = (s[i-1][j]=='#')+(s[(i-1)%h][j+1]=='#')+(s[i][j+1]=='#')+(s[i+1][j+1]=='#')+(s[i+1][j]=='#')+(s[i+1][j-1]=='#')+(s[i][j-1]=='#')+(s[i-1][j-1]=='#');
      cout << (char)(s[i][j]+48);
    }
    cout << endl;
  }
  delete[] s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
const int maxn = 100000+5;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

int n, q;
string s;
int pre[maxn];

void get_pre(){
    int t[maxn];
    memset(t, 0, sizeof(t));


    t[0] = 0;
    for(int i = 1; i < n; ++i)
        if(s[i-1] == 'A' && s[i] == 'C')
            t[i] = 1;

    pre[0] = 0;
    for(int i = 1; i < n; ++i)
        pre[i] = pre[i-1] + t[i];
}

int main(){
    //freopen("input.txt", "r", stdin);
    fastio();

    cin>>n >> q >>s;
    get_pre();

    while(q--){
        int l, r;
        cin >> l >> r; --l, --r;
        cout<<pre[r] - pre[l]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1872
#include<cstdio>
#include<vector>
#include<queue>
#include<ctime>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<bitset>
using namespace std;

typedef long long LL;
typedef double DL;

const int INF = 2147483647;
const int maxn = 100010;

int n;

inline LL getint()
{
	LL ret = 0,f = 1;
	char c = getchar();
	while (c < '0' || c > '9')
	{
		if (c == '-') f = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') 
		ret = ret * 10 + c - '0',c = getchar();
	return ret * f;
}

int main()
{
	#ifdef AMC
		freopen("AMC1.txt","r",stdin);
	#endif
	n = getint(); int ans = 0;
	for (int i = 1; i <= n; i++)
		if (getint() & 1) ans = 1;
	puts(ans ? "first" : "second");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
	char c[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}
	cout << c[0][0] << c[1][1] << c[2][2] << '\n';
	return 0;
}

Measured memory_bytes: 256
from collections import deque

def main():
    n, q = map(int, input().split())
    tree = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        tree[a-1].append(b-1)
        tree[b-1].append(a-1)
    
    ans = [0]*n
    for _ in range(q):
        p, x = map(int, input().split())
        ans[p-1] += x
    
    not_yet = deque([0])
    already = [False]*n
    already[0] = True
    
    while not_yet:
        key = not_yet.popleft()
        for value in tree[key]:
            if already[value]:
                continue
            already[value] = True
            not_yet.append(value)
            ans[value] += ans[key]
    
    print(*ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 107028
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll MOD=998244353;
const int MAX=200010;

signed main(){
    ll n;cin>>n;
    vector<ll>a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    vector<vector<ll> >dp(n+1,vector<ll>(90010));
    dp[0][0]=1;
    rep(i,n){
        rep(j,90010){
            if(a[i]+j<=90000){
                dp[i+1][a[i]+j]=(dp[i+1][a[i]+j]+dp[i][j])%MOD;
            }
            dp[i+1][j]=(dp[i][j]*2%MOD+dp[i+1][j])%MOD;
        }
    }
    ll cnt=0;
    REP(j,(sum+1)/2,90001)cnt=(cnt+dp[n][j])%MOD;
    cnt=cnt*3%MOD;
    rep(i,n+1){
        rep(j,90001){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    rep(i,n){
        rep(j,90010){
            if(a[i]+j<=90000){
                dp[i+1][a[i]+j]=(dp[i+1][a[i]+j]+dp[i][j])%MOD;
            }
            dp[i+1][j]=(dp[i][j]+dp[i+1][j])%MOD;
        }
    }
    ll cnt2=0;
    if(sum%2==0){
        cnt2=dp[n][sum/2]*3%MOD;
    }
    ll ans=1;
    rep(i,n){
        ans=ans*3%MOD;
    }
    ans=(ans-(cnt-cnt2)%MOD)%MOD;
    if(ans<0)ans+=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 215712
#include <cassert>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int main(void) {
  //クエリの数
  int nQuery;
  cin >> nQuery;
  cin.ignore();
  //中央値を基準に、大小を二つに分けて管理
  //左側の最大値と、右側の最小値を計算
  ll bsum = 0; // bの合計(定数)
  priority_queue<ll> q1; // 大きい順に出る
  priority_queue<ll, vector<ll>, greater<ll> > q2; // 小さい順に出る
 //unsignedのまま扱うには、INFの左側、右側を利用する
  const ll INF = 1e10;
  ll sum1 = 0;
  ll sum2 = 0;
  
  REP(iQuery, nQuery) {
    int type;
    cin >> type;
    if(type == 1) { //更新
      ll a, b;
      cin >> a >> b;
      cin.ignore();
      bsum += b; //定数項は足すだけ
      if(q1.size() == q2.size()) {//右側に追加するパターン
        q2.push(a);
        sum2 += a - (-INF);
        //最小のものをとって、q1に付け替える。
        ll t = q2.top(); q2.pop();
        sum2 -= t - (-INF);
        q1.push(t);
        sum1 += INF - t;
      } else {
      	//q1に追加
        q1.push(a);
        sum1 += INF - a;
      	//q1の最大のものをq2に付け替える
        ll t = q1.top(); q1.pop();
        sum1 -= INF - t;
        q2.push(t);
        sum2 += t - (-INF);
      }
    } else { //最小値算出
      cin.ignore();
      if(q1.empty()) {
        assert(false);
      } else {
        ll a = q1.top();
        ll v = 0;
        //中央値の時に傾きが0になる。ほかの項の総和がその時の値
        //ここまでの左側の和(INFを除いたもの)から中央値を引いたもの
        v += sum1 - (INF - a) * (int)q1.size();
        //右側の和から中央値を引いたもの
        v += sum2 - (a - (-INF)) * (int)q2.size();
        cout << a << " " <<v+bsum << endl;
      }
    }
  }
    
  return 0;
}


Measured memory_bytes: 3828
import heapq
import sys
input = sys.stdin.buffer.readline

def dijkstra(start: int, graph: list) -> list:
    """dijkstra法: 始点startから各頂点への最短距離を求める
    計算量: O((E+V)logV)
    """
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    n = len(graph)
    dist = [INF] * n
    ptn = [0] * n 
    dist[start] = 0
    ptn[start] = 1 
    q = [(0, start)] # q = [(startからの距離, 現在地)]
    while q:
        d, v = heapq.heappop(q)
        if dist[v] < d:
            continue
        for nxt_v, cost in graph[v]:
            if dist[v] + cost == dist[nxt_v]:
                ptn[nxt_v] += ptn[v]
                ptn[nxt_v] %= MOD
            if dist[v] + cost < dist[nxt_v]:
                dist[nxt_v] = dist[v] + cost
                ptn[nxt_v] = ptn[v]
                ptn[nxt_v] %= MOD
                heapq.heappush(q, (dist[nxt_v], nxt_v))
    return dist, ptn




n, m = list(map(int, input().split()))
s, t = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]
MOD = 10 ** 9 + 7

s -= 1
t -= 1
graph = [[] for i in range(n)]
for a, b, cost in info:
    a -= 1
    b -= 1
    graph[a].append((b, cost))
    graph[b].append((a, cost))
    
dist_st, ptn_st = dijkstra(s, graph)
dist_ts, ptn_ts = dijkstra(t, graph)

min_cost, max_ptn = dist_st[t], ptn_st[t]
all_ptn = (max_ptn * max_ptn) % MOD

# 最短路で使用する頂点を復元
use = [False] * n
use[t] = True
stack = [t]
while stack:
    v = stack.pop()
    for prv_v, cost in graph[v]:
        if use[prv_v]:
            continue
        if dist_st[v] == dist_st[prv_v] + cost:
            use[prv_v] = True
            stack.append(prv_v)

# 頂点上で出会うとき
for i in range(n):
    if dist_st[i] == dist_ts[i] and use[i]:
        all_ptn -= (ptn_st[i] * ptn_ts[i]) ** 2
        all_ptn %= MOD
        
# 辺上で出会うとき
for a, b, cost in info:
    a -= 1
    b -= 1
    if abs(dist_st[a] - dist_st[b]) != cost:
        continue
    if (not use[a]) or (not use[b]):
        continue
    if dist_st[a] > dist_st[b]:    
        a, b = b, a
    if dist_st[a] < dist_ts[a] and dist_st[b] > dist_ts[b]:
        all_ptn -= (ptn_st[a] * ptn_ts[b]) ** 2
    all_ptn %= MOD
print(all_ptn)

Measured memory_bytes: 126044
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  char s[101];
  scanf("%s",s);
  int n=0;
  while(s[n]!='\0') n++;
  int min=n-1;
  int i,j;
  for(i=0;i<n;i++){
    int local=0;
    for(j=0;j<n;j++){
      int k;
      for(k=j;k<n;k++){
	if(s[k]==s[i]) break;
      }
      local=MAX(local,k-j);
    }
    min=MIN(local,min);
  }
  printf("%d\n",min);
}

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


Measured memory_bytes: 128
// Problem : D - Not Divisible
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define fi first
#define se second
#define pb push_back
 
#define ll long long
#define pii pair<int, int>
//#define int ll
const int MOD = 1000000007;

int has[1000006];
int v[200005];

bool te(int d, int i) {
	if(d == i) return has[d] <= 1;
	else return has[d] == 0;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    rep(i, n) {
    	cin >> v[i];
    	has[v[i]]++;
    }
    int ans = 0;
    rep(i, n) {
    	bool ok = 1;
    	int p = v[i];
    	for(int j=1; j*j<=p; j++) {
    		if(p % j) continue;
    		ok = ok && te(j, p);
    		ok = ok && te(p/j, p);
    	}
    	ans += ok;
    }
    cout << ans << endl;
}



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

const bool DEBUG = false;

string S;

void input() { cin >> S; }

int main(int argc, char const *argv[]) {
  input();
  if (S[0] == S[1] && S[1] == S[2]) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class309
    {
        static void Main()
        {
            string s = Console.ReadLine();
            int count = 0;
            string last = "";
            string now = "";
            for(int i = 0; i < s.Length; i++)
            {
                now += s[i];
                if (now != last)
                {
                    count++;
                    last = now;
                    now = "";
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 15712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	int n,m;
	cin >> n >> m;
	vector<pair<bool,int>> box(n);
	box[0].first = true;
	box[0].second = 1;
	for(int i=1;i<n;i++){
		box[i].first = false;
		box[i].second = 1;
	}
	rep(i,m){
		int x,y;
		cin >> x >> y;
		x--;y--;
		if(box[x].first==true)
			box[y].first = true;
		box[y].second++;
		box[x].second--;
		if(box[x].second == 0)
			box[x].first = false;
	}
	int cnt=0;
	rep(i,n){
		if(box[i].first == true)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3940
#include "bits/stdc++.h"

using namespace std;

int main()
{
	string s;
	cin >> s;

	for (int i = 1; i < 4; i++)
	{
		if (s[i] == s[i - 1])
		{
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t;
    cin >> t;
    // vector<lli> v;
    lli c1 = 0, c2 = 0, c3 = 0, c4 = 0;

    while (t--)
    {
        string s;
        cin >> s;
        if (s.length() == 2)
        {
            if (s[0] == 'A' && s[1] == 'C')
            {
                c1 += 1;
            }
            else if (s[0] == 'W' && s[1] == 'A')
            {
                c2 += 1;
            }
            else if (s[0] == 'R' && s[1] == 'E')
            {
                c4 += 1;
            }
        }
        else if (s.length() == 3)
        {
            if (s[0] == 'T' && s[1] == 'L' && s[2] == 'E')
            {
                c3 += 1;
            }
        }
    }
    cout << "AC x  " << c1 << endl;
    cout << "WA x  " << c2 << endl;
    cout << "TLE x  " << c3 << endl;
    cout << "RE x  " << c4 << endl;
}

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

using namespace std;

int dp[100005],h[10005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
	scanf("%d",h+i);
	for(int i=n;i>=1;--i)
	{
		if(i == n)
		dp[i] = 0;
		else
		{
			if(i+1 <= n)
			dp[i] = dp[i+1]+abs(h[i]-h[i-1]);
			if(i+2 <= n)
			dp[i] = min(dp[i],dp[i+2]+abs(h[i+1]-h[i-1]));
		}
	}
	printf("%d\n",dp[1]);
	return 0;
}


Measured memory_bytes: 640
*A,=sorted(map(int,input().split()))

ans=0
if (A[1]-A[0])%2==0:
    ans=(A[1]-A[0])//2
    ans+=A[2]-A[1]
else:
    ans=(A[1]-A[0])//2+1
    ans+=A[2]+1-A[1]
    
print(ans)

Measured memory_bytes: 9116
#include<stdio.h>
int main()
{
  char s[4];
  scanf("%s",s);
  if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]){
    printf("Yes\n");
  }
  else if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]){
    printf("Yes\n");
  }
  else if(s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)

CARDS = defaultdict(int)
N = int(input())

for _ in range(N):
    s = input()
    CARDS[s] += 1

M = int(input())

for _ in range(M):
    s = input()
    CARDS[s] -= 1

ans = 0
for v in CARDS.values():
    ans = max(v, ans)


print(ans)


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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int a=0,b=0;

  string s;cin>>s;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      if(s[i]=='0')a++;
      else b++;
    }else{
      if(s[i]=='1')a++;
      else b++;
    }
  }

  cout<<min(a,b)<<endl;

  
  return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>
#include <math.h>
int main ()
{
    double Xa,Ya,Ra,Xb,Yb,Rb,distance;
    int test,i;
    scanf("%d",&test);
    for (i=1;i<=test;i++)
    {
    scanf("%lf %lf %lf %lf %lf %lf" , &Xa,&Ya,&Ra,&Xb,&Yb,&Rb);
    distance=sqrt((Xa-Xb)*(Xa-Xb)+(Ya-Yb)*(Ya-Yb));
    if (distance>=0 && distance<fabs(Ra-Rb))
    {
        if (Ra>Rb)
        {
            printf("2\n");
        }
        else if (Ra<Rb)
            {
            printf("-2\n");
        }
        else
            printf("1\n");
    }
    else if (distance >=fabs(Ra-Rb) && distance <=(Ra+Rb))
    {
        printf("1\n");
    }
    else
        printf("0\n");


}
 return 0;
}

Measured memory_bytes: 620
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <math.h>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}

Int count(Int n, Int x){
    if(n == -1){
        return 0;
    }

    return n/x +1;
}


int main() {
    Int a,b,x;

    cin >> a >> b >> x;

    cout << count(b,x) - count(a-1,x) << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<ctime>
#include<cassert>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[1000000];
int main()
{	int n;ll ans=0; cin>>n;
	for(rint i=1;i<=n;i++) scanf("%d",&a[i]); a[0]=-1;
	for(rint i=1;i<=n;i++) if(a[i]>a[i-1]+1) return !printf("-1");
	for(rint i=1;i<=n;i++)
	{	while(a[i+1]==a[i]+1&&i<=n) i++;
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}


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



int main() {
    int a, b;
    cin >> a >> b;
    
    int ans = a - b * 2;
    if(ans < 0) {
        cout << 0 << endl;
    }
    else
        cout << ans << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,A[100]={},count=0,flag=1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    int i=0;
    while(flag){
        flag=0;
        for(int j=n-1;j>=i+1;j--){
            if(A[j]<A[j-1]){
                int tmp=A[j-1];
                A[j-1]=A[j];
                A[j]=tmp;
                count+=1;
                flag=1;
            }
        }
        i+=1;
    }
    for(int i=0;i<n;i++){
        if(i>0) cout<<" ";
        cout<<A[i];
    }cout<<endl;
    cout<<count<<endl;
    return 0;
    
}





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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  bitset<100001> dp;
  dp[0] = 1;
  for (int c = 100; c <= 105; ++c) {
    for (int x = 0; x + c <= 100000; ++x) {
      if (dp[x]) {
        dp[x + c] = 1;
      }
    }
  }
  int x;
  cin >> x;
  cout << dp[x] << '\n';
}


Measured memory_bytes: 256
def solve():
    MOD = 998244353
    maxNK = 2000

    K, N = map(int, input().split())

    def getInvs(n, MOD):
        invs = [1] * (n+1)
        for x in range(2, n+1):
            invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
        return invs

    def getCombss(n, k, invs, MOD):
        def getCombNs(n, k, invs, MOD):
            combNs = [1] * (n//2+1)
            for x in range(1, n//2+1):
                combNs[x] = (combNs[x-1] * (n-x+1) * invs[x]) % MOD
            return (combNs + combNs[:(n+1)//2][::-1])[:k+1]
        combss = [[] for n in range(n+1)]
        for x in range(n+1):
            combss[x] = getCombNs(x, k, invs, MOD)
            combss[x] += [0] * (k+1-len(combss[x]))
        return combss

    invs = getInvs(2*maxNK, MOD)
    combss = getCombss(2*maxNK, maxNK, invs, MOD)

    def getPows(base, n, MOD):
        pows = [1] * (n+1)
        for x in range(1, n+1):
            pows[x] = (pows[x-1] * base) % MOD
        return pows
    pow2s = getPows(2, N, MOD)

    anss = []
    for i in range(2, K+2, 2):
        ans = 0
        numFree = abs(K+1-i)
        numPair = (K-numFree+1)//2
        numPair -= 1
        for x in range(min(numPair, N)+1):
            ans += combss[numPair][x] * pow2s[x] * combss[N+numFree-1][N-x] % MOD
            ans %= MOD
        for x in range(min(numPair, N)+1):
            ans += combss[numPair][x] * pow2s[x] * combss[N+numFree-2][N-x-1] % MOD
            ans %= MOD
        anss.append(ans)
        if i+1 <= K+1:
            anss.append(ans)

    anss = anss + anss[:-1][::-1]
    print('\n'.join(map(str, anss)))


solve()


Measured memory_bytes: 208532
#include<bits/stdc++.h>
#include <sstream>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define ull unsigned long long int
#define ll long long
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
ll MD=1000000007;
ll md=998244353;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}//put b as bmod(md-1) if md is prime}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll pow_2(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}
bool isPrime(ll a)
{
    for(ll i=3; (i*i)<=a; i+=2)
    {
        if( (a%i)==0 )
            return false;
    }
    if( ( a!=2 ) && ( (a%2)==0 ) )
        return false;
    if( a==1 )
        return false;

    return true;
}
string decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    string s="";
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            //cout << "1";
            s=s+"1";
        else
            //cout << "0";
            s=s+"0";
    }
    return s;
}
int decimalToBinary(int N)
{

    // To store the binary number
    ull B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        ull c = pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        // Count used to store exponent value
        cnt++;
    }

    return B_Number;
}
string toString(ull num)
{
    std::string number;
    std::stringstream strstream;
    strstream << num;
    strstream >> number;
    return number;
}
const double PI = acos(-1);
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n;
  	cin>>n;
  	int h[n];
  	fo(i,0,n-1)cin>>h[i];
  	int dp[n];
  	dp[0]=0;
  	dp[1]=abs(h[1]-h[0]);
  	for(int i=2;i<n;i++)
    {
      dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
  cout<<dp[n-1]<<endl;
return 0;}



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

int main() {
    int N, bk, l = 0; cin >> N >> bk;
    for (int i = 1; i < N; i++) {
        int x; cin >> x;
        if (abs(x - bk) > 1) {
            if (bk > x) {
                cout << "No" << endl;
                return 0;
            }
        } else if (x == bk) continue;
        bk = x - 1;
        l = max(l, x-1);
        if (l > bk) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
Graph G;
  
/*------------------------------------------------------------------*/
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
int main(){
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    rep(i, h) rep(j, w) if(s[i][j] == '.') s[i][j] = '0';

    rep(i, h){
        rep(j, w){
            if(s[i][j] == '#'){
                rep(k, 8){
                    int nh = i + dh[k];
                    int nw = j + dw[k];
                    if(nh < 0 or nh >= h or nw < 0 or nw >= w) continue;
                    if(s[nh][nw] != '#') s[nh][nw]++;
                }
            }
        }
    }
    rep(i, h){
        rep(j, w){
            cout << s[i][j];
        }
        cout << endl;
    }  
}

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

using namespace std;

int main(){
	int n, h, w;
	cin>>h>>w>>n;
	int c[n+1];
	for(int i=0; i<n; i++)cin>>c[i+1];
	int col=1;
	int tab[h][w];
	for(int i=0; i<h; i++){
		int emp, lim, sum;
		if(i%2==0){
			emp=0;
			lim=w;
			sum=1;
		}else{
			emp=w-1;
			lim=-1;
			sum=-1;
		}
		for(int j=emp; j!=lim; j+=sum){
			if(c[col]==0)col++;
			tab[i][j]=col;
			c[col]--;
		}
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cout<<tab[i][j]<<" ";
		}
		cout<<"\n";
	}
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

string s;
int ans = 0;
string t;
string t2;
queue<string>f, b;

bool check(){
    t2 = t;
    for(char c = 'b'; c <= 'z'; c++){
        for(int i = 0; i < t2.size(); i++){
            if(t2[i] == c){
                t2[i]--;
                break;
            }
        }
    }
    for(int i = 0; i < s.size(); i++){
        if(t2[i] == '*')break;
        if(t2[i] != s[i])return false;
    }
    return true;
}


void dfs(int idx){
    if(idx == s.size()){
        ans++;
        if(f.size() < 5)f.push(t);
        else{
            b.push(t);
            while(b.size() > 5)b.pop();
        }
    }
    else{
        t[idx] = s[idx];
        if(check())dfs(idx+1);
        if(t[idx] < 'z'){
            t[idx]++;
            if(check())dfs(idx+1);
        }
        t[idx] = '*';
    }
}

int main(){

    for(;cin >> s;){
        if(s == "#")break;
        ans = 0;
        t = string(s.size(), '*');
        dfs(0);
        cout << ans << endl;
        while(!f.empty()){
            cout << f.front() << endl;
            f.pop();
        }
        while(!b.empty()){
            cout << b.front() << endl;
            b.pop();
        }
    }

    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
using namespace std;
int main()
{
int a,b,c,i ;

cin>>a>>b>>c;
if( (a>0 && a<=9) && (b>0 && b<=9) && (c>0 && c<=9))
{

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

}}}

Measured memory_bytes: 384
NK = list(map(int, input().split()))
N = NK[0]
K = NK[1]
A = list(map(int, input().split()))

done = [1]
donedic = {}
donedic[1] = 1
now = 1
for i in range(1,N+1):
    nexttown = A[now-1]
    #print(now, "->", nexttown)
    try:
        a = donedic[nexttown]
    except:
        donedic[nexttown] = 1
        done.append(nexttown)
        now = nexttown
    else:
        break

start = done.index(nexttown)
end = len(done)-1
before = start #ループに入るまでの転移数
loop = done[start:]

if K < before:
    saisyuu = done[K]
else:
    nokori = K-before
    n_loop = int(nokori/len(loop))
    loopfirst = done[start]
    hasuu = nokori%len(loop)
    saisyuu = loop[hasuu]
    #print("1から",before,"回転移して",loopfirst,"に到着します。")
    #print("その後、大きさ",len(loop),"のループを",n_loop,"回転移して",loopfirst,"にいます。")
    #print("その後、",hasuu,"回の転移をして",saisyuu,"に到着します。")
print(saisyuu)


Measured memory_bytes: 35608
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int a,b;
  cin>>a>>b;
  int ans=0;
  if(b%a==0)ans=a+b;
  else ans=b-a;
  
  cout<<ans<<endl;
 
  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    int ans = 0;
    for (auto i = 0; i <= 999; i++) {
        vector<int> number(3);
        int tmp = i;
        for (auto j = 0; j < 3; j++) {
            number[j] = tmp % 10;
            tmp /= 10;
        }
        int cnt = 0;
        for (auto k = 0; k < (int)s.size(); k++) {
            if(s[k] - '0' == number[cnt]) cnt++;
            if(cnt == 3) {
                ans++;
                break;
            }
        }
    }

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

Measured memory_bytes: 256