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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

void solve()
{
	string s, t;
	cin >> s >> t;
	t = t.substr(0, s.size());
	if (t == s)
		cout << "Yes" << en;
	else
		cout << "No" << en;
}

int main()
{
	fast;
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3656
def cmb(n, k, mod, fac, infac):
  k = min(k,n-k)
  return fac[n] * infac[k] * infac[n-k] % mod

def tables(mod, n):
  fac = [1, 1] 
  infac = [1, 1] 
  inverse = [0, 1] 
  for i in range(2, n+1):
    fac.append((fac[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    infac.append((infac[-1] * inverse[-1]) % mod)
  return fac,infac

X,Y = map(int, input().split())

if X > Y:
  X, Y = Y, X

move = X + Y

if move % 3 != 0:
  print(0)
else:
  total = move // 3
  n = X - total
  
  if n < 0:
    print(0)
    
  else:
    MOD = 10 ** 9 + 7
    fac, infac = tables(MOD, total)
    ans = cmb(total, n, MOD, fac, infac)
    
    print(ans)

Measured memory_bytes: 82232
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

vector<int> G[1000005];

int len[1000005];

int dfs(int x){
    if(len[x] == -1){
        len[0] = -1;
        return -1;
    }
    if(len[x] > 0){
        ;
    }else if(G[x].size() == 0){
        len[x] = 1;
    }else{
        if(len[x] == -2){
            len[x] = -1;
            return len[x];
        }
        len[x] = -2;
        rep(i,G[x].size()){
            int tmp = dfs(G[x][i]);
            if(tmp == -1){
                len[x] = -1;
                len[0] = -1;
                return -1;
            }
            len[x] = max(len[x], tmp + 1);
            
        }
    }
    return len[x];
}

void solve(){
    rep(i,1000001){
        if(len[i] == 0){
            int tmp = dfs(i);
            if(tmp == -1){
                len[0] = -1;
                break;
            }
        }else if(G[i].size() > 0){
            int loop_flag = 0;
            rep(j,G[i].size()){
                if(len[G[i][j]] >= len[i]){
                    loop_flag = 1;
                    break;
                }
            }
            if(loop_flag == 1){
                len[0] = -1;
                break;
            }
        }
        if(len[i] == -1){
            len[0] = -1;
            break;
        }
    }
}

int main() {
    int n;
    cin >> n;
    int a[n-1];
    srep(i,1,n+1){
        rep(j,n-1){
            scanf("%d", &a[j]);
        }
        rep(j,n-2){
            int from, to;
            if(i<a[j]){
                from = i * 1000 + a[j];
            }else{
                from = i + a[j] * 1000;
            }
            if(i<a[j+1]){
                to = i * 1000 + a[j+1];
            }else{
                to = i + a[j+1] * 1000;
            }
            G[from].push_back(to);
        }
    }

    solve();
    if(len[0] == -1){
        cout << len[0] << endl;
    }else{
        int ans = 0;
        rep(i,1000001){
            ans = max(ans,len[i]);
        }
        cout << ans << endl;
    }

    return 0;
}
 
 


Measured memory_bytes: 43264
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>

using namespace std;

int main(void){
    int a,b, ans = 0;

    cin >> a >> b;

    if(a >= 10 || b >= 10) ans = -1;
    else ans = a*b;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>

#define SIZE 100005
#define MOD 1000000007
#define INF 100000000

using namespace std;

class DPredictionAndRestriction {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int64_t n, k;
        cin >> n >> k;
        int64_t r, s, p;
        cin >> r >> s >> p;
        string t;
        cin >> t;
        int ans = 0;
        for (int i = 0; i < k; ++i) {
            vector<int> vec;
            bool flag = false;
            for (int j = i; j < n; j += k) {
                if (i == j) {
                    switch (t[j]) {
                        case 'r':
                            vec.emplace_back(p);
                            break;
                        case 's':
                            vec.emplace_back(r);
                            break;
                        case 'p':
                            vec.emplace_back(s);
                            break;
                    }
                } else {
                    switch (t[j]) {
                        case 'r':
                            if (flag == false && t[j - k] == 'r') {
                                vec.emplace_back(vec.back());
                                flag = true;
                            } else {
                                vec.emplace_back(vec.back() + p);
                                flag = false;
                            }
                            break;
                        case 's':
                            if (!flag && t[j - k] == 's') {
                                vec.emplace_back(vec.back());
                                flag = true;
                            } else {
                                vec.emplace_back(vec.back() + r);
                                flag = false;
                            }
                            break;
                        case 'p':
                            if (!flag && t[j - k] == 'p') {
                                vec.emplace_back(vec.back());
                                flag = true;
                            } else {
                                vec.emplace_back(vec.back() + s);
                                flag = false;
                            }
                            break;
                    }
                }
            }
            ans += vec.back();
        }
        cout << ans << endl;
    }
};


int main() {
    DPredictionAndRestriction solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main(){
    int A, B, C, N, M ,K;
    int sum = 0;
    int t = 0;
    string s, s1;
    cin >> N >> s;

    for(int i = 0; i < N; i++){
        if(s.at(i) == 'R') t++;
        else t--;
    }

    if(t > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
//    vector<int> X();

//    for(int i = 0; i < ; i++){}
//    for(int j = 0; j < ; j++){}

//    cout <<  << endl;
}

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

using namespace std;

int main(){
int n; cin >> n;
set<string> Set;
string s, prev; cin >> prev;
Set.insert(prev);
for(int i = 0; i<n - 1; ++i){
cin >> s;
if(Set.find(s)!=Set.end() or s[0]!=prev.back()){
cout << "No";
return 0;
}
prev = s;
Set.insert(s);
}
cout << "Yes";
return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        char[] c = S.toCharArray();        
        
        int[][] dp = new int[N+1][N+1];
        int max=0;
        for(int i=N-1;i>=0;i--) {
        	for(int j=N-1;j>=0;j--) {
        		if(c[i]==c[j]) {
        			dp[i][j]=dp[i+1][j+1]+1;
        			max=Math.max(max, Math.min(dp[i][j], Math.abs(i-j)));
        		}
        	}
        }
        System.out.println(max);  	
               		
    }

}

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

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a = s[0];
            int b = s[1];
            int c = s[2];
            int x = s[3];
            int y = s[4];

            long ans = 0;
            if (c * 2 <= a + b)
            {
                int loop = Min(x, y);
                for (int i = 0; i < loop; i++)
                {
                    x--;
                    y--;
                    ans += c * 2;
                }
                if (x > 0 )
                {
                    if (2*c < a)
                    {
                        for (int i = 0; i < x; i++)
                        {
                            ans += c * 2;
                        }
                    }
                    else
                    {
                        for (int i = 0; i < x; i++)
                        {
                            ans += a;
                        }
                    }
                }
                else
                {
                    if (2*c < b)
                    {
                        for (int i = 0; i < y; i++)
                        {
                            ans += c * 2;
                        }
                    }
                    else
                    {
                        for (int i = 0; i < y; i++)
                        {
                            ans += b;
                        }
                    }
                }
            }
            else
            {
                ans += a * x;
                ans += b * y;
            }

            
            WriteLine(ans);
        }
    }
}


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

using namespace std;

const int INF = (int) 1e9;
const int N = 18;
const int L = 50;

int n;
int a[N];
int b[N];
int dp[1 << N][L + 1];

void read()
{
        cin >> n;
        for (int i = 0; i < n; i++)
                cin >> a[i];
        for (int i = 0; i < n; i++)
                cin >> b[i];
}

void init()
{
        for (int i = 0; i < (1 << N); i++)
                for (int j = 0; j <= 50; j++)
                        dp[i][j] = INF;
        dp[0][1] = 0;
}

bool is(int mask, int i)
{
        if (mask & (1 << i))
                return 1;
        else
                return 0;
}

void compute()
{
        /// primele size(mask) le punem mask
        for (int mask = 0; mask < (1 << n) - 1; mask++)
        {
                int p = 0;
                for (int i = 0; i < n; i++)
                        if (is(mask, i))
                                p++;
                for (int i = 0; i < n; i++)
                        if (!is(mask, i))
                        {
                                int cntb = 0;
                                for (int j = i; j < n; j++)
                                        cntb += is(mask, j);
                              //  cout << "# " << i + cntb << " " << p << "\n";
                                int dist = abs(i - p), nval;
                                if (dist % 2 == 0)
                                        nval = a[i];
                                else
                                        nval = b[i];
                                for (int cur = 1; cur <= nval; cur++)
                                        dp[mask + (1 << i)][nval] = min(dp[mask + (1 << i)][nval], i + cntb - p + dp[mask][cur]);
                        }
        }
}

int solve()
{
//        cout << dp[(1 << 0)][2] << "\n";
//        exit(0);
        int sol = INF;
        for (int last = 1; last <= 50; last++)
                sol = min(sol, dp[(1 << n) - 1][last]);
        if (sol == INF)
                return -1;
        else
                return sol;
}

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //      freopen ("input", "r", stdin);

        read();
        init();
        compute();
        cout << solve() << "\n";
}


Measured memory_bytes: 52480
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        int[] num = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int q = int.Parse(Console.ReadLine());
        for(int i=0; i<q; i++){
            int[] line = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Console.WriteLine(num.Skip(line[0]).Take(line[1]-line[0]).Count(x => x == line[2]));
        }
    }
}



