akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include <map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()


int main() {
	int x;
	int n;
	cin >> x >> n;
	vector<bool> tmp(301, true);

	rep(i, n) {
		ll a;
		cin >> a;
		if (a >= -100 && a <= 200) {
			a += 100;
			tmp[a] = false;
		}
	}
	ll ans = -100;
	ll min = 1000;
	rep(i, 301) {
		if (tmp[i]) {
			if (min > abs((i - 100) - x)) {
				min = abs((i - 100) - x);
				ans = i - 100;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


main(){
   double n;
   cin >> n;
   int i;

double ans;
for(i=1;i<=50000;i++){
   ans=i*1.08;
   if(floor(ans)==n){
      cout << i << endl;
      exit(0);
   }
}

puts(":(");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int a,b,h;
    cin>>a>>b>>h;


    cout << (a+b)*h/2 << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    string s, t;
    cin >> s >> t;
    
    ll ans = 0;
    
    string::iterator ptrs;
    string::iterator ptrt = t.begin();
    for(ptrs = s.begin(); ptrs != s.end(); ptrs++){
        if(*ptrs != *ptrt) ans++;
        ptrt++;
    }
    

    cout << ans << endl;
    return 0;
}

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

int main() {
    

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    //Write code below
    
    int a, b;
    
    cin >> a >> b;
    
    if (a % 2 == b % 2) {
        cout << (a + b) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


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

int RomantoArabic(char c)
{
	switch(c)
	{
	case 'I':
		return 1;
	case 'V':
		return 5;
	case 'X':
		return 10;
	case 'L':
		return 50;
	case 'C':
		return 100;
	case 'D':
		return 500;
	case 'M':
		return 1000;
	}

	return -1;
}

int RomanFigure(const std::string& figure)
{
	int temp = RomantoArabic(figure[figure.length()-1]);

	for(size_t i=1; i<figure.length(); ++i)
	{
		temp = RomantoArabic(figure[figure.length()-1-i])<RomantoArabic(figure[(figure.length()-1)-(i-1)]) ?
			temp - RomantoArabic(figure[figure.length()-1-i]) :
			temp + RomantoArabic(figure[figure.length()-1-i]);
	}

	return temp;
}

int main()
{
	std::string figure;

	while(std::cin >> figure)
	{
		std::cout << RomanFigure(figure) << '\n';
	}

}

Measured memory_bytes: 1180
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
#define INF -1
#define ll long long
using namespace std;

int main()
{
	priority_queue<int> que;
	int n;
	int tmp;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> tmp;
		que.push(tmp);
	}

	for (int i = 0; i < n; i++) {
		if (tmp == que.top()) {
			printf("NO");
			return 0;
		}
		tmp = que.top();
		que.pop();
	}
	
	printf("YES");

	return 0;
}

Measured memory_bytes: 1400
// template version 1.14
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#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 rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int n;cin>>n;
  vector<int> a(n);
  vi cnt(n+1);
  rep(i, n) {
    cin>>a[i];
    cnt[a[i]]++;
  }
  sort(all(a));
  dump(a);
  int M = a[n-1];
  dump(M);

  int x = ceil(M, 2);
  int even = (M%2==0?1:0);
  rep(i, n){
    if (a[i]<x){
      cout << "Impossible" << endl;
      return 0;
    }
  }
  //すべての要素がx+1
  if (even){
    if (cnt[x]==1){
    }
    else{
      cout << "Impossible" << endl;
      return 0;
    }
  }
  else{
    if (cnt[x]==2){
    }
    else{
      cout << "Impossible" << endl;
      return 0;
    }
  }
  rep(i, x+1, M+1){
    if (cnt[i]<2){
      cout << "Impossible" << endl;
      return 0;
    }
  }
  cout << "Possible" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#define MOD 1000000007
#define INT_MAX 2147000000
#define LONG_MAX 9223372036854775806
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
template<int mod=MOD> class modint {
private:
  int _num;
  modint set(int num){ _num = num % mod; return *this; }
public:
  modint(){ _num = 0; }
  modint(int num){ _num = num % mod; }

  modint operator= (int x){ return set(x % mod); }
  modint operator+ (int x){ return modint<mod>(_num + (x % mod)); }
  modint operator- (int x){ return modint<mod>(_num - (x % mod)); }
  modint operator* (int x){ return modint<mod>(_num * (x % mod)); }
  modint operator+=(int x){ return set(_num + (x % mod)); }
  modint operator-=(int x){ return set(_num - (x % mod)); }
  modint operator*=(int x){ return set(_num * (x % mod)); }

  explicit operator int() { return _num; }
  friend ostream& operator<<(ostream &os, const modint<mod> &x){ os << x._num; return os; }
};

int N;
#define MAXN 200001
int A[MAXN];
int B[MAXN];
void check(int a,int s){
    for(int i=2;i*i<=a;i++){
        if(a%i==0){
            if(a/i!=i){
                B[a/i]++;
            }
            B[i]++;
        }
    }
}
int main(){
    cin >> N;
    priority_queue<int,vector<int>,greater<int> > PQ;
    for(int i=1;i<=N;i++){
        cin >> A[i];
        B[i] = 0;
    }
    int count = 0;
    for(int i=N;i>0;i--){
        if(A[i]!=B[i]%2){
            B[1]++;
            B[i]++;
            PQ.push(i);
            check(i,2);
            count++;
        }
    }
    cout << count << endl;
    bool t = false;
    rep(i,count){
        cout << PQ.top()<<" ";
        PQ.pop();
        t = true;
    }
    if(t)cout << endl;
    return 0;
}

Measured memory_bytes: 3064
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(M)]

A = sorted(A, key=lambda x: x[1])
count = 0
x = 0
for a in A:
    if a[0] > x:
        x = a[1] - 1
        count += 1
        
        
print(count)


Measured memory_bytes: 65240
import numpy as np
N = int(input())
list_num = np.arange(1, N+1)

for i in list_num:
  if i % 3 == 0:
    list_num[i-1] = 0
  elif i % 5 == 0:
    list_num[i-1] = 0
  elif i % 15 == 0:
    list_num[i-1] = 0

print(list_num.sum())

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

int main(){
	/*input*/
	vector<int>a(3);
	for(int i = 0; i < 3; i++){
		cin >> a[i];
	}
	/*calculation*/
	int ans = 0;
	sort(a.begin(), a.end());
	ans += a[1] - a[0];
	ans += a[2] - a[1];
	/*output*/
	cout << ans << endl;
}


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

def main():
    N = int(input())
    H = list(map(int, input().split()))
    
    dp = [0]*N
    dp[0] = 0
    dp[1] = abs(H[1] - H[0])
    for i in range(2, len(H)):
        dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))

    print(dp[N-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 13708
def main():
    N = int(input())
    A = list( map(int, input().split()) )
    cnt = 0
    while True:
        if sum([ A[i]%2 for i in range(N) ]) == 0 :
            A = [ int(n/2) for n in A ]
            cnt += 1
        else:
            break
    print(cnt)


    

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

long long f(long long v) {
  return v % 2
    ? ((v + 1) % 4 ? 1 : 0)
    : ((v % 4 ? 1 : 0) ^ v);
}

int main() {
  long long A, B;
  cin >> A >> B;
  cout << (f(B) ^ f(A - 1)) << endl;
  return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll mod_pow(ll a,ll n){
	ll res=1;
	while(n>0){
		if(n&1)res=res*a%mod;
		a=a*a%mod;
		n>>=1LL;
	}
	return res;
}

ll fac[100010],finv[100010];

ll comb(ll n,ll r){
	if(n<0||r<0||n<r)return 0;
	else return (fac[n]*finv[r]%mod)*finv[n-r]%mod;
}

ll dp[22][1001];

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

  fac[0]=1;
  rep(i,100000)fac[i+1]=fac[i]*(i+1)%mod;
  rep(i,100001)finv[i]=mod_pow(fac[i],mod-2);

  ll n,k;
  cin>>n>>k;
  vector<ll> a(k);
  rep(i,k)cin>>a[i];
  dp[0][0]=1;
  rep(i,k)rep(j,n+1){
  	if(dp[i][j]==0)continue;
  	rep(x,min(a[i]+1,n-j+1)){
  		ll add=dp[i][j]*comb(n-x,a[i]-x)%mod;
  		(add*=finv[x])%=mod;
  		(dp[i+1][j+x]+=add)%=mod;
  	}
  }

  cout<<dp[k][n]*fac[n]%mod<<endl;

  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  int fee;
  if(k - n > 0){
    fee = n * x;
  }else{
    fee = k * x + (n - k) * y;
  }
  cout << fee << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<cctype>
#include<iomanip>
#include<string>
#include<utility>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 1e15
#define init(x) memset(x,0,sizeof(x))
int a,b;
int main()
{
	ios::sync_with_stdio(false);
    cin>>a>>b;
    if (a>b) a--;
    cout<<a<<endl;
	return 0;
}

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

#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mod 1000000007
#define ll long long
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define PI 3.14159265358979323

using namespace std;


ll dp[110][100010];

ll solve(vector< pair<ll,ll> > &v, ll n, ll w)
{
    if(dp[n][w]!=-1) return dp[n][w];
    if(n==0 || w==0) return 0;
    ll one=0,two=0;

    if(v[n-1].F<=w)  one=v[n-1].S+solve(v,n-1,w-v[n-1].F);
    two=solve(v,n-1,w);

    return dp[n][w]=max(one,two);
}


int main()
{
    memset(dp,-1,sizeof(dp));
    ll x,y,n,w,ans=0;
    cin>>n>>w;
    vector< pair<ll,ll> > v(n);
    for(ll i=0;i<n;i++){
        cin>>x>>y;
        v[i]=mp(x,y);
    }
    ans=solve(v,n,w);
    cout<<ans<<"\n";

return 0;
}


Measured memory_bytes: 89560
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

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

	vector<bool> check(3, false);

	check[A - 1] = true;
	check[B - 1] = true;

	for (int i = 0; i < 3; i++)
	{
		if (check[i] == false)
		{
			cout << i + 1;
			break;
		}
	}

	return 0;
}


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



signed main()
{
  int N=1000000;
  int arr[N+1]={0};
  for(int i=2;i<=sqrt(N);i++)
  {
      if(arr[i]==0)
      for(int j=i*i;j<=N;j+=i)
      {
          if(arr[j]==0)
          {
              arr[j]=i;
          }
      }
  }
  int n;
  cin>>n;
  int a[n];
   int gcd=0;
   map<int,int>m;
   bool flag=false;
  for(int i=0;i<n;i++)
  {
     cin>>a[i];
     gcd=__gcd(gcd,a[i]);
     while(true)
     {
         if(a[i]==1)
          break;
         if(arr[a[i]]==0)
         {
             if(m.find(a[i])!=m.end())
             {
                 flag=true;
                 break;
             }
           m[a[i]]++; 
           break;
         }
         int k=arr[a[i]];
         while(a[i]%k==0)
          a[i]=a[i]/k;
           if(m.find(k)!=m.end())
             {
                 flag=true;
                 break;
             }
          m[k]++;
         
     }
  }
     
  if(flag)
  {
      if(gcd==1)
      cout<<"setwise coprime"<<endl;
      else
      cout<<"not coprime"<<endl;
  }
   else
   {
       cout<<"pairwise coprime"<<endl;
   }
	return 0;
}


Measured memory_bytes: 24124
import itertools
import copy
n = int(input())
l = list(map(int,input().split()))
l2 = copy.deepcopy(l)
l.sort()
ans = []
for i in itertools.permutations(l,n):
    ans.append(list(i))

for i in range(len(ans)):
    if ans[i] == l2:
        if i - 1 >= 0:
            print(' '.join(map(str,(ans[i - 1]))))
        print(' '.join(map(str,(ans[i]))))
        if i != len(ans) - 1:
            print(' '.join(map(str,(ans[i + 1]))))
        break


Measured memory_bytes: 78908
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;


int main(){
  string S;
  cin >> S;
  vector<string> Head, Tail;
  int Q; cin >> Q;
  bool flag = true;
  for(int i = 0; i < Q; i++){
    int T; cin >> T;
    if(T == 1){
      flag = !flag;
    }else{
      int F; cin >> F;
      string  C; cin >> C;
      if((F == 1 && flag) || (F == 2 && flag == false) ){
	Head.push_back(C);
      }else{
	Tail.push_back(C);
      }
    }
  }
  
  if(flag){
    for(int i = Head.size()- 1; i >= 0; i--){
      cout << Head[i];
    }
    cout << S;
    for(int i = 0; i < Tail.size(); i++){
      cout << Tail[i];
    }
    cout << endl;
  }else{
    for(int i = Tail.size()- 1; i >= 0; i--){
      cout << Tail[i];
    }
    for(int i = S.size()- 1; i >= 0; i--){
      cout << S[i];
    }
    for(int i = 0; i < Head.size(); i++){
      cout << Head[i];
    }
    cout << endl;
  }
}


Measured memory_bytes: 11760
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int x = sc.nextInt();
      	int y = sc.nextInt();
      int mas1[] = new int[N]; 
      int mas2[] = new int[M];
      int ans = 0;
      
      for(int i=0; i<N;i++){mas1[i]=sc.nextInt();}
      for(int i=0; i<M;i++){mas2[i]=sc.nextInt();}
      Arrays.sort(mas1);Arrays.sort(mas2);
      
      for(int i=x+1;i<=y;i++){if(i>mas1[N-1]&&i<=mas2[0]){ans=1;break;}}
      
      if(ans==1){System.out.print("No War");}
      else{System.out.print("War");}
	}
}

Measured memory_bytes: 22608
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
using namespace std;
const int mod = 1000000007;

int main() {
 
  int64_t N,M,X,m=INF;
  cin>>N>>M>>X;
  //for(int i=0; i<N; i++){cin>>A[i];}
  vector<vector<int> > A(N,vector<int>(M+1));
  for(int i=0; i<N; i++){
    for(int j=0; j<M+1; j++){
      cin>>A[i][j];
    }
  }

  for (int i = 0; i < (1 << 12); i++) {
    bitset<12> s(i);
    vector<int64_t> P(M+1,0);
    int64_t price=0;
    for(int j=0; j<N; j++){
      if(s.test(j)){
        price+=A[j][0];
        for(int k=1; k<=M; k++){
          P[k]+=A[j][k];
        }
      }
    }
    for(int k=1; k<=M; k++){
         if(P[k]<X)break;
         if(k==M)m=min(m,price);
        }
}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  if(m==INF)cout<<-1<<endl;
  else cout << m << endl;
}

Measured memory_bytes: 3632
N = int(input())
F = [int(input().replace(' ', ''), 2) for _ in range(N)]
P = [[int(_) for _ in input().split()] for _ in range(N)]

ans = - 10 ** 10
for i in range(1, 2 ** 10):
    ans = max(ans, sum([P[j][bin(i&F[j]).count('1')] for j in range(N)]))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>
#include<cmath>
#include<utility>
#include<cstdlib>
#include<bitset>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iomanip>
using namespace std;                       

#define ll long long
#define pb push_back
#define mp make_pair

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const ll M = 1e9 + 7;

ll fastpo(ll a, ll x){
    if(x == 0) return 1ll;
    if(x == 1) return a;
    ll y = fastpo(a, x/2);
    if(x%2 == 0){
        return y*y;
    }
    return y*y*a;
}

ll inv(ll a, ll M){
    return fastpo(a, M-2);
}

ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}

ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    if (g != 1) 
        return -1; 
    else
    { 
        ll res = (x%m + m) % m; 
        return res;
    } 
}


