akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 

public class Main {
    public static void main(String[] args) {   
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        double x =(double)(a+b)/2;
        int y =(int)x;
        if((x-y)>0)
           System.out.println(y+1);
        else
           System.out.println(y);

		
    }
}



Measured memory_bytes: 21972
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n;
	char str[100000];
	int i, j;
	int count;
	char ans[100000];
	char buf[100000];
	int len;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		scanf("%s", str);
		for (i = 0; i < n; i++){
			ans[0] = '\0';
			count = 1;
			len = strlen(str);
			for (j = 0; j <= len - 1; j++){
				if (str[j] == str[j + 1]){
					count++;
				}
				
				else {
					sprintf(buf, "%d%c", count, str[j]);
					strcat(ans, buf);
					count = 1;
				}
			}
			strcpy(str, ans);
		}
		printf("%s\n", str);
	}
	
	return (0);
}

Measured memory_bytes: 724
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define pi pair<int,int>
#define mod 1000000007
#define vectormax *max_element
#define vectormin *min_element
#define arraysize 1000000
#define setbit _builtin_popcountll
using namespace std;

ll ipow(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x % mod;
        n = n / 2;
        x = x * x % mod;
    }
    return result;
}

int main(){
//   fio
//ll n;
//cin>>n;
//unordered_map<ll,ll>m;
//ll a[n];
//for(ll i=0;i<n;i++)
//{
//    cin>>a[i];
//    m[a[i]]++;
//}
//ll s=0;
//for(ll i=0;i<n;i++)
//    s+=a[i];
//
//ll t;
//cin>>t;
//while(t--){
//    ll x,y;
//    cin>>x>>y;
//    s=s-x*m[x]+y*m[x];
//    ll t=m[x];
//    m[x]-=t;
//    m[y]+=t;
//cout<<s<<endl;
//}

int t;
t=1;
while(t--){
        vector<int>v;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int x=0;
    for(int i=0;i<n;i++){
        x=x^a[i];
    }
    for(int i=0;i<n;i++)
        v.pb(x^a[i]);
    for(int x:v)
        cout<<x<<" ";
   // cout <<x<<endl;
}
  return 0;
}


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

int W,H;
vector<string> s;
vector<vector<int>> cost;

int bfs(){
  int dx[]={0,1,0,-1}, dy[]={1,0,-1,0};
  queue<pair<int,int>> que;
  que.push(make_pair(0,0));
  cost[0][0]=0;
  while(!que.empty()){
    pair<int,int> p=que.front();
    que.pop();
    if(p==make_pair(H-1,W-1)){return cost[p.first][p.second];}
    for(int i=0;i<4;i++){
      int ny=p.first+dy[i], nx=p.second+dx[i];
      //マスの外
      if(nx<0 || ny<0 || nx>=W || ny>=H)continue;
      //壁
      if(s[ny][nx]=='#')continue;
      //既に探索済み
      if(cost[ny][nx]!=-1)continue;
      
      cost[ny][nx]=cost[p.first][p.second]+1;
      que.push(make_pair(ny,nx));
    }
  }
  return -1;
}

int main(){
  cin >> H >> W;
  s=vector<string>(H);
  int white=0;
  for(int i=0;i<H;i++){cin >> s[i];}
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s[i][j]=='.')white++;
    }
  }
  cost=vector<vector<int>>(H,vector<int>(W,-1));
  int min=bfs();
  if(min==-1){cout << min << endl;}
  else{cout << white-min-1 << endl;}
}

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

using namespace std;

int main() {
  char a;
  cin >> a;
  if (a == 'a' ||a == 'i' ||a == 'u' ||a == 'e' ||a == 'o'){
  cout << "vowel" << endl; 
  } else {
  cout << "consonant" << endl; 
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
vector<P> compress(map<int,int> mp){
    vector<P> vec;
    for(auto p:mp){
        vec.emplace_back(p);
    }
    return vec;
}
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    map<int,int> mp;
    rep(i,0,N)mp[V[i]]++;
    auto vec = compress(mp);
    if(vec.size() > 2 || vec.back().first - vec[0].first > 1){
        cout << "No" << endl;
        return 0;
    }
    if(vec.size() == 1){
        int num = vec[0].first;
        if(num == N-1 || num <= N/2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        return 0;
    }
    
    P p1 = vec[0], p2 = vec[1];
    int k = N - p2.first;
    int dif = p1.first - p1.second;
    if(dif <= k-1 && dif >= 0 && !(N % 2 == 0 && p1.second == 1)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 11132
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (p[i]!=i+1) {
          cnt++;
        }
}
    if (cnt > 2) {
        cout << "NO" << endl;
    }
    else {
        cout << "YES" << endl;
    }

    return 0;
}


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

int main(){
  int k, n;
  cin >> k >> n;
  
  int a[200005];
  int max_a = 0;
  int sum = 0;
  
  cin >> a[0];
  //cout << a[0] << endl;
  
  for(int i=1; i<n-1; i++){
    cin >> a[i];
    if(max_a < (a[i] - a[i-1])) max_a = (a[i] - a[i-1]);
    //sum += a[i] - a[i-1];
    //cout << a[i] << endl;
  }
  
  cin >> a[n-1];
  //cout << a[n-1] << endl;
  if(max_a < (a[n-1] - a[n-2])) max_a = a[n-1] - a[n-2];
  if(max_a < (k - a[n-1] + a[0])) max_a = k - a[n-1] + a[0];
  //sum += a[n-1] - a[n-2];
  
  cout << k - max_a << endl;
  
  return 0;
}

Measured memory_bytes: 1024
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())

    COM_MAX = M

    fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2, COM_MAX + 1):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    def com(n, r):
        if n < 0 or r < 0 or n < r:
            return 0
        return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD

    def perm(n, r):
        if n < 0 or r < 0 or n < r:
            return 0
        return fac[n] * finv[n - r] % MOD

    ans = 0
    for k in range(N + 1):
        tmp = perm(M - k, N - k) * com(N, k) % MOD
        if k & 1:
            tmp *= -1
        ans = (ans + tmp) % MOD

    ans = ans * perm(M, N) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 85088
