akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
  int H, h, m, s, a;
  while(cin >> H >> h >> m >> s, H | h | m | s) {
    a = -1;
    while(true) {
      int d = 119 * H - 1;
      int n = 60 * m * (H + 1) + 60 * 60 * (h + a * H);
      // LOG("n :%d d:%d\n", n, d);
      if(s * d <= n && n < 60 * d && n != m * d) {
        int g = gcd(n, d);
        // LOG("g %d\n", g);
        n /= g;
        d /= g;
        printf("%d %d %d %d\n", h, m, n, d);
        break;
      }

      a++;
      if(a > 1) {
        a = -1;
        s = 0;
        m++;
        if(m >= 60) {
          m = 0;
          h++;
          if(h >= H) {
            h = 0;
          }
        }
      }
    }
  }
}

Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int dx[]={-1, 0, 1, 1, 0, -1};
int dy[]={0, 1, 1, 0, -1, -1};

int d[1010][1010];

int main(){
	while(1){
		int n, t;
		cin>>t>>n;
		if(n == 0 && t == 0) break;
		
		rep(i, 1010) rep(j, 1010) d[i][j] = INF;
		rep(i, n){
			int x, y;
			cin>>x>>y;
			d[y + 500][x + 500] = -1;
		}
		int sx, sy;
		cin>>sx>>sy;
		sx += 500;
		sy += 500;
		
		queue<pii> q;
		q.push({0, sy * 1000 + sx});
		d[sy][sx] = 0;
		int ans = 1;
		pii p;
		
		while(!q.empty()){
			p = q.front();	q.pop();
			int x = p.se % 1000, y = p.se / 1000, c = p.fi;
			if(c >= t) continue;
			rep(i, 6){
				int nx = x + dx[i], ny = y + dy[i];
				if(d[ny][nx] != INF) continue;
				d[ny][nx] = c + 1;
				q.push({c + 1, ny * 1000 + nx});
				ans++;
			}
		}
		
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 7140
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			int w=in.nextInt();
			if((n|w)==0)
				return;
			double cnt[]=new double[11];
			double sta=0;
			double ele=0;
			double ans=0.01;
			for(int i=0;i<n;i++)
			{
				int v=in.nextInt();
				for(int j=0;j<=10;j++)
				{
					int wi=w*j;
					if(v>=wi&&v<wi+w)
						cnt[j]++;
				}
			}
			for(int i=0;i<=10;i++)
			{
				sta=Math.max(sta,cnt[i]);
				if(cnt[i]!=0)
					ele=i;
			}
			for(int i=0;i<=10;i++)
				ans+=((ele-i)/ele)*(cnt[i]/sta);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 24672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int par[200005],ran[200005];
void init(){ for(int i=0;i<200005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
vector<P1>a,b;
int n;
vector<pair<int,P> >V;
int main(){
	init();
	cin >> n;
	rep(i,n){
		int x,y; scanf("%d%d",&x,&y);
		a.pb(mp(mp(x,y),i));
		b.pb(mp(mp(y,x),i));
	}
	SORT(a);
	SORT(b);
	for(int i=1;i<a.size();i++){
		if(a[i-1].fi.fi == a[i].fi.fi){
			unite(a[i-1].sc,a[i].sc);
		}
		else{
			V.pb(mp(a[i].fi.fi-a[i-1].fi.fi,mp(a[i-1].sc,a[i].sc)));
		}
	}
	for(int i=1;i<b.size();i++){
		if(b[i-1].fi.fi == b[i].fi.fi){
			unite(b[i-1].sc,b[i].sc);
		}
		else{
			V.pb(mp(b[i].fi.fi-b[i-1].fi.fi,mp(b[i-1].sc,b[i].sc)));
		}
	}
	ll ret = 0;
	sort(V.begin(),V.end());
	for(int i=0;i<V.size();i++){
		if(!same(V[i].sc.fi,V[i].sc.sc)){
			unite(V[i].sc.fi,V[i].sc.sc);
			ret += V[i].fi;
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 7852
N = int(input())

# (締切, 時間)
DeadlineCost = [] * N

for i in range(N):
    c, d = map(int, input().split())
    DeadlineCost.append((d, c))

DeadlineCost.sort()
#print(DeadlineCost)


t = 0
for i in range(N):
    # .pop じゃなくて参照に変更するとどれぐらい速くなる？
    (d, c) = DeadlineCost[i]

    t += c
    if t > d:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 29440
#include<stdio.h>
#include<string.h>
int main(){
  int n,m,i,j,d[5010],p[5010]={0};
  char s[5010][1000],a[1000],b[1000];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%s %d",s[i],&d[i+1]);
  scanf("%d",&m);
  while(m--){
    scanf("%s %s",a,b);
    i=j=0;
    while(strcmp(s[i++],a));
    while(strcmp(s[j++],b));
    for(;p[i];i=p[i]);
    for(;p[j];j=p[j]);
    if(i-j){
      if(d[i]<d[j])p[j]=i;
      else         p[i]=j;
    }
  }
  for(i=0;i<n;i++){
    for(j=i+1;p[j];j=p[j]);
    m+=d[j];
  }
  printf("%d\n",m+1);
  return 0;
}

Measured memory_bytes: 5552
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,M;
bool e[700][700];
int col[700];
int cnt[2];
void dfs(int v,int c){
	if(col[v]!=-1){
		if(col[v]!=c){
			puts("-1");
			exit(0);
		}
		return;
	}
	col[v] = c;
	cnt[c]++;
	rep(u,N) if(e[u][v]) dfs(u,c^1);
}
int main(){
	cin>>N>>M;
	rep(i,N) rep(j,N) if(i!=j) e[i][j] = 1;
	rep(i,M){
		int x,y;
		cin>>x>>y;
		x--,y--;
		e[x][y] = e[y][x] = 0;
	}

	rep(i,N) col[i] = -1;

	using P = pair<int,int>;
	vector<P> ps;

	rep(i,N) if(col[i]==-1){
		cnt[0] = cnt[1] = 0;
		dfs(i,0);
		ps.pb(P(cnt[0],cnt[1]));
	}
	vector<bool> can(N+1,0);
	can[0] = 1;
	for(P p:ps){
		int a = p.fs, b = p.sc;
		vector<bool> ncan(N+1,0);
		rep(i,N+1) if(can[i]){
			ncan[i+a] = 1;
			ncan[i+b] = 1;
		}
		can = ncan;
	}
	int ans = 1e9;
	rep(i,N+1) if(can[i]){
		int j = N-i;
		chmin(ans,i*(i-1)/2 + j*(j-1)/2);
	}
	cout<<ans<<endl;
}


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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,a[200000],b[200000],ans;
bool f=true;
priority_queue<pair<int,int>> pq;

signed main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n) {
        cin >> b[i];
        pq.push(mp(b[i],i));
    }
    while(pq.size()) {
        int i = pq.top().se;pq.pop();
        int tmp = b[(i+n-1)%n] + b[(i+1)%n],kr = (b[i]-a[i])/tmp;
        b[i] -= tmp*kr;
        if (a[i] != b[i] && (!kr || !tmp)) {f=false;break;}
        if (b[i] > a[i]) pq.push(mp(b[i],i));
        if (b[i] < a[i]) {f=false;break;}
        ans += kr;
    }
    rep(i,n) if (a[i] != b[i]) f=false;
    if (f) cout << ans << endl;
    else cout << -1 << endl;
}




Measured memory_bytes: 8944
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep_ll(i,n) for(ll i = 0; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
const long double PI = (acos(-1));
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
///                    BISMILLAHIR RAHMANIR RAHIM

int main()
{
   char c;
   cin>>c;
   if(c>='a' && c<='z')
    cout<<"a"<<endl;
   else{
    cout<<"A"<<endl;
   }
}



/// A L H A M D U L I L L A H


Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}


int main(){
  int n;cin>>n;
  nvec(long long,a,n);
  sort(a.begin(),a.end());
  if(a[0]==0){
      cout<<0;
      return 0;
  }
  for (int i = 1; i < n; i++) {
    long long l=a[i];
    a[i]*=a[i-1];
    if(a[i]>1000000000000000000 || a[i]/a[i-1]!=l){
      cout<<-1;
      return 0;
    }
  }
  cout<<a[n-1];
}



/* きょむ〜 */


Measured memory_bytes: 4052
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int h,w;
    cin>>h>>w;
    char a;
    int count=0;
    vector<vector<int>> s(h,vector<int>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin>>a;
            if (a=='.')
            {
                s[i][j]=1;
                count++;
            }else
            {
                s[i][j]=0;
            }            
        }    
    }

    vector<vector<int>> s1(h,vector<int>(w,-1));
    queue<pair<int,int>> que;
    s1[0][0]=1;
    que.push(make_pair(0,0));

    while (!que.empty())
    {
        pair<int,int> v=que.front();
        que.pop();
        if (v.first!=0)
        {
            if (s1[v.first-1][v.second]==-1 and s[v.first-1][v.second]==1)
            {
            s1[v.first-1][v.second]=s1[v.first][v.second]+1;
            que.push(make_pair(v.first-1,v.second));
            }
        }
        if (v.first!=h-1)
        {
            if (s1[v.first+1][v.second]==-1 and s[v.first+1][v.second]==1)
            {
            s1[v.first+1][v.second]=s1[v.first][v.second]+1;
            que.push(make_pair(v.first+1,v.second));
            }
        }
        if (v.second!=0)
        {
            if (s1[v.first][v.second-1]==-1 and s[v.first][v.second-1]==1)
            {
            s1[v.first][v.second-1]=s1[v.first][v.second]+1;
            que.push(make_pair(v.first,v.second-1));
            }
        }
        if (v.second!=w-1)
        {
            if (s1[v.first][v.second+1]==-1 and s[v.first][v.second+1]==1)
            {
            s1[v.first][v.second+1]=s1[v.first][v.second]+1;
            que.push(make_pair(v.first,v.second+1));
            }
        }
        
    }

    if (s1[h-1][w-1]==-1)
    {
        cout<<-1<<endl;
    }else
    {
        cout<<count-s1[h-1][w-1]<<endl;
    }

    return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(int, A, B);
	auto isKai = [](int n) {
		auto s = to_string(n);
		loop(i, s.size() / 2)
			if (s[i] != s[s.size() - 1 - i])
				return false;
		return true;
	};
	int cnt = 0;
	for (int i = A; i <= B; ++i) {
		cnt += isKai(i);
	}
	out(cnt);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
vector<int> a(100), b(100), c(100), d(100);
int ans = 0;

void dfs(vector<int> &A, int &num, int i){
    if(i == n){
        int sum = 0;
        for (int j = 0; j < q; j++)
        {
            if(A[b[j]] - A[a[j]] == c[j]) sum += d[j];
        }
        ans = max(ans, sum); 
    }
    else{
        for (int j = num; j < m; j++)
        {
            A.push_back(j);
            dfs(A,j,i+1);
            A.pop_back();
        }
    }
}
 

int main(){
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++)
    {
        int x, y, z, w;
        cin >> x >> y >> z >> w;
        a[i] = x-1;
        b[i] = y-1;
        c[i] = z;
        d[i] = w;

    }
    vector<int> A = {};
    int num = 0;
    dfs(A, num, 0);
    cout << ans << endl;

}

Measured memory_bytes: 3584
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int n;
    while(cin>>n)
    {
        bool flag=true;
        for(int i=1;i<=n;i++)
        {
            int a;cin>>a;
            if(a%2==0&&a%3!=0&&a%5!=0)flag=false;
        }
        if(flag)cout<<"APPROVED"<<endl;
        else cout<<"DENIED"<<endl;
    }
    return 0;
}


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

using namespace std;

int main() {
	int N;
	double x;
	string u;



	double yen = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> x;
		cin >> u;
		if (u == "JPY") {
			yen += x;
		}
		else if (u == "BTC") {
			yen += x * 380000;
		}
	}

	cout << dec << yen;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        String[] s = new String[n];
        for(int i=0; i<s.length; i++){
            s[i] = stdIn.next();
        }

        int c0 = 0;
        int c1 = 0;
        int c2 = 0;
        int c3 = 0;
        for(int i=0; i<s.length; i++){
            if(s[i].equals("AC")){
                c0++;
            }else if(s[i].equals("WA")){
                c1++;
            }else if(s[i].equals("TLE")){
                c2++;
            }else{
                c3++;
            }
        }

        System.out.println("AC x " + c0);
        System.out.println("WA x " + c1);
        System.out.println("TLE x " + c2);
        System.out.println("RE x " + c3);
    }
}


