akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var n uint32

	fmt.Scan(&n)

	t := make([][]int, n, n)
	for i := 0; i < int(n); i++ {
		t[i] = make([]int, n, n)
		for j := 0; j < int(n); j++ {
			t[i][j] = -1
		}
	}

	for i := 0; i < int(n); i++ {
		var a int
		fmt.Scan(&a)

		for j := 0; j < a; j++ {
			var x, y int
			fmt.Scan(&x)
			fmt.Scan(&y)
			x--
			t[i][x] = y
		}
	}

	answer := 0
	for b := 0; b < 1<<n; b++ {
		ok := true

		for i := uint32(0); i < n; i++ {
			for j := uint32(0); j < n; j++ {
				if (b>>i)&1 == 1 && (t[i][j] == 0 || t[i][j] == 1) && (b>>j)&1 != t[i][j] {
					ok = false
				}
			}
		}

		if ok {
			tmp := 0
			for i := uint32(0); i < n; i++ {
				tmp += (b >> i) & 1
			}

			if tmp > answer {
				answer = tmp
			}
		}
	}

	fmt.Println(answer)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll mod =1e9+7;
const ll maxi=2e6+5;
ll fac[maxi],inv[maxi],finv[maxi];
void cominit(){
  fac[0]=fac[1]=finv[0]=inv[1]=finv[1]=1;
  for(ll i=2;i<maxi;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(ll n,ll k){
  if(n<k||n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

ll powmod(ll a,ll n){
  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);
  cominit();
  ll k;
  string ss;cin>>k>>ss;
  ll t = ss.size()-1;
  ll n=1,ans=0;

  for(ll i=0;i<=k;i++){
    ans +=com(t+k-i,t)*(powmod(25,k-i)*n%mod)%mod;
    ans%=mod;
    n=n*26%mod;
  }
  cout<<ans<<endl;
  return 0;
  }


Measured memory_bytes: 51092
def main():
    n = int(input())
    L = []

    for i in range(n):
        a, b = map(int, input().split())  # 複数数値入力
        L.append([b, a])

    L.sort()
    sum = 0
    for l in L:
        sum += l[1]
        if sum > l[0]:
            print("No")
            return

    print("Yes")

main()

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

vector<pair<char, ll>> RLE(const string &S) {
    ll cnt = 0;
    vector<pair<char, ll>> res;
    for (ll i = 0; i < (ll) S.size(); i++) {
        cnt++;
        if (i == (ll) S.size() - 1) {
            res.emplace_back(S[i], cnt);
            break;
        }
        if (S[i] != S[i + 1]) {
            res.emplace_back(S[i], cnt);
            cnt = 0;
        }
    }
    return res;
}

void Main() {
    string S;
    cin >> S;
    ll ans = 0;
    auto X = RLE(S);
    cout << X.size() - 1 << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 2500
from collections import deque
d = deque()
d.extend(input())
q = int(input())
r = False
for i in range(q):
  qu = input().split()
  if qu[0] == "1":
    r = not r
  else:
    if (qu[1] == "1" and not r) or (qu[1] == "2" and r):
      d.extendleft(qu[2])
    else:
      d.extend(qu[2])

if r:
  d.reverse()

print(''.join(list(d)))


Measured memory_bytes: 71000
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   char s;
   cin>>s;
   s=char(s-'a'+1+97);
   cout<<s;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256
from collections import deque

if __name__ == "__main__":
    n, q = input().split()
    n, q = int(n), int(q)
    s = 0
    a = deque([list(map(str,input().split())) for _ in range(n)])

    while len(a):
        x = a.popleft()
        if int(x[1]) - q <= 0:
            s += int(x[1])
            print(x[0], s)
        else:
            x[1] = str(int(x[1]) - q)
            s += q
            a.append(x)


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

const int pri=1000000007;

template<int mod>
struct ModInt{
	int x;

	ModInt() : x(0){}
	ModInt(long long y) : x(y>=0 ? y%mod : (mod-(-y)%mod)){}

	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}

	ModInt operator-() const{return ModInt(-x);}
	ModInt operator+(const ModInt &p) const{return ModInt (*this)+=p;}
	ModInt operator-(const ModInt &p) const{return ModInt (*this)-=p;}
	ModInt operator*(const ModInt &p) const{return ModInt (*this)*=p;}
	ModInt operator/(const ModInt &p) const{return ModInt (*this)/=p;}
	bool operator==(const ModInt &p) const{return x==p.x;}
	bool operator!=(const ModInt &p) const{return x!=p.x;}
	friend ostream &operator<<(ostream &os, const ModInt &p){return os<<p.x;}
	friend istream &operator>>(istream &is,ModInt &a){
		int t;
		is>>t;
		a=ModInt<mod>(t);
		return (is);
	}

	ModInt inverse() const{
		int a=x, b=mod, u=1, v=0, t;
		while(b>0){
			t=a/b;
			a-=t*b;
			swap(a,b);
			u-=t*v;
			swap(u,v);
		}
		return ModInt(u);
	}
	
	ModInt pow(int e) const{
		long long a=1,p=x;
		while(e>0){
			if(e%2==0){p=(p*p)%mod; e/=2;}
			else {a=(a*p)%mod; e--;}
		}
		return ModInt(a);
	}
};

using modint=ModInt<pri>;
modint fact[100000+1000];

modint nCr(int n,int r){
	return fact[n]/fact[r]/fact[n-r];
}

signed main(){
	int N,K; cin>>N>>K;
	fact[0]=1;
	fact[1]=1;
	for(int i=1;i<=N+100;i++){
		fact[i]=i;
		fact[i]*=fact[i-1];
	}
	
	vector<int> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	sort(A.begin(),A.end());
	modint ans=0;
	for(int i=K-1;i<N;i++){
		modint a=A[i];
		ans+=a*nCr(i,K-1);
	}
	for(int i=N-K;i>=0;i--){
		modint a=A[i];
		ans-=a*nCr(N-i-1,K-1);
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 1792
s = list(input())
t = list(input())
s.sort()
t.sort()
t.reverse()
S=len(s)
T=len(t)
x = set(s)
y = set(t)
n = min(S, T)


for i in range(n):
  if ord(s[i]) > ord(t[i]):
    print('No')
    exit()
  elif ord(s[i]) < ord(t[i]):
    print('Yes')
    exit()
    
if x==y:
  if S<T:
    print('Yes')
    exit()
  else:
    print('No')
    exit()

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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 100111, inf = 1000111222;

vector<int> v[max_n];

vector<int> tout;
vector<int> pr[max_n];
int n, m;
int dp[max_n];
int dst[max_n];

bool vis[max_n];

void dfs(int cur) {
    vis[cur] = 1;
    for (int to : v[cur]) {
        if (!vis[to]) {
            dfs(to);
        }
    }
    tout.PB(cur);
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for (int i = 0; i < n + m - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        v[a].PB(b);
        pr[b].PB(a);
    }
    int start = -1;
    for (int i = 0; i < n; ++i) {
        if (pr[i].size() == 0) {
            if (start == -1) {
                start = i;
            } else {
                exit(228);
            }
        }
    }
    for (int i = 0; i < max_n; ++i) {
        dst[i] = -5;
    }
    dfs(start);
    dst[start] = 0;
    dp[start] = -1;

    while (!tout.empty()) {
        int cur = tout.back();
        dst[cur] = 0;
        tout.pop_back();
        for (int p : pr[cur]) {
            if (dst[p] == -5) {
                exit(229);
            }
            if (dst[p] + 1 > dst[cur]) {
                dst[cur] = dst[p] + 1;
                dp[cur] = p;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << dp[i] + 1 << "\n";
    }
    return 0;
}





Measured memory_bytes: 17788
#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__)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;

//dark power
#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
/*
vector<int> d(100000);
vector<int> b(100000);
class UnionFind{
	public:
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	signed find(signed x){
		if(d[x]==x){
			return x;
		}else{
			return d[x]=find(d[x]);
		}
	}
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	void unite(signed x,signed y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(b[x]<b[y]){
			d[x]=y;
		}else{
			d[y]=x;
			if(b[x]==b[y])b[x]++;
		}
	}
	bool same(signed x,signed y){return (find(x)==find(y));}
};
*/
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int w,a,b;
	cin>>w>>a>>b;
	if(a<=b&&a+w>=b||a<=b+w&&a+w>=b+w)cout<<0<<endl;
	else{
		if(a+w<b)cout<<b-(a+w)<<endl;
		else cout<<a-(b+w)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <vector>
#include <cstdio>
#include <algorithm>

using namespace std;

class Player{
public:
	int number;
	double time;
	
	Player(){
		number = 0;
		time = 0;
	}
	
	bool operator<( const Player& lhs ) const{
		return time < lhs.time;
	}
	bool operator>( const Player& lhs ) const{
		return time > lhs.time;
	}
};

int main(int argc, char const* argv[])
{
	vector<Player> race1( 8 );
	vector<Player> race2( 8 );
	vector<Player> race3( 8 );
	vector<Player> race( 18 );

	for( int i = 0;i < 8;i++ ){
		cin >> race1[i].number;
		cin >> race1[i].time;
	}
	for( int i = 0;i < 8;i++ ){
		cin >> race2[i].number;
		cin >> race2[i].time;
	}
	for( int i = 0;i < 8;i++ ){
		cin >> race3[i].number;
		cin >> race3[i].time;
	}

	sort( race1.begin(), race1.end(), greater<Player>() );

	printf("%d %.2f\n",race1[7].number, race1[7].time );
	printf("%d %.2f\n",race1[6].number, race1[6].time );
	race1.pop_back();
	race1.pop_back();

	sort( race2.begin(), race2.end() , greater<Player>());

	printf("%d %.2f\n",race2[7].number, race2[7].time );
	printf("%d %.2f\n",race2[6].number, race2[6].time );

	race2.pop_back();
	race2.pop_back();
	sort( race3.begin(), race3.end(), greater<Player>() );

	printf("%d %.2f\n",race3[7].number, race3[7].time );
	printf("%d %.2f\n",race3[6].number, race3[6].time );
	race3.pop_back();
	race3.pop_back();

	for( int i = 0;i < 6;i++ ){
		race[i] = race1[i];
		race[i + 6] = race2[i];
		race[i + 12] = race3[i];
	}

	sort( race.begin(), race.end(), greater<Player>() );

	
	printf("%d %.2f\n",race[17].number, race[17].time );
	printf("%d %.2f\n",race[16].number, race[16].time );
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE
//ABS, task 09, 2020/04/11
//ms, tle
/*
*/

int main(void){
  int N;
  string S;
  int64_t r=0;
  int g=0;
  int b=0;
  int64_t ans;

  cin >>N;
  cin >>S;

  for(int i=0;i<N;i++){
    if(S.at(i)=='R') r++;
    if(S.at(i)=='G') g++;
    if(S.at(i)=='B') b++;
  }

  ans = r*g*b;
  //cout <<"r:" <<r <<" g:"<<g <<" b:" <<b <<endl;


  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(S.at(i) != S.at(j) && 2*j-i<N){
        if(S.at(i) != S.at(2*j-i)
         &&S.at(j) != S.at(2*j-i)) ans--;
      }
    }
  }

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

/*
rgbrgb
8
,,,,,,
,,
*/


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

int main(){
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	vector<int> wa(0);
	vector<int> sh(0);
	for(int i=0; i>=0; i++){
		if(100*a*i >= f) break;
		for(int j=0; j>=0; j++){
			if(100*a*i+100*b*j >= f) break;
			wa.push_back(100*a*i+100*b*j);
		}
	}
	sort(wa.begin(), wa.end());
	for(int i=0; i>=0; i++){
		if(c*i*100 > f*e) break;
		for(int j=0; j>=0; j++){
			if((c*i+d*j)*100 > f*e) break;
			sh.push_back(c*i+d*j);
		}
	}
	sort(sh.begin(), sh.end());
	vector<int> w(0);
	vector<int> s(0);
	rep(i, wa.size()-1) if(wa.at(i+1) != wa.at(i)) w.push_back(wa.at(i+1));
	rep(i, sh.size()-1) if(sh.at(i+1) != sh.at(i)) s.push_back(sh.at(i+1));
	double ma = 0;
	int answs = w.at(0);
	int anss = 0;
	rep(i, w.size()){
		rep(j, s.size()){
			int ws = w.at(i) + s.at(j);
			double wsd = w.at(i) + s.at(j);
			if(ws > f) continue;
			double r = s.at(j);
			r *= 100;
			r /= w.at(i);
			double ed = e;
			if(r > ed) continue;
			if(r > ma){
				ma = r;
				answs = ws;
				anss = s.at(j);
			} 
		}
	}
	cout << answs << ' ' << anss << endl;
	return 0;
}


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

#include <bits/stdc++.h>


#define ll long long
#define ull unsigned long long
#define int ll
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 1e6 + 1 , LOG = 18;
int n ;
int a[N];

main(){
	//123456n
	//23456n1
	int n;
	cin >> n;
	cout << n * (n - 1) / 2;
}

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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	while (cin >> n, n) {
		vector<int> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a.begin(), a.end());
		a.pop_back();
		reverse(a.begin(), a.end());
		a.pop_back();
		cout << accumulate(a.begin(), a.end(), 0) / (n - 2) << endl;
	}
	return 0;
}



Measured memory_bytes: 3096
MOD = 10 ** 9 + 7

N = int(input())

ans = pow(10, N, MOD)
ans -= 2 * pow(9, N, MOD)
ans += pow(8, N, MOD)
ans %= MOD # 最後にMODを取り忘れないように気をつけましょう

print(ans)

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

int main() {
    REP(i,10000) {
        int a;
        cin >> a;
        if(a == 0) return 0;
        cout << "Case" << " " << i+1 << ":" << " " << a << endl;
    }
}


Measured memory_bytes: 3020
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a[4][4]={},aa[4]={},b[4]={};
	FOR(i,1,4){
		FOR(j,1,4){
			cin>>a[i][j];
		}
	}

	if(a[1][1]-a[1][2]!=a[2][1]-a[2][2]||a[2][1]-a[2][2]!=a[3][1]-a[3][2]){
		cout<<"No"<<endl;
		return 0;
	}
	if(a[1][3]-a[1][2]!=a[2][3]-a[2][2]||a[2][3]-a[2][2]!=a[3][3]-a[3][2]){
		cout<<"No"<<endl;
		return 0;
	}
	if(a[1][1]-a[2][1]!=a[1][2]-a[2][2]||a[1][2]-a[2][2]!=a[1][3]-a[2][3]){
		cout<<"No"<<endl;
		return 0;
	}
	if(a[3][1]-a[2][1]!=a[3][2]-a[2][2]||a[3][2]-a[2][2]!=a[3][3]-a[2][3]){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        h1: i32,
        m1: i32,
        h2: i32,
        m2: i32,
        k: i32,
    }
    println!("{}", (h2 - h1) * 60 + m2 - m1 - k);
}

Measured memory_bytes: 2120
#include <iostream>
#include <array>
using namespace std;
using uint = unsigned;
int main(){
    array<uint, 30> a = {};
    uint n,m;
    cin >> n >> m;
    for(uint i = 0; i < n; i++) {
        uint k;
        cin >> k;
        for(uint j = 0; j < k; j++) {
            uint tmp;
            cin >> tmp;
            a[tmp-1]++;
        }
    }

    uint cnt = 0;
    for(uint i = 0; i < 30; i++) {
        if (a[i] == n) {
            cnt++;
        }
    }
    cout << cnt << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int r = sc.nextInt();
		int c = sc.nextInt();

		int[][] sheet = new int[r + 1][c + 1];
		
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				int data = sc.nextInt();
				sheet[i][j] = data;
				sheet[i][c] += data;
				sheet[r][j] += data;
				sheet[r][c] += data;
			}
		}

		for (int i = 0; i < r + 1; i++) {
			StringBuffer line = new StringBuffer();
			for (int j = 0; j < c + 1; j++) {
				line.append(sheet[i][j]);
				if (j != c) {
					line.append(' ');
				}
			}
			System.out.println(line);
		}

		sc.close();
	}
}

Measured memory_bytes: 34724
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> v;
        PUSH(n,v);
        long maxv = -1e9;
        for(int i = 1; i <= n; i++) {
            vector<long> w;
            long j = 0;
            REP(k,i) j += v[k];
            w.push_back(j);
            REP(k,n-i) {
                j += -v[k] + v[i+k];
                w.push_back(j);
            }
            sort(w.begin(), w.end());
            maxv = max(maxv, w[w.size()-1]);
        }
        cout << maxv << endl;
    }
    return 0;
}