from heapq import heappop, heappush, heapify
n, m = map(int, input().split())
a = list(map(int, input().split()))
q = []
for x in a:
	heappush(q, -x)
for _ in range(m):
	l = heappop(q)
	heappush(q, -((-l)//2))
print(-sum(q))


Measured memory_bytes: 14180
#include<iostream>

int t[105];
int  main() {
    int n;
    std::cin >> n;
    long long sum = 0;
    for(int i = 0; i < n; i++) {
        std::cin >> t[i];
        sum += t[i];
    }
    int m;
    std::cin >> m;
    for (int i = 0; i < m; i++) {
        int x, y;
        std::cin >> x >> y;
        std::cout << sum + y - t[x - 1] << std::endl;
    }
}

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

using namespace std;

namespace abreto {

typedef vector<int> vi;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back

void main(void)
{
    const int maxn = 5;
    int x[maxn] = {0}, k = 0;
    for (int i = 0; i < maxn; i++)
        cin >> x[i];
    cin >> k;
    bool exist = false;
    for (int i = 0; i < maxn; i++)
        for(int j = i + 1; j < maxn; j++)
            if (x[j] - x[i] > k)
            {
                exist = true;
                break;
            }
    cout << (exist ? ":(" : "Yay!") << '\n';
}

}

int main(void)
{
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    abreto::main();
    return 0;
}


Measured memory_bytes: 256
/**
*    created: 11.07.2020 00:46:31
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int n;
    cin>>n;

    vector<int> coins {25, 10, 5, 1};
    int cnt = 0;
    for (auto c : coins) {
        cnt += n / c;
        n %= c;
    }
    cout<<cnt<<endl;;
}


Measured memory_bytes: 3216
def knapsack(items, budget)
    table = (0..1).map{ Array.new(budget+1, 0) }
    for i in 0..items.size-1
        c, v = items[i]
        for j in 0..budget
            x = table[0][j]
            y = (j >= c ? table[0][j-c] + v : 0)
            table[1][j] = x > y ? x : y
        end
        table << table.shift
    end
    table[0][budget]
end

n, budget = gets.split.map &:to_i
items = $<.map{|s| s.split.map(&:to_i).reverse}
p knapsack(items, budget)

Measured memory_bytes: 6264
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define debug2(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << nl;
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
const int MAXN = 100005;
ll mod=1000000007;


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  // cin>>t;
  while(t--){
    ll n;
    cin>>n;
    ll cnt = 0;
    for(ll i = 1; i*i <= n; i++){
        if(n%i == 0){
            ll x = i, y = n/i;
            if(x > 1)
            if((n%(x - 1))* (x) == n){
              cnt+= (x - 1);
            }
            if(y>1)
            if(x != y){
              if(n%(y - 1)*(y) == n){
                cnt+=(y-1);
              }
            }
        }
    }
    cout<<cnt<<nl;
  }
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,k,n) for(int i = k; i < n; i++)  
#define repp(i,k,n) for(int i = k; i <= n; i++) 
#define per(i,k,n) for(int i = k; i >= n; i--)

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii; 
typedef vector<ii> vii;
typedef vector<char> vchar;
typedef vector<int> vi;
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));

#define INF 1000000000
//#define mod 998244353
#define mod 1000000007
#define endl "\n"


   //=\/=\/=\/=\/=\/=\/=\/=\/=\/=\        Jai Hind Dosto        /=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\
  //=\/=\/=\/=\                    ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿                             /=\/=\/=\/=\\
 //=\/=\/=\/=\                                                                               /=\/=\/=\/=\\
//=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\



int modPow(int a, int b);           


int w[105], v[105];
int dp[100005];


void solve(){
    int n,W ;
    cin >> n >> W ;
   // rep(i,0,100005)dp[i]=0;
    rep(i,0,n){cin >> w[i] >> v[i];}
    rep(i,0,n){
        per(j,100004,0){
            if(dp[j]!=0){
                if(j+v[i]<100005){
                    if(dp[j+v[i]]==0)dp[j+v[i]] = (dp[j]+w[i]);
                    else dp[j+v[i]]= min(dp[j+v[i]],(dp[j]+w[i]));
                }
            }
        }
        if(dp[v[i]]==0)dp[v[i]]= w[i];
        else dp[v[i]] = min(dp[v[i]],w[i]);
    }
    per(i,100004,0){
        if(dp[i]!=0 && dp[i]<=W){
            cout << i ;
            return;
        }
    }

}






signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed;
    //cout <<setprecision(6);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
   // int test=1; cin >> test; while(test--)
    solve();
}

int modPow(int a, int b){
    if(b==0)return 1;
    if(b%2==0){
        int x = a*a;
        x%=mod;
        return modPow(x,b/2);
    }
    return (a*modPow(a,b-1))%mod;
}




Measured memory_bytes: 4320
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;

vector< vector<int> > f;
vector< vector<int> > p;
string func(int n){
  string s = "";
  for(int i=1; i<=n; i*=2){
    if( (n & i) == i ) s = '1' + s;
    else s = '0' + s;
  }
  s = string(10-s.size(), '0') + s;
  return s;
}

int func2(string s){
  cerr << s << endl;
  int n = f.size();
  int ret = 0;
  for(int i=0; i<n; i++){
    int tmp = 0;
    for(int j=0; j<10; j++){
      if( s[j]-'0' == 1 && f[i][j] == 1 ) tmp++;
    }
    cerr << i << " " << tmp << endl;
    ret += p[i][tmp];
  }
  cerr << ret << endl;
  return ret;
}

int main() {

  int n;
  cin >> n;

  f.resize(n, vector<int>(10));
  for(int i=0; i<n; i++){
    for(int j=0; j<10; j++){
      cin >> f[i][j];
    }
  }
  p.resize(n, vector<int>(11));
  for(int i=0; i<n; i++){
    for(int j=0; j<11; j++){
      cin >> p[i][j];
    }
  }

  // int ans = func2(func(1023));
  int ans = func2(func(1));
  for(int i=2; i<1024; i++){
    ans = max(ans, func2(func(i)));
    // cerr << ans << endl;
  }
  cout << ans << endl;

  return 0;
}


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

int main(){

    vector<int> a(3);

    rep(i,3) cin >> a[i];

    sort(a.begin(),a.end());

    int ans=0;

    ans+=(a[2]-a[0])/2;
    ans+=(a[2]-a[1])/2;

    a[0]+=((a[2]-a[0])/2)*2;
    a[1]+=((a[2]-a[1])/2)*2;

    int t=0;

    rep(i,3){
        if(a[i]%2==0){
            t++;
        }
    }

    if(t==0||t==3){
        cout << ans << endl;
    }else if(t==1){
        if(a[2]%2==0){
            cout << ans+1 << endl;
        }else{
            cout << ans+2 << endl;
        }
    }else{
        if(a[2]%2==0){
            cout << ans+2 << endl;
        }else{
            cout << ans+1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#define N 700
#define M 210000
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	if(a+1==b)puts("Borys");
	else
	{
		for(int i=1;i<=n;i++)
		{
			a++;
			if(a+1==b) { puts("Alice"); break; }
			b--;
			if(a+1==b) { puts("Borys"); break; }
		}
	}
}

Measured memory_bytes: 256
q=int(input())
m=10**9+7
for _ in range(q):
	x,y=sorted(map(int,input().split()))
	s=-1
	i=j=1
	while j<=x and i+j<=y:
		i,j=j,i+j
		s+=1
	if x==1 or y<3:print(1,x*y%m)
	else:
		a=max(0,(y-j)//i+1)+max(0,(x-j)//i+1)
		i=j=1
		for c in range(s):
			k,l=j,i+j*2
			for _ in range(s-c):k,l=l,k+l
			if x>=k:a+=max(0,(y-l)//k+1)
			if y>=k:a+=max(0,(x-l)//k+1)
			i,j=j,i+j
		print(s+1,a%m)

Measured memory_bytes: 81180
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int H,W;char s[20][20];
vector<pair<int,int>> line={{0,-1},{-1,0},{0,1},{1,0}};
int bfs(int a,int b,int c,int d){
	int dist[H][W]={};int check[H][W]={};
	deque<pair<int,int>> task;
	task.push_back({a,b});check[a][b]=1;
	while(!task.empty()){
		int h=task[0].first;
		int w=task[0].second;
		rep(i,0,4){
            int dx=line[i].first;
            int dy=line[i].second;
			if(h+dx<0||H<=h+dx||w+dy<0||W<=w+dy) continue;
			if(s[h+dx][w+dy]=='#') continue;
            if(check[h+dx][w+dy]==1) continue;
			task.push_back({h+dx,w+dy});
            check[h+dx][w+dy]=1;
			dist[h+dx][w+dy]=dist[h][w]+1;
		}task.pop_front();
	}return dist[c][d];
}
int main(){
	cin>>H>>W;
	rep(i,0,H)rep(j,0,W) cin>>s[i][j];
    int ans=0;
	rep(i,0,H)rep(j,0,W){
		rep(k,0,H)rep(l,0,W){
			if(s[i][j]=='.'&&s[k][l]=='.'){
				ans=max(ans,bfs(i,j,k,l));
			}
		}
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

    int main(){
      string s;
      cin >> s;
      bool ans=false;
      string t="keyence";
      for(int i=0;i<1;i++){
       rep(j,7){ //wakeru
         bool ok=true;
        rep(k,j){
          if(s[i+k]!=t[k])ok=false;
        }
         if(ok){
           
          for(int l=s.size()-(7-j);l+(7-j)<=s.size();l++){
            bool ok2=true;
            for(int n=0;n<7-j;n++){
             if(s[l+n]!=t[j+n])ok2=false; 
            }
            if(ok2==true)ans=true;
          }
           
           
           
           
         }
       }
      }
      if(ans)cout << "YES" << endl;
      else cout << "NO" << endl;
      return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

ll N;
ll A[100000];
ll B[100000];
ll C[100000];

int main(){
    cin>>N;
    rep(i,N) cin>>A[i];
    rep(i,N) cin>>B[i];
    rep(i,N) cin>>C[i];
    sort(A,A+N);
    sort(B,B+N);
    sort(C,C+N);

    vector<ll> ab(100005);
    rep(i,N){
        ll l=-1, r=N;
        while(r-l>1){
            ll m=(l+r)/2;
            if(B[i]<=A[m]) r=m;
            else l=m; 
        }
        ab[i]=r;
    }
    rep(i,N-1) ab[i+1]+=ab[i];
    //rep(i,N) cout<<ab[i]<<endl;

    ll ans=0;
    rep(i,N){
        ll l=-1, r=N;
        while(r-l>1){
            ll m=(l+r)/2;
            if(C[i]<=B[m]) r=m;
            else l=m; 
        }
        if(r>0) ans+=ab[r-1];
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 6428
#include<stdio.h>
#include<cstdio>
#include<string>
#include<math.h>
using namespace std;

int N, M;
int V[50][50];
int color[50];

void dfs(int v) {
  color[v] = 1;
  for (int i=0 ; i<N ; i++) {
    if (V[v][i] == 1 && color[i] == 0) dfs(i); 
  }
  return;
}

int main() {
  scanf("%d %d", &N, &M);
  pair<int, int> edge[M];
  for (int i=0 ; i<N ; i++) 
    for (int j=0 ; j<N ; j++) V[i][j] = 0;
  int a, b;
  for (int i=0 ; i<M ; i++) {
    scanf("%d %d", &a, &b);
    edge[i].first = a-1;
    edge[i].second = b-1;
    V[a-1][b-1] = 1;
    V[b-1][a-1] = 1;
  }
  int res = 0;
  for (int i=0 ; i<M ; i++) {
    V[edge[i].first][edge[i].second] = 0;
    V[edge[i].second][edge[i].first] = 0;
    
    for (int j=0 ; j<N ; j++) {
      color[j] = 0;
    }
    
    dfs(0);
    
    for (int j=0 ; j<N ; j++) {
      if (color[j] == 0) {
        res++;
        break;
      }
    }
    
    V[edge[i].first][edge[i].second] = 1;
    V[edge[i].second][edge[i].first] = 1;
  }
  printf("%d\n", res);
}

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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int x=1,y=1,z=1,n,i,j,k,mod=1000000007;
    cin>>n;
    for(i=1;i<=n;i++){
        x*=10;
        x%=mod;
        y*=9;
        y%=mod;
        z*=8;
        z%=mod;
    }

    cout<<(x-y-y+z+mod+mod)%mod;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long long int n,m;
    vector<long long int> arr_n1;
    vector<long long int> arr_m1;
    cin >> n;
    cin >> m;
    long long int sum_n=0;
    long long int sum_m=0;
    long long int sum = 0;
    for(long long int i=0;i<n;i++){
        long long int po = 0;
        cin >> po;
        arr_n1.push_back(po);
    }
    for(long long int i=0;i<m;i++){
      long long int po = 0;
      cin >> po;
      arr_m1.push_back(po);
    }
    for(long long int i=0;i<n;i++){
        sum_n += ((i*arr_n1[i])-((n-i-1)*arr_n1[i]))%1000000007;
        sum_n %= 1000000007;
    }
    for(long long int i=0;i<m;i++){
        sum_m += ((i*arr_m1[i])-((m-i-1)*arr_m1[i]))%1000000007;
        sum_m %= 1000000007;
    }
    sum = (sum_n*sum_m)%1000000007;

    cout << sum <<endl;
    return 0;
}

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

int main() {
	string S;
	cin >> S;
	int n = S.size();
	
	int counter_of_odd = 0, counter_of_even = 0;

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			if (S[i] != '1')counter_of_odd++;
		}
		if (i % 2 ==1) {
			if (S[i] != '0')counter_of_odd++;
		}
	}

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			if (S[i] != '0')counter_of_even++;
		}
		if (i % 2 == 1) {
			if (S[i] != '1')counter_of_even++;
		}
	}

	cout << min(counter_of_odd, counter_of_even) << endl;
	return 0;

}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
string s[101];
//int a[1000006];
int h,w;
int a[28];
int main()
{
	cin>>h>>w;
	rep(i,h)
	{
		cin>>s[i];
		rep(j,w)
		{
			int t=(int)(s[i][j]-'a');
			a[t]++;
		}
	}
	/*rep(i,26)
	{
		cout<<a[i]<<endl;
	}*/
	if(h%2==0&&w%2==0)
	{
		rep(i,26)
		{
			if(a[i]%4!=0)
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
		cout<<"Yes"<<endl;
		return 0;
	}
	else if(h%2==1&&w%2==1)
	{
		int f,ff;
		f=1;
		ff=(int)(h/2)+(int)(w/2);
		rep(i,26)
		{
			if(a[i]%2==1)
			{
				f--;
			}
			if(a[i]%4==2)
			{
				ff--;
			}
		}
		if(f>=0&&ff>=0)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		else cout<<"No"<<endl;
	}
	else
	{
		int f;
		
		if(w%2==0)
		{
			f=w/2;
		}
		else f=h/2;
		rep(i,26)
		{
			if(a[i]%2==1)
			{
				cout<<"No"<<endl;
				return 0;
			}
			if(a[i]%4==2)
			{
				f--;
			}
		}
		if(f>=0)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
		
	}
	return 0;
}

Measured memory_bytes: 256
object Main {
    val fld = Array.ofDim[Int](10)
    val ans = Array.ofDim[Int](10)

    def beam(y: Int, x: Int) = {
        val dir = List((y, x), (y - 1, x), (y, x - 1), (y + 1, x), (y, x + 1)).filter(p => 0 <= p._1 && p._1 < 10 && 0 <= p._2 && p._2 < 10)
        for(p <- dir) {
            fld(p._1) ^= (1 << p._2)
        }
    }

    def init(orig: Array[Int]) = {
        for(y <- 0 to 9) {
            fld(y) = orig(y)
            ans(y) = 0
        }
    }

    def row_flip(y: Int, bits: Int) = {
        for(x <- 0 to 9) {
            if((bits & (1 << x)) != 0) {
                beam(y, x)
                ans(y) |= (1 << x)
            }
        }
    }

    def flip(y: Int, bits: Int) = {
        row_flip(0, bits)
        for(y <- 1 to 9) row_flip(y, fld(y - 1))
    }

    def solve(orig: Array[Int]) = {
        var i = 0
        var flag = true
        while(flag) {
            init(orig)
            flip(0, i)
            if(fld(9) == 0) {
                ans.foreach(bits => println(Integer.toBinaryString(bits).reverse.padTo(10, '0').split("").mkString(" ")))
                flag = false
            }
            else i += 1
        }
    }

    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val n = sc.nextInt
        sc.nextLine
        for(_ <- 1 to n) {
            val orig = (1 to 10).toArray.map(_ => Integer.parseInt(sc.nextLine.split(" ").mkString("").reverse, 2))
            solve(orig)
        }
    }
}

Measured memory_bytes: 269960
def haha():    
    A=[]
    for i in range(3):
        A.extend(list(map(int, input().split())))
    N = int(input())
    n=[]
    while N>0:
        inp = int(input())
        if inp in A:
            n.append(inp)
        N-=1
    A = [A[:3],A[3:6],A[6:9], [A[0], A[4], A[8]], [A[2], A[4], A[6]], [A[0], A[3], A[6]], [A[1], A[4], A[7]], [A[2], A[5], A[8]]]
    for ele in A:
        if ele[0] in n and ele[1]in n and ele[2]in n:
            return 'Yes'
    return 'No'
print(haha())

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	cin>>n;
	int mas[2][n],a[2][n];
	rep(i,2){
		fill(mas[i],mas[i]+n,0);
		rep(j,n){
			cin>>a[i][j];
			if(i==0&&j==0)mas[i][j]=a[i][j];
			else if(i==0)mas[i][j]=max(mas[i][j],mas[i][j-1]+a[i][j]);
			else if(j==0)mas[i][j]=max(mas[i][j],mas[i-1][j]+a[i][j]);
			else mas[i][j]=max(mas[i][j],max(mas[i-1][j]+a[i][j],mas[i][j-1]+a[i][j]));
		}
	}
	cout<<mas[1][n-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

static const int MOD = 1e9 + 7;

int main() {

    int N;
    vector<bool>ans(100, false);
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++)ans[i*j] = true;
    }
    
    cin >> N;
    if (ans[N])cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
int arr[102],freq[102];
 
int main() {
    int x ,n,element;
    cin>>x>>n;
 
 
    for(int i=0;i<n;i++){
        cin>>element;
        freq[element]++;
    }
 
 
    int j=0;
 
    for(int i=0;i<=101;i++){
        if(freq[i]==0){
            arr[j]=i;
            j++;
        }
    }
 
 
    sort(arr,arr+102);
 
 
    int low = *lower_bound(arr,arr+102,x);
 
    int mini = low-x;
    int ans = low;
 
    for(int i=0;i<=x;i++){
        if(freq[i]==0){
            if(x-i<=mini){
                ans=i;
            }
        }
    }
 
    cout<<ans<<endl;
 
 
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
int main()
{
  string s;
  int ans;
  cin >>s;
  if(s=="++++")ans=4;
  if(s=="+++-")ans=2;
  if(s=="++-+")ans=2;
  if(s=="+-++")ans=2;
  if(s=="-+++")ans=2;
  if(s=="++--")ans=0;
  if(s=="+--+")ans=0;
  if(s=="--++")ans=0;
  if(s=="-+-+")ans=0;
  if(s=="+-+-")ans=0;
  if(s=="+---")ans=-2;
  if(s=="---+")ans=-2;
  if(s=="--+-")ans=-2;
  if(s=="-+--")ans=-2;
  if(s=="----")ans=-4;
  if(s=="-++-")ans=0;
  cout << ans;
}

Measured memory_bytes: 256
n = int(input())
l = []
for i in range(0,n):
  l.append(list(map(int,input().split())))

for i in range(0,n):
  l[i] = set(l[i])

ans = "No" 
for i in range(0,n-2):
  if len(l[i]) == 1 and len(l[i+1]) == 1 and len(l[i+2]) == 1:
    ans = "Yes"
  
print(ans)

Measured memory_bytes: 62508
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int c = in.nextInt();
            int k = in.nextInt();
            int[] t = new int[n];
            for (int i = 0; i < n; ++i) {
                t[i] = in.nextInt();
            }
        Arrays.sort(t);
        int people = 0;
        int start = 0;
        int res = 0;
        for (int tt : t) {
            if (people > 0 && tt - start > k) {
                ++res;
                people = 0;
            }
            if (people == 0) {
                start = tt;
            }
            ++people;
            if (people == c) {
                ++res;
                people = 0;
            }
        }
        if (people > 0) {
            ++res;
        }
        out.println(res);


        }

    }
}



