akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

int solve() {
    auto s = readln.split.map!(to!int);
    int M = s[0];
    int N = s[1];
    if (M == 0) return -1;
    auto A = new int[](M);
    auto B = new int[](N);
    int a, b;
    while (a < M) {
        auto T = readln.split.map!(to!int);
        foreach (t; T) A[a++] = t;
    }
    while (b < N) {
        auto T = readln.split.map!(to!int);
        foreach (t; T) B[b++] = t;
    }

    
    auto source = M + N;
    auto sink = M + N + 1;
    auto ff = new FordFulkerson(M+N+2, source, sink);
    
    foreach (i; 0..M) ff.add_edge(source, i, 1);
    foreach (i; 0..N) ff.add_edge(i+M, sink, 1);
    
    foreach (i; 0..M)
        foreach (j; 0..N)
            if (gcd(A[i], B[j]) > 1)
                ff.add_edge(i, j+M, 1);

    return ff.run;
}

void main() {
    while (true) {
        auto ans = solve;
        if (ans == -1) break;
        ans.writeln;
    }
}

class FordFulkerson {
    int N, source, sink;
    int[][] adj;
    int[][] flow;
    bool[] used;

    this(int n, int s, int t) {
        N = n;
        source = s;
        sink = t;
        assert (s >= 0 && s < N && t >= 0 && t < N);
        adj = new int[][](N);
        flow = new int[][](N, N);
        used = new bool[](N);
    }

    void add_edge(int from, int to, int cap) {
        adj[from] ~= to;
        adj[to] ~= from;
        flow[from][to] = cap;
    }

    int dfs(int v, int min_cap) {
        if (v == sink)
            return min_cap;
        if (used[v])
            return 0;
        used[v] = true;
        foreach (to; adj[v]) {
            if (!used[to] && flow[v][to] > 0) {
                auto bottleneck = dfs(to, min(min_cap, flow[v][to]));
                if (bottleneck == 0) continue;
                flow[v][to] -= bottleneck;
                flow[to][v] += bottleneck;
                return bottleneck;
            }
        }
        return 0;
    }

    int run() {
        int ret = 0;
        while (true) {
            foreach (i; 0..N) used[i] = false;
            int f = dfs(source, int.max);
            if (f > 0)
                ret += f;
            else
                return ret;
        }
    }
}

Measured memory_bytes: 30776
# coding: utf-8

x, y, z, k = [int(i) for i in input().split()]

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ab = [ai + bi for ai in a for bi in b]
ab.sort(reverse=True)
ab = ab[:k]

abc = [abi + ci for abi in ab for ci in c]
abc.sort(reverse = True)

for i in range(len(abc)):
  if i < k:
    print(abc[i])
  else:
    break


