akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	set<char> set1;

	for (int i = 0; i < s.size(); i++)
		set1.insert(s[i]);

	bool flag = true;
	for (char i = 'a'; i <= 'z'; i++) {
		set<char>::iterator it = set1.find(i);
		if (it == set1.end())
		{
			cout << i;
			flag = false;
			break;
		}
	}
	if (flag)
		cout << "None";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    string s;
  	cin >> s;
  	stack<char>st;
  	int ans = 0;
  	for(int i = 0 ; i < s.size() ; i++)
    {
     	if(s[i] == '0')
        {
         	if(st.size() && st.top() == '1'){
              	ans += 2;
              	st.pop();
            }
          	else{
             	 st.push(s[i]);
            }
        }
      	else{
          	if(st.size() && st.top() == '0'){
              	ans += 2;
              	st.pop();
            }
          	else{
             	 st.push(s[i]);
            }
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#62 バドミントン

f = True
while True:
    for k in range(3):
        p = list(input())
        if p[0] == '0':
            f = False
            break
        
        a, b = 0, 0
        del p[0]
        for x in p:
            if x == 'A': a += 1
            else: b += 1
        if a > b: a += 1
        else: b += 1
        print(a, b)
    if not f: break


Measured memory_bytes: 5564
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  bool fst = true;
  if(s[0] == s[n-1]){
    if(n%2==0)fst = true;
    else fst = false;
  }else{
    if(n%2==1)fst = true;
    else fst = false;
  }
  cout << (fst ? "First" : "Second") << endl;
  return 0;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    A,B,C=mi()
    K=ii()

    def f(X,Y,Z,k):
        if X < Y < Z: return True
        elif k == 0: return False

        return f(X*2,Y,Z,k-1) or f(X,Y*2,Z,k-1) or f(X,Y,Z*2,k-1)
    
    ans = f(A,B,C,K)
    print("Yes" if ans else "No")




if __name__ == "__main__":
    main()

Measured memory_bytes: 9212
from scipy.misc import comb

def prime_factorize_dict(N):
    d = dict()
    for n in range(2, N + 1):
        while not n & 1:
            d[2] = d.get(2, 0) + 1
            n >>= 1
        f = 3
        while f * f <= n:
            if not n % f:
                d[f] = d.get(f, 0) + 1
                n //= f
            else:
                f += 2
        if n != 1:
            d[n] = d.get(n, 0) + 1
    return {k:v for k, v in d.items() if v > 1}

d = prime_factorize_dict(int(input()))

l = [0] * 5
for p, k in d.items():
    if k < 4:
        index = 0
    elif k < 14:
        index = 1
    elif k < 24:
        index = 2
    elif k < 74:
        index = 3
    else:
        index = 4
    l[index] += 1

# 2, 4, 4
total = l[0] * comb(sum(l[1:]), 2, exact=True) + comb(sum(l[1:]), 3, exact=True) * 3
# 4, 14
total += l[1] * sum(l[2:]) + comb(sum(l[2:]), 2, exact=True) * 2
# 2, 24
total += sum(l[0:3]) * sum(l[3:]) + comb(sum(l[3:]), 2, exact=True) * 2
# 74
total += l[4]

print(total)


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

public class hello
{
    public static void Main()
    {
        var list1 = new List<int>();
        var list2 = new List<int>();
        var list3 = new List<int>();
        var firstflag = 0;
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            list1.RemoveAll(x => x >= 0);
            list2.RemoveAll(x => x >= 0);
            list3.RemoveAll(x => x >= 0);
            var y1 = int.Parse(line[0]);
            var y2 = int.Parse(line[1]);
            if (y1 == 0 && y2 == 0) break;
            for (int i = y1; i <= y2; i++)
                if (i % 4 == 0) list1.Add(i);
            foreach (var x in list1)
                if (x % 100 == 0) list2.Add(x);
                else list3.Add(x);
            foreach (var x in list2)
                if (x % 400 == 0) list3.Add(x);
            list3.Sort();
                if (firstflag != 0) Console.WriteLine();
                else firstflag = 1;
            if (list3.Count() == 0)
                Console.WriteLine("NA");
            else
            {
                foreach (var x in list3)
                    Console.WriteLine(x);
            }
        }

    }
}

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

char m[2020][2010];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int leftLgtUp[2010][2010];
int rightLgtUp[2010][2010];
int upLgtUp[2010][2010];
int downLgtUp[2010][2010];

int main() {
    int H, W;
    cin >> H >> W;
    for (int ci = 0; ci < H; ci ++) {
        for (int ri = 0; ri < W; ri++ ) {
            cin >> m[ci][ri];
        }
    }

    for (int ci = 0; ci < H; ci ++) {
        leftLgtUp[ci][0] = m[ci][0] != '#' ? 1 : 0;
        for (int ri = 0; ri < W - 1; ri++) {
            leftLgtUp[ci][ri + 1] = m[ci][ri + 1] != '#' ? leftLgtUp[ci][ri] + 1 : 0;
        }
    }
    for (int ci = 0; ci < H; ci ++) {
        rightLgtUp[ci][W - 1] = m[ci][W - 1] != '#' ? 1 : 0; 
        for (int ri = W - 1; ri > 0; ri--) {
            rightLgtUp[ci][ri - 1] = m[ci][ri - 1] != '#' ? rightLgtUp[ci][ri] + 1 : 0;
        }
    }
    for (int ri = 0; ri < W; ri++) {
        downLgtUp[0][ri] = m[0][ri] != '#' ? 1 : 0;
        for (int ci = 0; ci < H - 1; ci++) {
            downLgtUp[ci + 1][ri] = m[ci + 1][ri] != '#' ? downLgtUp[ci][ri] + 1 : 0;
        }
    }
    for (int ri = 0; ri < W; ri++) {
        upLgtUp[H - 1][ri] = m[H - 1][ri] != '#' ? 1 : 0;
        for (int ci = H - 1; ci > 0; ci--) {
            upLgtUp[ci - 1][ri] = m[ci - 1][ri] != '#' ? upLgtUp[ci][ri] + 1 : 0;
        }
    }
    int max = 0;
    for (int ci = 0; ci < H; ci ++) {
        for (int ri = 0; ri < W; ri ++) {
            int lightUp = leftLgtUp[ci][ri] + rightLgtUp[ci][ri] + upLgtUp[ci][ri] + downLgtUp[ci][ri] - 3;
            if (lightUp > max) {
                max = lightUp;
            }
        }
    }
    cout << max << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) scanf("%d", &a[i]);

    int ggg = a[0];
    rep(i,n-1) ggg = __gcd(ggg, a[i+1]);
    if(ggg != 1){
        puts("not coprime");
        return 0;
    }

    //エラトステネスの篩
    const int P_MAX = 1000005;
    vi pmn(P_MAX);     //smallest prime number that can divide i(pmn[i] == i -> i is prime number)
    for(int i = 1; i < P_MAX; i++)
        if(i%2 == 0) pmn[i] = 2;
        else pmn[i] = i;
    for(int i = 3; i*i < P_MAX; i += 2){
        if(pmn[i] == i){
            for(int j = i*i; j < P_MAX; j += 2*i)
                if(pmn[j] == j) pmn[j] = i; 
        }
    }

    vi cnt(P_MAX,0);
    rep(i,n){
        while(a[i] != 1){
            int apmn = pmn[a[i]];
            if(cnt[apmn]){
                puts("setwise coprime");
                return 0;
            }
            cnt[apmn]++;
            while(a[i]%apmn == 0) a[i] /= apmn;
        }
    }
    puts("pairwise coprime");
}


