akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

const int kNumTowns = 4;
const int kNumRoads = 3;

struct Road {
  Road(int from, int to, int index) : m_from(from), m_to(to), m_index(index) {}

  bool operator<(const Road &rhs) const { return m_index < rhs.m_index; }

  int m_from = 0;
  int m_to = 0;
  int m_index = 0;
};

bool IsEulerianTour(const vector<Road> &roads) {
  assert(roads.size() == 2 * kNumRoads);
  assert(!roads.empty());

  int curr = roads.front().m_from;
  vector<bool> visitedTowns(kNumTowns);
  vector<bool> usedRoads(kNumRoads);
  visitedTowns[curr] = true;

  for (const auto &road : roads) {
    if (usedRoads[road.m_index / 2])
      continue;
    usedRoads[road.m_index / 2] = true;

    if (road.m_from != curr)
      return false;
    curr = road.m_to;
    visitedTowns[curr] = true;
  }

  for (const auto & visited : visitedTowns) {
    if (!visited)
      return false;
  }
  return true;
}

int main() {
  vector<Road> roads;
  for (int i = 0; i < kNumRoads; ++i) {
    int from, to;
    cin >> from >> to;
    --from, --to;
    roads.emplace_back(from, to, 2 * i);
    roads.emplace_back(to, from, 2 * i + 1);
  }

  bool ok = false;
  do {
    if (IsEulerianTour(roads)) {
      ok = true;
      break;
    }
  } while (next_permutation(roads.begin(), roads.end()));
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << ' ' << y << ' ' << z << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(std::string S, std::string T){
    cout << T << S << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n;i++)
using namespace std;
int main(){
    string s;
    cin >> s;
    vector<string> ans = {"Sunny", "Cloudy", "Rainy"};
    rep(i, 3) if (s == ans[i]) cout << ans[(i+1)%3] << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define N 200002
int n,q;
vector<int>g[N];
int val[N];
bool vis[N];
void dfs(int x)
{
	//printf("%d\n",x);
	for(int i=0;i<g[x].size();i++)
	{
		val[g[x][i]]+=val[x];
		dfs(g[x][i]);
	}
}
inline int read()
{
	int x=0,f=1;
	char ch;
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main()
{
	n=read();
	q=read();
	int u,v;
	for(int i=1;i<n;i++)
	{
		u=read();
		v=read();
		vis[v]=1;
		g[u].push_back(v);
	}
	int r,x;
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{r=i;break;}
	while(q--)
	{
		x=read();
		v=read();
		val[x]+=v;
	}
	//printf("%d",r);
	dfs(r);
	for(int i=1;i<=n;i++)
		printf("%d ",val[i]);
}

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

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

    sort(a.begin(), a.end());

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

ll powa(ll a, ll b, ll c)
{
    a%=c;
    if(a<0)
	a+=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a, res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}

#define N 200005
 
ll fact[N];
ll ifact[N];

ll ncr(ll n, ll a)
{
    ll curr = 1;
    rep(a)
        curr*=(n-i), curr%=mod;
    curr*=ifact[a];
    curr%=mod;
    return curr;
}

int main()
{
   FAST/**/
   
   fact[0] = 1;
   for(ll i=1;i<N;i++)
        fact[i] = fact[i-1]*i, fact[i]%=mod;
   for(ll i=0;i<N;i++)
        ifact[i] = powa(fact[i],mod-2,mod);
   
   ll n,a,b;
   cin>>n>>a>>b;
   
   ll ans = powa(2,n,mod);
   ans = (ans-1+mod)%mod;
   ans-=(ncr(n,a) + ncr(n,b))%mod;
   ans%=mod;
   if(ans<0)
        ans+=mod;
   cout<<ans;        
    
   
   
   return 0;        
}  
   

Measured memory_bytes: 3456
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		double a = saori.Hayamin();
		double b = saori.Hayamin();
		double num1 = 0;
		double num2 = 0;
		boolean flg = false;
		int ans = 0;
		for(int i = 1;i <= 1250;i++){
			num1 = Math.floor(i*0.08);
			num2 = Math.floor(i*0.1);
		
			if(num1 == a && num2 == b){
				flg = true;
				ans = i;
				break;
			} 
		}
		if(flg){
			System.out.println(ans);
		} else {
			System.out.println("-1");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

class Program
{
    static void Main(string[] args)
    {
        var ab = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        if (ab[0] > 0) WriteLine("Positive");
        else if (ab[0] == 0 || ab[1] >= 0) WriteLine("Zero");
        else if ((ab[1] - ab[0] + 1) % 2 == 0) WriteLine("Positive");
        else WriteLine("Negative");
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N, M;
    cin >> N >> M;

    if (N >= M) {
        cout << 0 << endl;
        return;
    }

    vector<ll> X(M);
    for (int i = 0; i < M; i++) {
        cin >> X[i];
    }
    sort(all(X));

    vector<ll> diffX;
    ll total = 0;
    for (int i = 0; i < M-1; i++) {
        diffX.push_back(X[i+1] - X[i]);
        total += diffX[i];
    }

    sort(all(diffX));
    reverse(all(diffX)); // 降順

    ll ans = 0;
    for (int i = 0; i < N-1; i++) {
        ans += diffX[i];
    }

    cout << total - ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 2168
#include <iostream>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a == b)
    {
        cout << "a == b" << endl;
    }
    else if (a > b)
    {
        cout << "a > b" << endl;
    }
    else
    {
        cout << "a < b" << endl;
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h> //ライブラリ全読み込み
using namespace std; //std:を省略できる

int main(){
    int a,b,d,r;
    double f1,f2;
    cin >> a >> b;
    f1 = a;
    f2 = b;
    cout<<a/b<<" "<< a%b <<" ";
    printf("%.8lf\n", f1/f2);
    return 0;
}


Measured memory_bytes: 3224
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
a = [int(x) for x in input().split()]

total = sum(a)
mod = 10**9 + 7

ans = 0

for i in range(n):
    total -= a[i]
    ans += a[i] * total
    ans %= mod

print(ans)

Measured memory_bytes: 94240
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")



#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <memory>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <ctime>
#include <sstream>  
#include <deque>
#include <unordered_set>
#include <stack>
#include <functional>
#include <memory.h>
#include <bitset>
#include <numeric>

using namespace std;

//#define int long long

signed main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    int nec = 0;
    for (int i = 1; i <= n; ++i) {
        int cur;
        cin >> cur;
        nec |= cur % 2;
    }
    if (nec) {
        cout << "first" << endl;
    }
    else {
        cout << "second" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,c;
int main(){
    scanf("%d", &n);
    int temp = n;
    while(temp){
        c += temp%10;
        temp /= 10;
    }
    if(n%c==0)printf("Yes\n");
    else printf("No\n");
}


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

const int MAX_WIDTH = 1005, MAX_HEIGHT = 1005, MOD = 1e9 + 7;
const char WALL = '#';
char grid[MAX_WIDTH][MAX_HEIGHT];
long long no_of_paths[MAX_WIDTH][MAX_HEIGHT];

int main() {
    int height, width;
    scanf("%d %d", &height, &width);

    for (int i = 1; i <= height; i++)
        scanf("%s", grid[i] + 1);

    memset(no_of_paths, 0, sizeof(no_of_paths));

    for (int i = 1; i <= height; i++) {
        for (int j = 1; j <= width; j++) {
            if (grid[i][j] == WALL) continue;

            if (i == 1 && j == 1) {
                no_of_paths[i][j] = 1;
            } else {
                no_of_paths[i][j] = (no_of_paths[i - 1][j] + no_of_paths[i][j - 1]) % MOD;
            }
        }
    }

    printf("%lld", no_of_paths[height][width]);
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    int t,a; cin>>t>>a;
    double tmp=1000000000;
    int ans = 0;
    rep(i, n){
        int h; cin>>h;
        double d = t-h*0.006;
        if(abs(tmp-a) > abs(d-a)){
            tmp = d;
            ans = i;
        }
    }
    cout<<ans+1<<endl;
    return 0;
}

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

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

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

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

void solve()
{
    int n;
    ll k;
    cin >> n >> k;
    vl v(n), a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    int i = 0, nxt = 0;
    while (i < 2 * n)
    {
        a[v[nxt] - 1]++;
        nxt = v[nxt] - 1;
        i++;
    }
    set<int> s;
    int cnt = 0;
    for (int j = 0; j < n; j++)
    {
        if (a[j] > 1)
        {
            s.insert(j);
            cnt++;
        }
    }
    i = 0;
    nxt = 0;
    vi u;
    ll stage = -1;
    while (i < n)
    {
        if (s.count(nxt))
        {
            u.pb(nxt);
            if (stage == -1)
            {
                stage = (ll)i;
            }
        }
        nxt = v[nxt] - 1;
        i++;
    }
    int len = sz(u);
    if(k<stage) {
        nxt=0,i=0;
        while (i < k)
        {
            nxt = v[nxt] - 1;
            i++;
        }
        cout<<nxt+1;
        return;
    }
    k -= stage;
    ll pos = k % cnt;
    cout << u[pos] + 1;
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

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

#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pii pair<int,pi>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int I_LIMIT = 999999999;
ll L_LIMIT = 999999999999999999;
ll mod = 1e9+7;

vector <int> v[200005];

int dfs(int node, bool visited[])
{
    visited[node]=true;
    int ans=0;
    for(auto x:v[node])
    {
        if(!visited[x])
            ans += dfs(x,visited);
    }
    return ans+1;
}

void solve()
{
    int i,maxm=0,a,b;
    int n,m;
    cin>>n>>m;
    for(i=0;i<=n;i++)
        v[i].clear();
    bool visited[n+1];
    for(i=0;i<=n;i++)
        visited[i]=false;

    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }

    for(i=1;i<=n;i++)
    {
        if(!visited[i])
            maxm = max(maxm,dfs(i,visited));
    }

    cout<<maxm<<"\n";
}
int main()
{
    IOS;
    solve();
}


Measured memory_bytes: 24120
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            string s;
            cin>>s;
            ll n=s.length(),i,j,ans=0,pre=0;
            for(i=0;i+2<n;++i)
            {
                if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
                {
                    //cout<<i<<" "<<pre<<endl;
                    ans=ans+1+pre;
                    s[i+2]='A';
                    i=i+1;
                }
                else if(s[i]=='A')
                    ++pre;
                else
                    pre=0;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 720
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N;
    cin >> N;
    string *s;
    s = new string[N];
    for (int i = 0; i < N; i++)
    {
        cin >> s[i];
    }
    map<string, int> x;
    for (int i = 0; i < N; i++)
    {
        x[s[i]]++;
    }
    int cnt = 0;
    for (map<string, int>::iterator y = x.begin(); y != x.end(); ++y)
    {
        if (x[y->first] > 0)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

int main() {
  int D, G;
  cin >> D >> G;

  vector<int> p(D);
  vector<int> c(D);
  for (int i = 0; i < D; i++) {
    cin >> p.at(i) >> c.at(i);
  }

  int ans = 1e9;
  for (int bit = 0; bit < (1<<D); bit++) {
    int C = 0, num = 0, rest_max = -1;
    for (int i = 0; i < D; i++) {
      if (bit & (1<<i)) {
        C += 100*(i+1)*p.at(i) + c.at(i);
        num += p.at(i);
      } else {
        rest_max = i;
      }
    }
    if (C < G) {
      if ((G - C + 100*(rest_max+1) - 1) / (100*(rest_max+1)) >= p.at(rest_max)) {
        continue;
      } else {
        num += (G - C + 100*(rest_max+1) - 1) / (100*(rest_max+1));
      }
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl  "\n"
#define ll long long
#define PI acos(-1.0)
#define test cout<<"\n****\n"
#define precise fixed(cout);cout<<setprecision(12)
#define fast  ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using  namespace  std;

set<ll> vec;
int main(){

    fast;
    ll n;
    cin>>n;

    for(int i=0;i<n;i++){
        ll temp;
        cin>>temp;
        vec.insert(temp);
    }
    
    if(vec.size()==n){
        cout<<"YES";
    } else{
        cout<<"NO";
    }
    
    return 0;
}


Measured memory_bytes: 12916
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[5];
    rep(i, 5) cin >> A[i];
    sort(A, A + 5);
    cout << (A[0] + N - 1) / A[0] + 4 << endl;

    return 0;
}


Measured memory_bytes: 256
/*ex4_1
  Sweet_Sweet_Soul*/

#include <stdio.h>
#include <math.h>
int main(void) {
    float wood,range;
    scanf("%f",&wood);
    scanf("%f",&range);
    range=range*2+1;/*観測範囲*/
    int ans=ceil(wood/range);/*本数<範囲*人数*/
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=2e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
ll a[N];
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  ll n,ans=1000,val=1000;
  cin>>n;
  for(int i=1;i<=n;i++) cin>>a[i];
  for(int l=1;l<n;)
  {
    int r=l;
    for(int i=l+1;i<=n;i++)
    {
      if(a[i]>=a[i-1])
      {
        r=i;
      }
      else
      {
        break;
      }
    }
    if(r==l) l++;
    else
    {
      val=(val/a[l])*a[r]+(val%a[l]);
      ans=max(ans,val);
      l=r+1;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/env python
import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (
    acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,
    sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits


def inp():
    return(int(input()))


def inlist():
    return(list(map(int, input().split())))


def instr():
    s = input()
    return(list(s[:len(s)]))


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

# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')


def main():
    n = inp()
    a = input()
    b = sorted(a)
    c = 0
    for i in range(n):
        if b[i] == "R" and a[i] != "R":
            c += 1
    print(c)


# region fastio
BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")

# endregion


if __name__ == "__main__":
    main()


Measured memory_bytes: 13600
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let s = get!(String).chars().collect::<Vec<_>>();

    if n % 2 != 0 {
        println!("No");
        return;
    }

    for i in 0..n/2 {
        if s[i] != s[i+n/2] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

int main(){
    int N, L;
    cin >> N >> L;
    string s;
    vector<string> box(N);
    for(int i = 0; i < N; i++){
        cin >> box.at(i);
    }

    sort(box.begin(), box.end());
    for(int i = 0; i < N; i++){
        s += box.at(i);
    }

    cout << s << endl;
}

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

namespace abc146
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var connect = new Dictionary<int, List<int>>();

            var keys = new Tuple<int, int>[n - 1];
            for (int i = 0; i < n - 1; i++)
            {
                var ab = Console.ReadLine().Split();
                var a = int.Parse(ab[0]);
                var b = int.Parse(ab[1]);

                if (!connect.ContainsKey(a)) connect[a] = new List<int>();

                connect[a].Add(b);
                keys[i] = Tuple.Create(a, b);
            }

            var ans = new Dictionary<Tuple<int, int>, int>();
            dfs(connect, ans, 1, 0);

            var max = int.MinValue;
            foreach (var item in connect)
            {
                if (item.Key == 1)
                {
                    max = Math.Max(max, item.Value.Count - 1);
                }
                else
                {
                    max = Math.Max(max, item.Value.Count);
                }
            }

            Console.WriteLine(max + 1);

            foreach (var item in keys)
                Console.WriteLine(ans[item]);
        }

        static void dfs(Dictionary<int, List<int>> connect, Dictionary<Tuple<int, int>, int> ans, int p, int color)
        {
            if (!connect.ContainsKey(p)) return;

            var n = 1;
            foreach (var q in connect[p])
            {
                if (n == color) n++;
                ans[Tuple.Create(p, q)] = n;
                dfs(connect, ans, q, n);
                n++;
            }
        }
    }
}


Measured memory_bytes: 41284
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <queue>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define umap unordered_map
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

void solve() {

}

int char_count(char c, string s) {
  int cnt = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == c)
      cnt++;
  }
  return cnt;
}

int main() {
  int n;
  cin >> n;
  string st[n];
  int cnt[n]['z' - 'a' + 1];
  for (int i = 0; i < n; ++i) {
    cin >> st[i];
  }
  //a-zのカウントを取る
  //cnt[]['a']の最小値+cnt[]['b']+....
  for (int i = 0; i < n; ++i) {
    for (char j = 'a'; j <= 'z'; ++j) {
      cnt[i][j - 'a'] = char_count(j, st[i]);
    }
  }
  for (int i = 0; i < 'z' - 'a' + 1; ++i) {
    int mini = 1000;
    for (int j = 0; j < n; ++j) {
      mini = min(mini, cnt[j][i]);
    }
    if (mini > 0) {
      for (int k = 0; k < mini; ++k) {
        cout << (char) (i + 'a');
      }
    }
  }
  cout << endl;
}



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

namespace atc
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int q = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToList()[1];
            char[] str = Console.ReadLine().ToCharArray();
            List<List<int>> queries = new List<List<int>>();
            for (int i=0; i<q; i++)
            {
                queries.Add(Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToList());
            }
            List<int> sums = new List<int>();
            int tmp = 0;
            sums.Add(0);
            for (int i=1; i<str.Length; i++)
            {
                if (str[i-1] == 'A' && str[i] == 'C')
                {
                    sums.Add(tmp + 1);
                    tmp++;
                }
                else
                {
                    sums.Add(tmp);
                }
            }
            foreach (List<int> qu in queries)
            {
                int sum = sums[qu[1] - 1] - sums[qu[0] - 1];
                Console.WriteLine(sum);
            }
        }
    }
}


Measured memory_bytes: 30204
//
//  main.cpp
//  ABC164
//
//  Created by 安藤光希 on 2020/04/26.
//  Copyright © 2020 安藤光希. All rights reserved.
//

#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#define rep(i, n) for (int i = 0; i<n; i++)
using namespace std;
// https://atcoder.jp/contests/abc163/tasks/abc163_c
typedef long long ll;


int main() {
    ll S, W;
    cin >> S >> W;
    
    if (S > W) cout << "safe" << endl;
    else cout << "unsafe" << endl;

}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
#define all(x) (x).begin(),(x).end()

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

  int N; cin >> N;
  vector<ll> a(N), b(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 0; i < N; i++) cin >> b[i];

  auto digit = [](ll n) {
    int res = 0;
    for (; n; n >>= 1) res++;
    return res;
  };

  ll moa = max_element(all(a)) - a.begin();
  ll mob = max_element(all(b)) - b.begin();
  int m = max(digit(a[moa]), digit(b[mob])) + 1;

  auto pow = [](ll a, int n) {
    ll res = 1;
    for (int i = 0; i < n; i++) res *= a;
    return res;
  };

  vector<ll> c(m);
  ll d = pow(2, m+1);
  for (int i = m; i >= 0; i--) {
    for (int j = 0; j < N; j++) {
      a[j] %= d;
      b[j] %= d;
    }
    sort(all(b));
    for (int j = 0; j < N; j++) {
      c[i] += lower_bound(all(b), d-a[j])
            - lower_bound(all(b), max(0LL, (d>>1)-a[j]));
      c[i] += b.end()
            - lower_bound(all(b), min(d, d+(d>>1)-a[j]));
    }
    d >>= 1;
  }

  ll ans = 0;
  d = 1;
  for (int i = 0; i < m; i++) {
    if (c[i] & 1) ans += d;
    d <<= 1;
  }
  cout << ans << "\n";
}

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

bool find_path(vector<vector<int>> &E, int s, int g, int p, vector<int> &path) {
  if (s == g) {
    path.push_back(s);
    return true;
  }

  for (int t : E[s]) {
    if (t == p) continue;

    if (find_path(E, t, g, s, path)) {
      path.push_back(s);
      return true;
    }
  }

  return false;
}

int dfs(vector<vector<int>> &E, int v, int p, int d) {
  int ret = d;

  for (int u : E[v]) {
    if (u == p) continue;

    ret = max(ret, dfs(E, u, v, d + 1));
  }

  return ret;
}

int main(void) {
  int N, U, V;
  cin >> N >> U >> V, U--, V--;
  vector<vector<int>> E(N);
  for (int i = 0; i < N - 1; i++) {
    int A, B;
    cin >> A >> B, A--, B--;
    E[A].push_back(B);
    E[B].push_back(A);
  }

  vector<int> path;
  find_path(E, V, U, -1, path);

  int pd = path.size() - 1;
  int d = (pd - 1) / 2;
  int r = path[d];
  int z = path[d + 1];

  int dest = dfs(E, r, z, 0);

  cout << dest + d + (pd % 2 == 0 ? 1 : 0) << endl;
}

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

  const int MOD = 1000000007;
  const double PI = acos(-1); 

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

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

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



// // 二分探索(最小値を出す問題は疑う)
// bool C(ll x){
//     ll res = 0;
//     for(int i = 0; i < N; ++i){
// 		res += max(0ll, A[i]-x/F[i]);
//     }
//     return res <= K;
// }

//   ll binary_search(ll ok, ll ng){
//     while(abs(ok - ng) > 1){
//       ll mid = (ok + ng) / 2;
//       if(C(mid)) ok = mid;
//       else ng = mid;
//     }
//     return ok;
//   }

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

vector<int>sum(26, 0);
REP(i, N){
  sum.at(S.at(i) - 'a')++;
}

ll ans = 1;

REP(i, 26){
  ans *= sum.at(i) + 1;
  ans %= MOD;
}

print(ans % MOD - 1);
}

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

using namespace std;

int main(void){
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    sort(S.begin(), S.end());
    for(int i = 0; i < N; i++) cout << S[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define   pb              push_back
#define   REP(i,n)        for(int i=1;i<=n;i++)
#define   FOR(i,a,b)      for(int i=a;i<=b;i++)
#define   all(v)          v.begin(),v.end()
#define   F               first
#define   S               second
#define   vl              vector<LL>
#define   itr             ::iterator it
#define   lb              lower_bound
#define   ub              upper_bound
#define   LL              long long
#define   ULL             unsigned long long
#define   ret             return 
LL n,i,j,ans = 0,m,c;
LL b[1000] ; 
int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m>>c ; 
    REP(i,m) cin>>b[i] ; 
    REP(i,n)
    {  LL x ,k = 1,p = 0 ; 
        for(int j=1;j<=m;j++)
       {  cin>>x ; 
          p += x * b[k++] ; 
       }
       if(p+c>0) ans++ ; 


    }
    cout<<ans ; 
} 
//Check for 0,1 and other corner cases.

Measured memory_bytes: 256
use std::io::BufRead;
use std::process::exit;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    solve_b();
}

fn solve_b() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let a = input!(r, usize);
    let b = input!(r, usize);
    let c = input!(r, usize);
    let d = input!(r, usize);
    let e = input!(r, usize);
    let mut menus: Vec<usize> = vec![a, b, c, d, e];
    menus.sort_by_key(|k| k % 10);
    menus.reverse();
    let mut time = 0;
    for m in menus {
        if m % 10 == 0 {
            time += m;
            continue;
        }
        if time % 10 == 0 {
            time += m;
        } else {
            let tmp = 10 - (time % 10);
            time += tmp + m;
        }
    }
    println!("{}", time);
}


Measured memory_bytes: 4352
#include<cstdio>
int n,m,cnta,cntw;char s[2];
int ac[233333],tries[233333];
int main(){
    scanf("%d%d",&n,&m);
    while(m--){
        int k;scanf("%d%s",&k,s);
        if(!ac[k]){
            if(s[0]=='W')tries[k]++;
            else cnta++,ac[k]=1;
        }
    }
    for(int i=1;i<=n;i++)
        if(ac[i])cntw+=tries[i];
    printf("%d %d\n",cnta,cntw);
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define int long long

main()
{
    int k,ans=0;
    cin>>k;
    for(int i=1; i<=k; i++)
    {
        for(int j=1; j<=k; j++)
        {
            for(int m=1; m<=k; m++)
            {
                ans+=__gcd(i,__gcd(j,m));
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3576
import           Control.Monad
import           Data.Array

main = do
  _ <- getLine
  xs <- map read . words <$> getLine
  solve xs

solve xs =
  let
    xs_ = (0:xs ++ [0])

    f [_]      = 0
    f (x:y:xs) = abs (x-y) + f (y:xs)

    total =
      f xs_

    xs' =
      listArray (0, length xs + 1) xs_
  in
    forM_ [1..(length xs)] $ \ i ->
      let
        a = xs'!(i-1)
        b = xs'!i
        c = xs'!(i+1)
      in
        print $ total + abs (a - c) - (abs (a - b) + abs (b - c))


Measured memory_bytes: 45308
N, X = map(int, input().split())
L = list(map(int, input().split()))
S = [0]
c = 0

i = 0
while i <= N-1:
  S.append(S[i]+L[i])
  i += 1
  
j = 0
while j <= N:
  if S[j]<= X:
    c += 1
    j += 1
  
  else:
    j += 1

    
print(c)

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

using namespace std;
int main(){
	int N;
	long long K;
	cin >> N >> K;
	long long A[N], B[N];
	for (int i=0; i<N; i++) {
		cin >> A[i] >> B[i];
	}

	int Kbits[31] = {0};
	int j = 0;
	for (long long i = K; i > 0; i >>= 1, j++) {
		if (i%2 == 1) Kbits[j] = 1;
		//cout << Kbits[j];
	}
	//cout << endl;
	// now j is maxbit-1
	long long max = 0;
	vector<int> allow;
	for (int i = j-1; i >= 0; i--) {
		//cout << Kbits[i] << endl;
		long long val = 0;
		if (Kbits[i] == 0) continue;
		// maximize with Kbits[allow num] == 1 or Kbits[i:] == 0
		// buy all items which is Abits[i:] == 0
		for (int num = 0; num < N; num++) {
			long long item = A[num];
			/*if (item >> i == 0) {
				val += B[num];
				continue;
			}*/
			// allow bit
			vector<int>::iterator ite = allow.begin();
			while (ite != allow.end()) {
				item ^= (item&(1<<*ite));
				ite++;
			}
		//	cout << item << endl;
			if (item >> i == 0) {
				val += B[num];
				continue;
			}
		}
		//cout << "." << endl;
		if (max < val) max = val;
		allow.push_back(i);
	}
	for (int i=0; i<1; i++) {
		long long val = 0;
		// maximize with Kbits[allow num] == 1 or Kbits[i:] == 0
		// buy all items which is Abits[i:] == 0
		for (int num = 0; num < N; num++) {
			long long item = A[num];
			/*if (item >> i == 0) {
				val += B[num];
				continue;
			}*/
			// allow bit
			vector<int>::iterator ite = allow.begin();
			while (ite != allow.end()) {
				item ^= (item&(1<<*ite));
				ite++;
			}
		//	cout << item << endl;
			if (item >> i == 0) {
				val += B[num];
				continue;
			}
		}
		//cout << "." << endl;
		if (max < val) max = val;
	}
	cout << max << endl;
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    string s;

    cin >> s;

    s.replace(0, 4, "2018");

    cout << s << endl;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define to v[x]
using namespace std;
const int inf=0x3f3f3f3f,N=1e6;
int n,du[N],nxt[N],fir[N],cnt,ans[N];
vector<int>v[N],r[N];
void dfs(int x,int fo,int no)
{
	int tot=0;
	for(int i=0;i<v[x].size();i++)
	{
		if(to[i]==fo)continue;++tot;
		if(tot==no)tot++;ans[r[x][i]]=tot;
		dfs(to[i],x,tot);
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		v[x].push_back(y),v[y].push_back(x);du[x]++;du[y]++;r[x].push_back(i),r[y].push_back(i);
	}int wh=0;
	for(int i=1;i<=n;i++)if(du[i]>du[wh])wh=i;
	dfs(wh,0,0);
	cout<<du[wh]<<endl;
	for(int i=1;i<n;i++)printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 59776
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, L: int):
    s = L * N + sum(list(range(N + 1))) - N
    mn = float('inf')
    ret = float('inf')
    for i in range(1, N + 1):
        t = L + i - 1
        tmp = abs(s - (s - t))
        if tmp < mn:
            ret = s - t
            mn = tmp
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    solve(N, L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
using namespace std;
int k,n,f[1000000],x,y;
signed main(){
//	freopen("D://1.txt","w",stdout);
	cin>>k>>n;if (k&1){
		memset(f,10,sizeof(f));
		f[0]=1;for (int i=0;f[i]<100000000&&i<200000;i++)f[i+1]=f[i]*k+1;
		x=n;y=0;while (1){
			if (x==0)return 0;
			int xx=k/2+1,yy=y;
			while ((f[x-1]-yy)/2>f[x-1]){
				yy+=f[x-1]*2;
				xx++;
			}yy++;
			while (yy>=f[x-1]){
				yy-=f[x-1]*2;
				xx--;
			}if (f[x-1]==-yy){printf("%d",xx+1);return 0;}
			if (xx==0)return 0;
			printf("%d ",xx);x--;y=yy;
		}
	}else {
		printf("%d",k/2);for (int i=1;i<n;i++)printf(" %d",k);
	}
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
#define m 10000000
int main(){
  int s; cin >>s;
  int a[m];
  a[0]=s;
  for(int i=1;i<m;i++){
    if(a[i-1]%2==0) a[i]=a[i-1]/2;
    else a[i]=3*a[i-1]+1;
    for(int j=0;j<i;j++){
      if(a[j]==a[i]){
        cout << i+1 << endl;
        return 0;
      }
    }
  }
}
  
  

Measured memory_bytes: 256