akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) const { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) const { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};

int64_t const MOD = 1e9+7;
typedef mod_int<MOD> mint;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::string S; std::cin >> N >> S;
  std::vector<int> v(1, 0);
  if(S[0] == 'W') fin(0);

  for(int i = 1; i < N+N; ++i) {
    if((S[i] == S[i-1]) != (v.back() == i-1)) v.push_back(i);
  }
  if(v.size() != N) fin(0);
  mint ans=1;
  for(int i = 0; i < N; ++i) ans *= mint(i+1)*mint(i+i+1 - v[i]);
  fin(ans.v_);
  return 0;
}


Measured memory_bytes: 1680
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl; 
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)            for (auto i : v)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define pb(x)                 push_back(x)
#define bp(x)                 __builtin_popcount(x)
#define mp(x, y)              make_pair((x), (y))
#define fi                    first
#define se                    second
#define setp(x)               setprecision(x)
#define mset(m, v)            memset(m, v, sizeof(m))
static const int INF        = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD        = 1000000007;
static const double PI      = 3.14159265358979;

#define int                   long long

typedef vector<double>        vd;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef vector<int>           vi;
typedef pair<int, int>        pii;
typedef vector<pii>           vpii;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int _x; cin >> _x; return _x; }

int g[1010][1010];

struct state { int x, score; };
      
signed main() { 
        int n, m;
        cin >> n >> m;
        rep(i, n) rep(j, n) g[i][j] = 0;
        rep(i, m) {
                int a, b, c;
                cin >> a >> b >> c;
                a --;
                b --;
                g[a][b] = c;
        }
        vi used(1010, -INFL);
        queue<state> q;
        q.push({0, 0});
        int cnt = 0;
        int prev;
        int f = 0;
        while (true) {
                state p;
                bool ff = false;
                if (!q.empty()) {
                        p = q.front(); q.pop();
                        ff = true;
                }
                cnt ++;
                if (ff) {
                rep(i, n) {
                        if (g[p.x][i] != 0 && used[i] < p.score + g[p.x][i]) {
                                used[i] = p.score + g[p.x][i];
                                q.push({i, p.score + g[p.x][i]});
                        }
                }
                }
                if (q.empty() && p.x == n - 1) break;
                if (cnt > 5000 && cnt < 8000) prev = used[n - 1];
                if (cnt > 15000) {
                        if (prev == used[n - 1]) f = 1;
                        else f = 2;
                        break;
                }
        }
        if (f == 0 || f == 1) cout << used[n - 1] << endl;
        else cout << "inf" << endl;
}


Measured memory_bytes: 8192
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  vector<int> a(n);
  vector<int> b(n);
  REP(i,n) a[i] = getInt();
  REP(i,n) b[i] = getInt();

  int ans = 0;
  REP(i,n){
    int t = 0;
    for(int j = 0; j < n; j++){
      if(j <= i) t += a[j];
      if(j >= i) t += b[j];
    }
    ans = max(ans, t);
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        int n = ni();
        int k = ni();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) {
            arr[i] = ni();
        }
        Arrays.sort(arr);
        int res = 0;
        for (int i = 0; i < k; i++) {
            res += arr[i];
        }
        out.println(res);
        out.close();
    }

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

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    boolean input() throws IOException {
        return true;
    }

}


