akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int N;
int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101};
ull s;
unordered_map<ull, ll> num;

ull convert(string input) {
    ull ret = 1;
    for (char &c: input) {
        ret *= prime[c-'a'];
    }
    //cout << ret << endl;
    return ret;
}

int main() {
    cin >> N;
    string input;
    for (int i = 0; i < N; i++) {
        cin >> input;
        s = convert(input);
        num[s]++;
    }

    ll result = 0;
    for (auto n: num) {
        //cout << n.first << "=" << n.second << endl;
        result += n.second * (n.second - 1) / 2;
    }
    cout << result << endl;
}


Measured memory_bytes: 4388
N = int(input())
testi = {}
for i in range(N):
    T = []
    for a in range(int(input())):
        T.append(list(map(int, input().split())))
    testi[i+1] = T

ans = 0
for i in range(2**N):
    hypo = list(bin(i)[2:].zfill(N))
    num = hypo.count("1")
    for j, h in enumerate(hypo):
        if h == "1":
            for t in testi[j+1]:
                if hypo[t[0]-1] != str(t[1]):
                    break
            else:
                continue
            break
    else:
        if num > ans:
            ans = num

print(ans)

Measured memory_bytes: 45532
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def imos():
  for j in range(N+1):
    cnt = 0
    for i in range(N+1):
      tmp = l[j][i]
      l[j][i] += cnt
      cnt += tmp

  for j in range(N+1):
    cnt = 0
    for i in range(N+1):
      tmp = l[i][j]
      l[i][j] += cnt
      cnt += tmp

N,M,Q = IL()
l = [[0]*(N+1) for i in range(N+1)]
for i in range(M):
  a,b = IL()
  l[1][b] += 1
  if a+1 <= N:
    l[a+1][b] += -1

imos()

ans = [IL() for i in range(Q)]
for i in range(Q):
    print(l[ans[i][0]][ans[i][1]])

Measured memory_bytes: 39816
#include <bits/stdc++.h>
using namespace std; const int MAX = 666667;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
COMinit();
  int n,k;
  cin>>n>>k;
  int x=2*n-k;
  if(x%3!=0){
   cout<<0<<endl;
   return 0;
  }
  x/=3;
  int y=n-2*x;
  long long  xy=x+y;
int64_t ans=1;
long long u=min(x,y);

cout<<COM(xy,u)<<endl;
}



Measured memory_bytes: 15872
import sys

if __name__ == "__main__":
    para_list = list(map(int, input().split()))
    A = para_list[0]
    B = para_list[1]

    length = B-A+1
    if length == 1:
        print(A)
    elif A%2 == 0:
        if length%2 == 0:
            if length%4 ==0:
                print(0)
            else:
                print(1)
        else:
            if (length-1)%4 == 0:
                print(B)
            else:
                print(1^B)
    else:
        length -= 1
        if length%2 == 0:
            if length%4 ==0:
                print(A)
            else:
                print(A^1)
        else:
            if (length-1)%4 == 0:
                print(A^B)
            else:
                print(A^1^B)

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.NoSuchElementException;

public class Main {

	void solve() {

		a = in.nextInt();
		b = in.nextInt();
		c = in.nextInt();
		if (a == b) {
			out.println(c);
		} else if (b == c) {
			out.println(a);
		} else if (c == a) {
			out.println(b);
		}
		out.flush();
	}

	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	int n, a, b, c, d, e, f;
	ArrayDeque<Integer> q = new ArrayDeque<>();

	public static void main(String[] args) {
		new Main().solve();
	}