ll gcd(ll a, ll b){
    if(a == 0){
        return b;
    }
    return gcd(b%a, a);
}

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

void print(vector<int> &a){
    int n = a.size();
    for(int i=0; i<n; i++){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}

string next(string s){
    int n = s.length();
    for(int i=n-1; i>=0; i--){
        if(s[i] == '1'){
            s[i] = '0';
        }
        else{
            s[i] = '1';
            return s;
        }
    }
    return s;
}

int main(){
//    clock_t time_req;
//     time_req = clock();
    int n, m, k;
    cin>>n>>m>>k;
    vector<string> a(n);
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    int all = 1<<(n+m);
    string s = "";
    for(int i=0; i<n+m; i++){
        s.pb('0');
    }
    int sum = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(a[i][j] == '#') sum++;
        }
    }
    int ans = 0;
    for(int i=0; i<all; i++){
        int b = sum;
        for(int j=0; j<n+m; j++){
            if(s[j] == '0') continue;
            if(j < n){
                for(int p=0; p<m; p++){
                    if(a[j][p] == '#') b--;
                }
            }
            else{
                int q = j-n;
                // cout<<q<<" ";
                for(int p=0; p<n; p++){
                    if(a[p][q] == '#' && s[p] == '0'){
                        // cout<<"a";
                        b--;
                    }
                }
            }
        }
        // cout<<s<<" "<<b<<endl;
        if(b == k){
            ans++;
        }
        s = next(s);
    }
    cout<<ans<<endl;
    // time_req = clock()-time_req;
    // cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int [] list = new int [n + 1];
		list[0] = 0;

		for(int i = 1; i <= n; i++) {
			list[i] = sc.nextInt();
			list[i] += list[i-1];
		}
		int ans = 0;
		for(int i = 0; i <= n; i++) {
			if( list[i] <= x) ans++;
			else break;
		}
		System.out.println(ans);
	}
}

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

