akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll N, M;
    str S, T;
    cin >> N >> M >> S >> T;
    ll ans;
    while (M > 0) {
        ans = N % M;
        N = M;
        M = ans;
    }
    const ll gcd = N;
    ll n = S.size() / gcd, m = T.size() / gcd;
    ll count = 0;
    rep(i, gcd) {
        ll a = i * n, b = i * m;
        if (S[a] == T[b]) {
            count++;
        }
        else {
            break;
        }
    }
    if (count == gcd) {
        cout << S.size() * T.size() /gcd << endl;
    }
    else {
        cout <<-1 << endl;
    }
}

Measured memory_bytes: 512
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;

  cout << x2 - (y2 - y1) << " " << y2 + (x2 - x1) << " " ;
  cout << x1 - (y2 - y1) << " " << y1 + (x2 - x1);

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

struct timer {
  double t = 0.0;
  timer() { restart(); }
  inline void restart() { t = now(); }
  inline double time() { return now() - t; }
  inline double now() {
    unsigned long long l, h;
    __asm__ ("rdtsc" : "=a"(l), "=d"(h));
    return (double)(l | h << 32) * 3.5714285714285715e-10;
  }
};

inline double randouble3() {
    static unsigned long long x = 147028549203948592LL;
    x = x ^ (x << 7);
    x = x ^ (x >> 9);
    double ret = x*5.472109e-25;
    if (x&1) ret *= -1;
    return ret;
}

inline double randouble2() {
    static unsigned long long x = 147028549203948592LL;
    x = x ^ (x << 7);
    x = x ^ (x >> 9);
    double ret = (x%10000000000000)*(0.00000000000001);
    if (x&1) ret *= -1;
    return ret;
}

inline double randouble1() {
    static unsigned long long x = 1520931673207987412LL;
    x = x ^ (x << 7);
    x = x ^ (x >> 9);
    double ret = (x%1000000000)*(0.00000001);
    if (x&1) ret *= -1;
    return ret;
}

double radius (double y, double x, const vector<pair<double, double>> &data) {
    double ret = -1;
    for (const auto &d : data) {
        double dx, dy; tie(dx, dy) = d;
        double dist = sqrt((y-dy)*(y-dy) + (x-dx)*(x-dx));
        chmax(ret, dist);
    }
    return ret;
}
timer t;
int main() {
    int N;
    cin >> N;
    vector<pair<double, double>> data(N);
    for (int i = 0; i < N; i++) {
        cin >> data[i].first >> data[i].second;
    }

    double ans_x = 500, ans_y = 500;
    double ans = 1000000000;
    while (t.time() < 0.001) {
        double nxt_x = ans_x + randouble1();
        double nxt_y = ans_y + randouble1();
        double score = radius(nxt_y, nxt_x, data);
        if (score < ans) { ans_x = nxt_x; ans_y = nxt_y; ans = score;}
    }
    //cout << fixed << setprecision(15) << ans << endl;
    while (t.time() < 1.000) {
        double nxt_x = ans_x + randouble2();
        double nxt_y = ans_y + randouble2();
        double score = radius(nxt_y, nxt_x, data);
        if (score < ans) { ans_x = nxt_x; ans_y = nxt_y; ans = score;}
    }
    
    while (t.time() < 1.990) {
        double nxt_x = ans_x + randouble3();
        double nxt_y = ans_y + randouble3();
        double score = radius(nxt_y, nxt_x, data);
        if (score < ans) { ans_x = nxt_x; ans_y = nxt_y; ans = score;}
    }
    
    cout << fixed << setprecision(15) << ans << endl;
    //cout << randouble3() <<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=200005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll n,a,b,c;

int main(){
	Init();
	cin>>n>>a>>b>>c;
	ll p=Div(a,a+b),q=Div(b,a+b),res=0;
	for(int i=0;i<n;i++){
		(res+=nCk(n+i-1,i)*Pow(p,n)%mod*Pow(q,i)%mod*(n+i))%=mod;
		(res+=nCk(n+i-1,i)*Pow(p,i)%mod*Pow(q,n)%mod*(n+i))%=mod;
	}
	cout<<res*Div(100,100-c)%mod<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)
using namespace std;


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll k,a,b;
    cin >> k >> a >> b;
    if(b-a<=2)
    {
        cout << k+1 << endl;
        return 0;
    }
    if(k<=a-1)
    {
        cout << k+1 << endl;
        return 0;
    }
    ll rem = k-(a-1);
    ll ans = a;
    ans += (rem/2)*(b-a);
    if(rem%2) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int rd(){
    int x=0,fl=1;char ch=gc();
    for (;ch<48||ch>57;ch=gc())if(ch=='-')fl=-1;
    for (;48<=ch&&ch<=57;ch=gc())x=(x<<3)+(x<<1)+(ch^48);
    return x*fl;
}
int n,i,j,b[102],x;
int main(){
	n=rd();
	for (i=1;i<=n;i++){
		x=rd();
		if (i<x) return puts("-1"),0;
		for (j=n;j>x;j--) b[j]=b[j-1];
		b[x]=x;
	}
	for (i=1;i<=n;i++) printf("%d\n",b[i]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
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; }


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

  ll n,k;
  cin>>n>>k;
  vll h(n);
  rep(i,n){cin>>h[i];}

  ll cnt=0;
  sort(h.begin(),h.end(), __greater());
  rep(i,n){  
    if(k>0){
      k--;
    }else{
      cnt+=h[i];
    }
  }

  cout<<cnt<<endl;
}

Measured memory_bytes: 4768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	int n;
	string test;
	cin >> n >> test;
	int ans = 0;

	for (int i = 0; i < n - 2; i++) {
		if (test[i] == 'A' && test[i + 1] == 'B' && test[i + 2] == 'C') {
			ans++;
		}
	}

	printf("%d", ans);

	return 0;
}



