akhauriyash/Code-Regression huggingface dataset:
using System;
class _0030
{
    public static void Main()
    {
        string str = Console.ReadLine();
        int n,s,count;
        while (str != "0 0")
        {
            count = 0;
            n = int.Parse(str.Split()[0]); s = int.Parse(str.Split()[1]);
            for (int i = 0; i < 10; i++)
            {
                if (n == 1) count += (i == s) ? 1 : 0;
                for (int j = i + 1; j < 10; j++)
                {
                    if (n == 1) break;
                    if (n == 2) count += (i + j == s) ? 1 : 0;
                    for (int k = j + 1; k < 10; k++)
                    {
                        if (n == 2) break;
                        if (n == 3) count += (i + j + k == s) ? 1 : 0;
                        for (int l = k + 1; l < 10; l++)
                        {
                            if (n == 3) break;
                            if (n == 4) count += (i + j + k + l == s) ? 1 : 0;
                            for (int m = l + 1; m < 10; m++)
                            {
                                if (n == 4) break;
                                if (n == 5) count += (i + j + k + l + m == s) ? 1 : 0;
                                for (int o = m + 1; o < 10; o++)
                                {
                                    if (n == 5) break;
                                    if (n == 6) count += (i + j + k + l + m + o == s) ? 1 : 0;
                                    for (int p = o + 1; p < 10; p++)
                                    {
                                        if (n == 6) break;
                                        if (n == 7) count += (i + j + k + l + m + o + p == s) ? 1 : 0;
                                        for (int q = p + 1; q < 10; q++)
                                        {
                                            if (n == 7) break;
                                            if (n == 8) count += (i + j + k + l + m + o + p + q == s) ? 1 : 0;
                                            for (int r = q + 1; r < 10; r++)
                                            {
                                                if (n == 8) break;
                                                if (n == 9) count += (i + j + k + l + m + o + p + q + r == s) ? 1 : 0;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Console.WriteLine(count);
            str = Console.ReadLine();
        }
    }
}

Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=210000,V=301000,E=2010000;
int s,t,vtot,n,vis[N],pl[N],pr[N];
vector<PII> ed[N];
vector<pair<int,PII>> ans;
VI eg[N];
struct edge{int v,ne;ll f;}e[E*2];int g[V],et;
void ae(int u,int v,ll f){
	e[et]={v,g[u],f};g[u]=et++;
	e[et]={u,g[v],0};g[v]=et++;
}
int d[V],cu[V];
bool lb(){
	rep(i,0,vtot)d[i]=0,cu[i]=g[i];
	static int qu[V];
	int p=0,q=0;
	qu[q++]=s,d[s]=1;
	while(p!=q){
		int u=qu[p++];
		for (int i=g[u];~i;i=e[i].ne)if(e[i].f && !d[e[i].v]){
			d[e[i].v]=d[u]+1;
			if(e[i].v==t)return 1;
			qu[q++]=e[i].v;
		}
	}return 0;
}
ll aug(int u,ll m){
	if(u==t)return m;
	ll su=0,f;
	for (int i=cu[u];~i;cu[u]=i=e[i].ne)if(e[i].f && d[e[i].v]==d[u]+1){
		f=aug(e[i].v,min(m,e[i].f));
		e[i].f-=f; e[i^1].f+=f;
		m-=f; su+=f;
		if(!m)break;
	}
	if(!su)d[u]=-1;
	return su;
}
ll dinic(){
	ll su=0;
	while(lb())su+=aug(s,1<<30);
	return su;
}
void init(){
	rep(i,0,vtot)g[i]=-1;
	et=0;
}

void dfs(int u) {
	vis[u]=1;
	for (auto v:eg[u]) if (v!=pr[u]&&!vis[pl[v]]) {
		ans.pb(mp(v,mp(u,pl[v])));
		dfs(pl[v]);
	}
}
int main() {
	scanf("%d",&n);
	s=2*n-1, t=2*n;
	vtot=2*n+1;
	init();
	rep(i,0,n-1) {
		ae(n+i,t,1);
		int t,x;
		scanf("%d",&t);
		rep(j,0,t) {
			scanf("%d",&x);
			--x;
			ed[i].pb(mp(et,x));
			eg[x].pb(i);
			ae(x,n+i,1);
		}
	}
	rep(i,0,n) ae(s,i,1);
	int w=dinic();
	if (w!=n-1) {
		puts("-1");
		return 0;
	}
	rep(i,0,n) pr[i]=-1;
	rep(i,0,n-1) {
		for (auto p:ed[i]) {
			if (e[p.fi].f==0) {
				pl[i]=p.se;
				pr[p.se]=i;
			}
		}
	}
	int rt=-1;
	rep(i,0,n) if (pr[i]==-1) {
		rt=i;
	}
	dfs(rt);
	if (SZ(ans)!=n-1) {
		puts("-1");
		return 0;
	}
	sort(all(ans));
	for (auto p:ans) {
		printf("%d %d\n",p.se.fi+1,p.se.se+1);
	}
}

Measured memory_bytes: 43380
import java.util.Scanner;

public class Main {

    static int c = 0;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int result = 0;
        for (int i= 0; i < N; i++) {
            result += i;
        }
        for (int i= 0; i < M; i++) {
            result += i;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  ll now = 0;
  now = 10;
  vector<int> num(20);
  for(int i = 0;i < 20;i++)num[i] = -1;
  num[0] = 0,num[1] = 1;
  string res;
  if(n <= 10)res = to_string(n);
  else{
    ll keta = 0;
    keta = 1;
    while(1){
      now++;
      bool addketa = true;
      ll check = 0;
      //check = 1;
      while(1){
        if(num[check] <= 8 && num[check] >= 0 && ((abs(num[check] + 1 - num[check + 1]) <= 1) || num[check + 1] == -1)){
          num[check]++;
          for(int i = check - 1;i >= 0;i--)num[i] = max(num[i + 1] - 1,0);
          addketa = false;
          break;
        }
        if(check == 18)break;
        check++;
      }
      if(addketa){
        for(int i = 0;i <= keta;i++)num[i] = 0;
        num[keta + 1] = 1;
        keta++;
      }
      if(now == n){
        //cout << "A" << endl;
        for(int i = keta;i >= 0;i--)res += to_string(num[i]);
        break;
      }
      //for(int i = 19;i >= 0;i--)cout << num[i];
      //cout << endl;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <list>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#include <math.h>

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;

	int r[7] = { 0 };

	r[a - 1]++;
	r[b - 1]++;
	r[c - 1]++;


	if (r[6]==1 && r[4]==2){ cout << "YES" << endl; }
	else{ cout << "NO" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  char a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  if(a==f&&b==e&&c==d)cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    if(S=="Y"){
      cout<<"Four"<<endl;
      return 0;
    }
  }
  cout<<"Three"<<endl;

}


Measured memory_bytes: 256
import sys
K=input()
if int(K)%2==0:
    print(-1)
    sys.exit()

S=int('7'*(len(K)))
ans=len(K)
K=int(K)
for i in range(10**6):
    if S%K==0:
        print(ans)
        break
    else:
        S=(S*10)%K+7
        ans+=1
else:
    print(-1)

Measured memory_bytes: 9004
n = gets.chomp.to_i

s = Hash.new(0)
n.times do |i|
  si = gets.chomp
  s[si] += 1
end

keys = s.keys
values = s.values
max = values.max

list = []
s.each do |k, v|
  if v == max
    list.push(k)
  end
end

puts list.sort

Measured memory_bytes: 37084
#include <iostream>

using namespace std;

int main()
{
    /*int k;
    cin>>k;*/
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=0;
    int r=n-1;
    int res=0;
    while(s[l]=='R')
    {
        l++;
    }
    while(r>-1&&s[r]=='W')
    {
        r--;
    }
    while(l<r)
    {
            res++;
            l++;
            r--; 
            while(s[l]=='R')
            {
                l++;
            }
            while(r>-1&&s[r]=='W')
            {
                r--;
            }
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char b;
  cin>>b;
  if(b=='A')
    cout<<'T';
  if(b=='T')
    cout<<'A';
  if(b=='C')
    cout<<'G';
  if(b=='G')
    cout<<'C';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int a[200002]; 
int main() {
  int n,k;
  cin >> n >> k;
  rep(i,n) cin >> a[i];
  for (int i = 0; i < n-k; i++)
  {
    if (a[i]>=a[k+i]) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4400
#include <cstdio>
#include <cstring>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
int n,r;
int f[55],cp[55];
int main(void){
	for(;;){
		scanf("%d%d",&n,&r);
		if(n==0)break;
		rep(i,0,n)f[i]=n-i;
		rep(i,0,r){
			int a,b;
			scanf("%d%d",&a,&b);
			memcpy(cp,f,(a-1)*4);
			memcpy(f,f+a-1,b*4);
			memcpy(f+b,cp,(a-1)*4);
		}
		printf("%d\n",f[0]);
	}
	return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    vector<int> alp(26, 0);
    rep(i, s.size()) alp[s[i]-'a']++;
    if (s.size() == 26){
        for(int i = 25; i >= 0; i--){
            char sEnd = s[i] - 'a';
            alp[sEnd]--;
            s.pop_back();
            for(int j = sEnd+1; j < 26; j++){
                if(alp[j] == 0){
                    s += 'a' + j;
                    cout << s << endl;
                    return 0;
                }
            }
        }
        cout << -1 << endl;
        return 0;
    }else{
        rep(i,26){
            if (alp[i] == 0){
                s += 'a' + i;
                cout << s << endl;
                return 0;
            }
        }
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
class lca {
  public:
    int n, segn;
    std::vector<int> path, depth, in_order;
    std::vector<std::pair<int, int>> dat;
    const std::pair<int, int> INF = std::make_pair(1000000000, 1000000000);

    lca(vector<vector<int>> &g, int root)
        : n(g.size()), path(n * 2 - 1), depth(n * 2 - 1), in_order(n) {
        int k = 0;
        dfs(g, root, -1, 0, k);
        for(segn = 1; segn < n * 2 - 1; segn <<= 1)
            ;
        dat.assign(segn * 2, INF);
        for(int i = 0; i < (int)depth.size(); ++i)
            dat[segn + i] = std::make_pair(depth[i], i);
        for(int i = segn - 1; i >= 1; --i)
            dat[i] = min(dat[i * 2], dat[i * 2 + 1]);
    }

    int get(int u, int v) const {
        int l = std::min(in_order[u], in_order[v]);
        int r = std::max(in_order[u], in_order[v]) + 1;
        return path[range_min(1, segn, l, r).second];
    }

    void dfs(vector<vector<int>> &g, int v, int p, int d, int &k) {
        in_order[v] = k;
        path[k] = v;
        depth[k++] = d;
        for(auto &e : g[v]) {
            if(e != p) {
                dfs(g, e, v, d + 1, k);
                path[k] = v;
                depth[k++] = d;
            }
        }
    }

    std::pair<int, int> range_min(int v, int w, int l, int r) const {
        if(r <= l || w == 0)
            return INF;
        if(r - l == w)
            return dat[v];
        int m = w / 2;
        auto rmin = range_min(v * 2, m, l, std::min(r, m));
        auto lmin = range_min(v * 2 + 1, m, std::max(0, l - m), r - m);
        return min(rmin, lmin);
    }
};

int main() {
    int n;
    cin >> n;
    int u, v;
    cin >> u >> v;
    u--, v--;
    vector<vector<int>> edge(n);
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    lca L(edge, u);
    vector<int> d(n, -1);
    queue<int> que;
    que.push(u);
    d[u] = 0;
    while(!que.empty()) {
        int now = que.front();
        que.pop();
        for(auto next : edge[now]) {
            if(d[next] == -1) {
                d[next] = d[now] + 1;
                que.push(next);
            }
        }
    }
    ll M = 0;
    for(int i = 0; i < n; i++) {
        if(d[i] + d[v] - 2 * d[L.get(i, v)] > M) {
            if(d[L.get(i, v)] < d[v] - d[L.get(i, v)]) {
                M = d[i] + d[v] - 2 * d[L.get(i, v)];
            }
        }
    }
    if(M == 0) {
        cout << 0 << endl;
    } else {
        cout << M - 1 << endl;
    }
}


Measured memory_bytes: 14080
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 16 + 1;

int A[N], DP[N][1 << N], F[1 << N], I[1 << N];

void Add(int &x, int y) {
	x += y;
	if (x >= MOD) x -= MOD;
}
void Sub(int &x, int y) {
	x -= y;
	if (x < 0) x += MOD;
}
int SMul(int x, int y) { return 1LL * x * y % MOD; }
int Power(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = SMul(a, a)) if (b & 1) res = SMul(res, a);
	return res;
}
int nCr(int n, int r) {
	if (n < 0 || r > n) return 0;
	return SMul(SMul(I[r], I[n - r]), F[n]);
}

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	F[0] = 1;
	for (int i = 1; i < (1 << N); i++) F[i] = SMul(i, F[i - 1]);
	I[(1 << N) - 1] = Power(F[(1 << N) - 1], MOD - 2);
	for (int i = (1 << N) - 1; i > 0; i--) I[i - 1] = SMul(i, I[i]);

	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) cin >> A[m - i];

	DP[0][0] = 1;
	for (int i = 1; i <= m; i++) for (int mask = 0; mask < (1 << n); mask++) {
		Add(DP[i][mask], DP[i - 1][mask]);
		for (int j = 0; j < n; j++) if ((mask >> j) & 1) {
			int c = (1 << n) - A[i] - (mask ^ (1 << j));
			int w = SMul(nCr(c, (1 << j) - 1), F[1 << j]);
			Add(DP[i][mask], SMul(DP[i - 1][mask ^ (1 << j)], w));
		}
	}

	int ans = 0;
	for (int mask = 0; mask < (1 << n); mask++) {
		int c = (1 << n) - mask - 1;
		int w = F[c];
		if (!__builtin_parity(mask)) Add(ans, SMul(DP[m][mask], F[c]));
		else Sub(ans, SMul(DP[m][mask], F[c]));
	}
	cout << SMul(ans, (1 << n)) << endl;

	return 0;
}


Measured memory_bytes: 8740
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

x = [a,b,c,d,e]

x.sort()
if x[4] - x[0] <= k:
    print("Yay!")
else:
    print(":(")


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

int main(){
  int H, W;

  while(true){
    cin >> H >> W;

    if(H==0 && W==0){
      return 0;
    }else {
      for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
          if(i%2==0){
            if(j%2==0){
              cout << "#";
            }else{
              cout << ".";
            }
          }else{
            if(j%2==0){
              cout << ".";
            }else{
              cout << "#";
            }
          }
        }
        cout << endl;
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 3092
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define mod 1000000007
using namespace std;
typedef long long int LL;

int manhattan_dist(pair<int, int> a, pair<int, int> b) {
    return abs(a.first - b.first) + abs(a.second - b.second);
}

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

    vector<pair<int, int> > v;
    vector<int> time;
    rep(i, n) {
        int t;
        int x, y;
        cin >> t >> x >> y;
        v.push_back(make_pair(x, y));
        time.push_back(t);
    }
    if ((manhattan_dist(v[0], make_pair(0, 0)) != time[0]
         and (manhattan_dist(v[0], make_pair(0, 0)) ) % 2 == 0)
        or manhattan_dist(v[0], make_pair(0, 0)) > time[0]) {
        cout << "No" << endl;
        return 0;
    }
    for(int i = 1; i < n; i++) {
        int dist = manhattan_dist(v[i], v[i - 1]);
        // cout << "!!!" << dist << endl;
        int t = time[i] - time[i - 1];
        if ((dist != t and dist % 2 == 0) or dist > t) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int a[m+1];
    int s=0;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    if(s<=n)
    {
        cout<<n-s<<endl;
    }
    else
    {
        cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int a[3005];
	int r,d,x;
	scanf("%d%d%d",&r,&d,&x);
	for(int i=1;i<=10;i++)
	{
		printf("%d\n",r*x-d);
		x=r*x-d;
	}	
  return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long[] counts = new long[4];

        for (int i = 0; i < 6; i++)
        {
            counts[sc.NextInt() - 1]++;
        }

        bool ok = counts.Where(c => c == 3).Count() == 0;

        string answer = ok ? "YES" : "NO";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28124
function swap(A, i, j) {
	var tmp = A[i];
	A[i] = A[j];
	A[j] = tmp;
}

function partition(A, p, r) {
	var x = A[r].num;
	var i = p - 1;
	for (var j = p; j < r; j++) {
		if (A[j].num <= x) {
			i++;
			swap(A, i, j);
		}
	}
	swap(A, i + 1, r);

	return i + 1;
}

function sort(A, p, r) {
	if (p < r) {
		var q = partition(A, p, r);
		sort(A, p, q - 1);
		sort(A, q + 1, r);
	}
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

var n = +lines.shift();

var line;
var A = [];
var C = {};
while (line = lines.shift()) {
	var arr = line.split(' ');
	A.push({suit: arr[0], num: +arr[1]});

	var str = C[arr[1]] || '';
	C[arr[1]] = str + arr[0];
}

sort(A, 0, n - 1);

var isStable = true;
for (var i = 0; i < n; i++) {
	var e = A[i];
	var str = C[e.num + ''];
	if (str.substr(0, 1) != e.suit) {
		isStable = false;
		break;
	}
	C[e.num + ''] = str.substr(1);
}
console.log(isStable ? 'Stable' : 'Not stable');

A.forEach(function(e) {
	console.log(e.suit + ' ' + e.num);
});

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

int main(){
    string S;
    cin >> S;
    
    int count1 = 0;
    int count2 = 0;
    for(int i=0; i<S.length(); i++){
        if(i % 2==0){
            if(S[i] == '0')count1++;
        }else{
            if(S[i] == '1')count1++;
        }
    }
    
    for(int i=0; i<S.length(); i++){
        if(i % 2==0){
            if(S[i] == '1')count2++;
        }else{
            if(S[i] == '0')count2++;
        }
    }
    
    cout << min(count1, count2) << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

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

typedef int Weight;
struct edge {
  int src, dst;
  Weight weight;
  edge(int src, int dst) :
    src(src), dst(dst){ }
};
typedef vector<edge> edges;
typedef vector<edges> graph;

#define VAR(x) ((x) << 1)
#define NOT(x) ((x) ^ 1)
void visit(int v, const graph &g,
    vector<int> &ord, vector<int> &num, int k) {
  if (num[v] >= 0) return;
  num[v] = k;
  for (int i = 0; i < g[v].size(); ++i)
    visit(g[v][i].dst, g, ord, num, k);
  ord.push_back(v);
}
typedef pair<int,int> clause;
bool sat2(int m, const vector<clause> &cs) {
  int n = m * 2; // m positive vars and m negative vars
  graph g(n), h(n);
  for (int i = 0; i < cs.size(); ++i) {
    int u = cs[i].first, v = cs[i].second;
    g[NOT(u)].push_back( edge(NOT(u), v) );
    g[NOT(v)].push_back( edge(NOT(v), u) );
    h[v].push_back( edge(v, NOT(u)) );
    h[u].push_back( edge(u, NOT(v)) );
  }
  vector<int> num(n, -1), ord, dro;
  for (int i = 0; i < n; ++i)
    visit(i, g, ord, num, i);
  reverse(ord.begin(), ord.end());
  fill(num.begin(), num.end(), -1);
  for (int i = 0; i < n; ++i)
    visit(ord[i], h, dro, num, i);
  for (int i = 0; i < n; ++i)
    if (num[i] == num[NOT(i)])
      return false;
  return true;
}

struct NODE{
	int notflag;
	int a,b;
	int type;
	NODE(){
		notflag = a = b = 0;
		type = -1;
	}
};

NODE dem(NODE a){
	if( a.type == -1 ){
		a.a = NOT(a.a);
	}else{
		a.type ^= 1;
		a.notflag ^= 1;
		a.a ^= 1;
		a.b ^= 1;
	}
	return a;
}
NODE donot(NODE a){
	if( a.type == -1 ){
		a.a = NOT(a.a);
	}else{
		a.notflag ^= 1;
	}
	return a;
}

string ln;
int pos;
NODE Y();
NODE X(){
	NODE l = Y();
	NODE w;
	while( ln[pos] == '|' || ln[pos] == '&' ){
		char c = ln[pos];
		pos++;
		NODE r = Y();
		w.a = l.a;
		w.b = r.a; 
		w.type = c == '&';
		l = w;
	}
	return l;
}
int dic(string name){
	static map<string,int> memo;
	if( memo.count(name) ) return memo[name];
	else{
		int t = memo.size();
		return memo[name] = t;
	}
}
bool isalp(char c){
	return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') ;
}
NODE Y(){
	if( ln[pos] == '~' ){
		pos++;
		return donot(Y());
	}
	if( ln[pos] == '(' ){
		pos++;
		NODE r = X();
		pos++;
		return r;
	}
	string name = "";
	while( isalp(ln[pos]) ){
		name += ln[pos++];
	}
	NODE w;
	w.a = VAR(dic(name));
	return w;
}

int main(){
	int n,m;
	cin >> n >> m;
	vector< pair<int,int> > info;
	rep(i,n){
		cin >> ln;
		pos = 0;
		NODE e = X();
		if( e.notflag ) e = dem(e);
		if( e.type == 0 ) info.push_back(make_pair(e.a,e.b));
		else if( e.type == 1 ){
			info.push_back(make_pair(e.a,e.a));
			info.push_back(make_pair(e.b,e.b));
		}else{
			info.push_back(make_pair(e.a,e.a));
		}
		//;cout << (e.a&1?"~":"") << (e.a>>1) << " " << (e.b&1?"~":"") << (e.b>>1) << " " << (e.type?'&':'|') << endl;
	}
	cout << (sat2(m,info)?"accept":"reject") << endl;
}

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

int ans,c = 0,N,K;

void dfs(int sum,int top)
{
	if (top == N) {
		if (!c) {
			ans = sum;
			c = 1;
		}
		if (ans > sum)ans = sum;
		return;
	}
	top++;
	dfs(sum * 2, top);
	dfs(sum + K, top);
}

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

	dfs(1, 0);

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#define NMAX 100005

using namespace std;

int days[NMAX][3];
int n;
int dp[NMAX][3];

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
    {
        scanf("%d %d %d",&days[i][0],&days[i][1],&days[i][2]);
    }
    dp[1][0] = days[1][0];
    dp[1][1] = days[1][1];
    dp[1][2] = days[1][2];
    for (int i=2;i<=n;++i)
    {
        for (int j=0;j<3;++j)
        {
            for (int k=0;k<3;++k)
            {
                if (j == k)
                {
                    continue;
                }
                dp[i][j] = max(dp[i][j], dp[i-1][k] + days[i][j]);
            }
        }
    }
    int ans = 0;
    for (int i=0;i<3;++i)
    {
        ans = max(ans, dp[n][i]);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  set<string> st;
  cin >> N;
  for(int i=0; i<N; i++){
    string str;
    cin >> str;
    st.insert(str);
  }
  cout << st.size() << endl;
  return 0;
}

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

int main(void){
	long long int i, j, k, l, ret = 2019 * 2019;
	scanf("%lld %lld",&i, &j);
	if( j - i >= 2019) ret = 0;
	else {
		for(k = i; k < j; k++){
			for(l = k+1; l <= j; l++){
				if(ret > (k*l) % 2019)ret = (k*l) % 2019;
			}
		}
	}
	printf("%lld\n", ret);
}

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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long m = max(a * c, b * d);
  m = max(m, c * b);
  m = max(m, a * d);
  cout << m << endl;
}


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>


#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)


using namespace std;

typedef long long ll;

int N;
vector<int> m[100005];
pair<int, int> pr[100005];
map<pair<int, int>, int> umap;
int used[100005];
void dfs(int u, int clr) {
  int c = 1;
  for (int i = 0; i < m[u].size(); i++) {
    int v = m[u][i];
    if (!used[v]){
      //printf("%d->%d; color:%d\n", u, v, c);
      if (c == clr)c++;
      used[v]=1;
      umap[make_pair(u, v)] = c;
      umap[make_pair(v, u)] = c;
      dfs(v, c);
      c++;
    }
  }

}

int main(void) {
    scanf("%d", &N);
    rep(i, 0, N-1) {
      int a, b;
      scanf("%d %d", &a, &b);
      m[a-1].pb(b-1);
      m[b-1].pb(a-1);
      pr[i] = make_pair(a-1, b-1);
    }
    used[0] = 1;

    dfs(0, 0);
    
    int maxc = 0;
    rep(i, 0, N-1) {
      int u = pr[i].first;
      int v = pr[i].second;
      maxc = max(maxc, umap[make_pair(u, v)]);
    }
    printf("%d\n", maxc);

    rep(i, 0, N-1) {
      int u = pr[i].first;
      int v = pr[i].second;
      printf("%d\n", umap[make_pair(u, v)]);
    }
    

	return 0;
}


Measured memory_bytes: 20736
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char r = in.next().charAt(0);
            char g = in.next().charAt(0);
            char b = in.next().charAt(0);

            String l = "" + r + g + b;
            int w = Integer.valueOf(l);
            if (w % 4 == 0) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 23380
#include <stdio.h>
int S[10000];
int n;
int linearSearch(int);

int main(){
  int count=0;
  int T[500];
  int q,i;
  int re;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  } 
  for(i=0;i<q;i++){
    count+=linearSearch(T[i]);
  }
  printf("%d\n",count);
  return 0;
}
int linearSearch(int key){
  int i;
 for(i=0;i<n;i++){
    if(S[i]==key){
      return 1;
    }     
 }
 return 0;
}

Measured memory_bytes: 636
#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 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<P> vec;
  vector<ll> p(A);
  REP(i, A){
    cin >> p[i];
    vec.push_back(make_pair(p[i],0));
  }
  vector<ll> q(B);
  REP(i, B){
    cin >> q[i];
    vec.push_back(make_pair(q[i],1));
  }
  vector<ll> r(C);
  REP(i, C){
    cin >> r[i];
    vec.push_back(make_pair(r[i],2));
  }
  sort(ALL(vec));
  reverse(ALL(vec));

  ll x=0,y=0,z=0;
  ll ans = 0;
  REP(i,vec.size()){
    if(vec.at(i).second==0){
      if(x+1<=X&&y<=Y&&x+1+y+z<=X+Y){
        ans+=vec.at(i).first;
        x++;
      }
    }else if(vec.at(i).second==1){
      if(x<=X&&y+1<=Y&&x+y+1+z<=X+Y){
        ans+=vec.at(i).first;
        y++;
      }
    }else if(vec.at(i).second==2){
      if(x<=X&&y<=Y&&x+y+z+1<=X+Y){
        ans+=vec.at(i).first;
        z++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 8432
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int H, W;
  cin >> H >> W;
  int A, B;
  cin >> A >> B;

  int AA = W - A;
  int BB = H - B;

  rep(i, B) {
    rep(j, A) {
      cout << 1;
    }
    rep(j, AA) {
      cout << 0;
    }
    cout << endl;
  }
  rep(i, BB) {
    rep(j, A) {
      cout << 0;
    }
    rep(j, AA) {
      cout << 1;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let mut iter = s.trim().split_whitespace();

    let a: f64 = iter.next().unwrap().parse().unwrap();
    let b: f64 = iter.next().unwrap().parse().unwrap();
    let c: f64 = iter.next().unwrap().parse().unwrap();

    let h = b * c.to_radians().sin();
    let s = a * h / 2.;
    let l = a + b + ((a - b * c.to_radians().cos()).powi(2) + h.powi(2)).sqrt();

    println!("{}\n{}\n{}", s, l, h);
}



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

int main(){
    cin.sync_with_stdio(false);
    int n; cin >> n;

    vector<long long>v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    
    vector<int>cost(n);
    cost[n-1] = 0;
    cost[n-2] = abs(v[n-1]-v[n-2]);
    for(int i = n-3; i >= 0; i--){
        cost[i] = min(abs(v[i]-v[i+1])+cost[i+1], abs(v[i]-v[i+2])+cost[i+2]);
    }

    cout<<cost[0]<<endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll M;
ll A[101010],S[202020];

ll num(ll v) {
	ll tot=0;
	int i;
	FOR(i,N) {
		tot+=N-(lower_bound(A,A+N,v-A[i])-A);
	}
	return tot;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) {
		cin>>A[i];
	}
	sort(A,A+N);
	FOR(i,N) S[i+1]=S[i]+A[N-1-i];
	
	ll mi=0;
	for(i=40;i>=0;i--) if(num(mi+(1LL<<i))>=M) mi+=1LL<<i;
	
	ll num=0;
	ll ret=0;
	FOR(i,N) {
		x=N-(lower_bound(A,A+N,mi-A[i])-A);
		num+=x;
		ret+=A[i]*x+S[x];
		
	}
	ret-=(num-M)*mi;
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  string s;
  cin >> s;
  char a[s.size()];
  for(int i=0; i<s.size(); i++) {
    a[i]=s.at(i);
  }
  int ans=0;
  for(int i=0; i<s.size(); i++) {
    if(a[i]=='+') {
      ans++;
    }
    else {
      ans--;
    }
  }
  cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  vector<vector<ll>> dp(n,vector<ll>(n,INF));
  vector<ll> sum(n+1);
  rep(i,n) {
    dp[i][i] = 0;
    sum[i+1] = sum[i] + a[i];
  }
  for(int i = 1; i < n; i++) {
    for(int j = 0; j + i < n; j++) {
      for(int k = j; k < j+i; k++) {
        dp[j][i+j] = min(dp[j][i+j],dp[j][k]+dp[k+1][i+j]+sum[i+j+1]-sum[j]);
      }
    }
  }
  cout << dp[0][n-1] << endl;
  return 0;
}

Measured memory_bytes: 1536
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

vector<P> f(vector<int> x){
  sort(ALL(x));
  vector<P> y;
  int tmp = x[0];
  int c = 1;
  for (int i = 1; i < x.size(); i++){
    if (x[i] == tmp){
      c++;
    } else {
      y.push_back(make_pair(c, tmp));
      tmp = x[i];
      c = 1;
    }
  }
  y.push_back(make_pair(c, tmp));
  sort(ALL(y));
  reverse(ALL(y));
  return y;
}


int main(){
  int n;
  cin >> n;
  vector<int> a, b;
  rep(i, n){
    int x;
    cin >> x;
    if (i%2) a.push_back(x);
    else b.push_back(x);
  }

  vector<P> a_pair = f(a);
  vector<P> b_pair = f(b);

  int ans;
  if (a_pair[0].second != b_pair[0].second){
    ans = n - a_pair[0].first - b_pair[0].first;    
  } else {
    if (a_pair.size() != 1 && b_pair.size() != 1){  
      int ans1 = n - a_pair[0].first - b_pair[1].first;
      int ans2 = n - a_pair[1].first - b_pair[0].first;
      ans = min(ans1, ans2);
    } else if (a_pair.size() == 1 && b_pair.size() != 1){
      ans = n/2 - b_pair[1].first;
    } else if (a_pair.size() != 1 && b_pair.size() == 1){
      ans = n/2 - b_pair[1].first;
    } else if (a_pair.size() == 1 && b_pair.size() == 1){
      ans = n/2;
    }
  }

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


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

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

long long  lcm(long long x, long long y) {
	return x * y / gcd(x, y);
}

int main() {
	long long A,B,C,D;
	cin >> A>>B>>C>>D;
	A--;
	long long ans1 = A / C + A / D - A / (lcm(C, D));
	long long ans2 = B / C + B / D - B / (lcm(C, D));
	cout << (B-A)-(ans2 -ans1)<<endl;
	return 0;
}


Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	int d, n;
	std::cin >> d >> n;
	if (d == 0 && n >= 1 && n <= 99) {
		std::cout << n << std::endl;
	}
	else if (d == 0 && n == 100) {
		std::cout << 101 << std::endl;
	}
	else if (d == 1 && n >= 1 && n <= 99) {
		std::cout << n * 100 << std::endl;
	}
	else if (d == 1 && n == 100) {
		std::cout << 10100 << std::endl;
	}
	else if (d == 2 && n >= 1 && n <= 99) {
		std::cout << n * 10000 << std::endl;
	}
	else {
		std::cout << 1010000 << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
if a > b:
  print(0)
elif a == b:
  print(1)
else:
  if n > 1:
    max_ = a*1 + (n-1)*b
    min_ = a*(n-1) + 1*b
    print(max_ - min_ + 1)
  else:
    print(0)

Measured memory_bytes: 38384
a, b, n = [0] * 3

def format_input(filename = None):
	global a, b, n
	if filename == None:
		a, b, n = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		a = rng(1, 10**6)
		b = rng(1, 10**12)
		n = rng(1, 10**12)
		print(a, b, n)

def get_answer():
	answer = (a * min(b-1, n)) // b
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 9200
#include<iostream>
#include<vector>

using namespace std;

int main(){
  vector <long long> n;
  vector <long long> m;
  int a;
  cin >> a;
  int w,v;
  for(int i = 0;i < a;i++){
    cin >> w >> v;
    n.push_back(w);
    m.push_back(v);
  }
  long long h = 0,j = 0;
  for(int i = a - 1; i >= 0;i--){
    j = n[i] % m[i];
    if(j != 0)h = h + m[i] - j;
    j = 0;
    if((i - 1) != -1) n[i - 1] += h; 
  }
  cout << h << endl;
}

Measured memory_bytes: 2036
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    ll x;
    cin >> x;
    if (x < 7) {
        cout << 1 << "\n";
        return;
    }
    if (x < 12) {
        cout << 2 << "\n";
        return;
    }
    auto k = 2 * (x / 11);
    if (x % 11 <= 6) {
        k += (x % 11 != 0);
    } else {
        k += 2;
    }
    cout << k << "\n";
}





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

    return 0;
}

Measured memory_bytes: 256
object Main extends App {

  import scala.collection.mutable

  val n = scala.io.StdIn.readLine.toInt
  val a = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  var data = mutable.TreeSet.empty[Int]

  var cnt = n

  def getOdd(cnt: Int): Boolean = {
    data.count { a => a % cnt == 0 } % 2 == 0
  }

  def getOdd2(cnt: Int): Boolean = {
    var sumcnt = 0
    var now = cnt + cnt
    while (now <= n) {
      if (data(now)) {
        sumcnt += 1
      }

      now += cnt
    }

    sumcnt % 2 == 0
  }

  while (cnt >= 1) {
    val array_cnt = cnt - 1
    // 偶数 or 奇数
    val odd = getOdd2(cnt)

    if (odd && a(array_cnt) == 0) {
      // 偶数 & 求めるのも偶数
      //何もしない
    } else if (odd && a(array_cnt) == 1) {
      // 偶数 & 求めるのは奇数
      data += cnt
    } else if (!odd && a(array_cnt) == 0) {
      // 奇数 & 求めるのは偶数
      data += cnt
    } else if (!odd && a(array_cnt) == 1) {
      // 奇数 & 求めるのは奇数
      // なにもしない
    }
    cnt -= 1
  }

  println(data.size)
  if (data.nonEmpty) {
    println(data.toList.sorted.mkString(" "))
  }
}


Measured memory_bytes: 102524
#include <stdio.h>
#include <string.h>
#include <algorithm>

const int MOD = 998244353;

int main() {
  static char S[2019]; scanf("%2018s", S);
  int N = strlen(S);
  static int subsums[2001];
  subsums[0] = 0;
  for(int i = 0; i < N; ++i) {
    subsums[i+1] = subsums[i] + (S[i] - '0');
    // fprintf(stderr, "subsums[%d] = %d\n", i+1, subsums[i+1]);
  }
  static int dp[4001] = {};
  dp[0] = 1;
  for(int i = 1; i <= N; ++i) {
    for(int j = i; j >= 0; --j) {
      if(j > subsums[i] || i-j > i*2-subsums[i]) {
        dp[j] = 0;
        continue;
      }
      if(j > 0) dp[j] = (dp[j] + dp[j-1]) % MOD;
    }
    // for(int j = 0; j <= i; ++j) {
    //   fprintf(stderr, "dp[%d][%d] = %d\n", i, j, dp[j]);
    // }
  }
  for(int i = 0; i < N; ++i) {
    for(int j = subsums[N] - 1; j >= 0; --j) {
      dp[j+1] = (dp[j+1] + dp[j]) % MOD;
    }
  }
  printf("%d\n", dp[subsums[N]]);
  return 0;
}


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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(int i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define f(n)                for (ll i=0;i<n;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define N                   100005
ll MOD=pow(10,9)+7;
ll INF=1ll<<60;

int main()
{
    int n,w;cin>>n>>w;
    pair<int,ll> a[n+1];
    rep(i,1,n+1)
    {
        int w1;ll v;
        cin>>w1>>v;
        a[i]=mp(w1,v);
    }
    ll dp[n+1][w+1];
    mem(dp,0);
    rep(i,1,n+1)
    {
        rep(j,1,w+1)
        {
            if(j-a[i].F>=0)
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i].F]+a[i].S);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;
}


Measured memory_bytes: 79104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String[] cut = x.split(" ");
		int a = Integer.parseInt(cut[0]);
		int b = Integer.parseInt(cut[1]);
		int c = Integer.parseInt(cut[2]);

		int count = 3;

		if (a == b && a == c) {
			count = 1;
		} else {

			if (a == b) {
				count--;
			}
			if (b == c) {
				count--;
			}
			if (c == a) {
				count--;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23252
N = int(input())
b_list = list(map(int, input().split()))
a_list = []

if N == 2:
    print(sum(b_list) * 2)
    exit()
a_list.append(b_list[0])
for i in range(N-2):
    b = b_list[i]
    b2 = b_list[i+1]
    a_list.append(min(b, b2))

a_list.append(b_list[-1])
print(sum(a_list))



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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> b(n);
  rep(i, n) cin >> b[i];
  int ans = 0;
  sort(b.begin(), b.end());
  rep(i, k) ans += b[i];
  cout << ans << endl;
  
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define LL_INF (numeric_limits<long long>::max()/2)
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

const int kMaxN = 2*100000;

string S, T;
string ans;

// bool table[26];

signed main() {
  cin >> S;
  cin >> T;

  ans = "Yes";
  FOR(i, 'a', 'z') {
    int c = 0;
    REP(j, S.length()) {
      if (S[j] == i) {
        c = T[j];
        // if (table[c-'a']) {
        //   ans = "No";
        //   goto r;
        // } else {
        //   table[c-'a'] = true;
        // }
        break;
      }
    }

    if (c == 0) { continue; }

    REP(j, S.length()) {
      if ((S[j] == i && T[j] != c) || (S[j] != i && T[j] == c)) {
        ans = "No";
        goto r;
      }
    }
  }

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


Measured memory_bytes: 776
n,x=map(int,input().split())
l,p=[1],[1]
for i in range(n):
    l.append(l[i]*2+3)
    p.append(p[i]*2+1)

def f(n, x): # X <= 0 や X > a_N を許容し解説本文から簡略化
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + l[n-1]:
        return f(n-1, x-1)
    else:
        return p[n-1] + 1 + f(n-1, x-2-l[n-1])

print(f(n, x))

Measured memory_bytes: 3064
N, M, X = map(int, input().split())
squares = [0 for _ in range(N+1)]

A = list(map(int, input().split()))
for a in A:
    squares[a] = 1

root_a = sum(squares[0: X])
root_b = sum(squares[X: N+1])

if root_a < root_b:
    print(root_a)
else:
    print(root_b)

Measured memory_bytes: 9144
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let r = read::<i32>();
    let g = read::<i32>();
    let b = read::<i32>();

    let checking = 2*g + b;
    if checking % 4 == 0 {
        println!("YES");
    }else {
        println!("NO");
    }
}


Measured memory_bytes: 4352