Measured memory_bytes: 14888
package main

import (
	"fmt"
	"math"
)

func round(f float64) float64 {
	return math.Floor(f + .5)
}

func main() {
	var (
		N int
		sum int = 0
		result int = 0
	)
	fmt.Scan(&N)

	X := make([]int, N)
	for i, _ := range X {
		fmt.Scan(&X[i])
		sum += X[i]
	}

	avg := int(round(float64(sum)/float64(N)))

	for _, x := range X {
		result += (x-avg)*(x-avg)
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
long n,x,a[2000][2000],ans;
main()
{
	cin>>n>>x;
	for(int i=0;i<n;ans+=a[0][i++])cin>>a[0][i];
	for(int i=1;i<n;i++)
	{
		long s=i*x;
		for(int j=0;j<n;s+=a[i][++j%n])a[i][(j+1)%n]=min(a[i-1][(j+1)%n],a[i-1][j]);
		ans=min(ans,s);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 31488
/*
 © 2020-07-11 06:54:04 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli n ;cin >> n;
  lli res = 0;
  fore(i, 1, n + 1){
    lli x; cin >> x;
    if(i&1 and x&1) res++;
  }
  cout << res << ENDL;
  return 0;
}


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

int main() {
	int64_t n, a[5]{};
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		char c = s[0];
		if (c == 'M') {
			a[0]++;
		}
		if (c == 'A') {
			a[1]++;
		}
		if (c == 'R') {
			a[2]++;
		}
		if (c == 'C') {
			a[3]++;
		}
		if (c == 'H') {
			a[4]++;
		}
	}
	int64_t ans = 0;
	for (int i = (1 << 3) - 1; i < (1 << 5); ) {
		int64_t p = 1;
		for (int j = 0; j < 5; j++) {
			if ((i >> j) & 1) {
				p *= a[j];
			}
		}
		ans += p;
		int x = i & -i, y = i + x;
		i = ((i & ~y) / x >> 1) | y;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <pii> a(n);
    forn (i, 0, n)
        cin >> a[i].fs >> a[i].sc;
    multiset <int> s;
    forn (i, 0, n)
        s.insert(a[i].fs + a[i].sc);
    sort(rall(a));
    long long ans = 0;
    forn (i, 0, n - 1) {
        s.erase(s.find(a[i].fs + a[i].sc));
        chkmax(ans, a[i].fs + a[i].sc - *s.begin());
        /*for (int j : s)
            cerr << j << " ";
        cerr << "\n";
        cerr << a[i].fs + a[i].sc << "\n";
        cerr << *s.begin() << "\n";*/
    }

    cerr << ans << "  ";

    s.clear();
    forn (i, 0, n)
        s.insert(a[i].fs - a[i].sc);
    sort(rall(a));
    forn (i, 0, n - 1) {
        s.erase(s.find(a[i].fs - a[i].sc));
        chkmax(ans, a[i].fs - a[i].sc - *s.begin());
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 14284
# -*-coding:utf-8

import fileinput
import math

def main():

    for line in fileinput.input():
        a, b = map(int, line.strip().split())

        if (a < b):
            print('a < b')
        elif (a == b):
            print('a == b')
        else:
            print('a > b')

if __name__ == '__main__':
    main()

Measured memory_bytes: 6388
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;

	int n;
	cin >> n;

	for (int i = 0; i < (int) s.size(); i += n) {
		cout << s[i];
	}

	cout << "\n";

	return 0;

}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N = int(input())

a = [0 for i in range(100**2 * 6 + 2)]

for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            a[ x**2 + y**2 + z**2 + x*y + y*z + z*x ] += 1

for i in range(1,N+1):
    print(a[i])

Measured memory_bytes: 9624
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        PriorityQueue<Long> pq = new PriorityQueue<>(new MyComparator());
        for(int i=0;i<n;i++){
            pq.add(sc.nextLong());
        }
        for(int i=0;i<m;i++){
            long tmp = pq.poll();
            tmp = tmp/2;
            pq.add(tmp);
        }
        Long res = 0L;
        for(Long p : pq){
            res += p;
        }
        System.out.println(res);
    }
}

class MyComparator implements Comparator {

    public int compare(Object obj1, Object obj2) {

        long num1 = (long)obj1;
        long num2 = (long)obj2;

        if(num1 < num2) {
            return 1;
        } else if(num1 > num2) {
            return -1;
        } else{
            return 0;
        }
    }
}

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

int main(){
    int N, *D1, *D2;
    cin >> N;
    D1 = new int[N];
    D2 = new int[N];
    int count = 0;
    int count2 = 0;
    for (int i = 0; i < N; i++) {
        cin >> D1[i] >> D2[i];
        if (D1[i] == D2[i]) {
            count += 1;
        } else {
            count = 0;
        }
        if (count == 3) {
            count2 += 1;
        }
    }
    if (count2 > 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    delete[] D1;
    delete[] D2;
    return 0;
}

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

const int N = 2e5 + 10;

char s[N];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  int i = 0, ans = 0;
  while (i < n) {
    if (s[i] == s[i + 1]) {
      i++;
      ans++;
      if (i + 1 < n) {
        i += 2;
        ans++;
      } else {
        i++;
      }
    } else {
      i++;
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

class Card{
  public:
    char suit;
    int value;
};

typedef vector<Card> Cards;

void bubbleSort(const Cards in_cards, Cards &out_cards){
  int N = in_cards.size();
  assert(N==out_cards.size());
  out_cards = in_cards;

  for(int i=0; i<N; i++){
    for(int j=N-1; j>i; j--){
      if(out_cards[j].value < out_cards[j-1].value){
        swap(out_cards[j], out_cards[j-1]);
      }
    }
  }
}

void selectionSort(const Cards in_cards, Cards &out_cards){
  int N = in_cards.size();
  assert(N==out_cards.size());
  out_cards = in_cards;

  for(int i=0; i<N; i++){
    int min_j = i;
    for(int j=i; j<N; j++){
      if(out_cards[j].value < out_cards[min_j].value){
        min_j = j;
      }
    }
    swap(out_cards[i], out_cards[min_j]);
  }
}

void output_cards(const Cards cards){
  int N = cards.size();

  for(int i=0; i<N; i++){
    cout << cards[i].suit << cards[i].value;

    if(i != N-1){
      cout << " ";
    }
    else{
      cout << endl;
    }
  }
}

bool is_equal(const Cards cards_1, const Cards cards_2){
  int N = cards_1.size();
  assert(N==cards_2.size());

  for(int i=0; i<N; i++){
    if(cards_1[i].suit != cards_2[i].suit || cards_1[i].value != cards_2[i].value){
      return false;
    }
  }
  return true;
}

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

  Cards cards(N);
  for(int i=0; i<N; i++){
    cin >> cards[i].suit;
    cin >> cards[i].value;
  }

  Cards bubbleSorted_cards(N);
  bubbleSort(cards, bubbleSorted_cards);

  Cards selectionSorted_cards(N);
  selectionSort(cards, selectionSorted_cards);

  output_cards(bubbleSorted_cards);
  cout << "Stable" << endl;
  output_cards(selectionSorted_cards);
  if(is_equal(bubbleSorted_cards, selectionSorted_cards)){
    cout << "Stable" << endl;
  }
  else{
    cout << "Not stable" << endl;
  }

  return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
const ll INF= 1LL<<60-1;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << pair_var.first << " " << pair_var.second ;return os;}
template<class tContainer>
long long sum(tContainer const& iContainer) {return  std::accumulate(std::begin(iContainer), std::end(iContainer), 0LL);}

// head


int m,n,k,res,tmp,tmp2,tmp3,h,w,x,y;
VI a;
deque<PII> que;
string s;
//VI b;
vector<PII> g[2100600];
int b[2100000];
int c[210] = {};
int rui[210000];
set<int> ch;

signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n,x,y;
  res = 0;
  rep(i,1,n+1){
    rep(j,1,n+1){
      rep(l,1,n+1){
        res += gcd(gcd(i,j),l);
      }
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 52844
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace _gnu_pbds;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i = a ; i < b ; i++)
#define stoink stack<ll>
#define quu queue<ll>
#define quee queue<pair<ll,ll>>
#define vec vector <ll>
#define vecd vector<ld>
#define vg vector<vector<ll> >
#define eg vector<pair<ll,ll>>
#define vgw vector<vector<pair<ll,ll> > >
#define pa pair<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 100000000
#define mod (ll)(1e9 + 7)
#define endl '\n'
vec fact(200005);
vec finv(200005);
ll power(ll x,ll exp)
{ll res=1;while(exp>0){if(exp%2==1)res=((res%mod)*(x%mod)%mod);
 x=((x%mod)*(x%mod)%mod);exp=exp>>1;}return res;}
ll ncr(ll n,ll r) {
    ll ans = (fact[n] * finv[r]) % mod;
    ans = (ans * finv[n - r]) % mod;
    return ans;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    fact[0] = 1;
    fr(i,1,200005) {
        fact[i] = (i * fact[i - 1]) % mod;
    }
    fr(i,0,200005) {
        finv[i] = power(fact[i],mod - 2);
    }
    ll x,y,n;
    cin >> x >> y >> n;
    x--;
    y--;
    eg points;
    fr(i,0,n) {
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        points.pb({a,b});
    }
    ++n;
    points.pb({x,y});
    sort(full(points));
    vec dp(3001,0);
    fr(i,0,n) {
        dp[i] = ncr(points[i].ff + points[i].ss,points[i].ff);
        fr(j,0,i) {
            if(points[j].ff > points[i].ff || points[j].ss > points[i].ss)
                continue;
            ll temp = (dp[j] * ncr(points[i].ff - points[j].ff + points[i].ss - points[j].ss,points[i].ff - points[j].ff)) % mod;
            dp[i] = (dp[i] - temp + mod) % mod;         
        }
    }
    cout << dp[n - 1];
	return 0;
}	

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) {
    cin >> a.at(i);
  }
  int maxi = 0, second = 0;
  vector<int> b = a;
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  maxi = a.at(0), second = a.at(1);
  for (int x : b) {
    if (x == maxi) cout << second << endl;
    else cout << maxi << endl;
  }
  return 0;
}


Measured memory_bytes: 3200
import sys
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
for k in range(n):
 b=a[k];b[3],b[4]=b[4],b[3]
for i in range(n-1):
 d=a[i]
 for j in range(i+1,n):
  e=a[j]
  for p in('012345','152043','215304','302541','410352','514320'):
   f=[d[int(k)]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:print('No');sys.exit()
print('Yes')


Measured memory_bytes: 5612
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
/*
    time : 6:26:43 PM
    date : 3/12/2020
*/    
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5;  
const double pie = 3.14159265358979323846 ;
double dist(double Ax,double X,double Ay, double Y){
  double best = (Ax-Ay)*(Ax-Ay) + (X-Y)*(X-Y) ;
  best = sqrt(best) ;
  return best ;
} 
class Solution {
public:

    int solve(int n,int m,string S1,string S2){
      if(n < 0 || m < 0 )
        return 0 ;  
      int op1 = 1+solve(n-1,m,S1,S2) ;
      op1 = min(op1,1+solve(n,m-1,S1,S2));
      op1 = min(op1,(S1[n] != S2[m])+solve(n-1,m-1,S1,S2));  
      return op1 ;      
    }
    int minDistance(string word1, string word2) {
      return solve(word1.size()-1,word2.size()-1,word1,word2);
    }
};
int tests(){
  int n ; cin >> n ; 
  vector <int> v(n) ; 
  for(auto &x : v)
    cin >> x ; 
  int i ; 
  int now = -1 ; 
  int c = 0, j =1 ; 
  forn(i,0,n)
    if(v[i] == j){
      j++ ; 
      c++ ; 
    }
  if(!c)
    return cout << -1 << '\n',0 ;  
  cout << n-c << '\n' ; 
  return 0 ;
}
int main(){
    I__O ;  
    int cases = 1 ; 
    // cout << Solution().minDistance(S1,S2) ;
    // cin >> cases ; 
    while(cases--)
      tests(); 
    return 0 ; 
}

Measured memory_bytes: 1024
n = int(input())
arr = [input() for i in range(n)]
acnum = arr.count('AC')
wanum = arr.count('WA')
tlenum = arr.count('TLE')
renum = arr.count('RE')
print('AC x',str(acnum))
print('WA x',str(wanum))
print('TLE x',str(tlenum))
print('RE x',str(renum))

Measured memory_bytes: 16200
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	ll n, p;
	cin >> n >> p;
	string str;
	cin >> str;
	if (p == 2 || p == 5)
	{
		ll ans = 0;
		for (int i = n - 1; i >= 0; i--)
		{
			int dig = str[i] - '0';
			if (dig % p == 0)
				ans += (i + 1);
		}
		cout << ans << ln;
		return;
	}
	v64 ten(n, 0);
	ten[0] = 1;
	for (int i = 1; i < n; i++)
		ten[i] = mul(10, ten[i - 1], p);
	v64 cal(n, 0);
	cal[n - 1] = mul(str[n - 1] - '0', ten[0], p);
	for (int i = n - 2; i >= 0; i--)
	{
		cal[i] = mul(str[i] - '0', ten[n - i - 1], p);
		cal[i] = add(cal[i + 1], cal[i], p);
	}
	//print_container(cal);
	v64 cnt(p + 1, 0);
	cnt[0] = 1;
	ll ans = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		ans += cnt[cal[i]];
		cnt[cal[i]]++;
	}
	cout << ans << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

int main() {
    vector<string> vec(3);
    rep(i, 3) {
        cin >> vec[i];
        vec[i] += 'z';
    }
    vector<int> card_idx(3, 0);
    int player = 'a' - 'a';
    char now = vec[player][card_idx[player]];
    card_idx[player] += 1;
    while (now != 'z') {
        player = now - 'a';
        now = vec[player][card_idx[player]];
        card_idx[player] += 1;
    }
    cout << (char)('A' + player) << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
char target[52][52];
int main()
{
	int h,w,i,j;
	scanf("%d %d",&h,&w);
	for(i=1;i<=h;i++)
	{
		getchar();
		for(j=1;j<=w;j++)
		{
			scanf("%c",&target[i][j]);	
		}	
	}
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		{
			if(target[i][j]=='#')
			{
				if(target[i-1][j]!='#'&&target[i+1][j]!='#'&&target[i][j-1]!='#'&&target[i][j+1]!='#')
				{
					printf("No");
					return 0;	
				}
			}	
		}	
	}
	printf("Yes");
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  int med = n / 2;
  for(int i = 0; i < n; ++i) {
    cin >> x[i];
    y[i] = x[i];
  }
  sort(y.begin(), y.end());
  for(int i = 0; i < n; ++i) {
    if(x[i] < y[med]) cout << y[med] << endl;
    else cout << y[med-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <string.h>
int main ()
{
	long long int N,i,j,l;
	char S[1000000],a[1000000];
	scanf("%lld %s",&N,S);
	a[0]=S[0];
	for(i=1,j=1;S[j]!='\0';j++)
	{
		
		if(a[i-1]==S[j])
		{
			continue;
		}
		else
		{
			a[i]=S[j];
			i++;
		}
		
	}
	l=strlen(a);
	printf("%lld",l);
	
	for(i=0;i<l;i++)
	{
		a[i]='\0';
	}
	return 0;
	
}

Measured memory_bytes: 384
import "dart:io";

void main(List<String> args) {
  List ab = stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  int product = ab[0] * ab[1];
  if (product % 2 == 0) {
    print("Even");
  } else {
    print("Odd");
  }
}

Measured memory_bytes: 13140
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int n;
vector<int> w, s;
vector<bool> used;
vector<int> bestIndex;
int bestG;

void solve(int k, vector<int>& index, int g, int sumW)
{
    if(k == n){
        if(g < bestG){
            bestG = g;
            bestIndex = index;
        }
        return;
    }

    for(int i=0; i<n; ++i){
        if(used[i])
            continue;
        used[i] = true;
        if(s[i] >= sumW){
            index[k] = i;
            solve(k+1, index, g+(n-k)*w[i], sumW+w[i]);
        }
        used[i] = false;
    }
}

int main()
{
    for(;;){
        cin >> n;
        if(n == 0)
            return 0;

        vector<string> name(n);
        w.resize(n);
        s.resize(n);
        for(int i=0; i<n; ++i)
            cin >> name[i] >> w[i] >> s[i];

        bestG = INT_MAX;
        used.assign(n, false);
        vector<int> index(n);
        solve(0, index, 0, 0);
        for(int i=n-1; i>=0; --i)
            cout << name[bestIndex[i]] << endl;
    }
}

Measured memory_bytes: 916
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int n, a, b; cin >> n >> a >> b;
	cout << min(n*a,b) << endl;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()

string = 'keyence'
if s[-7:] == string:
    ans = 'YES'
elif s[:7] == string:
    ans = 'YES'
else:
    ans = 'NO'
    for i in range(1, 7):
        if s[:i] == string[:i] and s[-(7-i):] == string[-(7-i):]:
            ans = 'YES'
            break
print(ans)
        
    


Measured memory_bytes: 3060
object Main extends App {
  val List(n,k) = io.StdIn.readLine.split(" ").toList.map(_.toLong)

  var t = 0L
  (k to n+1).foreach{i =>
    val min = 1L*(0 + (i-1))*i / 2L
    val max = 1L*( n + (n-i+1) )*i / 2L
    t += max - min + 1
  }
  println(t % (1000000000L + 7))
}

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

ll solve() {
  ll N, M;
  cin >> N >> M;
  if(N == 2 || M == 2) return 0;
  if(N == 1 && M == 1) return 1;
  if(N == 1 || M == 1) return max(N, M) - 2;
  return (N - 2) * (M - 2);
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    // H行W列のマス目
    //行について小さい方の個数がA
    //列についてB
    REP(j, H) {
        REP(i, W) {
            if(j < B) {
                if(i < A) {
                    cout << 0;
                } else {
                    cout << 1;
                }
            } else {
                if(i < A) {
                    cout << 1;
                } else {
                    cout << 0;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
  vector<int> h(10);
  rep(i,10) cin>>h[i];
  sort(h.begin(),h.end());
  cout<<h[9]<<endl<<h[8]<<endl<<h[7]<<endl;
  return 0;
}



Measured memory_bytes: 3104
#include<stdio.h>
#include<string.h>
long long f[45][45];
long long func(int n,int m){
	int i,j,a=1,b=n;
	long long r=1;
	if(n==0 || m==0)return 1;
	if(f[n][m]>0)return f[n][m];
	for(i=0;i<m;i++){
		r=r*(b-i);
		r=r/(a+i);
	}
	f[n][m]=r;
	return r;
}
int main(){
	int i,j,k,l,d[30],e[44],x,y;
	long long ans=1;
	char s[44];
	x=0;
	scanf("%s",s);
	l=strlen(s);
	memset(d,0,sizeof(d));
	memset(e,0,sizeof(e));
	memset(f,0,sizeof(f));
	//printf("%lld\n",func(7,4));
	for(i=0;i<l;i++)d[s[i]-'a']++;
	for(i=0;i<26;i++){
		//printf("%d ",d[i]);
		if(d[i]%2==1)x++,y=i;
		d[i]=d[i]/2;
		for(j=2;j<=d[i];j++)e[j]++;
	}
	//printf("\n");
	//for(i=2;i<=l;i++)printf("%d:%d  ",i,e[i]);
	if(x>1)printf("0\n");
	else{
		/*//printf("l:%d\n",l);
		for(i=2;i<=l;i++){
			ans*=i;
			for(j=2;j<=i;j++){
				while(ans%j==0 && e[j]>0)ans/=j,e[j]--;
			}
		}*/
		y=l/2;
		for(i=0;i<26;i++){
			ans*=func(y,d[i]);
			y-=d[i];
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
//in the name of GOD//

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie();
#define sz(s) s.size()

int main(){
  string s,t;
  cin >> s >> t;
  int ans = 0;
  for(int i = 0; i < 3 ;i++){
    if(s[i] == t[i])
      ans++;
  }
  cout << ans;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

a = []
for i in range(6):
    a.append(int(input()))

# print(a)

flg = False

for i in range(5):
    # print("i ", i)
    
    for j in range(i + 1, 5):
        # print("j ", j)
        an = a[j] - a[i]
        # print("an ", an)
        if an <= a[5]:
            flg = False
        else:
            flg = True
            break
    
    if flg:
        break
    
if flg:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 3060
import sys

N, K = map(int, input().split())
A = list(map(int, input().split()))

i = 1
l = [1] * N
s = set([1])
n = 1
while True:
    n = A[n-1]
    if n in s:
        l = l[:i]
        mod = i - l.index(n)
        init_len = l.index(n)
        break
    else:
        l[i] = n
        s.add(n)
        i += 1

if K < init_len:
    print(l[K])
else:
    rest = ((K-init_len) % mod)
    print(l[init_len+rest])


Measured memory_bytes: 33688
#include <iostream>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int h[n], hm[n];
    int minh;
    for (int i = 0; i<n;i++) {
        cin>>h[i];
    }
    
    for (int i = 0; i<n-1;i++) {
        if(i==0)
        {
            hm[i+1]=abs(h[i]-h[i+1]);
            hm[i+2]=abs(h[i]-h[i+2]);
            minh=min(hm[i+1], hm[i+2]);
        }
        else if(i==n-2)
        {
            hm[i+1]=min(abs(h[i]-h[i+1])+hm[i], hm[i+1]);
            minh=hm[i+1];
        }
        else
        {
            hm[i+1]=min(abs(h[i]-h[i+1])+hm[i], hm[i+1]);
            hm[i+2]=abs(h[i]-h[i+2])+hm[i];
            minh=min(hm[i+1], hm[i+2]);
        }
    }
    
    cout << minh;
    return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////


void solve() {
	int N; cin >> N;
	int res = 0;
	for(int i = 1; i <= N; i++) {
		int cnt = 0;
		if(i % 2 == 0) continue;
		rep(j, 1, i + 1) {
			if(i % j == 0) cnt++;
		}
		if(cnt == 8) res++;
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int cntA,cntB;
  string str;
  while(1){
    cin >> str;
    if(str=="0") break;
    cntA=cntB=0;
    for(int i=1;i<str.size();i++){
      if(str[i]=='A') cntA++;
      else cntB++;
    }
    if(cntA>cntB){
      cout << cntA+1 << ' ' << cntB << endl;
    }else{
      cout << cntA << ' ' << cntB+1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1184
n = gets.to_i
t,a = gets.split.map(&:to_f)
h = gets.split.map(&:to_f)
ans = [100000,0]
n.times do |i|
    if ans[0] > (a-t+h[i]*0.006).abs
        ans = [(a-t+h[i]*0.006).abs,i]
    end
end
puts ans[1]+1

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

using namespace std;

int main()
{
    int n,k;
    string s;

    cin>>n>>k;

    cin>>s;

    if(s.size() == 1)
        cout<<0;

    else
    {
        int i,j,p,l;
        i = 1;
        l = s.size();
        p = 0;

        if(s[0] == 'R')
        {
            for(j=0;j!=n;j++)
            {
                if(s[j] == 'L')
                    s[j] = 'R';
                else
                    s[j] = 'L';
            }
        }

        while(k && i < l)
        {
            if(s[i] == 'R')
            {
                j = i;
                while(j < l && s[j] == 'R')
                {
                    p++;
                    j++;
                }

                if(j == l)
                {
                    if(k)
                    {
                        k--;
                    }
                }
                else
                {
                    if(k)
                    {
                        k--;
                        p++;
                    }
                }

                i = j+1;
            }

            else
            {
                p++;
                i++;
            }
        }

        while(i < l)
        {
            if(s[i] == s[i-1])
                p++;

            i++;
        }

        cout<<p;
    }

    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = 998244353;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int N, S;
vector<Int> A;

Int mod_pow(Int x, Int y){
  Int res = 1;
  while(y){
    if(y&1) res = res * x % mod;
    x = x * x % mod;
    y /= 2;
  }
  return res;
}

Int inv(Int x){return mod_pow(x, mod - 2);}

Int mem[3001][3001];
Int used[3001][3001];
Int dfs(Int idx, Int sum){
  if(sum == S) return mod_pow(2, N);
  if(sum > S) return 0;
  if(idx >= N) return 0;
  if(used[idx][sum]++) return mem[idx][sum];

  Int a = dfs(idx + 1, sum);
  Int b = dfs(idx + 1, sum + A[idx]) * inv(2) % mod;
  Int res = (a + b) % mod;
  return mem[idx][sum] = res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  cin>>N>>S;
  A.resize(N);
  cin>>A;


  Int ans = dfs(0, 0);
  cout<<ans<<endl;

  return 0;
}


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

int main() {
    long long int A,B,C,X,Y,price=0, minprice=999999999999999999;

    scanf("%lld%lld%lld%lld%lld", &A,&B,&C,&X,&Y);


    if (Y>=X) {
        for (long long int i=0;i<X*2;i++) price+=C;
        for (long long int i=0;i<Y-X;i++) price+=B;
    } else {
        for (long long int i=0;i<Y*2;i++) price+=C;
        for (long long int i=0;i<X-Y;i++) price+=A;
    }
    minprice=min(price, minprice);
    price=0;

    for (long long int i=0;i<X;i++) price+=A;
    for (long long int i=0;i<Y;i++) price+=B;

    minprice=min(price, minprice);
    price=0;

    for (long long int i=0;i<max(X,Y)*2;i++) price+=C;

    minprice=min(price, minprice);
    price=0;

    printf("%lld", minprice);
}

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

int main() {
  vector<vector<int>> b(3, vector<int>(3));
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      cin >> b[i][j];
    }
  }
  int N; cin >> N;
  
  vector<vector<int>> a(3, vector<int>(3, 0));

  for (int k=0; k<N; k++) {
    int n; cin >> n;
    for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      if (n == b[i][j]) a[i][j] = 1;
    }
  }
  }
  
  for (int i=0; i<3; i++) {
    if (a[i][0]*a[i][1]*a[i][2] == 1) {
      cout << "Yes" << endl;
      return 0;
    }
    if (a[0][i]*a[1][i]*a[2][i] == 1) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  if (a[0][0]*a[1][1]*a[2][2] == 1) {
    cout << "Yes" << endl;
    return 0;
  }
  if (a[0][2]*a[1][1]*a[2][0] == 1) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

solve :: Int -> [Int]
solve n = reverse $ solve' n primes []
    where
        range = truncate $ sqrt $ fromIntegral n
        primes = filter isPrime [2..range]

isPrime :: Int -> Bool
isPrime n = null [x | x <- [2.. truncate $ sqrt $ fromIntegral n], n `rem` x == 0]

solve' :: Int -> [Int] -> [Int] -> [Int]
solve' _ [] ans = ans
solve' 1 _ ans = ans
solve' n primes@(x:xs) ans =
    if isPrime n
    then (n:ans)
    else
        if n `rem` x == 0
        then solve' (n `div` x) primes (x:ans)
        else solve' n xs ans

readLnInt :: IO Int
readLnInt = readLn

main :: IO ()
main = do
    n <- readLnInt
    if isPrime n
    then do
        putStrLn $ show n ++ ": " ++ show n
    else do
        let answer = foldl' (++) "" (map ((" " ++) . show) (solve n))
        putStrLn $ show n ++ ":" ++ answer

Measured memory_bytes: 4168