Measured memory_bytes: 3720
N, A, B = map(int, raw_input().split())
V = map(float, raw_input().split())
V.sort(reverse=True)

idx = V.index(V[A-1])
k = V.count(V[A-1])
avr = sum(V[:A]) / A
print "%f" % avr

def fact(n):
    if n < 1:
        return 1
    else:
        return n * fact(n-1)

if idx > 0:
    y = A - idx
    print fact(k) / fact(y) / fact(k-y)
else:
    cnt = 0
    for i in range(A, B+1):
        cnt += fact(k) / fact(i) / fact(k-i)
    print cnt


Measured memory_bytes: 2692
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  
    int n;
    cin>>n;
    int arr[n];
    rep(i,0,n)cin>>arr[i];
    int prev_max = arr[0];
    int sum = 0;
    for(int i = 0 ;i < n;i++){
        if(prev_max<arr[i]){
            prev_max= arr[i];
            continue;
        }
        else{
            sum+=abs(prev_max-arr[i]);
        }
    }
    cout<<sum<<endl;
    
 
    return 0;
}


Measured memory_bytes: 5164
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
res = a[0]
a.pop(0)

num = (n - 2) // 2
num1 = (n - 2) % 2
res += sum(a[:num]) * 2 + a[num] * num1
print(res)

Measured memory_bytes: 31520
import java.util.*;
 
public class Main {
  	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String str = sc.next();
      
