akhauriyash/Code-Regression huggingface dataset:
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,k,a,ans=0;
  map<int,int> mp;
  cin >> n >> m;
  for(int i=0; i<n; i++) {
    cin >> k;
    for(int j=0; j<k; j++) {
      cin >> a;
      mp[a]++;
    }
  }
  for(auto p:mp) {
    if(p.second==n) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int mxn=1e5+10;
ll n,arr[mxn],dp[mxn][3];
ll func(ll i,ll idx)
{
    if(idx>=n-1)
        return 0;
    if(dp[idx][i]!=-1)
        return dp[idx][i];
    ll p=0,q=INT64_MAX;
    p=func(1,idx+1)+abs(arr[idx+1]-arr[idx]);
    if(idx+2<n)
        q=func(2,idx+2)+abs(arr[idx+2]-arr[idx]);
    return dp[idx][i]=min(p,q);
}
int main()
{   
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    memset(dp,-1,sizeof dp);
    cout<<func(0,0)<<endl;
    return 0;
}

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

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

int  answ(int a[5001],int i,int j,int n)
{
	return  a[i]+(j-i-(a[j]-a[i]))+a[n]-a[j];
}

int main(){

    int n,k;
    scanf("%d%d",&n,&k);
    int ans=1;
    while(n--){
        if(ans*2<=ans+k){
            ans*=2;
        }
        else{
            ans+=k;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        
        long cntA = 0;
        long cntB = 0;
        long lcm = lcm(c, d);

  
        cntA = a - a / c - a / d + a / lcm(c, d);
        cntB = b - b / c - b / d + b / lcm(c, d);
 
        long res = (cntB - cntA);
        if(a % c != 0 && a % d != 0) res++;
        System.out.println(res);
    }

    private static long gcd(long a, long b) {
    	if(b == 0)
    		return a;
    	return gcd(b, a % b);
    }

    private static long lcm(long a, long b) {
    	return a / gcd(a, b) * b;
    }

}




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

int main(){
  long long int n,m;
  cin >> n >> m;
  vector<vector<long long int>> stu(n, vector<long long int>(2));
  vector<vector<long long int>> check(m, vector<long long int>(2));
  rep(i,n)cin>>stu.at(i).at(0) >> stu.at(i).at(1);
  rep(i,m)cin>>check.at(i).at(0) >> check.at(i).at(1);
  long long int out;
  long long int MIN;
  long long int tmp;
  rep(i,n){
    MIN = abs(stu.at(i).at(0)-check.at(0).at(0))+abs(stu.at(i).at(1)-check.at(0).at(1));
    out = 1;
    rep(j,m){
      tmp =abs(stu.at(i).at(0)-check.at(j).at(0))+abs(stu.at(i).at(1)-check.at(j).at(1));
      if(tmp<MIN){
        out = j+1;
        MIN = tmp;
      }
    }
    cout << out << endl;
  }

	return 0;
}


Measured memory_bytes: 256
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def main() -> None:
    q, h, s, d = [next_int() for _ in range(4)]
    n = next_int()
    s = min(4 * q, 2 * h, s)
    
    print(s * (n % 2) + min(2 * s, d) * (n // 2))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
	let N = parseInt(input[0][0], 10);
	let M = parseInt(input[0][1], 10);
	let line;
	let ans = 0;
	for (skip = 0; skip < M; skip++){
		let uf = new UnionFind(N);
		for (let i = 0; i < M; i++){
			if (i === skip) continue;
			line = input[i + 1].map(e => parseInt(e, 10));
			uf.union(line[0] - 1, line[1] - 1);
		}
		if (uf.size(0) !== N) ans ++;
	}	
	console.log(ans);
}

function UnionFind (n) {
	this.parents = [];
	for (let i = 0; i < n; i++) {
		this.parents.push(-1);
	}
}

UnionFind.prototype.find = function (x) {
	if (this.parents[x] < 0) return x;
	return this.parents[x] = this.find(this.parents[x]);	
}

UnionFind.prototype.union = function (x, y) {
	x = this.find(x);
	y = this.find(y);
	if (x === y) return;
	if (this.parents[x] > this.parents[y]) [x, y] = [y, x];
	
	this.parents[x] += this.parents[y];
	this.parents[y] = x;
}

UnionFind.prototype.size = function (x) {
	x = this.find(x);
	while (x >= 0) {
		x = this.parents[x];
	}
	return x * -1;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

struct UnionFind {
  vector<LL> data;
  UnionFind(LL size) : data(size, -1) { }
  bool unionSet(LL x, LL y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(LL x, LL y) {
    return root(x) == root(y);
  }
  LL root(LL x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  LL size(LL x) {
    return -data[root(x)];
  }
};

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    LL ans = 1;
    REP1(i, N) ans += i;
    vector<LL> result;
    REP(i, M){
        A[i]--;
        B[i]--;
    }

    UnionFind uf(N);
    RREP(i, A.size()-1) {
        result.PB(ans);
        
        if(!uf.findSet(A[i], B[i])){
            LL a_size = uf.size(A[i]);
            LL b_size = uf.size(B[i]);
            uf.unionSet(A[i], B[i]);
            ans -= a_size * b_size;
        }
    }

    RREP(i, result.size()-1){
        cout << result[i]-1 << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


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

int main() {
    while(1){
        int a, b;
        cin >> a >> b;
        if (a == 0 && b == 0){
            break;
        }
        if (a > b) {
            cout << b << ' ' << a << endl;
        } else {
            cout << a << ' ' << b << endl;
        }
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
 
const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
deque<char> deq;
 
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for(auto tmp : S) {
        deq.push_back(tmp);
    }
    bool on = false;
    int Q;
    cin >> Q;
    while(Q--) {
        int T;
        cin >> T;
        if(T == 1) on ^= true;
        else {
            int F;
            cin >> F;
            char c;
            cin >> c;
            if(on ^ (F == 1)) deq.push_front(c);
            else deq.push_back(c);
        }
    }
    string ans;
    for(auto tmp : deq) ans.push_back(tmp);
    if(on) reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1368
#include <bits/stdc++.h>
 
#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;
 
const int INF = 1e9 + 7;
 
using namespace std;
 
int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	int k, x;
	cin >> k >> x;

	int MIN = -1000000;
	int MAX = 1000000;

	for (int i = max(x - (k-1), MIN); i <= min(x + (k-1), MAX); i++) {
	    cout << i << endl;
	}
	    


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

int main(){
  int m,n;
  cin>>n>>m;
  if(abs(n-m)>1) {
    cout<<"0"<<endl;
  }
  else if(abs(n-m)==1){
    cout<<(kaijo(n)*kaijo(m))%1000000007<<endl;
  }
  else{
    cout<<(kaijo(n)*kaijo(m))%1000000007*2%1000000007<<endl;
  }

  
  
  return 0;
}

  



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define db double
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define ms(x,v) memset(x,v,sizeof x)
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
ll i,j,k;
ll ans;
vector<long int > tree[10000+1];
vector<long int > v;
vector<bool> visited(10000+1,0);
int main(){
   
  ll x; cin>>x; 
  //cout<<x<<endl;
  ll y;
  if(x%2==0) y=x/2;
  else y=(x/2)+1;
  //cout<<y<<endl;
  db z=((1.0)*y)/((1.0)*x);
  cout<<setprecision(6)<<fixed<<z<<endl;


return 0;
}

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

using namespace std;

int A, B, C;

int main() {
	cin >> A >> B >> C;
	if (A == B && A != C) {
		cout << "Yes" << endl;
		return 0;
	}
	else if (A == C && A != B) {
		cout << "Yes" << endl;
		return 0;
	}
	else if (B == C && B != A) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;

}

Measured memory_bytes: 256
n, m = map( int, input().split())

l = [[0] * n for _ in range( m )]
for i in range( m ):
  k = list( map( int, input().split() ))
  for j in range( 1, k[0] + 1 ):
    l[i][ k[ j ] - 1] = 1
p = list( map( int, input().split() ) )

ret = 0
for i in range( 2 ** n ):
  b = [ int(k) for k in str( format(i,'b').zfill(n))]
  cnt = 0
  for j in range( m ): 
    a = 0
    for k in range( n ):
      a += b[ k ] * l[ j ][ k ]
    if a % 2 == p[ j ]:
      cnt += 1
  if cnt == m:
    ret += 1
print( ret )

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


int main() {
  int N, sum;
  cin >> N;
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    if (r != l){
      sum += r - l + 1;
    }
    else sum += 1;
  }
  cout << sum << endl;
}
     

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
#define double long double
typedef long long ll;
typedef unsigned long long ull;

template<typename T>
void __read(T &a) { cin >> a; }

template<typename T, typename ... Args>
void __read(T &a, Args &... args) {
    cin >> a;
    __read(args...);
}

#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T>
void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
template<class T>
static auto __super_speed__ = (ios_base::sync_with_stdio(0), cin.tie(
        0)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
//endregion

int fpow(int a, int b){
    int res = 1;
    while(b != 0){
        if (b & 1){
            res = res * a % M7;
        }
        a = a * a % M7;
        b >>= 1;
    }
    return res;
}

int inv(int a){
    return fpow(a, M7 - 2);
}

int32_t main() {
    make(int, n, k);
    k--;
    VI a(n);
    FOR(n){
        cin >> a[i];
    }
    sort(ALL(a));
    int res[] = {0, 0};
    VI f(n + 1);
    f[0] = 1;
    for(int i = 1; i <= n; ++i){
        f[i] = f[i - 1] * i % M7;
    }
    for(int b = 0; b < 2; ++b){
        int cur = f[n] * inv(f[k]) % M7 * inv(f[n - k]) % M7;
        for(int i = 0; i + k <= n; ++i){
            cur = cur * (n - i - k) % M7 * inv(n - i) % M7;
            res[b] += a[i] * cur % M7;
        }
        res[b] = (res[b] % M7 + M7) % M7;
        reverse(ALL(a));
    }
    cout << (res[1] - res[0] + M7) % M7;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

ll massiv[200010];
ll dp[200010];
ll n;

int main(){
FLASH;
cin>>n;
ll maxx=0;
for(ll i=1;i<=n;i++)cin>>massiv[i];
for(ll i=1;i<=n;i++)
{
  dp[massiv[i]]=max(dp[massiv[i]-1]+1,dp[massiv[i]]);
  maxx=max(maxx,dp[massiv[i]]);  	
}

cout<<n-maxx<<endl;






return 0;
} 


Measured memory_bytes: 6760
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

from heapq import heappop, heappush

dxdy = [(0,1),(1,0),(0,-1),(-1,0)]

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

def dfs(x, y):
    dist = [[float("inf")]*w for i in range(h)]
    heap = [(0, x, y)]
    while heap:
        c,x,y = heappop(heap)
        if dist[x][y] <= c:
            continue
        dist[x][y] = c
        for dx, dy in dxdy:
            nx = x + dx
            ny = y + dy
            if 0<=nx<h and 0<=ny<w and board[nx][ny] == "." and dist[nx][ny] > c+1:
                heappush(heap, (c+1, nx, ny))
    ret = 0
    for i in range(h):
        for j in range(w):
            if dist[i][j] != float("inf"):
                ret = max(ret, dist[i][j])
    return ret

ans = 0
for i in range(h):
    for j in range(w):
        if board[i][j] == ".":
            ans = max(ans, dfs(i,j))

print(ans)

Measured memory_bytes: 62556
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(int[]), k = rd[0], s = rd[1];

  auto ans = 0;
  foreach (x; 0..k+1)
    foreach (y; 0..k+1) {
      auto z = s-x-y;
      if (0 <= z && z <= k) ++ans;
    }

  writeln(ans);
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

enum P = 10L^^9+7;

void main()
{
    auto S = readln.chomp.to!int;
    auto DP = new long[](S+1);
    DP[] = -1;
    
    long solve(int s) {
        if (s == 0) return 1;
        if (s < 3) return 0;
        if (DP[s] == -1) {
            long r;
            foreach (i; 3..s+1) {
                (r += solve(s-i)) %= P;
            }
            DP[s] = r;
        }
        return DP[s];
    }
    writeln(solve(S));
}

Measured memory_bytes: 2760
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 13, 2020 11:37 PM
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
#define mod 1000000007
#define sz 1000+10
using namespace std;

int dp[sz][sz];

int main(){
    ios_base::sync_with_stdio(false);

    int row, col;
    cin >> row >> col;

    for(int i=0; i<row; i++) dp[i][0] = 0;
    for(int j=0; j<col; j++) dp[0][j] = 0;

    dp[1][1] = 1;

    for(int i=1; i<=row; i++){
        for(int j=1; j<=col; j++){
            char ch;
            cin >> ch;
            
            if(i == 1 && j == 1) continue;
            if(ch == '#' ) continue;

            dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod) % mod;
        }
    }

    cout << dp[row][col] << endl;

    return 0 ;
}


Measured memory_bytes: 7576
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long int n;
	cin>>n;
	long int p,q,i,j=sqrt(n);
	for(i=1;i<=j;i++)
	{
		if(n%i==0)
		{
			p=i;
			q=n/i;
		}
	}
	cout<<(p+q-2);
}

Measured memory_bytes: 256
import numpy as np

w, h, n = map(int, input().split())

r = np.ones([h, w], dtype=int)

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        r[:, :x] = 0
    elif a == 2:
        r[:, x:] = 0
    elif a == 3:
        r[:y, :] = 0
    else:
        r[y:, :] = 0

print(sum(sum(r)))


Measured memory_bytes: 12504
#include <iostream>
using namespace std;
#define ll long long

int main () {
  ll n, a, b;
  cin >> n >> a >> b;
  ll x[n];
  ll ans = 0;
  ll now = 1;
  for (ll i =0 ; i < n; i++) {
    cin >> x[i];
    if (i == 0) {
      now = x[i];  
    }
    if ((x[i] - now) * a > b) {
      ans += b;  
    }  
    else {
      ans += (x[i] - now) * a;  
    }
    now = x[i];
  }  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a;
  cin >> n;
  int evi[15][15];
  int ans = 0;
  for(int i = 0; i < 15; ++i) for(int j = 0; j < 15; ++j) evi[i][j] = -1;
  for(int i = 0; i < n; ++i){
    cin >> a;
    for(int j = 0, x, y; j < a; ++j){
      cin >> x >> y;
      --x;
      evi[i][x] = y;
    }
  }
  for(int bit = 0; bit < (1 << n); ++bit){
    vector<int> r(n);
    for(int i = 0; i < n; ++i){
      if(bit & (1 << i)){
        r[i] = 1;
      }
    }
    bool flag = true;
    for(int i =  0; i < n; ++i){
      if(r[i]){
        for(int j = 0; j < n; ++j){
          if(evi[i][j] == -1) continue;
          if(evi[i][j] != r[j]) flag = false;
        }
      }
    }
    if(flag) ans = max(ans, __builtin_popcount(bit));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ii pair<int,int>
#define ll long long int
#define F first
#define S second
using namespace std;
const int M = 1e4 + 7, mod = 1e9 + 7;

int a[107];
/// 10000 5000 1000
int main(){

  #ifndef ONLINE_JUDGE
  //freopen("i.txt", "r", stdin);
  //freopen("o.txt", "w", stdout);
  #endif

  int n, k;
  cin >> n >> k;

  if(k%1000){
    puts("-1 -1 -1");
    exit(0);
  }


  k/=1000;

  for(int i=0; i<M; i++){
    for(int j=0; j<M; j++){
      if(i+j>n)continue;
      int h = n - i - j;
      int p = i*10 + j*5 + h;
      if(p==k){
        cout << i << ' ' << j << ' ' << h << endl;
        exit(0);
      }
    }
  }


  puts("-1 -1 -1");

}


Measured memory_bytes: 256
s = str(input()) + 'E'
ans = [0] * (len(s)-1)
now = 0

for i in range(len(s)-1):
  now += 1
  if s[i] == s[i+1]:
    ans[i] += 0
  else:
    if s[i] == 'R':
      ans[i] += (now // 2 + now % 2)
      ans[i+1] += (now // 2)
      now = 0
    else:
      ans[i- now] += (now // 2)
      ans[i- now + 1] += (now // 2 + now % 2)
      now = 0

print(' '.join(map(str,ans)))
    

Measured memory_bytes: 17144
#include <iostream>

using namespace std;

int main()
{
	string s[3];
	unsigned int len[3];
	string name = "ABC";

	for (int i = 0; i < 3; i++) {
		cin >> s[i];
		len[i] = s[i].length();
	}
	unsigned int idx[3] = {0, 0, 0};
	unsigned int now = 0, next;

	while (idx[now] < len[now]) {
		next = s[now][idx[now]] - 'a';
		idx[now]++;
		now = next;
	}
	cout << name[now] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  set<ll> se;
  bool ret = true;
  rep(i, N) {
    cin >> A[i];
    if(se.count(A[i])) ret = false;
    se.insert(A[i]);
  }
  if(ret) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 11136
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n);
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); ++i)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)          (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)          (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define mp                  make_pair

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

D triangle_S(P p1, P p2, P p3){
    D l1 = sqrt(norm(p1-p2));
    D l2 = sqrt(norm(p2-p3));
    D l3 = sqrt(norm(p3-p1));
    D z = (l1 + l2 + l3) / 2;
    return sqrt(z * (z - l1) * (z - l2) * (z - l3));
}

void solve(vector<P> &v){
    int n = v.size();
    double sum = 0;
    REPEAT(i, 1, n-2){
        //cout << v[0] << " : " << v[i] << " : " << v[i+1] << endl;
        sum += triangle_S(v[0], v[i], v[i+1]);
    }
    printf("%.9f\n", sum);
}

int main(){
    string s;
    vector<P> v;
    while(cin >> s){
        D x, y;
        sscanf(s.c_str(), "%lf,%lf", &x, &y);
        P p(x,y);
        v.push_back(p);
    }
    solve(v);
    return 0;
}

Measured memory_bytes: 1308
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int N;
int bit[500005]; // bit 1-index
map<int, int> amap;

void add(int i, int x) {
  int tmp;
  if(amap[x]==0) {
    tmp = i;
    while(tmp<=N) {
      bit[tmp]++;
      tmp += tmp&-tmp;
    }
  }
  else {
    tmp = i;
    while(tmp<=N) {
      bit[tmp]++;
      tmp += tmp&-tmp;
    }
    tmp = amap[x];
    while(tmp<=N) {
      bit[tmp]--;
      tmp += tmp&-tmp;
    }
  }
  amap[x] = i;
}

int sum(int l) {
  int ans = 0;
  while(l>0) {
    ans += bit[l];
    l -= l&-l;
  }
  return ans;
}

int main() {
  int Q;
  cin>>N>>Q;
  int c[N];
  for(int i=0;i<N;++i) cin>>c[i];
  vector<tuple<int, int, int> > query(Q);
  int l, r;
  for(int i=0;i<Q;++i) {
    cin>>l>>r;
    query[i] = make_tuple(r, l, i);
  }
  sort(query.begin(), query.end());
  int ans[Q];
  int index = 0;
  for(int i=0;i<Q;++i) {
    l = get<1>(query[i]);
    r = get<0>(query[i]);
    for(int j=index;j<r;++j) {
      add(j+1, c[j]);
      ans[get<2>(query[i])] = sum(r) - sum(l-1);
    }
    index = r-1;
  }
  for(int i=0;i<Q;++i) cout<<ans[i]<<endl;
}



Measured memory_bytes: 38920
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define INF (1e9+1)
 
int n,W;
int dp[MAX];
 
int main(){
  fill(dp,dp+MAX,INF);
  dp[0]=0;
   
  cin>>n>>W;
  for(int i=0;i<n;i++){
    int v,w;
    cin>>v>>w;
    for(int j=MAX-1;j>=v;j--){
      dp[j]=min(dp[j],dp[j-v]+w);
    }
  }
 
  for(int i=MAX-1;i>=0;i--){
    if(dp[i]<=W){
      cout<<i<<endl;
      break;
    }
  }
   
  return 0;
}

Measured memory_bytes: 3504
n = int(input())
ls = [int(input()) for _ in range(n)]

ls.sort()

ans = sum(ls)

if ans % 10 != 0:
	print(ans)
else:
	for i in range(n):
		if ls[i] % 10 != 0:
			print(ans - ls[i])
			break
		elif i == n - 1:
			print(0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define bloop(i,a,b) for(int i=b-1;i>=a;i--)
#define brep(i,a) bloop(i,0,a)
using namespace std;

int decode(string s){
	int size=s.size();
	int ans=0;
	rep(i,size){
		if(s[i]=='m'){
			if(i==0)ans+=1000;
			else{
				ans+=(int)(s[i-1]-'0')*1000;
			}
		}else if(s[i]=='c'){
			if(i==0 || isalpha(s[i-1])){
				ans+=100;
			}else{
				ans+=(int)(s[i-1]-'0')*100;
			}
		}else if(s[i]=='x'){
			if(i==0 || isalpha(s[i-1])){
				ans+=10;
			}else{
				ans+=(int)(s[i-1]-'0')*10;
			}
		}else if(s[i]=='i'){
			if(i==0 || isalpha(s[i-1])){
				ans+=1;
			}else{
				ans+=(int)(s[i-1]-'0');
			}
		}
	}
	return ans;
}

string encode(int n){
	int mn=n/1000;
	int cn=(n-mn*1000)/100;
	int xn=(n-mn*1000-cn*100)/10;
	int in=(n-mn*1000-cn*100)%10;
	string ans="";
	if(mn==1)ans+='m';
	else if(mn!=0)ans=ans+(char)(mn+'0')+'m';
	if(cn==1)ans+='c';
	else if(cn!=0)ans=ans+(char)(cn+'0')+'c';
	if(xn==1)ans+='x';
	else if(xn!=0)ans=ans+(char)(xn+'0')+'x';
	if(in==1)ans+='i';
	else if(in!=0)ans=ans+(char)(in+'0')+'i';
	return ans;
}

int main(){
	int n;
	cin>>n;
	rep(z,n){
		string s1,s2;
		cin>>s1>>s2;
		int num1=decode(s1);
		int num2=decode(s2);
		int ans=num1+num2;
		cout<<encode(ans)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
import sys
 
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]+[0] #jがはみ出ないように最後に付け足しておく
MOD=7+10**9 #%MODを忘れない
 
dp=[1]+[0]*n
 
j=0
#iにのぼることができるかを考える
for i in range(1,n+1):
  if i==a[j]:
    j+=1
  elif i>1:
    dp[i] = (dp[i-1] + dp[i-2])%MOD #-1,-2からの遷移を考える
  else:
    if i!=a[0]:
      dp[i] = dp[i-1]

print((dp[-1])%MOD)

Measured memory_bytes: 8472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        long x = Min(n[1] - 1, n[2]);
        long result = (long)((n[0] * x) / (double)n[1]) - n[0] * (long)(x / (double)n[1]);
        WriteLine($"{result}");
    }
}


Measured memory_bytes: 19112
#include <iostream>
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
using namespace std;




int main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     ll i,j,m,n,k;
     ll t;
     ll s=0;
     cin>>n;
     for(i=1;i<=n;i++)
     {
         if(i%3==0 || i%5==0);
         else
             s+=i;
     }
    cout<<s;
}


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

int main(){
    long long n,k; cin>>n>>k;
    long long a[n],i=0;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    
    long long r=100000000;
    long long j;
    vector<int>dp(n,INT_MAX);
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        r=10000000000;

        if(i<=k){
            for(j=1;j<i+1;j++){
                r=min(dp[i-j]+abs(a[i]-a[i-j]),r);
            }
            dp[i]=r;
        }
        else{
            for(j=1;j<=k;j++){
                r=min(dp[i-j]+abs(a[i]-a[i-j]),r);
            }
            dp[i]=r;
            
        }
        }
        

    
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1408
main = do 
  a <- readLn
  s <- getLine
  let l = take (a `div` 2) s
  let l' = reverse $ take (a `div` 2) (reverse s)
  if (a `mod` 2) == 0 then if (l == l') then putStrLn "Yes" else putStrLn "No" else putStrLn "No"

Measured memory_bytes: 508
#include <iostream>
#include <cmath>
#include <algorithm>
int main()
{
    using namespace std;
    long long H, times = 0;
    int res;
    cin >> H;
    res = log2(H);
    res = floor(res);
    times = pow(2, res + 1) - 1;
    cout << times;
    return 0;
}

Measured memory_bytes: 512
h, w = gets.split.map(&:to_i)
a = []
h.times do
  a << gets.chomp.chars
end

([h, w].max * 2).times do
  a.delete_if {|s| s.count('.') == s.size } 
  a = a.transpose
end

a.each do |s|
  puts s.join
end


Measured memory_bytes: 11004
N = int(input())
A = sorted(list(map(int,input().split())))

p = A[-1]
n = A[0]

ans_list = []

for a in A[1:-1]:
    if a >= 0:
        ans_list.append((n, a))
        n -= a
    else:
        ans_list.append((p, a))
        p -= a

M = p - n
ans_list.append((p, n))

print(M)
for x, y in ans_list:
    print(x, y)

Measured memory_bytes: 20120
N = int(input())
A = list(map(int, input().split()))

upFlag = False
B = []
for i in range(1, N):
    if A[i-1] < A[i]:
        if not upFlag:
            B.append(A[i-1])
            upFlag = True
    elif A[i-1] > A[i]:
        if upFlag:
            B.append(A[i-1])
            upFlag = False

if upFlag:
    B.append(A[-1])


X = 1000
Y = 0

for i, b in enumerate(B):
    if i%2 == 0:
        Y = X//b
        X = X%b
    else:
        X += Y*b
        Y = 0

print(X)
    
    
    


Measured memory_bytes: 9212
R,G,B,N=map(int,input().split())
R,G,B=sorted([R,G,B])
ans=0
for b in range(1+N//B):
      for g in range(1+(N-b*B)//G):
            if  (N-b*B-g*G)%R==0:
                  ans+=1
print(ans)



Measured memory_bytes: 2940
S = input()

S = S.replace("hi", "")

if len(S) == 0:
    print("Yes")
else:
    print("No")

# if len(S) == 1:
#     print("No")
#     exit()
    
# for i in range(len(S)):
#     if i % 2 == 0:
#         if S[i] != "h":
#             print("No")
#             exit()
#     else:
#         if S[i] != "i":
#             print("No")
#             exit()

# print("Yes")


Measured memory_bytes: 2940
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
B=[];C=[]
for i in range(Q):
    b,c=map(int,input().split())
    B.append(b);C.append(c)
d={}
for a in A:
    if a not in d:
        d[a]=1
    else:
        d[a]+=1
s=sum(A)
for i in range(Q):
    b = B[i]
    c = C[i]
    if b not in d:
        print(s)
    else:
        if c not in d:
            s=s+(c-b)*d[b]
            print(s)
            d[c] = d[b]
            del d[b]
        else:
            s=s+(c-b)*d[b]
            print(s)
            d[c] += d[b]
            del d[b]

Measured memory_bytes: 96292
n, m, x = map(int, input().split())

arr = [list(map(int, input().split())) for _ in range(n)]

maxi = 10 ** 5 * 12 + 1
ans = maxi

for bits in range(1, 2 ** n):
    scores = [0 for _ in range(m)]
    cost = 0
    for i in range(n):
        if bits >> i & 1:
            cost += arr[i][0]
            for j in range(m):
                scores[j] += arr[i][j + 1]

    if min(scores) >= x:
        ans = min(ans, cost)

print(ans if ans != maxi else -1)


Measured memory_bytes: 9188
"""
// Author : snape_here - Susanta Mukherjee
     
"""
 
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
 
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())
 
 
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
    
 
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 
 
 
import math

mod=1000000007 

def main():

    n,a,b=mi()
    s=a+b
    if a==0:
        print(a)
        exit() 
    c=(n//s)*a
    d=min(n%s,a) 
    print(c+d)

# region fastio#
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
 
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
 
if __name__ == "__main__":
    #read()
    main() 
#Comment read()

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

int main(){
	int k[10],w[10];
	for(int i=0;i<10;i++){
		scanf("%d",&k[i]);
	}
	for(int i=0;i<10;i++){
		scanf("%d",&w[i]);
	}
	sort(k,k+10);
	sort(w,w+10);
	k[9]+=k[8]+k[7];
	w[9]+=w[8]+w[7];
	printf("%d %d\n",k[9],w[9]);
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

bool carry(int th, stack<tuple<int,int,int>>& st) {
  int f, l, c;
  tie(f, l, c) = st.top();
  if (c <= th) return true;
  int last = l;
  while (c >= th) {
    st.pop();
    if (st.empty()) return false;
    tie(f, l, c) = st.top();
  }
  st.pop();
  if (f != l) {
    st.emplace(f, l-1, c);
  }
  st.emplace(l, l, c+1);
  st.emplace(l+1, last, 1);
  return true;
}

bool ok(int th, const vecint& v) {
  stack<tuple<int,int,int>> st;
  st.emplace(0, 0, 0);
  int n = v.size();
  REP(i,n) {
    int sf, sl, sc;
    tie(sf, sl, sc) = st.top();
    if (v[i] > sl) {
      st.emplace(sl+1, v[i], 1);
    } else {
      while (sf > v[i]) {
        st.pop();
        tie(sf, sl, sc) = st.top();
      }
      st.pop();
      if (v[i] > sf) {
        st.emplace(sf, v[i]-1, sc);
      }
      st.emplace(v[i], v[i], sc+1);
      if (!carry(th, st)) return false;
    }
  }
  while (!st.empty()) {
    int f, l, c;
    tie(f, l, c) = st.top();
    st.pop();
    if (f == 0 && c > 0) return false;
  }
  return true; 
}

int main()
{
  int n;
  cin>>n;
  vecint v(n);
  REP(i,n) cin>>v[i];
  int ge = 1 << 20;
  int lt = 0;
  while (ge - lt > 1) {
    int mid = (ge + lt) / 2;
    if (ok(mid, v)) {
      ge = mid;
    } else {
      lt = mid;
    }
  }
  cout << ge << endl;
  return 0;
}


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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

const int MOD = int(1e9) + 7;

int mpow(int x, int y) {
    int t = 1;
    for (; y > 0; y >>= 1) {
        if (y & 1) t = (1LL * t * x) % MOD;
        x = (1LL * x * x) % MOD;
    }
    return t;
}

int fact[1 << 17];

int main() {
    fact[0] = 1;
    for (int i = 1; i < (1 << 17); ++i)
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    int n, m;
    cin >> n >> m;
    unordered_map<int, int > divs;
    for (int t = 2; t * t <= m; ++t) if (m % t == 0) {
        int c = 0;
        while (m % t == 0) {m /= t; ++c;}
        divs[t] = c;
    }
    if (m > 1) divs[m] = 1;

    int ans = 1;
    for (auto p : divs) {
        ans = 1LL * ans * fact[n + p.second - 1] % MOD * mpow(fact[n - 1], MOD - 2) % MOD * mpow(fact[p.second], MOD - 2) % MOD;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 768
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    String u = sc.next();
    
    if (u.equals(s) == true){
      a = a-1;
    }
    else {
      b = b-1;
    }
    System.out.println(a + " " + b);
  }
}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll a[MAX];



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


  cin >> n;
  rep(i, n) cin >> a[i];
  bool ok = false;
  rep(i, n) FOR(j, i, n) {
    swap(a[i], a[j]);
    bool b = true;
    FOR(k, 1, n) {
      if (a[k] <= a[k - 1]) b = false;
    }
    swap(a[i], a[j]);
    if (b) ok = true;
  }
  if (ok) cout << "YES" << endl;
  else cout << "NO" << endl;



  return 0;
}


Measured memory_bytes: 256
//k_tourist
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 3005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define sp(a) setprecision(a)
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
using namespace __gnu_pbds;  

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set;
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void flag(ll fl){

	if(fl)
	cout<<"NO";
	else
	cout<<"YES";
}

ll n, m, dp[mx][mx];
string s, t;

ll lcs(ll x, ll y){

	if(x == n || y== m)
	return 0;

	if(dp[x][y] != -1)
	return dp[x][y];

	if(s[x] == t[y])
	return dp[x][y] = 1 + lcs(x+1, y+1);

	return dp[x][y]= max(lcs(x+1, y), lcs(x, y+1));
}

string an;

void backtrack(ll x, ll y){

	if(x == n || y== m)
	return;

	if(s[x] == t[y])
	{
		an.pb(s[x]);
		backtrack(x+1, y+1);
		return;
	}

	if(dp[x+1][y] > dp[x][y+1])
	backtrack(x+1, y);
	else
	{
		backtrack(x, y+1);
	}
	


}
void bta_de_yarr(){

	ll  i, j, fl=0, ans;

	cin>>s>>t;

	n= s.size();
	m= t.size();

	rep(i, 0, n+1)
	rep(j, 0, m+1)
	dp[i][j]= -1;

	ans= lcs(0, 0);

	// string an;
	backtrack(0, 0);
	cout<<an;

	// cout<<ans;
	// flag(fl);
	cout<<endl;
}

int main(){
    fst

	// freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll D;
    cin >> D; //=365
    vec c(26);
    loop(i, 26) cin >> c[i];
    vector<vector<ll>> s(D, vector<ll>(26));
    loop(i, D)
    {
        loop(j, 26) cin >> s[i][j];
    }
    loop(i, D)
    {
        ll nowans = -10000000;
        ll ans = 1;
        loop(j, 26)
        {
            if (s[i][j] > nowans)
                ans = j + 1;
            nowans = max(nowans, s[i][j]);
        }
        putout(ans);
    }
    return 0;
}

Measured memory_bytes: 3720
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long ll;

int main(){
    ll n,a,ans[200001]={};
    scanf("%lld",&n);
    for(int i=1;i<n;i++) {scanf("%lld",&a);ans[a]++;};
    for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
    
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll M=1e9+7;
 
 
int main() {
	
	ll r;cin>>r;
	float pi=22/7.0;
	pi=2*pi*r;
	cout<<pi;
 
	
	return 0;
} 

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N, M; cin >> N >> M;
	vector<int> cnt (N);
	vector<bool> ac (N);
	int fail = 0;
	int success = 0;
	for(int i = 0; i < M; i++){
		int p; string s; cin >> p >> s;
		p--;
		if(ac[p]) continue;
		if(s == "AC"){
			ac[p] = true;
			fail += cnt[p];
			success++;
		}else{
			cnt[p]++;
		}
	}
	cout << success << " " << fail << endl;
}


Measured memory_bytes: 640
import sys

N = int(input())
A = list(map(int, input().split()))

ans = 1
for i in range(N):
    if A[i] == 0:
        print(0)
        sys.exit(0)

for i in range(N):
    ans *= A[i]
    if ans > 1000000000000000000:
        print(-1)
        sys.exit(0)
print(ans)


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

int main(){
	int n;cin>>n;
	vector<int> a(100001, 0);
	while(n--){
		int l, r; cin>>l>>r;
		for(int i = l; i <= r; i++){
			a[i] = 1;
		}
	}	
	int res = 0;
	for(int i = 1; i <= 100000; i++){
		if(a[i] == 1){
			res++;
		}
	}
	cout<<res<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+5;
const int p=1e9+7;
int a[N],n;
int pow(int k,int t,int p)
{
	int ret=1;
	while(t){
		if(t&1)ret=1ll*ret*k%p;
		k=k*k%p;
		t>>=1;
	}
	return ret;
}
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%lld",&x);
		a[x]++;
	}
	int k=0;
	if(n%2==0){
		for(int j=1;j<n;j+=2)
			if(a[j]==2)k++;
			else{
				puts("0");
				return 0;
			}
		printf("%lld",pow(2,k,p));	
	}
	else {
		for(int j=2;j<n;j+=2)
			if(a[j]==2)k++;
			else{
				puts("0");
				return 0; 
			}
		printf("%lld",pow(2,k,p));
	}
	return 0;
}

Measured memory_bytes: 1024