akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
struct edge{
	int from,to,cost;
};
signed main(){
	int n,m;
	cin>>n>>m;
	edge es[2010];
	rep(i,m){
		cin>>es[i].from>>es[i].to>>es[i].cost;
		es[i].from--;
		es[i].to--;
		es[i].cost=-es[i].cost;
	}
	int d[1010];
	rep(i,n)d[i]=INF;
	d[0]=0;
	rep(i,n-1){
		bool update=false;
		rep(j,m){
			edge e=es[j];
			if(d[e.from]!=INF&&d[e.from]+e.cost<d[e.to]){
				d[e.to]=d[e.from]+e.cost;
				update=true;
			}
		}
		if(!update)break;
	}
	bool ne[1010]={};
	rep(i,n-1){
		rep(j,m){
			edge e=es[j];
			if(d[e.from]!=INF&&d[e.from]+e.cost<d[e.to]){
				d[e.to]=d[e.from]+e.cost;
				ne[e.to]=true;
			}
			if(ne[e.from])ne[e.to]=true;
		}
	}
	if(ne[n-1])cout<<"inf"<<endl;
	else cout<<(-d[n-1])<<endl;
}

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

long long a[200013],n,ans,j,h;

int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n;i++)
	{
	 for(j;j<n;j++)
	 {
	  if((h|a[j])!=h+a[j]) break;
	  else 
	       h=h+a[j],
	       ans=ans+j-i+1;
	  }
	 h-=a[i];
	 }
	 cout<<ans<<endl;
 return 0;
 }

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

const int mod = 998244353;

char s[300010];
int cnt[3];
vector <int> all[100010];

int id(char c) {return c == 'R' ? 0 : c == 'G' ? 1 : 2;}