      if (str.substring(2,3).equals(str.substring(3,4)) && 
         str.substring(4,5).equals(str.substring(5,6))) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 21844
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    if (n == 1) return false;

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

int main() {
    int Q;
    cin >> Q;
    vi a(100010, 0);
    vi b(100010, 0);
    int res = 0;
    rep(k, 0, a.size()) {
        if (k % 2 != 0) {
            if (is_prime(k)) {
                if (is_prime((k+1)*0.5)) {
                    ++res;
                    b[k] = 1;
                }
            }
        }
        a[k] = res;
    }

    rep(i, 0, Q) {
        int l, r;
        cin >> l >> r;
        if (l == r) {
            cout << b[r] << endl;
        } else {
            cout << a[r] - a[l-1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>

int main()
{
	int n;
	while (~scanf("%d", &n)) {
		if (n == 0)
			break;

		int max_p = 0, min_p = 500;
		for (int i = 0; i < n; ++i) {
			int sum = 0;
			for (int j = 0; j < 5; ++j) {
				int p;
				scanf("%d", &p);
				sum += p;
			}
			max_p = std::max(max_p, sum);
			min_p = std::min(min_p, sum);
		}

		printf("%d %d\n", max_p, min_p);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <valarray>
#define int long long
#define SIZE 10000
//#define _DEBUG
using namespace std;
int N, M, A, B, C, T, S[SIZE], U[SIZE];
struct Matrix {
    valarray<int> a;
    Matrix() : a(N*N) {a=0;}
};
Matrix mult(const Matrix& P, const Matrix& Q){
    Matrix R;
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            R.a[i*N + j] = (P.a[slice(i*N,N,1)]*Q.a[slice(j,N,N)]).sum() % M;
        }
    }
    return R;
}
Matrix pow(const Matrix& P, int p){
    if(p==0){
        Matrix I;
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                I.a[i*N + j] = ((i==j)? 1: 0);
            }
        }
        return I;
    }else if(p%2 == 0){
        Matrix Q = pow(P, p/2);
        return mult(Q, Q);
    }else{
        return mult(pow(P, p-1), P);
    }
}
void mat4vec(const Matrix& P){ //U <= M x S
    for(int i=0; i<N; i++){
        int t=0;
        for(int j=0; j<N; j++){
            t += P.a[i*N+j]*S[j] % M;
        }
        U[i] = t % M;
    }
}
void showMat(Matrix P){
    cout << "[";
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cout << P.a[N*i + j] << "\t";
        }
        cout << endl << " ";
    }
    cout << "]" << endl;
}
void solve(){
    Matrix P;
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(j-i == -1){
                P.a[i*N+j] = A;
            }else if(j-i == 0){
                P.a[i*N+j] = B;
            }else if(j-i == 1){
                P.a[i*N+j] = C;
            }else{
                //P.a[i*N+j] = 0;
            }
        }
    }
    P = pow(P, T);
    //showMat(P);
    mat4vec(P);
    for(int i=0; i<N; i++){
        S[i] = U[i];
        //cout << S[i] << endl;
    }
}
signed main(){
    while(cin>> N>>M>>A>>B>>C>>T && N>0){
        for(int i=0; i<N; i++){
            cin >> S[i];
        }
        solve();
        cout << S[0];
        for(int i=1; i<N; i++){
            cout << " " << S[i];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef int64_t lint;
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using lb = long double;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SI(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define debug(x) cerr << #x << ": " << x << "\n"//手動デバッグ
#define debugV(x) for(int i=0;i<((ll)(x).size());i++)cerr << #x <<"at:"<<i<< ": " << x[i] << "\n"//手動デバッグ 
#define YES(c) cout<<((c)?"YES\n":"NO\n"),0
#define Yes(c) cout<<((c)?"Yes\n":"No\n"),0
#define O(p) cout<<p<<"\n",0
#define OS(p) cout<<p<<" ",0
#define ON(p) cout<<p,0
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define endl "\n"//endlを置き換える
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定

const int dy[4]={1,0,-1,0};
const int dx[4]={0,1,0,-1};//^>v<

template<class T=int> T in(){
    T x;
    cin>>x;
    return (x);
}
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
//------------------------------------------------------------





//------------------------------------------------------------
int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
//------------------------------------------------------------
    int k,t;cin>>k>>t;
    vector<int> A(t);
    rep(i,t){
        cin>>A[i];
        A[i]*= -1;
    }
    
    sort(ALL(A));
    //debugV(A);
    ll ans=0;
    rep(i,k/2){
        if(A[1]!=0){
            A[0]++;
            A[1]++;
        }else{
            //ans++;
            //debug(i);
            break;
        }
        sort(ALL(A));
    }
    ll tmp=ans+abs(A[0])-1;
    if(tmp<=0){
        O(0);
    }else{
        O(tmp);
    }
    //O(ans+abs(A[0])-1);
    
    
    
    
    
    
//------------------------------------------------------------
	return 0;
}


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

using namespace std;

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = 0; j < m; j++) {
      int a;
      cin >> a;
      sum += a * b[j];
    }
    sum += c;
    if (sum > 0) {
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

int main()
{
    long long int a;
    cin>>a;
    if(a<=599) cout<<8<<endl;
    else if(a<=799) cout<<7<<endl;
    else if(a<=999) cout<<6<<endl;
    else if(a<=1199) cout<<5<<endl;
    else if(a<=1399) cout<<4<<endl;
    else if(a<=1599) cout<<3<<endl;
    else if(a<=1799) cout<<2<<endl;
    else if(a<=1999) cout<<1<<endl;
    return 0;
}


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

int main(void){
    // Your code here!
   float b;
   int a;
   cin >> a >> b;

   for(float i = (b*10); i < (b*10+10);i++){
       if(int(i*0.08) == a) {
           cout << i << endl;
           return 0;
       }
   }
   
   cout << -1 << endl;
}


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

int main() {
  int A, B, C, D, E, F;
  scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);

  double current = -1;
  double max_percent = (double)E / (double)(100 + E);
  int sugar_water = 0;
  int in_sugar = 0;

  for (int a = 0; a <= 30; a++) {
    for (int b = 0; b <= 30; b++) {
      int water = 100 * A * a + 100 * B * b;

      for (int c = 0; c <= 3000; c += C) {
        for (int d = 0; d <= 3000; d += D) {
          int sugar = c + d;

          if (water + sugar > F) {
            break;
          }

          double percent = (double)sugar / (double)(water + sugar);
          if (current < percent && percent <= max_percent) {
            sugar_water = water + sugar;
            in_sugar = sugar;
            current = percent;
          }
        }
      }
    }
  }
  printf("%d %d", sugar_water, in_sugar);
  return 0;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  
  int len = s.size();
  for(int i = 0; i < len; ++i){
    if(s[i] != t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
}


Measured memory_bytes: 3588
#include<stdio.h>
#include<math.h>
int prime(int);


int main(){
  int i,j,n,s,a=0,c=0;
  scanf("%d",&s);
  for(i=0;i<s;i++){
    scanf("%d",&n);
    a= prime(n);
    if(a==1) c++;
  }
  printf("%d\n",c);
  return 0;
}

int prime(int x){
  int i;
  if(x<=1)return 0;
  for(i=2;i<=sqrt(x);i++){
      if(x%i==0){
	return 0;
      }
  }
  return 1;
      }



Measured memory_bytes: 2084
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

class bipartite_matching {
public:
    int n;
    vector<vector<int>> g;
    vector<int> match;

    bipartite_matching(int n_) : n(n_), g(n_), match(n_), used(n_) {}

    void add_edge(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int maximum_matching(void) {
        int res = 0;
        fill(begin(match), end(match), -1);
        for (int v = 0; v < n; ++v) {
            if (match[v] == -1) {
                fill(begin(used), end(used), false);
                if (dfs(v)) res++;
            }
        }
        return res;
    }

private:
    vector<int> used;
    bool dfs(int v) {
        used[v] = true;
        for (int u : g[v]) {
            int w = match[u];
            if (w == -1 || (!used[w] && dfs(w))) {
                match[v] = u; match[u] = v;
                return true;
            }
        }
        return false;
    }
};

int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}

int n, m;
int a[500], b[500];

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

    while (cin >> n >> m && n) {
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        for (int i = 0; i < m; i++) {
            cin >> b[i];
        }

        bipartite_matching bm(n + m);

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (gcd(a[i], b[j]) != 1) {
                    bm.add_edge(i, n + j);
                }
            }
        }

        cout << bm.maximum_matching() << '\n';
    }
}

Measured memory_bytes: 4504
N,M = (int(x) for x in input().split())
X_arr = [int(x) for x in input().split()]

if N >= M:
    print("0")
    exit()

X_arr.sort()

D_arr = [X_arr[x+1]-X_arr[x] for x in range(len(X_arr)-1)]
D_arr.sort()

D_all = 0
for D in D_arr[:(M-N)]:
    D_all += D

print(D_all)


Measured memory_bytes: 13960
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
arr=[0]*N
d={'r':P,'s':R,'p':S}
for i,t in enumerate(T):
    if i-K>=0:
        if T[i-K]!=t or arr[i-K]==0:
            arr[i]=d[t]
    else:
        arr[i]=d[t]
print(sum(arr))

Measured memory_bytes: 4084
#include <iostream>

using namespace std;
int searchs(int A[], int n, int key){
	int i = 0;
	A[n] = key;
	while (A[i] != key) {
		i++;
	}
	return i!=n;
}
int main() {
	int i, n, A[10000+1], q, key, sum = 0;
	cin >> n;
	for(int i = 0; i<n; i++){
		cin >> A[i];
	}
	cin >> q;
	for(int i = 0; i<q; i++){
		cin >> key;
		if(searchs(A, n, key)) sum ++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3080
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int ar[3];

int main(){
    cin >> ar[0] >> ar[1] >> ar[2];
    sort(ar , ar + 3);
    cout << ar[0] + ar[1] << endl;
}


Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,d = map(int,ipt().split())
    d **= 2
    nm = 0
    for i in range(n):
        x,y = map(int,ipt().split())
        if x**2+y**2 <= d:
            nm += 1

    print(nm)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 70284
# AtCoder Beginner Contest 081 A
# [URL]      https://atcoder.jp/contests/abc081/tasks/abc081_a
# [compiler] Version 0.5.0
# [reference]
# <1> https://atcoder.jp/contests/abc081/submissions/3181551

#==================================================================================================#
function isTargetNum( char, target )
	return Base.ifelse( Base.isequal(char, target), 1, 0 )
end

function abc081_a()

	# STEP.01
	# get the target positive numbers
	buffer = Base.readline( Base.STDIN )

	# STEP.02
	# count up the target letter
	count =  Base.zero( Core.Int16 )
	count += Main.isTargetNum( buffer[1], '1' )
	count += Main.isTargetNum( buffer[2], '1' )
	count += Main.isTargetNum( buffer[3], '1' )

	# STEP.03
	# output the result
	Base.println( Base.STDOUT, count )

	# STEP.TRUE_END
	return Base.nothing

end

#==================================================================================================#

Main.abc081_a()


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

LL X,Y;

int main(){
	cin >> X >> Y;
	cout << (X%Y==0?-1:X) << endl;
	return 0;
}


Measured memory_bytes: 764
import java.util.*

fun main(args: Array<String>) {
    //ビンゴの縦チェック・横チェック・斜めチェックを愚直にやっていくぞ
    val sc = Scanner(System.`in`)
    val a = (0 until 9).map { sc.nextInt()}
    var mA = a.toMutableList()
    val n = sc.nextInt()
    repeat(n) {
        var b = sc.nextInt()
        if (mA.contains(b)) {
            mA[mA.indexOf(b)] = 0
        }
    }
    var res = "No"
    if (mA[0] == 0 && mA[3] == 0 && mA[6] == 0 || mA[1] == 0 && mA[4] == 0 && mA[7] == 0 || mA[2] == 0 && mA[5] == 0 && mA[8] == 0) {
        //縦チェック
        res = "Yes"
    } else if(mA[0] == 0 && mA[1] == 0 && mA[2] == 0 || mA[3] == 0 && mA[4] == 0 && mA[5] == 0 || mA[6] == 0 && mA[7] == 0 && mA[8] ==0) {
        //横チェック
        res = "Yes"
    } else if(mA[0] == 0 && mA[4] == 0 && mA[8] == 0 || mA[2] == 0 && mA[4] == 0 && mA[6] == 0) {
        //斜めチェック
        res = "Yes"
    }
    println(res)
}

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

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

    int target = 0;
    for(int i : a){
        target += i;
    }
    if((10*target / n)% 10 >= 5) target = target/n + 1;
    else target = target/n;

    int cost = 0;
    for(int i : a){
        cost += pow(i - target, 2);
    }
    cout << cost << endl;
}

Measured memory_bytes: 3632
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e3+4;

vector<pair<int,int>> v;

int n;

//dp[i][j] tells the best answer if we have processed till i-1 elements(and currently
//are at the ith element) and used the first j-1 places from the left to place some
//of the elements which we have taken now.

ll dp[N][N];

int main()
{
	scn(n);

	rep(i,0,n)
	{
		int val;

		scn(val); v.emplace_back(val,i);
	}

	//you will definetely try to give the largest element the most possible movement.
	sort(v.rbegin(),v.rend());

	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			dp[i][j]=(-1e18);

	dp[0][0]=0;

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		if(j<=i)
		{
			int right=j+(n-1-i);

			dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1LL*v[i].F*abs(v[i].S-j));

			dp[i+1][j] = max(dp[i+1][j],dp[i][j]+1LL*v[i].F*abs(v[i].S-right));
		}
	}

	ll ans=0;

	rep(i,0,n+1)
	ans=max(ans,dp[n][i]);

	lpri(ans);

    return 0;
}

