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

//const int mod = 998244353;
const int mod = 1000000007;


struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(void){
    int n;
    cin >> n;
    vector<bitset<60>> vec(n);
    for(int i=0;i<n;i++){
        ll a; cin >> a;
        bitset<60> bit(a);
        vec[i] = bit;
        //cout << vec[i] << endl;
    }

    mint ans=0;
    for(int k=0;k<60;k++){
        int x=0,y=0;
        for(int i=0;i<n;i++){
            if(vec[i].test(k)== 1) x++;
            else y++; 
        }
        mint subans = x;
        subans *= y;
        mint pow2 = 2;
        subans *= pow2.pow(k/2);
        subans *= pow2.pow(k-k/2);
        ans += subans;
        //cout << "subans" << k << ": " << subans << endl;

    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
using System;

namespace ALDS1_1_A_InsertionSort
{
    class InsertionSort
    {

        public static void Main()
        {
            // Input
            Scanner cin = new Scanner();
            int n = cin.myInputInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
            {
                arr[i] = cin.myInputInt();
            }

            // ?¢??????????
            for (int i = 0; i < n; i++)
            {
                if ((i + 1) % n == 0)
                {
                    Console.Write("{0}", arr[i]);
                    Console.WriteLine();
                }
                else
                {
                    Console.Write("{0} ", arr[i]);
                }
            }

            // ??¢??°????????????
            new InsertionSort().insertionSort(arr, n);

            /*
            // ????????????
            for (int i = 0; i < n; i++)
            {
                if (i % 6 == 0)
                    Console.WriteLine();
                Console.Write("{0} ", arr[i]);
            }
            */
        }

        public void insertionSort(int[] A, int n)
        {
            int v, j;

            for (int i = 1; i < n; i++)
            {
                v = A[i];
                j = i - 1;
                while (j >= 0 && A[j] > v)
                {
                    A[j + 1] = A[j];
                    j--;
                }
                A[j + 1] = v;
                for (int z = 0; z < n; z++)
                {
                    if ((z + 1) % n == 0)
                    {
                        Console.Write("{0}", A[z]);
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.Write("{0} ", A[z]);
                    }
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string myInput()
        {
            if (i < s.Length)
                return s[i++];
            string st = Console.ReadLine();
            while (st == "")
                st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }

        public int myInputInt()
        {
            return int.Parse(myInput());
        }

        public long myInputLong()
        {
            return long.Parse(myInput());
        }

        public double myInputDouble()
        {
            return double.Parse(myInput());
        }
    }
}

Measured memory_bytes: 5764
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>         // abs
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

int main()
{  
    int N;
    cin >> N;
    char h[110];
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    set<char> value;
    for(int i = 0; i < N; i++){
        value.insert(h[i]);
    }
    int many = value.size();
    if(many == 3){
        cout << "Three" << endl;
    }
    else if(many == 4){
        cout << "Four" << endl;
    }
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
int a[9];
int main() {
	cin >> a[0] >> a[1] >> a[4];
	for (int i = -100000; i <= 100000; i++) {
		a[2] = i - a[0] - a[1];
		a[6] = i - a[2] - a[4];
		a[7] = i - a[1] - a[4];
		a[8] = i - a[0] - a[4];
		a[3] = i - a[0] - a[6];
		a[5] = i - a[2] - a[8];
		if (a[3] + a[4] + a[5] == i && a[6] + a[7] + a[8] == i) {
			cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
			cout << a[3] << ' ' << a[4] << ' ' << a[5] << endl;
			cout << a[6] << ' ' << a[7] << ' ' << a[8] << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 384
n = gets.to_i
a = gets.split.map(&:to_i)

# 交換回数
$count = 0

def bubble_sort(a, n)
  flag = true
  i = 1

  while flag
    flag = false

    (i..n-1).reverse_each do |j|
      if a[j] < a[j-1]
        tmp = a[j]
        a[j] = a[j-1]
        a[j-1] = tmp
        flag = true

        $count += 1
      end
    end
    i += 1
  end
  a
end

puts bubble_sort(a, n).join(' ')
puts $count


Measured memory_bytes: 6892
s = input()
n = len(s)
rl = []
ll = []
c = 0
b = "R"
for i in range(n):
  if s[i] == b:
    c += 1
  else:
    if b == "R":
      rl.append(c)
      b = "L"
    else:
      ll.append(c)
      b = "R"
    c = 1
ll.append(c)
ans = []
for i,j in zip(rl,ll):
  ans += [0]*(i-1) + [i-i//2+j//2] + [i//2+j-j//2] + [0] *(j-1)
print(*ans)

Measured memory_bytes: 11584
import sys
X,Y,Z = map(int,input().split())

if not (1 <= X <= 10 ** 5 and 1 <= Y <= 10 ** 5 and 1 <= Z <= 10 ** 5):
    sys.exit()

if not (Y + 2*Z <= X):
    sys.exit()

max = 0
for I in range(int(X/(Y+Z))+1):
    if X - (Y * I + Z * (I + 1)) >= 0:
        max = I
print(max)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

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

int main() {
    int n; cin >> n;
    int t, a; cin >> t >> a;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    vector<double> tmp(n);
    rep(i, n) {
        tmp[i] = t-0.006*h[i]-a;
    }
    double ondo = INF;
    int ans = 0;
    rep(i, n) {
        if (ondo > abs(tmp[i])) {
            ondo = abs(tmp[i]);
            ans = i+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, K; cin >> n >> K;
    vi a(n); for(auto& e : a) cin >> e;
    
    int sum = 0; for(auto& e : a) cin >> e, sum += e;
    vi ds;
    rep(i, 1, (int)sqrt(sum) + 1){
        if(sum % i == 0){
            ds.emplace_back(i);
            ds.emplace_back(sum / i);
        }
    }
    uniq(ds);
    int m = ds.size();

    rrep(i, m){
        int d = ds[i];

        vi b = a;
        for(auto& e : b) e %= d;
        sort(_all(b));

        sum = 0;
        for(auto& e : b) sum += e;

        int rsum = 0;
        rrep(i, n){
            sum -= b[i];
            rsum += (d - b[i]) % d;

            if(sum == rsum){
                if(sum <= K){
                    cout << d << endl;
                    return 0;
                }
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

c = STR()
print(chr(ord(c) + 1))

Measured memory_bytes: 60012
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

#define INF 1e9+7

struct edge{
  int t,c, rev;
};

struct Graph{
  vector<vector<edge>> edges;
  vector<int> used;
  Graph(int n): edges(n){};
};

int dfs(int v, int t, int f, Graph& G){
  if(v == t) return f;
  G.used[v] = 1;
  for(edge& e:G.edges[v]){
    if(!G.used[e.t] && e.c > 0){
      int d = dfs(e.t, t, min(f, e.c), G);
      if(d > 0){
        e.c -= d;
        G.edges[e.t][e.rev].c += d;
        return d;
      }
    }
  }
  return 0;
}

int main(){
  int x,y,e;
  int ans = 0;
  cin >> x >> y >> e;
  Graph G = Graph(x+y+2);
  for(int i = 0; i < e; i++){
    int f,t;
    cin >> f >> t;
    G.edges[f].push_back((edge){x+t, 1, (int)G.edges[x+t].size()});
    G.edges[x+t].push_back((edge){f, 0, (int)G.edges[f].size() - 1});
  }
  int s = x+y;
  int t = x+y+1;

  for(int i = 0; i < x; i++){
    G.edges[s].push_back({i, 1, (int)G.edges[i].size()});
    G.edges[i].push_back({s, 0, (int)G.edges[s].size() - 1});
  }
  for(int i = 0; i < y; i++){
    G.edges[x+i].push_back({t, 1, (int)G.edges[t].size()});
    G.edges[t].push_back({x+i, 0, (int)G.edges[x+i].size() - 1});
  }
  for(;;){
    G.used = vector<int>(x+y+2, 0);
    int f = dfs(s, t, INF, G);
    if(f == 0) break;
    ans += f;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3256
/*
https://open.spotify.com/track/1nEjpWJlqcOsf2ZaRQ3XdW?si=kp72YcBSRjSiiZjnbDqP2A

In the particularly cold night
Perhaps you couldn’t sleep well
In the bright morning woken up from sleep
You are full of darkness
You, who were so worried for some reason that you
Hugged me tightly and asked for my love

You broke and ruined my everything
My daily life and even my people yeah
I resent you all day
But to leave you I oh I

Don’t worry babe
I love you babe
I’ll be by your side
Maybe

Maybe

Looks about to collapse but remains
And the cycle continues unsteadily
I’m about to give up but when I see you I Oh I

No babe
I love you babe
I’ll hold your hand
Maybe

Maybe
I’ll be by your side
Maybe
I’ll trust you

Stay with me, stay with me
So you won’t think of anything
I’ll stay here pretending to be reluctant
So hold me back
Maybe

Maybe
I will be by your side
Maybe
I’ll trust you

Maybe
*/

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 5010, K = 26, inf = 1e9;

int n, m, dp[maxn][maxn];
string s;

void solve(){
	int i, j, k, l, r; 
	cin >> n >> s; //s = '@' + s;
	m = s.length();
	dp[0][0] = 1;
	for1(i, 1, n){
		for1(j, 0, i){
			if(i == 1 && j == 0){
				dp[i][j] = 1;
			}
			else{
				dp[i][j] = (dp[i - 1][max(0ll, j - 1)] + dp[i - 1][j + 1] * 2) % modd1;
			}
		}
	}
//	for1(i, 1, n){
//		for1(j, 0, m){
//			cout << dp[i][j] << ' ';
//		}
//		cout << '\n';
//	}
	cout << dp[n][m];
}

signed main() {
    //freopen(".INP", "r", stdin);
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}

Measured memory_bytes: 120272
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;
const int INF = 1<<29;

signed main(){
    ll k;
    cin>>k;
    ll ans=0;
    vector<vector<ll>> a(20);
    rep(i,9){
        a[0].push_back(i+1);
        k--;
        if(k==0){
            ans = i+1;
            break;
        }
    }
    ll pm0[2],pm9[2],pm[3];
    pm0[0]=0,pm0[1]=+1;
    pm9[0]=-1,pm9[1]=0;
    pm[0]=-1,pm[1]=0,pm[2]=1;
    ll ct=1;
    bool f = false;
    while(k>0){
        ll sz = a[ct-1].size();
        rep(i,sz){
            if(a[ct-1][i]%10==0){
                rep(j,2){
                    ans = a[ct-1][i]*10+a[ct-1][i]%10+pm0[j];
                    a[ct].push_back(ans);
                    k--;
                    if(k==0){
                        f = true;
                        break;
                    }
                }
            }else if(a[ct-1][i]%10==9){
                rep(j,2){
                    ans = a[ct-1][i]*10+a[ct-1][i]%10+pm9[j];
                    a[ct].push_back(ans);
                    k--;
                    if(k==0){
                        
                        f = true;
                        break;
                    }
                }
            }else{
                rep(j,3){
                    ans = a[ct-1][i]*10+a[ct-1][i]%10+pm[j];
                    a[ct].push_back(ans);
                    k--;
                    if(k==0){
                        f = true;
                        break;
                    }
                }
            }
            if(f) break;
        }
        ct++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	
	int ans = INF;
	REP(i, max(X, Y) + 1) {
		int cur = C * i * 2;
		int nx = X - i;
		int ny = Y - i;
		
		cur += max(nx, 0) * A;
		cur += max(ny, 0) * B;
		chmin(ans, cur);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int n;
	cin >> n;
	int a[n];
	set <int> st;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		st.insert(a[i]);
	}

	sort(a, a+n);

	// for (int i = 0; i < n; i++) {
	// 	cout << a[i] << " ";
	// }
	// cout << "" << "\n";

	ll ans = 0;

	for (int i = 1; i < n; i++) {
		if(a[i] == a[i-1]) {
			int tmp = i;
			while (a[i]==a[i-1] && i < n) {
				i++;
			}
			if ((i-tmp) % 2 == 1) {
				ans++;
			}
		}
	}
	// cout << "pair: " << ans << "\n";
	// cout << "set size: " << st.size() << "\n";
	if (ans % 2 == 0) {
		cout << st.size() << "\n";
	} else {
		cout << st.size()-1 << "\n";
	}

}


Measured memory_bytes: 5376
using System.Collections.Generic;
using System.Linq;
using System;

public class C
{
    public const int INF = 999999999;
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var te = new int[n, 3];
            var d = new Dictionary<int, int>();
            var cnt = 0;
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var a = int.Parse(line[0]);
                var b = int.Parse(line[1]);
                var c = int.Parse(line[2]);
                te[i, 0] = a; te[i, 1] = b; te[i, 2] = c;
                if (!d.ContainsKey(a)) d[a] = cnt++;
                if (!d.ContainsKey(b)) d[b] = cnt++;
            }
            var city = d.Count();
            var dp = new int[city, city];
            for (int i = 0; i < city; i++)
                for (int j = 0; j < city; j++)
                    if (i == j) dp[i, j] = 0;
                    else dp[i, j] = C.INF;
            for (int i = 0; i < n; i++)
            {
                dp[te[i, 0], te[i, 1]] = te[i, 2];
                dp[te[i, 1], te[i, 0]] = te[i, 2];
            }
            goWarshall(dp);
            var mincity = -1; var mintotal = C.INF;
            for (int i = 0; i < city; i++)
            {
                var submin = 0;
                for (int j = 0; j < city; j++)
                    submin += dp[i, j];
                if (submin < mintotal) { mintotal = submin; mincity = i; }
            }
            Console.WriteLine("{0} {1}", mincity, mintotal);
        }
    }
    public static void goWarshall(int[,] dp)
    {
        var n = dp.GetLength(0);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                    dp[j, k] = Math.Min(dp[j, k], dp[j, i] + dp[i, k]);
    }
}

Measured memory_bytes: 10036
hist = {}
while line = gets do
  n = line.to_i
  if hist.include? n
    hist[n] += 1
  else
    hist[n] = 1
  end
end
hist = hist.sort{|(k1, v1), (k2, v2)| v2 <=> v1}
keys = []
0.step(hist.length - 2) do |i|
  keys.push hist.to_a[i][0]
  break if hist.to_a[i][1] != hist.to_a[i + 1][1]
end
keys.sort!
keys.each do |i|
  puts i
end

Measured memory_bytes: 8716
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
int main()  
{     
    ll n,l;
    cin>>n>>l;
    vector<string> v(n);
    for(ll i=0;i<n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    for(ll i=0;i<n;i++)
        cout<<v[i];
}   

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

int main(){
    int A,B;
    cin >> A >> B;
    if(A <= 5){
        cout << 0 << endl;
    }
    else if(A <= 12){
        cout << B/2 << endl;
    }
    else{
        cout << B << endl;
    }
}


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

using namespace std;

int n,m;
int hit;
int d;
int line[31][31];

// ツ個サツ催敖づ個暗クツつォツ陛サツづゴツーツδ仰づつォツづゥツつゥツづつ、ツつゥ
bool isOk(){
	int rank=0;
	int p=m;
	for(int i = 0; i < d; i++){
		int left=p-1;
		int right=p;
		if(left>=0&&line[i][left]){
			p=left;
		}
		else if(right<n-1&&line[i][right]){
			p=right+1;
		}
	}
	// goal
	if(p==hit){
		return true;
	}
	else
		return false;
}

int main(){

	while(cin>>n&&n!=0){
		cin>>m>>hit>>d;
		hit--;
		m--;
		for(int i = 0; i < d; i++){
			for(int j = 0; j < n-1; j++){
				char ch;
				cin>>ch;
				line[i][j]=ch-'0';
			}
		}
		if(isOk())
			cout<<0<<endl;
		else{
			bool f=false;
			for(int i = 0; i < d; i++){
				for(int j = 0; j < n-1; j++){
					if(line[i][j]==0&&(j==0||line[i][j-1]==0)&&(j==n-1||line[i][j+1]==0)){
						line[i][j]=1;
						if(isOk()){
							cout<<i+1<<" "<<j+1<<endl;
							f=true;
							break;
						}
						line[i][j]=0;
					}
				}
				if(f)
					break;
			}
			if(!f){
				cout<<1<<endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;

ll k, x;

ll max(ll a, ll b) {
	if (a > b)
		return a;
	else return b;
}

int main(void) {
	cin >> k >> x;
	int cnt = 0;
	for (ll i = max(-1000000, x - k + 1); cnt < 2 * k - 1; i++, cnt++) {
		if (i <= 1000000)
			cout << i << " ";
		else break;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
# 文字列として、red, green, blue の数字を出力
red_num, green_num, blue_num = map(str, input().split())

# ３つの文字列を合わせる。
join_three_num = red_num + green_num + blue_num

# 文字列を数字に変換。
three_digit_int = int(join_three_num)

if three_digit_int % 4 == 0:
    print('YES')
else:
    print('NO')

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

using namespace std;

using LL = long long;
using II = pair<int, int>;

const int MAX_N = 100005;
int N;
LL A, B;
LL H[MAX_N];

bool check(LL mid)
{
  LL t = B*mid;
  LL d = A-B;
  int index = 0;
  for(; index < N; index++) {
    LL h = H[index] - t;
    if(h <= 0) {
      continue;
    } else {
      mid -= (h/d)+(h%d != 0);
    }
  }

  return mid >= 0;
}

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

  LL l = 0, r = 1145141919;
  while(r-l > 1) {
    LL mid = (l+r)/2;
    if(check(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }

  cout << r << endl;

  return 0;
}


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

int main()
{
	int i, count=0;
	string s;
	int x[26] = { 0 };

	cin >> s;

	for (i = 0; i < 4; i++){
		x[s[i] - 'A']++;
	}

	for (i = 0; i < 26; i++){
		if (x[i] == 2){
			count++;
		}
	}

	if (count == 2){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
import math

ans = []
for i in range(n+1):
    cnt6 = i
    cnt9 = n - i
    ans6 = 0
    ans9 = 0
    
    while cnt6 > 0:
        sho = 6**math.floor(math.log(cnt6, 6))
        ans6 += cnt6//sho
        cnt6= cnt6%sho
        
    while cnt9 > 0:
        if cnt9 != 59049:
            sho2 = 9**math.floor(math.log(cnt9, 9))
        else:
            sho2=59049
        ans9 += cnt9//sho2
        cnt9 = cnt9%sho2
        
    ans.append(ans6+ans9)
    sho, sho2 = 0, 0
        
print(min(ans))

Measured memory_bytes: 3864
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MOD = 998244353;
long long INF = 1e18;
int main(){
    long long N, S;
    cin >> N >> S;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    vector<vector<long long>> dp(N + 1, vector<long long> (S + 1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < S + 1; j++){
            if(j < A[i]) dp[i + 1][j] = 2 * dp[i][j] % MOD;
            else dp[i + 1][j] = (2 * dp[i][j] + dp[i][j - A[i]]) % MOD;
        }
    }
    cout << dp[N][S] << endl;
}

Measured memory_bytes: 73632
n = int(input())
check = {}
lst = []

for _ in range(n):
  s = list(input())
  s.sort()
  s = "".join(s)
  lst.append(s)
  try:
    check[s]+=1
  except:
    check.update({s:1})
  
cnt=0
check_set = set(lst)
for c in check_set:
  temp_cnt = check[c]
  cnt +=  temp_cnt*(temp_cnt-1)/2
print(int(cnt))

Measured memory_bytes: 23068
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    vector<ll> potenciasPositivas;
    vector<ll> potenciasNegativas;
    for(ll i=0;i<126;i++){
        potenciasPositivas.push_back(i*i*i*i*i);
        potenciasNegativas.push_back(-(i*i*i*i*i));
    }
    int x;
    cin >> x;
    bool romper=false;
    for(int i=0;i<potenciasPositivas.size();i++){
        for(int j=0;j<potenciasPositivas.size();j++){
            if(potenciasPositivas[i]-potenciasPositivas[j]==x){
                cout << i << " " << j << endl;
                romper=true;
                break;
            }
            if(potenciasPositivas[i]-potenciasNegativas[j]==x){
                cout << i << " " << -j << endl;
                romper=true;
                break;
            }
            if(potenciasNegativas[i]-potenciasPositivas[j]==x){
                cout << -i << " " << j << endl;
                romper=true;
                break;
            }
            if(potenciasNegativas[i]-potenciasNegativas[j]==x){
                cout << -i << " " << -j << endl;
                romper=true;
                break;
            }
        }
        if(romper) break;
    }
    return 0;
}


Measured memory_bytes: 3644
n=int(input())
v=[int(i) for i in input().split()]
v.sort()
ans=0
for i in range(n):
  
  if i<n-1:
    ans+=v[n-i-1]/(2**(i+1))
  else:
    ans+=v[n-i-1]/(2**(n-1))
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
int main() {

int a, b, c;
int sum;
  
cin >> a >> b >> c;
  
for (int i = b; i <= c; i++) {
  if(i%a==0){sum=sum+1;}
}

if(sum==0){cout<<"NG";}
  else{cout<<"OK";}
}

Measured memory_bytes: 3636
/*
公式チャンネルの解説を実装したものです
*/

#include<stdio.h>

int myJudge(char *sa, char *sb);

int main(void)
{
  char s[100+1]={0};
  char sa[100+1]={0};
  char sb[100+1]={0};
  int n=0;
  int ans=0;
  int i=0;
  int k=0;
  int j=0;
  int max=0;

  scanf("%d", &n);
  scanf("%s", s);

  //kは仕切りの位置を表していて
  //[i]と[i+1]の間にあるときk=iとしています
  for(k=0; k<=n-2; k++){
    
    i=0;
    j=0;

    //saに入れる
    while(i!=k+1){
      sa[i] = s[i];
      i++;
    }
    sa[i] = '\0';
    //sbに入れる
    while(i<=n-1){
      sb[j] = s[i];
      i++;
      j++;
    }
    sb[j] = '\0';

    ans = myJudge(sa, sb);
   
    if(ans > max){
      max = ans;
    }
    
    
  }
  printf("%d\n", max);

  return 0;
}

//aからzの文字を一つずつ、saとsbの両方に含まれるか判定する関数
int myJudge(char *sa, char *sb)
{
  char c;
  int cnt=0;
  int ans1=0,ans2=0;
  char *p;


  for(c='a'; c<='z'; c++){
    ans1=0,ans2=0;

    p=sa;
    while(*p != '\0'){
      if(*p == c){
	ans1 = 1;
	break;
      }
      ++p;
    }
    p=sb;
    while(*p != '\0'){
      if(*p == c){
	ans2 = 1;
	break;
      }
      ++p;
    }
    if(ans1==1 && ans2==1)
      cnt++;
  
  }

  return cnt;
}



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

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

int main(){
	double n=read(),d=read(),x=read(),ans=0;
	while (n){
		ans+=d+x*(2*n-1)/2;
		d=((2*n+2)*d+5*x)/(2*n);
		x*=(n+2.0)/n;
		n--; 
	}
	printf("%.12lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
//104A
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int R =0;
    cin >> R;
    if (R <1200){
        cout << "ABC";
    }else if(R <2800){
        cout << "ARC";
    }else{
        cout << "AGC";
    }
 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int w[]={1,2,4,8,16,32,64,128,256,512};
main(){
  int n;
  while(cin >>n){
    vector<int> ans;
    for(int i=9;i>-1;i--){
      if(w[i]<=n){
	ans.push_back(w[i]);
	n-=w[i];
      }
    }
    reverse(ans.begin(),ans.end());
    int m=ans.size();
    for(int i=0;i<m;i++){
      printf("%d",ans[i]);
      if( i==m-1 ) printf("\n");
      else printf(" ");
    }
  }
}

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

typedef long long ll;
#define int ll

using namespace std;

const int N=2e3+100;
const int inf=2e9;
int a[N],b[N];

signed main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2)
        cout<<b-a;
    else
        cout<<a-b;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I32_MAX
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 201010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

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

vector<int> divisor(int n)
{
  vector<int> ret;
  for (int 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);
}

template <typename T>
map<T, T> prime_factor(T n)
{
  map<T, T> ret;
  for (T i = 2; i * i <= n; i++)
  {
    T tmp = 0;
    while (n % i == 0)
    {
      tmp++;
      n /= i;
    }
    ret[i] = tmp;
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}
/*  divisor_num(n)
    入力：整数 n
    出力：nの約数の個数
    計算量：O(√n)
*/
template <typename T>
T divisor_num(T N)
{
  map<T, T> pf = prime_factor(N);
  T ret = 1;
  for (auto p : pf)
  {
    ret *= (p.second + 1);
  }
  return ret;
}

void solve(void)
{
  int n;
  cin >> n;
  int res = 0;
  int x = n - 1;
  for (int i = 1; i < n; i++)
  {
    /* code */
    res += x / i;
  }
  cout << res << endl;

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

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

  return 0;
}


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

int main() {
	string N;
  bool A=false;
  cin>>N;
  if(N.at(0)=='7'){
    A=true;
  }
  if(N.at(1)=='7'){
    A=true;
  }
  if(N.at(2)=='7'){
    A=true;
  }
  if(A==true){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

	ll n, m;
	cin >> n >> m;
	if (2*n >= m)cout << m/2 << endl;
	else cout << n + (m - 2 * n) / 4 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int num;
        for(int i=1; i<= x; ++i){
		if(output1(i) != 0){
            System.out.printf(" %d", output1(i));
		}

		else if(output2(i) != 0){
		System.out.printf(" %d", output2(i));
		}
        }

        System.out.printf("\n");

    }
    private static int output1(int i){
        if((i % 3) == 0){
            return i;
        }
        else if(i>10 && output2(i/10) != 0){
		return i;
	}
	else{
		return 0;
	}
}

	private static int output2(int i){
        if((i % 10) == 3){
            return i;
        }
        else if( i>10 && output2(i/10) != 0){
            return i;
        }
        else{
            return 0;
         }
    }
}

Measured memory_bytes: 38812
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
const int N=5e5;
int fa[N],dep2[N],dep1[N],n,ans;
struct TREE
{
    int fst[N],nxt[N],to[N],mm;
    void ade(int u,int v){to[++mm]=v,nxt[mm]=fst[u],fst[u]=mm;}
}e1,e2;
void dfs2(int u,int Fa)
{
    fa[u]=Fa;
    for(int i=e2.fst[u];i;i=e2.nxt[i])
    {
        int v=e2.to[i];if(v==Fa)continue;
        dep2[v]=dep2[u]+1;dfs2(v,u);
    }
}
int check(int u,int v)
{
    if(dep2[u]==dep2[v])return fa[u]!=fa[v];
    if(dep2[u]>dep2[v])swap(u,v);
    return fa[v]!=u&&fa[fa[v]]!=u;
}
void dfs1(int u,int Fa)
{
    ans=max(ans,dep2[u]);
    for(int i=e1.fst[u];i;i=e1.nxt[i])
    {
        int v=e1.to[i];if(v==Fa)continue;
        dep1[v]=dep1[u]+1;
        if(check(u,v)){puts("-1");exit(0);}
        if(dep2[v]<=dep1[v])continue;
        dfs1(v,u);
    }
}
int main()
{
    int X,Y;
    scanf("%d%d%d",&n,&X,&Y);
    for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),e1.ade(u,v),e1.ade(v,u);
    for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),e2.ade(u,v),e2.ade(v,u);
    dfs2(Y,0),dfs1(X,0);
    cout<<ans*2<<endl;
}

Measured memory_bytes: 24972
import fractions

a, b = map(int, input().split())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append(i)

    if temp != 1:
        arr.append(temp)

    if arr == []:
        arr.append(n)

    return arr


f = fractions.gcd(a, b)

t = len(factorization(f))

if t == 1 and factorization(f)[0] == 1:
    print(t)
else:
    print(t + 1)


Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, A, B, C, D;
string s;
vector <int> h[2];

void go(int a, int g, vector <int> &e){
	while(a <= g){
		e[a] = 1;
		if(a == g) return;
		if(s[a + 1] == '.') a++;
		else if(a + 2 <= g && s[a + 2] == '.') a += 2;
		else return;
		
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> A >> B >> C >> D >> s;
	A--;
	B--;
	C--;
	D--;
	h[0].resize(n);
	h[1].resize(n);
	go(A, C, h[0]);
	go(B, D, h[1]);
	if(C < D){
		if(h[0][C] && h[1][D]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else{
		bool ok = 0;
		for(int i = 0 ; i + 2 < n ; i++){
			if(s[i] == '#' || s[i + 1] == '#' || s[i + 2] == '#') continue;
			if(h[0][i] && h[1][i + 1] && h[0][i + 2]) ok = 1;
		}
		if(h[0][C] && h[1][D] && ok) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 2128
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        Console.WriteLine(input[0]<=input[2]&&input[2]-input[0]<=input[1]?"YES":"NO");


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 13268
#include<stdio.h>

#define MAX 100000

int n,k;
long long T[MAX];
int check(long long P)
{
	int i=0;
	for(int j=0;j<k;j++)
	{
		long long s=0;
		while(s+T[i]<=P)
		{
			s+=T[i];
			i++;
			if(i==n)return n;
		}
	}
	return i;
}
int solve()
{
	long long left=0;
	long long right =100000*10000;
	long long mid;
	while(right-left>1)
	{
		mid=(right+left)/2;
		int v=check(mid);
		if(v>=n)right=mid;
		else left=mid;
		
	}
	return right;
}
int main(void)
{
	scanf("%d",&n);
	scanf("%d",&k);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&T[i]);
	}
	long long ans=solve();
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 2580
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N, M;
            N = cin.ReadInt;
            M = cin.ReadInt;
            int[] res =  new int[M];
            for (int i = 0; i < M; i++)
            {
                res[i] = 1;
            }
            for (int i = 0 ; i < N; i++)
            {
                int K = cin.ReadInt;
                int [] nowres = new int[M];
                for (int j = 0; j < M; j++)
                {
                    nowres[j] = 0;
                }
                for (int j = 0; j < K; j++)
                {
                    int A = cin.ReadInt;
                    nowres[A - 1] = 1;
                }
                for (int j = 0; j < M; j++)
                {
                    if (res[j] == 1 && nowres[j] == 0) { res[j] = 0; }
                }
            }
            int finres = Array.FindAll(res, x => x == 1).Length;
            Console.WriteLine("{0}", finres);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) { return inputStream.Dequeue(); }
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                {
                    inputStream.Enqueue(tmp[i]);
                }
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N)
        {
            string[] ret = new string[N];
            for (long i = 0; i < N; i++)
            {
                ret[i] = Read;
            }
            return ret;
        }
        public int[] ReadIntArray(long N)
        {
            int[] ret = new int[N];
            for (int i = 0; i < N; i++)
            {
                ret[i] = ReadInt;
            }
            return ret;
        }
        public long[] ReadLongArray(long N)
        {
            long[] ret = new long[N];
            for (long i = 0; i < N; i++)
            {
                ret[i] = ReadLong;
            }
            return ret;
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 51;
vector<pair<int, int>> adj[N];

vector<int> path;
bool dfs(int u, int p, int t) {
  if (u == t) return true;
  for (auto& e: adj[u]) {
    int v = e.first;
    int i = e.second;
    if (v != p) {
      if (dfs(v, u, t)) {
        path.push_back(i);
        return true;
      }
    }
  }
  return false;
}

int main() {
  int n; cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v; cin >> u >> v;
    adj[u].emplace_back(v, i);
    adj[v].emplace_back(u, i);
  }

  int m; cin >> m;
  vector<vector<int>> paths;
  for (int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    path.clear();
    bool res = dfs(u, u, v);
    assert(res);
    paths.push_back(path);
  }

  ll ans = 0;
  for (int mask = 0; mask < (1 << m); mask++) {
    int sign = 1;
    vector<bool> seen(n - 1, false);
    for (int i = 0; i < m; i++) {
      if (mask & (1 << i)) {
        sign *= -1;
        for (int j: paths[i]) seen[j] = true;
      }
    }
    int num = 0;
    for (bool s: seen) if (!s) num++;
    ans += sign * (1ll << num);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  
  if(n <= 104) cout<<0;
  else if(n <= 134) cout<<1;
  else if(n <= 164) cout<<2;
  else if(n <= 188) cout<<3;
  else if(n <= 194) cout<<4;
  else cout<<5;
  cout<<endl;
}


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

using namespace std;

int main(){
    int N, h, H;
    cin >> N >> H;
    int ans = 1;
    for(int i = 0; i < N-1; i++){
        cin >> h;
        if(H <= h){
            H = h;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;
typedef int64_t Data;
typedef vector<Data> Array;
typedef vector<Array> Matrix;

int64_t MOD;

Matrix operator*(const Matrix &lhs, const Matrix &rhs) {
  Matrix res(lhs.size(), Array(rhs[0].size(), 0));
  REP(i,lhs.size()) REP(j,rhs[0].size()) REP(k,rhs.size()){
    res[i][j] = res[i][j] + lhs[i][k] * rhs[k][j];
    res[i][j] %= MOD;
  }
  return res;
}

Matrix scalar(int size, Data k) {
  Matrix mat(size, Array(size, 0));
  REP(i,size) mat[i][i] = k;
  return mat;
}

Matrix operator^(const Matrix &lhs, const int n) {
  if (n == 0) return scalar(lhs.size(), 1);
  Matrix res = (lhs * lhs) ^ (n / 2);
  if (n % 2) res = res * lhs;
  return res;
}

int main() {
  while(1){
    int n,m,a,b,c,t;
    cin>>n>>m>>a>>b>>c>>t;
    if(!n)break;
    MOD = m;
    vector<int> v(n);
    REP(i,n)cin>>v[i];
    Matrix mat(n,Array(n));
    REP(i,n){
      if(i)mat[i][i-1] = a;
      if(i)mat[i-1][i] = c;
      mat[i][i] = b;
    }
    auto res = mat ^ t;
    REP(i,n) {
      int64_t val = 0;
      REP(j,n){
        val += res[i][j] * v[j];
        val %= MOD;
      }
      if(i)cout<<' ';
      cout << val;
    }
    cout<<endl;
  }
  return 0;
}

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

int main(){
	int n,k; cin >> n >> k; 
	vector<int>h(n);
	for(int i=0; i<n; i++){
		cin >> h[i];
	}
	vector<int>dp(n,INT_MAX);
	dp[0] = 0; 
	dp[1] = abs(h[1] - h[0]);
	for(int i=0; i<n; i++){
		for(int j = i+1; j<= i+k; j++){
			if(j < n){
				dp[j] = min(dp[j] , dp[i]+abs(h[i] - h[j]));
			}
		}
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 998244353;

int main(){
  string s;
  string t;
  cin >> s;
  cin >> t;
  vector<ll>s_char[26];
  for(int i=0; i<s.size(); i++){
    int S = s[i]-'a';
    int I = i;
    s_char[S].push_back(I);
  }
  
  ll MAX=0;
  for(int i=0; i<t.size(); i++){
    ll T = t[i]-'a';
    ll ss = s_char[T].size();
    ll n = MAX/s.size()+1;
    if(!ss){
      cout << -1 << endl;
      return 0;
    }
    ll x=0,j=0;
    if(s.size()*n-s.size()+s_char[T][ss-1]<MAX)n++;
    x=MAX-s.size()*n+s.size()-1;
    while(s_char[T][j]<=x){
      j++;
    }
    MAX=s.size()*n-s.size()+s_char[T][j]+1;
    //cout << x << endl;
  }
  cout << MAX << endl;
}
  
  
  
  


Measured memory_bytes: 1724
#include<iostream>
#include<math.h>
using namespace std;

int isPrime(int num)
{
    int n=int(pow(num,0.5));
    for(int i=2;i<=n;i++)
    {
        if(num%i==0)return 0;
    }
    return 1;
}

int main()
{
    int n,temp,sum=0;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> temp;
        if(isPrime(temp))sum++;
    }
    cout << sum << endl;
    return 0;
}


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

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

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

    int c = 0;
    for (int j = 0; j < N; j++){
        if (p[j] != j + 1) c++;
        if (c == 3){
            cout << "NO" << endl;
            break;
        }
    }

    if (c < 3)cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 256