int main() {
	int n; scanf("%d", &n);
	scanf("%s", s);
	for (int i = 0; i < 3 * n; i++) {
		all[cnt[id(s[i])]].push_back(i), cnt[id(s[i])]++;
	}
	int now = 0;
	long long ans = 1;
	for (int i = 0; i < n; i++) {
		while (now < n && all[now][1] < all[i][2]) now++;
		ans = (ans * (now - i)) % mod;
	}
	now = 0;
	for (int i = 0; i < n; i++) {
		while (now < n && all[now][0] < all[i][1]) now++;
		ans = (ans * (now - i)) % mod;
	}
	for (int i = 1; i <= n; i++) {
		ans = (ans * i) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n, T; cin >> n >> T;
  vi t(n), c(n);
  rep(i,n) cin>>c[i]>>t[i];
  int ans=-1;
  int C = numeric_limits<int>::max();
  rep(i,n) {
    if(t[i]<=T){
      if(c[i]<C){
        C = c[i];
        ans = c[i];
      }
    }
  }
  if(ans<0) cout << "TLE" << endl;
  else cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<stack>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
#define MAX 510000
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;}
using namespace std;


int main(){
  ll N,ans=0;
  cin>>N;
  ll A[N],B[N],C[N],DP[N][3];
  REP(i,N){
    cin>>A[i]>>B[i]>>C[i];
    DP[i][0]=0;
    DP[i][1]=0;
    DP[i][2]=0;
  }
  DP[0][0]=A[0];
  DP[0][1]=B[0];
  DP[0][2]=C[0];
 
  for(int i=1; i<N; ++i){
    DP[i][0]=A[i]+max(DP[i-1][1],DP[i-1][2]);
    DP[i][1]=B[i]+max(DP[i-1][2],DP[i-1][0]);
    DP[i][2]=C[i]+max(DP[i-1][0],DP[i-1][1]);
  }
  
  
  cout<<max(DP[N-1][0],max(DP[N-1][1],DP[N-1][2]))<<endl;
  return 0;
}

Measured memory_bytes: 4992
#include<cstdio>

int main(){
  int w,h;
  scanf("%d %d",&h,&w);
  for(int i=0;i<h;i++){
    int x = -1;
    for(int j=0;j<w;j++){
      char c;
      scanf(" %c",&c);
      if(c=='c'){
        x = 0;
      }else if(x!=-1){
        x++;
      }
      printf("%d",x);
      if(j<w-1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2672
/**
 *  author: nayakashutosh9
 *	[2020-09-19 17:25]
**/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define modd 998244353
#define inf 1e18
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> pbds;
const int N = 300005;
/*******************************************************/


void solve() {
	int n, x, m; cin >> n >> x >> m;
	int ans = x, cur = x;
	map<int, pii> vis;
	for (int i = 2; i <= n; i++) {
		cur = (cur * cur) % m;
		cur %= m;
		ans += cur;
		if (vis.count(cur)) {
			int st = i - vis[cur].ff;
			int val = ans - vis[cur].ss;
			int left = n - i;
			ans += (left / st) * val;
			int rem = left % st;
			while (rem > 0) {
				cur = (cur * cur) % m;
				cur %= m;
				ans += cur;
				rem--;
			}
			break;
		}
		else vis[cur] = {i, ans};
		if (cur == 0) break;
	}
	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int T = 1;
	// cin >> T; cin.ignore();
	for (int i = 1; i <= T; i++) {
		// cout << "Case #" << i << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

Measured memory_bytes: 6716
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        double[] a = new double[n];
        for(int i = 0;i<n;i++){
            a[i] = Integer.parseInt(sc.next());
        }
        double ans = 0;
        for(int i = 0;i<n;i++){
            ans += 1/a[i];
        }
        ans = 1/ans;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
package main

import (
	"fmt"
)

func main() {
	var H, W uint64
	fmt.Scanf("%d %d\n", &H, &W)
	r := H / 2
  if H == 1 || W == 1 {
    fmt.Println(1)
  } else if H % 2 == 0 {
		fmt.Println(r * W)
    } else {
		i := W / 2
		j := W / 2
		if W % 2 != 0 {
			i += 1
		}
		result := (r + 1) * i + r * j
		fmt.Println(result)
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#if 0
#define DEBUG(x) do{cerr << #x << "=" << x << endl;}while(0);
#else
#define DEBUG
#endif


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

	int tmp = 2 * d + 1;

	cout << n/tmp+((n%tmp)?1:0) << 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.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author zhangyong
 */
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 in, PrintWriter out) {
            int num = in.nextInt();
            int i;
            for (i = 1; i <= num; i <<= 1) {
                if (i > num) {
                    break;
                }
            }
            out.println(i / 2);
        }

    }
}



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

const int size=234567;
int N,K,L;
int p[size],q[size],r[size],s[size],g1[size],g2[size];
int par[size],Rank[size],G[size],H[size],I[size];
vector<int> cnt[size];
typedef pair<int, int> pii;
#define mp make_pair
map<pii, int> a;

void init(int n){
    for(int i=1; i<=n; i++){
        par[i]=i;
        Rank[i]=0;
    }
}
int find(int x){
    if(par[x]==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(Rank[x]<Rank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(Rank[x]==Rank[y]) Rank[x]++;
    }
}
bool same(int x,int y){
    return find(x)==find(y);
}

int main(){

cin>>N>>K>>L; 

init(N);
for(int i=0; i<K; i++){
    scanf("%d %d",&p[i],&q[i]);
    unite(p[i],q[i]);
}
for(int i=1; i<=N; i++) G[i]=find(i);

init(N);
for(int i=0; i<L; i++){
    scanf("%d %d",&r[i],&s[i]);
    unite(r[i],s[i]);
}
for(int i=1; i<=N; i++) H[i]=find(i);

for(int i=1; i<=N; i++){
    a[mp(G[i], H[i])]++;
}

for(int i=1; i<=N; i++) printf("%d ",a[mp(G[i], H[i])]);

return 0;
 
}

Measured memory_bytes: 26752
fun main() {
    var n=readLine()!!.toInt()
    var s=readLine()!!
    var ans=0
    for (i in 0 until 1000){
        var tmp=i.toString().padStart(3, '0')
        var ind=0
        for (j in s){
            if (tmp[ind]==j){
                ind++
                if (ind==3) break
            }
        }
        if (ind==3){
            ans++
        }
    }
    println(ans)

}

Measured memory_bytes: 38280
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,ans1="",ans2;
  map<string,int> mp;
  while(cin >> s){
    if(ans1==""){
      ans1=s;
      ans2=s;
    }
    mp[s]++;
    if(mp[s]>mp[ans1]){
      ans1=s;
    }
    if(s.size()>ans2.size()){
      ans2=s;
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  if (A*N<=B) {
    cout << A*N << endl;
  }
  else {
    cout << B << endl;
  }
}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
	long long a,b,c,d,e;
	double s;
	while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d))
	{
		s=a*b/2.0;
		if(a%2==0&&b%2==0&&a/2==c&&b/2==d)
		e=1;
		else
		e=0;
		printf("%.6lf %d\n",s,e);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
  short rate_before,rate_after;
  int price_before,a,item_a_after,item_b_after,max;
  int item_a_before,m,b,item_b_before;

  // a,p = ?¨???????????????????                                                       
  // item_a_before,item_b_before = ????¨???????????????????                             
  // item_a_after,item_b_after = ????¨???????????????????                               

  while(1){
    max = 0;
    scanf("%hd %hd %d",&rate_before,&rate_after,&price_before);

    if(rate_before == 0 && rate_after == 0 && price_before == 0){
      break;
    }

    for(a = 1;a <= price_before/2;a++){
      item_a_before= a * (100+rate_before) / 100;
      m = price_before - item_a_before;
      b = m * 100 / (100+rate_before);

      while(1){
          b++;
          item_b_before = b * (100+rate_before) / 100;
          if(item_a_before + item_b_before != price_before){
              b--;
              break;
          }
      }

      item_b_before = b * (100+rate_before) / 100;

      if(item_a_before + item_b_before == price_before){
          item_a_after = a * (100+rate_after) / 100;
          item_b_after = b * (100+rate_after) / 100;
          if(item_a_after + item_b_after > max){
              max = item_a_after + item_b_after;
          }
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 600
n = int(input())
s = input()
words = [[0]*3for _ in range(n)] #i以降のR,G,Bの数(i含まず)
for i in range(n-2,-1,-1):
    if s[i+1] == 'R':
        words[i][0]+=1
    elif s[i+1] == 'G':
        words[i][1] +=1
    else:words[i][2] +=1
    words[i][0] +=words[i+1][0]
    words[i][1] +=words[i+1][1]
    words[i][2] +=words[i+1][2]
ans = 0
for i in range(n):
    for j in range(i+1,n):
        
        if s[i] == 'R':
            if s[j] == 'G':
                ans += words[j][2]
                if j+j-i >n-1:continue
                if s[j+(j-i)] == 'B':ans-=1
            if s[j] == 'B':
                ans += words[j][1]
                if j+j-i >n-1:continue
                if s[j+(j-i)] == 'G':ans-=1
        if s[i] == 'G':
            if s[j] == 'R':
                ans += words[j][2]
                if j+j-i >n-1:continue
                if s[j+(j-i)] == 'B':ans-=1
            if s[j] == 'B':
                ans += words[j][0]
                if j+j-i >n-1:continue
                if s[j+(j-i)] == 'R':ans-=1
        if s[i] == 'B':
            if s[j] == 'G':
                ans += words[j][0]
                if j+j-i >n-1:continue
                if s[j+(j-i)] == 'R':ans-=1
            if s[j] == 'R':
                ans += words[j][1]
                if j+j-i >n-1:continue
                if s[j+(j-i)] == 'G':ans-=1
print(ans)
 


        

        

        
        
    

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

namespace ABC159B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int N = S.Length;
            int a = 1;
            int b = (N - 1) / 2;
            int c = (N + 3) / 2;
            int d = N;
            bool hantei = true;
            if (N == 3)
            {
                if (S[a-1] != S[d-1])
                {
                    hantei = false;
                }
            }
            else
            {
                while (a <= (N - 1) / 2)
                {
                    if (S[a-1] == S[b-1]& S[a-1] == S[c-1] & S[a-1] == S[d-1])
                    {
                    }
                    else
                    {
                        hantei = false;
                    }
                    a += 1;
                    b -= 1;
                    c += 1;
                    d -= 1;
                }
            }
            if (hantei == true)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 25672
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, const char *argv[]) {
  vector<int> abc(3);
  int k;
  cin >> abc[0] >> abc[1] >> abc[2];
  cin >> k;

  vector<int>::iterator iter = max_element(abc.begin(), abc.end());
  size_t index = distance(abc.begin(), iter);

  abc[index] *= (int)pow(2.0, (double)k);
  cout << accumulate(abc.begin(), abc.end(), 0) << endl;

  return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
除DP
dp[i]=|初めて通った壁がi番目|
dp[i]=|(1,1) \to w_i| - \sum^{i-1}_{j=0}|w_j \to w_i|dp[j]
*/

struct pos{
	ll x,y;
};
bool operator<(const pos &lhs, const pos &rhs){
	return lhs.x+lhs.y<rhs.x+rhs.y;
}

struct Factorial{
	long long N,mod;
	vector<long long> fact,inv;
	long long mod_pow(long long x,long long n){
		long long res=1;
		while(n){
			if(n&1) (res*=x)%=mod;
			(x*=x)%=mod;
			n>>=1;
		}
		return res;
	}
	long long Inverse(long long n){
		return mod_pow(n,mod-2);
	}
	Factorial(){}
	Factorial(long long sn,long long smod){
		N=sn; mod=smod;
		fact.reserve(sn+1); inv.reserve(sn+1);
		//初期化
		fact[0]=1;
		for(int i=1;i<=sn;i++){
			fact[i]=(fact[i-1]*i) % mod;
		}
		inv[sn]=Inverse(fact[sn]);
		for(int i=sn;i>0;i--){
			inv[i-1]=(inv[i]*i) % mod;
		}
	}
	long long Fact(long long n){
		if(n<0)return 0;
		return fact[n];
	}
	long long Inv(long long n){
		if(n<0)return 0;
		return inv[n];
	}
	long long Combination(long long n,long long r){
		if(n<r)return 0;
		if(r<0)return 0;
		if(r==0)return 1;
		long long ans=1;
		ans = (ans*Fact(n)) % mod;
		ans = (ans*Inv(r)) % mod;
		ans = (ans*Inv(n-r)) % mod;
		return ans;
	}
};

ll H,W,n,dp[3010]={},ans=0,mod=1e9+7;
pos w[3010];

int main(void){
	cin>>H>>W>>n;
	rep(i,n){
		ll x,y;
		cin>>y>>x;
		w[i]={x,y};
	}
	w[n]={W,H};
	//
	Factorial f(200010,mod);
	sort(w,w+n+1);
	reg(i,0,n){
		ll sum=0;
		rep(j,i){
			if(w[i].x>=w[j].x && w[i].y>=w[j].y){
				sum=(sum+(dp[j]*f.Combination(w[i].x-w[j].x+w[i].y-w[j].y, w[i].x-w[j].x))%mod)%mod;
			}
		}
		dp[i]=(f.Combination(w[i].x+w[i].y-2, w[i].x-1)+mod-sum)%mod;
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 3456
L = []
for i in range(5):
    L.append(int(input()))

import math
Lc = []
L_subtract = []
for i in range(len(L)):
    Lc.append(math.ceil(L[i]/10)*10)
    L_subtract.append(Lc[i]-L[i])
print(sum(Lc) - max(L_subtract))

Measured memory_bytes: 3060
def main():
	H, W = [int(x) for x in input().split(" ")]
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	c = [[0] * W for i in range(H)]
	k = 0
	for i in range(len(c)):
		for j in range(len(c[i])):
			if i % 2 == 0:
				c[i][j] = str(k + 1)
				A[k] -= 1
			elif i % 2 == 1:
				c[i][-j-1] = str(k + 1)
				A[k] -= 1
			if A[k] == 0:
				k += 1
	print("\n".join([" ".join(ci) for ci in c]))

main()

Measured memory_bytes: 9868
#include <stdio.h>
int main(){
  int n,m,x,i,r=0,s=0,a;
  scanf("%d%d%d",&n,&m,&x);
  for(i=0;i<m;i++){
    scanf("%d",&a);
    a>x?r++:s++;
  }
  printf("%d",r>s?s:r);
  return 0;
}

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

int digit(int n) {
	int count = 0;
	while (n != 0) {
		n /= 10;
		count++;
	}
	return count;
}

struct number {
	int num;
	int p;
	int y;
	bool operator<(const number& another) const {
		if (p != another.p)
			return p < another.p;
		if (y != another.y)
			return y < another.y;
	}
};

bool cmp(const number& a, const number& b) {
	return a.num < b.num;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<number> city(m);
	for (int i = 0; i < m; i++) {
		city[i].num = i;
		cin >> city[i].p >> city[i].y;
	}
	sort(city.begin(), city.end());
	int count = 1;
	city[0].y = 1;
	for (int i = 1; i < m; i++) {
		if (city[i].p != city[i - 1].p)
			count = 1;
		else
			count++;
		city[i].y = count;
	}

	sort(city.begin(), city.end(), cmp);

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < 6 - digit(city[i].p); j++)
			cout << 0;
		cout << city[i].p;
		for (int j = 0; j < 6 - digit(city[i].y); j++)
			cout << 0;
		cout << city[i].y << endl;
	}
	return 0;
}

Measured memory_bytes: 2688
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	d := make([]int, n)
	
	for i := range d {
		fmt.Scan(&d[i])
	}
	
	sort.Ints(d)

	fmt.Println(d[n / 2] - d[n / 2 - 1])
}


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll a,b;
    cin >> a >> b;

    if( a <= 0 && b >= 0 )
    {
        cout << "Zero" << endl;
    }
    else if( b < 0 )
    {
        if( abs(a-b)%2==0 ) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    }
    else cout << "Positive" << endl;
}


Measured memory_bytes: 256
(declaim (optimize (speed 3) (debug 0) (safety 0)))

(let ((x (read)))
  (declare (type fixnum x))

  (defun solve (n &optional (i 0) (ans 1))
    (declare (type fixnum n i ans))
    (if (= i n)
      ans
      (solve n (the fixnum (1+ i)) (the fixnum (mod (* ans (1+ i)) (+ (expt 10 9) 7))))))

  (format t "~a~%"
          (solve x)))



Measured memory_bytes: 24328
#include<cstdio>
#include<iostream>
#include<cstdlib>
using namespace std;
typedef long long ll;
int a[5],b[5];
void dfs(int pos,int sum)
{
	if(pos==4&&sum==7)
	{
		printf("%d",a[1]);
		if(b[1]==1)printf("+");
		else printf("-");
		printf("%d",a[2]);
		if(b[2]==1)printf("+");
		else printf("-");
		printf("%d",a[3]);
		if(b[3]==1)printf("+");
		else printf("-");
		printf("%d",a[4]);
		printf("=7");
		exit(0);
	}
	if(pos==4)return;
	b[pos]=1;
	dfs(pos+1,sum+a[pos+1]);
	b[pos]=2;
	dfs(pos+1,sum-a[pos+1]);
}
int main()
{
	for(int i=1;i<=4;i++)
	{
		scanf("%1d",&a[i]);
	}
	dfs(1,a[1]);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<double,double>P;


int main()
{
    ll m,n;
    cin>>n>>m;
    if(n>=m/2)
    {
        cout<<m/2;
    }
    else
    {
        ll k=(m-2*n)/2;
        cout<<n+k/2;
        
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

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

ll calc (ll x) {
  ll cnt1 = (x+1)/2;
  ll res = cnt1%2;
  if (x%2 == 0) res ^= x;
  return res;
}

int main () {
  ll a, b;
  cin >> a >> b;
  ll ans = calc(b)^calc(a-1);
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


void sugoi_sort(int N, int A[], int B[]) {
	const int b = 8;
	int tmpA[100001], tmpB[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmpA[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmpB[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[tmpA[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmpA[i] >> k * b & ((1 << b) - 1)]] = tmpA[i];
			B[kazu2[tmpA[i] >> k * b & ((1 << b) - 1)]] = tmpB[i];
		}
	}
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), M = getint();
	int A[100000], B[100000];
	rep(i, N) {
		A[i] = getint();
		B[i] = getint();
	}
	sugoi_sort(N, A, B);
	priority_queue<int> que;

	int kotae = 0;
	int j = 0;
	rep1(i, M) {
		while (j < N && A[j] <= i) {
			que.push(B[j++]);
		}
		if (que.size()) {
			kotae += que.top();
			que.pop();
		}
	}

	printf("%d", kotae);

	Would you please return 0;
}

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

int vis[101];

int main(){
	int N, K;
	cin >> N >> K;
	
	for(int i=1; i<=K; i++){
		int d1, v;
		cin >> d1;                   //1
		for(int j=1; j<=d1; j++){    //3
			cin >> v;
			vis[v] = 1;
		}
	}
	
	int ans = 0;
	for(int i=1; i<=N; i++){
		if(vis[i]==0) ans++;
	}
	
	cout << ans;
	return 0;
}
 

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

template <uint32_t mod> class modint {
  using i64 = int64_t;
  using u32 = uint32_t;
  using u64 = int64_t;
public:
  u32 v;
  constexpr modint(const i64 x = 0) noexcept
    : v(x < 0 ? mod - 1 - -(x + 1) % mod : x % mod) {}
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    v += rhs.v;
    if (v >= mod) v -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (v < rhs.v) v += mod;
    v -= rhs.v;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    v = u64(v) * rhs.v % mod;
    return *this;
  }
  constexpr modint &operator/=(const modint rhs) noexcept {
    *this *= rhs.pow(mod - 2);
    return *this;
  }
  constexpr modint pow(u32 exp) const noexcept {
    modint self(*this), ret(1);
    while (exp != 0) {
      if (exp % 2 != 0) ret *= self;
      self *= self;
      exp /= 2;
    }
    return ret;
  }
};
 
template <uint32_t mod>
istream &operator>>(istream &is, modint<mod> &rhs) {
  int64_t v;
  is >> v;
  rhs = modint<mod>(v);
  return is;
}
 
template <uint32_t mod>
ostream &operator<<(ostream &os, const modint<mod> &rhs) {
  os << rhs.v;
  return os;
}

constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int MAX = 1e5;

vector<long> fact(MAX), finv(MAX), inve(MAX);

void init() {
  fact.at(0) = fact.at(1) = 1;
  finv.at(0) = finv.at(1) = 1;
  inve.at(1) = 1;
  for (int i = 2; i < MAX; i++) {
    fact.at(i) = fact.at(i - 1) * i % MOD;
    inve.at(i) = MOD - inve.at(MOD % i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i - 1) * inve.at(i) % MOD;
  }
}

long com(long n, long r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact.at(n) * (finv.at(r) * finv.at(n - r) % MOD) % MOD;
}

int main() {
  init();
  using mint = modint<MOD>;
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  mint ans = 0;
  for (int i = 0; i < N; i++) {
    ans += com(i, K - 1) * A.at(i);
    ans -= com(N - i - 1, K - 1) * A.at(i);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 6428
n, m, l = map(int, input().split())
A, B = [], []
for i in range(n):
    A.append(list(map(int, input().split())))
for i in range(m):
    B.append(list(map(int, input().split())))
ans = []
for i in range(n):
    li = []
    for j in range(l):
        s = 0
        for k in range(m):
            s += A[i][k] * B[k][j]
        li.append(s)
    ans.append(li)
for a in ans:
    print(' '.join(map(str, a)))


Measured memory_bytes: 6904
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




long long fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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


int main() {
  // 前処理
  //COMinit();

  ll N,K;
  cin>>N;
	string S;
  cin>>S;

  cin>>K;
  char a;
  a=S[K-1];

  FOR(i,0,N-1){
    if(a!=S[i]){
      S[i]='*';
    }
  }


cout<<S<<endl;

  return 0;
 
}


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

using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1005;
int dp[maxn][maxn];
char str[maxn][maxn];


int main() {
//    freopen("in.in", "r", stdin);
    int n, m, u, v;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> str[i] + 1;
    }
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (str[i][j] == '#') dp[i][j] =  0;
            else {
                dp[i][j] = (dp[i][j] + (dp[i - 1][j] + dp[i][j - 1]) % mod) %mod;
            }
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}

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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

int main(){
    ll N, M;
    cin >> N >> M;
    if(N==M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;

int fact(int n){
    int x = 1;
    FOR(i,1,n+1) x *= i;
    return x;
}


int main() {
    int n; cin >> n;
    vi x(n),y(n);
    rep(i,n) cin >> x.at(i) >> y.at(i);
    double d[n][n];
    rep(i,n) {
        rep(j,n){
            d[i][j] = sqrt(pow(x.at(i)-x.at(j),2) + pow(y.at(i)-y.at(j),2));
        }
    }
    double ans = 0.0;
    vi nodes;
    rep(i,n) nodes.pb(i);
    do {
        rep(i,n-1) ans += d[nodes[i]][nodes[i+1]];
    } while (next_permutation(ALL(nodes)));
    ans /= fact(n);
    printf("%.7f\n",ans);
    // cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



int main() {
    int N, R;
    cin >> N >> R;
    cout << R + 100 * (10 - min(N, 10)) << endl;
}


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

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N;
v_ll A,C;
int main(){
  cin >> N;
  A.assign(N+10,0);
  C.assign(N+10,-1);
  for (ll i=1;i<=N;i++){
    cin >> A[i];
  }
  ll ans = 0;

  for (ll i=1;i<=N;i++){
    auto iter = lower_bound(C.begin()+1,C.begin()+N+1,A[i]);
    C[(iter-C.begin())-1]=A[i];
  }
  for (ll i=1;i<=N;i++){
    if (C[i]>-1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1920
A,B=map(int,input().split())
l=[[0]*100 for i in range(40)]
A-=1
for i in range(0,19,2):
    for j in range(1,100,2):
        if A:
            l[i][j]=1
            A-=1
B-=1
for i in range(21,40,2):
    for j in range(1,100,2):
        if B:
            l[i][j]=1
            B-=1
print(40,100)
for i in l[:20]:
    for j in i:
        print("." if j else "#",end="")
    print()
for i in l[20:]:
    for j in i:
        print("#" if j else ".",end="")
    print()

Measured memory_bytes: 3700
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc122/editorial.pdf
・数え上げDP
・正規表現
"""

import sys, re
from itertools import product
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()

# NGパターン一覧
patterns = [
    # 任意の0か1文字
    re.compile(r'^(.?)AGC(.?)$'),
    re.compile(r'^(.?)GAC(.?)$'),
    re.compile(r'^(.?)ACG(.?)$'),
    # 任意の1文字
    re.compile(r'^A.GC$'),
    re.compile(r'^AG.C$'),
]

# dp[i][j] := 全部でi文字の時、最後の3文字がjとなる文字列の数
dp=[Counter() for i in range(N+1)]
keys = [''.join(key) for key in product('ACGT', repeat=3)]
# 3文字での初期値
for key in keys:
    if key not in ['AGC', 'GAC', 'ACG']:
        dp[3][key]=1
    else:
        dp[3][key]=0

for i in range(4, N+1):
    for key in keys:
        for nxt in 'ACGT':
            # NGパターンのいずれにもマッチしないものだけ遷移させる
            if not any([ptn.match(key+nxt) for ptn in patterns]):
                dp[i][key[1:]+nxt]=(dp[i][key[1:]+nxt]+dp[i-1][key])%MOD
print((sum(dp[N].values()))%MOD)


Measured memory_bytes: 4424
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        u: [i32; 4],
    };
    println!(
        "{}",
        (0..100)
        .filter(|&x| x >= u[0] && x < u[1] && x >= u[2] && x < u[3])
        .count()
    );
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  string s,kk;
  cin >> n >> k >> s;
  
   string  kmojime =s.substr(k-1,1);
  
  	 if (kmojime=="A") {
    	kk="a";
     }
  	if (kmojime=="B") {
     	kk="b";
  }
 
 	 if (kmojime=="C") {
   		 kk="c";	
  }
   cout <<s.substr(0,k-1)<<kk<<s.substr(k,n-k)      << endl; 
  
}

Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())
h = x/(a**2)
if b//2 >= h:

    d = 2*h*a/b

    sin = math.degrees(math.acos(d/((d**2+b**2)**0.5)))
    print(sin)
else:
    d = 2*(b-h)*a/a
    sin = math.degrees(math.acos(d/((d**2+a**2)**0.5)))
    print(90-sin)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N,D;
    cin>>N>>D;
    if(N%(D*2+1)){
        cout<<N/(D*2+1)+1<<endl;
    }else{
        cout<<N/(D*2+1)<<endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, T, i, t[200001], ans;

    cin >> N >> T;

    for(i=1; i<=N; i++){
        cin >> t[i];
    }

    if(N==1) cout << T << endl;

    else{
        ans = T;

        for(i=2; i<=N; i++){
            if(t[i]-t[i-1] >= T){
                ans += T;
            }

            else{
                ans += (t[i]-t[i-1]);
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
s = list(map(str,input()))
a,b,c = 0,0,0

for i in range(len(s)):
    if s[i] == "a":
        a += 1
    elif s[i] == "b":
        b += 1
    else:
        c += 1

if abs(a-b) <= 1 and abs(b-c) <= 1 and abs(c-a) <= 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 77488