Measured memory_bytes: 18384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	vector<int>A(100);
	int a;
	while (cin >> a) {
		A[a - 1]++;
	}
	int M = -1;
	rep(i, 100) {
		M = max(M, A[i]);
	}
	rep(i, 100) {
		if (M == A[i]) {
			cout << i + 1 << endl;
		}
	}
}


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

int main() {
    ll n, a, b, c, d, e, ans;
    cin >> n >> a >> b >> c >> d >> e;

    ll mn = min(a, min(b,min(c, min(d, e))));
    if(n%mn==0) {
        ans = 5 + n/mn - 1;
    }
    else{
        ans = 5 + n/mn;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using pii = pair<int, int>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

// union-find
const int MAX_N = 1e5+1;

int parent[MAX_N];
int root(int x) {
  if (parent[x] == x)
    return x;
  return parent[x] = root(parent[x]);
}
void unite(int x, int y) {
  if (root(x) == root(y))
    return;
  x = root(x);
  y = root(y);
  parent[x] = y;
  return;
}
bool same(int x, int y) {
  return root(x) == root(y);
}
// end

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

  pii x[N], y[N];
  rep(i, N) {
    in(x[i].first); in(y[i].first);
    x[i].second = y[i].second = i;
    parent[i] = i;
  }
  sort(x, x+N); sort(y, y+N);
  priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> diff_x, diff_y;

  rep(i, N-1) {
    diff_x.push(make_pair(x[i+1].first - x[i].first, pii(x[i].second, x[i+1].second)));
    diff_y.push(make_pair(y[i+1].first - y[i].first, pii(y[i].second, y[i+1].second)));
  }
  ll ans = 0;
  while (!diff_x.empty() || !diff_y.empty()) {
    int cost1 = diff_x.top().first;
    int cost2 = diff_y.top().first;
    if (diff_y.empty() || !diff_x.empty() && cost1 < cost2) {
      int x1 = diff_x.top().second.first,
          x2 = diff_x.top().second.second;
      diff_x.pop();
      if (!same(x1, x2)) {
        unite(x1, x2);
        ans += cost1;
      }
    } else {
      int y1 = diff_y.top().second.first,
          y2 = diff_y.top().second.second;
      diff_y.pop();
      if (!same(y1, y2)) {
        unite(y1, y2);
        ans += cost2;
      }
    }
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 6444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int A = sc.nextInt(); //red
		int B = sc.nextInt(); //green
		int C = sc.nextInt(); //blue
		int K = sc.nextInt(); //num
		sc.close();

		int tryNum = 0;

		while(B <= A) {
			//gleen > red
			//B > A が終着点
			B *= 2;
			tryNum++;
		}

		while(C <= B) {
			//blue > green
			//C > Bが終着点
			C *= 2;
			tryNum++;

		}

		if(tryNum > K) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}

}


Measured memory_bytes: 27064
#include <stdio.h>

#define MAX 101
#define INFTY 100000001

int p[MAX];
int m[MAX][MAX];

int min(int a, int b){
  if(a < b) return a;
  else if(a > b) return b;
  else if(a == b) return a;
  }

void matrixChainMultiplication(int n){
  int i,j,k,l;
  for(i=1; i<=n; i++) m[i][i] = 0;
  for(l=2; l<=n; l++){
    for(i=1; i<= n-l+1; i++){
      j = i + l - 1;
      m[i][j] = INFTY;
      for(k=i; k<=j-1; k++){
	m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]);
      }
    }
  }
}