vector<int> D(1000001, -1);

void P() {
  D.at(0) = D.at(1) = 0;
  for (int i = 2; i <= 1000000; i++) {
    if (D.at(i) != -1) continue;
    for (int j = 2; i * j <= 1000000; j++) {
      if (D.at(i * j) == -1) D.at(i * j) = i;
    }
  }
  return;
}

int main() {
  P();
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int G = A.at(0);
  for (int i = 0; i < N; i++) G = __gcd(G, A.at(i));
  string ans = "pairwise coprime";
  set<int> S;
  for (int i = 0; i < N; i++) {
    if (A.at(i) == 1) continue;
    while (D.at(A.at(i)) > 0) {
      if (S.count(D.at(A.at(i)))) {
        ans = "setwise coprime";
        break;
      }
      else {
        int x = D.at(A.at(i));
        S.insert(x);
        while (A.at(i) % x == 0) A.at(i) /= x;
      }
    }
    if (A.at(i) != 1) {
      if (S.count(A.at(i))) {
        ans = "setwise coprime";
        break;
      }
      else S.insert(A.at(i));
    }
  }
  if (G != 1) ans = "not coprime";
  cout << ans << endl;
}

Measured memory_bytes: 11164
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val k = sc.nextLong()
    val n = sc.nextLong()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem160c(k, n, a))
}

