akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#include <climits>
#include <deque>
#include <random>
#include <functional>
#include <unordered_map>
#define rep(i,n) for(int i=0;i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int dx[] = {-1,-1,-1,0,0,1,1,1};
int dy[] = {0,-1,1,-1,1,-1,0,1};
int main(){
    int h,w;
    cin >> h >> w;
    string s[100];
    rep(i,h){
        cin >> s[i];
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j] == '.'){
                int res = 0;
                rep(k,8){
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if(0<=x and x < h and 0<=y and y < w and s[x][y] == '#'){
                        res ++ ;
                    }
                }
                s[i][j] = '0'+res;
            }
        }
    }
    rep(i,h){
        cout << s[i] << endl;
    }
    return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskB {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {

			int t = sc.nextInt();

			for (int i = 0; i < t; i++) {
				long a = sc.nextLong();
				long b = sc.nextLong();
				long c = sc.nextLong();
				long d = sc.nextLong();

				if (a < b || d < b) {
					out.println("No");
				} else if (c >= b) {
					out.println("Yes");
				} else {
					long g = Utils.gcd(b, d);
					out.println(c < b - g + (a % g) ? "No" : "Yes");
				}
			}

		}

	}

	static class Utils {
		public static long gcd(long n, long m) {
			return m == 0 ? n : gcd(m, n % m);
		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

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

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			byte b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) throw new NumberFormatException();
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			byte b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) throw new NumberFormatException();
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

	}
}



Measured memory_bytes: 23764
#include <iostream>
#include<deque>

using namespace std;

int main()
{
    int x;
    string n;
    cin>>n;
    deque<char>s;
    deque<char>t;
    for(int i=0; i<n.size(); i++){
        s.push_back(n[i]);
    }
    cin>>n;
    for(int i=0;i<n.size();i++){
        t.push_back(n[i]);
    }
    for(int i=0;i<n.size();i++){
        if(s==t){
            cout<<"Yes";
            return 0;
        }
        x=s.size()-1;
        s.push_front(s[x]);
        s.pop_back();

    }
    cout<<"No";

    return 0;
}


Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
ant=[a,b,c,d,e]
f=False

for i in range(0,5):
    for ii in range(i+1,5):
        sa=ant[i]-ant[ii]
        if -sa<=k:
            continue
        else:
            print(":(")
            f=True
            break
    break

if f is False:
    print("Yay!")

Measured memory_bytes: 3064
//https://atcoder.jp/contests/arc100/tasks/arc100_c
#include <bits/stdc++.h>
using namespace std;

template <class X, class Y>
bool chkmax(X &a, const Y &b) {
    return a < b ? a = b, 1 : 0;
}

const int N = 18;
int dp[1 << N], res[1 << N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n; cin >> n;
    for (int i = 0; i < (1 << n); i++)
        cin >> dp[i];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < (1 << n); j++)
            if (j >> i & 1) {
                chkmax(res[j], dp[j] + dp[j ^ (1 << i)]);
                chkmax(dp[j], dp[j ^ (1 << i)]);
            }
    for (int i = 1; i < (1 << n); i++) {
        chkmax(res[i], res[i - 1]);
        cout << res[i] << '\n';
    }
}

Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <string,int> mp;
vector<string> V;
set<string> set_s;
#define INF (1<<29)
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
int K;
string s;
void solve(){
    for(int i=1;i<=K;i++){ //substringの長さ
        for(int j=0;j<s.size();j++){ //substringの開始位置
            V.push_back(s.substr(j,i));
        }
    }
    sort(V.begin(),V.end());
    V.erase(unique(V.begin(),V.end()),V.end());
    cout<<V[K-1]<<"\n";
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>s>>K;
    solve();
    
    return 0;
}


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

using Lint=long long;
const double INF=1e9;

int main()
{
   int N; cin>>N;
   N++;
   vector<double> p(N-1),q(N);
   for(int i=0;i<N-1;i++) cin>>p[i];
   for(int i=0;i<N;i++) cin>>q[i];

   vector<double> sumP(N),sumQ(N+1);
   for(int i=0;i<N-1;i++) sumP[i+1]=sumP[i]+p[i];
   for(int i=0;i<N;i++) sumQ[i+1]=sumQ[i]+q[i];

   vector<vector<double>> dp(N+1,vector<double>(N+1,INF));
   for(int i=0;i<N;i++) dp[i][i+1]=0;
   for(int len=2;len<=N;len++){
      for(int l=0;l+len<=N;l++){
         int r=l+len;
         for(int m=l+1;m<r;m++){
            double cost=(sumQ[r]-sumQ[l])+(sumP[m-1]-sumP[l])+(sumP[r-1]-sumP[m]);
            dp[l][r]=min(dp[l][r],dp[l][m]+dp[m][r]+cost);
         }
      }
   }
   double ans=dp[0][N];
   ans+=accumulate(p.begin(),p.end(),0.0);
   ans+=accumulate(q.begin(),q.end(),0.0);
   cout<<fixed<<setprecision(10)<<ans<<endl;
   return 0;
}