Measured memory_bytes: 1288
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = (1..n).map { readLine()!!.first() }
        .plus("MARCH".toList()).filter { it in "MARCH" }.groupBy { it }.map { it.value.size.toLong()-1 }


    var ans = 0L
    for(i in 0..4)for(j in i+1..4)for(k in j+1..4){
        ans+=s[i]*s[j]*s[k]
    }
    println(ans)
}

Measured memory_bytes: 37552
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<long double> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}

	long double b = 0;
	for (Int i = 0; i < N; i++) {
		b += (long double)1 / a[i];
	}

	printf("%.6Lf\n", (long double)1 / b);

	//Int all = 1;
	//for (Int i = 0; i < N; i++) {
	//	all *= a[i];
	//}

	//vector<Int> b(N);
	//for (Int i = 0; i < N; i++) {
	//	b[i] = all / a[i];
	//}

	//Int sum = 0;
	//for (Int i = 0; i < N; i++) {
	//	sum += b[i];
	//}

	////cout << (long double)all / (long double)sum << endl;
	//printf("%.6Lf\n", (long double)all / sum);
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ab = readln.split.to!(long[]);
    auto a = ab[0];
    auto b = ab[1];
    if (a > b) swap(a, b);
    long r;
    while (b) {
        r *= 10;
        r += a;
        --b;
    }
    writeln(r);
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_N 101
#define INF (1<<28)