fun problem160c(k: Long, n: Long, a: List<Long>): Long {
    var maxDiff = a[0]
    var maxI = -1
    for (i in 1 until a.size) {
        val diff = a[i] - a[i - 1]
        if (maxDiff < diff) maxI = i
        maxDiff = Math.max(maxDiff, diff)
    }
    if (maxDiff <= k - a.last() + a[0]) maxI = -1

    if (maxI == -1) {
        return a.last() - a[0]
    }
    return a[maxI - 1] + k - a[maxI]
}

Measured memory_bytes: 53712
def d_robot_arms(N, Pos):
    # 参考: http://drken1215.hatenablog.com/entry/2018/09/30/002900
    ans = []

    pos = []
    parity = (abs(Pos[0][0]) + abs(Pos[0][1])) % 2
    for x, y in Pos:
        parity_current = (abs(x) + abs(y)) % 2
        if parity != parity_current:
            return -1
        pos.append([x + y, x - y])

    d = []
    for i in range(30, -1, -1):
        d.append(1 << i)
    if parity % 2 == 0:
        d.append(1)
    ans.append(str(len(d)))
    ans.append(' '.join(list(map(str, d))))

    for i in range(N):
        xdir, ydir = 0, 0
        xsum, ysum = 0, 0
        tmp = []
        for j in range(len(d)):
            if xsum <= pos[i][0]:
                xdir = 1
                xsum += d[j]
            else:
                xdir = -1
                xsum -= d[j]
            
            if ysum <= pos[i][1]:
                ydir = 1
                ysum += d[j]
            else:
                ydir = -1
                ysum -= d[j]
            
            if xdir == 1 and ydir==1:
                tmp.append('R')
            elif xdir == 1 and ydir==-1:
                tmp.append('U')
            elif xdir == -1 and ydir==-1:
                tmp.append('L')
            else:
                tmp.append('D')
        ans.append(''.join(tmp))
    ans = '\n'.join(ans)
    return ans