Measured memory_bytes: 25968
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<algorithm>
#include<cstdio>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int bm = 3010;
ll BIT[bm];
void add(int A, ll B) {
	while (A <= bm) {
		BIT[A] = max(BIT[A], B);
		A += A & -A;
	}
}
ll query(int A) {
	ll kotae = 0;
	while (A > 0) {
		kotae = max(BIT[A], kotae);
		A -= A & -A;
	}
	return kotae;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

ll V[200000], tmp[200000];

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


	int R = getint(), C = getint(), K = getint();

	rep(i, K) {
		ll r = getint(), c = getint(), v = getint();
		V[i] = v << 30 | r << 12 | c;
	}

	const int b = 12;
	int kazu[1 << b] = {}, kazu2[1 << b] = {};
	rep(i, K) kazu[V[i] & ((1 << b) - 1)]++;
	rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
	for (int i = K - 1; i >= 0; i--) tmp[--kazu[V[i] & ((1 << b) - 1)]] = V[i];
	rep(i, K) kazu2[tmp[i] >> b & ((1 << b) - 1)]++;
	rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
	for (int i = K - 1; i >= 0; i--) V[--kazu2[tmp[i] >> b & ((1 << b) - 1)]] = tmp[i];

	int mae = -1;
	ll A[4] = {};
	ll L[3001];
	int l = 0;
	rep(k, K) {
		int v = V[k] >> 30;
		int i = V[k] >> 12 & 4095;
		int j = V[k] & 4095;
		if (mae != i) {
			mae = i;
			A[0] = 0;
			A[1] = 0;
			A[2] = 0;
			A[3] = 0;
			rep(a, l) add(L[a] & 4095, L[a] >> 12);
			l = 0;
		}
		ll kari = query(j);
		A[0] = kari;
		chmax(A[3], kari);
		chmax(A[2], kari);
		chmax(A[1], kari);
		chmax(A[3], A[2] + v);
		chmax(A[2], A[1] + v);
		chmax(A[1], A[0] + v);
		L[l++] = A[3] << 12 | j;
	}

	rep(a, l) add(L[a] & 4095, L[a] >> 12);
	ll kotae = query(C);

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 4920
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

int main(){

    int n,l;
    int sum;
    int num;
    int flag=0;
    int mini=100000;
    int flag1=0;
    
    cin >> n >> l;

    int r[n];

    for(int i=0;i<n;i++){
        int local;
        r[i]= l + i;
        if(r[i]==0){flag=1;num=0;}
        local = r[i];
        if(r[i]<0){local=r[i]*(-1);}
        // cout << local << endl;
        if(local<mini){
            mini=local;
            if(r[i]<0)flag1=1;
            // cout << mini << endl;
        }
    }
    if(flag1==1)mini*=-1;

    sum = (l-1) * n + (n *(n+1))/2;
    // cout << sum << endl;
    if(flag == 0){
        sum -= mini;
    }


    cout << sum << endl;

    return 0;
}

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

int main()
{
    int a , b, c , x;
    cin>>a>>b>>c>>x;
    int ans =0;

    for(int i=0;i<=a;i++)
    {
        for(int j=0;j<=b;j++)
        {
            for(int k=0;k<=c;k++)
            {
                int temp = i*500 + j*100 + k*50;
                if( temp == x)
                    ans++;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N, M;
  cin >> N >> M;
  cout << N*(N-1)/2 + M*(M-1)/2 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        ReadLine();
        var str = ReadLine();
        var res = "";
        var le = 0;
        var ri = 0;
        for(var i = 0; i < str.Length; i++)
        {
            var s = str.Substring(i, 1);
            res += s;
            if (s == "(") le++;
            else ri++;
            if (le < ri)
            {
                res = "(" + res;
                le=ri;
            }
        }
        for (var i = 0; i < le-ri; i++)
            res += ")";
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
typedef vector<int> VI;
#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )

int main() {
    REP(i, 1, 10) {
        REP(j, 1, 10) {
            cout << i << "x" << j << "=" << i * j << endl;
        }
    }
        
    return 0;
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
using namespace std;
int main() {
	int T;
	scanf("%d", &T);
	while (T--) {
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		int k = (a + b) / (min(a, b) + 1);
		int lo = 0, hi = a;
		while (lo < hi) {
			int na = (lo + hi + 1) >> 1;
			int nb = max(0, (na - 1) / k);
			if (b - nb <= 1ll * (a - na + 1) * k) lo = na;
			else hi = na - 1;
		}
		int lim = lo + max(0, (lo - 1) / k);
		for (int i = c; i <= d; i++) {
			if (i <= lim) putchar((i % (k + 1)) ? 'A' : 'B');
			else putchar(((a + b - i + 1) % (k + 1)) ? 'B' : 'A');
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	ll a, b, c;
	cin >> a >> b >> c;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
		cout << 0 << endl;
	}else{
		ll answer = min({ a * b, a * c, b * c });
		cout << answer << endl;
	}
	return 0;
}



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

int main(void)
{
	int m, sikinA, years, n, p, A, C, max;
	double risi;
	cin >> m;
	for (int i = 0; i < m; i++) {
		max = 0;
		cin >> sikinA >> years >> n;
		for (int j = 0; j < n; j++) {
			cin >> p >> risi >> C;
			A = sikinA;
			if (p == 0) {
				int B = 0;
				for (int i = 0; i < years; i++) {
					B += (int)((double)A * risi);
					A = A - C;
				}
				A += B;
			}else {
				for (int i = 0; i < years; i++) {
					A = A + (int)((double)A * risi) - C;
				}
			}
			if (max < A) max = A;
		}
		cout << max << endl;
	}
	
	return 0;
}

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

int main() {
    int X,i;
    cin >> X;
	
  	if(X == 2) {
      	cout << X << endl;
  		return 0;
    }
    while(1) {
        for(i=2; i<X/2; i++)
            if(X%i == 0)
                break;
        if(i == X/2)
            break;
        X++;
    }

    cout << X << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
      ll k,a,b;
       cin>>k>>a>>b;
      ll n=(b/k)*k;
      if(n>=a && n<=b)
         cout<<"OK"<<endl;
      else
         cout<<"NG"<<endl;
  
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
vector<int>v;
int xx[105];
int yy[105];
int main()
{
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int mx=-1001;
    int mn=1001;
    for(int i=0;i<n;i++)
    {
        cin>>xx[i];
        if(i==0) mx=xx[i];
        else
        mx = max(mx,xx[i]);
    }
    for(int i=0;i<m;i++)
    {
        cin>>yy[i];
        if(i==0)
            mn=yy[i];
        else
        mn = min(mn,yy[i]);
    }
    int l = max(mx,x)+1;
    int r = min(y,mn);
    if(l<=r)
    {
        cout<<"No War"<<endl;
    }
    else cout<<"War"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ちゃんとユニークな配列にする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int X;
  cin >> X;
  int A, B;
  cin >> A >> B;
  int result = (X - A) % B;
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++) 
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++) 
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//const ll mod = 1000000007;
//const ll INF = mod * mod;
//const double pi = 3.14159265358979;

int main() {
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int y = ty - sy;
    int x = tx - sx;
    rep(i,y) cout << "U";
    rep(i,x) cout << "R";
    rep(i,y) cout << "D";
    rep(i,x) cout << "L";
    cout << "D";
    rep(i,x+1) cout << "R";
    rep(i,y+1) cout << "U";
    cout << "L";
    cout << "U";
    rep(i,x+1) cout << "L";
    rep(i,y+1) cout << "D";
    cout << "R";
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

void bubbleSort(int);

int main(){
  int n;

  scanf("%d",&n);

  bubbleSort(n);

  return 0;
}

void bubbleSort(int n){
  int A[n], i, j, flag = 1, v, count = 0;

  for(i = 0; i < n; i++)
    scanf("%d",&A[i]);

  while(flag){
    flag = 0;
    for(j = n - 1; j >= 1; j--){
      if(A[j] < A[j - 1]){
	v = A[j];
	A[j] = A[j - 1];
	A[j - 1] = v;
	flag = 1;
	count++;
      }
    }
  }
  for(i = 0; i < n; i++){
    printf("%d",A[i]);
    if(i != n - 1)
      printf(" ");
  }
  printf("\n%d\n",count);
}



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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n), b(n), c(m), d(m);
  REP(i, n){
    cin >> a[i] >> b[i];
  }
  REP(i, m){
    cin >> c[i] >> d[i];
  }
  REP(i, n){
    ll ans = 1;
    ll dis = 1e+10;
    REP(j, m){
      ll now = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (now < dis){
        ans = j + 1;
        dis = now;
      }
    }
    cout << ans << endl;
  }
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    string s;cin>>s;
    int len=s.length();
    map<char,ll> mp;
    ll res=0;
    for(ll i=0;i<len;i++){
        res += i-mp[s[i]];
        mp[s[i]]++;
    }
    cout<<res+1<<endl;
}


Measured memory_bytes: 720
#include <stdio.h>
#include <stdbool.h>
#include <algorithm>
#include <vector>
#include <string.h>

int main(){
    
	
	bool a[524]={false},c[524]={false};
	int b[10024][3]={0};
	int i,j,x,y;
	int n,m,count=0;
	
	scanf("%d\n%d\n",&n,&m);
    while(n!=0||m!=0){
        if(n==0) break;
        count = 0;
        for(i=0;i<524;i++){
            a[i] = false;
            c[i] = false;
        }
        memset(b,0,sizeof(b));
	a[1] = true;
	c[1] = true;
	j=0;
	for(i=1;i<=m;i++){
		scanf("%d %d\n",&x,&y);
        //printf("%d %d\n",x,y);
		if(x==1){
			count++;
			a[y]=true;
			c[y] = true;
		}
    	
        if(y==1){
			count++;
			a[x]=true;
			c[x]=true;
		}
		b[i][1]=x;
		b[i][2]=y;
	}
    //printf("%d\n",count);
	for(j=1;j<=m;j++){
		if(a[b[j][1]]==true){
            if(c[b[j][2]]==false){
                count++;
				c[b[j][2]] = true;
			}
		}
        if(a[b[j][2]]==true){
            if(c[b[j][1]]==false){
                count++;
    			c[b[j][1]] = true;
			}
		}
        
	}
	//printf("%d\n",count);
	printf("%d\n",count);
    scanf("%d\n%d\n",&n,&m);
    }
	return 0;
}
	

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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/


struct Edge{
    int to,index;
};

vector<bool> seen;
vector<int> parent;
map<pair<int,int>,int> v_pair;
vector<int> vert;


vector<vector<Edge>> G;

void dfs(int v,int p,int num){
  //if(p == parent[v]) return;

  vert[v_pair[MP(p,v)]] = num;

   int tmp = 1;
  for(auto next_e:G[v]){
    if(tmp == num) tmp++;
    dfs(next_e.to,v,tmp);
    tmp++;
  }
}

  
int main(){
  //cout.precision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  seen.assign(N,false);
  parent.resize(N);
  vert.assign(N-1,0);

  G.resize(N);

  vector<int> dim(N);

  rep(i,N-1){
      int a,b;
      cin >> a >> b;
      --a;--b;
      parent[b] = a;
      G[a].PB((Edge){b,i});
      dim[a]++;
      dim[b]++;
      v_pair[MP(a,b)] = i;
  }

  auto itr = max_element(ALL(dim));
  int M = *itr;
  cout << M << endl;        //最大次数

  dfs(0,-1,0);


  rep(i,N-1)cout << vert[i] << endl;


}

Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

ll gcd(ll m, ll n) {
  if(m < n) swap(m, n);
  if(n == 0) return abs(m);
  else return gcd(n, m % n);
}

ll lcm(ll m, ll n) {
  return abs(m*n) / gcd(m, n);
}

int main() {
  ll A, B; cin >> A >> B;
  cout << lcm(A, B) << endl;
  return 0;
}


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

    public class B
    {
        public static void Main()
        {
            var nums = Console.ReadLine().Split(" ").Select(n => int.Parse(n)).ToArray();
            int sum = 0;

            for (int i = 1; i <= nums[0]; i++)
            {
                int d = DigitSum(i);
                if (nums[1] <= d && d <= nums[2]) sum += i;
            }

            Console.WriteLine(sum);
        }

        public static int DigitSum(int i)
        {
            int tmp = 0;

            while (i > 0)
            {
                tmp += i % 10;
                i /= 10;
            }

            return tmp;
        }
    }


Measured memory_bytes: 28256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

#define rep(i, N) for (int i = 0; i < N; i++)


int main()
{
	int n, l,teist;
	cin >> n >> l;
	teist = 0;

	for (int i = 0; i < n; i++) {
		//cout << "i:" << i << endl;
		teist += l+i;
	}
	//cout << "teist : " << teist << endl;

	if (l <= 0 && (n + l - 1) >= 0) {
		//cout << "0matagi" << endl;
		cout << teist << endl;
	}
	else if (l < 0) {
		//cout << "minus" << endl;
		cout << teist - (n + l - 1) << endl;
	}
	else if (l > 0) {
		//cout << "plus" << endl;
		cout << teist - l << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc066/tasks/arc077_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll n, a;
list<ll> lst;

int main()
{
  cin >> n;
  REP(i, n)
  {
    cin >> a;
    if (i % 2 == 0)
      lst.push_front(a);
    else
      lst.push_back(a);
  }

  if (n % 2 == 0)
    reverse(ALL(lst));

  for (auto &it : lst)
    cout << it << " ";

  cout << '\n';

  return 0;
}


Measured memory_bytes: 8448
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

M = len(bin(K)) - 2
one = [0] * M
for i in range(N) :
    for j in range(M) :
        one[j] += (A[i] >> j) & 1 

X = 0
for i in range(M - 1, -1, -1) :
    X *= 2
    if N - one[i] > one[i] :
        X += 1
        
for i in range(M - 1, -1, -1) :
    a = (X >> i) & 1
    b = (K >> i) & 1
    if a == 0 and b == 1 :
        break
    if a == 1 and b == 0 :
        X ^= (1 << i)
        
ret = 0
for i in range(N) :
    ret += A[i] ^ X
print(ret)

Measured memory_bytes: 69136
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String S = sc.next();
	String T = sc.next();
	if((S + T.charAt(T.length()-1) ).equals(T))
	    System.out.print("Yes");
	else
	    System.out.print("No");
    }
}


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

int main()
{
  int n;
  cin>>n;
  unordered_map<string,long> m;
  string tmp;
  int val;
  long total=0;
  for(int i=0;i<n;i++)
  {
    cin>>tmp;
    cin>>val;
    total += val; 
    m[tmp]= total;
  }
  cin>>tmp;
  long res = total - m[tmp];
  cout<<res;
  
}

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

int main(void) {
  string s; cin >> s;
  string ans;
  int length = 0;
  for( int i = 0; i < s.size(); i++ ) {
    if( s.at(i) == '0' ) {
      ans += "0";
      length++;
    }
    else if( s.at(i) == '1' ) {
      ans += "1";
      length++;
    }
    else {
      if( length > 0) {
        ans.erase(length-1);
        length--;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    	int[][] ink = new int[10][10];
    	Scanner input = new Scanner(System.in);
		while(input.hasNext()){
			String[] st = input.next().split(",");
			int x = Integer.parseInt(st[0]);
			int y = Integer.parseInt(st[1]);
			if(st[2].charAt(0) == '1'){
				ink[y][x]++;
				if(0 <= x-1)ink[y][x-1]++;
				if(0 <= y-1)ink[y-1][x]++;
				if(x+1 < 10)ink[y][x+1]++;
				if(y+1 < 10)ink[y+1][x]++;
			}else if(st[2].charAt(0) == '2'){
				for(int i = y-1 ; i <= y+1 ; i++){
					for(int j = x-1 ; j <= x+1 ;j++){
						if(isok(j,i))ink[i][j]++;
					}
				}
			}else{
				for(int i = y-2 ; i <= y+2 ; i++){
					for(int j = x-2 ; j <= x+2 ;j++){
						if(isok(j,i) && Math.abs(x-j)+Math.abs(y-i) <= 2)ink[i][j]++;
					}
				}
			}
		}
		int maxink = 0;
		int count = 0;
		for(int i = 0 ; i < 10 ; i++){
			for(int j = 0 ; j < 10 ; j++){
				if(ink[i][j] == 0)count++;
				maxink = Math.max(maxink, ink[i][j]);
			}
		}
		System.out.println(count);
		System.out.println(maxink);
    }
    
    public static boolean isok(int x,int y){
    	if(x < 0 || y < 0 || x >= 10 || y >= 10)return false;
    	return true;
    }
   
}

Measured memory_bytes: 17232
#include <stdio.h>
int main (){
  char KURURU[100];
  char ar[26]="abcdefghijklmnopqrstuvwxyz";
  char AR[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int i=-1;
  while (1){
    i++;
    scanf ("%c",&KURURU[i]);
    if (KURURU[i]==10) break;
  }
  for (int s=0;s<=i-1;s++){
    for (int s2=0;s2<26;s2++){
        if (KURURU[s]==ar[s2]){
            KURURU[s]=AR[s2];
           }
     }
}
for (int s=0;s<i;s++){
    printf ("%c",KURURU[s]);
}

printf ("\n");
return 0;
}

Measured memory_bytes: 1768
import statistics
N = int(input())
a = list(map(int, input().split()))
for i in range(N):
    a[i] -= i + 1
b = statistics.median(a)
if b > 0 and b % 1 >= 0.5:
    b += 1
elif b < 0 and b % -1 <= -0.5:
    b -= 1
b = int(b)
ans = 0
for i in range(N):
    ans += abs(a[i] - b)
print(ans)

Measured memory_bytes: 27248
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int main(){
  scanf("%d%d%d",&n,&m,&k);
  for(int i=1;i<=n;++i){
    for(int j=0;j<=m;++j){
      int cur=m*i-j*i+(n-i)*j;
      if(cur==k)
        return 0*puts("Yes");
    }
  }
  for(int i=1;i<=m;++i){
    for(int j=0;j<n;++j){
      int cur=n*i-j*i+(m-i)*j;
      if(cur==k)
        return 0*puts("Yes");
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 256
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

a,b,x = LI()

ans = 0
if a > 0:
    a -= 1
else:
    ans += 1
ans += b//x - a//x

print(ans)

Measured memory_bytes: 9164
a,b,c = map(int,input().split())

if a == 0 and b == 0:
    if c > 0:
        print('Yes')
    else:
        print('No')
elif c-a-b <= 0:
    print('No')
else:
    if 4*a*b < (c-a-b)**2:
        print('Yes')
    else:
        print('No')

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

int main(){
  int n,q;
  string s;
  int l,r;
  cin >> n >> q >> s;
  int ans = 0;
  int cnt = 0;
  int c[n];
  c[0] = 0;
  for(int i=0;i<n-1;i++){
    if(s[i]=='A' && s[i+1]=='C'){
      cnt++;
    }
    c[i+1] = cnt;
  }
  c[n] = cnt;
  
  for(int i=0;i<q;i++){
    cin >> l >> r;
    ans = c[r-1] - c[l-1];
    cout << ans << endl;
    ans = 0;
  }
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

ll so[10] = { 2,3,5,7,11,13,17,19,23,29 };
ll n, cnt = 0;
vector<ll>list(10000, 0);

bool IsPrime(ll num)
{
	cnt %= MOD;

	if (num < 2) return true;
	else if (num == 2) {
		n /= 2;
		list[2]++;
		//cnt++;
		cnt += 2;
		return true;
	}
	else if (num % 2 == 0) {
		n /= 2;
		//cnt++;
		list[2]++;
		cnt += 2;
		return false; // 偶数はあらかじめ除く
	}

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			//cout << "i->" << i << endl;
			list[i]++;
			n /= i;
			//cnt++;
			cnt += 2;
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

signed main() {

	cin >> n;
	ll n2 = n - 1;

	while (true)
	{
		bool flag = false;

		if (n < 1000000000) {
			if (n2 > 1) {
				n *= n2;
				n2--;
			}
		}

		if (IsPrime(n) == true) {
			list[n]++;
			break;
		}

	}

	ll sum = 1;

	for (int i = 2; i < list.size(); i++) {
		if (list[i] > 0) {
			sum = sum * (list[i] + 1);
			sum %= MOD;
		}
	}

	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  string s;
  cin>>s;
  int n = s.length();
  int i,j;
  for(i = 0; i < n; i++){
    if(s[i]=='A') break;
  }
  for(j = n-1; j >= 0; j--){
    if(s[j]=='Z') break;
  }
  cout<<j-i+1<<endl;
  return 0;
}


Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    ll ans = min(n,m/2);
    m -= ans*2;
    ans += m/4;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;

int D, N;
int T[256], A[256], B[256], C[256];
int dp[256][256];

int rec(int day, int prev)
{
	if(day == D) return 0;

	
}

int main()
{
	memset(dp, 0, sizeof dp);
	
	cin >> D >> N;

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

	for(int i = 0; i < N; i++) {
		cin >> A[i] >> B[i] >> C[i];
	}

	for(int day = 0; day < D-1; day++) {
		for(int now = 0; now < N; now++) {
			for(int next = 0; next < N; next++) {
				if(A[now] <= T[day] && T[day] <= B[now] && A[next] <= T[day+1] && T[day+1] <= B[next]) {
					dp[day+1][next] = max(int(dp[day+1][next]), int(dp[day][now] + abs(C[now] - C[next])));
				}
			}
		}
	}

	int ans = 0;
	for(int i = 0; i < N; i++) {
		ans = max(ans, dp[D-1][i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 1432
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector

typedef long long ll;
typedef unsigned long long ull;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

inline int read() {
    int res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}

int n, m, c[1005], w[1005];
int f[1005][5005];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++) {
        int b, tmp = 0;
        scanf("%d %d", &c[i], &b);
        for (int j = 1; j <= b; j++) {
            int x;
            scanf("%d", &x);
            tmp |= (1 << (x - 1));
        }
        w[i] = tmp;
    }

    memset(f, 0x3f, sizeof(f));
    f[0][0] = 0;
    for (int i = 1; i <= m; i++) {
        for (int S = 0; S < (1 << n); S++) {
            f[i][S] = std::min(f[i][S], f[i - 1][S]);
            if (f[i - 1][S] != INF) {
                f[i][S | w[i]] = std::min(f[i][S | w[i]], f[i - 1][S] + c[i]);
            }
        }
    }
    printf("%d\n", f[m][(1 << n) - 1]  == INF ? -1 : f[m][(1 << n) - 1]);
    return 0;
}

Measured memory_bytes: 19840
N,A,B = map(int,input().split())
l = list(range(1,N+1))
su = 0
for i in l:
    num_li = (list(str(i)))
    num_li = list(map(int,num_li))
    k = sum(num_li)
    if A <= k <= B:su+=i
print(su)

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

int main(){
    int n;
    cin >> n;
    vector<char> s(n);
    for(int i =0; i<n; i++) cin >> s[i];

    bool ans = true;
    if(n % 2 == 0) {
        for(int i = 0; i<n; i++){
                if( s[i] != s[n/2 + i])  ans = false;
                if( i == n/2 - 1) break;
        }
    }
    else {
        ans = false;
    }

    if(ans) puts("Yes");
    else puts("No");

}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1) a = 14;
	if (b == 1) b = 14;
	if (a == b) {
		cout << "Draw" << endl;
	} else if (a > b) {
		cout << "Alice" << endl;
	} else {
		cout << "Bob" << endl;
	}
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
long long x,y,h,no;
int g;
int main()
{
	cin>>x>>y;
	h=y/x;
	no=1;
	while(no<=h)
	{
		g++;
		no*=2;
	}
	cout<<g<<endl;
	return 0;
}

Measured memory_bytes: 256
h,  w =  map(int, input().split())
a = []
a.append("."*(w+2))
for _ in  range(h):
    a.append("."+input()+".")
a.append("."*(w+2))

ans  = "Yes"
for i in range(h+2):
    for j in  range(w+2):
        if a[i][j] == "#":
            if not(a[i-1][j] == "#" or a[i+1][j] == "#" or a[i][j-1] == "#" or a[i][j+1] == "#"):
                ans = "No"
                break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fr(n) for(int i=0;i<n;i++)
#define mod 1000000007


int32_t main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int l = c/b;
	int k = a/d;
	while(a>0 && c>0){
		c = c-b;
		if(c<=0){ cout<<"Yes";return 0;}
		a = a-d;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
typedef long long ll;
string s;
ll k,N,a[301],b[301],cnt,ans,dp[301][301][301],MOD=998244353;
int main(void){
    cin>>s>>k;
    for(int i=0;i<s.size();i++){
        if(s[i]-'0')a[N++]=cnt;
        else cnt++;
    }
    for(int i=0;i<N;i++){
        b[a[i]]++;
    }
    k=min(k,N);
    dp[cnt+1][0][0]=1;
    for(int i=cnt+1;i>=1;i--){
        for(int j=0;j<=k;j++){
            for(int l=0;l<=N;l++){
                if(dp[i][j][l]==0)continue;
                for(int x=0;x<=b[i-1]+l;x++){
                    dp[i-1][j+max(0LL,b[i-1]-x)][b[i-1]+l-x]+=dp[i][j][l];
                    dp[i-1][j+max(0LL,b[i-1]-x)][b[i-1]+l-x]%=MOD;
                }
            }
        }
    }
    for(int i=0;i<=k;i++){
        ans+=dp[0][i][0];
        ans%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 31132
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

S = "0" + input()
l = len(S) - 1


MOD = int(1e9) + 7
dp = makelist(l+1, 4)

def toInt(c):
    return [ord(c) - 65]

dp[0][-1] = 1

for i in range(1, l+1):
    if S[i] == 'A':
        dp[i][-1] = dp[i-1][-1]
        dp[i][0] = (dp[i-1][0] + dp[i-1][-1]) % MOD
        dp[i][1] = dp[i-1][1]
        dp[i][2] = dp[i-1][2]
    elif S[i] == 'B':
        dp[i][-1] = dp[i-1][-1]
        dp[i][0] = dp[i-1][0]
        dp[i][1] = (dp[i-1][1] + dp[i-1][0]) % MOD
        dp[i][2] = dp[i-1][2]
    elif S[i] == 'C':
        dp[i][-1] = dp[i-1][-1]
        dp[i][0] = dp[i-1][0]
        dp[i][1] = dp[i-1][1]
        dp[i][2] = (dp[i-1][2] + dp[i-1][1]) % MOD
    elif S[i] == '?':
        dp[i][-1] = (dp[i-1][-1] * 3) % MOD
        dp[i][0] = ((dp[i-1][0] * 3) % MOD + dp[i-1][-1])  % MOD
        dp[i][1] = ((dp[i-1][1] * 3) % MOD + dp[i-1][0]) % MOD
        dp[i][2] = ((dp[i-1][2] * 3) % MOD + dp[i-1][1]) % MOD

print(dp[l][2])


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

int main() {
	int N;
	cin >> N;
	vector<int> P(N), DP(N);
	for (int i = 0; i < N; i++) {
		cin >> P.at(i);
	}

	for (int i = 0; i < N; i++) {
		if (i == 0) {
			DP.at(i) = P.at(i);
		}
		else if (DP.at(i - 1) > P.at(i)) {
			DP.at(i) = P.at(i);
		}
		else {
			DP.at(i) = DP.at(i - 1);
		}
	}

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (DP.at(i) == P.at(i)) cnt++;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 1792
il = [int(k) for k in input().split()]

if (il[0] != il[1] and il[1] == il[2]):
    print("Yes")
elif (il[0] != il[1] and il[0] == il[2]):
    print("Yes")
elif (il[0] != il[2] and il[0] == il[1]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
object Main extends App {
    val map = Seq(1, 3, -1, 2, 4, 5, 1, -1, 5, 3, 3, 1).grouped(2).toSeq.lift
    for (p <- io.Source.stdin.getLines if p != "#") {
        val x = p.foldLeft(0)((c, w) => map(c) match {
            case None => -1
            case Some(next) => next(w.asDigit)
        })
        if (x == 5) println("Yes")
        else println("No")
    }
}

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

int main()
{
    ll n ;
    cin >> n ;
    string ans ;
    while(n)
    {
        n-- ;
        ans += 'a' + n%26 ;
        n/=26 ;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl ;
    return 0 ;
}

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

#define FOR(i, a, b) for (int i = a; i < (int) b; i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)

#define f first
#define s second
#define eb emplace_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, 30, +31, +30, +31, +31, +30, +31, +30, +31};

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  bool is_valid = true;
  F0R (i, n) {
    int foo;
    cin >> foo;
    if ((foo & 1) == 0) {
      is_valid &= ((foo % 3) == 0 || (foo % 5) == 0);
    }
  }
  cout << (is_valid ? "APPROVED" : "DENIED") << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

int main(void){
    using namespace std;
    constexpr int KMAX = 1000;
    static int s[KMAX+1][2*KMAX+1];
    char c;
    int n, k, x, y;
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> k;
    for(int i=0; i<n; i++){
        cin >> x >> y >> c;
        y %= 2*k;
        if(c=='W'){
            x += k;
        }
        if(y>=k){
            y-=k;
            x+=k;
        }
        x %= 2*k;
        s[y+1][x+1]++;
    }
    for(int y=0; y<k; y++){
        for(int x=0; x<2*k; x++){
            s[y+1][x+1] += s[y][x+1] + s[y+1][x] - s[y][x];
        }
    }
    int max = 0;
    int v = s[0][0] - s[0][2*k];
    for(int y=0; y<k; y++){
        int u = v - s[y][0] + s[y][2*k];
        for(int x=0; x<k; x++){
            int t = u - s[0][x] - s[k][x] + s[0][x+k] + s[k][x+k] + 2*s[y][x] - 2*s[y][x+k];
            t = t<n/2 ? n-t : t;
            max = t>max ? t : max;
        }
    }
    cout << max;
    return 0;
}


Measured memory_bytes: 8064
/**
 * 単一始点最短経路（負の重みあり）
 * ベルマン・フォード法
 * https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_1_B
 * */

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//#define INF 1LL<<60 //使いやすい無限(ll)
#define INF 1'000'000'000'000'000'000

using Node = long long; //頂点
using Distance = long long; //距離
using Weight = long long; //重み

using Edge = tuple<Node, Node, Weight>;

ll V,E,r;
vector<Edge> Edges;
vector<Distance> dist;

bool BellmanFord(ll start){
  dist.assign(V, INF);
  dist[start] = 0;

  for(int i=1; i<V; i++){
    for(Edge x: Edges){
      Node s,t; Weight d;
      tie(s,t,d) = x;
      if(dist[s]==INF)continue; //距離無限ノードからの辺は考えない
      
      if(dist[s]+d < dist[t]){
        dist[t] = dist[s] + d;
      }

    }
  }

  bool NC = false;
  for(Edge x: Edges){
    Node s,t; Weight d;
    tie(s,t,d) = x;
    if(dist[s]==INF)continue; //距離無限ノードからの辺は考えない
    if(dist[s]+d < dist[t]){
      NC = true;
    }
  }

  return NC;
}

int main(){
  cin>>V>>E>>r;

  for(int i=0; i<E; i++){
    ll s,t,d;
    cin>>s>>t>>d;
    Edges.push_back(make_tuple(s,t,d));
  }

  bool isNcycle = BellmanFord(r);

  if(isNcycle){
    cout<<"NEGATIVE CYCLE"<<endl;
    return 0;
  }

  for(ll x: dist){
    if(x==INF){
      cout<<"INF"<<endl;
    }else{
      cout<<x<<endl;
    }
  }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

#define INF 1e9

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m; cin>>n>>m;
	vll a(m), c(m, 0);
	rep(i, m){
		int b; cin>>a[i]>>b;
		rep(j, b){
			ll temp; cin>>temp;
			c[i] += 1<<(temp-1);
		}
	}

	vector<vll> dp(m+1, vll(1<<n, INF));
	dp[0][0] = 0;

	rep(i, m){
		rep(j, 1<<n){
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			dp[i+1][j|c[i]] = min(dp[i+1][j|c[i]], dp[i][j]+a[i]);
		}
	}

	if (dp[m][(1<<n)-1] < INF){
		cout << dp[m][(1<<n)-1] << "\n";
	}else{
		cout << "-1\n";
	}

	return 0;
}

Measured memory_bytes: 32384