Measured memory_bytes: 49228
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
struct edge {int to, next;} e[N * 2];
int stk[N], top, vis[N];
int head[N], ecnt, rt;
inline void adde(int from, int to) {e[++ecnt] = (edge){to, head[from]}, head[from] = ecnt;}
int ans[N], fuck = 1e9;
void dfs(int u) {
	if (top >= fuck) return;
	if (vis[u]) {
		if (u != rt) return;
		if (top < fuck) {
			fuck = top;
			for (int i = 1; i <= top; i++) ans[i] = stk[i];
		}
		return;
	}
	vis[u] = 1, stk[++top] = u;
	for (int i = head[u]; i; i = e[i].next)
		dfs(e[i].to);
	top--;
}
int main() {
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 1, a, b; i <= m; i++) scanf("%d%d", &a, &b), adde(a, b);
	for (int i = 1; i <= n; i++) {
		memset(vis, 0, sizeof(vis));
		rt = i, dfs(i);
	}
	if (fuck < 1e9) {
		cout << fuck << endl;
		for (int i = 1; i <= fuck; i++) cout << ans[i] << endl;
		return 0; 
	}
	puts("-1");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, s, N) for(ll i{N - 1}; i > s - 1; i--)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  kyopro;
  ll N, K;
  cin >> N >> K;
  vector<ll> V(N);
  for(auto&& i : V){
    cin >> i;
  }
  ll ans{};
  rep(hidari, 0, N + 1){
    rep(migi, 0, N + 1 - hidari){
      if(hidari + migi > K) continue;
      vector<ll> motteruhouseki;
      ll nice{};
      rep(i, 0, hidari){
        motteruhouseki.push_back(V.at(i));
      }
      rep(i, 0, migi){
        motteruhouseki.push_back(V.at(N - 1 - i));
      }
      sort(motteruhouseki.rbegin(), motteruhouseki.rend());
      rep(i, 0, K - hidari - migi){
        if(motteruhouseki.size() == 0) break;
        if(motteruhouseki.back() > 0) break;
        motteruhouseki.pop_back();
      }
      ans = max(ans, accumulate(motteruhouseki.begin(), motteruhouseki.end(), 0LL));
    }
  }
  cout << ans << rt;
}

