akhauriyash/Code-Regression huggingface dataset:
n = int(input())
MOD = 10**9 + 7
# dp[i][x][y][z] 0:A 1:C 2:G 3:T
dp = [[[[0] * 4 for _ in range(4)] for _ in range(4)] for _ in range(n + 1)]
dp[0][3][3][3] = 1
for i in range(n):
    for x in range(4):
        for y in range(4):
            for z in range(4):
                for w in range(4):
                    if x == 0 and z == 2 and w == 1:
                        continue
                    elif y == 0 and z == 2 and w == 1:
                        continue
                    elif y == 2 and z == 0 and w == 1:
                        continue
                    elif y == 0 and z == 1 and w == 2:
                        continue
                    elif x == 0 and y == 2 and w == 1:
                        continue

                    dp[i+1][y][z][w] += dp[i][x][y][z]
                    dp[i+1][y][z][w] %= MOD

ans = 0
for x in range(4):
    for y in range(4):
        for z in range(4):
            ans += dp[n][x][y][z]
            ans %= MOD

print(ans)


Measured memory_bytes: 74860
/* 
    Author : Jeff Ahn
    Sun 14 Jun 2020 01:34:52 PM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const map<T,T> &vec){ os<< "{"; for (auto p : vec) os << "(" << p.first << "," << p.second << "), "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_map<T,T>&vec){ os<< "{"; for (auto p : vec) os << "(" << p.first << "," << p.second << "), "; os << "}"; return os; }


signed main() {
  fastio;
  int x,y;
  cin >> x >> y;
  int b;
  b = y - 2*x;
  if (b < 0 || b % 2) {
    cout << "No" << endl;
    return 0;
  }
  b /= 2;
  if (x - b < 0) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
  
}


Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string ans = "Three";
	int n;
	cin >> n;
	rep(i,n){
		char c;
		cin >> c;
		if (c=='Y') {
			ans = "Four";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def straight?(ncs)
  if ncs[10] == 1 && ncs[11] == 1 && ncs[12] == 1 && ncs[13] == 1 &&
      ncs[1] == 1
    return true
  end

  max_con = 1
  con = 0

  for nc in ncs
    if nc > 0
      con += 1
      if (max_con < con)
        max_con = con
      end
    else
      con = 0
    end
  end

  max_con == 5
end

### main

while (line =gets)
  ncs = (0..13).map{ 0 }
  line.chop.split(",").each{|s| ncs[s.to_i] += 1}

  n4 = ncs.select{|n| n == 4}.length
  n3 = ncs.select{|n| n == 3}.length
  n2 = ncs.select{|n| n == 2}.length
  n1 = ncs.select{|n| n == 1}.length

  hand = "null"

  if n4 == 1
    hand = "four card"
  elsif n3 == 1 && n2 == 1
    hand = "full house"
  elsif n1 == 5 && straight?(ncs)
    hand = "straight"
  elsif n3 == 1
    hand = "three card"
  elsif n2 == 2
    hand = "two pair"
  elsif n2 == 1
    hand = "one pair"
  end

  puts hand
end

Measured memory_bytes: 6116
#include <bits/stdc++.h>
#define eps 1e-6
#define rep(i,n) for(int i=0;i<n;++i)
#define snc(a,b,c) ((a)?(b):(c))
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define ins insert
#define pb push_back
using namespace std; 

int main(){
    int n,d,x,a[100],count=0;
    cin >> n >> d >> x;
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++){
        int j=0;
        while(j*a[i]+1<=d){
            j++;
            ++count;
        }
    }
    cout << count+x << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().strip().split()))
A=[1000000] * (N)

for i in range(N-1):
  if B[i] < A[i]:
    A[i] = B[i]
    A[i+1] = B[i]
  else:
    A[i+1] = B[i]
A_sum=0
for x in A:
  A_sum+=x
print(A_sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()


void solve(){
  ll n, k;cin >> n >> k;
  vector<ll> a(n), f(n);
  FOR(i,0,n) cin >> a[i];
  FOR(i,0,n) cin >> f[i];
  sort(ALL(a));sort(ALL(f));reverse(ALL(f));
  //for(auto x: af) cout << x.first << " " << x.second << endl; cout << endl;
  ll cost = (ll)1 << 45;
  ll cr = cost + 1, cl = -1, cm;
  while(cr-cl>1){
    cm = (cl+cr)/2;
    ll sk=0;
    FOR(i,0,n){
      if(a[i]*f[i]>cm){
        ll tmp = (a[i]*f[i]-cm+f[i]-1)/f[i];
        sk += tmp;
      }
    }
    if(sk>k) cl = cm;
    else cr = cm;
  }
  cout << cr << endl;
}

int main(){
  solve();
  return 0;
}

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

#define MAX_Q 100000

// int Q = 1;
// int l[] = {3};
// int r[] = {7};

int Q;
int l[MAX_Q], r[MAX_Q];

int prime[MAX_Q];
bool is_prime[MAX_Q + 1];

// エラトステネスの篩
int sieve(int n) {
    int p = 0;
    for (int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;

    for (int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }

    return p;
}

int main() {
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        cin >> l[i] >> r[i];
    }
    int ans[MAX_Q];

    int prime_count = sieve(MAX_Q);
    for (int i = 0; i < Q; i++) {
        int result = 0;
        for (int j = 0; j < prime_count; j++) {
            if (prime[j] < l[i]) {
                continue;
            }
            if (r[i] < prime[j]) {
                break;
            }

            if (is_prime[(prime[j]+1) / 2]) {
                result++;
            }

        }
        ans[i] = result;
    }

    for (int i = 0; i < Q; i++) {
        printf("%d\n", ans[i]);
    }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
signed main(void){
    string s; cin>>s; 
    int n = s.size() + 1;
    s += '?';
    vector <int> a(n);
    vector <int> b(n);
    rep(i,n-1){
        if(s[i] == '<') a[i+1] = a[i] + 1;
        else a[i+1] = 0;
    }
    /*rep(i,n) cout<<a[i]<<' ';
    cout<<endl;*/
    rrep(i,n-1){
        if(s[i] == '>') b[i] = b[i+1] + 1;
        
    }
    vector <int> ans(n);
    //rep(i,n) cout<<b[i]<<' ';
    //cout<<endl;
    rep(i,n-1){
        
        if(s[i] == '<') ans[i] = a[i];
        else ans[i] = b[i];
    }
    for(int i=0;i<=n-1;i++){

            ans[i] = max(a[i], b[i]);
        
    }
       
    //rep(i,n) cout<<ans[i]<<s[i];
    int sum = 0;

    rep(i,n) sum += ans[i];
    cout<<sum<<endl;
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e7;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/
vector<int> arr[1009];
map<pair<int,int>,int> m;
struct edge{
    int from,to,w;
    edge(int uu,int vv,int ww):from(uu),to(vv),w(ww){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }
};