int N;
int M[MAX_N][MAX_N];

int main() {
	int id, v, c, kx;
	int tmp;
	for (int ix = 0; ix < MAX_N; ++ix) {
		for (int jx = 0; jx < MAX_N; ++jx) {
			M[ix][jx] = ix == jx ? 0 : INF;
		}
	}
	scanf("%d\n", &N);
	for (int ix = 0; ix < N; ++ix) {
		scanf("%d %d", &id, &kx);
		while(kx--) {
			scanf("%d %d", &v, &c);
			M[id][v] = c;
		}
	}

	for (kx = 0; kx < N; ++kx)
		for (int ix = 0; ix < N; ++ix)
			for (int jx = 0; jx < N; ++jx) {
				tmp = M[ix][kx] + M[kx][jx];
				if( tmp < M[ix][jx] ) M[ix][jx] = tmp;
			}
	for (int ix = 0; ix < N; ++ix)
		printf("%d %d\n", ix, M[0][ix]);
	return 0;
}



Measured memory_bytes: 2056
//do not think about past and stay in this moment
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
int prime[1000005];
void seive(){
	for(int i=2;i<1000005;++i){
		if(prime[i]==0)
		for(int j=2*i;j<1000005;j+=i)
			prime[j]=1;
	}
}			
int digit(int n){
	int xp=0;
	while(n!=0){
		n/=10;
		xp++;
	}
	return xp;
}
void q1(){
	string s,t;
	cin>>s>>t;
	cout<<t<<s;
}
void q2(){
	int a,b,k;
	cin>>a>>b>>k;
	int mn=min(a,k);
	a-=mn; k-=mn;
	mn=min(b,k);
	b-=mn; k-=mn;
	cout<<a<<" "<<b;
}
void q3(){
	int x;
	cin>>x;
	seive();
	while(prime[x])
	x++;
	cout<<x<<endl;
}
void q4(){
	int n,k;	cin>>n>>k;
	int r,S,p;	cin>>r>>S>>p;
	string s;	cin>>s; 
	string ans="";
	for(int i=0;i<k;++i)
	ans+='w';
	for(int i=k;i<n;++i){
		if(s[i]==s[i-k] && ans[i-k]=='w')
		ans+='l';
		else
		ans+='w';
	}
	int score=0;
	for(int i=0;i<n;++i)
	if(ans[i]=='w'){
		if(s[i]=='r'){
			score+=p;
		} else if(s[i]=='p'){
			score+=S;
		}else{
			score+=r;
		}
	}
	cout<<score;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q4();
	return 0;
}
	


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

