akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}

int main()
{
  int n,m;
  string s,t;
  string ans;
  while(cin >> n)
  {
    if(n == 0) break;
    map<string,string> d;
    REP(i,n)
    {
      cin >> s >> t;
      d[s] = t;
    }
    cin >> m;
    ans = "";
    REP(i,m)
    {
      cin >> s;
      if(d.find(s) == d.end())
        ans += s;
      else
        ans += d[s];
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string N;
  int K;
  cin >> N >> K;

  vector<int> cnt(10);
  int d;
  rep(i, K){
    cin >> d;
    cnt[d]++;
  }

  vector<int> kouho;
  for(int i = 0; i < 10; i++){
    if(cnt[i] == 0){
      kouho.push_back(i);
    }
  }

  bool is_great = false;

  string ans = "";

  if(kouho[kouho.size()-1] < (N[0]-'0')){
    if(kouho[0] == 0){
      ans += char(kouho[1] + '0');
    }else{
      ans += char(kouho[0] + '0');
    }
    is_great = true;
  }
  
  rep(i, N.length()){

    if(!is_great){

      rep(j, kouho.size()){
        if(kouho[j] < (N[i] - '0')) continue;
        if(kouho[j] == (N[i]-'0')){
          ans += char(kouho[j] + '0');
          break;
        }else{
          ans += char(kouho[j] + '0');
          is_great = true;
          break;
        }
      }
    }else{
      ans += char(kouho[0] + '0');
    }
  }

  if(stoi(ans) < stoi(N)){
    ans = "";
    if(kouho[0] == 0){
      ans += char(kouho[1] + '0');
    }else{
      ans += char(kouho[0] + '0');
    }
    is_great = true;
    rep(i, N.length()){

    if(!is_great){

      rep(j, kouho.size()){
        if(kouho[j] < (N[i] - '0')) continue;
        if(kouho[j] == (N[i]-'0')){
          ans += char(kouho[j] + '0');
          break;
        }else{
          ans += char(kouho[j] + '0');
          is_great = true;
          break;
        }
      }
    }else{
      ans += char(kouho[0] + '0');
    }
  }
  }

  cout << ans << endl;

  return 0;
}


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

namespace ABC123B
{
    class MainClass
    {

        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {
            var lst = new List<int>();
            var zerolst = new List<int>();
            for (int i = 0; i < 5; i++)
            {
                int a = int.Parse(Console.ReadLine());
                if (a % 10 == 0)
                {
                    zerolst.Add(a);
                }
                else
                {
                    lst.Add(a);
                }
            }

            var alst = lst.ToArray();
            Array.Sort(alst, delegate (int x, int y) { return (x % 10).CompareTo(y % 10); });
            lst = alst.ToList();
            int ans = 0;
            if (lst.Count() != 0)
            {
                ans += lst.First();
                //Console.WriteLine("first+ " + lst.First());
                lst.RemoveAt(0);
            }
            if (lst.Count() != 0)
            {
               foreach(int item in lst)
                {
                    double d = (double)item / 10;
                    //Console.WriteLine(d);
                    int iitem = (int)(Math.Ceiling(d) * 10);
                    //Console.WriteLine("iitem+ " + iitem);
                    ans += iitem;
                }
            }
            if (zerolst.Count() != 0)
            {
                foreach(int item in zerolst)
                {
                    //Console.WriteLine("zeroitem+ " + item);
                    ans += item;
                }
            }
            Console.WriteLine(ans);


        }
    }
}


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

int main() {
    string S; cin >> S;
    int N = S.size();
    int ans = N, s = 0;
    rep(i, N) {
        if(S[i] == 'S') s++;
        else {
            if(s) s--, ans -= 2;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

int n,s;
vector<int> a;
ll mod = 998244353;

ll dp[3100][3100][2];

ll f(int i, int s, int fir){
	if(s<0){
		return 0;
	}
	if(s==0){
		// cout<<n<<" "<<i<<endl;
		return n-i+1;
		// return 1;
	}
	if(i==n){
		return 0;
	}
	if(dp[i][s][fir] != -1){
		return dp[i][s][fir];
	}

	ll ans =0;

	ans += f(i+1,s,fir);
	ans %= mod;
	// ans += f(i+1,s-a[i],fir);
	// ans %= mod;

	if(fir){
		ans += (i+1)*f(i+1,s-a[i],0);
		ans %= mod;
	}
	else{
		ans += f(i+1,s-a[i],0);
		ans %= mod;
	}
	dp[i][s][fir] = ans;
	return ans;
}

int main(){
	fastread;
	cin>>n>>s;
	a.resize(n);
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++){
		cin>>a[i];
	}

	cout<<f(0,s,1)<<endl;

	return 0;
}


Measured memory_bytes: 150656
arg1 = input().split()
arg2 = input()
N = arg1[0]
A = arg1[1]
B = arg1[2]
C = int(A) + int(B)
passed = 0
passed_f = 0
for i,s in enumerate(arg2):
    if s == 'a':
        if passed < C:
            passed += 1
            print('Yes')
            continue
    elif s == 'b':
        if passed < C and passed_f < int(B):
            passed += 1
            passed_f += 1
            print('Yes')
            continue
    print('No')

Measured memory_bytes: 4040
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	cout << (n + 1) / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;

	rep(i,n){
		cout<<s[i]<<t[i];
	}
	cout<<endl;


	return 0;
}



Measured memory_bytes: 3596
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

// The Incubator
// 2012/12/04
public class Main{
	Scanner sc=new Scanner(System.in);

	void run(){
		for(;;){
			int q=sc.nextInt();
			int lim=sc.nextInt();
			if((q|lim)==0){
				return;
			}

			BIT bit=new BIT(q);
			HashMap<Integer, Integer> map=new HashMap<Integer, Integer>();
			int[] a=new int[q];

			for(int i=0; i<q; i++){
				int query=sc.nextInt();
				int x=sc.nextInt();
				if(query==0){
					map.put(x, i);
					bit.add(i, 1);
					a[i]=x;
					if(bit.sum(0, q)>lim){
						int k=bit.get(0);
						bit.add(k, -1);
					}
				}else if(query==1){
					int k=bit.get(x-1);
					bit.add(k, -1);
				}else if(query==2){
					int k=bit.get(x-1);
					println(a[k]+"");
				}else if(query==3){
					int k=map.get(x);
					bit.add(k, -1);
				}
			}
			println("end");
		}
	}

	class BIT{
		int[] vs;

		BIT(int n){
			vs=new int[n+1];
		}

		void add(int k, int a){
			for(int i=k+1; i<vs.length; i+=i&-i){
				vs[i]+=a;
			}
		}

		int sum(int s, int t){
			if(s>0)
				return sum(0, t)-sum(0, s);
			int res=0;
			for(int i=t; i>0; i-=i&-i){
				res+=vs[i];
			}
			return res;
		}

		int get(int k){
			int p=Integer.highestOneBit(vs.length-1);
			for(int q=p; q>0; q>>=1, p|=q){
				if(p>=vs.length||k<vs[p])
					p^=q;
				else
					k-=vs[p];
			}
			return p;
		}
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 54000
N=int(input())
d=[]
for _ in range(N):
    d.append(list(map(int,input().split())))
d.sort(key=lambda x:x[1])
sum_d=[0]*N
sum_d[0]=d[0][0]
for i in range(N-1):
    sum_d[i+1]=sum_d[i]+d[i+1][0]

for i in range(N):
    if sum_d[i]>d[i][1]:
        print('No')
        exit()
print('Yes')

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

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

    string s[100000];
    for(int i=0;i<n;i++){
        char str[11];
        cin >> str;
        sort(str, str+10);
        s[i] = str;
    }

    sort(s, s+n);

    int64_t ans = 0, cur = 1;
    for(int i=1;i<n;i++){
        if(s[i-1]==s[i]) ++cur;
        else{
            ans += cur * (cur-1) / 2;
            cur = 1;
        }
    }
    ans += cur * (cur-1) / 2;

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

Measured memory_bytes: 5760
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;


int main() {
	int n;
	cin >> n;
	vector<long long> l(87);
	l[0] = 2;
	l[1] = 1;
	for (int i = 2; i <= n; i++) {
		l[i] = l[i-2] + l[i-1];
	}
	cout << l[n] << endl;
}

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

const int MAXN = 1e5+10;

int p[MAXN];
int tmp[MAXN];
int main() {
	int n;
	scanf("%d", &n);
	for(int i=1;i<=n;i++) {
		scanf("%d", &p[i]);
		tmp[i] = p[i];
	}

	int cnt1=0;
	for(int i=1;i<=n;i++) {
		if(i<n) {
			if(tmp[i]==i) {
				cnt1++;
				swap(tmp[i], tmp[i+1]);
			}	
		}
		else {
			if(tmp[i]==i) {
				cnt1++;
					
			}
			
		}
	}

	int cnt2=0;
	for(int i=1;i<=n;i++)
		tmp[i] = p[i];

	for(int i=n;i>=1;i--) {
		if(i>=2) {
			if(tmp[i]==i) {
				cnt2++;
				swap(tmp[i], tmp[i-1]);
			}	
		}
		else {
			if(tmp[i]==i) {
				cnt2++;
				swap(tmp[i], tmp[i+1]);	
			}
		}
	}
	// printf("%d %d\n", cnt1, cnt2);
	printf("%d", min(cnt1, cnt2));
	return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<vector>
#include<cstring>


using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	char k[]="keyence";
	char s[100+2];

	while(scanf("%100[a-z]\n", s)==1)
	{
		int sl=strlen(s);
		int kl=strlen(k);
		int mh=0, mt=0;

		for(int i=0;i<kl;i++)
		{
			if(s[i]!=k[i]) break;
			mh++;
		}
		for(int i=0;i<kl;i++)
		{
			if(s[sl-1-i]!=k[kl-1-i]) break;
			mt++;
		}

		int ans=(mh+mt>=kl);
		printf("%s\n", ans?"YES":"NO");
	}

	return 0;
}



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

using namespace std;

int main(void) {
        int n;
        vector<int> l;

        cin >> n;

        for (int i = 0; i < n; i++) {
                int tmp;
                cin >> tmp;
                l.push_back(tmp);
        }

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


        int count = 0;
        for (int i = 0; i < n; i++) {
                for (int j = i+1; j < n; j++) {
                        for (int k = j+1; k < n; k++) {
                                if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i])
                                        continue;
                                if (l[i] + l[j] > l[k])
                                        count++;
                        }
                }
        }

        cout << count << endl;

        return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int calc(char *fst, size_t f, char *snd, size_t s, char *ans, size_t a) {
	int buf = 0;

	while (a > 0) {
		if (f) {
			f--;
			buf += fst[f] - '0';
		}
		if (s) {
			s--;
			buf += snd[s] - '0';
		}
		a--;
		if ((ans[a] - '0') != (buf % 10)) {
			return 0;
		}
		buf /= 10;
	}
	return 1;
}

int main(void) {
	char in[130];
	char *first, *second, *answer;
	size_t f_len, s_len, a_len;
	char cf[130], cs[130], ca[130];
	const char *candidate, *c;
	int i;

	while (scanf("%s ", in) != EOF) {
		first = strtok(in, "+");
		second = strtok(NULL, "=");
		answer = strtok(NULL, "\n");

		f_len = strlen(first);
		s_len = strlen(second);
		a_len = strlen(answer);

		if (f_len > 1 && first[0] == 'X') {
			candidate = "123456789";
		} else if (s_len > 1 && second[0] == 'X') {
			candidate = "123456789";
		} else if (a_len > 1 && answer[0] == 'X') {
			candidate = "123456789";
		} else {
			candidate = "0123456789";
		}

		for (c = candidate; *c; c++) {
			for (i = 0; first[i]; i++) {
				cf[i] = first[i] != 'X' ? first[i] : *c;
			}
			cf[i] = '\0';
			for (i = 0; second[i]; i++) {
				cs[i] = second[i] != 'X' ? second[i] : *c;
			}
			cs[i] = '\0';
			for (i = 0; answer[i]; i++) {
				ca[i] = answer[i] != 'X' ? answer[i] : *c;
			}
			ca[i] = '\0';

			if (calc(cf, f_len, cs, s_len, ca, a_len)) {
				printf("%c\n", *c);
				c = NULL;
				break;
			}
		}
		if (c) {
			puts("NA");
		}
	}
	return 0;
}

Measured memory_bytes: 560
n = int(input())
a_list = list(map(int, input().split()))
sum_a = sum(a_list)
ans = 0
m = 10 ** 9 + 7

for i in range(n):
    sum_a -= a_list[i]
    ans += a_list[i] * sum_a
    ans %= m

print(ans)


Measured memory_bytes: 31552
#include <cstdio>

int n, x;

int main(){
	while(1){
		scanf("%d %d", &n,&x);
		if(n==0 && x==0){
			break;
		}else{
			int time=0;
			for(int i=1; i<=n-2; ++i){
				for(int j=i+1; j<=n-1; ++j){
					for(int k=j+1; k<=n; ++k){
						if(i+j+k==x){
							++time;
						}
					}
				}
			}
			printf("%d\n", time);
		}
	}
}


Measured memory_bytes: 2588
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));



int main(){
    vector<int> ans;
    while(true){
        int a, b;
        char op;
        cin >> a >> op >> b;
        if(op == '?') break;
        else if(op == '+') ans.push_back(a+b);
        else if(op == '-') ans.push_back(a-b);
        else if(op == '*') ans.push_back(a*b);
        else if(op == '/') ans.push_back(a/b);
    }
    for(int a : ans) cout << a << endl;
}


Measured memory_bytes: 3132
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S := sc.nextRuneSlice()
	K := sc.nextInt()
	sums := []int{}
	count := 1
	for i := 1; i < len(S); i++ {
		if S[i] == S[i-1] {
			count++
		} else {
			sums = append(sums, count)
			count = 1
		}
	}
	sums = append(sums, count)
	if len(sums) == 1 {
		fmt.Fprintln(wtr, (sums[0]*K)/2)
		wtr.Flush()
		return
	}
	ans := 0
	for _, s := range sums {
		ans += s / 2
	}
	if S[0] != S[len(S)-1] {
		ans *= K
	} else {
		startSum := sums[0]
		endSum := sums[len(sums)-1]
		extra := (startSum+endSum)/2 - startSum/2 - endSum/2
		ans = ans*K + extra*(K-1)
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

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

#define loop(i, n) for(int i = 0;i < n;i++)
#define IINF 2e9
#define MOD 1e9+7

int main(void){

    int n;
    cin >> n;
    vector<ll> a(n);
    bool flag = false;
    loop(i, n) {
        cin >> a[i];
        if(a[i] == 0){
            flag = true;
        }
    }

    if(flag){
        cout << 0 << endl;
        return 0;
    }

    long double logans = 0;
    ll ans = 1;

    cout << fixed << setprecision(30);

    loop(i, n){
        logans += log10l(a[i]);
        if(logans >= 18.5){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }

    cout << (ans > 1000000000000000000 ? -1 : ans) << endl;

    return 0;
}


Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
vector<int>arr(n);
for(int i=0; i<n; ++i)
cin>>arr[i];
sort(arr.begin(),arr.end());
reverse(arr.begin(),arr.end());
int sum(0);
for(int i=0; i<k; ++i)
sum+=arr[i];
cout<<sum;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    int x,a;
    cin>>x>>a;
    if(x<a)cout<<0;
    else cout<<10;
    return 0;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())

ans = [0, 0]

if k > a:
    ans[1] = a + b - k
    if ans[1] < 0:
        ans[1] = 0
else:
    ans[0] = a - k
    ans[1] = b

print(ans[0], ans[1])


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  Cinint(n);
  Cinstring(s);
  int64_t count = 0;
  int64_t Rcount = 0;
  int64_t Gcount = 0;
  int64_t Bcount = 0;
  rep(i, n) {
    if (s.at(i) == 'R') {
      Rcount++;
    }
    else if (s.at(i) == 'G') {
      Gcount++;
    }
    else {
      Bcount++;
    }
  }
  count = Rcount*Gcount*Bcount;
  rep(i, n-2) {
    for (int j = i+1; j < n-1; j++) {
      int sa = j-i;
      int k = j+sa;
      if (k <= n-1) {
        if (s.at(i) == 'R') {
          if (s.at(j) == 'G') {
            if (s.at(k) == 'B') {
              count--;
            }
          }
          else if (s.at(j) == 'B') {
            if (s.at(k) == 'G') {
              count--;
            }
          }
        }
        else if (s.at(i) == 'G') {
          if (s.at(j) == 'B') {
            if (s.at(k) == 'R') {
              count--;
            }
          }
          else if (s.at(j) == 'R') {
            if (s.at(k) == 'B') {
              count--;
            }
          }
        }
        else {
          if (s.at(j) == 'R') {
            if (s.at(k) == 'G') {
              count--;
            }
          }
          else if (s.at(j) == 'G') {
            if (s.at(k) == 'R') {
              count--;
            }
          }
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3556
n,m=map(int,input().split())
abc=[]
for i in range(m):
    a,b,c=map(int,input().split())
    abc.append([a-1,b-1,-c])
abc.sort()
INF=10**18
d=[INF]*n
chk=[False]*n
d[0]=0
for i in range(n-1):
    for a,b,c in abc:
        if d[b]>d[a]+c:
            d[b]=d[a]+c
for i in range(n):
    for a,b,c in abc:
        if d[b]>d[a]+c:
            d[b]=d[a]+c
            chk[b]=True
            chk[a]=True
if chk[n-1]==True:
    print('inf')
else:
    print(-d[n-1])

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


int main(){
  ll k;
  cin >> k;
  if(k%2==0){
    cout << "-1" << endl;
    return 0;
  }
  if(k%7==0){
    k=k/7;
  }
  while(k%10==0){
    k=k/10;
  }
  ll ans=0;
  bool ok=true;
  ll tot=1;
  while(ok){
    if(ans>=999983){
      cout << -1 << endl;
      return 0;
    }
    if(tot%k==0){
      ans++;
      ok=false;
      break;
    }else{
      tot*=10;
      tot+=1;
      tot%=k;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

int dp[100005];
int sum[26];

signed main() {
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    dp[n-1] = 1;
    sum[t[n-1] - 'a'] = 1;
    for (int i = n - 2;i >= 0;i--) {
        dp[i] = sum[s[i] - 'a'];
        sum[t[i] - 'a'] += dp[i];
        sum[t[i] - 'a'] %= mod;
    }
    cout << dp[0] << endl;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

ll dp[101][100001];//dp[i][j]: i(1-idx 0番は初期条件用)番目の子供の受け取る個数を決めるとき、キャンディがのこりjこの時の場合の数
ll ruisekiwa[101][100002];//累積和　DPの漸化式のブーストに使う idx i ~ idx j(i < j)で[i, j)
int N, K;
int A[101];

int main() {
	cin >> N >> K;
	for (int i = 1; i <= N; i++)cin >> A[i];
	ruisekiwa[0][0] = 0;
	for (int i = 1; i <= K + 1; i++) {
		ruisekiwa[0][i] = 1;
	}
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		for(int j = 0; j <= K; j++){
			int ulimit = max(0, j - A[i]);
			dp[i][j] = (ruisekiwa[i - 1][j + 1] - ruisekiwa[i - 1][ulimit] + MOD) % MOD;
			dp[i][j] %= MOD;

			ruisekiwa[i][j + 1] = ruisekiwa[i][j] + dp[i][j];
			ruisekiwa[i][j + 1] %= MOD;
		}
	}
	cout << dp[N][K] % MOD << endl;
	return 0;
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... Args> void rd(Args&... args) {((cin >> args), ...);}
template<typename... Args> void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto p=[](ll x){
        return x*x*x*x*x;
    };
    ll x;
    cin>>x;
    for(int a=0;a<=6000;a++){
        for(int b=-6000;b<a;b++){
            if(p(a)-p(b)==x){
                cout<<a<<' '<<b;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    long long int A,V,B,W,T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    if(V<W || (V==W && A!=B)){
        cout << "NO" << endl;
    }else if(A==B || abs(A-B)<=(V-W)*T){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n;
		double[] data1 =new double[1001];
		double[] data2 =new double[1001];
		double[] ans =new double[1001];
		double D=0,D2=0,D3=0,D4=0;

		n = sc.nextInt();
		for(int i=0;i<n;i++)data1[i]=sc.nextDouble();
		for(int i=0;i<n;i++)data2[i]=sc.nextDouble();
		for(int i=0;i<n;i++)ans[i] = data1[i]-data2[i];
		for(int i=0;i<n;i++){
			D +=Math.abs(ans[i]);
			D2 +=Math.pow(Math.abs(ans[i]),2);
			D3 +=Math.pow(Math.abs(ans[i]),3);
			if(Math.abs(ans[i])>D4)D4=Math.abs(ans[i]);
			
		}
		System.out.println(D);
		System.out.println(Math.sqrt(D2));
		System.out.println(Math.cbrt(D3));
		System.out.println(D4);
		
		sc.close();

	}

}



Measured memory_bytes: 29048
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	s = inp().strip();
	dic = defaultdict(int); dic[0] = 1
	# sett.add(0)
	ans = 0; cum = 0
	for i in range(len(s)-1, -1, -1):
		cum += (int(s[i])*pow(10, (len(s)-i-1), 2019)) % 2019
		cum %= 2019
		dic[cum] += 1
	# print(dic)
	for i in dic:
		ans += ((dic[i])*(dic[i]-1))//2
	print(ans)






if __name__ == "__main__":
	solve()

Measured memory_bytes: 9584
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <stdio.h>
#include <unistd.h>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define itrep(itr, base) for (auto itr = base.begin(); itr != base.end(); itr++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
#define PI 3.14159265359

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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;}

int main() {
  int h, w;
  cin >> h >> w;
  int c[10][10];
  rep(i, 10) rep (j, 10) cin >> c[i][j];

  map<int, int> mp;
  rep (i, 10) mp[i] = 0;
  rep (i, h) {
    rep (j, w) {
      int a;
      cin >> a;
      if (a != -1 && a != 1) {
        mp[a]++;
      }
    }
  }

  rep (m, 10) {
    rep (i, 10) {
      rep (j, 10) {
        if (i == j) continue;
        c[i][j] = min(c[i][j], c[i][m] + c[m][j]);
      }
    }
  }

  ll ans = 0;
  rep (i, 10) {
    if (i == 1) continue;
    ans += mp[i] * c[i][1];
  }
  P(ans);


  // rep (i, 10) {
  //   rep (j, 10) {
  //     cout << c[i][j] << " ";
  //   }
  //   cout << endl;
  // }



  return 0;
}



Measured memory_bytes: 256
/*
          .  .
          |\_|\
          | a_a\
          | | "]
      ____| '-\___
     /.----.___.-'\
    //        _    \
   //   .-. (~v~) /|
  |'|  /\:  .--  / \
 // |-/  \_/____/\/~|
|/  \ |  []_|_|_] \ |
| \  | \ |___   _\ ]_}
| |  '-' /   '.'  |
| |     /    /|:  |
| |     |   / |:  /\
| |     /  /  |  /  \
| |    |  /  /  |    \
\ |    |/\/  |/|/\    \
 \|\ |\|  |  | / /\/\__\
  \ \| | /   | |__
       / |   |____)
       |_/
*/

#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
using namespace std;
const int INF = 1e9;
int main()
{
    FLASH
    ll n;
    cin >> n;
    ll a[n],dp[n + 1];
    for(int i = 0; i <= n ; ++i)dp[i] = INF;
    for(int i = 0; i < n ; ++i)cin >> a[i];
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n && j <= i + 2; j++)
            dp[j] = min(dp[j],dp[i] + abs(a[i] - a[j]) );
    }
    cout << dp[n - 1];
    return 0;
}


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

class Test
{
    static void Main()
    {
        Dice dice1 = new Dice(Console.ReadLine());
        Dice dice2 = new Dice(Console.ReadLine());

        string move = "PPPPNPPPPNPPPPNPPPPEPPPPEEPPPP";
        int flag = 0;

        for (int i = 0; i < move.Length; i++)
        {
            //if (ReferenceEquals(dice1, dice2))
            if (dice1.d1 == dice2.d1 && dice1.d2 == dice2.d2 && dice1.d3 == dice2.d3 && dice1.d4 == dice2.d4 && dice1.d5 == dice2.d5 && dice1.d6 == dice2.d6)
            {
                Console.WriteLine("Yes");
                flag = 1;
                break;
            }

            switch (move[i])
            {
                case 'N':
                    dice2.North();
                    break;
                case 'E':
                    dice2.East();
                    break;
                case 'W':
                    dice2.West();
                    break;
                case 'S':
                    dice2.South();
                    break;
                case 'P':
                    dice2.Spin();
                    break;
            }
        }

        if (flag == 0) Console.WriteLine("No");
    }
}

class Dice
{
    string[] ss;
    public string d1, d2, d3, d4, d5, d6;

    public Dice(string s)
    {
        this.ss = s.Split();
        d1 = ss[0];
        d2 = ss[1];
        d3 = ss[2];
        d4 = ss[3];
        d5 = ss[4];
        d6 = ss[5];
    }

    string tmp;

    public void North()
    {
        tmp = d1;
        d1 = d2;
        d2 = d6;
        d6 = d5;
        d5 = tmp;
    }

    public void East()
    {
        tmp = d1;
        d1 = d4;
        d4 = d6;
        d6 = d3;
        d3 = tmp;
    }

    public void West()
    {
        tmp = d1;
        d1 = d3;
        d3 = d6;
        d6 = d4;
        d4 = tmp;
    }

    public void South()
    {
        tmp = d1;
        d1 = d5;
        d5 = d6;
        d6 = d2;
        d2 = tmp;
    }

    public void Spin()
    {
        tmp = d2;
        d2 = d4;
        d4 = d5;
        d5 = d3;
        d3 = tmp;
    }
}


Measured memory_bytes: 19884
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, ans = 0;
  cin >> N;
  vector<string> blue(N);
  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }
  cin >> M;
  vector<string> red(M);
  for (int i = 0; i < M; i++) {
    cin >> red.at(i);
  }
  for (int i = 0; i < N; i++) {
    int ac = 0;
    for (int j = 0; j < N; j++) {
      if (blue.at(i) == blue.at(j)) {
        ac++;
      }
    }
    for (int k = 0; k < M; k++) {
      if (blue.at(i) == red.at(k)) {
        ac--;
      }
    }
    ans = max(ans, ac);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
ans = []
add = ans.append
for line in open(0).readlines():
    H, W = map(int, line.split())
    if not H:
        break
    r = "#"*W+"\n"
    add(r)
    add(("#"+"."*(W-2)+"#\n")*(H-2))
    add(r)
    add("\n")
open(1, 'w').writelines(ans)



Measured memory_bytes: 5648
/*input
7
1 2 3 4 5 6 7
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    cin>>n;
    int b[n];
	REP(i,n){
        cin>>arr[i];
        b[i]=arr[i];
    }
    sort(b,b+n);
    int cnt=0;
    REP(i,n){
        if(arr[i]!=b[i]) ++cnt;
    }
    if(cnt==0 or cnt==2) cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.StringBuilder
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)
    val n = sc.nextInt()
    val arr = arrayOf(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
    println(arr[n - 1])
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31264
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

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

  vector<int>pm(101);
  for ( int i = 2; i <= N; i++ ) {
    int x = i;
    for ( int j = 2; x > 1; j++ ) {
      while(x%j==0) {
	pm[j]++;
	x /= j;
      }
    }
  }

  // for ( int i = 0; i <= 100; i++ ) {
  //    if ( pm[i] ) cout << i << " " << pm[i] << endl;
  //  }

  int ans = 0;

  for ( int i = 0; i <= 100; i++ ) if ( pm[i]>=74 ) ans++;

  for ( int i = 0; i <= 100; i++ ) {
    for ( int j = 0; j <= 100; j++ ) {
      if ( i == j ) continue;
      if ( pm[i]>=14 && pm[j]>=4 ) ans++;
      if ( pm[i]>=24 && pm[j]>=2 ) ans++;
    }
  }

  for ( int i = 0; i <= 100; i++ ) {
    for ( int j = 0; j <= 100; j++ ) {
      for ( int k = j+1; k <= 100; k++ ) {
	if ( i == j || i == k ) continue;
	if ( pm[i]>=2 && pm[j]>= 4 && pm[k]>=4 ) ans++;
      }    
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while(scan.hasNext()){
			char[] s = scan.next().toCharArray();
			int sum = 0;
			int i;
			
			for(i = 0; i < s.length - 1; i++){
				if(f(s[i]) >= f(s[i+1]))sum += f(s[i]);
				else{
					sum += f(s[i+1]) -f (s[i]);
					i++;
				}
			}
			
			if(i < s.length)sum += f(s[i]);
			System.out.println(sum);
		}
	}
	
	public static int f(char c){
		return c=='I'?1:
			c=='V'?5:
			c=='X'?10:
			c=='L'?50:
			c=='C'?100:
			c=='D'?500:1000;
	}
}

Measured memory_bytes: 25688
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	static final int INF = (int)1e9 + 7;
	int N,Ma,Mb;
	int[] A,B,C;

	public void solve() {
		N = nextInt();
		Ma = nextInt();
		Mb = nextInt();

		A = new int[N];
		B = new int[N];
		C = new int[N];

		for(int i = 0;i < N;i++){
			A[i] = nextInt();
			B[i] = nextInt();
			C[i] = nextInt();
		}

		int[][][] dp = new int[N+1][1000+10][1000+10];
		for(int i = 0;i < N + 1;i++){
			for(int j = 0;j < 1000 + 10;j++){
				for(int k = 0;k < 1000 + 10;k++){
					dp[i][j][k] = INF;
				}
			}
		}

		dp[0][0][0] = 0;
		for(int i = 0;i < N;i++){
			for(int j = 0;j < 1000+1 - A[i];j++){
				for(int k = 0;k < 1000+1 - B[i];k++){
					int a = j + A[i];
					int b = k + B[i];
					dp[i+1][j][k] = Math.min(dp[i+1][j][k], dp[i][j][k]);
					dp[i+1][a][b] = Math.min(dp[i+1][a][b],dp[i][j][k]+C[i]);
				}
			}
		}

		int ans = INF;
		int max = Math.max(Ma,Mb);
		for(int i = 1;i * max <= 1000;i++){
			ans = Math.min(ans,dp[N][i*Ma][i*Mb]);
		}
		if(ans == INF){
			out.println(-1);
		}else{
			out.println(ans);
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 222904
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string a, b; cin >> a >> b;
  int n = a.size();
  if (!count(begin(b), end(b), '1')) {
    if (count(begin(a), end(a), '1')) cout << -1 << '\n';
    else cout << 0 << '\n';
    return 0;
  }
  b += b + b;
  V<> l(n), r(n);
  for (int i = 0; i < n; ++i) {
    int j = 0;
    while (b[n + i - j] == '0') ++j;
    l[i] = j;
    j = 0;
    while (b[n + i + j] == '0') ++j;
    r[i] = j;
  }
  int res = 1e9;
  for (int s = 1; s < 2 * n; ++s) {
    V< pair<int, int> > p;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] == b[s + i]) continue;
      ++cnt;
      if (s <= n - l[i]) continue;
      if (n + r[i] <= s) continue;
      p.emplace_back(l[i] - max(n - s, 0), r[i] - max(s - n, 0));
    }
    sort(begin(p), end(p), [](const auto& l, const auto& r) {
      return l.first != r.first ? l.first > r.first : l.second < r.second;
    });
    int R = 0;
    for (const auto& e : p) {
      int L = e.first;
      res = min(res, cnt + abs(s - n) + 2 * (L + R));
      R = max(R, e.second);
    }
    res = min(res, cnt + abs(s - n) + 2 * R);
  }
  cout << res << '\n';
}

Measured memory_bytes: 384
from math import trunc
a, b = input().split()
a = int(a)
b = list(b)
b.remove(".")
b = "".join(b)
b.lstrip("0")
b = int(b)
answ = list(str(a*b))
answ.insert(-2, ".")
final = ""
for x in answ:
	if x != ".":
		final += x
	else:
		break
if final == "":
	print(0)
else:
	print(final)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int h,a;
    cin>>h>>a;
    if(h%a==0) cout<<h/a;
    else cout<<h/a+1;
}

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

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

int main()
{
	int N,K;
	cin >> N >> K;
	int M = (N-1)*(N-2)/2;
	if (K > M)
	{
		cout << "-1" << endl;
		return 0;
	}
	int ans = N-1 + (M-K);
	int cnt = M-K;
	cout << ans << endl;
	rep(i,N-1)
	{
		cout << 1 << " " << i+2 << endl;
	}
	int c = 1;
	while (cnt)
	{
		if ((N-1) % c == 0 && (N-1) / c == 2)
		{
			rep(j,(N-1)/2)
			{
				cout << j+2 << " " << (j+c)%(N-1)+2 << endl;
				cnt--;
				if (cnt == 0) break;
			}
			c++;
		}
		else
		{
			rep(j,N-1)
			{
				cout << j+2 << " " << (j+c)%(N-1)+2 << endl;
				cnt--;
				if (cnt == 0) break;
			}
			c++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

#include<string>

#define ll long long 

#include<vector>

using namespace std;

int gcd(int a,int b){

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

}

int main(){

  ll n;

  cin>>n;

  ll sum=0;

  for(int i=1;i<=n;i++){

  	  

	  for(int j=1;j<=n;j++){

  	  	int gcv=gcd(i,j);

  	  	

  	  	for(int k=1;k<=n;k++){

  	  		sum+=gcd(gcv,k);

  	  	}

	  }

  }

  cout<<sum;

   	 	 

}

Measured memory_bytes: 3188
#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>

using namespace std;

int main() {
  vector<int> mountains;
  for (int i = 0; i < 10; i++) {
    int mountain;
    scanf("%d", &mountain);
    mountains.push_back(mountain);
  }
  sort(mountains.begin(), mountains.end(), greater<int>());
  for (int i = 0; i < 3; i++) {
    printf("%d\n", mountains[0]);
    mountains.erase(mountains.begin());
  }
}

Measured memory_bytes: 2824
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a,b,c,d,amari;
			a = sc.nextInt();
			b = sc.nextInt();
			c = a;
			d = b;
			if(a<b){
				int x = a;
				a=b;
				b=x;
			}	
			while(a%b != 0){
				amari = a % b;
				a = b;
				b = amari;
			}
			int saidaikouyakusuu = b;
		
			int saisyoukoubaisuu = c/saidaikouyakusuu*d;

			System.out.println(saidaikouyakusuu+" "+saisyoukoubaisuu);
		}
	}
}



Measured memory_bytes: 26048
#include<stdio.h>

char c;
int f;
int nextInt();

int H, W, N, X, Y, low[200001], p, i;
int MAX = 524288;

int main(void){
	H=nextInt();
	W=nextInt();
	N=nextInt();
	for(i=2; i<=H; i++){
		low[i]=MAX;
	}
	for(i=0; i<N; i++){
		X=nextInt();
		Y=nextInt();
		if(Y<low[X]){
			low[X]=Y;
		}
	}
	for(i=2; i<=H; i++){
		if(low[i]+p==i){
			p++;
		}else if(low[i]+p<i){
			printf("%d\n", i-1);
			return 0;
		}
	}
	printf("%d\n", H);
	return 0;
}

int nextInt(){
	f=0;
	c = getchar();
	while((c<'0')||('9'<c)){
		c=getchar();
	}
	while((c>='0')&&(c<='9')){
		f=f*10+(c-'0');
		c=getchar();
	}
	return f;
}


Measured memory_bytes: 896