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

using namespace std;
using i64 = long long;
using f64 = double;

#define FOR(i, s, n) for (size_t i = (s); i < (size_t)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

template <typename T, typename U>
inline bool chmax(T &a, U b) {
  return a < b ? (a = b, true) : false;
}

template <typename T, typename U>
inline bool chmin(T &a, U b) {
  return a > b ? (a = b, true) : false;
}

int calc(int n) {
  auto count = 0;

  FOR (a, 1, n) {
    if (a * a >= n) {
      return count;
    }
    FOR (b, a, n) {
      auto ab = a * b;
      if (ab < n) {
        if (a == b) {
          count += 1;
        } else {
          count += 2;
        }
      }
    }
  }

  return count;
}

int main() {
  int n;
  cin >> n;
  cout << calc(n);
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	ll sum = 0 ;
	vll a(n) ;
	for(int i=0;i<n;i++){
		cin >> a.at(i) ;
		sum += a.at(i) ;
	}
	mysort(a) ;
	myrev(a) ;
	yorn(a.at(m-1)>=((double)sum/(double)(4*m))) ;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			int h = Integer.parseInt(std.next());
			int w = Integer.parseInt(std.next());
			if(h!=0 && w!=0){
				String line = "";
				for(int m=1; m<=w/2+1; m++){
					line += "#.";
				}
				for(int n=1; n<=h; n++){
					if(n%2==1){
						System.out.println(line.substring(0, w));
					}else{
						System.out.println(line.substring(1, w+1));
					}
				}
				System.out.println();
			}else break;
		}
	}
}

Measured memory_bytes: 27228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    int cnt = 0;
    for(int i=1; i<= 55555; i++){
        if(isPrime(i) && i%5==1){
            cout<<i<<" ";
            cnt++;
        } 
        if(cnt==n) break;
    }
    cout<<endl;
    return 0;
}
// abc096_d

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define fastAF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define int ll
#define ull unsigned ll
#define ld long double
#define pb push_back
#define pf push_front
#define dll deque<ll>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mapll map<ll,ll>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;
void swap(auto*,auto*);
const ll p=1e9+7;
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fastAF
    ll n; cin>>n; ll a[n]; for(ll i=0;i<n;i++) cin>>a[i];
    ll pre[n+1]; pre[0]=0; for(ll i=0;i<n;i++) pre[i+1]=(pre[i]+a[i])%p;
    ll ans=0;
    for(ll i=n-1;i>=0;i--)
    {
    	ans=(ans+(a[i]*pre[i])%p)%p;
    }
    cout<<ans<<endl;
    return 0;
}
void swap(auto &a,auto &b)
{
    auto temp=a; a=b; b=temp;
}

Measured memory_bytes: 6740
#include <stdio.h>

int main() {

  int n,i,s,e,j;

    while(1) {

      scanf("%d",&n);
      if(n==0) break;

      for(i=0;i<n;i++) {

	scanf("%d %d %d",&s,&e,&j);

	if(s == 100 || e == 100 || j == 100) printf("A\n");
	else if((s+e)/2 >= 90) printf("A\n");
	else if((s+e+j)/3 >=80) printf("A\n");
	else if((s+e+j)/3 >= 70) printf("B\n"); 
	else if((s+e+j)/3 >=50 && s >= 80 || e >= 80) printf("B\n");
	else printf("C\n");

      }

    }

    return 0;

}

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

using namespace std;

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

ll N,M;
vv_ll S;
v_ll K,P,O,L;