const int N = 205;

int main(){
    int n;
    string s;

    cin >> n ;
    cin >> s;
    if(n >= 3200) cout << s;
    else cout << "red";

}













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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	ll n; cin >> n;
	vector<pll> v;
	for(ll i=2;i*i<=n;i++){
		int cnt = 0;
		while(n%i==0){
			n = n/i;
			cnt++;
		}
		if(cnt!=0) v.push_back({i, cnt});
	}
	if(n!=1) v.push_back({n, 1});
	ll ans = 0;
	for(auto p: v){
		ll cur = p.second;
		ll tmp = 1;
		while(cur-tmp>=0){
			cur -= tmp;
			tmp++;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

const int maxn = 1e5 + 5;
int a[maxn], b[maxn], c[maxn];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <=n; i++) cin >> a[i];
    for (int i = 1; i <=n; i++) cin >> b[i];
    for (int i = 1; i <=n; i++) cin >> c[i];
    sort(a+1, a + n+1);
    sort(b+1, b + n+1);
    sort(c+1, c + n+1);
    long long res = 0;
    int h = 1, t = 1;
    for (int i = 1; i <=n; i++) {
        while (a[h] < b[i] && h <=n) h++;
        while (b[i] >= c[t] && t <=n) t++;
        long long tmp1 = n - t + 1;
        long long tmp2 = h-1;
        res += tmp1 * tmp2;
    }
    cout << res << endl;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(int argc, const char * argv[]){
    int S, h, m, s;
    scanf("%d" , &S);
    h=S/3600;
    m=(S-(h*3600))/60;
    s=(S-(h*3600))%60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
    
}

Measured memory_bytes: 592
#include <stdio.h>

int cmpfunc (const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}

int main()
{
    int a, b, c=0, i, j, l, d1, d2, d3, d[10010];
    char ar[13];
    gets(ar);
    l = strlen(ar);
    for(a=0; a<l-2; a++)
    {
        d1 = ar[a] - '1' + 1;
        d2 = ar[a+1] - '1' + 1;
        d3 = ar[a+2] - '1' + 1;
        d[c] = d1*100 + d2*10 + d3;
        d[c] = abs(d[c] - 753);
        c++;
    }
    qsort (d, c, sizeof(int), cmpfunc);
    printf("%d", d[0]);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int M=4e3+200;
int a[M][M];
int main(){
	long long n;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++){
			scanf("%d",&a[i][j]);
		}
		a[i][0]=1;
	}
	long long num=n*(n-1)/2;
	int flag=0;
	long long ans=0;
	long long i=0;
	while(1){
		ans++;
		int flag2=0;
		int used[M]={0};
		for(int j=1;j<=n;j++){
			long long k=a[j][0];
			if(!used[j]&&k!=n){
				long long t1=a[j][k];
				long long k2=a[t1][0];
				long long t2=a[t1][k2];
				if(t2==j&&!used[t1]){
					a[t1][0]++;
					a[j][0]++;
					used[t1]=1;
					used[j]=1;
					flag2=1;
					i++;
				}
			}
		}
		if(!flag2){
			flag=1;
			break;
		}
		if(i==num){
			break;
		}
	}
	if(flag){
		printf("-1\n");
	}else{
		printf("%d\n",ans);
	}
	return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> l(N, 0);
	for (int i = 0; i < N; i++) cin >> l[i];
	sort(l.begin(), l.end(), greater<int>());
	int sum = 0;
	for (int i = 0; i < K; i++) sum += l[i];
	cout << sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int N,M,K,A,B,C,ans=0,cnt=0;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;


int main(){
  cin>>N;
  int L[N];
  REP(i,N){
    cin>>L[i];
    cnt+=L[i]*L[i];
    ans+=L[i];
  }
  cout<<(ans*ans-cnt)/2<<endl;
}

Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__);
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__);