Measured memory_bytes: 134300
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
	bool is_visited;
} edge;
int main( void ){
	int A,B,C; cin >> A>>B>>C;
	int cnt = 0;
	while(true){
		if (A%2 == 1 || B%2 == 1 || C % 2 == 1)
			break;
		if (A==B && B ==C){
			cout << "-1\n";
			return 0;
		}
		int temp_a = A, temp_b = B;
		A = (temp_b+C)/2;
		B = (temp_a+C)/2;
		C = (temp_a+temp_b)/2;
		cnt++;
	}
	cout << cnt << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
String res="";
     String[] nyu=sc.nextLine().split("");
res+=nyu[0];
nyu=sc.nextLine().split("");
res+=nyu[1];
nyu=sc.nextLine().split("");
res+=nyu[2];

  //   String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu[3]);


//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

System.out.println(res);





	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
    
        while(true){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a==0&&b==0) break;
            for(int i=0;i<a;i++){
                for(int j=0;j<b;j++){
                System.out.printf("#");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 64200
#include<stdio.h>

int main(){
   int i,j,x,A[100],N,count =0,flag = 1; // 逆の隣接要素が存在する
   
   scanf("%d",&N);
   
   for(i = 0 ; i < N ; i++){
       scanf("%d",&A[i]);
   }
   
   while(flag){
     flag = 0;
     for (j=N-1 ; j >= 1 ; j--){
       if(A[j] < A[j-1]){
           x = A[j];
           A[j] = A[j-1];
           A[j-1] = x;
         flag = 1;
         count++;
       }
     }
   }
    for(i = 0 ; i < N ; i++){
       printf("%d",A[i]);
       if(i+1!=N){
           printf(" ");
       }
   }
   printf("\n%d\n",count);
}



Measured memory_bytes: 2124
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

const int MOD = 1e9+7;
class mint {
    ll x;
public:
    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 {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator *(const mint &a) const {
        mint res(*this);
        return res *= 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 {
        mint res(*this);
        return res /= a;
    }

    friend ostream &operator<<(ostream& os, const mint &m) {
        os << m.x;
        return os;
    }
};


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

    string K;
    ll D;
    cin >> K >> D;

    mint dp[K.size()+1][D][2];
    dp[0][0][0] = mint(1);
    Rep (i, K.size()) {
        ll d = K[i] - '0';
        Rep (j, D) {
            dp[i+1][(j+d)%D][0] += dp[i][j][0];
            Rep (k, d) {
                dp[i+1][(j+k)%D][1] += dp[i][j][0];
            }
            Rep (k, 10) {
                dp[i+1][(j+k)%D][1] += dp[i][j][1];
            }
        }
    }

    // Rep (i, K.size()+1) {
    //     Rep (j, D) {
    //         cout << dp[i][j][0] << " \n"[j==D-1];
    //     }
    // }

    // Rep (i, K.size()+1) {
    //     Rep (j, D) {
    //         cout << dp[i][j][1] << " \n"[j==D-1];
    //     }
    // }

    cout << dp[K.size()][0][0] + dp[K.size()][0][1] + mint(-1) << "\n";

}

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

using namespace std;

void a(){
    int S,W;
    cin >> S >> W;
    if(W<S){
        cout << "safe"; 
    }
    else{
        cout << "unsafe";
    }
}

void b(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int T = a/d;
    if (a%d!=0)T++;
    int A = c/b;
    if (c%b!=0)A++;
    if(A>T)
    {
        cout << "No";
    }
    else cout << "Yes";
}
int main(void){
    //a();
    b();
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

const int mod = 1e9 + 7;

typedef long long ll;

using namespace std;

int n, m;
vec<int> t[200005];

bool dfs(int c, int mv, int p) {
  if (c == n && mv == 2)
    return true;
  if (mv > 2) return false;
  for (auto i : t[c]) {
    if (i == p) continue;
    if (dfs(i, mv + 1, c))
      return true;
  }
  return false;
}

string solve() {
  if (dfs(1, 0, -1))
    return "POSSIBLE";
  else
    return "IMPOSSIBLE";
}

int main() {
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    t[a].pb(b);
    t[b].pb(a);
  }
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 12016
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <list>
#include <set>
#include <string>
#include <queue>
using namespace std;

struct p {
	int x, y;
};
int dx[4] = { 1 , 0, -1,0 };
int dy[4] = { 0,1,0,-1 };

#define INF 99999999
int main() {
	int H, W;
	cin >> H >> W;
	int b_n = 0;
	vector<vector<bool> > map(H, vector<bool>(W, false));
	for (int i = 0; i < H; i++) {
		string temp;
		cin >> temp;
		for (int j = 0; j < W; j++) {
			if (temp[j] == '#')map[i][j] = true;
			else map[i][j] = false;
			if (map[i][j] == true)b_n++;
		}
	}
	queue<p> que;
	vector<vector<int> > dist(H, vector<int>(W, INF));
	dist[0][0] = 1;
	que.push({ 0,0 });
	while (que.size()) {
		p now = que.front(); que.pop();
		if (now.x == W - 1 && now.y == H - 1) break;
		for (int i = 0; i < 4; i++) {
			int nx = now.x + dx[i], ny = now.y + dy[i];
			if (0 <= nx && 0 <= ny && nx < W && ny < H && map[ny][nx] == false && dist[ny][nx] == INF) {
				que.push({ nx,ny });
				dist[ny][nx] = dist[now.y][now.x] + 1;
			}
		}
	}
	if (dist[H-1][W-1] != INF) {
		cout << H*W - b_n - dist[H-1][W-1] << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main()
{
    long long int n,m,p,q,x,arr[105],sum,s;

    while(scanf("%lld",&n)==1)
    {
        sum=0;

        for(int i=1; i<=n; i++)
        {
            scanf("%lld",&x);

            sum+=x;

            arr[i]=x;
        }

        scanf("%lld",&m);

        while(m--)
        {
            scanf("%lld %lld",&p,&q);

            s=sum-arr[p];

            printf("%lld\n",s+q);
        }
    }

    return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
  if (A + B < C + D){
    cout << "Right" << endl;
  }
  else if(A + B == C + D){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Left" << endl;
}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
   char ch;
   scanf("%c",&ch);
   if(ch>='A'&&ch<='Z')
   printf("A\n");
   else
   printf("a\n");
}

Measured memory_bytes: 3692
#include <iostream>
#include <string>

struct node
{
  int key;
  node *parent=nullptr, *left=nullptr, *right=nullptr;
};

using tree = node*;

void preOrder(tree t)
{
  std::cout << " " << t->key;
  if (t->left != nullptr)
    preOrder(t->left);
  if (t->right != nullptr)
    preOrder(t->right);
}

void inOrder(tree t)
{
  if (t->left != nullptr)
    inOrder(t->left);
  std::cout << " " << t->key;
  if (t->right != nullptr)
    inOrder(t->right);
}

void insert(tree &t, int key)
{
  node *new_node = new node;
  new_node->key = key;
  if (t == nullptr)
    {
      t = new_node;
      //std::cout << "New: " << t->key << std::endl;
    }
  else
    {
      tree cur_node = t;
      auto parent = cur_node->parent;
      while (cur_node != nullptr)
        {
          parent = cur_node;
          if (key < cur_node->key)
            cur_node = cur_node->left;
          else
            cur_node = cur_node->right;
        }
      if (key < parent->key)
        {
          parent->left = new_node;
        }
      else
        {
          parent->right = new_node;
        }
      new_node->parent = parent;
    }
}

tree find(tree t, int key)
{
  tree cur_node = t;
  while (cur_node != nullptr)
    {
      if (key == cur_node->key)
        return cur_node;
      else if (key < cur_node->key)
        cur_node = cur_node->left;
      else
        cur_node = cur_node->right;
    }
  return nullptr;
}

tree getSuccessor(tree t)
{
  tree node = t->right;

  while (node->left != nullptr)
    {
      node = node->left;
    }

  return node;
}

void del(tree &t, int key)
{
  auto key_node = find(t, key);
  if (key_node == nullptr) return;

  tree del_node = nullptr;
  if (key_node->left != nullptr && key_node->right != nullptr)
    {
      del_node = getSuccessor(key_node);
      key_node->key = del_node->key;
    }
  else
    del_node = key_node;

  auto parent_node = del_node->parent;
  tree child_node = nullptr;
  if (del_node->left != nullptr)
    child_node = del_node->left;
  else
    child_node = del_node->right;

  if (parent_node != nullptr)
    {
      if (parent_node->left == del_node)
        parent_node->left = child_node;
      else
        parent_node->right = child_node;
    }

  if (child_node != nullptr)
    {
      child_node->parent = parent_node;
    }

  delete del_node;
}

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

  std::string order;
  tree root = nullptr;
  for (int i=0; i<n; ++i)
    {
      std::cin >> order;
      if (order == "insert")
        {
          int key;
          std::cin >> key;
          insert(root, key);
        }
      else if (order == "print")
        {
          inOrder(root);
          std::cout << std::endl;
          preOrder(root);
          std::cout << std::endl;
        }
      else if (order == "find")
        {
          int key;
          std::cin >> key;
          if (find(root, key) != nullptr)
            std::cout << "yes\n";
          else
            std::cout << "no\n";
        }
      else if (order == "delete")
        {
          int key;
          std::cin >> key;
          del(root, key);
        }
    }
}





Measured memory_bytes: 21868
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
 
 
using namespace std;
 
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
 
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}
#define int long long
#define left left228
#define right right228
#define prev prev228
#define mp make_pair
#define all(v) v.begin(), v.end()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define x first
#define y second



signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int res = (a & 1) * b * c;
    uin(res, (b & 1) * a * c);
    uin(res, (c & 1) * a * b);
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int main()
{
    string a;
    cin >> a;
    ll k;
    cin >> k;
    ll n = a.size();
    ll db = 0;
    ll sum = 1;
    ll i = 0;
    for(; i < n - 1; i++){
        if(a[i] != a[i + 1]) break;
    }
    ll fir = i + 1;
    for(; i < n - 1; i++){
        if(a[i] == a[i + 1]) sum++;
        else{
            db += sum / 2;
            sum = 1;
        }
    }
    if(n == 1) cout << k / 2 << endl;
    else if(fir == n) cout << n * k / 2 << endl;
    else if(a[0] != a[n - 1]) cout << (fir / 2) * k + db * k + (sum / 2) * k << endl;
    else cout << db * k + ((sum + fir) / 2) * (k - 1) + sum / 2 + fir / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<LL> a(3), b(3);
    rep(i, 3) cin >> a[i];
    rep(i, 3) cin >> b[i];

    LL ans = 0;
    for(int i=0; i*a[0] <= n; i++){
        for(int j=0; i*a[0]+j*a[1]<=n; j++){
            int k = n - (i*a[0]+j*a[1]);
            k /= a[2];
            ans = max({ans, (b[0]-a[0])*i+(b[1]-a[1])*j+(b[2]-a[2])*k+n, (b[0]-a[0])*i+(b[1]-a[1])*j+n});
        }
    }

    n = ans;
    // cout << ans << endl;
    if(ans > 5000){
        int l[2] = {0, 1};
        if(b[0] - a[0] > 0) l[0] = 2;
        else if(b[1] - a[1] > 0) l[1] = 2;
        for(int i=0; i*b[l[0]] <= n; i++){
            int k = n - (i*b[l[0]]);
            k /= b[l[1]];
            ans = max({ans, (a[l[0]]-b[l[0]])*i+(a[l[1]]-b[l[1]])*k+n, (a[l[0]]-b[l[0]])*i+n});
        }
    }else{
        for(LL i=0; i*b[0] <= n; i++){
            for(LL j=0; i*b[0]+j*b[1]<=n; j++){
                LL k = n - (i*b[0]+j*b[1]);
                k /= b[2];
                ans = max({ans, (a[0]-b[0])*i+(a[1]-b[1])*j+(a[2]-b[2])*k+n, (a[0]-b[0])*i+(a[1]-b[1])*j+n});
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#与えられた数列の中から、素数の個数を返す

length = int(input())
List = [int(input()) for i in range(length)]

def isPrime(n):
    if n == 2:
        return True
    elif n < 2 or n % 2 == 0:
        return False
    else:
        i = 3
        while i <= n**(1/2):
            if n % i == 0:
                return False
            else:
                i = i + 2
        else: return True

count = 0

for j in range(length):
    if isPrime(List[j]) is False:
        continue
    else:
        count = count + 1

print(count)


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

string  s;
int ans;

signed main() {
    cin >> s;
    rep(i,s.size()) if (s[i] == 'o') ans++;
    ans += 15-s.size();
    if (ans > 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int N = Integer.parseInt(stdin.next());
		double v[] = new double[N];

		for(int i=0;i<N;i++) {
			v[i] = Integer.parseInt(stdin.next());
		}
		for(int i=0;i<N-1;i++) {
			for(int j=i+1;j<N;j++) {
				if(v[i] > v[j]) {
					double max = v[i];
					v[i] = v[j];
					v[j] = max;
				}
			}
		}
		
		for(int i=0;i<N-1;i++) {
			v[i+1] = (v[i]+v[i+1])/2;
		}
		
		out.println(v[N-1]);

		out.flush();
	}
	
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	string s;
	ll n;
	cin >> n;
	cin >> s;
	V<int> wr(n);
	rep(i, n) {
		if (s[i] == 'R') {
			wr[i] = 0;
		}
		else {
			wr[i] = 1;
		}
	}
	int ii = 0, jj = n - 1;
	ll cnt = 0;
	while (1) {
		for (; ii < n; ++ii) {
			if (wr[ii] == 1) {
				break;
			}
		}
		for (; jj >= 0; --jj) {
			if (wr[jj] == 0) {
				break;
			}
		}
		if (ii < jj) {
			++cnt;
			++ii;
			--jj;
		}
		else {
			break;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 4452
A, B, C, D, E , F = map(int, input().split())

def makeSet(a, b):
  list = []
  for i in range(int(F / a + 2)):
    for j in range(int(F / b + 2)):
      tmp = i * a + j * b
      if tmp > F:
        break
      list.append(tmp)
  return set(list)

W = makeSet(A * 100, B * 100)
S = makeSet(C, D)

def isOK(a, b):
  return b * (100 + E) <= E * (a + b) and a + b <= F

ma = F
mb = 0

def chmax(a, b):
  if b * (ma + mb) >= mb * (a + b):
    return a, b
  return ma, mb

for w in W:
  for s in S:
    if isOK(w, s):
      ma, mb = chmax(w, s)

print(ma + mb, mb)

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

void ioinit() { ios::sync_with_stdio(0); cin.tie(0); }

int main() {
  ioinit();
  int n, k;
  string s;
  cin >> n >> k >> s;
  vector<int> c;
  {
    int t = 1, cnt = 0;
    for(int i = 0; i < n; i++) {
      if (s[i] - '0' != t) {
        c.push_back(cnt);
        cnt = 1; t = 1 - t;
      } else {
        cnt++;
      }
    }
    c.push_back(cnt);
    if (t == 0) c.push_back(0);
  }
  {
    int n = c.size();
    vector<int> sums(n + 1);
    partial_sum(c.begin(), c.end(), sums.begin() + 1);
    int rng = k * 2 + 1;
    int ans = 0;
    for (int i = 0; i < n; i += 2) {
      int l = i, r = min(n, i + rng);
      if(ans<sums[r] - sums[l]) ans = sums[r] - sums[l];
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lli long long
#define REP(i,a,b) for (int i = a; i < b; i++)
#define test int t; cin>>t; while(t--)
using namespace std;

int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   // test
    {
        int n;
        cin>>n;
        lli a[n];
        REP(i,0,n)
        cin>>a[i];
        lli max= a[0],c=0;
        REP(i,1,n)
        {
            if(a[i]<max)
            c+=(max-a[i]);
            else
            max=a[i];
        }
        cout<<c;
    }
    return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int MOD = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

long long fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理 from: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct mint {
    // Preparation: MOD is already defined.
    ll x;

    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(mint m) const {
        return pow(m.x);
    }

    mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        return u;
    }

    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) {
        return (*this) *= a.inv();
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    COMinit();
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    mint sum = 0;
    rep(i, n - k + 1) {
        mint diff = COM(n - i, k) - COM(n - i - 1, k);
        mint ma = (diff * a[i]);
        mint mi = (diff * a[n - i - 1]);
        sum += ma;
        sum -= mi;
    }
    out(sum.x);
    return 0;
}


Measured memory_bytes: 3328
a = str(input())
Big = ["Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y"]
small = ["z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y"]
if a in Big:
    print('A')
else:
    print('a')

Measured memory_bytes: 9036
n = int(input())
s = [int(input()) for _ in range(n)]
num = sum(s)
s.sort()
ss = []
for i in s:
	if i % 10 != 0:
		ss.append(i)
ss.sort()

if len(ss) == 0:
	mins = num
else:
	mins = ss[0]
if num % 10 != 0:
	print (num)
else:
	print (num - mins)

Measured memory_bytes: 3064
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    readint();
    auto ss = readints();

    bool[int] map;
    foreach (s; ss)
        map[s] = true;

    readint();
    auto ts = readints();

    int ans = 0;
    foreach (t; ts) {
        auto p = t in map;
        if (p != null)
            ans++;
    }
    writeln(ans);
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
    	var sc = new Scanner();
    	int n = sc.NextInt();
    	int[] a = new int[n];
    	for (int i = 0; i < n; i++)
    	    a[i] = sc.NextInt();
    	Array.Sort(a);
    	for (int i = 1; i < n; i++)
    	{
    		a[i] = Gcd(a[i - 1], a[i]);
    	}
    	
    	Console.WriteLine(a[n - 1]);
    }
    
    static int Gcd(int a, int b)
    {
    	if (a < b) return Gcd(b, a);
    	if (b == 0) return a;
    	return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }
        
    public long NextLong()
    {
    	CheckNext();
    	return long.Parse(buf[index++]);
    }
    
    public double NextDouble()
    {
    	CheckNext();
    	return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}

Measured memory_bytes: 18528
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int wh, bk;
char map[100][100];

// white .
// black #

int main(){
    cin >> wh >> bk;

    bool reverse = bk > wh;
    if (reverse) {
        int tmp = wh;
        wh = bk;
        bk = tmp;
    }

    // wh >= bk
    int common = min(wh, bk);
    wh -= common;
    bk -= common;

    int ck_h = 0;
    while (ck_h * ck_h / 2 < common) ck_h += 2;

    int cnt = 0;

    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            map[i][j] = ' ';
        }
    }
    int lasti;
    for (int i = ck_h - 1; i >= 0; i--) {
        for (int j = ck_h - 1; j >= 0; j -= 2) {
            if (i % 2 == 1) {
                map[i][j] = '#';
                map[i][j - 1] = '.';
            } else {
                map[i][j] = '.';
                map[i][j - 1] = '#';
            }
            cnt += 1;
            if (cnt == common) {
                if (j - 2 >= 0) {
                    map[i][j - 2] = i % 2 == 1 ? '#' : '.';
                }
                break;
            }
        }
        lasti = i;
        if (cnt == common) break;
    }

    for (int i = lasti; i >= 0; --i) {
        for (int j = 0; j < ck_h; ++j) {
            if (map[i][j] != ' ') continue;
            map[i][j] = map[i + 1][j];
        }
    }

    for (int i = ck_h; i < 100; ++i) {
        for (int j = 0; j < ck_h; ++j) {
            map[i][j] = map[i - 1][j];
        }
    }

    for (int j = ck_h; j < 100; ++j) {
        for (int i = 0; i < ck_h; ++i) {
            map[i][j] = map[i][j - 1];
        }
    }

    for (int i = ck_h; i < 100; ++i) {
        for (int j = ck_h; j < 100; ++j) {
            map[i][j] = '#';
        }
    }

    int i = ck_h;
    int j = ck_h;
    for (int cnt = 0; cnt < wh; ++cnt) {
        map[i][j] = '.';
        j += 2;
        if (j >= 100) {
            j = ck_h;
            i += 2;
        }
    }

    if (reverse) {
        for (int i = 0; i < 100; ++i) {
            for (int j = 0; j < 100; ++j) {
                map[i][j] = map[i][j] == '.' ? '#' : '.';
            }
        }
    }

    cout << "100 100" << endl;
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            cout << map[i][j];
        }
        cout << endl;
    }

}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int N, S;

  cin >> N;

  int t = N % 10;
  int s = N / 10;
  S = t;
  while(s != 0){
    int tmp = s;
    t = s % 10;
    S += t;
    s = tmp / 10;
  }
  
  if(N % S == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

	return 0;
}


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

int main()
{
	int a, b;
	string op;
	cin >> a >> op >> b;
	if (op=="+")
	{
		cout << a + b << endl;
	}
	else {
		cout << a - b << endl;
	}
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i=0;i<n;i++)
        cin >> a[i] >> b[i] >> c[i];
    vector<vector<int>> dp(n, vector<int>(3));
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][2], dp[i-1][0]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << "\n";
    return 0;
}



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

int main() {
  int a,b;
  cin >> a >> b;
  
  if ((a * b)%2 == 0) {
    cout << "Even" << endl;
  }
  if ((a * b)%2 == 1) { 
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, p = 1000000007;
int a[420], pa[420];
int b[420], pb[420];
long long f[420][420][420];
int t[420][420];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pa[a[i]] = i;
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
		pb[b[i]] = i;
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				if (pa[k] <= i || pb[k] <= j) {
					t[i][j]++;
				}
			}
		}
	}
	f[0][0][0] = 1;
	for (int k = 1; k <= n / 3; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				f[k][i][j] = (f[k][i - 1][j] + f[k][i][j - 1] + p - f[k][i - 1][j - 1]) % p;
				if (i < pa[b[j]] && j < pb[a[i]]) {
					f[k][i][j] = (f[k][i][j] + f[k - 1][i - 1][j - 1] * (3 * k - t[i][j])) % p;
				}
			}
		}
	}
	long long z = f[n / 3][n][n];
	for (int i = 1; i <= n; i++) {
		if (i % 3) {
			z = z * i % p;
		}
	}
	cout << z << endl;
	return 0;
}

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

int main() {
    int n, maxv, minv;
    cin >> n;
    int A[n];
    for (int i=0; i<n; i++) cin >> A[i];
    maxv = A[1] - A[0];
    minv = min(A[1], A[0]);
    for (int j=2; j<n; j++) {
        maxv = max(maxv, A[j] - minv);
        minv = min(minv, A[j]);
    }
    
    cout << maxv << endl;
    return 0;
}


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

int main() {
    int n, m, l;
    long long A[100][100], B[100][100], C[100][100] = {0};
    cin >> n >> m >> l;

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

    for (int i=0; i<m; i++)
        for (int j=0; j<l; j++)
            cin >> B[i][j];

    for (int i=0; i<n; i++)
        for (int j=0; j<l; j++)
            for (int k=0; k<m; k++)
                C[i][j] = C[i][j] + A[i][k]*B[k][j];

    for (int i=0; i<n; i++) {
        for (int j=0; j<l; j++)
            if (j == 0)
                cout << C[i][j];
            else
                cout << " " << C[i][j];
        cout << endl;
    }    

    return 0;
}


Measured memory_bytes: 3288
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int n, k, a[100000];
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	if (k > a[n - 1]) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if (a[i] == k) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	for (int i = 2; i <= a[0]; i++) {
		if (a[0] % i != 0)continue;
		for (int j = 0; j < n; j++) {
			if (a[j] % i != 0)
				break;
			else if (j == n - 1) {
				if (k%i != 0) {
					cout << "IMPOSSIBLE" << endl;
					return 0;
				}
			}
		}
		i += i % 2;
	}
	cout << "POSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 640
def f(a):
    cnt=1
    while a != 4:
        cnt +=1
        if a%2==0:
            a /=2
        else:
            a=3*a+1
    return cnt+3

s=int(input())

if s!=1 and s!=2 and s!=4:
    print(f(s))
else:
    print(4)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc101b
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var s = 0;
            for (var i = 0; i != input.Length; ++i)
                s += int.Parse((input[i].ToString()));
            var n = int.Parse(input);
            Console.WriteLine(n % s == 0 ? "Yes" : "No");
        }
    }
}


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