// 13の倍数は、3桁ごとに区切って判定できる、らしい。
// 和の差が13の倍数であるかで判定できる。

#define MOD 1000000007
	
long long dp[100005][13];

int main()
{
	string s;
	cin >> s;

	for(int i=0;i<100005;i++)
		for(int j=0;j<13;j++)
			dp[i][j]=0;

	dp[0][0]=1;

	for(int i=1;i<=s.size();i++)
	{
		for(int j=0;j<13;j++)
		{
			dp[i-1][j]%=MOD;
			if(s[i-1]=='?')
			{
				for(int k=0;k<=9;k++)
				{
					int nx=j*10+k;
					nx%=13;
					dp[i][nx]+=dp[i-1][j];
				}
			}
			else
			{
				int now=s[i-1]-'0';
				int nx=j*10+now;
				nx%=13;
				dp[i][nx]+=dp[i-1][j];
			}
		}
	}

	cout << dp[s.size()][5]%MOD << endl;
}

Measured memory_bytes: 10624
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;


int N, M;
int solve(vector<int> &v){
  int l = -1, r = (int)(v.size()), res = 0;
  while(r - l > 1){
    ++res;
    int m = (r + l) / 2;
    if(v[m] == M) break;
    else if(v[m] > M) r = m;
    else l = m;
  }
  return res;
}