int main(){
  int i,num;
  scanf("%d",&num);
  for(i=1; i<=num; i++) scanf("%d%d",&p[i-1],&p[i]);
  matrixChainMultiplication(num);
  printf("%d\n",m[1][num]);

  return 0;

}

Measured memory_bytes: 636
/*
 Templatka c++ Kacper Fis																							   																											   //
*/

#include <iostream>
#include <cstdio>
#include <limits>
#include <cstdlib>
#include <utility>
#include <iterator>
#include <bitset>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <time.h>
#include <iomanip>
#include <sstream>
#include <bits/stdc++.h>

using namespace std;

const int INF = 1000000001;
const float PI = 3.14;
typedef long long LL;

typedef vector<int> vi;
typedef list<int> li;
typedef queue<int> qi;
typedef pair<int,int> ii;
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra

list<int>::iterator it;
list<int>::iterator it1;
vector<int>::iterator it2;
vector<int>::iterator it3;
set<int>::iterator it4;
map<string, int>::iterator it5;
vector<ii>::iterator iter;

#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair(x, y)
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////



///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{ios_base::sync_with_stdio(false); cin.tie(NULL);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    int k, x;

    cin >> k >> x;

    int temp1 = x-k;
    int temp2 = x;

    int i = x+k;
    while(temp1 < x)
    {
        temp1++;
        cout << temp1 << " ";
    }

    while(temp2 < i-1)
    {
        temp2++;
        cout << temp2 << " ";
    }

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long LL;
int T;
LL a,b,c,d;
LL gcd(LL x, LL y) {
    return y==0?x:gcd(y,x%y);
}
int main() {
    scanf("%d", &T);
    while(T--) {
        cin>>a>>b>>c>>d;
        if(d<b||a<b) {
            printf("No\n"); continue;
        }
        LL a1 = a - ((a-(c+1))/b + 1)*b;
        //printf("a1 = %lld\n", a1);
        if (a1<0) {
            printf("No\n"); continue;
        }
        LL dt = gcd(b,d);
        if(dt==0) {
            printf("Yes\n"); continue;
        }
        LL l = (c+1-a1+dt-1)/dt;
        LL r = (b-1-a1)/dt;
        //printf("[%lld,%lld]\n", l,r);
        if (r >= l) {
            printf("No\n");
        } else {
            printf("Yes\n");
        }
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define CRLF <<'\n';
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
#define trav(it,v) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

#define MAX_N 8
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;
typedef bitset<MAX_N> bs;
int memo[1<<MAX_N][1<<MAX_N];
int n,m,k;
char arr[MAX_N][MAX_N];

int rec(bs rw,bs col){

    if (memo[rw.to_ulong()][col.to_ulong()] != -1)
        return 0 ;

    int num=0;
    rep(i,0,n){
        if (rw[i]) continue;
        rep(j,0,m){
            if (col[j]) continue;
            if (arr[i][j] == '#')
                num++;
        }
    }
    int c =0;
    if (num == k)
        c++;

    rep(i,0,n){
        if (!rw[i])
            rw.flip(i),c+=rec(rw,col),rw.flip(i);
    }
    rep(i,0,m){
        if (!col[i])
            col.flip(i),c+=rec(rw,col),col.flip(i);
    }
    memo[rw.to_ulong()][col.to_ulong()] = c;
    return c;
}


int main(){
    scanf("%d%d%d%*c",&n,&m,&k);
    rep(i,0,n){
        rep(j,0,m){
            scanf("%c",&arr[i][j]);
        }scanf("%*c");
    }
    memset(memo,-1,sizeof memo);
    bs a,b;
    cout  << rec(a,b);


}


Measured memory_bytes: 3972
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>

int x;
int dp[1000000];
int N=100000;
int main(void){
    cin>>x;

    dp[0]=1;


    for(int i=0;i<=N;i++){
     for(int j=0;j<=5;j++){
        if(dp[i])dp[i+100+j]=1;
    }
    }

    if(dp[x]){
        cout<<1<<endl;
    }
    else{
        cout<<0<<endl;
    }

    return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = []
B = []
for i in range(M):
    A_, B_ = map(int, input().split())
    A.append(A_)
    B.append(B_)

l = [1] * N
for i in range(M):
    if H[A[i]-1] >= H[B[i]-1]:
        l[B[i]-1] = 0
    if H[A[i]-1] <= H[B[i]-1]:
        l[A[i]-1] = 0
print(sum(l))

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

using ll = long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    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;
  }
};

// nCa
mint choose(int n, int a) {
  mint x = 1, y = 1;
  for (int i = 0; i < a; ++i) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = mint(2).pow(n);
  ans -= 1; // 0個の場合
  ans -= choose(n, a);
  ans -= choose(n, b);

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


Measured memory_bytes: 256
<?php
list($n) = ints();
for ($i = 0; $i < $n; ++$i) list($a[]) = ints();
$ends = [$a[0]];
for ($i = 1; $i < $n; ++$i) {
    $l = count($ends);
    $ok = $l;
    $ng = -1;
    while (abs($ok - $ng) > 1) {
        $mid = intdiv($ok + $ng, 2);
        if ($ends[$mid] < $a[$i]) $ok = $mid;
        else $ng = $mid;
    }
    $ends[$ok] = $a[$i];
}
echo count($ends);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 24112
// Last Change: 03/30/2019 21:01:13.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A == B and A == C) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int[] g = new int[s.length + 1];
        if (s.length == 1) {
            System.out.println(1);
            return;
        }
        g[0] = 0;
        g[1] = 1;
        if (s[0] == s[1]) {
            g[2] = 1;
        } else {
            g[2] = 2;
        }
        for (int i = 3 ; i <= s.length ; i++) {
            if (i >= 3) {
                if (s[i - 1] == s[i - 2]) {
                    g[i] = g[i - 3] + 2;
                } else {
                    g[i] = g[i - 1] + 1;
                }
            }
        }
        System.out.println(g[s.length]);

    }

}