int main(){
  int n;
  cin >> n;
  vector<vector<int>> d(n, vector<int>(26, 0));
  rep(i, n){
    string s;
    cin >> s;
    rep(j, s.size()){
      int ind = s[j] - 'a';
      d[i][ind]++;
    }
  }
  
  string ans = "";
  rep(i, 26){
    int x = 100;
    char tmp = i + 'a';
    rep(j, n){
      x = min(x, d[j][i]);
    }
    rep(k, x){
      ans += tmp;
    }
  }
  cout << ans << endl;
}

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

n =int(input())
s = list(input())
a=[]
k = 0
for i in range(1,n,1):
    if s[i] == 'E':
        k = k+1
a.append(k)

for i in range(1,n,1):
    if s[i] == 'E' and s[i-1] == 'E':
        a.append(a[i-1]-1)
    elif s[i] == 'E' and s[i-1] == 'W':
        a.append(a[i-1])
    elif s[i] == 'W' and s[i-1] == 'E':
        a.append(a[i-1])
    else :
        a.append(a[i-1]+1)

print(min(a))


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  vll A(N);
  REP(i,N) IN(A[i]);

  vll dp(N+1, 0);
  dp[0] = 3;
  ll ans = 1;
  REP(i,N){
    ans *= dp[A[i]];
    ans %= MOD;
    dp[A[i]]--;
    dp[A[i]+1]++;
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, 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;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n - 1; i++) {
		ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
    ll cnt = 0;
    rep(i,m){
        cin >> a[i];
        cnt+=a[i];
    } 
    ll ans = ((n-cnt)>=0 ? (n-cnt) : -1);
    cout << ans << endl;
    return 0;


}