Measured memory_bytes: 65608
x, k, d = map(int,input().split())

if x - k * d >= 0:
    print(x - k * d)
elif x + k * d <= 0:
    print(abs(x + k * d))
else:
    dis = x % d
    dis_p = d - dis
    c = k - x // d

    if c % 2 == 0:
        print(dis)
    else:
        print(dis_p)

Measured memory_bytes: 9200
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

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

	int A, B;
	cin >> A >> B;

	cout << A * B - A -B + 1 << endl;

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}




Measured memory_bytes: 504
n, x = map(int, input().split())
a = list(map(int, input().split()))
eat = 0
i = 0
total = 0
while i < (n - 1):
  a[i] -= eat
  if (a[i] < 0):
    a[i] = 0
  if (a[i] + a[i+1]) > x:
    eat = a[i] + a[i+1] - x
    total += eat
  else:
    eat = 0
  i += 1
print(str(total))

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c&&c==a)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int t[100];
	int n = 0;
	int c = 0;

	for(int i=0;i<=9;++i){
		for(int j=0;j<=9;++j){
			t[i*10+j] = i+j;
		}
	}

	while(scanf("%d", &n) != EOF){
		c = 0;
		for(int i=0;i<100;++i){
			for(int j=0;j<100;++j){
				if(t[i]+t[j] == n){
					c++;
				}
			}
		}
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
   lli n,k;cin >>n>>k;
   vector<lli>v;
   for(lli i=0;i<n;i++)
   {
       lli p;cin >> p; v.push_back(p);
   }
   vector<lli> dp;
   dp.resize(k+2);
   dp[0]=0;
   for(int i=1;i<=k;i++)
   {
       int f=0;
       for(int j=0;j<n;j++)
       {
           int p =v[j];
           if(i>=p && dp[i-p] == 0)
           {    
             dp[i] =1;
             f=1; 
             break; 
           }
       }
       if(f==0)
       {
           dp[i] = 0;
       }
   }
   if(dp[k] == 1)
   {
       cout << "First\n";
   }
   else
   {
          cout <<"Second\n";
       
   }

}

Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long num = 0;
        num = (long)Math.sqrt(N);
        long ans = 0;
        long total = 0;
        for(int i =1; i < num+1; i++){
            ans = i * i;
        }
        if(ans == N){
            System.out.println(ans);
            return;
        }else{
            total = ans;
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 35764
a,b = gets.chomp.split(" ").map(&:to_i)
n2 = b *10 
n2.upto(n2+9){|n|
  if (n * 0.08).to_i == a and (n*0.1).to_i == b
    puts n
    exit
  end
  }
puts "-1"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
ll K, A, B;

void solve(){
	if((A + 1) >= B or (K + 1) <= A){
		cout << K + 1 << endl;
		return;
	}
	K -= (A - 1);
	ll ans = A;
	ans += (B - A) * (K / 2) + K % 2;
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> K >> A >> B;

		solve();
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 5e5 + 42;
struct Query
{
	int l, r, idx;
};
Query qs[N];
int a[N];
bool cmp(Query x, Query y) {
	return x.r < y.r;
}
void update(int idx, int val, int bit[], int n) {
	for (; idx <= n; idx += idx&-idx)
		bit[idx] += val;
}
int query(int idx, int bit[], int n) {
	int sum = 0;
	for (; idx>0; idx-=idx&-idx)
		sum += bit[idx];
	return sum;
}
void solve(int arr[], int n, Query qs[], int q) {
	int bit[n + 1], last[N];
  memset(bit,0, sizeof(bit));
	memset(last, -1, sizeof(last));
	int ans[q];
	int cnt = 0;
	for (int i=0; i<n; i++) {
		if(last[arr[i]] != -1) update (last[arr[i]] + 1, -1, bit, n);
		last[arr[i]] = i;
		update(i + 1, 1, bit, n);
		while (cnt < q && qs[cnt].r == i) {
			ans[qs[cnt].idx] = query(qs[cnt].r + 1, bit, n)- query(qs[cnt].l, bit, n);
			cnt++;
		}
	}
	for (int i = 0; i < q; i++)
		cout << ans[i] << endl;
}
int main() {

  int n, m;

  cin >> n >> m;

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

  for(int i = 0; i < m; i++) {
    qs[i].idx = i;
    cin >> qs[i].l >> qs[i].r;
    qs[i].l--;
    qs[i].r--;
  }

	sort(qs, qs+m, cmp);

	solve(a, n, qs, m);

	return 0;
}


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

using namespace std;

#define ll					long long
#define vi					vector<int>
#define vii					vector<vi>
#define ALL(s)			(s).begin(),(s).end()
#define pii					pair<int, int> pii;
#define pll					pair<ll, ll>
#define si					set<int>
#define mp					make_pair
#define F						first
#define S						second
#define pb					push_back
#define tc(t)				int t; cin >> t; while(t--)
#define _						ios_base::sync_with_stdio(false); cin.tie(NULL); 
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;

int main() {_
	int n;
	cin >> n;
	
	int x[n], smallest[n];
	int val = 1;
	for(int i = 0; i < n; ++i)
		cin >> x[i];
	
	smallest[0] = x[0];
	
	for(int i = 1; i < n; ++i) {
		if(x[i] <= smallest[i - 1]) {
			val++;
			smallest[i] = x[i];
		}

		else
			smallest[i] = smallest[i -1];
	}

	cout << val;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=std::vector<ll>;
using VC=std::vector<char>;
using VB=std::vector<bool>;
using VD=std::vector<ld>;
using VVI=std::vector<VI>;
using VVC=std::vector<VC>;
using VS=std::vector<string>;
using PLL =std::pair<ll,ll>;
using PLD=std::pair<ld,ld>;
using VPLL=std::vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#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 ALLR(x) (x).std::rbegin(),(x).std::rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *std::max_element((x).begin(),(x).std::end())
#define MIN(x) *std::min_element((x).begin(),(x).std::end())
#define SORTR(x) std::sort((x).std::rbegin(),(x).std::rend())
#define SORT(x) std::sort((x).begin(),(x).std::end())
#define SUM(x) std::accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) std::fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).std::begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}

struct DFS{
	//VB visited;
	VVI m_link;

	DFS(ll n,ll m=0){
		m_link.resize(n);
		//visited.assign(n,false);
	}

	ll search(VB visited,ll s=0){
		visited[s]=true;
		if(!EXIST(visited,false)) return 1;
		ll ret=0;
		for(auto &v:m_link[s]){
			if(visited[v]) continue;
			else{
				ret+=search(visited,v);
			}
		}
		return ret;
	}
};


void Main()
{
	ll n, m, l;
	ll res = 0;
	string s, t, u;
	string sres = "No or NO";

	cin >> n>>m;
	VVI ab(n);
	DFS dfs(n);

	rep(i, m) {
		ll a, b;
		cin >> a >> b;
		--a; --b;
		dfs.m_link[a].emplace_back(b);
		dfs.m_link[b].emplace_back(a);
	}
	VB visited(n,false);
	res=dfs.search(visited);
	print(res);
	return;
}

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


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int[] a = new int[3];
    for(int i=0;i<a.length;i++){
      a[i]=scan.nextInt();
    }
    Arrays.sort(a);
    System.out.println(a[0]+a[1]);
  }
}

Measured memory_bytes: 21716
x1,y1,x2,y2 = gets.split.map &:to_i
N = gets.to_i
xi,xs = [x1,x2].sort
yi,ys = [y1,y2].sort
Ps = (0...N).map{
  x,y = gets.split.map &:to_i
  next nil if !(xi <= x && x <= xs)
  next nil if !(yi <= y && y <= ys)
  if x1 > x2
    x = 10**8 - x
  end
  if y1 > y2
    y = 10**8 - y
  end
  if xs-xi > ys-yi
    x,y = [y,x]
  end
  [x,y]
}.compact.sort

x1,x2 = [x1,x2].sort
y1,y2 = [y1,y2].sort
if x2-x1 > y2-y1
  x1,y1 = [y1,x1]
  x2,y2 = [y2,x2]
end

lis = Array.new(Ps.size+1, 10**15)
lis[0] = -1

Ps.each{ |x,y|
  j = (0...lis.size).bsearch{ |i| y < lis[i] }
  lis[j] = y
}
n = lis.rindex{ |y| y < 10**9 }
p ((y2-y1) + (x2-x1))*100 + n*(-20 + 5*Math::PI) + (n == x2-x1+1 ? 5*Math::PI : 0)


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

int main() {
  int k;
  string s;
  cin >> k >> s;
  
  int len = s.size();
  
  if (len <= k)
    cout << s << endl;
  else {
    for (int i = 0; i < k; i++)
      cout << s.at(i);
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3632
#include <stdio.h>

void output(int A[],int N)
{
    int i;
    for(i=0;i<N;i++)
    {
        if(i>0)
            printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

void insertionSort(int A[],int N)
{
    int i=0;
    int j=0;
    int v=0;
    for(i=1;i<N;i++)
    {
        v=A[i];
        j=i-1;
        while(j>=0&&A[j]>v)
        {
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        output(A,N);
    }
}

int main(){
    int N,i,j;
    int A[100];

    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",&A[i]);
    output(A,N);
    insertionSort(A,N);

    return 0;

}



Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

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

    vector<ll> a(n + 1), b(n);
    rep2(i, n + 1) cin(a[i]);
    rep2(i, n) cin(b[i]);

    ll ans = 0;
    rep3(i, 1, n + 1) {
        ll ta = a[i - 1] + a[i];
        ll tb = b[i - 1];

        if (ta > tb) {
            ans += tb;

            if (a[i - 1] < b[i - 1]) {
                ll temp = a[i] - tb + a[i - 1];
                if (temp > 0) a[i] = temp;
                else a[i] = 0;
            }
        } else {
            ans += ta;
            a[i] = 0;
        }
    }

    print(ans);
    return 0;
}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int pw2[maxn+5],pw5[maxn+5];

int off=60;
int cnt[150][150];

ll myfloor(long double n)
{
    ll x=floorl(n);
    while(x<n) x++;
    while(x>n) x--;
    return x;
}

int getpw(ll x,int a)
{
    int r=0;
    while(x%a==0)
    {
        x/=a;
        r++;
    }
    return r;
}

int main()
{
    int n; scanf("%d",&n);
    ll ans=0;
    rep(i,1,n) 
    {
        db t; scanf("%lf",&t);
        long double x=t;
        ll p=round(x*1000000000),q=1000000000;
        ll g=__gcd(p,q);
        p/=g; q/=g;
        pw2[i]+=getpw(p,2);
        pw5[i]+=getpw(p,5);
        pw2[i]-=getpw(q,2);
        pw5[i]-=getpw(q,5);
        cnt[off+pw2[i]][off+pw5[i]]++;
        assert(pw2[i]>=-10 && pw5[i]>=-10 && pw2[i]<=45 && pw5[i]<=20);
    }
    rep(i,-10,45) rep(j,-10,20) rep(i2,max(-i,-10),45) rep(j2,max(-j,-10),20) ans+=1ll*cnt[off+i][off+j]*cnt[off+i2][off+j2];
    rep(i,1,n) if(pw2[i]>=0 && pw5[i]>=0) ans--;
    assert(ans%2==0);
    ans/=2;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 5360
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
using namespace std;
const int N=1e5+5;
int a[N],fa[N],head[N],cnt,b[N],p;
int getfa(int x){return fa[x]==x?x:fa[x]=getfa(fa[x]);}
struct egde{
	int to,nxt;
}e[N<<1];
void add(int a,int b){
	e[++cnt].to=b;
	e[cnt].nxt=head[a];
	head[a]=cnt;
}
void dfs(int u,int type){
	a[u]=type;
	for(re int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if(v==fa[u]) continue;
		fa[v]=u;
		dfs(v,-type);
		a[u]+=a[v];
	}
}
int main(){
	int n,m,rt=1,rs=1,ans=0;
	scanf("%d%d",&n,&m);
	inc(i,1,n) fa[i]=i;
	inc(i,1,m){
		int x,y;
		scanf("%d%d",&x,&y);
		if(getfa(x)!=getfa(y)) fa[fa[x]]=fa[y];
		else{rt=x,rs=y;continue;}
		add(x,y),add(y,x);
	}
	fa[rt]=0,dfs(rt,1);
	if(n==m){
		for(re int i=rs;i;i=fa[i]) b[++p]=a[i];
		if(p&1){
			if(a[rt]&1) return puts("-1"),0;
			for(re int i=rs;i;i=fa[i]) a[i]-=a[rt]>>1;
		}
		else{
			if(a[rt]) return puts("-1"),0;
			sort(b+1,b+p+1);
			for(re int i=rs;i;i=fa[i]) a[i]-=b[p>>1]; 
		}
	}
	else if(a[rt]) return puts("-1"),0;
	inc(i,1,n) ans+=abs(a[i]);
	printf("%d",ans);
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    string s;
    cin >> s;
    int n = s.size();
    // i文字見て, L/not L
    vector<vector<ll>> dp(n, vector<ll>(2, 0));
    if (s[0] == '0')
    {
        dp[0][1] = 1;
    }
    else
    {
        dp[0][1] = 2;
        dp[0][0] = 1;
    }
    for (int i = 1; i < n; i++)
    {
        if (s[i] == '0')
        {
            dp[i][1] = dp[i - 1][1];
            dp[i][0] = dp[i - 1][0] * 3 % MOD;
        }
        else
        {
            dp[i][1] = dp[i - 1][1] * 2 % MOD;
            dp[i][0] = (dp[i - 1][0] * 3 + dp[i - 1][1]) % MOD;
        }
    }
    cout << (dp[n - 1][0] + dp[n - 1][1]) % MOD << endl;
}


Measured memory_bytes: 5840
#include <stdio.h>

int main() {

  int a, b;
  char op;
  while(1) {
  scanf("%d %c %d", &a, &op, &b);
    if ( op == '?' )
      break;

  if ( op == '+')
    printf("%d\n", a + b);
  else if ( op == '-' )
    printf("%d\n", a - b);
  else if ( op == '*')
    printf("%d\n", a * b);
  else
    printf("%d\n", a / b);
  }

  return 0;

}

Measured memory_bytes: 600
M, K = gets.split.map(&:to_i)

if M <= 1
  puts K == 0 ? (0 .. M).flat_map{|i| [i, i]}.join(' ') : -1
elsif K < 2**M
  as = [*0 ... 2**M] - [K]
  puts (as + [K] + as.reverse + [K]).join(' ')
else
  puts -1
end

Measured memory_bytes: 12400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
bool custom (pair<int, int> a, pair<int, int> b) {
  if(a.first == b.first) return (a.second < b.second);
  else return (a.first < b.first);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> req(m);
  rep(i, m) cin >> req[i].first >> req[i].second;
  sort(req.begin(), req.end(), custom);
  int ans = 0;
  int from = 0;
  while(from != m) {
    if(from == m-1) {
      ans++;
      break;
    } 
    pair<int, int> p = req[from];
    for(int i=from+1;i<m;i++) {
      pair<int, int> common;
      common.first = max(p.first, req[i].first);
      common.second = min(p.second, req[i].second);
      if(common.first >= common.second) {
        from = i;
        ans++;
        break;
      }
      else p = common;
      if(i == m-1) {
        from = m;
        ans++;
        break;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        string[] s = SpRead(' ');
        int H = int.Parse(s[0]);
        int W = int.Parse(s[1]);
        char[,] list = new char[50, 50];
        for (int i = 0; i < H; i++)
        {
            s = Console.ReadLine().ToCharArray().Select(a => a.ToString()).ToArray();
            for (int j = 0; j < W; j++) { list[i, j] = Char.Parse(s[j]); }
        }
        bool flag = true;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (list[i, j] == '#')
                {
                    if (i != 0)
                    {
                        if (list[i - 1, j] == '#') { flag = true; continue; }
                        else flag = false;
                    }
                    if (i != W - 1)
                    {
                        if (list[i + 1, j] == '#') { flag = true; continue; }
                        else flag = false;
                    }
                    if (j != 0)
                    {
                        if (list[i, j - 1] == '#') { flag = true; continue; }
                        else flag = false;
                    }
                    if (j != H - 1)
                    {
                        if (list[i, j + 1] == '#') { flag = true; continue; }
                        else flag = false;
                    }
                    
                }

                if (!flag)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }
        Console.WriteLine("Yes");
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


Measured memory_bytes: 13396
import java.util.*;

class Main{

    String[] shape = {"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun"};

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    int n = sc.nextInt();
	    if(n==0) break;

	    boolean[] hands = new boolean[15];
	    for(int i=0; i<n; i++){
		String s = sc.next();
		for(int j=0; j<15; j++){
		    if(s.equals(shape[j])) hands[j] = true;
		}
	    }

	    boolean[] win = new boolean[15];
	    boolean[] lose = new boolean [15];
	    for(int i=0; i<15; i++){
		if(!hands[i]) continue;
		for(int j=1; j<=7; j++){
		    if(!hands[(i+j)%15])continue;
		    win[i] = true;
		    lose[(i+j)%15] = true;
		}
	    }
	    
	    ArrayList<String> winner = new ArrayList<String>();
	    for(int i=0; i<15; i++){
		if(win[i] && !lose[i]){
		    if(!winner.contains(shape[i]))winner.add(shape[i]);
		    if(winner.size()>=2) break;
		}
	    }

	    if(winner.size()==1){
		System.out.println(winner.get(0));
	    }else{
		System.out.println("Draw");
	    }
	}
    }

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;

int main() {
  int h,w;
  cin>>h>>w;
  rep(i, h) {
    string s;
    cin>>s;
    cout << s << endl << s << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
#define pa pair<int,int>
#define fi first
#define se second
#define pi acos(-1)
using namespace std;
int a[300005],b[300005];
int c[300005],d[300005];
int n,ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for (int i=0;i<=29;i++){
		int s1=0,s2=0,sum=0;
		for (int j=1;j<=n;j++)
			s1^=(a[j]>>i)&1,s2^=(b[j]>>i)&1;
		sum=(s1+s2)*n%2;
		if (i==0){
			ans+=sum;
			continue;
		}
		for (int j=1;j<=n;j++)
			c[j]=a[j]&((1<<i)-1);
		for (int j=1;j<=n;j++)
			d[j]=b[j]&((1<<i)-1);
		sort(c+1,c+n+1);
		sort(d+1,d+n+1);
		int r=n;
		for (int j=1;j<=n;j++){
			for (;d[r]+c[j]>=(1<<i);r--);
			sum^=(n-r)&1;
		}
		ans+=sum<<i;
	}
	printf("%d",ans);
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int n,k;
long double f[200005],tmp=0,ans=0,s[200005];
inline double cs(double x){
	return x*(x+1)/2;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>f[i],s[i]=cs(f[i])/f[i];
	for(int i=0;i<=n-k+1;i++){
		if(i==0)
			for(int j=0;j<k;j++) 
				tmp+=s[j];
		ans=fmax(ans,tmp);
		if(i==0) continue;
		tmp-=s[i-1],tmp+=s[i+k-1];
	}
	cout<<setprecision(7)<<fixed<<ans;
	return 0;
}
/*
5 5
1 2 2 4 5
*/

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N;

signed main(void) {
    cin >> N;

    cout << (N-2) * 180 << endl;


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	s := make(map[string]int)
	var a string
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		s[a]++
	}

	var M int
	fmt.Scan(&M)
	for i := 0; i < M; i++ {
		fmt.Scan(&a)
		s[a]--
	}

	ans := 0
	for _, v := range s {
		if ans < v {
			ans = v
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    int n;
    cin>>n;
    //cin.ignore();
    string s;
    cin>>s;
    //cout<<n<<" "<<s<<endl;
    int l=0,r=0;
    for(int i=0;i<n;i++){
        if(s[i]=='(')l++;
        else if(s[i]==')'){
            if(l>0)l--;
            else r++;
        }
    }
    for(int i=0;i<r;i++){
        printf("(");
    }
    cout<<s;
    for(int i=0;i<l;i++){
        printf(")");
    }
    cout<<endl;
    
    return 0;
}


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

int main(){
    int a, b, p=-1;
    cin >> a >> b;
    for(int i=b*10; i<=b*10+9; i++){
        if(i*8/100 == a){
            p=i;
            break;
        } 
    }
    cout << p << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)
#define f first
#define se second
#define M 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<long long, long long>
#define vi vector<int>
#define ll long long


int x1,y11,x2,y2;

bool check(int x,int y){
    if(x>=x1&&x<=x2&&y>=y11&&y<=y2){
        return true;
    }
    return false;
}
int main(){
   ll n;
   cin>>n;
   if(n<=9){
       cout<<n;
       return 0;
   }
   vector<string>v;
   for(int i=1;i<=9;i++){
       string s1=to_string(i);
       v.pb(s1);
   }
   int in=0,i=10;
   while(i<=n){
       string s1=v[in];
       int k=s1[s1.size()-1]-'0';
       for(int j=-1;j<=1;j++){
           if(k+j>=0&&k+j<=9){
               string s2=s1+to_string(k+j);
               v.pb(s2);
               if(i==n){
                   cout<<s2;
                   return 0;
               }
               i++;
           }
       }
       in++;
   }
} 


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int n,m;
int main(){
	cin >> n >> m;
	if(n == m)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256