int main() {
  while(cin >>N && N){
    vector<int> v(N);
    REP(i, N) cin >>v[i];
    cin >>M;
    cout <<solve(v) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>

#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 ll = long long;

using namespace std;



int main() {
    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
    bool suc = false;
    int cnt = 0;
    if(a<b){
        if(b<c) suc = true;
        else{
            while(cnt < k){
                cnt++;
                c *= 2;
                if(b<c){
                    suc = true;
                    break;
                }
            }
        }
    } else{
        while(cnt<k){
            cnt++;
            b *= 2;
            if(a<b){
                break;
            }
        }
        if(b<c) suc = true;
        else{
            while(cnt < k){
                cnt++;
                c *= 2;
                if(b<c){
                    suc = true;
                    break;
                }
            }
        }
    }
    if(suc) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}

Measured memory_bytes: 3632
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            try :
                if isCLKWISE(phU) : break
                else : del phU[-2]
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            try :
                if isCLKWISE(phL) : break
                else : del phL[-2]
            except IndexError : break
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])

Measured memory_bytes: 33192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int a,b;
    cin >> a >> b;
    int x = a+b;
    int y = a-b;
    int z = a*b;
    int saidai = max({x,y,z});
    cout << saidai << endl;
}

Measured memory_bytes: 3560
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

s = list(str(input()))
t = list(str(input()))

s.sort()
t.sort(reverse=True)

s = "".join(s)
t = "".join(t)

ans = sorted([s, t])
# print(ans)

if ans[0] == t:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9064
from collections import deque

H, W = [int(i) for i in input().split()]
S = [list(input()) for _ in range(H)]

white = sum(s.count(".") for s in S)

S[0][0] = "_"
Q = deque([(0, 0, 1)])
while Q:
    h, w, count = Q.popleft()
    if (h, w) == (H - 1, W - 1):
        print(white - count)
        quit()

    for nh, nw in [(h, w + 1), (h, w - 1), (h + 1, w), (h - 1, w)]:
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == ".":
            S[nh][nw] = "_"
            Q.append((nh, nw, count + 1))