Measured memory_bytes: 35184
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		if(M == 0) {
			if(N == 1)
				System.out.println(0);
			else if(N == 2)
				System.out.println(10);
			else
				System.out.println(100);
			return;
		}
		int[] ans = new int[N];
		boolean[] used = new boolean[N];
		for(int i = 0; i < M; i++) {
			int s = sc.nextInt();
			int c = sc.nextInt();
			if(used[s-1] && ans[s-1] != c) {
				System.out.println(-1);
				return;
			}
			ans[s-1] = c;
			used[s-1] = true;
		}
		if(used[0] && ans[0] == 0) {
			if(N == 1)
				System.out.println(0);
			else
				System.out.println(-1);
			return;
		}
		else if(ans[0] == 0)
			ans[0] = 1;
		for(int i = 0; i < N; i++)
			System.out.print(ans[i]);

	}

}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum = sum + x[i];
		}
		sc.close();

		int center = sum / n;
		if (sum % n > n / 2) {
			center++;
		}

		int answer = 0;

		for (int i = 0; i < n; i++) {
			answer = answer + (x[i] - center) * (x[i] - center);
		}

		print(answer);
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}


Measured memory_bytes: 23764
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int a,b;
    vector<int>start(26,-114514),end(26,-114514);
    for(int i=0;i<s.length();i++){
        a=s[i]-'a';
        b=t[i]-'a';
        if(start[a]!=-114514||end[b]!=-114514){
            if(start[a]!=b||end[b]!=a){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else{
            start[a]=b;
            end[b]=a;
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 776
/*
      author : nishi5451
      created: 11.08.2020 01:16:44
*/

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


int main(){
    char x,y;
    cin >> x >> y;
    if(x > y) cout << ">" << endl;
    else if(x < y) cout << "<" << endl;
    else cout << "=" << endl;
    return 0;
}

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

int MaxValue(int N){
    int V[N]={};
    int C[N]={};
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }
    int value=0;
    for(int i=0;i<N;i++){
        if(V[i]-C[i]>0){
            value+=V[i]-C[i];
        }
    }
    return value;
}

int main(){
    int N; cin >> N;
    cout << MaxValue(N) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	for(int i=1;i<=3;i++)
		if(a*b*i%2==1)
		{
			puts("Yes");
			return 0;
		}
	puts("No");
	return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		String s=scan.next();
		String t=scan.next();
		ArrayList<Integer>[] sad=new ArrayList[26];
		TreeSet<Integer> set[]=new TreeSet[26];
		int count1[]=new int[26];
		int count2[]=new int[26];
		for(int i=0;i<26;i++)
		{
			set[i]=new TreeSet<Integer>();
		}
		for(int i=0;i<s.length();i++)
		{
			count1[s.charAt(i)-'a']++;
			set[s.charAt(i)-'a'].add(i);
		}
		for(int i=0;i<t.length();i++) {
			count2[t.charAt(i)-'a']++;
		}
		for(int i=0;i<26;i++)
		{
			if(count1[i]==0 && count2[i]!=0)
			{
				System.out.println(-1);
				return;
			}
		}
		int pos=-1;
		long times=0;
		
		for(int i=0;i<t.length();i++)
		{
			int x=t.charAt(i)-'a';
//			int cur=set[x].higher(pos);
			if(set[x].last()<=pos) {
				times++;
				pos=set[x].first();
				
			}else {
				pos=set[x].higher(pos);
			}
//			System.out.print/ln(pos);
			
		}
		long ans=(s.length()*1L*times)+pos+1L;
		System.out.println(ans);
	
		
		
		
	}
}


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

int main()
{
	int time, tmp;

	cin >> time;

	tmp = time / 3600;
	cout << tmp << ":";
	time -= tmp * 3600;

	tmp = time / 60;
	cout << tmp << ":";
	time -= tmp * 60;

	cout << time << endl;

	return 0;

}

Measured memory_bytes: 3100
N = int(input())
A = [int(i) for i in input().split()]

ans = 0

sum_tmp = A[0]
xor_tmp = A[0]
l = 0
r = 1
while True:
        if r == N:
                ans += (r - l)
                if l == N - 1:
                        break
                else:
                        l += 1
                        continue

        if sum_tmp + A[r] == xor_tmp ^ A[r]:
                sum_tmp += A[r]
                xor_tmp ^= A[r]
                r += 1
                continue

        ans += (r - l)

        if l+1 == r:
                l += 1
                r += 1
                sum_tmp = A[l]
                xor_tmp = A[l]
                continue

        sum_tmp -= A[l]
        xor_tmp ^= A[l]
        l += 1

print(ans)

Measured memory_bytes: 23560
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, read().split())
if n % 2 == 1:
    for i in range(1, m + 1):
        print(i, n - i)
else:
    x, y = 0, 0
    for i in range(m):
        a, b = 2 * i, n - 2 * (i + 1)
        if a == b or (a == y and b == x):
            n -= 1
        x, y = a, b
        print(i + 1, n - i)


Measured memory_bytes: 9128
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;

    vector<int> a(n);
    vector<int> b(n);
    rep(i,0,n)
    {
        int x,y;
        cin>>x>>y;

        a[i] = x;
        b[i] = y;
    }

    sort(all(a));
    sort(all(b));

    if ( n % 2 == 0 )
    {
        cout<<(((b[n/2] + b[n/2 - 1]) - ((a[n/2] + a[n/2 - 1])))) + 1<<endl;
    }
    else
    {
        cout<<b[n/2] - a[n/2] + 1<<endl;
    }

}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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