#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){

    CIN(x,t);
    COUT(max(0,x-t));


   return 0;


}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 2005
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, M, A, B, C, K;
ll arr[MAX_INT], arr1[MAX_INT], dist[MAX_INT], vis[MAX_INT], mp[MAX_INT];
vector<ll> V, adj[MAX_INT];

void bfs(ll node) {
	vis[node] = 1;
	dist[node] = 0;
	queue<int> q;
	while(!q.empty()) {
		q.pop();
	}
	q.push(node);
	while(!q.empty()) {
		node = q.front();
		q.pop();
		fi(i, 0, adj[node].size(), 1) {
			ll child = adj[node][i];
			if(!vis[adj[node][i]]) {
				vis[child] = 1;
				dist[child] = dist[node] + 1;
				mp[dist[child]]++;
				q.push(child);
			}
		}
	}
}



int main() {
	scanf("%lld %lld %lld", &N, &M, &K);
	for(int i = 0; i < N - 1; i++) {
		adj[i].push_back(i + 1);
		adj[i + 1].push_back(i);
	}
	M--;
	K--;
	adj[M].push_back(K);
	adj[K].push_back(M);
	for(int i = 0; i < N; i++) {
		memset(vis, 0, sizeof(vis));
		memset(dist, 0, sizeof(dist));
		bfs(i);
	}
	for(int i = 1; i <= N - 1; i++) {
		cout << mp[i] / 2 << "\n";
	}

	
	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  bool j = true;
  bool ans = false;
  int a,b;
  int c=0;
  int t=0;
  while(j){
    cin>>a>>b;
    t++;
    if(a==b){
      c++;
    }
    if(a!=b){
      c=0;
    }
    if(c==3){
      j = false;
      ans = true;
    }
    if(t==n) j=false;
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n; cin >> n;
    int tmp = n;
    int sum = 0;
    while (tmp) {
        sum += tmp % 10;
        tmp /= 10;
    }

    cout << (n % sum == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  int maxL=1;
  int minR=N;
  
  for(int i=0;i<M;i++){
    int L, R;
    cin >> L >> R;
    maxL = max(maxL, L);
    minR = min(minR, R);
  }
  
  int ans = minR - maxL + 1;
  cout << max(ans, 0) << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
	int ss;
	
	int h,m,s;
	
	cin>>ss;
	
	h = ss/3600;
	
	m = ss%3600/60;
	
	s = ss%60;
	
	cout << h << ":" << m << ":" << s << endl;
	
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll mod = 1e9+7;

int main(){
  int n;
  cin >> n;
  ll x[n], g[n] = {};
  for(ll i = 0; i < n; i++) {
    cin >> x[i];
    if(i > 0) {
      g[i] = max(g[i-1],i-(1+x[i-1])/2);
    }
  }
  ll ans = 1;
  for(ll i = 0; i < n; i++) {
    (ans *= i + 1 - g[i] ) %= mod; 
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int ans = 1, r = K;
    while (r < N) {
        ans++;
        r += K - 1;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 640
var i,j:byte;
begin
        readln(i);
        readln(j);
        if i=1 then begin
                if j=2 then writeln(3)
                else if j=3 then writeln(2); end
        else if i=2 then begin
                if j=1 then writeln(3)
                else if j=3 then writeln(1); end
        else begin
                if j=2 then writeln(1) else if j=1 then writeln(2);
        end;
end.


Measured memory_bytes: 128
#include <iostream>

int main()
{
   int nTree, nLook;
   std::cin >> nTree >> nLook;
   int nPeople;
   if (nTree % (2 * nLook + 1)) {
      nPeople = nTree / (2 * nLook + 1) + 1;
   } else {
      nPeople = nTree / (2 * nLook + 1);
   }
   std::cout << nPeople << std::endl;
   return 0;
}


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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int c = 0;
    int d = 0;

    if(a>b) {
        c = b;
        d = b - (n - a);
    }
    else {
        c = a;
        d = a - (n - b);
    }

    if (d < 0) d = 0;
    cout << to_string(c) + " " + to_string(d) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int cnt=0;  
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='C')
        {
            cnt=1;
        }
        if(a[i]=='F'&&cnt==1)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <functional>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n'&&c!=EOF;)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

template <typename T>
using V = vector<T>;

int sum(int n, int k) {
	return (2 * n - k + 1) * k / 2;
}

int main() {
	for (int n, k, s; n = in, k = in, s = in;) {
		V<V<V<int>>> m(k, V<V<int>>(n + 1, V<int>(sum(n, k) + 1, -1)));
		function<int(int, int, int)> f = [&](int i, int j, int a){
			if (i == k)
				return (int) (a == s);
			if (m[i][j][a] >= 0)
				return m[i][j][a];
			int r {};
			for (int l = j; l <= n - k + i + 1; l++)
				r += f(i + 1, l + 1, a + l);
			return m[i][j][a] = r;
		};
		if (sum(n, k) < s)
			outl(0);
		else
			outl(f(0, 1, 0));
	}
}


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

int main() {
  int a,b;
  int kekka = 0;
  
  cin >> a >> b;
  
  if((a + b) % 2 == 0) cout << (a + b) / 2;
  else cout << (a + b) / 2 + 1;
}


Measured memory_bytes: 256
x,y = map(int,input().split())
if (x+y)%3!=0:print(0);exit()
mod = 10**9+7
n = (x+y)//3
m = min(x-n,y-n)
frac = [1]*(n+1)
finv = [1]*(n+1)
for i in range(n):
    frac[i+1] = (i+1)*frac[i]%mod
finv[-1] = pow(frac[-1],mod-2,mod)
for i in range(1,n+1):
    finv[n-i] = finv[n-i+1]*(n-i+1)%mod
def nCr(n,r):
    if n<0 or r<0 or n<r: return 0
    r = min(r,n-r)
    return frac[n]*finv[n-r]*finv[r]%mod
print(nCr(n,m)%mod)

Measured memory_bytes: 74988
using System;

class D
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		long n = h[0], k = h[1], m = n - k + 2;
		Console.WriteLine((-(n + 1) * m + (n + 3) * m * (m + 1) / 2 - m * (m + 1) * (2 * m + 1) / 6) % 1000000007);
	}
}


Measured memory_bytes: 17780
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 200050
typedef long long ll;
int n,a[N];
ll s[N];
ll Abs(ll x) {return x>0?x:-x;}
ll _max(ll a,ll b,ll c,ll d) {
	if(a<b) a=b; if(a<c) a=c; if(a<d) a=d;
	return a;
}
ll _min(ll a,ll b,ll c,ll d) {
	if(a>b) a=b; if(a>c) a=c; if(a>d) a=d;
	return a;
}
int main() {
	scanf("%d",&n);
	int i,j=1,k=3,l,p;
	ll ans=1ll<<60;
	for(i=1;i<=n;i++) scanf("%d",&a[i]),s[i]=s[i-1]+a[i];
	for(i=2;i<n-1;i++) {
		while(s[j]<s[i]-s[j]) j++;
		while(s[k]-s[i]<s[n]-s[k]) k++;
		for(l=-1;l<=1;l++) {
			for(p=-1;p<=1;p++) {
				int l1=j+l,l2=k+p;
				if(l1<1||l1>i-1||l2<i+1||l2>n-1) continue;
				ll P=s[l1],Q=s[i]-s[l1],R=s[l2]-s[i],S=s[n]-s[l2];
				ans=min(ans,_max(P,Q,S,R)-_min(P,Q,S,R));
			}
		}
	}
	printf("%lld\n",ans);
}


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

int main(){
  string s1;
  cin >> s1;
  int N;
  N = s1.size();
  vector<int> s2(N);

  for (int i = 0; i < N; i++) {
    s2.at(i) = s1.at(i) - '0';
  }

  int ans;
  ans = 753;
  for (int i = 0; i <= N-3; i++) {
    ans = min(ans,abs(753-(s2.at(i)*100+s2.at(i+1)*10+s2.at(i+2))));
  }
  cout << ans << endl;
}

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

// a^nを計算　O(log n)
long long int powint(long long int a, long long int n) {
    if (n == 0) {
        return 1;
    } else {
        long long int temp = powint(a, n / 2);
        if (n % 2 == 0) {
            return temp * temp;
        } else {
            return temp * temp * a;
        }
    }
}

int n, m;
vector<int> s;
vector<char> c;

int main() {
    cin >> n >> m;
    s.resize(m), c.resize(m);
    for (int i = 0; i < m; i++) {
        cin >> s[i] >> c[i];
    }
    int start = powint(10, n - 1), goal = powint(10, n);
    if (n == 1) {
        start = 0;
    }
    for (int i = start; i < goal; i++) {
        string num = to_string(i);
        bool judge = true;
        for (int j = 0; j < m; j++) {
            if (num[s[j] - 1] != c[j]) {
                judge = false;
                break;
            }
        }
        if (judge) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo INT_MAX

const int N = 20;
const int MASK = (1 << 16) + 5;
ll n , res;
ll b[N] , f[MASK];
ll a[N][N];
ll dp[N][MASK];
vector < int > g[N];

/// dp[i][mask] là số điểm cao nhất đạt được khi xài i cái lòng và cái các cái lòng từ 1 -> i có giá trị là mask
/// vì để tránh tình trạng lập lại vs cái lồng thứ i ta chỉ xét trạng thái mask mà i * (số bit 1 của mask) <= n.

int main()
{
    //freopen("U.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    REP(i , n)
        REP(j , n)
            cin >> a[i][j];
    REP(j , (1 << n))
    {
        int r = 0;
        REP(x , n)
            if((j >> x) & 1 == 1)
                b[++r] = x;
        g[r].pb(j);
        FOR(x , 1 , r)
            FOR(y , x + 1 , r)
                f[j] += a[b[x]][b[y]];
        dp[0][j] = f[j];
    }


    FOR(i , 1 , n - 1)
    {
        REP(j , (1 << n))
            dp[i][j] = dp[i - 1][j];
        FOR(j , n - (n / (i + 1))  , n - 1)
        {
            REP(s , g[j + 1].size())
            {
                int y = g[j + 1][s];
                for(int x = (y - 1) & y ; x > 0 ; x = (x - 1) & y)
                    dp[i][y] = max(dp[i][y] , dp[i - 1][x] + f[y ^ x]);
            }
        }
    }
    REP(i , n)
        res = max(res , dp[i][(1 << n) - 1]);
    cout << res;
}


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

int main()
{
	string a;
	string b;
	string half1;
	string half2;
	int i;
	int check = 1;
	getline(cin, a);

	//cout << "a:" << a<<endl;

	while (check== 1)
	{
		for (i = 0; i < a.size() - 1; i++)
		{
			b += a[i];
		}

	//	cout << "b:" << b << endl;

		if (b.size() % 2 == 0)
		{
			for (i = 0; i < (b.size() / 2); i++)
			{
				half1 += b[i];
			}

			for (i = b.size() / 2; i < b.size(); i++)
			{
				half2 += b[i];
			}
		}


	//	cout << "half1:" << half1 << half1.size()<<endl;
	//	cout << "half2:" << half2 << half2.size()<<endl;

		if (half1.size() == 0 && half2.size() == 0)
		{
			a = b;
			b = "";
			half1 = "";
			half2 = "";
			continue;
		}
		else 
		{
			if (half1 == half2)
			{
				cout << half1.size() * 2;
				break;
			}

		}

		a = b;
		b = "";
		half1 = "";
		half2 = "";
	

	}

	return 0;

	
}


Measured memory_bytes: 256
while True:
    (m,f,r) = [int(i) for i in input().split()]
    if m == f == r == -1:
        break

    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
    elif total < 50 and r < 50:
        print('D')
    elif total < 65:
        print('C')
    elif total < 80:
        print('B')
    else:
        print('A')
        

Measured memory_bytes: 6724
n,m = map(int,input().split())
N = []
for _ in range(n):
  N.append(input())
M = []
for _ in range(m):
  M.append(input())
for i in range(n-m+1):
  for j in range(n-m+1):
    for k in range(m):
      if M[k] != N[i+k][j:j+m]:
        break
    else:
      print('Yes')
      break
  else:
    continue
  break
else:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
#define ll long long
#define ld long double
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define sz(x) (int)x.size()
#define ull unsigned long long
#define vvi vector<vi>
#define vvl vector<vl>
#define vpi vector<pii>
#define vpl vector<pll>
ll mod = 1000000007;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
#define openfile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#else
#define openfile
#define deb(x...)
#endif
void init()
{
    
}
void solve()
{
    string s,t;cin>>s>>t;
    ll i,n = sz(s),ans = 0;
    fo(0,i,n)
    {
        ans+=(s[i]!=t[i]);
    }
    cout<<ans<<endl;
}
int main()
{
    init();
    // openfile;fastio;
    int T = 1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
}

Measured memory_bytes: 3864
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion

int main()
{
	int n, m, k; cin >> n >> m >> k;
	UnionFind uf(n);
	vector<int> res(n), f(n);
	rep(i, m)
	{
		int a, b; cin >> a >> b;
		--a, --b;
		++f[a];
		++f[b];
		uf.merge(a, b);
	}
	rep(i, n)res[i] = uf.size(i) - f[i] - 1;
	rep(i, k)
	{
		int c, d; cin >> c >> d;
		--c, --d;
		if (uf.issame(c, d))
		{
			--res[c];
			--res[d];
		}
	}
	rep(i, n)cout << res[i] << endl;
}


Measured memory_bytes: 2048
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
dp0 = [0] * (n+11)
dp1 = [0] * (n+11)
dp2 = [0] * (n+11)
for i,ai in enumerate(A):
  dp2[i+11] = (max(dp0[i+7] + ai, dp1[i+8] + ai, dp2[i+9] + ai) if i >= 2 else 0)
  dp1[i+11] = (max(dp0[i+8] + ai, dp1[i+9] + ai) if i >= 1 else 0)
  dp0[i+11] = dp0[i+9] + ai 
if n % 2 == 0:
  print(max(dp0[n + 9], dp1[n + 10]))
else:
  print(max(dp0[n + 8], dp1[n + 9], dp2[n + 10]))

# debug
# print(dp0,dp1,dp2,sep="\n")




Measured memory_bytes: 95596
import numpy as np

def main():
    n = int(input())
    a = list(map(int, input().split()))
    A = np.array(a)
    B = np.where(A < 0, A * -1, A)
    cnt = np.count_nonzero(A < 0)
    #print(B)
    s = B.sum()
    if cnt % 2 == 0:
        print(s)
    else:
        m = np.amin(B)
        print(s - m * 2)
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 23284
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", (double)v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A& a, const B& b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A& a, const B& b) { a = max(a, (A)b); };


int main() {
	string s, t; cin >> s >> t;
	vector<int> s_a(1+s.size());
	vector<int> s_b(1+s.size());
	vector<int> t_a(1+t.size());
	vector<int> t_b(1+t.size());
	s_a[0] = 0;
	s_b[0] = 0;
	t_a[0] = 0;
	t_b[0] = 0;
	REP(i, 1, 1+s.size()) {
		s_a[i] = s_a[i - 1] + (s[i - 1] == 'A' ? 1 : 0);
		s_b[i] = s_b[i - 1] + (s[i - 1] == 'B' ? 1 : 0);
	}
	REP(i, 1, 1+t.size()) {
		t_a[i] = t_a[i - 1] + (t[i - 1] == 'A' ? 1 : 0);
		t_b[i] = t_b[i - 1] + (t[i - 1] == 'B' ? 1 : 0);
	}
	ll q; cin >> q;
	REP(i, 0, q) {
		ll a, b, c, d; cin >> a >> b >> c >> d;
		ll sa = s_a[b] - s_a[a - 1];
		ll sb = s_b[b] - s_b[a - 1];
		ll ta = t_a[d] - t_a[c - 1];
		ll tb = t_b[d] - t_b[c - 1];
		ll smod = ((sa - sb) % 3 + 3) % 3;
		ll tmod = ((ta - tb) % 3 + 3) % 3;
		if (smod == tmod) PRI("YES");
		else PRI("NO");
	}
	return 0;
}

Measured memory_bytes: 5080
if __name__ == "__main__":
    K = list(map(int,input().split()))
    X = K[1]
    K = K[0]
    maxX = (X + (K-1))
    minX = (X - (K-1))
    if maxX > 1000000:
        maxX = 1000000
    elif minX < -1000000:
        minX = -1000000
    for i in range(maxX - minX + 1):
        print(minX + i, end = " ")
    

    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
 
 
int main(){
    ll n,x; cin >> n >> x;
    vl a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    ll sum=0;
    ll ans=0;
    rep(i,n){
        if(sum + a[i] <= x && i < n-1){
            sum += a[i];
            ans++;
        }
        if(i == n-1){
            if(sum + a[n-1] == x){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 13, maxm = 5000, inf = 2000000000;
int tmp, mn = inf, tc, arr[maxn], n, m, x, c[maxn], a[maxn][maxn];
bool ok;

int main()
{
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        for (int j = 0; j < m; j++)
            cin >> a[i][j];
    }
    for (int i = 0; i < (1 << n); i++)
    {
        memset(arr, 0, sizeof arr);
        tmp = i;
        tc = 0;
        for (int j = 0; j < n; j++)
        {
            if (tmp & 1)
            {
                tc += c[j];
                for (int k = 0; k < m; k++)
                    arr[k] += a[j][k];
            }
            tmp >>= 1;
        }
        ok = 1;
        for (int j = 0; j < m; j++)
        {
            if (arr[j] < x)
            {
                ok = 0;
                break;
            }
        }
        if (ok)
            mn = min(mn, tc);
    }
    if (mn == inf)
        cout << -1;
    else
        cout << mn;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int x, a, b;
    cin >> x >> a >> b;

    if(abs(x-a) < abs(x-b)) cout << 'A' << endl;
    else cout << 'B' << endl;

    return 0;
}

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

using namespace std;

using ll = long long;

ll Solve(ll a, ll b) {
    if (a == b) return 2 * a - 2;

    if (b < a) swap(a, b);

    ll lb = a, ub = 2 * b, ab = a * b;
    while (1 < ub - lb) {
        ll mid = 0.5 * (lb + ub);
        ll max_p = (mid + 1) / 2 * (mid / 2 + 1);
        if (max_p < ab) lb = mid;
        else ub = mid;
    }

    return lb - 1;
}

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

    int q;
    cin >> q;
    while (q--) {
        ll a, b;
        cin >> a >> b;
        cout << Solve(a, b) << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
S = input()
tf_str = ""

ans = 0

def dfs(tf_str,S):
    global ans
    if len(tf_str) != len(S)-1:
        dfs(tf_str + "f",S)
        dfs(tf_str + "t",S)
    else:
        frm = 0
        for to in range(1,len(S)):
            if tf_str[to-1] == "t":
                ans += int(S[frm:to])
                frm = to
        
        ans += int(S[frm:])


dfs(tf_str,S)   
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;

typedef long long ll;

long long myGcd(long long a, long long b)
{
	if (a % b == 0)return b;
	return myGcd(b, a % b);
}

int myGcd(int a, int b)
{
	if (a % b == 0)return b;
	return myGcd(b, a % b);
}

long long myLcm(long long a, long long b)
{
	return a * b / myGcd(a, b);
}

int myLcm(int a, int b)
{
	return a * b / myGcd(a, b);
}

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

	int K, A, B;
	bool ans = false;

	cin >> K >> A >> B;

	REP(i, B)
	{
		if ((i + 1) * K >= A && (i + 1) * K <= B)
		{
			ans = true;
			break;
		}
	}

	if (ans == true)
	{
		cout << "OK" << endl;
	}
	else
	{
		cout << "NG" << endl;
	}

	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;


int main() {
	int n;
	cin >> n;
	cout << 180 * (n - 2);
}

Measured memory_bytes: 764
#include "bits/stdc++.h"

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
 
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;

template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cout << x << " ";
    }
    cout << endl;
}

template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cout << q.top() << " ";
        q.pop();
    }
    cout << endl;
}

template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cout << q.front() << " ";
        q.pop();
    }
    cout << endl;
}

template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}

int main(void) {
    int n;
    cin >> n;
    
    if(n < 3200) {
        cout << "red" << endl;
        return 0;
    }
    
    string s;
    cin >> s;
    cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x, a, b;

	scanf("%d %d %d", &x, &a, &b);

	if (a - b >= 0) printf("delicious\n");
	else if ((a - b < 0) && (b - a <= x)) printf("safe\n");
	else printf("dangerous\n");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=300010;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	ll n,x;
	cin>>n>>x;
	ll ans=1;
	ll d=0;
	for(ll i=0;i<n;++i)
    {
        ll a;
        cin>>a;
        d+=a;
        if(d<=x){++ans;}
    }
    cout<<ans;

	return(0);
}


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

using namespace std;

int main(){
    int x;
    cin >> x;
    if(x == 0){
        cout << "1" << endl;
    }
    if(x == 1){
        cout << "0" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second

const int N = 2e5 + 5;
const int M = 998244353;

int mod(int m){
    m%=M;
    return (m+M)%M;
}

int power(int x,int y) {
    int res = 1;
    x = mod(x);
    while (y > 0) {
        if (y & 1)
            res =mod(res*x);
        y = y>>1;
        x = mod(x*x);
    }
    return mod(res);
}

int f[N],invf[N];
void fact(){
    f[0]=f[1]=1;
    for(int i=2;i<N;i++)
        f[i]=mod(f[i-1]*i);

    invf[N-1]=power(f[N-1],M-2);
    for(int i=N-1;i>0;i--)
        invf[i-1]=mod(invf[i]*i);

}

int nCr(int n,int r) {
    if(r>n)
        return 0;
    int ans = f[n];
    ans = mod(ans*invf[n-r]);
    ans = mod(ans*invf[r]);
    return ans;
}

int32_t main() {
	fact();
	int n,m,k;
	cin>>n>>m>>k;
	int ans = 0;
	for(int i=0;i<=k;i++){
		int tt = power(m-1,n-i-1);
		tt = mod(tt*m);
		tt = mod(tt * nCr(n-1,i));
			ans = mod(ans+tt);
		//else
			//ans = mod(ans-tt);
	}	
	cout<<ans<<endl;
}	

Measured memory_bytes: 6764
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, t;
    cin >> n >> t;
    vector<P> ab(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    sort(all(ab));
    auto dp = make_vec<int>(n+1, t);
    int ans = 0;
    rep(i, n) {
        int a = ab[i].fi, b = ab[i].se;
        rep(j, t) {
            chmax(dp[i+1][j], dp[i][j]);
            if (j+a < t) chmax(dp[i+1][j+a], dp[i][j] + b);
        }
        chmax(ans, dp[i][t-1] + b);
    }
    cout << ans << endl;
}


Measured memory_bytes: 35584
def solve(inp)
    return inp
end

inp = gets.chomp
left = (inp[0] + inp[1]).to_i
right = (inp[2] + inp[3]).to_i

l_yy = false
l_mm = false
r_yy = false
r_mm = false
na = false

if left > 12 || left <= 0
    l_yy = true
    l_mm = false
end
if right > 12  || right <= 0
    r_yy = true
    r_mm = false
end

if 0 < left && left <= 12 
    l_yy = true
    l_mm = true
end

if 0 < right && right <= 12 
    r_yy = true
    r_mm = true
end


if l_yy == true && l_mm == true &&
    r_yy == true && r_mm == true
    puts "AMBIGUOUS"
elsif l_yy == true && l_mm == true &&
    r_yy == true && r_mm == false
    puts "MMYY"
elsif l_yy == true && l_mm == true &&
    r_yy == false && r_mm == true
    puts "YYMM"
elsif l_yy == true && l_mm == false &&
    r_yy == true && r_mm == true
    puts "YYMM"
elsif l_yy == true && l_mm == false &&
    r_yy == true && r_mm == false
    puts "NA"
elsif l_yy == true && l_mm == false &&
    r_yy == false && r_mm == true
    puts "YYMM"
elsif l_yy == false && l_mm == true &&
    r_yy == true && r_mm == true
    puts "MMYY"
elsif l_yy == false && l_mm == true &&
    r_yy == true && r_mm == false
    puts "MMYY"
elsif l_yy == false && l_mm == true &&
    r_yy == false && r_mm == true
    puts "NA"
end


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
//		整数 
//		N
//		 が与えられます。
//
//		高橋君は、
//		N
//		 以下の正整数の中から等確率で 
//		1
//		 つを選んで 
//		a
//		 とします。
//
//		このとき、
//		a
//		 が奇数である確率を答えてください。

		Scanner sc = new Scanner(System.in);
		double num = sc.nextInt();
		double odd = Math.ceil(num/2);
		double result = odd / num;
		System.out.println(result);
		sc.close();
	}
}


Measured memory_bytes: 21844