print(-1)



Measured memory_bytes: 3436
#include <vector>
#include <iostream>
#define int long long
using namespace std;

const int N = 1e5 + 1, MOD = 1e9 + 7;

bool b[N][2];
int n, pos[N][2];
vector<int> adj[N];

int DFS(int i, int col, int pre) {
  if(b[i][col])
    return pos[i][col];
  b[i][col] = true;
  pos[i][col] = 1;
  for(int j : adj[i])
    if(j != pre) {
      if(col == 1)
        pos[i][col] *= DFS(j, 0, i);
      else
        pos[i][col] *= ((DFS(j, 0, i) + DFS(j, 1, i)) % MOD);
      pos[i][col] %= MOD;
  	}
  return pos[i][col];
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
  cin >> n;
  for(int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  
  cout << (DFS(1, 0, 0) + DFS(1, 1, 0)) % MOD;
}

Measured memory_bytes: 15872
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto A=vecin(9);
	vector<pair<int,int>> P(9);
	for(int i=0;i<9;i++){
		P[i].first=A[i];
		P[i].second=0;
	}
	int N=in();
	REP(i,N){
		int v=in();
		REP(j,9){
			if(P[j].first==v) P[j].second=1;
		}
	}

	bool exist=false;
	REP(i,3){
		bool e=true;
		REP(j,3){
			if(!P[j+i*3].second) e=false;
		}
		if(e){
			out("Yes");
			return 0;
		}
	}
	REP(j,3){
		bool e=true;
		REP(i,3){
			if(!P[j+i*3].second) e=false;
		}
		if(e){
			out("Yes");
			return 0;
		}
	}
	if(P[0].second && P[4].second && P[8].second){
		out("Yes");
		return 0;
	}
	if(P[2].second && P[4].second && P[6].second){
		out("Yes");
		return 0;
	}
	out("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
          
#define endl        "\n"
#define int         long long
#define all(v)      v.begin(),v.end()
#define sz(v)       (int)v.size()
#define pii         pair<int,int>
#define fi          first
#define se          second
#define mod         1e9+7
#define forn(i,a,b) for(int i=a;i<b;i++)
#define deb(x)      cout << #x << ' ' << x << endl
#define clock       cerr << 1000 * (double)clock() / (double)CLOCKS_PER_SEC << "ms" << endl;

void solve(){
	int n,m,x;
	cin>>n>>m>>x;
	int a[n][m+1];
	forn(i,0,n){
		forn(j,0,m+1) cin>>a[i][j];
	}
	int ans=LLONG_MAX;
	int und[m];
	forn(i,0,(1<<n)){
		memset(und,0,sizeof(und));
		int cnt=0;
		forn(j,0,n){
			if(i&(1<<j)){
				cnt+=a[j][0];
				forn(k,1,m+1) und[k-1]+=a[j][k];
			}
		}
		bool ok=true;
		forn(j,0,m) ok&=(und[j]>=x);
		if(ok) ans=min(ans,cnt);
	}
	if(ans==LLONG_MAX) ans=-1;
	cout<<ans<<endl;
}
 
int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3644
package main

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

func main() {
	N := nextInt()
	hist := map[string]int{}

	for i := 0; i < N; i++ {
		S := nextString()
		n, ok := hist[S]

		if ok {
			n++
		} else {
			n = 1
		}
		hist[S] = n
	}
	c := 0
	ans := make(strings, 0)

	for s, n := range hist {
		if c > n {
			continue
		}
		if c < n {
			ans = make(strings, 0)
			c = n
		}
		ans = append(ans, s)
	}

	sort.Sort(ans)
	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}

type strings []string

func (a strings) Len() int           { return len(a) }
func (a strings) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a strings) Less(i, j int) bool { return a[i] < a[j] }
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 31744
a,b=map(int,input().split())
if a<=0 and b>=0:
    print('Zero')
elif a>0 and b>0:
    print('Positive')
elif a<0 and b<0:
    if ((-a)-(-b)+1)%2==0:
        print("Positive")
    else:
        print("Negative")


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, string> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	ll n;
	cin >> n;
	map<string,ll> mp;
	rep(i,n){
		string s;
		cin >> s;
		mp[s]++;
	}

	vector<P> xx;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		auto tmp = *itr;
		xx.push_back(P(tmp.second, tmp.first));
	}

	sort(xx.begin(), xx.end());
	reverse(xx.begin(), xx.end());

	ll mm = xx[0].first;
	vector<string> anss;
	rep(i,xx.size()){
		if(xx[i].first == mm){
			anss.push_back(xx[i].second);
		}
	}

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

	rep(i,anss.size()){
		cout << anss[i] << endl;
	}

	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

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