int main(){
  int H,W;
  cin>>H>>W;

  char C[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>C[i][j];
    }
  }

  char ans[2*H][W];

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans[2*i][j] = C[i][j];
      ans[2*i+1][j] = C[i][j];
    }
  }

  for(int i=0;i<2*H;i++){
    for(int j=0;j<W;j++){
      cout<<ans[i][j];
    }
    cout<<"\n";
  }
return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int a, b;
  cin >> a >> b;
  if (a + b >= 10) cout << "error" << '\n';
  else cout << a + b << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3628
package main

import "fmt"

func SumOfDigit(N int) int {
  var sum int
  for N > 0 {
    sum += N % 10
    N /= 10
  }
  return sum
}

func main() {
  var N, A, B, ans int
  fmt.Scan(&N, &A, &B)
  for i := 1; i <= N; i++ {
    sum := SumOfDigit(i)
    if A <= sum && sum <= B {
      ans += i
    }
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define gcd(a,b)   __gcd(a,b)
#define lcm(a,b)   (a*b)/gcd
#define rep(i,n)   for(int i=0;i<n;i++)
#define Rep(i,n)   for(int i=1;i<=n;i++)
#define REP(i,j,n) for(int i=j;i<=n;i++)
#define fast   ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

int ar[10];

int ans(int n){

	int j;
    int flag=1;
    while(n){
    	j=n%10;
    	if(ar[j]==1){
    		flag=0;
    		break;
    	}
    	n=n/10;
    }
    if(flag==0) return 0;
    else return 1;

}

int main()
{ 
	fast;
    int n,k;
    cin>>n>>k;
    
    int x;
    memset(ar,0,sizeof(ar));
    rep(i,k){
         cin>>x;
         ar[x]=1;
    }
    for(int i=n; ; i++){
    	if(ans(i)==1){
    		cout<<i<<endl;
    		break;
    	}
    }
    return 0;
   


	

}

Measured memory_bytes: 3584
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <queue>

using namespace std;

const int INF = 100000000;
const int MAX_W = 1001;
const int MAX_H = 1001;
int H, W, N;
char field[MAX_H][MAX_W] = {'X'};
int d[MAX_H][MAX_W] = {INF};
typedef pair<int, int> P;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    queue<P> que;
    P start;
    int pow = 1;
    while (std::cin >> H >> W >> N, H) {
        for (int i = 0; i < H; i++) {
            std::cin >> field[i];
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                d[i][j] = INF;
                if (field[i][j] == 'S') {
                    start = P(i, j);
                }
            }
        }
        que.push(start);
        d[start.first][start.second] = 0;
        int count = 0;
        while (que.size()) {
            P p = que.front();
            que.pop();
            if (field[p.first][p.second] == '0' + N and N <= pow) {
                count = d[p.first][p.second];
                break;
            }

            for (int i = 0; i < 4; i++) {
                int nx = p.second + dx[i];
                int ny = p.first + dy[i];
                if (nx >= 0 and ny >= 0 and nx < W and ny < H and field[ny][nx] != 'X' and d[ny][nx] == INF) {
                    if (field[ny][nx] == '.') {
                        que.push(P(ny, nx));
                        d[ny][nx] = d[p.first][p.second] + 1;
                    } else {
                        if (field[ny][nx] <= '0' + pow) {
                            //cout << "pow:" << pow << ", cheese:" << field[ny][nx] << endl;
                            int s = d[p.first][p.second];
                            field[ny][nx] = '.';
                            for (int i = 0; i < H; i++) {
                                for (int j = 0; j < W; j++) {
                                    d[i][j] = INF;
                                }
                            }


                            while (que.size()) {
                                que.pop();
                            }
                            que.push(P(ny, nx));
                            d[ny][nx] = s + 1;
                            if(pow == N) {
                                field[ny][nx] = '0' + N;
                            }
                            pow++;
                            break;
                        } else {
                            que.push(P(ny, nx));
                            d[ny][nx] = d[p.first][p.second] + 1;
                        }
                    }
                }
            }
        }

        std::cout << count << std::endl;
        break;
    }

    return 0;
}