Measured memory_bytes: 28472
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  string W[N];
  for(int i=0;i<N;i++){
    cin >> W[i];
  }
  bool item = true;
  for(int j=0;j<N-1;j++){
    if(W[j][W[j].size()-1]!=W[j+1][0]) item=false;
    for(int i=j+1;i<N;i++){
      if(W[j]==W[i]) item=false;
    }
  }
  if(item) cout << "Yes" <<endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int a,b;
    cin >> a >> b;
    print(a * b);
    



}



//queue<pint>().swap(q); キュー内を全て削除
//priority_queue<ll, vector<ll>, greater<ll> > que;
//auto dp=make_v<int>(4,h,w);
//vector<vector<ll>> g;
//g.assign(n, vector<ll>()); g.resize(n);でも大丈夫っぽい
//fill_v(dp,0);
//int n;
//cin >> n;
//vector<int> test(n);
//cins(all(test));
//array_output(all(test));
// Yes(true);

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

using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e18
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
using ll = long long;

ll n,k;
string s;
vector<ll> vec;
int main(){
    cin>>n>>k;
    cin>>s;
    vector<ll> v;

    int c=0;
    char now = '1';
    for(int i=0;i<n;i++){
        if(now==s[i]){
            c++;
        }else{
            v.push_back(c);
            c=1;
            now=s[i];
        }
    }
    v.push_back(c);
    v.push_back(0);
    ll sum=0;
    ll ans=0;


    int l=0;
    int r=1;
    //idx
    int pos=0;
    sum+=v[0];
    sum+=v[1];
    ans=sum;
    while(l<(int)v.size()){
        if(r-l<2*k && r<(int)v.size() ){
            r++;
            sum+=v[r];
            if(s[pos]=='1')ans=max(ans,sum);
        }else{
            l++;
            sum-=v[l-1];
            pos+=v[l-1];

        }
    }

    l=0;
    r=1;
    pos=0;
    sum=0;
    sum+=v[0];
    sum+=v[1];

    while(l<(int)v.size()){
        if(r-l<2*k-1 && r<(int)v.size() ){
            r++;
            sum+=v[r];
            if(s[pos]=='0')ans=max(ans,sum);
        }else{

            l++;
            pos+=v[l-1];

            sum-=v[l-1];
        }
    }

    cout<<ans<<endl;

 



  



}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < 5; i++)cout << s[i];
	cout << " ";
	for (int i = 6; i < 13; i++)cout << s[i];
	cout << " ";
	for (int i = 14; i < 19; i++)cout << s[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, size):
        self.data = [-1 for _ in range(size)]
    def find(self, x):
        if self.data[x] < 0:
            return x
        else:
            self.data[x] = self.find(self.data[x])
            return self.data[x]
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:
            if self.data[y] < self.data[x]:
                x, y = y, x
            self.data[x] += self.data[y]
            self.data[y] = x
        return (x != y)
    def same(self, x, y):
        return (self.find(x) == self.find(y))
    def size(self, x):
        return -self.data[self.find(x)]