Measured memory_bytes: 256
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

reds = dict()
blues = dict()

n=ni()
for i in range(n):
  s = input()
  if s not in blues:
    blues[s] = 1
  else:
    blues[s]+=1

n = ni()
for i in range(n):
  s = input()
  if s not in reds:
    reds[s] = 1
  else:
    reds[s]+=1


ans=0
for k in blues.keys():
  if k in reds:
    num = blues[k]-reds[k]
    if num>0:
      ans = max(ans,num)
      continue
  else:
    ans = max(ans,blues[k])
  # ans+=blues[k]

print(ans)


Measured memory_bytes: 62256
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    if(n==25)Cout("Christmas");
    else if(n==24)Cout("Christmas Eve");
    else if(n==23)Cout("Christmas Eve Eve");
    else Cout("Christmas Eve Eve Eve");
    return 0;
}


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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]), a[i]--;

	vector<int> ans(n);
	for(int i=n-1;i>=0;i--){
		int j;
		for(j=i;j>=0;j--) if(a[j]==j) break;
		if(j<0) return puts("-1"),0;
		a.erase(a.begin()+j);
		ans[i]=j;
	}

	rep(i,n) printf("%d\n",ans[i]+1);

	return 0;
}


Measured memory_bytes: 256
import numpy as np
N, _ = map(int, input().split())
D = np.bincount(tuple(map(int, input().split())), minlength=10)
while True:
    n = N
    while n:
        if D[n % 10]:
            break
        n //= 10
    else:
        break
    N += 1