Measured memory_bytes: 7932
#include<bits/stdc++.h>
inline void upi(int&a,const int&b){a>b?a=b:0;}
const int N=2e5+5,mo=1e9+7;
int fac[N],inv[N],vf[N],n,i,ans,ct[N],ct2,X,Y,m11,m12,c11,m2[N],c[N],w[N];
bool b[N];
int main(){
	for(i=2,*fac=fac[1]=*vf=vf[1]=inv[1]=1;i<N;++i)
		fac[i]=1ll*fac[i-1]*i%mo,
		inv[i]=1ll*(mo-mo/i)*inv[mo%i]%mo,
		vf[i]=1ll*vf[i-1]*inv[i]%mo;
	scanf("%d%d%d",&n,&Y,&X);
	for(i=1;i<=n;++i)m2[i]=1<<30;m11=m12=1<<30;
	for(i=1;i<=n;++i){
		scanf("%d%d",c+i,w+i),upi(m2[c[i]],w[i]);
		if(w[i]<=m11)m12=m11,m11=w[i],c11=c[i];
			else if(w[i]<m12)m12=w[i];
	}
	for(i=1;i<=n;++i)if((c11!=c[i] && m11+w[i]<=X) || (c11==c[i] && m12+w[i]<=X))
		++ct[c[i]],++ct2,b[i]=1;
	for(i=1;i<=n;++i)if(!b[i] && ct[c[i]] && m2[c[i]]+w[i]<=Y)++ct[c[i]],++ct2;
	for(i=1,ans=fac[ct2];i<=n;++i)ans=1ll*ans*vf[ct[i]]%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6016
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
	Scanner in = new Scanner(System.in);
	int a = in.nextInt();
	int b = in.nextInt();
	int c = in.nextInt();
	if(a<b && b<c)System.out.println("Yes");
	else System.out.println("No");

    }
}