Measured memory_bytes: 5036
#include<cstdio>
#include<cstdlib>
#include<cmath>
#define N 100001
#define M 2001
using namespace std;
long long jc[N],njc[N],C[M][M];
long long a[N],sprime[N];
int prime[]={0,2,3,5,7,13,17,19,29,31,41,89,97};
long long xabs(long long x)
{
	if (x<0)return -x;
	return x;
}
long long ksmi(long long x,long long y,long long mod)
{
	long long total=1,ab=x,p=y;
	while (p)
	{
		if (p%2==1) total=total*ab%mod;
		ab=ab*ab%mod;
		p/=2;
	}
	return total;
}
long long gcd(long long x,long long y)
{
	if (y==0) return x;
	return gcd(y,x%y);
}
void qsort(int l,int r)
{
	int i=l,j=r;
	long long mid=sprime[(i+j)/2];
	while (i<=j)
	{
		while (sprime[i]<mid) i++;
		while (sprime[j]>mid) j--;
		if (i<=j)
		{
			long long t=sprime[i];sprime[i]=sprime[j];sprime[j]=t;
			i++;j--;
		}
	}
	if (i<r) qsort(i,r);
	if (l<j) qsort(l,j);
}
int main()
{
	long long n;
	scanf("%lld",&n);
	for (int i=n;i>=0;i--) scanf("%lld",&a[i]);
	long long s=0;
	for (int i=0;i<=n;i++) 
	{
		if (s==0&&a[i]!=0) s=xabs(a[i]);
		else	
			if (a[i]!=0) s=gcd(s,xabs(a[i]));
	}
	sprime[0]=0;
	for (int i=2;i<=sqrt(s);i++)
	{
		if (s==1) break;
		if (s%i==0)
		{
			sprime[0]++;sprime[sprime[0]]=i;
			while (s%i==0) s/=i;
		}
	}
	if (s!=1) 
	{
		sprime[0]++;sprime[sprime[0]]=s;
	}
	for (int i=2;i<=n;i++)
	{
		bool bo=true;
		for (int j=2;j<i;j++)
		{
			if (i%j==0)
			{
				bo=false;break;
			}
		}	
		for (int j=1;j<=sprime[0];j++)
			if (sprime[j]==i)
			{
				bo=false;break;
			 } 
		if (!bo) continue;
		for (int j=1;j<=20;j++)
		{
			long long p=0;
			for (int k=n;k>=0;k--)
				p=(p*j%i+a[k])%i;
			if (p!=0)
			{
				bo=false;break;
			}
		}
		if (!bo) continue;
		sprime[0]++;sprime[sprime[0]]=i;
	}
	qsort(1,sprime[0]);
	for (int i=1;i<=sprime[0];i++)
		if (i==1||sprime[i]!=sprime[i-1]) 
			printf("%d\n",sprime[i]);
} 

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

int main() {
    // 入力
    int n, m; cin >> n >> m;
    vector<int> P(m), Y(m);
    for (int i = 0; i < m; ++i) cin >> P[i] >> Y[i], --P[i];
    
    // vals[v] := P[i] = v であるような i についての Y[i] の値を集めたもの
    vector<vector<int> > vals(n);
    for (int i = 0; i < m; ++i) vals[P[i]].push_back(Y[i]);
    
    // 各 p の値に対して
    for (int v = 0; v < n; ++v) {
        sort(vals[v].begin(), vals[v].end());
        
        // 今回は不要だが、通常は数のダブりをなくす
        vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
    }

    // 答え
    for (int i = 0; i < m; ++i) {
        int v = P[i];
        printf("%06d", v + 1);
        
        // 座標圧縮して導いた答え
        int id = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
        printf("%06d\n", id + 1);
    }
}

Measured memory_bytes: 7808
#include<stdio.h>
int dp[1001][1001];
char s[1001],t[1001];
int ans,x,y;
int max(int a,int b){
  if(a>b)return a;
  else return b;
}
int main(){
  int i,j;
  scanf("%d",&x);
  for(y=0;y<x;y++){
    scanf("%s %s",s,t);
    for(i=0;i<=1000;i++)
      for(j=0;j<=1000;j++)
	dp[i][j]=0;
    ans=0;
    for(i=1;s[i-1]!='\0';i++){
      for(j=1;t[j-1]!='\0';j++){
	if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1]+1;
	else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
    }
    printf("%d\n",dp[i-1][j-1]);
  }
  return 0;
}