Measured memory_bytes: 1156
module queue
  implicit none
  type :: JagArray
    integer,allocatable :: array(:)
  end type JagArray
  contains
  subroutine push(A,b)
  	integer,allocatable,dimension(:)::A
    integer::b
    A=[A,b]
  end subroutine
  subroutine pop(A)
  	integer,allocatable,dimension(:)::A
    A=A(2:)
  end subroutine
end module queue

use queue
integer N,M
integer X,Y
type(JagArray),allocatable,dimension(:)::EDGE
integer,allocatable,dimension(:)::DP
integer ans

read*,N,M
allocate(EDGE(N),DP(N))
do i=1,N
  EDGE(i)%array=[integer::]
end do
do i=1,M
  read*,X,Y
  call push(EDGE(X)%array,Y)
end do

DP = -1
ans = 0
do i=1,N
  if( DP(i)== -1)DP(i)=DFS(i)
  ans=max(ans,DP(i) )
end do

print"(I0)",ans

contains

recursive function DFS(u)result(res)
integer u,res

if(DP(u) >= 0)then
  res=DP(u)
else
  DP(u)=0
  do while(size(EDGE(u)%array)/=0)
    DP(u)=max(DP(u),DFS(EDGE(u)%array(1))+1)
    call pop(EDGE(u)%array)
  end do
  res=DP(u)
endif
end function DFS
end

Measured memory_bytes: 10496
-- ABC112 C - Pyramid
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  am <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
  putStrLn . unwords . map show $ solve am

solve :: [[Int]] -> [Int]
solve am = head . filter isOk $ [[x,y,centerH (x,y)] | x <- [0..100], y <- [0..100]]
  where
    isOk (cx:cy:ch:_) = all (\(x:y:h:_) -> height ch (x,y) (cx,cy) == h) am
    highest = last $ sortBy (\a b -> compare (a!!2) (b!!2)) am
    centerH = calcBackHeight highest

type Position = (Int, Int)
height :: Int -> Position -> Position -> Int
height h (x, y) (cx, cy) = max (h - (abs (x - cx)) - (abs (y - cy))) 0
calcBackHeight :: [Int] -> Position -> Int
calcBackHeight a (cx, cy) = h + (abs (x - cx)) + (abs (y - cy))
  where
    x = a !! 0
    y = a !! 1
    h = a !! 2


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 810114514
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int long long 

signed main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    Yes((abs(a-b)<=d&&abs(b-c)<=d)||(abs(a-c)<=d));
	return 0;
}

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

using namespace std;


#define MAXN 1000000
typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll x, y;
  cin >> x >> y;
  for (int i = 1; i < 10000; ++i) {
    if ((x*i)%y) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ins insert
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rev(i,a,b) for(int i=b;i>=a;i--)
#define boost ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL)
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N=101;
const int M=1001;
const int MXN=1000001;
const int inf=1e9;
const ll INF=1e18;
const ll mod=1e9+7;

int main(){
  int m,d;
  cin>>m>>d;
  int ans=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=d;j++){
      int a=j%10,b=j/10;
      if(a>=2&&b>=2&&a*b==i){
        ans++;
      }
    }
  }
  cout<<ans;
}


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

using namespace std;

#define intt long long

const int N = 105;
const int NN = 100005;

int n, W;

int v[N], w[N];

intt dp[NN];

int main() {

	cin >> n >> W;

	for (int i = 1; i <= n; i ++) {
		cin >> w[i] >> v[i];
	}

	for (int k = 1; k <= n; k ++) {
		for (int x = W; x >= 0; x --) {
			if (x - w[k] >= 0) {
				dp[x] = max(dp[x], v[k] + dp[x - w[k]]);
			}
		}
	}

	cout << dp[W] << '\n';
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

func main() {
	var M, D int
	fmt.Scan(&M, &D)
	var m, d int
	m = 1
	d = 1
	var ans int
	for {
		if d > D {
			m++
			d = 1
			if m > M {
				break
			}
		}
		d1 := d % 10
		d10 := d / 10
		// log.Println(m, d)
		if d1 >= 2 && d10 >= 2 && d1*d10 == m {
			ans++
		}
		d++
	}
	fmt.Println(ans)
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
int main()
{
	double m=100,n,s=0,a[114];
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i],s+=a[i];
	s=s/n;
	int p;
	for(int i=0;i<n;i++)
	{
		if(abs(s-a[(int)n-1-i])<=m)
		{
			p=n-1-i;
			m=abs(s-a[(int)n-1-i]);
		}
	}
	cout<<p<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(int, n);
  Cins(int, n, a);

  map<int, int> mp;
  rep(i, n) {
    mp[a[i] - 1]++;
    mp[a[i]]++;
    mp[a[i] + 1]++;
  }

  int mx = 0;
  for (auto e : mp) mx = max(mx, e.second);
  cout << mx << endl;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int a, b; cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++){
        string s = to_string(i);
        if(s[0] == s[4] && s[1] == s[3]) ans++;
    }
    cout << ans << endl;
}


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