print(N)

Measured memory_bytes: 12420
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

a.unshift(0)
a.push(0)

k = 0
(n+1).times do |i|
  k += (a[i+1] - a[i]).abs
end

def same?(one, two, three)
  if two - one >= 0
    if three - two >= 0
      true
    else
      false
    end
  else
    if two - three >= 0
      true
    else
      false
    end
  end
end

n.times do |i|
  if same?(a[i], a[i+1], a[i+2])
    p k
  else
    if ((a[i+2] - a[i] >= 0) && (a[i] - a[i+1] >= 0)) || ((a[i+1] - a[i] >= 0) && (a[i] - a[i+2] >= 0))
      p k - (a[i+1] - a[i]).abs * 2
    else
      p k - (a[i+2] - a[i+1]).abs * 2
    end
  end
end


Measured memory_bytes: 17172
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

bool solve(int h, int w, int a, int b, vector<vector<char> > & f) {
    auto put_a = [&](int y, int x) {
        if (a == 0) return;
        if (f[y][x    ] != '.') return;
        if (f[y][x + 1] != '.') return;
        f[y][x    ] = '<';
        f[y][x + 1] = '>';
        -- a;
    };
    auto put_b = [&](int y, int x) {
        if (b == 0) return;
        if (f[y    ][x] != '.') return;
        if (f[y + 1][x] != '.') return;
        f[y    ][x] = '^';
        f[y + 1][x] = 'v';
        -- b;
    };
    if (h % 2 == 0 and w % 2 == 0) {
        for (int y = 0; y + 1 < h; y += 2) {
            for (int x = 0; x + 1 < w; x += 2) {
                if (a != 0) {
                    put_a(y,     x);
                    put_a(y + 1, x);
                } else {
                    put_b(y, x);
                    put_b(y, x + 1);
                }
            }
        }
        return a == 0 and b == 0;
    } else if (h % 2 == 0) {
        for (int y = 0; y + 1 < h; y += 2) {
            put_b(y, w - 1);
        }
        return solve(h, w - 1, a, b, f);
    } else if (w % 2 == 0) {
        for (int x = 0; x + 1 < w; x += 2) {
            put_a(h - 1, x);
        }
        return solve(h - 1, w, a, b, f);
    } else {
        put_a(h - 1, w - 2);
        put_b(h - 3, w - 1);
        for (int x = 0; x + 1 < w - 3; x += 2) {
            put_a(h - 1, x);
        }
        for (int y = 0; y + 1 < h - 3; y += 2) {
            put_b(y, w - 1);
        }
        auto saved_f = f;
        if (solve(h - 1, w - 1, a, b, f)) return true;
        f = saved_f;
        put_a(h - 3, w - 3);
        put_b(h - 2, w - 3);
        if (solve(h - 1, w - 1, a, b, f)) return true;
        return false;
    }
}