int main(){
  cin >> N >> M;
  S.assign(M+10,v_ll());
  K.assign(M+10,0);
  P.assign(M+10,0);
  O.assign(N+10,0);
  L.assign(N+10,0);
  for (ll i=1;i<=M;i++){
    cin >> K[i];
    S[i].assign(N+10,0);
    for (ll j=1;j<=K[i];j++){
      ll s;
      cin >> s;
      S[i][s]=1;
    }
  }
  for (ll i=1;i<=M;i++){
    cin >> P[i];
  }
  /*
  for (ll j=1;j<=M;j++){
    for (ll k=1;k<=N;k++){
      cout << S[j][k] << " ";
    }
    cout << endl;
  }
  */
  ll ans=0;
  for (ll i=0;i<(1<<N);i++){
    ll x=i;
    bool ok=true;
    for (ll j=1;j<=N;j++){
      O[j]=x%2;
      x/=2;
      //cout << O[j] << " ";
    }
    //cout << "hoge" << endl;
    for (ll j=1;j<=M;j++){
      ll p=0;
      for (ll k=1;k<=N;k++){
        if (O[k]==1&&S[j][k]==1)p++;
      }
      if (p%2!=P[j])ok=false;
    }
    if (ok)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
"use strict";
function Main(input) {
    let n = input.split("\n")[0].split("").map((v) => v - 0).map(
        function(v) {
            switch (v) {
            case 1: return 9;
            case 9: return 1;
            default: return v;
            }
        }        
    );
    let ans = n.join("");
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		// int t = reader.ni();
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	private void run_case() {
		// int n = reader.ni();
		String str = reader.ns();
		if (str.contains("7")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 32672
#include <iostream>

using namespace std;

int main(){
  int a,b,m;
  bool f;
  while(cin>>a>>b){
    f=true;
    m=0;
    int x[101]={0};
    ++x[a];++x[b];
    if(a>m||b>m) m=(a>b)?a:b;
    while(1){
      cin>>a>>b;
      if(a==0&&b==0) break;
      ++x[a];++x[b];
      if(a>m||b>m) m=(a>b)?a:b;   
    }
    for(int i=1;i<=m;++i){
      if(i<3&&x[i]%2==0){
	cout<<"NG"<<endl;f=false;break;
      }
      else if(i>2&&x[i]%2==1){
	cout<<"NG"<<endl;f=false;break;
      }
    }
    if(f) cout<<"OK"<<endl;
  }
  return 0;
}

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

using namespace std;
const int nn = 2e5 + 5;
long long arr[nn], gcd_l[nn], gcd_r[nn];

int main() {
	int n;
	scanf("%d", & n);
	for (int i = 0; i < n; i++) {
		scanf("%d", & arr[i]);
	}
	long long fpb = 0;
	for (int i = 0; i < n; i++) {
		fpb = __gcd(fpb, arr[i]);
		gcd_l[i] = fpb;
	}
	fpb = 0;
	for (int i = n - 1; i >= 0; i--) {
		fpb = __gcd(fpb, arr[i]);
		gcd_r[i] = fpb;
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		long long tmp = 0;
		if (i > 0) tmp = __gcd(tmp, gcd_l[i - 1]);
		if (i < n - 1) tmp = __gcd(tmp, gcd_r[i + 1]);
		ans = max(ans, tmp);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	
	long long l = 0, r = 3000000000;
	while (r - l > 1) {
		long long m = (l + r) / 2;
		if (m * m <= 4 * a * b)
			l = m;
		else
			r = m;
	}
	
	cout << (c - a - b >= r ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
// AtCoder ABC137: B - One Clue
// 2019.8.26 bal4u

#include <stdio.h>
 
int main()
{
	int x, K, X;
	
	scanf("%d%d", &K, &X);
	x = X-K+1;
	printf("%d", x++);
	K = 2*(K-1);
	while (K--) printf(" %d", x++);
	printf("\n");
	return 0;
}

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

int M,W;
int bm[12],bw[12];

int gt(int m,int w){
	int sa=abs(bm[m]-bw[w]);
	int tmp=sa-30;
	return sa*tmp*tmp;
}

int memo[12][1<<12];
int solve(int m,int w,int wn){
	if(m<0){return 0;}
	if(m+1 < wn){return 0;}
	if(memo[m][w]!=-1){return memo[m][w];}

	int ans=solve(m-1,w,wn);
	for(int i=0;i<W;i++){
		if(w & (1<<i)){
			ans=max(ans,solve(m-1,w-(1<<i),wn-1)+gt(m,i));
		}
	}

	memo[m][w]=ans;
	return ans;
}

int main(){
	while(cin>>M>>W,M){
		int i,j;
		for(i=0;i<M;i++){
			cin>>bm[i];
			for(j=0;j<(1<<W);j++){
				memo[i][j]=-1;
			}
		}
		for(i=0;i<W;i++){
			cin>>bw[i];
		}

		int ans=0;
		for(i=0;i<(1<<W);i++){
			int cnt=0;
			for(j=0;j<W;j++){
				if(i & (1<<j)){cnt++;}
			}
			ans=max(ans,solve(M-1,i,cnt));
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main(){
  int a,N,total;
  total = 1;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin >> a;
    v[i] = a;
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(int i=0;i<N-1;i++){
    if(v[i] != v[i+1]){
      total++;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>

int main() {
  int N,Q;
  cin >> N >> Q;

  string S;
  cin >> S;

  vector<int> Ci(N);

  int ACcnt = 0;
  Ci.at(0) = ACcnt;
  rep2(i,1,N){
    if((S.at(i-1) == 'A') && (S.at(i) == 'C')) ACcnt++;
    Ci.at(i) = ACcnt;
  }

   rep(i,Q){
    int lQ,rQ;
    cin >> lQ >> rQ;
    cout << Ci.at(rQ-1) - Ci.at(lQ-1) << endl;
  }

  return 0;
}

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

int main()
{
  int n,k;
  cin>>n>>k;
  
  vector<int64_t> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(int i=0;i<min(n,k);i++)
  {
    a.at(i)=0;
  }
  int64_t sum=0;
  for(int i=0;i<n;i++)
  {
    sum+=a.at(i);
  }
  cout<<sum<<endl;
  
  
}

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

int main() {
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    ll ans = 5;
    ll mincap = min(min(min(A, B), min(C, D)), E);
    ans += N / mincap - 1;
    if (N % mincap != 0) ++ans;
    cout << ans << endl;
}


Measured memory_bytes: 3600
// 6/13
// 3-2-3. 反転
// 類題
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
    string s;
    cin >> s;
    int N = s.size();

    vector<int> S(N);
    rep(i, N) S[i] = s[i] - '0';

    int res = N;

    for (int i = 0; i < N - 1; i++) {
        if (S[i] != S[i + 1]) {
            int k = max(i + 1, N - i - 1);
            res = min(res, k);
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[])
{
    std::string s, t;

    std::cin >> s;
    std::cin >> t;

    int ans = 0;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t[i]) {ans++;}
    }
    
    std::cout << ans << std::endl;

    return 0;
}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
//const int dc[4] = {1, -1, 0,  0};
//const int dr[4] = {0,  0, 1, -1};
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    v_int p(a), q(b), r(c);

    cin >> p >> q >> r;

    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());

    irep(i, x) { r.push_back(p[i]); }
    irep(i, y) { r.push_back(q[i]); }
    
    sort(r.rbegin(), r.rend());

    ll ans = 0;
    irep(i, x+y) {
        ans += r[i];
    }
    cout << ans << endl;
    return 0;
}

/*atcoder*/


Measured memory_bytes: 5548
// finish date: 2019/06/29

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 998244353;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    string S;
    cin >> S;
    int N = S.length();
    vi vec(26, 0);
    rep(i, N) {
        vec[S[i] - 'A']++;
    }
    rep(i, 26) {
        if (vec[i] != 0 && vec[i] != 2) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

using namespace std;

char s[15], t[15];

int main() {
	scanf("%s%s", s, t);
	
	int l = strlen(s);
	int l1 = strlen(t);
	
	if (l1 == l + 1) {
		bool same = 1;
		for (int i = 0; i < l; i++) {
			if (s[i] != t[i]) same = 0;
		}
		if (same) return 0 * printf("Yes\n");
	}
	
	printf("No\n");
}


Measured memory_bytes: 3720
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    a,b,m = map(int, input().split())
    As = list(map(int, input().split()))
    Bs = list(map(int, input().split()))
    xycs = [list(map(int, input().split())) for i in range(m)]

    #min(min(As) + min(Bs), nin)
    nin = 10**9
    for i in range(m):
        if As[xycs[i][0]-1] + Bs[xycs[i][1]-1] - xycs[i][2] <= nin:
            nin = As[xycs[i][0]-1] + Bs[xycs[i][1]-1] - xycs[i][2]
    
    print(min(min(As) + min(Bs), nin))
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 40496
N, T = map(int, input().split())

answer = 1001
c_list = [] 

for i in range(N):
	c_i, t_i = map(int, input().split())
	if T >= t_i:
		if answer > c_i:
			answer = c_i

if answer >= 1001:
	print('TLE')
else:
	print(answer)

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

using namespace std;

const int maxn = 1e5 + 42;
int mx[maxn];
vector<int> g[maxn];

void dfs(int v = 0, int p = 0)
{
    set<int> lol;
    int c = 0;
    for(auto u: g[v])
    {
        if(u == p)
            continue;
        dfs(u, v);
        c++;
        mx[v] ^= 1 + mx[u];
    }
    //if(c == 1)
    //    mx[v] = 1;
}

signed main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        g[u - 1].push_back(v - 1);
        g[v - 1].push_back(u - 1);
    }
    dfs();
    cout << (mx[0] == 0 ? "Bob" : "Alice") << endl;
}


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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    if (s[n-1] == 's') s.append("es");
    else s.append("s");
    cout << s << endl;
    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  int ans = 1;
  
  rep(i, N) if(A[i]%2 == 0) ans *= 2;
  ans = pow(3, N) - ans;
  cout << ans << endl;
  
}

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

string s;
int n;

int main()
{
    cin >> s;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        if (s[i] != '1')
        {
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class AtCoderD
{
    static void Main()
    {
        int n;
        int a;
        int b;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            a = int.Parse(words[1]);
            b = int.Parse(words[2]);
        }

        int mod = 1000000007;
        long total = Pow(2, n, mod);
        long ca = Combination(n, a, mod);
        long cb = Combination(n, b, mod);
        long answer = total - ca - cb - 1;

        answer += mod * 2;
        answer = answer % mod;

        Console.WriteLine(answer);
    }

    // Comnibation（mod版）
    private static long Combination(int n, int k, int d)
    {
        long answer = 1;
        for (int i = n; i > n - k; i--)
        {
            answer = Mul(answer, i, d);
        }
        for (int i = 1; i <= k; i++)
        {
            answer = Div(answer, i, d);
        }
        return answer;
    }

    // 掛け算（mod版）
    private static long Mul(long a, long b, long c)
    {
        return ((a % c) * (b % c)) % c;
    }

    // 割り算（mod版）
    private static long Div(long a, long b, long c)
    {
        return Mul(a, Pow(b, c - 2, c), c);
    }

    // べき乗（mod版）
    private static long Pow(long a, long b, long c)
    {
        if (b == 0)
        {
            return 1;
        }
        else if (b == 1)
        {
            return a % c;
        }
        else if (b % 2 == 0)
        {
            long d = Pow(a, b / 2, c);
            return d * d % c;
        }
        else
        {
            return a * Pow(a, b - 1, c) % c;
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>

int bubbleSort(int *a, int n){
    int i = 0;
    int tmp, c;
    int flag = 1;
    while(flag){
        flag = 0;
        for(int j=n-1;j>i;j--){
            if(a[j]<a[j-1]){
                tmp = a[j];
                a[j] = a[j-1];
                a[j-1] = tmp;
                flag = 1;
                c++;
            }
        }
        i++;
    }
    return c;
}

int main(){
    int i, n, count;
    scanf("%d",&n);
    int *a = new int [n];
    for(i=0;i<n;i++)scanf("%d",a+i);

    count = bubbleSort(a, n);

    for(i=0;i<n;i++){
        if(i>0)printf(" ");
        printf("%d",a[i]);
    }
    printf("\n%d\n",count);

    return 0;
}



Measured memory_bytes: 2716
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    vector<string>vec;
    for(int i=0; i+t.size()<=s.size();i++)
    {
        bool m=0;
        for(int j=0,k=i; j<t.size(); j++,k++)
        {
            if(s[k]==t[j]||s[k]=='?')
                m=1;
            else
            {
                m=0;
                break;
            }

        }
        if(m)
        {
            string str=s;
            for(int j=0,k=i; j<t.size(); j++,k++)
            {
                str[k]=t[j];
            }
            for(int j=0;j<str.size();j++)
            {
                if(str[j]=='?')str[j]='a';
            }
            vec.push_back(str);
        }
    }
    sort(vec.begin(),vec.end());
    if(vec.size()==0)
        cout<<"UNRESTORABLE\n";
    else
        cout<<vec[0]<<"\n";
}


Measured memory_bytes: 256
while(<>){
	chomp;
	next if($. == 1);
	$s = $_ if($. == 2);
}

$cnt = 0;
for $i (0 .. 999){
	$i = sprintf("%03d", $i);
	$pos= 0;
	$f = 0;
	for $one (split(//, $i)){
		$r = index($s, $one, $pos);
		if($r == -1){
			last;
		}else{
			$pos = $r + 1;
			$f++;
		}
	}
	$cnt++ if($f == 3);
}

print "$cnt\n";


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <set>
#include <algorithm>

#define ALL(T) T.begin(), T.end()
using namespace std;

int main(void){
    int n; cin >> n;

    while(n --){
        set<string> found;
        string line; cin >> line;
        
        for(int i = 1; i < line.length(); i ++){
            string rFrontLine = line.substr(0, i);
            string rBackLine = line.substr(i, line.length() - i);
        
            string frontLine = rFrontLine;
            string backLine = rBackLine;

            reverse(ALL(rFrontLine));
            reverse(ALL(rBackLine));

            found.insert(frontLine + backLine);
            found.insert(rFrontLine + backLine);
            found.insert(frontLine + rBackLine);
            found.insert(rFrontLine + rBackLine);
            found.insert(backLine + frontLine);
            found.insert(rBackLine + frontLine);
            found.insert(backLine + rFrontLine);
            found.insert(rBackLine + rFrontLine);
        }

        cout << found.size() << endl;
    }
}

Measured memory_bytes: 1292
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    c = input()
    print(chr(ord(c)+1))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
use std::io::{self, BufRead};
use std::mem::swap;

const M: usize = 1000000007;

fn lower_bound<T: Ord>(vec: &[T], val: T) -> usize {
  let mut lo = 0;
  let mut hi = vec.len();
  while hi - lo > 0 {
    let p = (hi + lo) / 2;
    if vec[p] < val {
      lo = p + 1;
    } else {
      hi = p;
    }
  }
  return lo;
}

fn create_div_floor(n: usize) -> Vec<usize> {
  let mut divfloor: Vec<usize> = Vec::new();
  let mut i: usize = 1;
  while i * i <= n {
    divfloor.push(i);
    i += 1;
  }
  let j = divfloor.len();
  for i in (0..j) {
    let k = n / divfloor[j-i-1];
    if *(divfloor.last().unwrap()) != k {
      divfloor.push(k);
    }
  }
  divfloor
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let (n, k) = (xs[0], xs[1]);
  let df = create_div_floor(n);
  let mut counts = df.clone();
  for l in 0..(k-1) {
    let mut temp = vec![0; df.len()];
    temp[0] = counts[df.len()-1];
    for i in 1..df.len() {
      let j = df.len() - i - 1;
      let k = df[i] - df[i-1];
      temp[i] = (temp[i-1] + (k * counts[j] % M)) % M;
    }
    swap(&mut counts, &mut temp);
  }
  println!("{}", counts[df.len()-1]);
}

Measured memory_bytes: 7808
import math
import sys
import numpy
import decimal

a, b, h, m = map(int, input().split())

sita = abs((h / 12 * 360+m/60*30) - (m / 60 * 360))

if (sita > 180):
    sita = 360-sita

ans = numpy.sqrt((a * a) + (b * b) - (2 * a * b*math.cos(math.radians(sita))))
print(decimal.Decimal(ans))


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

int main() {
    vector<int> num(3);
    for (int i = 0; i < 3; i++) {
        cin >> num[i];
    }
    sort(num.begin(), num.end());
    cout << num[2] * 10 + num[0] + num[1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long int
#define hmap        unordered_map
#define pii         pair<int,int>
#define pdd         pair<double, double> 
#define M           1000000007
#define MOD         998244353
#define fast        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test        ll t; cin>>t; while(t--)
#define inp(a,n)    int a[n]; for(int i=0;i<n;i++)  cin>>a[i];
#define inpl(a,n)   ll a[n];  for(ll i=0;i<n;i++)   cin>>a[i];
#define out(a,n)    for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define outl(a,n)   for(ll i=0;i<n;i++)  cout<<a[i]<<" "; cout<<endl;
#define outv(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";  cout<<endl;
#define all(s)      (s).begin(),(s).end()

struct pair_hash {
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1,T2> &p) const {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};
using vote = pair<ll,ll>;
using Unordered_map = unordered_map<vote, ll, pair_hash>;

int main()
{
      fast
      int n,k;
      cin>>n>>k;
      inp(a,n)
      int dp[n]={};
      
      dp[0]= 0;
      for(int i=1;i<min(n,k);i++)
      {
            dp[i]=INT_MAX;
            for(int j=i-1;j>=0;j--)
                  dp[i] = min(dp[i],dp[j]+abs(a[j]-a[i]));
      }

      for(int i=k;i<n;i++)
      {
            dp[i]=INT_MAX;
            for(int j=i-1;j>=i-k;j--)
                  dp[i] = min(dp[i],dp[j]+abs(a[j]-a[i]));
      }
      cout<<dp[n-1];      
      
      
      
      
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

signed main() {
    int s[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    SS(int,k);
    p(s[k-1]);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	string s;
	cin >> s;
	vector<int> a(s.size());
	vector<int> b(s.size());
	int tmp = 0;
	for (int i = 0; i < (int)s.size(); ++i) {
		a[i] = tmp;
		if (tmp)
			tmp = 0;
		else
			tmp = 1;
		b[i] = tmp;
	}


	int ans1 = 0;
	int ans2 = 0;
	for (int i = 0; i < (int)s.size(); ++i) {
		if (a[i] == 0 && s[i] == '1')
			ans1++;
		if (a[i] == 1 && s[i] == '0')
			ans1++;
		if (b[i] == 0 && s[i] == '1')
			ans2++;
		if (b[i] == 1 && s[i] == '0')
			ans2++;
		
	}
	cout << min(ans1, ans2) << endl;
}



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

int main(){
    string s;
    int zeros = 0, ones = 0;
    cin >> s;

    for(int i = 0; i < s.length(); i++){
        if(s[i] == '0'){
            zeros++;
        }else{
            ones++;
        }
    }

    cout << 2 * min(zeros, ones) << endl;
}


Measured memory_bytes: 512
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    from bisect import bisect_left
    input = sys.stdin.buffer.readline

    N = int(input())
    A = list(map(int, input().split()))
    adj = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    que = deque()
    que.append(1)
    seen = [0] * (N+1)
    seen[1] = 1
    ans = [0] * (N+1)
    ans[1] = 1
    LIS = []
    change = [[] for _ in range(N+1)]
    while que:
        v = que.pop()
        if v > 0:
            que.append(-v)
            a = A[v-1]
            if not LIS:
                LIS.append(a)
                change[v] = (0, -1)
            else:
                j = bisect_left(LIS, a)
                if j == len(LIS):
                    LIS.append(a)
                    ans[v] = len(LIS)
                    change[v] = (len(LIS) - 1, -1)
                else:
                    change[v] = (j, LIS[j])
                    LIS[j] = a
                    ans[v] = len(LIS)
            for u in adj[v]:
                if seen[u] == 0:
                    seen[u] = 1
                    que.append(u)
        else:
            v = -v
            i, x = change[v]
            if x == -1:
                LIS.pop()
            else:
                LIS[i] = x
    for i in range(1, N+1):
        print(ans[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 135852
n, a, b = map(int, input().split())
H = [int(input()) for _ in range(n)]

def is_ok(x):
    cnt = 0
    for i in range(n):
        h  = H[i]
        if h <= x*b:
            continue
        else:
            h -= x*b
            cnt += (h+(a-b-1))//(a-b)
    if cnt <= x:
        return True
    else:
        return False

l = 0
r = 19**18
while l+1 < r:
    c = (l+r)//2
    if is_ok(c):
        r = c
    else:
        l = c
print(r)


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

using namespace std;

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef pair<int, int> P;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define PB push_back
#define LL long long

int main()
{
	string str;
	while(cin >> str)
	{
		for(int i = 0; i < str.size(); i++)
			printf("x");
		printf("\n");
	}
	return 0;
}

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

using namespace std;

const uint64_t B = 103, H = 1e+17+3;

inline uint64_t ctoi(char c) { return c - 'a' + 1; }

uint64_t to_hash(const string &s)
{
  uint64_t _hash = 0;
  for (uint64_t i = 0; i < s.size(); ++i) {
    _hash = (_hash * B) % H;
    _hash = (_hash + ctoi(s[i])) % H;
  }
  return _hash;
}

inline uint64_t build_mask(uint64_t L) {
  uint64_t mask = 1;
  for (uint64_t i = 0; i < L - 1; ++i) {
    mask = (mask * B) % H;
  }
  return mask;
}

inline uint64_t change_hash(uint64_t _hash, uint64_t mask, char c1, char c2)
{
  uint64_t x = (ctoi(c1) * mask) % H;
  _hash = ((_hash + H) - x) % H;
  _hash = (_hash * B) % H;
  _hash = (_hash + ctoi(c2)) % H;
  return _hash;
}

inline bool is_not_overlap(uint64_t lb1, uint64_t ub1, uint64_t lb2, uint64_t ub2)
{
  return (ub2 <= lb1) || (ub1 <= lb2);
}

bool find(uint64_t N, const string &S, uint64_t L)
{
  uint64_t mask = build_mask(L);
  
  uint64_t hash = to_hash(S.substr(0, L));
  
  map<uint64_t, set<uint64_t>> m;
  m[hash].insert(0);
  
  for (uint64_t i = 1; i <= S.size() - L; ++i) {
    hash = change_hash(hash, mask, S[i - 1], S[i + L - 1]);
    
    if (m[hash].size() > 0) {
      for (uint64_t j : m[hash]) {
        if (is_not_overlap(i, i + L, j, j + L)) {
          return true;
        }
      }
    }
    
    m[hash].insert(i);
  }
  
  return false;
}

int main()
{
  uint64_t N;
  cin >> N;
  
  string S;
  cin >> S;
  
  uint64_t hi = N, lo = 0;
  
  while (hi - lo > 1) {
    uint64_t L = (hi + lo) >> 1;
    if (find(N, S, L)) {
      lo = L;
    } else {
      hi = L;
    }
  }
  
  if (find(N, S, hi)) {
    cout << hi << endl;
  } else {
    cout << lo << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1012
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

int N;

int calc(int n)
{
	if (n <= 1) return 0;
	if (n <= 2) return 1;
	switch(n%3) {
	case 0: return 1+calc(n/3);
	case 1: return 1+calc((n+2)/3);
	case 2: return 1+calc((n+1)/3);
	}
}

int main(void)
{
	cin >> N;
	cout << calc(N) << endl;
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> as;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        as.emplace_back(a, b);
    }
    sort(as.begin(), as.end());
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (as[i].second >= m) {
            ans += 1ll * as[i].first * m;
            break;
        } else {
            ans += 1ll * as[i].first * as[i].second;
            m -= as[i].second;
        }
    }
    cout << ans << endl;
}

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

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

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

    ll r,D,x; cin >> r >> D >> x;

    for (int i = 0;i < 10;i++){
        x = x*r-D;
        cout << x << endl;
    }

    return 0;

}

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 3e3 + 10, mod = 998244353;

int add(int a, int b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

int sub(int a, int b) {
	a -= b;
	if (a < 0) a += mod;
	return a;
}

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

int pwr(int x, int e) {
	int res = 1;
	while (e) {
		if (e & 1) {
			res = mul(res, x);
		}
		x = mul(x, x);
		e /= 2;
	}
	return res;
}

int divd(int a, int b) {
	return mul(a, pwr(b, mod - 2));
}

int dp[N][N], f[N][N], g[N][N];

int main() {
	fast_cin();
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for (int i = a; i <= c; ++i) {
		for (int j = b; j <= d; ++j) {
			if (i == a and j == b) {
				dp[i][j] = 1;
			} else if (i == a) {
				dp[i][j] = pwr(a, j - b);
			} else if (j == b) {
				dp[i][j] = pwr(b, i - a);
			} else {
				dp[i][j] = mul(mul(i - 1, j - 1), dp[i - 1][j - 1]);
				dp[i][j] = add(dp[i][j], f[i][j]);
				dp[i][j] = add(dp[i][j], g[i][j]);
			}
			f[i + 1][j + 1] = add(mul(j + 1, f[i][j + 1]), mul(i, dp[i][j]));
			g[i + 1][j + 1] = add(mul(i + 1, g[i + 1][j]), mul(j, dp[i][j]));
		}
	}
	cout << dp[c][d] << endl;
}

Measured memory_bytes: 109412
Lmin=[]
for i in range(5):
    Lmin.append(int(input()))
m=10
ans=0
for j in Lmin:
    ans+=(j//10)*10
    if j%10!=0:
        ans+=10
        if j%10<m:
            m=j%10
ans=ans-10+m
print(ans)

Measured memory_bytes: 3064
flag=[0 for i in range(64)]

def Test(flag,i):
    print(flag[i])

def Set(flag,m):
    for i in m:
        flag[i]=1
    return flag

def Clear(flag,m):
    for i in m:
        flag[i]=0
    return flag

def Flip(flag,m):
    for i in m:
        if flag[i]==0:
            flag[i]=1
        else:
            flag[i]=0
    return flag

def All(flag,m):
    judge=[flag[i] for i in m]
    if all(judge)==True:
        print(1)
    else:
        print(0)

def Any(flag,m):
    judge=[flag[i] for i in m]
    if any(judge)==True:
        print(1)
    else:
        print(0)

def none(flag,m):
    judge=[flag[i] for i in m]
    if not any(judge)==True:
        print(1)
    else:
        print(0)

def Count(flag,m):
    judge=[flag[i] for i in m]
    print(judge.count(1))

def Val(flag,m):
    a=0
    for i in m:
        a+=flag[i]*2**i
    print(a)

n=int(input())
mask=[]
for i in range(n):
    m=list(map(int,input().split()))
    mask.append(m[1:])

q=int(input())
for i in range(q):
    query=list(map(int,input().split()))
    if query[0]==0:
        Test(flag,query[1])
    elif query[0]==1:
        flag=Set(flag,mask[query[1]])
    elif query[0]==2:
        flag=Clear(flag,mask[query[1]])
    elif query[0]==3:
        flag=Flip(flag,mask[query[1]])
    elif query[0]==4:
        All(flag,mask[query[1]])
    elif query[0]==5:
        Any(flag,mask[query[1]])
    elif query[0]==6:
        none(flag,mask[query[1]])
    elif query[0]==7:
        Count(flag,mask[query[1]])
    else:
        Val(flag,mask[query[1]])


Measured memory_bytes: 5644
#include <stdio.h>

int N;
int x, y, z;

int min(int a, int b) {
    if(a <= b) {
        return a;
    } else {
        return b;
    }
}

int max(int a, int b) {
    if(a >= b) {
        return a;
    } else {
        return b;
    }
}

int main() {
    scanf("%d", &N);

    int a = 0, b = 0, c = 0;
    for(int i = 0; i < N; ++i) {
        scanf("%d %d %d", &x, &y, &z);
        a = min(x, min(y, z));
        c = max(x, max(y, z));
        b = (x + y + z) - (a + c);

        if(a*a + b*b == c*c) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    ll n;
    cin >> n;
    vector<vector<pair<ll, ll>>> g(n + 1);
    ll a[n - 1], b[n - 1], c[n - 1] = {};
    rep(i, n - 1) {
        cin >> a[i] >> b[i];

        g[a[i]].push_back(make_pair(b[i], i));
        g[b[i]].push_back(make_pair(a[i], i));
    }

    ll num = 0;
    rep(i, n + 1) {
        ll size = g[i].size();
        num = max(num, size);
    }

    queue<ll> q;
    q.push(1);

    ll from[n + 1] = {};
    ll e_from[n + 1] = {};

    while (!q.empty()) {
        ll now = q.front();
        q.pop();

        ll e_last = 0;
        rep(i, g[now].size()) {
            ll next = g[now][i].first;
            if (next == from[now]) {
                continue;
            } else {
                q.push(next);
                from[next] = now;

                ll e_number = g[now][i].second;
                e_last++;
                if (e_last == e_from[now]) {
                    e_last++;
                }

                e_from[next] = e_last;
                c[e_number] = e_last;
            }
        }
    }

    cout << num << endl;

    rep(i, n - 1) { cout << c[i] << " " << endl; }

    return 0;
}



Measured memory_bytes: 12032
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let a = input::<i64>();
    let b = input::<i64>();
    println!("{}", (a - 1) * (b - 1));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
struct pat{int x,y;pat(int x=0,int y=0):x(x),y(y){}bool operator<(const pat &p)const{return x==p.x?y<p.y:x<p.x;}};
template<typename TP>inline void read(TP &tar)
{
	TP ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+(ch-'0');ch=getchar();}
	tar=ret*f;
}
template<typename TP,typename... Args>inline void read(TP& t,Args&... args){read(t),read(args...);}
namespace RKK
{
const int N=100011;
int n;
vector<int> mp[N];int col[N];
void link(int x,int y){mp[x].push_back(y),mp[y].push_back(x);}
void paint(int x,int c=1){col[x]=c;for(auto t:mp[x])if(!col[t]) paint(t,-c);}
struct remi
{
	struct sumireko{int to,ne;}e[N];int he[N],ecnt;
	void addline(int f,int t){e[++ecnt].to=t;e[ecnt].ne=he[f],he[f]=ecnt;}
	int rt,fa[N],sonc[N];
	void init()
	{
		for(int i=1;i<=n;i++)
		{
			read(fa[i]);if(!~fa[i]) rt=i,fa[i]=0;
			else addline(fa[i],i),sonc[fa[i]]++;
		}
	}
	int dfs(int x)
	{
		vector<int> ve;
		if(!(sonc[x]&1)) ve.push_back(x);
		for(int i=he[x],t=e[i].to;i;i=e[i].ne,t=e[i].to) ve.push_back(dfs(t));
		sort(ve.begin(),ve.end());for(int i=1;i<ve.size()-1;i+=2) link(ve[i],ve[i+1]);
		return ve[0];
	}
	void work(){dfs(rt);}
}TA,TB;
int main()
{
	#ifdef RDEBUG
	freopen("sample.in","r",stdin);
	#endif
	read(n);TA.init(),TB.init();
	for(int i=1;i<=n;i++)if((TA.sonc[i]^TB.sonc[i])&1) return puts("IMPOSSIBLE"),0;
	puts("POSSIBLE");
	TA.work(),TB.work();
	for(int i=1;i<=n;i++)if(!(TA.sonc[i]&1)&&!col[i]) paint(i);
	for(int i=1;i<=n;i++) printf("%d ",(TA.sonc[i]&1)?(0):(col[i]));putchar('\n');
	return 0;
}
}
int main(){return RKK::main();}

Measured memory_bytes: 17888
#include<stdio.h>
#include<string.h>
#include<stdbool.h>

#define LENTH_MAX 200000

int main(void){

    char s[LENTH_MAX];
    int leftest_a,leftest_z,i;
    bool first_A = true;

    scanf("%s",s);

    for(i = 0;i < strlen(s);i++){
        if(s[i] == 'A' && first_A){
            leftest_a = i;
            first_A = false;
        }else if(s[i] == 'Z'){
            leftest_z = i;
        }
    }

    printf("%d",leftest_z - leftest_a + 1);
    return 0;
}

Measured memory_bytes: 384