int M, N, K;
vector<int> u, v;

int main()
{
    cin >> N >> M;
    vector<int> X(M), S;
    for (int i = 0; i < M; i++)
    {
        cin >> X[i];
    }
    sort(X.begin(), X.end());
    int ans = 0;
    for (int i = 0; i < M - 1; i++)
    {
        S.push_back(X[i + 1] - X[i]);
        ans += S.back();
    }
    sort(S.begin(), S.end());
    N--;
    if (M == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i <= M - 1 && i < N; i++)
    {
        ans -= S[M - 2 - i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1276
/*
  X以上の数について、素数かどうか判定すればよい
*/
#include <bits/stdc++.h>
using namespace std;

bool isPrime(int ans) {
  for (int i = 2; i * i < ans; i++) {
    if (ans % i == 0) return false;
  }
  return true;
}

int main() {
  int X; cin >> X;
  int ans;

  ans = X;
  while (!isPrime(ans)) ans++;

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

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> g(n, vector<int>());
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> dist(n);
  function<void(int, int)> Dfs = [&](int u, int p) {
    for (int v : g[u]) {
      if (v != p) {
        dist[v] = dist[u] + 1;
        Dfs(v, u);
      }
    }
  };
  dist[0] = 0;
  Dfs(0, -1);
  int u = max_element(dist.begin(), dist.end()) - dist.begin();
  dist[u] = 0;
  Dfs(u, -1);
  int d = *max_element(dist.begin(), dist.end());
  cout << (d % 3 == 1 ? "Second" : "First") << '\n';
  return 0;
}


Measured memory_bytes: 33708
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        list.add(s);
        while(true) {
            if(s % 2 == 0) s = s / 2;
            else s = s * 3 + 1;
            if(list.contains(s)) {
                System.out.println(list.size() + 1);
                return;
            } else {
                list.add(s);
            }
        }
    }
}


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

int main(){
  ll dp[4][100010];
  string S;
  cin>>S;
  int ss=S.size();
  char c;
  for(int i=0;i<ss;i++){
    c=S[i];
    if(i==0){
      if(c=='?'){
        dp[0][0]=3;
        dp[1][0]=1;
      }else if(c=='A'){
        dp[0][0]=1;
        dp[1][0]=1;
      }else{
        dp[0][0]=1;
        dp[1][0]=0;
      }
      dp[2][0]=0;
      dp[3][0]=0;
      continue;
    }
    if(c=='A'){
      dp[0][i]=dp[0][i-1];
      dp[1][i]=dp[1][i-1]+dp[0][i-1];
      dp[2][i]=dp[2][i-1];
      dp[3][i]=dp[3][i-1];
    }
    if(c=='B'){
      dp[0][i]=dp[0][i-1];
      dp[1][i]=dp[1][i-1];
      dp[2][i]=dp[2][i-1]+dp[1][i-1];
      dp[3][i]=dp[3][i-1];
    }
    if(c=='C'){
      dp[0][i]=dp[0][i-1];
      dp[1][i]=dp[1][i-1];
      dp[2][i]=dp[2][i-1];
      dp[3][i]=dp[3][i-1]+dp[2][i-1];
    }
    if(c=='?'){
      dp[0][i]=dp[0][i-1]*3;
      dp[1][i]=dp[1][i-1]*3+dp[0][i-1];
      dp[2][i]=dp[2][i-1]*3+dp[1][i-1];
      dp[3][i]=dp[3][i-1]*3+dp[2][i-1];
    }
    dp[0][i]%=1000000007;
    dp[1][i]%=1000000007;
    dp[2][i]%=1000000007;
    dp[3][i]%=1000000007;
  }
  cout<<dp[3][ss-1]<<endl;
}

Measured memory_bytes: 3584
#!/usr/bin/env python3
n, k, *x = map(int, open(0).read().split())
ans = 10**18
neg = [i for i in x if i<0]+[0]
pos = [0]+[i for i in x if i>=0]
l = len(neg) -max(0, k + 1 - len(pos))
r = min(k+1, len(pos))
while l > 0 and r > 0:
    l -= 1
    r -= 1
    ans = min(ans, -neg[l] * 2 + pos[r], -neg[l] + pos[r] * 2)
print(ans)


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

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

  int n; cin >> n;
  vector<int> f(n+1, 1);
  for(int i = 2; i <= n; i++){
    f[i] = f[i-1] + f[i-2];
  }

  cout << f[n] << endl;

  return 0;
}

Measured memory_bytes: 1196
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc171_a.cpp"

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

  char a;
  cin >> a;
  if (0 <= a - 'a' && a - 'a' < 26) {
    cout << "a" << endl;
  }
  if (0 <= a - 'A' && a - 'A' < 26) {
    cout << "A" << endl;
  }
  return 0;
}


Measured memory_bytes: 3652