int main() {
    // input
    int h, w, a, b; scanf("%d%d%d%d", &h, &w, &a, &b);

    // solve
    auto f = vectors(h, w, '.');
    bool result = solve(h, w, a, b, f);

    // output
    if (not result) {
        printf("NO\n");
    } else {
        printf("YES\n");
        REP (y, h) {
            REP (x, w) {
                printf("%c", f[y][x]);
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2176
# input
D = int(input())

S = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j")

# process
def f(x):
    if x == 0:
        return ["a"]

    else:
        t =  f(x - 1)
        r = []
        for s in t:
            num = len(set(list(s)))
            for i in range(num+1):
                r.append(s+S[i])
        return r

ans = f(D-1)

# output
print(" ".join(map(str, ans)))


Measured memory_bytes: 15452
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m, cutback;
        cin >> n >> m >> cutback;
        if(n == 0)
            return 0;

        vector<int> p(n*m+1, 0);
        p[0] = 1;
        for(int i=0; i<n; ++i){
            for(int j=m*i; j>=i; --j){
                for(int k=1; k<=m; ++k)
                    p[j+k] += p[j];
                p[j] = 0;
            }
        }

        int pSum = accumulate(p.begin(), p.end(), 0);
        double ret = 0;
        for(int i=0; i<n*m+1; ++i)
            ret += max(i-cutback, 1) * p[i] / (double)pSum;

        printf("%.10f\n", ret);
    }
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d%d", &a, &b);

    char s[100];
    scanf("%s", s);

    int i;
    for (i = 0; i < a; i++) {
        if (s[i] < '0' || '9' < s[i]) {
            puts("No");
            return 0;
        }
    }

    if (s[a] != '-') {
        puts("No");
        return 0;
    }

    for (i = a + 1; i < a + 1 + b; i++) {
        if (s[i] < '0' || '9' < s[i]) {
            puts("No");
            return 0;
        }
    }

    puts("Yes");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MAX_N 1005
using namespace std;
/*????¬??????????????????°???????????\ O(H*W)*/
/*T????????????U????????´????????´????????¢???*/
typedef unsigned long long ull;
const ull A=9999973,B=950527; //A:???????´???°, B:?¨?????´???°
 
int H,W;
char T[MAX_N][MAX_N];
ull t[MAX_N][MAX_N]; 
ull t2[MAX_N][MAX_N];

int h,w;
char U[1005][1005];
 
void rol_hash2(){

  ull target=0;  //????????¨?????????????????\
  for(int i=0; i<h ;i++){
    ull key=0;
    for(int j=0; j<w ;j++)key= key * B + U[i][j];
    target = target * A + key;
  }
 
  ull C=1;
  for(int i=0; i<w ;i++)C*=B;
   
  //?¨?????????????????????\????????????
  for(int i=0; i<H ;i++){
    ull key=0;
    for(int j=0; j<W ;j++){
      key = key * B + T[i][j];
      if(j-w >= 0)key -= T[i][j-w] * C;
      t[i][j] = key;
      t2[i][j] = t[i][j];
    }
  }
   
  C=1;
  for(int i=0; i<h ;i++)C*=A;
  
  //???????????????????????\????????????
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++){
      if( i ) t[i][j] += t[i-1][j] * A;
      if(i-h >= 0) t[i][j] -= t2[i-h][j] * C;
      if(t[i][j] == target)
        if(i-h+1>=0&&j-w+1>=0)
	  printf("%d %d\n",i-h+1,j-w+1);//???????????§?¨??????????
    }
}
 
int main(){
  scanf("%d %d",&H,&W);
  for(int i=0;i<H;i++)scanf("%s",T[i]);
  scanf("%d %d",&h,&w);
  for(int i=0;i<h;i++)scanf("%s",U[i]);
  rol_hash2();
  return 0;
}

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

const int N = 1e5 + 10;

int n, ans, cnt, a;

int main(){
	scanf("%d", &n);
	cnt = 0;
    ans = 0;
	for(int i=1; i<=n; i++){
        scanf("%d", &a);
        if(a == i){
			cnt++;
        } else {
			if(cnt){
				ans = ans + (cnt + 1) / 2;
			}
			cnt = 0;
        }
	}
	if(cnt){
		ans = ans + (cnt + 1) / 2;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
/* Author : bitshar */
// #pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
ll MOD = 1e9+7;
 
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=e; i>=s; i--)
#define ln "\n"
#define sp " "
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define NEGINF -1e18
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
#define dbg(x) cout << #x << " = " << x << ln 
#define all(x) x.begin(), x.end()
 
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln
 
#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6
 
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;
 
void solve() {
 
    ll x,y,z;
    cin >> x >> y >> z;
    out3(z,x,y);
}
 
int main() {
    
    #ifdef DEBUG_MODE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    fio;
    int t=1;
    //cin >> t;
    while(t--) {
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

vvi G(100100, vi(0));
vi dp(100100, -1);

int func(int v){
  if(dp.at(v) != -1) return dp.at(v);

  int res = 0;
  for(auto x: G.at(v)){
    chmax(res, func(x)+1);
  }
  return dp.at(v) = res;
}

int main(){
  int N, M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int x, y;
    cin >> x >> y;
    x--; y--;
    G.at(x).push_back(y);
  }

  int result = 0;
  for(int i = 0; i < N; i++){
    chmax(result, func(i));
  }
  cout << result << endl;

}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;
  ll q;
  cin >> q;
  deque<char> ans;
  for (int i = 0; i < s.size(); i++) {
    ans.push_back(s[i]);
  }

  bool rev = false;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      rev = !rev;
      continue;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        if (!rev) {
          ans.push_front(c);
        } else {
          ans.push_back(c);
        }
      } else {
        if (rev) {
          ans.push_front(c);
        } else {
          ans.push_back(c);
        }
      }
    }
  }

  if (rev) {
    reverse(all(ans));
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  cout << ln;

  return 0;
}

Measured memory_bytes: 976
import queue

dx = (1, 0, -1, 0)
dy = (0, 1, 0, -1)

h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]