N, M = [int(i) for i in input().split()]
AB = [[int(i) for i in input().split()] for _ in range(M)]

count = 0
for a, b in AB:
    uf = UnionFind(N + 1)
    for c, d in AB:
        if (a, b) == (c, d):
            continue
        uf.union(c, d)
    if uf.size(1) != N:
        count += 1

print(count)

Measured memory_bytes: 3064
import sys
input=sys.stdin.readline

N,X = map(int,input().split())

total = [1]*(N+1)
pate = [1]*(N+1)
for i in range(1, N+1):
    total[i] = total[i-1]*2 + 3
    pate[i] = pate[i-1]*2 + 1

ans = 0
def f(lv):
    global ans, X
    if X == total[lv]:
        ans += pate[lv]
    else:
        X -= 1
        if X > 0:
            if X < total[lv-1]:
                f(lv-1)
            else:
                ans += pate[lv-1]
                X -= total[lv-1]                
                if X > 0:
                    ans += 1
                    X -= 1
                if X > 0:
                    f(lv-1)
                if X > 0:
                    X -= 1 # unreachable?

def main():
    f(N)
    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
  int n,m;
  cin>>n>>m;
  int cnt=n;
  set<int>st;
  vector<int>h(n);
  rep(i,n){
    cin>>h[i];
  }
  rep(i,m){
    int a,b;
    cin>>a>>b;
    int x,y;
    x=h[a-1];
    y=h[b-1];
    int mn=min(x,y);
    if(x==y){
      st.insert(a);
      st.insert(b);
    }
    else if(mn==x){
      st.insert(a);
    }
    else if(mn==y){
      st.insert(b);
    }    
  }
  cnt-=st.size();
  cout<<cnt<<endl;
}

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