N = int(input())
Pos = [[int(i) for i in input().split()] for j in range(N)]
print(d_robot_arms(N, Pos))

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

void solve(long long N, long long K, vector<long long> h){
	sort(h.begin(), h.end());
	long long res = (int)1e9 + 10;
	for(int i = 0; i + K <= N; ++i) {
		res = min(res, h[i + K - 1] - h[i]);
	}
	cout << res << endl;
}

int main(){	
	long long K;
	long long N;
	scanf("%lld",&N);
	vector<long long> h(N-1+1);
	scanf("%lld",&K);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&h[i]);
	}
	solve(N, K, h);
	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 int main(){
   ll n;
   cin>>n;
   ll k=1,ans=0;
   while(n>0){
     ans+=k;
     n/=2;
     k*=2;
   }
   cout<<ans<<endl;
   return 0;
 }

Measured memory_bytes: 256
import sys
my_input = sys.stdin.readline


class BinarySearchTree:
    class Node:
        def __init__(self, key):
            __slots__ = ['key', 'left', 'right', 'parent']
            self.key = key
            self.left = None
            self.right = None
            self.parent = None

    def __init__(self):
        self.root = None

    def insert(self, target_key):
        parent = None
        attention = self.root
        target = self.Node(target_key)

        while attention is not None:
            parent = attention
            if target.key < attention.key:
                attention = attention.left
            else:
                attention = attention.right
        target.parent = parent

        if parent is None:
            self.root = target
        elif target.key < parent.key:
            parent.left = target
        else:
            parent.right = target

    def preorder_walk(self, node):
        if node is None:
            return []
        return [node.key] + self.preorder_walk(node.left) + self.preorder_walk(node.right)

    def inorder_walk(self, node):
        if node is None:
            return []
        return self.inorder_walk(node.left) + [node.key] + self.inorder_walk(node.right)


N = int(my_input())
BST = BinarySearchTree()
for _ in range(N):
    command = my_input().split()
    if len(command) == 2:
        BST.insert(int(command[1]))
    else:
        print(' ' + ' '.join(map(str, BST.inorder_walk(BST.root))))
        print(' ' + ' '.join(map(str, BST.preorder_walk(BST.root))))