ans = 0

#startを順に探索
for y in range(h):
    for x in range(w):
    
        i = 0
        move = [[-1] * w for _ in range(h)]
        #壁はスキップ
        if(maze[y][x] == '#'):
            continue

        #幅優先探索
        q = queue.Queue()
        q.put([x, y])
        move[y][x] = 0

        while not q.empty():
            pos = q.get()
            for i in range(4):
                next = [pos[0] + dx[i], pos[1] + dy[i]]

                #端
                if(next[0] == w or next[1] == h or next[0] < 0 or next[1] < 0):
                    continue

                if(maze[next[1]][next[0]] == '.' and move[next[1]][next[0]] == -1):
                    move[next[1]][next[0]] = move[pos[1]][pos[0]] + 1
                    q.put(next)
        ans = max([ans] + [max(v) for v in move])

print(ans)



Measured memory_bytes: 3952
#include<stdio.h>
int main(void)
{
    int n,h[101],f,s[101],b[101],i,j,k;
    scanf("%d",&n);
    while(n!=0){
        for(i=0;i<n+1;i++){
            scanf("%d",&h[i]);
        }
        for(i=0;i<n+1;i++){
            k=0;
            for(j=0;j<n+1;j++){
                if(i!=j){
                    b[k]=h[j];
                    k++;
                }
            }
            for(j=0;j<n-1;j++){
                s[j]=b[j+1]-b[j];
            }
            f=0;
            for(j=0;j<n-2;j++){
                if(s[j]!=s[j+1]){
                    f=1;
                }
            }
            if(f==0){
                printf("%d\n",h[i]);
                break;
            }
        }   
        scanf("%d",&n);
    }
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
 
int main(void){
  
  int m1,d1,m2,d2;
  
  scanf("%d %d",&m1,&d1);
  scanf("%d %d",&m2,&d2);
  
  if(m1<m2){}
  else if((m1==m2) && (d1<d2)){}
  else{
    m1=m2;
    d1=d2;
  }
      
  
  switch(m1){
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
      if(d1==31){
        printf("1\n");
      }else{printf("0\n");}
      break;
    case 2:
      if(d1==28){
        printf("1\n");
      }else{printf("0\n");}
      break;
    case 4:
    case 6:
    case 9:
    case 11:
      if(d1==30){
        printf("1\n");
      }else{printf("0\n");}
      break;
    default:
      printf("0\n");
      
  }
  return 0;
}

Measured memory_bytes: 128