using namespace std;
using ll = long long;

//cout << std::fixed << std::setprecision(15) << y << endl;

int main() {
    ll n = 0;
    cin >> n;
    vector<ll> a(n + 1);
    vector<ll> b(n);
    for(ll i = 0;i <= n;i++){
        cin >> a[i];
    }
    for(ll i = 0;i < n;i++){
        cin >> b[i];
    }

    ll sum = 0;
    for(ll i = 0;i < n;i++){
        if(a[i] <= b[i]){
            sum += a[i];
            b[i] -= a[i];
            a[i] = 0;
        }else{
            sum += b[i];
            a[i] -= b[i];
            b[i] = 0;
        }
        if(a[i + 1] <= b[i]){
            sum += a[i + 1];
            b[i] -= a[i + 1];
            a[i + 1] = 0;
        }else{
            sum += b[i];
            a[i + 1] -= b[i];
            b[i] = 0;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
const double PI=3.14159265358979323846;


int main() {
  long double ans;
  int R;
  cin >> R;

  ans = 2 * PI * R;

  cout << setprecision(18) << ans << endl;

  return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
using namespace std;

typedef long long int lli;

string S, T;
bool ans = true;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> S >> T;
    for(int j = 0; j < S.size(); ++j){
        if(S[j] != T[j])
            ans = false;
    }
    if(ans)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;
char ans[100005];

int main(){
	int n,a,b,c,flag=0;
	char s[5],s2[5];
    scanf("%d%d%d%d",&n,&a,&b,&c);
    getchar();
    scanf("%s",s);
    getchar();
    for(int i=1;i<=n;i++)
    {
        if(i!=n)
        {
            scanf("%s",s2);
            getchar();
        }
        if(s[0]=='A'&&s[1]=='B')
        {
            if(a>b)
            {
                a--;b++;
                ans[i]='B';
            }
            else if(a==b)
            {
                if(s2[0]=='A')
                {
                    a++;b--;
                    ans[i]='A';
                }
                else
                {
                    a--;b++;
                    ans[i]='B';
                }
            }
            else
            {
                a++;b--;
                ans[i]='A';
            }
        }
        else if(s[0]=='B'&&s[1]=='C')
        {
            if(b>c)
            {
                b--;c++;
                ans[i]='C';
            }
            else if(c==b)
            {
                if(s2[1]=='C')
                {
                    c++;b--;
                    ans[i]='C';
                }
                else
                {
                    c--;b++;
                    ans[i]='B';
                }
            }
            else
            {
                b++;c--;
                ans[i]='B';
            }
        }
        else if(s[0]=='A'&&s[1]=='C')
        {
            if(a>c)
            {
                a--;c++;
                ans[i]='C';
            }
            else if(a==c)
            {
                if(s2[0]=='A')
                {
                    a++;c--;
                    ans[i]='A';
                }
                else
                {
                    a--;c++;
                    ans[i]='C';
                }
            }
            else
            {
                a++;c--;
                ans[i]='A';
            }
        }
        if(a<0||b<0||c<0)
        {
            flag=1;
        }
        s[0]=s2[0];s[1]=s2[1];
    }
    if(flag)
    {
        printf("No");
        return 0;
    }
    if(a>=0&&b>=0&&c>=0)
    {
        printf("Yes\n");
        for(int i=1;i<=n;i++)
        {
            printf("%c",ans[i]);
            if(i!=n)    printf("\n");
        }
    }
    else       printf("No");
	return 0;
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a;string s;cin>>a>>s;
  print((a>=3200)?s:"red");
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = str(input())
arr = []
cnt = 0

for i in range(1,N):

  for ch in range (97,123):
    if S[:i].count(chr(ch)) != 0 and S[i:].count(chr(ch)) != 0:
      cnt=cnt+1
  arr.append(cnt)
  cnt=0

print(max(arr))

Measured memory_bytes: 3064
//
//  main.cpp
//  A
//
//  Created by Kazi Nayeem on 9/13/20.
//  Copyright © 2020 Brain Craft Ltd. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>

typedef long long ll;
using namespace std;


ll getMax(ll a, ll b, ll x) {
    ll answer = max(a*x,b*x);
    if (a<=0 && b >= 0) {
        answer = max(answer, 0ll);
    }
    if (a<=1 && b >= 1) {
        answer = max(answer, x);
    }
    if (a<=-1 && b >= -1) {
        answer = max(answer, -x);
    }
    return answer;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    long long a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    ll answer = a*c;
    answer = max(answer, getMax(c, d, a));
    answer = max(answer, getMax(c, d, b));
    
    if (a<=0 && b >= 0) {
        answer = max(answer, 0ll);
    }
    if (a<=1 && b >= 1) {
        answer = max(answer, getMax(c, d, 1));
    }
    if (a<=-1 && b >= -1) {
        answer = max(answer, getMax(c, d, -1));
    }
    printf("%lld\n", answer);
}


Measured memory_bytes: 3864
#include <iostream>
using namespace std;
using LL = long long int;

int main() {
	LL X;
	cin >> X;
	LL money = 100;
	LL ans = 0;
	while (money < X) {
		ans++;
		money = money * 1.01;
		//cout << money << endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
A,B,C,X,Y = map(int,input().split())
min_ = min(X,Y)
max_ = max(X,Y)

res = A*X + B*Y

m = 2 * C * max(X, Y);

sum = C * 2* min_

if(C<=0.5 * A and C <= 0.5 * B):
    sum += 2*C*(max_-min_)

elif(max_==X):
    sum += (max_-min_)*A
else:
    sum += (max_-min_)*B
    
print(min(m,min(res,sum)))

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

int nc2(int n)
{
	if(n<0)return 0;
	int x=n*(n-1);x/=2;
	return x;
}

int32_t main()
{
	int n;
	cin>>n;
	int a[n],cnt[n]={0};
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		a[i]--;
		cnt[a[i]]++;
	}
	int ans=0;
	for(int g=0;g<n;g++)
	{
	  ans+=nc2(cnt[g]);
	}
	for(int k=0;k<n;k++)
	{
		int temp=ans-nc2(cnt[a[k]]);
		temp+=  nc2( cnt[a[k]]-1 );
		cout<<temp<<endl;
	}
}

Measured memory_bytes: 5760
#include<iostream>
using namespace std;
int main()
{
  long long int h,w,n=0;
  cin>>h>>w;
  if(h==1 ||w==1)cout<<"1"<<endl;
  else 
   {
     n=h*w;
    if(n%2==0)cout<<n/2<<endl;
    else cout<<(n/2)+1<<endl;
   }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<sstream>
#include<queue>
#include<algorithm>
#include<cstdlib>

using namespace std;

const int MAX = 3001;
const int INF = (1<<25);

struct Node{
  int rank,row,column;
  bool operator < (const Node& n) const{
    return rank < n.rank;
  }
};

typedef pair<int,int> P;
int W,H;
vector<Node> V;

int s2i(const string& s){
  stringstream ss(s);
  int res;
  ss >> res;
  return res;
}

void input(){
  V.clear();
  for(int i = 0; i < H; i++)
    for(int j = 0; j < W; j++){
      string s;
      cin >> s;
      int rank = -1;
      if(s == ".") continue;

      if(s == "S") rank = 0;
      else if(s == "G") rank = MAX-1;
      else if(s != ".") rank = s2i(s);
      V.push_back((Node){rank,i,j});
    }
}

void solve(){
  sort(V.begin(),V.end());
  int T[MAX];
  fill(T,T+MAX,INF);
  queue<P> Q; // time position
  Q.push(P(0,0));
  
  int res = INF;

  while(!Q.empty()){
    P p = Q.front(); Q.pop();

    // cout << p.first << " " << p.second << endl;
    if(p.first > T[p.second]) continue;

    if(p.second == (int)V.size()-1) res = min(res,p.first);
    
    else{
      vector<Node>::iterator ite = upper_bound(V.begin(),V.end(),(Node){V[p.second].rank,0,0});
      int lim = ite->rank;
      
      while(ite < V.end() && ite->rank <= lim){
	// cout << V[p.second].rank << " "<< ite->rank << " " << ite->row << " " << ite->column << endl;
	P nex = p;
	Node node = V[p.second];
	nex.first += abs(node.row-ite->row)+abs(node.column-ite->column);
	nex.second = ite-V.begin();
	if(T[nex.second] > nex.first){
	  T[nex.second] = nex.first;
	  Q.push(nex);
	}
	ite++;
      }
    }
  }

  // for(int i = 0; i < (int)V.size(); i++) cout << V[i].rank << " " << T[i] << endl;
  cout << res << endl;
}

int main(){
  while(cin >> W >> H && W+H){
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1348
#!/usr/bin/env python3

import math
def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

def fact(n):
    r = [1]
    if n % 2 == 0:
        r.append(2)
        while n % 2 == 0:
            n //= 2
    i = 3
    k = int(math.sqrt(n))
    while i <= k:
        if n % i == 0:
            r.append(i)
            while n % i == 0:
                n //= i
            k = int(math.sqrt(n))
        i += 2
    if n > 1:
        r.append(n)
    return r

def main():
    A, B = map(int, input().split())
    t = gcd(A, B)
    print(len(fact(t)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
int main(int argc, char *argv[])
{
	int t;
	scanf("%d",&t);
	int a[100000];
	int count[100005]={0};
	for(int i=0;i<t;i++){
		scanf("%d",&a[i]);
		if(a[i]==0){
			count[a[i]]++;
			count[a[i]+1]++;
		}
		else{
			count[a[i]]++;
			count[a[i]-1]++;
			count[a[i]+1]++;
		}
	}
	int max=count[0];
	for(int i=1;i<100000;i++){
		if(count[i]>max) max=count[i];
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 2488
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let n = buf.trim().chars().collect::<Vec<char>>();
	if n[0] == '9' || n[1] == '9' {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]

x, y = gets.chomp.split(" ").map(&:to_i)
if (g1.include?(x) && g1.include?(y)) || (g2.include?(x) && g2.include?(y)) || (g3.include?(x) && g3.include?(y)) then
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define x first
#define y second
#define i64 long long
int n,p;
bool cmp(pi x,pi y){
	return (100LL-p)*x.x + (i64)p * x.y > 
		(100LL-p)*y.x + (i64)p * y.y;
}
pi a[111111];
int main(){
	i64 pig = 0, all = 0;
	scanf("%d%d",&n,&p);
	for(int i=0; i<n; i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		all += a[i].y;
	}
	sort(a,a+n,cmp);
	for(int i=0; i<n; i++){
		pig += a[i].x;
		all += a[i].x - a[i].y;
		if(pig * 100 >= all * p){
			printf("%d\n",i+1);
			break;
		}
	}
	return 0;
}


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

using static Input;
using static Util;
class Program
{
    static int N;
    static int[] D;
    static void INPUT()
    {
        N = NextInt();
        D = LineInt();
    }

    static void OUT()
    {
        Array.Sort<int>(D);
        var a = D[N / 2];
        var b = D[N / 2 - 1];
        Console.WriteLine(a - b);
    }

    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
}


Measured memory_bytes: 26624