	class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		FastScanner(InputStream in) {
			this.in = in;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}

Measured memory_bytes: 21332
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if ((a + b) >= c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 20948
#include <set>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cstdio>
using namespace std;

set<vector<int>> S;
int P,Q,A,N;

struct Frac{
    int p,q;//frac{p}{q}
    Frac(int P, int Q){
        p=P; q=Q;
    }
    int gcd(int a, int b){
        if(b==0) return a;
        return gcd(b,a%b);
    }
    void reduce(){
        int d=gcd(p,q);
        if(d<0)d=-d;
        p/=d; q/=d;
    }
    Frac operator*(const Frac& F){
        Frac ret(p*F.p,q*F.q);
        ret.reduce();
        return ret;
    }
    Frac operator*(int d){
        Frac ret(p*d,q);
        ret.reduce();
        return ret;
    }
    Frac operator/(const Frac& F){
        Frac ret(p*F.q,q*F.p);
        ret.reduce();
        return ret;
    }
    Frac operator/(int d){
        Frac ret(p,q*d);
        ret.reduce();
        return ret;
    }
    Frac operator+(const Frac& F){
        Frac ret(p*F.q+q*F.p,q*F.q);
        ret.reduce();
        return ret;
    }
    Frac operator+(int d){
        Frac ret(p+q*d,q);
        ret.reduce();
        return ret;
    }
    Frac operator-(const Frac& F){
        Frac ret(p*F.q-q*F.p,q*F.q);
        ret.reduce();
        return ret;
    }
    Frac operator-(int d){
        Frac ret(p-q*d,q);
        ret.reduce();
        return ret;
    }
    bool operator<(const Frac& F){
        Frac ret(p*F.q-q*F.p,q*F.q);
        ret.reduce();
        return ret.p<0;
    }
    bool operator<=(const Frac& F){
        Frac ret(p*F.q-q*F.p,q*F.q);
        ret.reduce();
        return ret.p<=0;
    }
};

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

int rec(int rmin, int p, int q, int n){
    if(p*Q==q*P) return 1;
    if(n<=0||p*Q>q*P) return 0;
    int ret=0;
    for(int r=rmin;q*r<=A;r++){
        ret+=rec(r,p*r+q,q*r,n-1);
    }
    return ret;
}

int main(){
    while(scanf("%d %d %d %d",&P,&Q,&A,&N),P){
        cout<<rec(1,0,1,N)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3036
#include <stdio.h>
/* #include <stdlib.h> */
/* #include <math.h> */
#include <limits.h>

int absolute_value(int value){
  if(value < 0){
    value *= -1;
  }
  return value;
}

int main(){
  int N; scanf("%d", &N);
  int i, j;
  int W[100] = {};
  int S[101] = {};

  S[0] = 0;
  
  for(i = 0; i < N; i++){
    scanf("%d", &W[i]);
    S[i + 1] = S[i] + W[i];
    /* printf("%d\n", S[i + 1]); */
  }
  
  puts("");
  
  int min = INT_MAX;
  int S1, S2;
  for(j = 1; j < N; j++){
    S1 = S[j];
    S2 = S[N] - S[j];
    /* printf("S1 = %d, S2 = %d\n", S1, S2); */
    /* printf("S1 - S2 = %d\n", S1 - S2); */
    if(absolute_value(S1 - S2) < min){
      min = absolute_value(S1 - S2);
    }
  }

  printf("%d", min);
  return 0;
}


Measured memory_bytes: 128
N, K = map(int,input().split())
R = N-K
T = 1000000007

def generating_combination(n):
	T = 1000000007
	C = C = [[0 for i in range(n+1)] for j in range(n+1)]
	C[0][0] = 1
	C[1][0] = 1
	C[1][1] = 1
	for i in range(2,n+1):
		C[i][0] = 1
		C[i][i] = 1
		for j in range(1,i):
			C[i][j] = (C[i-1][j-1] + C[i-1][j])%T
	return(C)

D = generating_combination(N)
for i in range(1,K+1):
	print((D[K-1][i-1]*D[R+1][i])%T)


Measured memory_bytes: 99208
#include <bits/stdc++.h>
using namespace std;
const int N = 3000;

vector<vector<double>> memo(N+1, vector<double>(N+1, -1));
vector<double>p(N+1);

double prob(int n, int a){
    if (a > n or a<0) return 0;
    else if (memo.at(n).at(a) != -1) return memo[n][a];
    else if (a==0){
        memo[n][0] = 1;
        return memo[n][0];
    }
    else if (n==1 and a==1){
        memo[1][1] = p[1];
        return memo[1][1];
    }
    else {
        memo[n][a] = p[n]* prob(n-1, a-1) + (1-p[n])*prob(n-1, a);
        return memo[n][a];
    } 

}


int main(){
    int n; cin >> n;
    for (int i=1; i<=n; i++) cin >> p.at(i);
    
    cout.precision(10);
    cout << prob(n, n/2+1) << endl;
    return 0;

    
}


Measured memory_bytes: 74428
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  string s;
  cin >> s;
  int n=s.size();
  int zero=0,one=0;
  rep(i,n){
    if(s[i]=='0'){zero++;}else if(s[i]=='1'){one++;}
  }
  cout << 2*min(zero,one) << endl;
}

Measured memory_bytes: 3720
# input
n, k = map(int, input().split())
D = list(map(int, input().split()))

N = [int(x) for x in list(str(n))]
D_inv = sorted(list(set(range(10)) - set(D)))

m = len(N) + 1 # 置換する桁
for i in range(len(N)):
    if N[i] in D:
        m = i
        break

if m == len(N) + 1:
    print(n)
    exit()

n = len(N) + 1 # 置換可能な桁 
for i in range(m + 1):
    if N[i] < D_inv[len(D_inv) - 1]:
        n = i

ans = 0
if n == len(N) + 1: # 置換可能な桁がない場合
    if D_inv[0] == 0:
        ans += D_inv[1] * (10 ** len(N))
    else:
        ans += D_inv[0] * (10 ** len(N))
    for i in range(len(N)):
        ans += D_inv[0] * (10 ** (len(N) - 1 - i))
else:
    for i in range(len(N)):
        if i < n:
            ans += N[i] * (10 ** (len(N) - 1 - i))
        if i == n: 
            for j in D_inv:
                if j > N[i]:
                    ans += j * (10 ** (len(N) - 1 - i))
                    break
        if i > n:
            ans += D_inv[0] * (10 ** (len(N) - 1 - i))
print(ans)

Measured memory_bytes: 3188
import heapq
import collections as c
N, M = map(int ,input().split())
A = list(map(int, input().split()))
A_c = c.Counter(A)
q = []
for a in list(A_c.keys()):
	heapq.heappush(q, [-a, A_c[a]])

for _ in range(M):
	bt,ct = map(int, input().split())
	heapq.heappush(q,[-ct,bt])

cnt = 0
ans = 0
while True:
	s, p = heapq.heappop(q)
	cnt += p
	ans += (s*p)
	if cnt > N:
		break
ans -= (s*(cnt-N))
print(-ans)



Measured memory_bytes: 44484
#include<stdio.h>
#include<string.h>
int main()
{
    char A[10000];
    int i,l;
    gets(A);
    l = strlen(A);
    for(i=0;i<l;i++)
    {
        A[i] = 'x';
    }
    puts(A);
    return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int X, Y;
int field[20][20];
int dp[20][20];

int main() {
	while(scanf("%d %d", &X, &Y), X || Y) {
		rep(i, Y) rep(j, X) field[i][j] = 1;
		rep(i, Y) rep(j, X) scanf("%d", &field[i][j]);
		memset(dp, 0, sizeof(dp));
		rep(j, X) dp[0][j] = (field[0][j] == 0);
		rep(i, Y - 1) rep(j, X) {
			if(field[i][j] == 0) {
				if(field[i + 1][j] != 1) dp[i + 1][j] += dp[i][j];
				if(j - 1 >= 0 && field[i + 1][j - 1] == 0) dp[i + 1][j - 1] += dp[i][j];
				if(j + 1 < X && field[i + 1][j + 1] == 0) dp[i + 1][j + 1] += dp[i][j];
			}
			else if(field[i][j] == 2) {
				dp[i + 2][j] += dp[i][j];
			}
		}
		/*rep(i, Y) {
			rep(j, X) printf("%2d", dp[i][j]);
			puts("");
		}
		rep(i, X) printf("%2d", dp[Y][i]);
		*/
		int res = 0;
		rep(i, X) if(field[Y - 1][i] != 1) res += dp[Y - 1][i];
		rep(i, X) res += dp[Y][i];
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 3124
#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<ll> xs(n), ys(n), hs(n);
    rep(i, n) {
        cin >> xs[i] >> ys[i] >> hs[i];
    }
    for (int x = 0; x <= 100; x++) {
        for (int y = 0; y <= 100; y++) {
            ll height = -1;
            bool match = true;
            for (int i = 0; i < n; i++) {
                if (hs[i] == 0)
                    continue;
                if (height == -1) {
                    height = hs[i] + abs(x - xs[i]) + abs(y - ys[i]);
                    continue;
                }
                ll h = height - abs(x - xs[i]) - abs(y - ys[i]);
                if (h != hs[i]) {
                    match = false;
                    break;
                }
            }
            if (!match)
                continue;
            for (int i = 0; i < n; i++) {
                if (hs[i] > 0)
                    continue;
                ll h = height - abs(x - xs[i]) - abs(y - ys[i]);
                if (h > 0) {
                    match = false;
                    break;
                }
            }
            if (match) {
                cout << x << " " << y << " " << height << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
X = np.array(lr())
# Brute Force Attack
answer = 10 ** 6
for x in range(101):
    temp = ((X-x) ** 2).sum()
    if temp < answer:
        answer = temp

print(answer)


Measured memory_bytes: 12500
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
const string nyan("(=^・ω・^=)");

int N, b[200000], w[200000], res;
string S;

int main(){
	cin >> N >> S;
	for (int i = 0; i < N; ++i) {
		if (S[i] == '#') {
			++b[i];
		}
		else {
			++w[i];
		}
	}
	for (int i = 1; i < N; ++i) {
		b[i] += b[i - 1];
	}
	for (int i = N - 2; i >= 0; --i) {
		w[i] += w[i + 1];
	}
	res = min(w[0], b[N - 1]);
	for (int i = 0; i < N - 1; ++i) {
		res = min(res, b[i] + w[i + 1]);
	}
	cout << res << endl;
}


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

using namespace std;

int main() {
  int64_t A, B, C;
  int64_t X, Y;
  cin >> A >> B >> C >> X >> Y;

  int64_t minCost = 1LL << 60;
  for (int ci = 0; ci <= 2 * max(X, Y) + 10; ci += 2) {
    int ai = max(0L, X - ci / 2);
    int bi = max(0L, Y - ci / 2);
    int64_t cost = A * ai + B * bi + C * ci;
    minCost = min(minCost, cost);
  }
  printf("%ld\n", minCost);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
using namespace std;

int index(char c){
	return (int)c - '0';
}

int get_num(string s){
	int count = 0;
	count += index(s[0]) * 10;
	count += index(s[1]);
	return count;
}
int main(){
	int n;
	while(cin >> n){
		map<int, int> mp;
		int u[] = {
			1,1,1,1,1,1,1
		};
		for(int i = 0; i < n; i++){
			string num;
			cin >> num;
			int a = get_num(num);
			if(a / 10 == a % 10){
				u[a / 10] = 0;
			}else{
				mp[a / 10]++;
				mp[a % 10]++;
			}
		}
		int count = 0;
		for(int i = 0; i <= 6; i++){
			if(mp[i] % 2 == 1) count++;
			if(u[i] == 0 && mp[i] == 0) count += 2;
		}
		if(count > 2) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
n=int(input())
a=[0]*n
b=[0]*n
c=[0]*n
for i in range(n):
	a[i],b[i],c[i]=list(map(int,input().split(" ")))

f=[(0,0,0)]*n
f[0]=(a[0],b[0],c[0])
for i in range(1,n):
	f[i]=(a[i]+max(f[i-1][1],f[i-1][2]),b[i]+max(f[i-1][0],f[i-1][2]),c[i]+max(f[i-1][0],f[i-1][1]))

print(max(f[-1][0],f[-1][1],f[-1][2]))

Measured memory_bytes: 50904
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    ll n, m;
    cin >> n >> m;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<pair<ll, ll>> bc(m);
    for (int i = 0; i < m; ++i) {
        ll b, c;
        cin >> b >> c;
        bc.emplace_back(c, b);
    }
    sort(bc.begin(), bc.end(), greater<pair<ll, ll>>());
    sort(a.begin(), a.end(), greater<ll>());
    ll ret = 0;
    ll nleft = n;
    ll aind = 0;
    ll pind = 0;
    while (nleft > 0) {
        auto p = bc[pind];
        if (a[aind] < p.first) {
            pind++;
            if (p.second < nleft) {
                ret += p.second * p.first;
                nleft -= p.second;
            } else if (p.second >= nleft) {
                ret += nleft * p.first;
                nleft -= nleft;
            }
        } else {
            ret += a[aind];
            aind++;
            nleft--;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 5632
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<map>
using namespace std;
typedef pair<int, pair<int, int> >PP;
typedef long long ll;
typedef pair<int, int>P;
typedef vector<int>vec;
int inf=-1;
ll mod = pow(10, 9) + 7;
 
int main(){
    int n;cin>>n;
    for(int i=1;i<=9;i++){
        if(n%i==0 &&n/i<=9){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout <<"No"<<endl;
    return 0;
}

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

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

long cal(long r,long d,long x){
  return r*x-d;
}

int main(){
  int i;
  long r,d,x,K;
  scanf("%ld",&r);
  scanf("%ld",&d);
  scanf("%ld",&x);

  for(i=0;i<10;i++){
    x=cal(r,d,x);
    printf("%ld\n",x);
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if(n&1)
    {
        cout << ((1.0*(n - 1)/2 + 1)*1.0)/n;
    }else
    {
        cout << fixed << setprecision(20) << ((n*1.0/2)*1.0)/n;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int h,n,total=0,l;
	cin>>h>>n;
	for(int i=1;i<=n;i++){
		cin>>l;
		total+=l;
	}
	if(total>=h) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
int n,a[200010];
int m[1000010];
int main(){
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>a[i];
	}
	std::sort(a,a+n);
	int ans=0;
	for(int i=0;i<n;i++){
		if(!m[a[i]]){
			if(i==n-1||a[i]!=a[i+1])ans++;
			for(int j=a[i];j<=1000000;j+=a[i]){
				m[j]=true;
			}
		}
	}
	std::cout<<ans<<std::endl;
	return 0;
}


Measured memory_bytes: 8296
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int   ll;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll A,B,C,K;
        cin>>A>>B>>C>>K;
        if(K<=A)
            cout<<K<<endl;
        else if(K<=A+B)
            cout<<A<<endl;
        else
            cout<<A-(K-A-B)<<endl;
    }
}

Measured memory_bytes: 3652
import scala.io.StdIn

object Main {

  def main(args: Array[String]) = {

    val Array(n, m) = StdIn.readLine().split(' ').map(_.toInt)
    val as: Set[Int] = (1 to m).foldLeft(Set(): Set[Int])((s, _) =>
      s + StdIn.readLine().toInt
    )

    println(solve(n, as))

  }

  def solve(n: Int, as: Set[Int]): Int = {

    val r = 1000000007
    def local(i: Int, prepre: Int, pre: Int): Int = {
      val now: Int = if (as.contains(i)) {
        0
      } else {
        (prepre + pre) % r
      }
      if (i == n) {
        now
      } else {
        local(i + 1, pre, now)
      }
    }

    local(1, 0, 1)
  }

}


Measured memory_bytes: 56504
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<long long> vl;

signed main() {

  ll n,sum = 0;

  cin >> n;

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

    if( (i%3 != 0) && (i%5 != 0)) {

      sum += i;

    }

  }

  cout << sum << endl;
  return 0;

}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> G(8, vector<int>(8, 0));
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G.at(a).at(b) = G.at(b).at(a) = 1;
  }
  
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    v.at(i) = i;
  }
  sort(v.begin(), v.end());
  
  int ans = 0;
  do {
    if(v.at(0) != 0){
      break;
    }
    
    bool judge = true;
    for (int i = 0; i+1 < n; i++) {
      int from = v.at(i);
      int to = v.at(i+1);
      if(G.at(from).at(to) != 1){
        judge = false;
      }
    }
    if(judge){
      ans++;
    }
  } while (next_permutation(v.begin(), v.end()));
    
  cout << ans << endl;

 
}
             
 


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(v) (v).begin(),(v).end()

int main() {

	string S;
	cin >> S;
	ll K;
	cin >> K;

	const int N = S.length();
	V<pair<char,int>> aaa;
	int i = 0;
	while(i<N) {
		ll cnt = 1;
		while(S[i]==S[i+cnt])cnt++;
		aaa.push_back({S[i],cnt});
		i += cnt;
	}

	if(aaa.size()==1) {
		cout << K*aaa[0].second/2 << endl;
		return 0;
	}

	ll ans = 0;
	if(aaa.front().first == aaa.back().first) {
		ll g = aaa.front().second + aaa.back().second;
		ans += aaa.front().second/2 + (g/2)*(K-1) + aaa.back().second/2;
		aaa.erase(aaa.begin());
		aaa.pop_back();
	}

	for(auto e : aaa) {
		ans += (e.second/2)*K;
	}
	
	cout << ans << endl;

}

Measured memory_bytes: 256
n,k=map(int,input().split())
ab=[]
for i in  range(n):
    a,b=map(int,input().split())
    ab.append([a,b])
ab.sort()
c=0
for i in range(n):
    c+=ab[i][1]
    if c>=k:
        print(ab[i][0])
        exit()


Measured memory_bytes: 58840
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;
    cin >> n;
    for (int i = 0;i<n; i++) cin >> R[i];
    int maxv = -2000000000;
    int minv = R[0];

    for (int i=1;i<n;i++){
        maxv = max(maxv,R[i]-minv);
        minv = min(minv,R[i]);
    }
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 3860
package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

var n int
var G map[int]map[int]bool

func initGraph() {
	G = make(map[int]map[int]bool, n)
}

func add(from, to int) {
	if _, ok := G[from]; !ok {
		G[from] = make(map[int]bool)
	}
	G[from][to] = true
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n = readInt()
	m := readInt()
	initGraph()

	type bridge struct{ a, b int }
	bs := make([]bridge, m)
	for i := 0; i < m; i++ {
		a, b := readInt(), readInt()
		add(a, b)
		add(b, a)
		bs[i] = bridge{a, b}
	}

	ans := 0
	for _, bv := range bs {
		ba, bb := bv.a, bv.b
		seen := make(map[int]bool, n)
		qu := list.New()
		qu.PushBack(1)
		seen[1] = true
		for qu.Len() > 0 {
			v := qu.Remove(qu.Front()).(int)
			for t := range G[v] {
				if seen[t] {
					continue
				}
				if (v == ba && t == bb) || (v == bb && t == ba) {
					continue
				}
				seen[t] = true
				qu.PushBack(t)
			}
		}

		if len(seen) != n {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    s = s_input()

    print(s[0] + str(len(s)-2) + s[-1])

if __name__ == '__main__':
    main()


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

int main(){
	int a[5],b,i,j;
	
	scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
	
	for(i=4;i>0;i--){
		for(j=0;j<i;j++){
			if(a[j]>a[j+1]){
				b=a[j];
				a[j]=a[j+1];
				a[j+1]=b;
			}
		}
	}
	
	printf("%d %d %d %d %d\n",a[4],a[3],a[2],a[1],a[0]);
	
	return 0;
}

Measured memory_bytes: 596
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())


def main():
    N = ii()
    A = list(mi())
    B = [0]*N
    B[0] = sum(A[i]*((-1)**(i%2)) for i in range(N))
    for i in range(1, N):
        B[i] = 2*A[i-1]-B[i-1]
    print(*B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 90024
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n;
  cin >> n;
  
  if(n%10 == n/100) cout << "Yes" << endl;
  else  cout << "No" << endl;
 return 0;
}


Measured memory_bytes: 256
f=lambda:map(int,input().split())
n,m=f()
lt=sorted(list(f()) for _ in range(n))[::-1]
from heapq import *
q,s=[],0
for i in range(m):
  while lt and lt[-1][0]<i+2: a,b=lt.pop(); heappush(q,-b)
  if q: s-=heappop(q)
print(s)

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

int main() {
	int nodes[4] = { 0,0,0,0 };
	for (int i = 0; i < 3; i++) {
		int x, y;
		cin >> x >> y;
		nodes[x - 1]++;
		nodes[y - 1]++;
	}
	for (int i = 0; i < 4; i++) {
		if (nodes[i] == 3) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M, K, A[201010], B[201010];
ll Atot[201010], Btot[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> K;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, M) cin >> B[i];

	Atot[0] = 0;
	rep(i, 0, N) Atot[i + 1] = Atot[i] + A[i];
	Btot[0] = 0;
	rep(i, 0, M) Btot[i + 1] = Btot[i] + B[i];

	int ans = 0;
	int ok = M;
	rep(a, 0, N + 1) {
		while (0 <= ok && K < Atot[a] + Btot[ok]) ok--;
		if(0 <= ok) chmax(ans, a + ok);
	}
	cout << ans << endl;
}







Measured memory_bytes: 8336
x=input()
m=0
for i in range(len(x)):
    for j in range(i,len(x)):
        #print(x[i])
        if x[j] not in ["A","G","C","T"]:
            #print(j)
            break
        else:
            m=max(m,j-i+1)
print(m)
        
            


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

int main(){
    int n,q;
    cin >> n >> q;
    G graph(n);
    vector<int> parent(n,-1);
    vector<int> addition(n,0);
    vector<int> ans(n);
    rp(i,n-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    rp(i,q){
        int p,x;
        cin >> p >> x;
        p--;
        addition[p]+=x;
    }
    queue<int> bfs;
    bfs.push(0);
    ans[0]=addition[0];
    while(!bfs.empty()){
        int v=bfs.front(); bfs.pop();
        for(auto nxt : graph[v]){
            if(nxt!=0&&parent[nxt]==-1){
                parent[nxt]=v;
                ans[nxt]=ans[v]+addition[nxt];
                bfs.push(nxt);
            }
        }
    }
    rp(i,n){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
ll t;
ll a[202020];

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>t;
  rep(i,n){
    cin>>a[i];
  }
  a[n]=a[n-1]+t;
  ll res=0;
  rep(i,n){
    res+=min(t,a[i+1]-a[i]);
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <string>
#include <iostream>
using namespace std;
string s;
int main() {
	while(cin >> s, s != "#") {
		int p = 0, f = 0;
		for(int i = 0; i < s.size(); i++) {
			switch(p) {
				case 0: if(s[i] == 48) p = 1; else p = 2; break;
				case 1: if(s[i] == 48) f = 1; else p = 3; break;
				case 2: if(s[i] == 48) p = 1; else f = 1; break;
				case 3: if(s[i] == 48) p = 4; else p = 5; break;
				case 4: if(s[i] == 48) p = 5; else p = 2; break;
				case 5: if(s[i] == 48) p = 2; else p = 1; break;
			}
		}
		puts(p == 5 && f == 0 ? "Yes" : "No");
	}
}

Measured memory_bytes: 3108
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#define IOS ios::sync_with_stdio(0)
template <typename T>
inline T read(){T sum=0,fl=1;int ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
for(;isdigit(ch);ch=getchar())sum=sum*10+ch-'0';
return sum*fl;}
template <typename T>
inline void write(T x) {static int sta[35];int top=0;
do{sta[top++]= x % 10, x /= 10;}while(x);
while (top) putchar(sta[--top] + 48);}
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
const ll mod = 1e9+7;
int x[man];
int l[man],r[man];
int pos[man];
int main() {
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt","w",stdout);
    #endif
    int n = read<int>();
    for(int i = 1;i<= n;i++){
        x[i] = read<int>();
        pos[x[i]] = i;
        l[i] = i-1;
        r[i] = i+1;
    }
    long long ans = 0;
    for(int i = 1;i <= n;i++){
        int lpos1 = l[pos[i]];
        int lpos2 = l[lpos1];
        int rpos1 = r[pos[i]];
        int rpos2 = r[rpos1];
        if(lpos1)ans += 1ll*(lpos1 - lpos2)*(rpos1 - pos[i])*i;
        if(rpos1!=n+1)ans += 1ll*(rpos2 - rpos1)*(pos[i] - lpos1)*i;
        l[rpos1] = lpos1;
        r[lpos1] = rpos1;
    }
    write(ans);
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> p(n), q(n);
	rep(i, n) cin >> p[i];
	rep(i, n) cin >> q[i];
	if(p > q) swap(p, q);
	int cnt = 0;
	do{
		if(p == q) break;
		cnt++;
		// rep(i, n) cout << p[i] << " ";
		// cout << endl;
	}while(next_permutation(all(p)));
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int,int> P;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int n, m;
int dp[(1<<10)*400+20*20+20];
int brd[20][20];
vector<P> e[(1<<10)*400+20*20+20];

void solve(){
	int cnt = 0;
	int st;
	rep(i,(1<<10)*400+20*20+20){
		dp[i] = INF;
		e[i].clear();
	}
	rep(i,20*20) e[i].clear();
	rep(i,m) rep(j,n){
		char tmp; cin >> tmp;
		if(tmp == 'o'){
			st = 20*i+j;
			dp[20*i+j] = 0;
			brd[i][j] = -1;
		} else if(tmp == '*'){
			brd[i][j] = cnt;
			cnt++;
		} else if(tmp == 'x'){
			brd[i][j] = INF;
		} else{
			brd[i][j] = -1;
		}
	}
	rep(i,m) rep(j,n){
		if(brd[i][j] == INF) continue;
		if(brd[i][j] >= 0){
			rep(k,(1<<cnt)){
				if(k&(1<<brd[i][j])) continue;
				e[400*k+20*i+j].push_back(P(400*(k+(1<<brd[i][j]))+20*i+j,0));
			}
		}
		rep(u,4){
			int x = i+dx[u], y = j+dy[u];
			if(0>x||x>=m||0>y||y>=n) continue;
			rep(k,(1<<cnt)){
				e[400*k+20*i+j].push_back(P(400*k+x*20+y,1));
			}
		}
	}
	priority_queue<P,vector<P>, greater<P> > que;
	que.push(P(0,st));
	while(true){
		if(que.size() == 0) break;
		P q = que.top();
		que.pop();
		if(q.first > dp[q.second]) continue;
		rep(i,e[q.second].size()){
			P p = e[q.second][i];
			if(dp[p.first] > q.first+p.second){
				dp[p.first] = q.first+p.second;
				que.push(P(dp[p.first],p.first));
			}
		}
	}
	int ans = INF;
	int x = 1;
	for(int i = 1; i < cnt; i++) x = x*2+1;
	rep(i,20) rep(j,20){
		ans = min(ans,dp[x*400+i*20+j]);
	}
	if(ans == INF) ans = -1;
	cout <<  ans << endl;
}

int main(){
	while(cin >> n >> m){
		if(n == 0 && m == 0) break;
		solve();
	}
}

Measured memory_bytes: 24000
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[2][501][1025] = {};
ll sum[1025][510] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,X;
    cin >> N >> X;
    rep(i,0,X+1){
        dp[0][i][i] = 1;
    }
    ll n = 1;
    while(n < X){
        n *= 2;
    }

    rep(k,0,n+1){
        rep(l,0,X+1){
            sum[k][l+1] = sum[k][l] + dp[0][l][k];
        }
    }
    ll cur = 0, nxt = 1;
    rep(i,1,N){
        rep(l,0,X+1){
            rep(k,0,n+1){
                dp[nxt][l][k] = 0;
            }
        }
        rep(l,0,X+1){
            rep(k,0,n+1){
                dp[nxt][l][k] += sum[k^l][l+1];
                dp[nxt][l][k] %= MOD;
            }
        }
        rep(k,0,n+1){
            rep(l,0,X+1){
                sum[k][l+1] = sum[k][l] + dp[nxt][l][k];
            }
        }
        cur ^= 1;
        nxt ^= 1;
    }

    ll ans = 0;
    rep(i,0,X+1){
        ans += dp[cur][i][X];
        ans %= MOD;
    }
    print(ans);
    

}


Measured memory_bytes: 13260
#!/usr/bin/env python3
# GRL_5_D: Tree - Range Query on Tree


class Edge:
    __slots__ = ('v', 'w')

    def __init__(self, v, w):
        self.v = v
        self.w = w

    def either(self):
        return self.v

    def other(self, v):
        if v == self.v:
            return self.w
        else:
            return self.v


class Graph:
    def __init__(self, v):
        self.v = v
        self._edges = [[] for _ in range(v)]

    def add(self, e):
        self._edges[e.v].append(e)
        self._edges[e.w].append(e)

    def adj(self, v):
        return self._edges[v]

    def edges(self):
        for es in self._edges:
            for e in es:
                yield e


class RAQ:
    """Segment Tree
    """
    def __init__(self, n, initial=0):
        size = 1
        while size < n:
            size *= 2
        self.size = 2*size - 1
        self.data = [initial] * self.size

    def add(self, i, j, v):
        def _add(r, lo, hi):
            if i <= lo and hi <= j:
                data[r] += v
            elif i <= hi and lo <= j:
                mid = lo + (hi - lo)//2
                _add(r*2 + 1, lo, mid)
                _add(r*2 + 2, mid+1, hi)

        data = self.data
        return _add(0, 0, self.size//2)

    def get(self, i):
        def _get(r, lo, hi, v):
            v += self.data[r]
            if lo == hi:
                return v
            mid = lo + (hi - lo)//2
            if mid >= i:
                return _get(r*2 + 1, lo, mid, v)
            else:
                return _get(r*2 + 2, mid+1, hi, v)

        return _get(0, 0, self.size//2, 0)


class PathSum:
    def __init__(self, graph, root):
        self.seg = RAQ(graph.v)
        self._dfs(graph, root)

    def _dfs(self, graph, root):
        visited = [False] * graph.v
        pos = [None] * graph.v
        stack = [root]
        n = 0
        ns = []
        while stack:
            v = stack.pop()
            if not visited[v]:
                visited[v] = True
                ns.append(n)
                n += 1
                stack.append(v)
                for e in graph.adj(v):
                    w = e.other(v)
                    if not visited[w]:
                        stack.append(w)
            else:
                pos[v] = (ns.pop(), n - 1)

        self._pos = pos

    def add(self, v, val):
        i, j = self._pos[v]
        self.seg.add(i, j, val)

    def get(self, v):
        return self.seg.get(self._pos[v][0])


def run():
    n = int(input())
    g = Graph(n)

    for i in range(n):
        k, *cs = [int(i) for i in input().split()]
        if k > 0:
            for j in cs:
                g.add(Edge(i, j))

    raq = PathSum(g, 0)
    q = int(input())
    for _ in range(q):
        com, *args = [int(i) for i in input().split()]
        if com == 0:
            u, val = args
            raq.add(u, val)
        elif com == 1:
            u, = args
            print(raq.get(u))
        else:
            raise ValueError('invalid command')


if __name__ == '__main__':
    run()



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

typedef long long ll;

int main(){
	int n,A,B;
	cin>>n>>A>>B;
	string s;
	cin>>s;
	int num1=0,num2=0,tmp=0;
	for(int i=0;i<n;i++){
		if(s[i]=='a'){
			num1++;
			if(tmp<A+B){
				tmp++;
				cout<<"Yes"<<endl;
			}else{
				cout<<"No"<<endl;
			}
		}else if(s[i]=='b'){
			num2++;
			if(tmp<A+B&&num2<=B){
				cout<<"Yes"<<endl;
				tmp++;
			}else{
				cout<<"No"<<endl;
			}
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define isFile 0
#define NAME "taskA"
#define scan 1
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;

#define mp make_pair
#define pb push_back
#define fr first
#define sc second

#define ins insert
#define all(v) v.begin(), v.end()
#define rep(i,a,n) for (int i=a;i<n;i++)
#define bit(n, i) (n >> i) & 1
#define bpc(x) __builtin_popcountll(x)
#define rev(a) reverse(all(a))
#define skip continue
#define read(a) for(auto &i : a) cin >> i
#define print(a) for(auto i : a) cout << i << ' '
#define unique(a) sort(all(a));    a.resize(unique(all(a)) - a.begin())

//                D  R  U   L
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void faster() {
    if (isFile) {
        freopen(NAME".in", "r", stdin);
        freopen(NAME".out", "w", stdout);
    }
    if (scan) {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    }
}

const ll  INF = 1e18;
const int inf = 2e9;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ld  PI = acos(-1);
const ld  EPS = 3E-16;
const int ALPHA = 26;
const int N = (int)3e2 + 5;
const int M = 123;

bool isPal(string s) {
    string t = s;
    rev(s);
    return t == s;
}

void solve() {
    string s;
    cin >> s;

    int n = (int) s.size();
    string a = s;
    string b = "";
    for(int i = 0; i < (n - 1) / 2; i++)
        b += s[i];
    string c = "";
    for(int i = (n + 3) / 2 - 1; i < n; i++)
        c += s[i];
    if (!isPal(a) || !isPal(b) || !isPal(c)) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
}

int main() {
    faster();
    int t = 1;
//    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"

const int inf = (int)1e18 + 10;

int pre[10] , last[10];
signed main(){
  fast;
  
  int n , d = 0 , ans;
  cin >> n;
  for(int i = n ; i > 0 ; i/=10){
  	d++;
  }
  pre[0] = 0;
  for(int i = 1 ; i<= 5 ; i++){
  	if(i % 2 == 1)
  	pre[i] = 9 * pow(10 , i-1) + pre[i-1];
    else
    	pre[i] = pre[i-1];
  }

  last[0] = 0;
  for(int i = 1 ; i <= 6 ; i++){
  	last[i] = 10 * last[i-1] + 9;
  	// cout << i << "  "<< last[i] << endl;
  }


  if(d % 2 == 0){
  	cout << pre[d-1]<<endl;
  }
  else{
  	  if(d - 2 >= 0)
  	  	ans += pre[d-2];

  	  ans += n - last[d-1];

  	  cout << ans << endl;
  }

  
}	

Measured memory_bytes: 256
using System;
using System.Linq;

class Program {
  static void Main() {
    var a = "";
    for (int w = int.Parse(Console.ReadLine()); w > 0; w /= 3) {
      if (w % 3 == 0) a += "0";
      else if (w % 3 == 1) a += "+";
      else {
        a += "-";
        w++;
      }
    }
    Console.WriteLine(new string(a.Reverse().ToArray()));
  }
}


Measured memory_bytes: 18292