Measured memory_bytes: 4516
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

 class Main {

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }


    public static void main(String[] args){
        FastReader sc = new FastReader();
         int d =sc.nextInt(),n=sc.nextInt();
         if(d==0)
             System.out.println( n==100?101:n);
         else if (d==1)
             System.out.println(n==100?10100:n*100);
         else{
             System.out.println(n==100?1010000:n*10000);
         }
}


}


Measured memory_bytes: 21332
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(){
  int N,M,sum=0;
  float k;
  cin>>N>>M;
  int ans=0;
  vector<float> a(N);
    for(int i=0;i<N;i++){
      cin>>a[i];
      sum+=a[i];
    }
  for(int i=0;i<N;i++){
    if(4*M*a[i]>=sum){ans++;}
  }
  if(ans>=M){cout<<"Yes";}
  else{cout<<"No";}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll    long long
#define PR    pair<ll, ll>

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    string a, b;
    cin >> a >> b;
    b.pop_back();
    puts(a == b ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF = 1e12+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}



int main() {
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    ll res = 0;
    for (int i = 1; i < N; i++) {
        if (x < (a[i-1]+a[i])) {
            ll tmp = min((ll) a[i], (ll) (a[i]+a[i-1]-x));
            res += (ll) (a[i]+a[i-1]-x);
            a[i] -= tmp;
        }
    }
    cout << res << endl;

}


Measured memory_bytes: 640
import os
import math
import heapq

def main():
	n,m = map(int, input().split())
	a_list = list(map(lambda x: int(x)*(-1), input().split()))
	heapq.heapify(a_list)
	
	for i in range(m):
		max_num = heapq.heappop(a_list)*(-1)
		heapq.heappush(a_list, (max_num//2)*(-1))

	print((-1)*sum(a_list))

		

if __name__ == "__main__":
	main()


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

int main() {
    string s;
    cin >> s;
    if(s == "SUN") {
        cout << 7 << '\n';
    } else if(s == "MON") {
        cout << 6 << '\n';
    } else if(s == "TUE") {
        cout << 5 << '\n';
    } else if(s == "WED") {
        cout << 4 << '\n';
    } else if(s == "THU") {
        cout << 3 << '\n';
    } else if(s == "FRI") {
        cout << 2 << '\n';
    } else if(s == "SAT") {
        cout << 1 << '\n';
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#include<numeric>
#include<limits>
#include<map>

int main()
{
	int N;
	std::cin >> N;
	std::map<int, bool> data;
	for (int i{};i < N;++i)
	{
		int x;
		std::cin >> x;
		data[x] ^= true;
	}
	int c = std::count_if(data.begin(), data.end(), [](auto p) {return p.second == false;});
	
	if (c == 2)
	{
		auto n = std::find_if(data.begin(), data.end(), [](auto p) {return p.second == false;});
		auto n2 = std::find_if(std::next(n), data.end(), [](auto p) {return p.second == false;});
		if (std::distance(n, n2) == 1)
		{
			std::cout << data.size() - 1 << std::endl;
		}
		else
		{
			std::cout << data.size() << std::endl;
		}
	}
	else if (c % 2 == 0)
	{
		std::cout << data.size() << std::endl;
	}
	else
	{
		std::cout << data.size() - 1 << std::endl;
	}
}

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

int main()
{
  double ans=0;
  int N,K,i,j,t;
  double a,sum;
  
  cin>>N>>K;
  sum=0;
  double p[N+1]={};
  
  for(i=0;i<N;i++)
  {
    cin>>a;
    sum+=a+1;
    p[i+1]=sum;
    //cout<<p[i+1]<<" ";
  }
  //cout<<endl;
  for(i=0;i<N-K+1;i++)
  {
    sum=p[i+K]-p[i];
    //cout<<sum<<" ";
    ans=max(sum,ans);
  }
  //cout<<endl;
  printf("%.10f",ans/2);
       
}

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

int main(){
	int A, B;
	cin >> A >> B;
	
	int Max=A, ans=0, i;
	
	for(i=0; i<2; i++){
		Max=A;
		if(A<B){
			Max=B;
			B--;
		}
		else	A--;
		
		ans += Max;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
const ll mod = (ll)1e9 + 7;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = t.size();
  rep(i, t.size()) {
    for (int j = i; j < s.size() && t.size() - i <= s.size() - j; j++) {
      if (t[i] != s[j]) continue;
      int cnt = 0;
      rep(k, t.size()) if (t[k] != s[j - i + k]) cnt++;
      ans = min(cnt, ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

int main()
{
	int a, b, c;
    cin >> a >> b >> c;
    cout << c << ' ' << a << ' ' << b << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    
    int ans = (N + max(H, W) - 1) / max(H, W);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 764
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)

from collections import defaultdict

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = ii()
d = defaultdict(int)
for i in range(2, N+1):
    for l in factorization(i):
        d[l[0]] += l[1]
#print(d)
ans = 1
INF = 10**9+7

for key in d:
    ans = (ans * (d[key]+1))%INF
          
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
long long A[999999],W[999999];
long long M(int l,int r){
	if(l+1>=r)return 0;
	if(l+2==r){
		if(A[l]<=A[l+1])return 0;
		long long z=A[l];A[l]=A[l+1];A[l+1]=z;
		return 1;
	}
	int m = (l+r)/2,i=l, j=m, k=l;
	long long cl=M(l, m),cr=M(m,r),c=0;
	while(i<m&&j<r){
		if(A[i]<=A[j])W[k++]=A[i++];
		else{
			W[k++]=A[j++];
			c+=m-i;
		}
	}
	while(i<m)W[k++]=A[i++];
	while(j<r)W[k++]=A[j++];
	for(i=l;i<r;i++)A[i]=W[i];
	return cl+cr+c;
}
int main(){
	int T,i,N;
	scanf("%d%d",&N,&T);for(i=1;i<=N;i++)scanf("%d",&A[i]);for(i=1;i<=N;i++)A[i]+=A[i-1]-T;printf("%lld\n",(long long)N*-~N/2-M(0,N+1));
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
int main(void){
    int n, k;
    ll m=0, x=0;
    P p[100000];
    set<int> s;
    priority_queue<int, vector<int>, greater<int> > q;
    
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int t, d;
        cin>>t>>d;
        p[i]=P(d, t);
    }
    sort(p, p+n, greater<P>());
    for(int i=0;i<n;i++){
        int d=p[i].first, t=p[i].second;
        if(i<k){
            if(s.find(t)==s.end()){
                s.insert(t);
            }else{
                q.push(d);
            }
            x+=d;
        }else if(s.find(t)==s.end()&&!q.empty()){
            s.insert(t);
            int w=q.top();
            q.pop();
            x+=d-w;
        }
        if(i>=k-1){
            ll w=s.size();
            m=max(m, x+w*w);
        }
    }
    cout<<m<<endl;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define N 200010
#define INF 1000000010
using namespace std;
pair<long long,long long> gl[N],gr[N];
long long a[N];
int main(){
	int n,i,now=0;
	long long sl=0,sr=0,ans=INF;
	vector<long long> v;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
	{
		sr+=a[i];
		while(now<=i&&abs(sl-sr)>=abs(sl+a[now]-(sr-a[now])))
		{
			sl+=a[now];
			sr-=a[now];
			now++;
		}
		gl[i]=make_pair(sl,sr);
	}
	sl=0;
	sr=0;
	now=n-1;
	for(i=now;i>=0;i--)
	{
		sl+=a[i];
		while(now>=i&&abs(sl-sr)>=abs(sl-a[now]-(sr+a[now])))
		{
			sl-=a[now];
			sr+=a[now];
			now--;
		}
		gr[i]=make_pair(sl,sr);
	}
	for(i=1;i<=n-1;i++)
	{
		v.clear();
		v.push_back(gl[i].first);
		v.push_back(gl[i].second);
		v.push_back(gr[i+1].first);
		v.push_back(gr[i+1].second);
		sort(v.begin(),v.end());
		ans=min(ans,v[3]-v[0]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
using namespace std;
#define ll long long int
int main(){
   ll n,x;
   cin>>x>>n;
   ll has[105]={};
   ll a,i;
   for(i=0;i<n;i++){
       cin>>a;
       has[a]++;
   }
   ll ans = -100;
   ll diff = 1000;
   for(i=-110;i<=110;i++){
       ll tt = abs(i-x);
       if(tt<diff){
           if(i<0||has[i]==0){
           ans = i;
           diff = tt;
           }
       }
   }
   cout<<ans;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

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

    vpll robot(N);
    ll tmp_x, tmp_l;
    rep(i, N) {
        cin >> tmp_x >> tmp_l;
        robot.at(i) = mp(tmp_x+tmp_l, tmp_x-tmp_l);
    }

    VSORT(robot);

    ll cnt = 0;
    ll r = -INF;

    rep(i, N) {
        if(robot[i].second < r) cnt++;
        else r = robot[i].first;
    }
    cout << N-cnt << endl;
    
    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }

ll MOD = 1000000007;
ll INF =1<<29;

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<ll,ll>> a(n);
    rep(i,n) cin >> a[i].first >> a[i].second;
    sort(a.begin(),a.end());
    ll tot = 0;
    int SUM = 0;
    rep(i,m){
    if(SUM<=m){
        tot += a[i].first*a[i].second;
        SUM += a[i].second;
    } 
    if(SUM == m){
        cout << tot << endl;
        return 0;
    }
    if(SUM>m){
        tot -=a[i].first*(SUM-m);
        cout << tot << endl;
        return 0;
    }
    }
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int N,M,C,ans=0,k=0,i,j;
	int A[21][21],B[21];
	scanf("%d%d%d",&N,&M,&C);
	for(i=0;i<M;i++){
		scanf("%d",&B[i]);
	}
	for(j=0;j<N;j++){
		for(i=0;i<M;i++){
			scanf("%d",&A[j][i]);
		}
	}
	for(j=0;j<N;j++){
		for(i=0;i<M;i++){
			ans=ans+A[j][i]*B[i];
			//printf("%d\n",ans);
		}
		if(ans+C>0){
		k++;
		}
		ans=0;
	}	
	printf("%d",k);
	
	return 0; 
	
	
	
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll N, A, B, C, D;
unordered_map<ll, ll> dp;

ll dfs(ll x) {
    if (dp.find(x) != dp.end()) {
        return dp[x];
    }

    if (x == 0) {
        dp[x] = 0;
        return dp[x];
    }

    if (x == 1) {
        dp[x] = D;
        return dp[x];
    }

    ll res = L_INF;

    ll r2 = x % 2;
    ll r3 = x % 3;
    ll r5 = x % 5;

    // goto 0
    if (x < L_INF / D) {
        res = dfs(0) + x * D;
    }

    // 2
    res = min(res, dfs(x / 2) + A + r2 * D);
    res = min(res, dfs((x + 1) / 2) + A + r2 * D);

    // 3
    res = min(res, dfs(x / 3) + B + r3 * D);
    res = min(res, dfs((x + 2) / 3) + B + (3 - r3) * D);

    // 5
    res = min(res, dfs(x / 5) + C + r5 * D);
    res = min(res, dfs((x + 4) / 5) + C + (5 - r5) * D);

    dp[x] = res;
    return res;
}

void solve() {
    int Q;
    cin >> Q;
    while (Q--) {
        cin >> N >> A >> B >> C >> D;
        dp.clear();
        ll res = dfs(N);
        cout << res << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    cout << a-b+1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ar[15];
int n;
int main(){
	cin>>n;
  	for(int i=1;i<=n;i++)cin>>ar[i];
  	sort(ar+1,ar+n+1);
  	if(accumulate(ar+1,ar+n,0)>ar[n]) cout<<"Yes";
  	else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void) {
   int a, b, sum, sub, bec, ans;
   std::cin >> a >> b;
   sum = a + b;
   sub = a - b;
   bec = a * b;
   if(sum > sub){
      ans = sum;
   }else{
      ans = sub;
   }
   if(ans > bec){
      std::cout << ans << '\n';
   }else{
      std::cout << bec << '\n';
   }
}


Measured memory_bytes: 256
import sys
from numpy import fromstring
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall as f
def main():
  t=fromstring(sys.stdin.buffer.read(),'i',sep=' ')
  n,m,l=t[:3]
  m=m*3+3
  print('\n'.join((f(f(csr_matrix((t[5:m:3],(t[3:m:3],t[4:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n).astype(int)%n-1).astype(str).tolist()))
main()

Measured memory_bytes: 28828
N = int(input())
S = tuple(map(int, input()))

ans = 0
for i in range(1000):
    ii = i
    key = ii%10
    count = 0
    for s in S:
        if key == s:
            count += 1
            if count == 3:
                ans += 1
                break
            ii //= 10
            key = ii%10

print(ans)


Measured memory_bytes: 3444
#include<stdio.h>

int main() {
	int n, i, c[52] = { 0 }, j, d, l;
	char k[2];
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%s %d", k, &j);
		switch(k[0]) {
			case 'S':
				c[j - 1]++;
				break;
			case 'H':
				c[j + 12]++;
				break;
			case 'C':
				c[j + 25]++;
				break;
			case 'D':
				c[j + 38]++;
		}
	}
	for (i = 0; i < 52; ++i) {
		d = i / 13;
		l = i + 1 - (d * 13);
		if(!c[i]) {
			switch(d) {
				case 0:
					printf("S %d\n", l);
					break;
				case 1:
					printf("H %d\n", l);
					break;
				case 2:
					printf("C %d\n", l);
					break;
				case 3:
					printf("D %d\n", l);
			}	
		}
		
	}
	return 0;
}


Measured memory_bytes: 2044
n = int(input())
documents = list(map(int, input().split()))

i = 0
for document in documents:
    if document % 2 == 0:
        if not (document % 3 == 0 or document % 5 == 0):
            i = i + 1

if 1 <= i:
    print("DENIED")
else:
    print("APPROVED")


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

int main(){
    ll n,m;
    cin>>n>>m;
    ll a[n],j=1;
    vector<vector<ll>> v(n+10);
    map<ll,ll> ma;
    for(ll i=0;i<n;i++) cin>>a[i];
    for(ll i=0;i<m;i++){
        ll A,B;
        cin>>A>>B;
        // if(ma[A]==0)    ma[A]=j,j++;
        // if(ma[B]==0)    ma[B]=j,j++;
        v[A-1].push_back(a[B-1]);         
        v[B-1].push_back(a[A-1]);
    }
    ll count=0;
    for(ll i=0;i<n;i++){
        sort(v[i].begin(),v[i].end());
        reverse(v[i].begin(),v[i].end());
        if(v[i].size()==0 || v[i][0]<a[i])  count++;
    }
    cout<<count<<endl;
    return 0; 
}


Measured memory_bytes: 9860
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
const ll mod = 1000000007;
ll posmax[201000];
ll posmin[201000];
ll negmax[200100];
ll negmin[200100];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> pos, neg;
    for(int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        if(a >= 0) pos.push_back(a);
        else neg.push_back(-a);
    }
    sort(neg.begin(), neg.end(), greater<ll>());
    sort(pos.begin(), pos.end(), greater<ll>());
    if((K == N and neg.size() % 2 == 1) or (neg.size() == N and K % 2 == 1)) {
        ll ans = mod - 1;
        vector<ll> A;
        for(auto val : neg) A.push_back(val);
        for(auto val : pos) A.push_back(val);
        sort(A.begin(), A.end());
        for(int i = 0; i < K; i++) {
            ans = ans * A[i] % mod;
        }
        cout << ans << endl;
    } else {
        ll ans = 1;
        ll idx1 = 0;
        ll idx2 = 0;
        while(K) {
            //cerr << K << " " << idx1 << " " << idx2 << endl;
            if(K % 2 == 1) {
                K--;
                ans *= pos[idx1];
                idx1++;
                ans %= mod;
                continue;
            }
            K -= 2;
            if(idx1 + 1 >= pos.size()) {
                ans *= neg[idx2];
                ans %= mod;
                idx2++;
                ans *= neg[idx2];
                ans %= mod;
                idx2++;
                continue;
            }
            if(idx2 + 1 >= neg.size()) {
                ans *= pos[idx1];
                ans %= mod;
                idx1++;
                ans *= pos[idx1];
                ans %= mod;
                idx1++;
                continue;
            }
            if(neg[idx2]*neg[idx2+1] >= pos[idx1]*pos[idx1+1]) {
                ans *= neg[idx2];
                ans %= mod;
                idx2++;
                ans *= neg[idx2];
                ans %= mod;
                idx2++;
                continue;
            }
            if(neg[idx2]*neg[idx2+1] <= pos[idx1]*pos[idx1+1]) {
                ans *= pos[idx1];
                ans %= mod;
                idx1++;
                ans *= pos[idx1];
                ans %= mod;
                idx1++;
                continue;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

const int MOD=1000000007;
int n,m;

long long memo[100050];
bool danger[100050];

//i段目以降の上り方
long long calc(int i){
    if(memo[i]!=-1) return memo[i];
    if(danger[i]) return 0;
    if(i>=n-1) return 1;
    memo[i]=calc(i+1)+calc(i+2);
    //cout << i << " " << memo[i] <<endl;
    return memo[i]%MOD;
}

int main(){
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a;
        cin >> a;
        danger[a]=true;
    }
    memset(memo,-1,sizeof(memo));
    cout << calc(0) << endl;
    return 0;
}

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

using namespace std;

#define N 300000
#define INF 0x3f3f3f3f

int n,m,a[N],b[N],c[N],d[N],f1[N],f2[N],xb1,xb2,ans,tot,tmp,now,vis[N];
long long s1;
vector<int> g[N];

void gg(){
	puts("-1");
	exit(0);
}

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i){
		scanf("%d%d%d",a+i,b+i,c+i);
		++d[a[i]]; ++d[b[i]];
		g[a[i]].push_back(i);
	}
	for (int i=1;i<=n;++i){
		if (!vis[i]){
			int x=i; bool flag=0;
			while (1){
				if (vis[x]==1||g[x].size()!=1||d[x]!=2){
					flag=1; break;
				}
				x=b[g[x][0]];
				if (x==i) break;
			}
			if (flag){vis[i]=1; continue;}
			x=i;
			int sum=0,num=0;
			while (1){
				++num;
				vis[x]=2;
				x=b[g[x][0]];
				sum+=c[g[x][0]]-1;
				if (x==i) break;
			}
			if (num>1){
				++tot; ++ans;
				s1+=sum;
			}
			else{
				if (sum>1) f1[++xb1]=sum-1;
			}
		}
	}
	for (int i=1;i<=m;++i){
		if (a[i]!=b[i]){
			if (!c[i]) gg();
			++ans;
		}
		if (vis[a[i]]==1){
			if (c[i]>1){
				if (a[i]!=b[i]) now+=c[i]-1;
				else f2[++xb2]=c[i]-1;
			}
		}
	}
	sort(f1+1,f1+xb1+1,greater<int>());
	sort(f2+1,f2+xb2+1,greater<int>());
	for (int i=1;i<=xb1;++i) f1[i]+=f1[i-1];
	for (int i=1;i<=xb2;++i) f2[i]+=f2[i-1];
	tmp=INF;
	for (int i=0,j=xb1;i<=xb2;++i){
		int t=now+f2[i];
		if (t==0&&tot) continue;
		t+=s1;
		for (;j&&t+f1[j-1]>=tot;--j);
		if (t+f1[j]>=tot) tmp=min(tmp,i+j*2); 
	}
	if (tmp>=INF) gg();
	printf("%d\n",ans+tmp);
	
	return 0;
}
			

Measured memory_bytes: 16036
#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 MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

char ch[105];
int k;
LL cnt[105];

int main()
{
	scanf("%s%d", ch, &k);
	int n = strlen(ch);
	
	int cl = 0, bl = 0;
	bool beg = true;
	rep(i, n) if(i == 0 || ch[i] == ch[i - 1]) cl ++;
	else {
		if(beg) bl = cl;
		cnt[cl] ++;
		cl = 1;
		beg = false;
	}
	cnt[cl] ++;
	
	if(beg) {
		printf("%lld\n", 1LL * n * k / 2);
		return 0;
	}
	if(ch[0] == ch[n - 1]) {
		cnt[cl] --;
		cnt[bl] --;
		cnt[cl + bl] ++;
	}
	rep1(i, n) cnt[i] *= k;
	if(ch[0] == ch[n - 1]) {
		cnt[cl] ++;
		cnt[bl] ++;
		cnt[cl + bl] --;
	}
	
	LL ret = 0;
	rep1(i, n) ret += (i / 2) * cnt[i];
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest20191029
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int ans = n;

            for(int i = 0; i < n - 1; i++)
            {
                if (s[i] == s[i + 1])
                    ans--;
            }


            Console.WriteLine(ans);

        }
    }
}


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

int main(void)
{
    int H,W;
    while(1)
    {
        cin >> H >> W;
        if(H==0 && W==0)break;
        for(int i = 0 ; i < H ; i++)
        {
            for(int j = 0 ; j < W ; j++)cout << "#";
            cout << endl;
        }
        cout << endl;
    }
  return 0;
}


Measured memory_bytes: 3096
#include<string>
#include<cctype>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<queue>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
const int maxn = 1000 + 8;
int sta[maxn];
char c[100];
int top ;
/*
bool isEmpty(int sta[])
{
    return !top;
}*/

int pop()
{
    int x = sta[top];
    top--;
    return x;
}
void push(int x)
{
    ++top;
    sta[top] = x;
}
void add()
{
    int y = pop();
    int x = pop();
    //cout <<"x + y: " << x + y << endl;
    push(x+y);
}
void subtract()
{
    int y =  pop();
    int x =  pop();
    //cout << "x - y: " <<x - y << endl;
    push(x-y);
}

void multiple()
{
    int y = pop();
    int x = pop();
    //cout <<"x * y: "<< x * y << endl;
    push(x*y);
    //cout << sta[top] << endl;
}
void operate(char s[])
{
    int x = atoi(c);
    push(x);
}
int main()
{
    top = 0;
    while(scanf("%s",c) != EOF)
    {
        if(strcmp(c,"+") == 0){
            add();
        }else if(strcmp(c,"-") == 0){
            subtract();
        }else if(strcmp(c,"*") == 0){
            multiple();
        }else {
            operate(c);
        }
    }
    printf("%d\n",sta[top]);
    return 0;
}

Measured memory_bytes: 3204
#include <iostream>


using namespace std;


void swap(int *x, int *y)
{
  int tmp=*x;
  *x = *y;
  *y = tmp;
}


int main()
{
  int n, p[100000], cnt=0;

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

  for (int i=0; i<n; i++){
    if (i == n-1 && i+1 == p[i]){
      cnt++;
    } else if (i+1 == p[i]){
      cnt++;
      swap(&p[i], &p[i+1]);
    }
  }
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

N = int(input())
dp = [0] * (N + 1)
dp[0] = 1
for i in range(N + 1):
  if i + 4 <= N:
    dp[i + 4] += dp[i]
  if i + 7 <= N:
    dp[i + 7] += dp[i]
if dp[-1]:
  print("Yes")
else: print("No")

Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

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

    vector< int> v(n);
    while(m--) {
        int a, b;
        cin >> a >> b;
        v[a - 1]++;
        v[b - 1]++;
    }

    for(int x: v) cout << x << endl;
}

Measured memory_bytes: 256
n,m,d = gets.split.map(&:to_i)
count = 0
if d==0
  count = n*1.0
elsif d>(n-1)/2.0
  count = n*1.0
else
  count = 2.0*(n-2*d)+2.0*d
end

puts (count/n**2)*(m-1)


Measured memory_bytes: 1788
def low_elements(seq):
    count = 1
    m = seq[0]
    for l in range(1, len(seq)):
        if seq[l] <= m:
            count += 1
            m = seq[l]
    return count


n = int(input())
seq1 = list(map(int, input().split()))
print(low_elements((seq1)))

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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 3e5+10;

vector<int> inv(MAX+10);
vector<int> fact(MAX+10);
vector<int> invfact(MAX+10);

inline int add(int a, int b)
{
	int ret=((ll)a+b)%modn;
	if(ret<0) {
		ret=(ret+modn)%modn;
	}
	return ret;
}

inline int mul(int a, int b)
{
	return ((ll)a*b)%modn;
}

inline int C(int n, int r)
{
	if(r<0 or r>n) return 0;
	return mul(mul(fact[n], invfact[n-r]), invfact[r]);
}

void precal()
{
	fact[0]=inv[0]=invfact[0]=1;
	for(int i=1; i<=MAX; i++) {
		fact[i]=mul(i, fact[i-1]);
		inv[i]=(i==1)?1:add(modn, -mul(modn/i, inv[modn%i]));
		invfact[i]=mul(inv[i], invfact[i-1]);
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    precal();
	int h, w, n;
	cin>>h>>w>>n;
	h--, w--;
	vector<pair<int, int>> walls;
	for(int i=0; i<n; i++) {
		int r, c;
		cin>>r>>c;
		r--, c--;
		walls.emplace_back(r, c);
	}
	sort(walls.begin(), walls.end());
	map<pair<int, int>, int> dp;
	function<int(int, int)> solve = [&](int i, int j)
	{
		if(dp[{i, j}]) return dp[{i, j}]; 
		int ans=C(h-i+w-j, h-i);
		for(auto p:walls) {
			if(p>make_pair(i, j)) {
				ans=add(ans, -mul(C(p.first-i+p.second-j, p.first-i), solve(p.first, p.second)));
			}
		}
		return dp[{i, j}]=ans;
	};
	cout<<solve(0, 0)<<"\n";
    return 0;
}



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

bool judge(int W, int H, int x, int y, int r) {
	int up = y+r,
	down = y-r,
	right = x+r,
	left = x-r;

	return((up <= H && down >= 0) && (right <= W && left >= 0));
}

int main(void) {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if(judge(W, H, x, y, r)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
char s[5];
int main(){
	scanf("%s",s);
	if(s[0]=='a'||s[0]=='e'||s[0]=='i'||s[0]=='o'||s[0]=='u'){
		printf("vowel");
	}else printf("consonant");
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, L, R, H, W;


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

	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i += 2)cout << s[i];
	cout << endl;
	return 0;
}

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

using ll = long long;

const ll mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

ll mod_pow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll res = mod_pow(x * x % mod, n / 2, mod);
    if (n & 1) res = res * x % mod;
    return res;
}

ll ext_gcd(ll a, ll b, ll& x, ll& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll g = ext_gcd(b, a % b, y, x);
  y -= (a / b) * x;
  return g;
}

ll mod_inv(ll a, ll mod) {
  ll x, y;
  ext_gcd(a, mod, x, y);
  return (x % mod + mod) % mod;
}

ll fact(ll n, ll mod) {
  ll res = 1;
  for (ll i = 2; i <= n; ++i) res = (res * i) % mod;
  return res;
}

ll comb(ll n, ll r) {
    // ll numerator = fact(n, mod);
    // ll denominator = (fact(r, mod) * fact(n - r, mod)) % mod;
    // return (numerator * mod_inv(denominator, mod)) % mod;
    ll res = 1;
    for (ll i = 1; i <= r; ++i) {
        res = ((res * (n - i + 1)) % mod * mod_inv(i, mod)) % mod;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    cout << (((mod_pow(2, n, mod) - 1 - comb(n, a) - comb(n, b)) % mod) + mod) % mod << endl;
}


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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N;
    string S;
    cin >> N >> S;

    int right=0, left=0;

    REP(i, S.size()) {
        if (S[i] == '(') ++right;
        else {
            if (right > 0) --right;
            else ++left;
        }
    }

    cout << string(left, '(') << S << string(right, ')') << endl;

}


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    string a;
    cin>>a;
    map<char,ll> m;
    for(auto i:a) m[i]++;
    if(sz(m)!= 2) cout<<"No" el;
    else cout<<"Yes" el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!

Measured memory_bytes: 3656