akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Comparator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DKatanaThrower solver = new DKatanaThrower();
        solver.solve(1, in, out);
        out.close();
    }

    static class DKatanaThrower {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), h = in.nextInt();
            PriorityQueue<DKatanaThrower.Action> a = new PriorityQueue<>(Comparator.comparing(x -> -x.damage));
            for (int i = 0; i < n; i++) {
                a.add(new DKatanaThrower.Action(false, in.nextInt()));
                a.add(new DKatanaThrower.Action(true, in.nextInt()));
            }
            int ans = 0;
            while (h > 0) {
                DKatanaThrower.Action x = a.poll();
                if (!x.last) {
                    ans += (h + x.damage - 1) / x.damage;
                    break;
                }
                h -= x.damage;
                ans++;
            }
            out.println(ans);
        }

        private static class Action {
            boolean last = false;
            int damage = 0;

            public Action(boolean last, int damage) {
                this.last = last;
                this.damage = damage;
            }

        }

    }
}



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

int main() {
  long long N;
  cin >> N;
  
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A[i];
  
  long long ans=0;
  long long sum=0;
  long long kari=0;
  
  for(int i=0;i<N;i++) sum += A[i];
  
  for(int i=0;i<N;i++){
    sum -= A[i];
    kari = sum % 1000000007;
    ans += A[i] * kari;
    ans %= 1000000007;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3968
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
string str;
vector<int> tot[30];
int main()
{
	cin>>str;
	int len=str.length();
	for(int i=0;i<len;i++)
		tot[str[i]-'a'].push_back(i);
	for(int i=0;i<26;i++)
		for(int m=0;m<tot[i].size();m++)
			for(int n=m+1;n<tot[i].size();n++)
				if((n-m+1)*2>tot[i][n]-tot[i][m]+1)
				{
					printf("%d %d\n",tot[i][m]+1,tot[i][n]+1);
					return 0;
				}
	printf("-1 -1\n");
	return 0;
}


Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
const int M = 1000 + 10;
int n;
int main()
{
    //freopen("in.txt","r",stdin);
    cin >> n;
    vector <string> r;
    vector <string> :: iterator it;
    bool vis = false;
    char pre,now;
    string te;
    for(int i=0;i<n;i++)
    {
        cin >> te;
        if(i == 0){
            r.push_back(te);
            pre = te[te.size()-1];
            continue;
        }
        now = te[0];
        if(now != pre){
            vis =true;
            //cout << "前后不对" << endl;
        }
        it = find(r.begin(),r.end(),te);
        if(it != r.end())
        {
            vis = true;
            //cout << "*it = " << *it << endl;
        }
        r.push_back(te);
        pre = te[te.size()-1];
        //cout << now << endl;
    }
    if(vis == true) cout << "No";
    else cout << "Yes" ;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  for(int i=n;i>0;i--){
    rep2(j,1,32){
      rep2(k,2,11){
        if(pow(j,k)==i){
          cout<<i<<endl;
          goto out;
        }
      }
    }
  }
out:
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> xy(n);
  vector<int> vx(n), vy(n);
  rep(i, n){
    int x, y;
    cin >> x >> y;
    xy.at(i) = {x, y};
    vx.at(i) = x;
    vy.at(i) = y;
  }
  sort(ALL(vx));
  sort(ALL(vy));
  ll ans = 5e18;
  rep(il, n){
    rep2(ir, il, n){
      int l = vx.at(il), r = vx.at(ir);
      rep(id, n){
        rep2(iu, id, n){
          int d = vy.at(id), u = vy.at(iu);
          int co = 0;
          rep(j, n){
            if(xy.at(j).first < l) continue;
            if(xy.at(j).first > r) continue;
            if(xy.at(j).second < d) continue;
            if(xy.at(j).second > u) continue;
            co++;
          }
          if(co >= k){
            ll add = (ll)(r-l) * (u-d);
            ans = min(ans, add);
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};

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

int n;

void aa(vector<int> &v,int m,int pow){
  if(pow > n)return;
  v[m] += (n/pow);
  aa(v,m,pow*m);
}

int main(){

  cin >> n;
  vector<int> v(1010,0);
  for(int i = 2;i <= n;i++){
    if(!isprime(i))continue;
    aa(v,i,i);
  }
  ll res = 1;
  REP(i,n+1){
    if(v[i] == 0)continue;
    res = res*(v[i]+1)%MOD;
  }
  cout << res << endl;




  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  int H,W,h,w;
  cin >> H >> W >> h >> w;
  cout << H*W-h*W-w*H+h*w << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> now(3, 0);
    rep(i, N) {
        int t, x, y;
        cin >> t >> x >> y;
        int t_diff = t - now[0];
        int xy_diff = abs(x - now[1] + y - now[2]);
        if (t_diff < xy_diff) {
            cout << "No" << endl;
            return 0;
        } else {
            if (t_diff % 2 != xy_diff % 2) {
                cout << "No" << endl;
                return 0;
            }
        }
        now[0] = t;
        now[1] = x;
        now[2] = y;
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
 int n,ans=0;cin >> n;
  vector<int> r(n),l(n),cnt(n);
  for(int i=0;i<n;i++){
   cin >> l[i] >> r[i];
    cnt[i]=r[i]-l[i]+1;
    ans+=cnt[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
    int a;
    cin>>a;
    int b[a+10];
    for(int i=0;i<a;++i){
        cin>>b[i];
    }
    
    int MIN,MAX,rec=0,ans=0,flag=0;
    for(int i=0;i<100;++i){
        for(int j=0;j<a;++j){
            if(b[j] > i && flag==0){
                ++flag;
                ++rec;
            }
            else if(b[j] <= i && flag==1){
                --flag;
            }
        }
        ans += rec;
        rec = 0;
        flag = 0;
    }
    cout<<ans;
}

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

#define int long long

signed main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l = a+b;
    int r = c+d;
    if(l>r) cout << "Left" << endl;
    else if(l==r) cout << "Balanced" << endl;
    else cout << "Right" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, x;
  cin >> N >> x;
  vector<ll> a(N);
  rep(i, 0, N){
    cin >> a[i];
  }

  vector<vector<ll> > a_min(N, vector<ll>(N));
  rep(i, 0, N){
    a_min[0][i] = a[i];
    rep(j, 1, N){
      a_min[j][i] = min(a_min[j-1][i], a[(i+j)%N]);
    }
  }

  ll count=0;
  rep(i, 0, N){
    count += a_min[0][i];
  }

  rep(j, 1, N){
    ll count_tmp=j*x;
    rep(i, 0, N){
      count_tmp += a_min[j][i];
    }
    count = min(count, count_tmp);
  }

  cout << count << "\n";

  return 0;
}


Measured memory_bytes: 31616
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  int i;
  for(i=0;i<a;i++){
    if('0' <= s[i] && s[i] <= '9') continue;
    else{
      cout << "No" << "\n";
      return 0;
    }
  }
  if(s[a] != '-'){
    cout << "No" << "\n";
    return 0;
  }
  for(i=a+1;i<a+b+1;i++){
    if('0' <= s[i] && s[i] <= '9') continue;
    else{
      cout << "No" << "\n";
      return 0;
    }
  }
  cout << "Yes" << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int a, b;
	cin >> a >> b;
	if ((a - (2 * b)) > 0) {
		cout << (a - (2 * b)) << endl;
	} else {
		cout << 0 << endl;
	}

	return 0;
}

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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

int binary_search(VI& a, int key) {
    int left = 0, right = (int)a.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (a[mid] == key) return mid;
        else if (a[mid] > key) right = mid - 1;
        else if (a[mid] < key) left = mid + 1;
    }
    return -1;
}

void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

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

	int n;
	cin>>n;

  VI v;
  priority_queue<int> que;
  REP(i,n){
    int a;cin>>a;
    v.push_back(a);
    que.push(a);
  }
  
  REP(i,n){
    int ans = que.top();
    if(ans==v[i]){
      int tmp=ans;
      que.pop();
      ans=que.top();
      que.push(tmp);
    }
    cout << ans<< endl;
  }

  return 0;
}

Measured memory_bytes: 3436
#include <stdio.h>
#include <math.h>

int c=0,n;
typedef struct XY{
  double x;
  double y;
}XY;

XY add(XY p1,XY p2){
  XY p3 = {p1.x+p2.x,p1.y+p2.y};
  return p3;
}

double bunkatu(XY p1, XY p2,int c){
  if(c>=n){return 0;}

  XY p3 = {((p2.x-p1.x)/3.0),((p2.y-p1.y)/3.0)};
  XY s=add(p1,p3);
  XY t=add(s,p3);
  XY u;

 //if(p1.x<p2.x){
   u.x=((t.x-s.x)*cos(M_PI/3)-(t.y-s.y)*sin(M_PI/3))+s.x;
   u.y=((t.x-s.x)*sin(M_PI/3)+(t.y-s.y)*cos(M_PI/3))+s.y;
// }else{
 //  u.x=((t.x-s.x)*cos(-M_PI/3)-(t.y-s.y)*sin(-M_PI/3))+s.x;
 //  u.y=((t.x-s.x)*sin(-M_PI/3)+(t.y-s.y)*cos(-M_PI/3))+s.y;
 //}

  bunkatu(p1,s,c+1); 
  printf("%f %f\n",s.x,s.y); 
  bunkatu(s,u,c+1);
  printf("%f %f\n",u.x,u.y); 
  bunkatu(u,t,c+1);
 printf("%f %f\n",t.x,t.y);
  bunkatu(t,p2,c+1);
}

int main(){
scanf("%d",&n);
printf("%f %f\n",0.0,0.0);
XY p1={0,0},p2={100.0};
  bunkatu(p1,p2,0);

printf("%f %f\n",100.0,0.0);
  return 0;
}

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int K = cin.nextInt();
        long ret = 0;
        for (int i = 0; i < K; i++)
        {
            if (i == (K - i) % K)
            {
                ret += ModNum(N, K, i) * ModNum(N, K, (K - i) % K) * ModNum(N, K, i);
            }
        }
        Console.WriteLine(ret);
    }

    long ModNum(long N, long K, long mod)
    {
        return (N + mod) / K;
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}





Measured memory_bytes: 13140
#include<stdio.h>

int main(void){
  char str[3];
  int ans,i;
  
  ans = 0;
  
  scanf("%s",&str);
  
  for(i=0;i<3;i++){
    if(str[i]=='7'){
      ans = 1;
    }
  }
  
  if(ans){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 2e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

// ARC077
int fact[MAX_N];
int ifact[MAX_N];
 
int power(int x, int n) {
	int res = 1LL;
	while (n > 0) {
		if (n & 1) (res *= x) %= MOD;
		(x *= x) %= MOD;
		n >>= 1;
	}
	return res % MOD;
}
 
int inv(int x) {
	return power(x, MOD - 2);
}
 
int nCr(int n, int r) {
	if (n < 0 || r < 0 || r > n) return 0;
	if (r > n / 2) r = n - r;
	return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

signed main() {
  INIT;
	VAR(int, n);
	VEC(int, a, n + 1);

	fact[0] = ifact[0] = 1;
	FOR(i, 1, MAX_N) {
		fact[i] = (fact[i - 1] * i) % MOD;
		ifact[i] = inv(fact[i]);
	}

	int d = 0;
	vector< int > t(MAX_N, -1);
	REP(i, n + 1) {
		if (t[a[i]] > -1) {
			d = i - t[a[i]];
			break;
		}
		t[a[i]] = i;
	}

	int ans = 0;
	REP(i, n + 1) {
		(ans = nCr(n + 1, i + 1) + MOD) %= MOD;
		(ans -= nCr(n - d, i) + MOD) %= MOD;
		// debug(ans);
		
		while (ans < 0) (ans += MOD) %= MOD;
		OUT(ans)BR;
 	}
  
  return 0;
}


Measured memory_bytes: 6656
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	s := getNextString(scanner)

	ans := make([]int, n)
	for i := 0; i < 4; i++ {
		ans[0] = (i >> 1) & 1
		ans[1] = (i) & 1
		for ii := 2; ii < n; ii++ {
			ans[ii] = neighbor(ans[ii-2], ans[ii-1], s[ii-1])
		}
		if ans[0] != neighbor(ans[n-2], ans[n-1], s[n-1]) {
			continue
		}
		if ans[1] != neighbor(ans[n-1], ans[0], s[0]) {
			continue
		}
		for ii := 0; ii < n; ii++ {
			if ans[ii] == 1 {
				fmt.Fprint(writer, "W")
				continue
			}
			fmt.Fprint(writer, "S")
		}
		fmt.Fprintln(writer, "")
		writer.Flush()
		return
	}

	fmt.Fprintln(writer, "-1")
	writer.Flush()
}

func neighbor(a1, a2 int, ch byte) int {
	if a2 == 1 && ch == 'o' {
		return a1 ^ 1
	}
	if a2 == 0 && ch == 'x' {
		return a1 ^ 1
	}

	return a1
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(){
	int N, sum=0, max=0, i;
	scanf("%d", &N);
	int price[N];
	for(i=0;i<N;i++){
		scanf("%d", price+i);
		sum+=price[i];
		if(max<price[i]){
			max=price[i];
		}
	}
	printf("%d", sum-max+max/2);
}

Measured memory_bytes: 128
button = [0, ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"]

n = int(input())
for i in range(n):
    s = input()

    cnt = 0
    key = "0"

    for c in s:
        if c != "0":
            cnt += 1
            key = c
        else:
            if key == "0":
                cnt = 0
                continue
            else:
                print(button[int(key)][(cnt - 1) % len(button[int(key)])], end = "")
                cnt = 0
                key = "0"

    print()


Measured memory_bytes: 5628
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
using namespace std;

int main(){
  int n,m,l; cin >> n >> m >> l;

  int a[n][m], b[m][l];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    for(int j = 0; j < l; j++){
      cin >> b[i][j];
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      long long now = 0;
      for(int k = 0; k < m; k++){
        now += a[i][k] * b[k][j];
      }
      cout << now;
      if(j == l-1) cout << endl;
      else cout << " ";
    }
  }
  return 0;
}



Measured memory_bytes: 3172
N=int(input())
#map(int, input().split())
#list(map(int, input().split()))

ans1 = 1
ans2 = 1
ans3 = 1
b=10**9+7
for i in range(N):
    ans1 *= 10
    ans1 %= b
    ans2 *= 9
    ans2 %= b
    ans3 *= 8
    ans3 %= b

ans = (ans1-2*ans2+ans3)%b

print(ans)

Measured memory_bytes: 63400
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
List=[list(map(int,input().split())) for i in range(M)]
minn=min(a)+min(b)

for i in range(M):
    minn=min(minn,a[List[i][0]-1]+b[List[i][1]-1]-List[i][2])

print(minn)

Measured memory_bytes: 38628
n = list(map( int, input()))
 
h = 3
for i in range(h):
  if( n[i] == 1):
    n[i] = 9
    n[i] = str(n[i])   
  else:
    n[i] = 1
    n[i] = str(n[i])
    
a = "".join(n)
 
print(a)

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

int main() {
    int N,N0,n=0;
    string str;
    cin >> N;
    N0 = N;
    
    for (int i; i<8; i++){
        n += N0%10;
        N0 /= 10;
        if (N0==0) break;
    }
    
    if (N%n==0) str = "Yes";
    else str = "No";
    
    cout << str << endl;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

int main(){
    ll n; cin >> n;
    vector<vector<ll>> ab;
    for(int i=0; i<n; i++){
        ll a, b; cin >> a >> b;
        ab.push_back(vector<ll>{a, b});
    }
    sort(ab.begin(), ab.end());
    cout << ab[n-1][0] + ab[n-1][1] << endl;
    return 0;
}

Measured memory_bytes: 6836
def spaceinput():
    return list(map(int,input().split(" ")))



N=int(input())
words=[]
done=[]
for i in range(N):
    words.append(input())

done.append(words[0])
for i in range(1,N):
    if words[i-1][-1]!=words[i][0]:
        print("No")
        break

    if words[i] in done:
        print("No")
        break

    done.append(words[i])
    if i==N-1:
        print("Yes")

#print(done)
#print(words)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100
#define MAXV 1000
#define MAXW 1000000000
#define INF 10000000000000LL


int w[MAXN], v[MAXN];
int n,C;
long long dp[MAXN*MAXV+1];
int totalV;

int main() {
	int i,j;
	scanf("%d %d",&n, &C);	
	for (totalV=i=0; i<n;i++) {
		scanf("%d %d",&w[i],&v[i]);
		totalV += v[i];
	}
	dp[0]=0;
	for (i=1; i<=totalV;i++) {
		dp[i]=INF;
	}

	for (i=0; i<n; i++) {
		for (j=totalV; j>=v[i]; j--) {
			dp[j]=min(dp[j], dp[j-v[i]]+w[i]);
		}
	}
	for (i=totalV;  i>=0;i--) {
		if (dp[i]<= C) break;
	}
	printf("%d\n", i);
	return 0;
}



Measured memory_bytes: 4520
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
using namespace std;
#define lli                                 long long int
#define lb                                  long double
#define pi                                  acos(-1)
#define FindDistance(ax,ay,bx,by)           sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)                            __gcd(a,b)
#define lcm(a,b)                           (a/gcd(a,b))*b
#define T                                  int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define all(v)                             v.begin(),v.end()
#define pb                                 push_back
#define inf                                999999999999999
#define mod                                1000000007
#define maxn                               100003
#define FastIO                             ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
    string s;
    cin>>s;
    if(s=="A")
        cout<<"T"<<endl;
        else if(s=="T")
        cout<<"A"<<endl;
        else if(s=="G")
        cout<<"C"<<endl;
        else if(s=="C")
        cout<<"G"<<endl;

    return 0;
}


Measured memory_bytes: 3592
from math import ceil
N = int(input())
A = list(map(int,input().split()))
ans_1 = max(A)
A.remove(ans_1)
ans_2 = 1000000
d = 10000000000
half = ceil(ans_1/2)
for e in A:
    if d > abs(half-e):
        d = abs(half-e)
        ans_2 = e
print(ans_1,ans_2)

Measured memory_bytes: 14180
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
   string s;
   cin>>s;
   int ans=0;
   int a;
   bool f=false;
   rep(i,0,s.size()){
      if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
         if(!f){
            a=1;
            f=true;
         }else a++;
      }else{
         a=0;
         f=false;
      }
      ans=max(ans,a);
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

def main():
	a, b, c, d = map(int, input().split(" "))
	
	if c >= b or a >= d:
		print(0)
		sys.exit()
	
	if a <= c and b >= d:
		print(d - c)
		sys.exit()
	
	if a >= c and b <= d:
		print(b - a)
		sys.exit()
		
	if a < c:
		print(b - c)
		sys.exit()
		
	if a > c:
		print(d - a)
		sys.exit()
		
	if d < b:
		print(d - c)
		sys.exit()
		
	if d > b:
		print(b - c)
		sys.exit()
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a,b;scanf("%d%d",&a,&b);
	int ret=mod;
	for(int i=0;i<a;i++){
		int p,q;scanf("%d%d",&p,&q);
		if(q<=b)ret=min(ret,p);
	}
	if(ret==mod)printf("TLE\n");
	else printf("%d\n",ret);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string s;
    int K, len;
    cin >> s >> K;

    len = (int)s.size();

    rep(i, len) {
        int dis = 26 - (int)(s[i] - 'a');
        dis %= 26;
        if (dis <= K) {
            s[i] = 'a';
            K -= dis;
        }
    }

    if (K > 0) {
        int cnt = K % 26;
        s[len - 1] = s[len - 1] + cnt;
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
ans = sum(B)
 
now = A[0]
for i in range(1, len(A)):
    if now+1 == A[i]:
        ans += C[now-1]
    now = A[i]
 
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000
#define MMAX 100005

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	std::fill( (T*)array, (T*)(array+N), val );
}

typedef long long ll;
typedef pair<ll ,ll > P;

ll A[MMAX],B[MMAX],C[MMAX] = {},N,M,W,K,ans,dp[HMAX][WMAX];
multimap <ll ,ll> mp; 
string S;
static const ll dx[8] = {0,1,1,1,0,-1,-1,-1},
dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	for (ll i = 0; i < N; ++i)
	{
		mp.insert(P(A[i],B[i]));
	}
	for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
		if(K > itr -> second){
			K -= itr -> second;
		}else{
			ans = itr -> first;
			break;
		}
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N >> K;
	for (ll i = 0; i < N; ++i)
	{
		cin >> A[i] >> B[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 9856
void main() {
    string s = readln.chomp[0..$-2];
    ulong len = s.length / 2;
    while (s[0..len] != s[len..$]) {
        s = s[0..$-2];
        --len;
    }
    s.length.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw4(30,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,29) pw4[i]=4*pw4[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    string s; cin>>s;
    ll L=sz(s);
    vector<ll> X(sz(s)+1,0);
    vector<ll> RL(1,0);
    s="a"+s;
    
    ll now=1;
    X[1]=now;
    bool r=true;
    FOR(i,2,L+1){
        if(s[i]=='L'){
            if(r){
                RL.pb(i);
                r=false;
            }
            X[i]=now;
        }
        else{
            if(!r){
                now++;
                r=true;
            }
            X[i]=now;
        }
    }
    
    vector<ll> ans(L+1,0);
    rep1(i,L){
        if((RL[X[i]]-i)%2==0) ans[RL[X[i]]]++;
        else ans[RL[X[i]]-1]++;
    }
    
    rep1(i,L) cout<<ans[i]<<" ";
    //rep(i,sz(RL)) cout<<RL[i]<<endl;
}



Measured memory_bytes: 5376
M=2**61-1;eval"N,*A="+`dd`.split*?,;C=[0,N].map{|z|(A[z,N]*3).each_cons(2).map{|x,y|x^y}};e,f=C.map{|z|z[b=0,N].map{|x|b=b*97+x&M};b};q=1-97**N&M;N.times{|i|e==f&&p(i,A[i]^A[N]);e=e*97+C[0][i]*q&M}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n;
set<string> st;
void solve(){
    cin>>n;
    rep(i,0,n){
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<sz(st)<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

long long A,B,N;

int main(){
    cin>>N>>A>>B;
    long long ans;
    long long set=N/(A+B);
    long long rem=N%(A+B);
    if(A==0){
        cout<<0<<endl;
        return 0;
    }
    if(rem>=A){
        ans=set*A+A;
    }else {
        ans=set*A+rem;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fr first
#define sc second
#define close(x){cout<<x<<endl;return 0;}
#define pb push_back
#define mp make_pair
#define forr(i,a,b) for(ll i=a;i<b;i++)

int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);ll a,b;
cin>>a>>b;
ll x=a+b-1;
ll y=(ll)a*b-x;
cout<<y<<endl;
return 0;}


Measured memory_bytes: 256
n = int(input())

a = []

evidences = []
for i in range(n):
    ls = []
    x = int(input())
    a.append(x)
    for j in range(x):
        l = [int(_) for _ in input().split(' ')]
        ls.append(l)
    evidences.append(ls)

patterns = []
for i in range(2**n):
    pattern = [0] * n
    for j in range(n):
        if (i >> j & 1):
            pattern[j] = 1
    patterns.append(pattern)

honest = 0
for pattern in patterns:
    contradict = False
    for i in range(n):
        for evidence in evidences[i]:
            if(pattern[i] == 1):
                if (pattern[evidence[0]-1] != evidence[1]):
                    contradict = True
    if (contradict == False):
        honest = max(honest, pattern.count(1))

print(honest)

Measured memory_bytes: 9460
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final PrintStream so = System.out;
    static final Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int[] a = new int[3];
        a[0] = ni();
        a[1] = ni();
        a[2] = ni();
        if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0) {
            so.println(0);
            return;
        }
        
        Arrays.sort(a);
        so.println((long)a[0] * a[1]);
    } 

    static int ni() {
        return sc.nextInt();
    }
    
    static long nl() {
        return sc.nextLong();
    }

    static char[] nsToChars() {
        return sc.next().toCharArray();
    }
}


Measured memory_bytes: 23892
import math 
A,B = map(int,input().split()) 
# print(A/0.08,B/0.1)
price = []
x = int(A/0.08)
# print(x,y)
y = int(B/0.1)
for i in range(min(x,y),10001):
	if math.floor(i*0.08) == A and math.floor(i*0.1) == B:
		price.append(i)	
		break
		# print(i, math.floor(i*0.08),math.floor(i*0.1))
if len(price) == 0:
	print(-1)
else:
	print(min(price))

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a << c && b << c) printf("%d",a*b/2);
  else if(a << b && c << b) printf("%d",a*c/2);
  else printf("%d",b*c/2);
return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, P;
  string S;
  cin >> N >> P >> S;
  int64_t res = 0;
  if (P == 2 || P == 5) {
    for (int i = 0; i < N; i++) {
      if ((S[i] - '0') % P == 0) res += i + 1;
    }
  } else {
    map<int, int> mp;
    mp[0]++;
    int cur = 0, b = 1;
    reverse(S.begin(), S.end());
    for (int i = 0; i < N; i++) {
      cur += b * (S[i] - '0');
      cur %= P;
      b *= 10;
      b %= P;
      res += mp[cur]++;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 916
import numpy as np

n,m,x = [int(i) for i in input().split()]
costs =[]
maa = 1000000000000000000000000000
ans = maa

for i in range(n):
    a = [int(i) for i in input().split()]
    costs.append(a)
    
for i in range(1,2**n+1):
    cost = 0
    c = 0
    sums = [0] * m
    use_index=[]
    for j in range(n):
        if i%2==1:
            use_index.append(j)
        i >>= 1
    
    for v in use_index:
        c += costs[v][0]        
        for j in range(m):
            sums[j] += costs[v][j+1]
            
    judge=True
    for j in range(m):
        if sums[j]<x:
            judge=False
            break
    
    if judge:
        ans = min(ans, c)

if ans ==maa:
    print(-1)
else:
    print(ans)
            
            

    
    

Measured memory_bytes: 27168
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<numeric>
#include<limits>
#include <cstdint>
#include<stack>
#include<queue>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define rep2(N1,N2) for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)for(ll k=0;k<N3;k++)
#define For(i,N) for(ll i=0;i<N;i++)

void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

ll keta(ll a) {
	ll i = 1;
	while (1) {
		if (a < pow((ll)10, i))
			return i;
		i++;
	}
}
vector<ll> v;
ll n, m;
//m進数全探索
ll inc(ll a = n - 1) {
	if (a == 0 && v[0] == m) {
		v[0] = -1;
		return v[0];
	}
	if (v[a] == m) {
		v[a] = 0;
		inc(a - 1);
		return v[a];
	}
	else {
		++v[a];
		return v[a];
	}
}

ll mod = 1000000007;

ll modkai(ll a) {
	ll ret = 1;
	rep(a) {
		ret *= (i + 1);
		ret %= mod;
	}
	return ret;
}

ll modpowl(ll a, ll b) {
	if (b == 0) {

		return 1;
	}
	if (b == 1) {

		return a;
	}
	if (b >= 2) {
		if (b % 2 == 0) {
			ll c = modpowl((a*a) % mod, b / 2);
			c = c % mod;

			return c;
		}
		else {
			ll c = (modpowl((a*a) % mod, b / 2) % mod)*a;
			c = c % mod;

			return c;
		}
	}
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

ll llpow(ll a, ll b) {
	if (b == 0) {

		return 1;
	}
	if (b == 1) {

		return a;
	}
	if (b >= 2) {
		if (b % 2 == 0) {
			ll c = llpow((a*a), b / 2);
			c = c;

			return c;
		}
		else {
			ll c = (llpow((a*a), b / 2))*a;
			c = c;

			return c;
		}
	}
}
std::vector<ll> Eratosthenes(ll N)
{
	std::vector<bool> is_prime(N + 1);
	for (ll i = 0; i <= N; i++)
	{
		is_prime[i] = true;
	}
	std::vector<ll> P;
	for (ll i = 2; i <= N; i++)
	{
		if (is_prime[i])
		{
			for (ll j = 2 * i; j <= N; j += i)
			{
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

int main() {
	cout.precision(20);
	ll H, M, H2, M2, K;
	cin >> H >> M >> H2 >> M2 >> K;
	ll ans = 60 * H2 + M2 - 60 * H - M;
	ans -= K;
	cout << ans;
}

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

using namespace std;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX = 1e9 + 5;

int main() {
    char x;
    cin >> x;
    if (isupper(x)) puts("A");
    else puts("a");
}


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

#define MOD_1_000_000_007 (1000000007LL)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  static const ll MAX = 100LL;
  ll H, W;
  bool A[MAX][MAX];
  ll dist[MAX][MAX], black = 0;
  struct P {
    ll i;
    ll j;
    bool operator == (const P& rhs) const {
      return i == rhs.i && j == rhs.j;
    }
  };
  vector<int> di = {1, 0, -1, 0};
  vector<int> dj = {0, 1, 0, -1};

  void init() {
    scanf("%lld %lld", &H, &W);
    string s;
    char c;
    rep(i, H) {
      cin >> s;
      rep(j, W) {
        c = s[j];
        if(c == '.') A[i][j] = true;
        else { A[i][j] = false; black++; }
      }
    }
  }

  void bfs() {
    queue<P> que;
    que.push({0, 0});
    dist[0][0] = 1;
    P goal = {H-1, W-1};
    while(!que.empty()) {
      P u = que.front(); que.pop();
      if (u == goal) break;
      rep(k, 4) {
        P v = {u.i+di[k], u.j+dj[k]};
        if(0 <= v.i && v.i < H && 0 <= v.j && v.j < W && A[v.i][v.j] && dist[v.i][v.j] == 0) {
          dist[v.i][v.j] = dist[u.i][u.j] + 1;
          que.push(v);
        }
      }
    }
  }

  void solve() {
    bfs();
    if(dist[H-1][W-1] == 0) printf("-1\n");
    else printf("%lld\n", H*W-black-dist[H-1][W-1]);
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main { 
    public static void main(String[] args) {
      Scanner sc=new Scanner(System.in);
      long n=sc.nextLong();
      long o;
      long x=Long.MAX_VALUE/2;
      long y=Long.MAX_VALUE/2;
      long r=(long)Math.sqrt(n);
      for(long i=1;i<=r;i++){ 
      	if(n%i==0){
        	long j=n/i;
            if ((i+j)<(x+y)){
            	x=i;
                y=j;
            }
        }
      }
      o=x+y-2;
      System.out.println(o);
    }
}

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

int main() {
	int N;
	cin >> N;
	cout << N*N*N;
}

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

int main(){
  long N;cin>>N;
  vector<long> A(N);
  vector<long> R(100010,0);
  long count=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    count +=A.at(i);
    R.at(A.at(i))++;
  }
  long Q;cin>>Q;
  vector<long> B(Q),C(Q);
  for(int i=0;i<Q;i++) cin>>B.at(i)>>C.at(i);
  
  for(int i=0;i<Q;i++){
    if(R.at(B.at(i))>0){
      long Bi=R.at(B.at(i));
      R.at(B.at(i))=0;
      R.at(C.at(i))+=Bi;
      count += Bi*(C.at(i)-B.at(i));
    }
    cout<<count<<endl;
  }
}

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

int main() {
    int n, cnt = 0;
    int a[250];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    while (true)
    {
        for (int i = 0; i < n; i++)
        {
            if (a[i] % 2 != 0)
            {
                goto l_exit;
            }
            a[i] = a[i] / 2;
        }
        cnt++;
    }
    l_exit:
    cout << cnt << endl;
}

Measured memory_bytes: 256
# coding: utf-8

scores = []
grades = []
while (1):
    one = list(map(int, input().split()))
    if sum(one) <= -3:
        break
    scores.append(one)

for s in scores:
    # ??????????¨??????????????¨????????????????????¬???? -> F
    if (s[0] == -1 or s[1] == -1):
        grades.append('F')
        continue
    # ??????????¨???¨??????????¨????????¨??????°???80?????\??? -> A
    if (s[0] + s[1] >= 80):
        grades.append('A')
        continue
    # ??????????¨???¨??????????¨????????¨??????°???65?????\???80????????? -> B
    if (s[0] + s[1] >= 65):
        grades.append('B')
        continue
    # ??????????¨???¨??????????¨????????¨??????°???50?????\???65????????? -> C
    if (s[0] + s[1] >= 50):
        grades.append('C')
        continue
    # ??????????¨???¨??????????¨????????¨??????°???30?????\???50?????????
    if (s[0] + s[1] >= 30):
        if (s[2] >= 50):
            grades.append('C')
            continue
        else:
            grades.append('D')
            continue
    grades.append('F')

for g in grades:
    print(g)

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)

signed main(){

	lli n;
	cin>>n;

	map<lli,lli> d;

	REP(i,0,n){
		lli tmp;
		cin>>tmp;
		d[-tmp]++;
	}

	vector<lli> v;
	for(auto e:d){
		if(e.second>=2)v.push_back(-e.first);
		if(e.second>=4)v.push_back(-e.first);
		if(v.size()>=2){
			cout<<v[0]*v[1]<<endl;
			return 0;
		}
	}
	cout<<0<<endl;

	return 0;
}

Measured memory_bytes: 6528
N, W = map(int, input().split())
wl = [0]*(N+1)
vl = [0]*(N+1)
for i in range(1, N+1):
    wl[i], vl[i] = map(int, input().split())

MAX = W
dp = [0]*(MAX+1)

for i in range(1, N+1):
    w, v = wl[i], vl[i]
    for k in reversed(range(MAX+1-w)):
        if k + w > MAX:
            break
        else:
            dp[k+w] = max(dp[k+w], dp[k] + v)
print(max(dp))



Measured memory_bytes: 41712