Measured memory_bytes: 26336
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(long long i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<ll>v;

int main() {
	int n;
	cin >> n;
	v.push_back(2);
	v.push_back(1);
	REP(i, 0, n - 1) {
		v.push_back(v[i] + v[i + 1]);
	}
	cout << v[n] << endl;
	return 0;
}

Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
c = [0]
flg = False
cnt = 0
for ss in s:
    if ss == 'C' and flg:
        cnt += 1
    flg = (ss == 'A')
    c.append(cnt)
# print(c)
for _ in range(q):
    l, r = map(int, input().split())
    # [l,r]

    res = c[r] - c[l - 1]
    if l >= 2 and s[l - 2:l] == 'AC':
        res -= 1
    print(res)


Measured memory_bytes: 6152
def solve(fld)
  $h.times do |y|
    fld[y].each_cons(2).with_index do |(a, b), x|
      if a != b
        fld[y][x], fld[y][x+1] = fld[y][x+1], fld[y][x]
        return true if search(adjust(fld.transpose.map{|ar| ar.reverse} ))
        fld[y][x], fld[y][x+1] = fld[y][x+1], fld[y][x]
      end
    end
  end
  false
end
  
def search(fld)
  return true if fld.flatten.all?{ |v| !v }
  ret_x = count(fld, $w)
  ret_y = count(fld.transpose, $h)
  return false if ret_x.size == 0 && ret_y.size == 0
  ret_x.each do |y, x|
    $n.times{ |i| fld[y][x + i] = nil }
  end
  ret_y.each do |y, x|
    $n.times{ |i| fld[x + i][y] = nil }
  end
  search(adjust(fld))
end
  
def count(fld, r)
  ret = []
  r.times do |y|
    fld[y].each_cons($n).with_index do |ar, x|
      next unless ar[0]
      ret << [y, x] if ar.all?{|v| v == ar[0] }
    end
  end
  ret
end
  
def adjust(fld)
  $w.times do |x|
    fld[x].map! { |v| v if /[A-Z]/ =~ v }.compact!
  end
  fld.map!{|ar| ar.fill(nil, ar.size...$h) }
end
  
$h, $w, $n = gets.split.map(&:to_i)
fld = $h.times.map{ gets.chomp.split('').map{ |v| v if /[A-Z]/ =~ v } }
puts solve(fld) ? 'YES' : 'NO'

Measured memory_bytes: 10372
import java.util.Scanner;
import java.io.PrintWriter;

class Main {
    static String maxVolume(int l) {
        double vol = l * l * l / 27.0;

        return String.format("%.12f", vol);
    }


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

        int l = Integer.parseInt(sc.next());

        out.println(maxVolume(l));
        out.flush();
    }
}


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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b ? gcd(b,a%b) : a;}

//head

bool isPal(string s){
	int i = 0;
	while(i < s.size()/2) {
		if(s[i] != s[s.size()-1-i]){
			return false;
			
		}
		i++;
	}
	return true;
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	string ans = ((isPal(s) && isPal(s.substr(0,(n-1)/2)) && isPal(s.substr((n-1)/2+1)) ? "Yes" : "No"));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
from itertools import product,combinations
from functools import reduce,lru_cache
import heapq

def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def rvfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:rvfunc(f)(*x,**kwargs) if all(vfunc(lambda y:isinstance(y,list))(x)) else f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

s=reader()

print(max(vfunc(len)(s[0][0].split('S'))))


Measured memory_bytes: 9516