Measured memory_bytes: 143832
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	if(0) {
possible:
		print("Possible");
		return 0;
impossible:
		print("Impossible");
		return 0;
	}
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];

	int k = 0;
	for(int e:a) k=std::max(k,e);

	std::multiset<int> set(all(a));

	std::vector<int> necessary;
	for(int i=0;i<=k/2;i++) {
		int x = i; int y = k-i;
		auto it = set.find(k-i);
		if(it==set.end()) goto impossible;
		set.erase(it);
		if(x==y) break;
		it = set.find(k-i);
		if(it==set.end()) goto impossible;
		set.erase(it);
	}

	int l = (k+1)/2+1;
	int r = k;

	for(int e:set) {
		if(e<l || r<e) goto impossible;
	}


	goto possible;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
	int x = 0, ans = 0, n;
	string s;
	cin >> n >> s;
	REP(i,n){
		if (s[i] == 'I') x++;
		else x--;
		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>#include <iomanip>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define debug(s, param) std::cerr << s << param << std::endl;

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> p(n, 0), q(n, 0), v(n);
  rep (i, n) cin >> p[i];
  rep (i, n) cin >> q[i];
  rep (i, n) v[i] = i + 1;

  int a = 1, b = 1;
  bool pDone = false, qDone = false;
  do {
    bool allMatchP = true;
    bool allMatchQ = true;
    rep (i, n) {
      if (p[i] != v[i]) allMatchP = false;
      if (q[i] != v[i]) allMatchQ = false;
    }
    if (allMatchP) pDone = true;
    if (allMatchQ) qDone = true;
    if (pDone && qDone) break;
    if (!pDone) ++a;
    if (!qDone) ++b;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(a-b) << endl;
  return 0;
}

Measured memory_bytes: 3604
from sys import stdin
N=int(stdin.readline().rstrip())
 
data=[]
ans=0
A=0
B=0
ab=0
for i in range(N):
    S=input()
    ans+=S.count("AB")
    if S[0] == "B":
        B+=1
    if S[-1] == "A":
        A+=1
    if S[-1] == "A" and S[0] == "B":
        ab+=1
if ab == 0:
    print(ans+min(A,B))
    
elif A == B == ab:
    print(ans+ab-1)

else:
    print(ans+min(A,B))

Measured memory_bytes: 3064
N = int(input())
cnt = 0
g = 0
for i in range(1,N+1):
  if i % 2 == 1:
    cnt = 0
    for j in range(1,i+1):
      if i % j == 0:
        cnt += 1
    if cnt == 8:
      g += 1
print(g)

Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main() { 
    int a, b;
    cin >> a >> b;
    if (a - b > 0) {
    cout << a - b << endl;
    }
    else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;

typedef pair<int, int> P;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int H, W, sx, sy, gx, gy;
    cin >> H >> W;
    --sx;
    --sy;
    --gx;
    --gy;
    char s[H][W];
    int count = 0;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cin >> s[i][j];
            if(s[i][j] == '.') count++;
        }
    }

    sx = 0, sy = 0;
    gx = H-1, gy = W-1;
    int dist[H][W];
    fill(dist[0], dist[H], INF);
    queue<P> que;
    dist[sx][sy] = 0;
    que.push(P(sx, sy));
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int x = p.first;
        int y = p.second;
        
        for(int i = 0; i < 4; ++i){
            int nx = x + dx[i], ny = y + dy[i];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W)  continue;
            if(s[nx][ny] == '#')    continue;
            
            if(dist[nx][ny] > dist[x][y] + 1){
                dist[nx][ny] = dist[x][y] + 1;
                que.push(P(nx, ny));
            }
        }
    }
    
    if(dist[gx][gy] == INF){
      cout << -1 << endl;
    }
    else cout << count - dist[gx][gy] - 1 << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val X = nextInt()
    if (X < 100) {
        println(0)
        return
    }
    val n = X / 100
    val r = (X - (n * 100)).toDouble() / n.toDouble()
    println(if (r > 5.0) 0 else 1)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int a;
    cin >> a;

    string s;
    cin >> s;

    if(a < 3200)
        cout << "red\n";
    else
        cout << s << '\n';
    return 0;
}

Measured memory_bytes: 256
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
let kotae = readInts()
let a = kotae[0]
let b = kotae[1]

if (a+b)%2==0 { 
  print((a+b)/2)
} else { 
  print("IMPOSSIBLE")
}

Measured memory_bytes: 8272
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
import bisect
import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal

INF = 1 << 50