Measured memory_bytes: 3724
#include <iostream>
#include <cstdlib>

using namespace std;

int main(void) {
  int N, D, X;
  int *A;
  int res=0;
  int j=1;
  cin >> N;
  cin >> D >> X;

  A = (int *) malloc(sizeof(int) * N);
  for(int i=0;i < N;i++) {
    cin >> A[i];
  }

  for(int i=0;i < N;i++) {
    res++;
    while (j * A[i] + 1 <= D) {
      res++;
      j++;
    }
    j=1;
  }
  cout << res + X << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 26.11.2019 03:31:32       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> cnt(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    --a[i];
    ++cnt[a[i]];
  }
  sort(cnt.rbegin(), cnt.rend());
  long long ans = 0;
  for (int i = k; i < n; i++) {
    ans += cnt[i];
  }
  cout << ans << '\n';
  return 0;
}


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nkq = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nkq[0];
        var k = nkq[1];
        var q = nkq[2];
        var seqA = new int[q];
        for (int i = 0; i < seqA.Length; ++i)
        {
            seqA[i] = int.Parse(Console.ReadLine());
        }

        var ps = new int[n];
        for (int i = 0; i < ps.Length; ++i)
        {
            ps[i] = k - q;
        }
        for (int i = 0; i < seqA.Length; ++i)
        {
            ++ps[seqA[i] - 1];
        }

        Console.WriteLine(string.Join(Environment.NewLine, ps.Select(x => x > 0 ? "Yes" : "No")));
    }
}


Measured memory_bytes: 17888
def main():
    N = int(input())
    AB = [[int(i) for i in input().split()] for j in range(N)]
    AB.sort(key=lambda p: p[1])
    time = 0
    for a, b in AB:
        time += a
        if time > b:
            return print("No")
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 88024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    string s;
    cin >> s;
    int ans = 0;
    char now_char = s[0];
    rep(i, s.length()) {
        if ( s[i] != now_char ) {
            ++ans;
            now_char = s[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512