def run():
    N, K, *A = map(int, read().split())
    A_lists = [A]
    while True:
        generated_A = []
        B = A_lists[-1]
        for i in range(0, len(B), 2):
            if i+1 < len(B):
                val = math.gcd(B[i], B[i+1])
                generated_A.append(val)
            else:
                generated_A.append(B[i])
        A_lists.append(generated_A)
        if len(generated_A) == 1:
            break

    gcd = A_lists[-1][0]
    #print(gcd)
    amax = max(A)
    if not K % gcd and K <= amax:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')



if __name__ == "__main__":
    run()

Measured memory_bytes: 36284
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

vector<ll> to(200000), order;
vector<bool> f(200000, false);
void dfs(ll v){
  order.emplace_back(v);
  if(f[v]) return;
  f[v] = true;
  dfs(to[v]);
}

int main(void){
  ll n, k;
  cin >> n >> k;
  REP(i, n) cin >> to[i], to[i]--;
  dfs(0);
  ll m = order.size();
  map<ll, ll> mp;
  ll r = m-1;
  ll l;
  REP(i, m-1) if(order[i] == order.back()) l = i;
  if(k < m) cout << order[k]+1 << endl;
  else{
    ll t = r-l;
    cout << order[l + ((k-l)%t)]+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 12524
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    LL ans = N-1;
    for (LL i = 2; i * i <= N; ++i) {
        if (N % i == 0) {
            LL j = N / i;
            LL k = (i-1) + (j-1);
            ans = min(ans, k);
        }
    }

    cout << ans << endl;

    return 0;
}


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 (int i = 0; i < (int)(n); i++)
# define RREP(i,n) for (int i=(n)-1;i>=0;i--)

# define int(x) int x; scanf("%d",&x);
# define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
# define string(x) string x; cin >> x;

using namespace std;

namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    REP (i, mat.size()) {
      REP (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    REP (i, v.size())
      if (i >= v.size()-1)
	cout << v[i];
      else
	cout << v[i] << ' ';
    
    cout << endl;
  }

  template <typename T> pair<T, T> shape(vector<vector<T>> mat) {
    int d1, d2;

    d1 = mat.size();
    if (d1 > 0) d2 = mat[0].size();
    else int d2 = 0;
    cout << "(" << d1 << ", " << d2 << ")" << endl;
    return make_pair(0, 0);
  }

  template <typename T> vector<vector<T>> empty(int n, int m) {
    vector<vector<T>> mat(n, vector<T>(m));
    return mat;
  }
}


int main() {
  int(n);
  vint(A,n);
  long long ans = 1000000000000000000LL;
  long long  x = 0;
  long long  X = 0;
  REP(i,n)
    X += A[i];

  REP(i,n){
    x += A[i];
    if(i+1<n)
      ans = min(ans,abs(X-2*x));
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
const long long INF = numeric_limits<long long>::max();
int main() {
    ll A, B;
    cin >> A >> B;
    string str;
    cin >> str;

    bool isOk = true;
    REP(i, str.size()) {
        if (i == A) {
            isOk &= str[i] == '-';
        } else {
            isOk &= str[i] != '-';
        }
        if (!isOk) break;
    }
    PR(isOk ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int f[505][505],up[505],dw[505];
pair<int,int> v[505];

int main(){
	int n,M;
	scanf("%d%d",&n,&M);
	for(int i=0;i<2*n;i++){
		up[i]=sqrt(2*n*2*n-i*i);
		if(up[i]==2*n)up[i]--;
		if(i<n){
			dw[i]=sqrt(n*n-i*i-1);
			v[i]=make_pair(dw[i],n-1-i);
		}else v[i]=make_pair(up[i],i);
	}
	sort(v,v+2*n);
	for(int i=0;i<2*n;i++)if(v[i].second<n)v[i].second=n-1-v[i].second;
	int ans=0;
	for(int i=0;i<=n;i++){
		memset(f,0,sizeof(f));
		if(v[0].second<n){
			f[0][0]=v[0].first+1;
			f[0][1]=max(up[v[0].second]-n-(n-i)+1,0);
		}else{
			f[0][0]=v[0].first+1;
		}
		for(int j=1;j<2*n;j++)
			for(int k=0;k<=min(i,j+1);k++)
				if(v[j].second<n)f[j][k]=((k>0?1ll*f[j-1][k-1]*max(up[v[j].second]-n-(n-i)-(k-1)+1,0):0)+1ll*f[j-1][k]*max(v[j].first-(j-k)+1,0))%M;
				else f[j][k]=1ll*f[j-1][k]*max(v[j].first-(j-k)+1,0)%M;
		if((n-i)&1)ans=(ans-f[2*n-1][i]+M)%M;
		else ans=(ans+f[2*n-1][i])%M;
	}
	printf("%d\n",ans);
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	vector<bool> alphabet_flag(26);

	for (int i = 0; i < s.size(); i++)
	{
		alphabet_flag.at(s.at(i) - 'a') = true;
	}

	for (int i = 0; i < alphabet_flag.size(); i++)
	{
		if (!alphabet_flag.at(i))
		{
			cout << (char)(i + 'a') << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    string s;
    cin>>s;
    char now=s[0];
    lint cnt=1;
    rep(i,s.size()){
        if(now!=s[i]){
            cnt++;
            now=s[i];
        }
    }
    cout<<cnt-1;
}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll n; cin>>n;
    if(n%2!=0){
        cout<<0<<endl;
        return 0;
    }
    ll ans=0;
    ll w=5;
    while(1){
        ans+=n/(w*2);
        if(n/(w*2)==0)break;
        w*=5;
    }
    cout<<ans<<endl;
}









































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

using namespace std;

const int MOD = 1e9 + 7;

int n,i;

int main(){
	scanf("%d", &n);
	
	long long res = 1;
	
	for(i = 1; i <= n; i++)
	res = (res * i) % MOD;
	
	printf("%lld\n", res);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            string s = Console.ReadLine();
            int n0 = 0, n1 = 0;
            foreach (char c in s)
            {
                if (c == '0') n0++;
                else n1++;
            }
            Console.WriteLine(Math.Min(n0, n1) * 2);
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 11232
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pa;
const int maxn=1e4+7;
const int mod=1e9;
int n,t,m;
int a[maxn];
int main()
{
    int sum=mod;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=100;i++){
        int s=0;
        for(int j=0;j<n;j++){
            s+=(a[j]-i)*(a[j]-i);
        }
        sum=min(sum,s);
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		in.close();
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int a = Integer.parseInt(tokens[0].substring(0, 3));
		int b = Integer.parseInt(tokens[1].substring(0, 3));
		int min = Integer.parseInt(tokens[0].substring(0, 3) + tokens[0].charAt(1) + tokens[0].charAt(0));
		int max = Integer.parseInt(tokens[1].substring(0, 3) + tokens[1].charAt(1) + tokens[1].charAt(0));
		int result = b - a + 1;
		if (A > min) {
			result -= 1;
		}
		if (B < max) {
			result -= 1;
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  int minsF = 0;
  int ans = 0;

  cin >> N;

  vector<long long> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] < 0){
      minsF++;
    }
  }

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

  if(minsF == 0){
    //全て正数の場合
    cout << A[N-1]-A[0] << endl;
  }else{
    //負の数が含まれる場合
    cout << A[N-1] - A[0] << endl;
  }

}


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

using namespace std;

int main(){
  int n;
  std::cin >> n;

  vector<int> p(n);
  int max = -INT_MAX;
  for(int i=0; i<n; i++){
    std::cin >> p[i];
    if(max < p[i]) max = p[i];
  }

  int ans = 0;
  for(int i=0; i<n; i++){
    ans += p[i];
  }
  std::cout << ans - max + max/2 << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

/*
   AtCoder contest
   coder : yoichidon
 */

class Counter<T> extends HashMap<T,Integer>{
    public Counter(){
        super();
    }
    public Integer get(Object elm){
        return getOrDefault(elm,0);
    }
    public void add(T elm, int amount){
        if(!this.containsKey(elm)) put(elm, amount);
        else replace(elm, get(elm)+amount);
    }
    public void addOne(T elm){
        add(elm, 1);
    }
    public void remove(T elm, int amount){
        replace(elm, Math.max(get(elm)-amount, 0));
    }
    public void removeOne(T elm){
        remove(elm, 1);
    }
}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();

        Counter<Integer> favorite = new Counter<>();
        for(int n=0; n<N; n++){
            int K = sc.nextInt();
            for(int k=0; k<K; k++){
                favorite.addOne(sc.nextInt());
            }
        }

        int ans = 0;
        for(Integer food:favorite.keySet()){
            if(favorite.get(food).equals(N)) ans++;
        }
        System.out.println(ans);


    }
}


Measured memory_bytes: 22612
# A B c
# d E f
# g h i

a = int(input())
b = int(input())
e = int(input())
g = a + b - e
h = a + e - g
t = b + e + h
c = t - a - b
d = t - a - g
f = t - d - e
i = t - g - h
print("{} {} {}".format(a,b,c))
print("{} {} {}".format(d,e,f))
print("{} {} {}".format(g,h,i))


Measured memory_bytes: 3064