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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

class Node {
 public:
  int id;
  vector<pair<Node*, bool> > children;
};

bool Test(vector<int>& test_results, const Node* node) {
  test_results[node->id] = 1;
  bool flag = true;
  FOR(i, 0, node->children.size()) {
    Node* child = node->children[i].first;
    bool child_judge = node->children[i].second;
    if (test_results[child->id] == -1) {
      if (child_judge) {
        flag = flag && Test(test_results, child);
      } else {
        test_results[child->id] = 0;
      }
    } else {
      if (test_results[child->id] != (int)child_judge) {
        return false;
      }
    }
  }
  return flag;
}

int main() {
  int n;
  cin >> n;
  vector<Node> nodes(n);
  FOR(i, 0, n) {
    nodes[i].id = i;
    int a;
    cin >> a;
    FOR(j, 0, a) {
      int x, y;
      cin >> x >> y;
      nodes[i].children.push_back(pair<Node*, bool>(&nodes[x - 1], y));
    }
  }

  int ans = 0;
  FOR(i, 0, n) {
    vector<int> test_results(n, -1);  // -1: undefined, 0: false, 1: true
    // FOR(j, 0, n) { test_results[j] = -1; }
    bool flag = true;
    flag = Test(test_results, &nodes[i]);
    if (!flag) continue;
    FOR(j, 0, n) {
      if (test_results[j] == -1) {
        vector<int> test_results_copy(n, -1);
        // Copy
        FOR(k, 0, n) { test_results_copy[k] = test_results[k]; }
        // Test
        if (!Test(test_results_copy, &nodes[j])) {
          if (test_results[j] != -1) {
            flag = false;
            break;
          }
          test_results[j] = 0;
          continue;
        }
        FOR(k, 0, n) { test_results[k] = test_results_copy[k]; }
      }
    }
    if (!flag) continue;
    int try_ans = 0;
    FOR(j, 0, n) {
      if (test_results[j] == 1) try_ans++;
    }
    ans = max(ans, try_ans);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    long long r;
    cin >> r;
    a[i] = a[i - 1] + r;
  }
  long long ans = llabs(a[1] - a[0] - (a[n] - a[1]));
  for (int i = 1; i <= n - 1; i++) {
    long long x = a[i] - a[0], y = a[n] - a[i];
    long long tmp = llabs(x - y);
    if (tmp < ans) {
      ans = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n, x, m, r, p;
    cin >> n >> x >> m;
    p = x;
    r = x;
    ll ans = 0, cnt = 0;
    set<ll> s, t;
    while(true){
        if(s.find(x) != s.end())
            break;
        s.insert(x);
        x = x * x % m;
    }
    while(r != x){
        ans += r;
        r = r * r % m;
        cnt++;
    }
    if(cnt >= n){
        ans = 0;
        for(ll i = 0; i < n; i++){
            ans += p;
            p = p * p % m;
        }
        cout << ans << endl;
        return 0;
    }
    ll l = 0, part_sum = 0;
    while(true){
        if(t.find(x) != t.end())
            break;
        t.insert(x);
        l++;
        part_sum += x;
        x = x * x % m;
    }
    n -= cnt;
    ans += (n / l) * part_sum;
    for(ll i = 0; i < n % l; i++){
        ans += x;
        x = x * x % m;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8300
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0, i##len=(N); i<i##_len; i++)
#define RREP(i, N) for(int i=1, i##_len=(N); i<i##_len; i++)
#define REPP(i, N) for(int i=0, i##_len=(N); i<=i##_len; i++)
#define RREPP(i, N) for(int i=1, i##_len=(N); i<=i##_len; i++)
#define P(x) cout << (x)
using ll = long long;
using namespace std;


int main() {
    int a;
    string s;
    cin >> a >> s;
    cout << ((a>=3200)? s:"red");
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  rep(i,3){
    if(S[i] == S[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    map<int,int> mp;
    ll ans = 0;
    for (int i = 0;i < n;++i) {
        ans += mp[i-a[i]];
        mp[a[i]+i]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 21124
# EduDPA - Frog 1
n = int(input())
lst = list(map(int, input().rstrip().split()))
ans = [0, abs(lst[0] - lst[1])] + [float("inf")] * (n - 2)
for i in range(2, n):
    ans[i] = min(ans[i], ans[i - 1] + abs(lst[i] - lst[i - 1]))
    ans[i] = min(ans[i], ans[i - 2] + abs(lst[i] - lst[i - 2]))

print(ans[-1])

Measured memory_bytes: 13980
from bisect import bisect_left
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
A.sort()
t=0
for i in range(N):
    while 2**t<=A[i]:
        if 2**t<=A[i]<2**(t+1):
            break
        t+=1
    B[i]=2**(t+1)-A[i]
i=N-1
count=0
flag=[0]*N
for i in range(N-1,0,-1):
    if flag[i]==1:
        continue
    flag[i]=1
    b=bisect_left(A,B[i])
    if A[b]==B[i] and flag[b]==0:
        flag[i]=1
        flag[b]=1
        A[b]-=1
        count+=1
print(count)

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

int  main()
{
	int n; cin >> n;
	vector<long> h(n);
	rep(i, n)
		cin >> h[i];
	long cnt = 0;
	long ans = 0;
	for (int i = 1; i < n; i++)
	{
		if (h[i-1] >= h[i])
			cnt++;
		else
		{
			ans = max(cnt,  ans);
			cnt = 0;
		}
	}
	ans = max(cnt,  ans);
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 1024
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;



int main(){

    long long A;
    float B;

    string S;

    // 入力
    cin >> A >> S;
    
    int it = stoi(S.substr(0, S.length()-2));
    int dc = stoi(S.substr(S.length()-2));
    
//    cout << it << endl;
//    cout << dc << endl;
    
    long long aa = A*dc;
    float temp = A*dc;

//    cout << aa/100 << endl;
//    cout << temp/100 << endl;
    
//    cout << A*dc << endl;
//    cout << A*dc/100.0 << endl;
    long long result = floor(aa/100);
//    cout << result << endl;
    result += it*A;
    cout << result << endl;
    
   
    
    return 0;
}


Measured memory_bytes: 3612
N, H = map(int, input().split())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

B.sort(reverse = True)
maxA = max(A)
cnt = 0
for b in B:
    if b > maxA and H > 0:
        H -= b
        cnt += 1
        
if H > 0:
    cnt += - (- H // maxA)

print(cnt)

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

void solve(){
	int k;
	ll ans = 0;
	cin >> k;
	for(int i = 1; i <= k; i++)
		for(int j = 1; j <= k; j++)
			for(int t = 1; t <= k; t++)
				ans += __gcd(__gcd(i,j), t);
	cout << ans << '\n';
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3588
#include<stdio.h>
#define max 100000

int a[max],n;

int part(int p,int r){
	int x,i,j,t;
	x=a[r];
	i=p-1;
	for(j=p;j<r;j++){
		if(a[j]<=x){
			i++;
			t=a[i];
			a[i]=a[j];
			a[j]=t;
		}
	}
	t=a[i+1]; a[i+1]=a[r]; a[r]=t;
	return i+1;
}

int main(){
	int i,q;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	
	q=part(0,n-1);
	
	for(i=0;i<n;i++){
		if(i)printf(" ");
		if(i==q)printf("[");
		printf("%d",a[i]);
		if(i==q)printf("]");
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 2148
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

ll mpow(ll n, ll t) {
  rep(i,t) n*=n;
  if (t==0) n=1;
  return n;
}

int main() {
  ll N,oN;
  cin >> N;
  string ans = "";
  N--;
  string memo = "abcdefghijklmnopqrstuvwxyz";
  ll n = 1;
  rep2(i,1,30) {
    n*=26;
    if (N>=n) {
      N-=n; continue;
    }
    else {
      // cout << N << endl;
      rep(j,i) {
        // cout << memo[N%26] << endl;
        ans.push_back(memo[N%26]);
        N /= 26;
        // cout << N << endl;
      }
      break;
    }
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 1001;
double ev[N + 5];
int main(){
  FASTER;
  double sum = 0;
  for (int i = 1; i <= N; i++){
    sum += i;
    ev[i] = (double)sum / (double) i;
  }
  double ans = 0;
  int n, k;
  cin >> n >> k;
  vector<int>ar(n);
  for (int i = 0; i < n; i++){
    cin >> ar[i];
  }
  //return 0;
  double tmp = 0;
  for (int i = 0; i < k; i++){
    tmp += ev[ar[i]];        
  }        
  ans = max(tmp, ans);
  for (int i = k; i < n; i++){
    tmp += ev[ar[i]];
    tmp -= ev[ar[i - k]];
    ans = max(tmp, ans);
  }
  //cout << fixed << setprecision(10);
  cout << fixed << setprecision(10) << ans << "\n";
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		boolean[] n = new boolean[1000000] ;
		for(int i = 0;i< 1000000;i++){
			if(i <=1){
				n[i] = false;} else
					if(i > 1){
						n[i] = true;
					}
			}
	for(int i = 2;i < 1000000;i++){
		if(n[i] == true){
			for(int j = 2;j*i < 1000000;j++){
				n[j*i] = false;
			}
		}
	}
		Scanner scan = new Scanner(System.in);
		int N;
	while(scan.hasNext()){
		N = scan.nextInt();
		 int count = 0;

		for(int i = 0;i <= N;i++){
			if(n[i] == true){count = count +1;
		}
		}
			System.out.println(count);

		}

	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int x;
    cin>>x;
    if(x==2){
        cout<<2;
        return 0;
    }
    rep(i,x){
        int cnt=0,k=x+i;
        repi(j,2,sqrt(k)){
            if(k%j==0) cnt++;
        }
        if(cnt==0){
            cout<<x+i;
            return 0;
        }
    }
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] c = new int[3][3];
        for (int i = 0; i < 9; i++) c[i/3][i%3] = sc.nextInt();
        System.out.println(c[0][0]+c[1][1]==c[0][1]+c[1][0] && c[0][2]+c[2][0]==c[0][0]+c[2][2] && c[1][2]+c[2][1]==c[1][1]+c[2][2]? "Yes": "No");
    }
}

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

int main()
{
	int n;
	int d[101];
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> d[i];
	
	int sum = 0;
	
	for(int i = 0; i < n; i++)
		for(int j = i+1; j < n; j++)
			sum += d[i] * d[j];
		
	cout << sum << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
const int N = 2e5+5; 
map<ll,ll>ma;
string s1,s2;
ll a,b,n;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(ma[a]){
			puts("NO");
			return 0;
		}
		ma[a]++;
	}
	puts("YES");
	
	return 0;
}

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

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    int *H = new int[N];
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    
    int max = 0;
    int count = 0;
    int h = H[0];
    for (int i = 1; i < N; i++) {
        if (h >= H[i]) {
            count++;
        }else {
            max = std::max(max, count);
            count = 0;
        }
        h = H[i];
    }
    max = std::max(max, count);
    
    cout << max << endl;
    
    delete[] H;
    
    return 0;
}

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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long double d,t,s;
    cin >> d >> t >> s;

    long double time = d/s;

    //cout << t << " " << time << "\n";
    if(t >= time)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    int a, b;
    string s;
    cin >> a >> b >> s;
    for(int i = 0; i < a; i++){
        if(0 > s[i] - '0' || s[i] - '0' > 9){
            cout << "No" << "\n";
            return;
        }
    }
    if(s[a] != '-') {
        cout << "No" << "\n";
        return;
    }
    for(int i = a+1; i < a+b+1; i++){
        if(0 > s[i] - '0' || s[i] - '0' > 9){
            cout << "No" << "\n";
            return;
        }
    }
    cout << "Yes" << "\n";
}

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	long long n,m,p;
	cin>>n>>m;
	if(n*2>m) p=1;
	else{
		m+=n*2;
		p=0;
	} 
	if(p==0) cout<<m/4<<endl;
	else cout<<m/2;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。


int main(){
	string s;
	int n;
	cin>>n>>s;
	map<char,ll> mp;
	rep0(i,n){
		mp[s[i]]++;
	}
	ll ans=1;
	ll mod=1e9+7;
	for(char i='a';i<='z';i++){
		ans=(ans*(mp[i]+1))%mod;
	}
	cout<<(ans-1)%mod<<endl;
    return 0;
}

Measured memory_bytes: 512
program contest_with_drinks_easy
  implicit none
  integer :: n, m, t(100), p, x, i, s
  t = 0
  read(*,*) n
  read(*,*) t(1:n)
  read(*,*) m
  s = sum(t(1:n))
  do i = 1, m
    read(*,*) p, x
    write(*,'(i0)') s-t(p)+x
  end do
  stop
end program contest_with_drinks_easy

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


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

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

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

      
      cin>>n>>k;
      map<ll,ll> mp;
      rep(i,k){
        cin>>a;
        mp[a]++;
      }
     while(1){
       fl=true;
       string s;
       s=to_string(n);
       rep(i,Size(s)){
         if(mp[(s[i]-'0')]!=0)fl=false;
       }
       if(fl){
         Cout(n);
         return 0;
       }
       else{
         n++;
       }
     }
     

       
return 0;
}


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

int main() {
    int n;
    int flag = 0;

    cin >> n;

    while(n != 0) {
        if (n % 10 == 7) {
            flag = 1;
        }
        n /= 10;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int p , q , r , m1 , m2 , m3 ;
    cin >> p >> q >> r ;
    m1 = p + q ;
    m2 = p + r ;
    m3 = r + q ;
    cout << min(min(m1,m2),m3) ;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int N,M,Q;
int a[50],b[50],c[50],d[50];
int solve(long n,int in,long A){
	int ans=0;
	if(in<N){
		A=A*10+n;
		for(int i=n;i<M;i++){
			ans=max(solve(i,in+1,A),ans);
		}
	}else{
		int Ar[10];
		for(int i=0;i<N;i++){Ar[N-i-1]=A%10;A/=10;}
		for(int i=0;i<Q;i++){
			if(Ar[b[i]]-Ar[a[i]]==c[i])ans+=d[i];
		}
	}
	return ans;
}
int main(){
	cin>>N>>M>>Q;
	for(int i=0;i<Q;i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i]--;b[i]--;
	}
	cout<<solve(0,0,0);
	return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int N, t[110], v[110];
double ans, vmax[44000], vmaxR[44000];

int main() {
	rd(N);
	repi(i, 0, N) {
		int temp;
		rd(temp);
		i == 0 ? t[i] = temp : t[i] = t[i - 1] + temp;
	}
	repi(i, 0, N) rd(v[i]);

	vmax[0] = 0;

	repi(i, 0, N) {
		int cur_t;
		if (i == 0) cur_t = 1;
		else cur_t = t[i - 1] * 2 + 1;
		repi(j, cur_t, t[i] * 2 + 1) vmax[j] = min((double)v[i], vmax[j - 1] + 0.5);
	}

	vmaxR[t[N - 1]] = 0;

	repd(i, N - 1, -1) {
		int next_t;
		if (i == 0) next_t = -1;
		else next_t = t[i - 1] * 2 - 1;
		repd(j, t[i] * 2 - 1, next_t) vmaxR[j] = min((double)v[i], vmaxR[j + 1] + 0.5);
	}

	repi(i, 0, t[N - 1] * 2 + 1) {
		vmax[i] = min(vmax[i], vmaxR[i]);
	}

	repi(i, 1, t[N - 1] * 2 + 1) {
		ans += (double)(vmax[i] + vmax[i - 1]) / (double)4;
	}

	cout << fixed << setprecision(8) << ans << endl;

	return 0;
}

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

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

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	char a; cin >> a;
	if (int(a) <= 90)cout << "A";
	else cout << "a";
}


Measured memory_bytes: 3588
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int nRs;
	R[] rs;
	int[][] map;
	int n=4;

	void run(){
		nRs=sc.nextInt();
		rs=new R[nRs];
		for(int i=0; i<nRs; i++){
			int h=sc.nextInt();
			int w=sc.nextInt();
			rs[i]=new R(w, h);
		}
		map=new int[n][n];
		for(int j=0; j<n; j++){
			String s=sc.next();
			for(int i=0; i<n; i++){
				switch(s.charAt(i)){
				case 'R':
					map[j][i]=1;
					break;
				case 'G':
					map[j][i]=2;
					break;
				case 'B':
					map[j][i]=3;
					break;
				}
			}
		}
		solve();
	}

	void solve(){
		LinkedList<State> que=new LinkedList<State>();
		boolean[] visited=new boolean[1<<(n*n)];

		int[] removed=new int[n];
		for(int i=0; i<n; i++){
			fill(removed, (1<<n)-1);
		}

		State s0=new State(0, removed);
		que.offer(s0);
		visited[s0.hashCode()]=true;

		for(; !que.isEmpty();){
			State s=que.poll();
			for(int k=0; k<nRs; k++){
				for(int y=-n+1; y<n; y++){
					for(int x=-n+1; x<n; x++){
						if(canStamp(x, y, rs[k].w, rs[k].h, s.removed)){
							State t=new State(s.step+1, s.removed);
							t.clear(x, y, rs[k].w, rs[k].h);
							if(!visited[t.hashCode()]){
								que.offer(t);
								visited[t.hashCode()]=true;
								if(t.isCleared()){
									println(t.step+"");
									return;
								}
							}
						}
					}
				}
			}
		}
	}

	boolean canStamp(int x, int y, int w, int h, int[] removed){
		boolean same=true;
		int k=0;
		for(int j=y; j<y+h; j++){
			for(int i=x; i<x+w; i++){
				if(i>=0&&i<n&&j>=0&&j<n){
					if(((removed[j]>>i)&1)!=0){
						if(k==0){
							k=map[j][i];
						}else{
							same&=k==map[j][i];
						}
					}
					if(!same){
						return false;
					}
				}
			}
		}
		return same&&k!=0;
	}

	class R{
		int w, h;

		R(int w, int h){
			this.w=w;
			this.h=h;
		}
	}

	class State{
		int step;
		int[] removed=new int[n];

		State(int step, int[] rem){
			this.step=step;
			for(int i=0; i<n; i++){
				removed[i]=rem[i];
			}
		}

		void clear(int x, int y, int w, int h){
			for(int j=y; j<y+h; j++){
				for(int i=x; i<x+w; i++){
					if(i>=0&&i<n&&j>=0&&j<n){
						removed[j]&=~(1<<i);
					}
				}
			}
		}

		boolean isCleared(){
			boolean ret=true;
			for(int i=0; i<n; i++){
				ret&=removed[i]==0;
			}
			return ret;
		}

		@Override
		public int hashCode(){
			int hash=0;
			for(int i=0; i<n; i++){
				hash=hash*16+removed[i];
			}
			return hash;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

int main()
{
    long a, b;
    cin >> a >> b;

    long c = abs(a - b);
	long d = abs(a + b);
    if (c % 2 == 1)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
    {
        cout << d / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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;
}

int main()
{
  int n;
  ll k;
  cin >> n >> k;

  int g[300300] = {};
  rep(i, n)
  {
    int x;
    cin >> x;
    --x;
    g[i] = x;
  }

  int tmp = 0;
  int last = 0;
  int index = 0;
  vector<int> vec;
  map<int, int> mp;

  for (;;)
  {
    auto it = mp.find(tmp);
    if (it == mp.end())
    {
      mp[tmp] = index;
      last = tmp;
      vec.push_back(tmp);
      tmp = g[tmp];
      index++;
    }
    else
    {
      int index = mp[tmp];
      ll size = mp[last] - index + 1;

      if (k <= index)
      {
        cout << vec[k] + 1 << endl;
        return 0;
      }
      else
      {
        ll amari = (k - index) % size;
        cout << vec[index + amari] + 1 << endl;
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 14328
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    map<ll,ll>mp;
    ll answer = 0;
    REP(i,200100){
        mp[i]=0;
    }
    REP(i,n){
        cin >> a[i];
        mp[a[i]]++;
    }
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        answer += (itr->second*(itr->second-1))/2;
    }
    
    REP(i,n){
        //if(mp[a[i]]==0)continue;
        answer -= (mp[a[i]]*(mp[a[i]]-1))/2;
        answer += ((mp[a[i]]-1)*(mp[a[i]]-2))/2;
        cout << answer << endl;
        answer -= ((mp[a[i]]-1)*(mp[a[i]]-2))/2;
        answer += (mp[a[i]]*(mp[a[i]]-1))/2;
    }

    return 0;
}

Measured memory_bytes: 17024
#include<stdio.h>
int main(){
  int n,a[100010],ans[100010],i;
  scanf("%d\n",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
  }
  for(i=1;i<=n;i++){
    ans[a[i]]=i;
  }
  for(i=1;i<=n;i++){
    if(i==1){
    printf("%d",ans[i]);
    }
    else{
      printf(" %d",ans[i]);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <queue>

int main() {
  uint32_t K = 0;
  std::cin >> K;

  uint32_t k = 0, value = 0;
  std::queue<uint32_t> todo({1, 2, 3, 4, 5, 6, 7, 8, 9});
  while (k != K) {
    value = todo.front();
    if (value % 10 != 0) todo.push(value * 10 + value % 10 - 1);
    todo.push(value * 10 + value % 10);
    if (value % 10 != 9) todo.push(value * 10 + value % 10 + 1);
    todo.pop();
    k++;
  }
  std::cout << value << std::endl;

  return 0;
}

Measured memory_bytes: 4364
use std::io;
use std::collections::HashSet;
 
 
fn main() {
    let mut values = HashSet::new();
    let n: i32 = get_line().parse().unwrap();
 
    for _ in 0..n {
        let a : i32 = get_line().parse().unwrap();
        if !values.contains(&a) {
            values.insert(a);
        }else{
            values.remove(&a);
        }
    }
    println!("{}", values.len());
}
 
fn get_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    return String::from(line.trim())
}

Measured memory_bytes: 6396
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = getInt(sc);
		int m = getInt(sc);
		int x = getInt(sc);

		int[] janctions = getIntArray(sc);
		List<Integer> jancList = new ArrayList<Integer>();
		for (int janc : janctions) {
			jancList.add(janc);
		}

		int costToN = 0;
		for (int i = x; i <= n; i++) {
			if (jancList.contains(i)) {
				costToN++;
			}
		}

		int costToZero = 0;
		for (int i = x; i >= 0; i--) {
			if (jancList.contains(i)) {
				costToZero++;
			}
		}

		if (costToN < costToZero) {
			System.out.println(costToN);
		} else {
			System.out.println(costToZero);
		}

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 22100
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := 5
	ml := make([]int, n+1)

	lossmax := 10
	sum := 0
	for i := 1; i < n+1; i++ {
		ml[i] = nextInt()
		if ml[i]%10 > 0 {
			lossmax = min(lossmax, ml[i]%10)
		}
		sum += kiriageX(ml[i], 10)
	}
	fmt.Println(sum - (10 - lossmax))
}

// aをbの倍数に切り上げ  ex.(b=10) 123->130, 40->40
func kiriageX(a, b int) int {
	return (a + (b - 1)) / b * b
}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;


int main() {
    int n, k;
    cin >> n >> k;
    V h(n);
    rep(i, 0, n) cin >> h[i];

    sort(ALL(h));

    ll ans = 1001001001;
    Rep(i, 0, n-k){
        ll Mh = h[i+k-1], mh = h[i];
        ans = min(ans, Mh-mh);
    }

    cout << ans << endl;
}

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

const int MAX_V = 5001;
const int INF = 1e9;

struct edge { int to, cap, rev, ori; };

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];
int V, E;

void add_edge(int from, int to, int cap) {
  G[from].push_back((edge){to, cap, (int)G[to].size(), cap});
  G[to].push_back((edge){from, cap, (int)G[from].size() - 1, cap});
}

void bfs(int s) {
  memset(level, -1, sizeof(level));
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while ( !que.empty() ) {
    int v = que.front(); que.pop();
    for ( int i = 0; i < (int)G[v].size(); i++ ) {
      edge &e = G[v][i];
      if ( e.cap > 0 && level[e.to] < 0 ) {
	level[e.to] = level[v] + 1;
	que.push(e.to);
      }
    }
  }
}

int dfs(int v, int t, int f) {
  if ( v == t ) return f;
  for ( int &i = iter[v]; i < (int)G[v].size(); i++ ) {
    edge &e = G[v][i];
    if ( e.cap > 0 && level[v] < level[e.to] ) {
      int d = dfs(e.to, t, min(f, e.cap));
      if ( d > 0 ) {
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t) {
  int flow = 0;
  for (;;) {
    bfs(s);
    if ( level[t] < 0 ) return flow;
    memset(iter, 0, sizeof(iter));
    int f;
    while ( (f = dfs(s, t, INF)) > 0 ) {
      flow += f;
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  cin >> V >> E;
  for ( int i = 0; i < E; i++ ) {
    int a, b, c; 
    cin >> a >> b >> c;
    add_edge(a, b, c);
    // add_edge(b, a, c);
  }

  int f = max_flow(0, V-1);

  vector<pair<int, int> > v;
  for ( int i = 0; i < V; i++ ) {
    for ( int j = 0; j < (int)G[i].size(); j++ ) {
      edge &e = G[i][j];
      if ( e.cap == 0 && e.ori == 1 ) v.push_back(pair<int, int>(i, j));      
    }
  }

  
  max_flow(V-1, 0);
  for ( int i = 0; i < (int)v.size(); i++ ) {
    int a = v[i].first, b = v[i].second;
    edge &e1 = G[a][b];
    edge &e2 = G[e1.to][e1.rev];
    e1.cap = 0;
    e1.ori = 0;
    e2.cap = 0;
    e2.ori = 0;
  }

  int f2 = max_flow(0, V-1);
  
  if ( f*2 > f2 ) f--;
  if ( f <= 10000 ) cout << f << endl;
  else cout << -1 << endl;
  
  return 0;
}

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

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

Measured memory_bytes: 256
e=enumerate
n,*a=map(int,open(0).read().split())
d=[0]
for j,(a,i)in e(sorted((a,i)for i,a in e(a))[::-1]):d=[d[0]+a*abs(n-j-i-1)]+[max(d[k]+a*abs(n-j+k-i-1),d[k-1]+a*abs(i-k+1))for k in range(1,j+1)]+[d[j]+a*abs(i-j)]
print(max(d))

Measured memory_bytes: 9532
from collections import Counter

N = int(input())
S = input()
counter_s = Counter(S)
min_stone = counter_s.most_common()[-1][1]
if min_stone == N:
    min_stone = 0
A, B = 0, counter_s['.']
for s in S:
    if s == '#':
        A += 1
    else:
        B -= 1
    if min_stone > A+B:
        min_stone = A+B
print(min_stone)

Measured memory_bytes: 3872
#include <stdio.h>

int main(void)
{
	int n;
	int i, j, k, l;
	int count;
	
	while ((scanf("%d", &n)) != EOF){
		count = 0;
		for (i = 0; i < 10; i++){
			for (j = 0; j < 10; j++){
				for (k = 0; k < 10; k++){
					for (l = 0; l < 10; l++){
						if (i + j + k + l == n){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n", count);
	}
	
	return (0);
}

Measured memory_bytes: 596
def resolve():
    n = int(input())
    listS = []
    for i in range(n):
        s = input()
        listS.append(s)
    ac = listS.count("AC")
    tle = listS.count("TLE")
    wa = listS.count("WA")
    re = listS.count("RE")
    print("AC x {}".format(ac))
    print("WA x {}".format(wa))
    print("TLE x {}".format(tle))
    print("RE x {}".format(re))
    
resolve()

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

int main()
{
	int A, B;
	cin >> A >> B;
	if (A <= 5)
		cout << "0";
	else if (A >= 6 && A <= 12) {
		cout << B / 2;
	}
	else
		cout << B;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n%2==0)
	{
		cout<<0.5000000000<<endl;
	}
	else
	{
		printf("%lf\n",(double)((n/2)+1)/n);
	}
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, n) for(long i = x; i < n; i++)
#define erep(i, x, n) for(long i = x; i <= n; i++)
#define all(a) a.begin(), a.end()
#define show(ans)  cout << ans << endl;
const long MOD = 1000000007;

long long euclidean_gcd(long long a, long long b) {
  if(a < b) euclidean_gcd(b, a);
  long long r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {long N;
cin >> N;
vector<long long> t(N+1);
erep(i, 1, N) cin >> t[i];
long long ans = 1;
erep(i, 1, N){
    ans = ans / (euclidean_gcd(ans, t[i])) * t[i];
}

show(ans);
  return 0;
 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  int cnt=1;
  
  for(int i=0; i<N; i++)
    cin >> d.at(i);
  
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());

  for(int i=1; i<N; i++){
    if(d.at(i-1) != d.at(i))
      cnt++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
import math
n=int(input())
e=[]
for i in range(n):
    x,y=map(int,input().split())
    if (x,y)==(0,0):
        continue
    else:
        t=math.atan2(y,x)
        e.append((x,y,t))
e.sort(key=lambda x:x[2])
n=len(e)

e+=e
a=[(0,0)]
ans=0
for x,y,t in e:
    a+=[(a[-1][0]+x,a[-1][1]+y)]
for l in range(n*2):
    for r in range(l,n*2):
        if r-l>n:
            continue
        else:
            x,y=a[r]
            w,z=a[l]
            ans=max((x-w)**2+(y-z)**2,ans)
print(ans**0.5 if n>0 else 0)

Measured memory_bytes: 40048
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>

using namespace std;

const int MAX_P=10,MAX_T=50,MAX_R=2000;
const int MAX_CASE=100;

struct data{
	int ans;	//??£?§£??°
	int time;	//????????????
	int pena[MAX_P];	//??????i?????????????????£???
	int index;	//???????????????
};

bool comp(const data &a,const data &b){
	if (a.ans!=b.ans)
		return a.ans>b.ans;
	if (a.time!=b.time)
		return a.time<b.time;
	return a.index>b.index;
}

bool same(const data &a,const data &b){
	if (a.ans==b.ans && a.time==b.time){
		return true;
	}
	return false;
}

int A[MAX_CASE],B[MAX_CASE],C[MAX_CASE],D[MAX_CASE];
int ma[MAX_CASE][MAX_R],ta[MAX_CASE][MAX_R],pa[MAX_CASE][MAX_R],ja[MAX_CASE][MAX_R];

data d[MAX_T];

int main(){
	int q=0;
	do{
		int n,t,p,r;
		scanf("%d %d %d %d",A+q,B+q,C+q,D+q);
		for (int i=0;i<D[q];i++){
			scanf("%d %d %d %d",&ma[q][i],&ta[q][i],&pa[q][i],&ja[q][i]);
		}
		q++;
	}while (A[q-1]!=0);
	int N,T,P,R;
	for (int k=0;k<q;k++){
		N=A[k],T=B[k],P=C[k],R=D[k];
		for (int i=0;i<T;i++){
			d[i].ans=d[i].time=0;
			d[i].index=i+1;
			memset(d[i].pena,0,sizeof(d[i].pena));
		}
		for (int i=0;i<R;i++){
			int m,t,p,j;
			m=ma[k][i],t=ta[k][i],p=pa[k][i],j=ja[k][i];
			data &da=d[t-1];
			if (j==0){
				//??£?§£
				da.time+=m+da.pena[p-1];
				da.ans++;
			}
			else{
				//?????£?§£
				da.pena[p-1]+=20;	//??????????????£???
			}
		}
		sort(d,d+T,comp);
		for (int i=0;i<T;i++){
			if (i){
				if (same(d[i],d[i-1])){
					printf("=");
				}
				else{
					printf(",");
				}
			}
			printf("%d",d[i].index);
		}
		if (k!=q-1)
			printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
long long fac[100005];
long long power(long long x, long long n, long long M = mod){
    long long res = 1;
    if(n > 0){
        res = power(x, n / 2, M);
        if(n%2 == 0)res = (res * res) % M;
        else res = (((res * res) % M) * x) % M;
    }
    return res;
}
long long C(int n, int m){
    long long x = 1;
    for (int i = 0; i < m; i++)
    {
        x *= (n-i);
        x %= mod;
        x *= power(i+1, mod-2);
        x %= mod;
    }
    return x;
}
int main(){
    long long n, a, b; cin >> n >> a >> b;
    long long ans = ((power(2, n) + mod) - 1) % mod;
    fac[0] = 1;
    for (int i = 1; i <= 100000; i++)
    {
        fac[i] = (fac[0] * i) % mod;
    }
    ans += mod - C(n, a);
    ans %= mod;
    ans += mod - C(n, b);
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[200005], b[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];
	sort(a+1, a+n+1);
	sort(b+1, b+n+1);
	
	if(n%2) cout << b[n/2+1]-a[n/2+1]+1 << endl;
	else cout << (b[n/2+1]+b[n/2])-(a[n/2+1]+a[n/2])+1 << endl;
	return 0;
}

Measured memory_bytes: 6780
from functools import reduce

def main():
	N,M,C = map(int,input().split())
	B = list(map(int,input().split()))
	mtr_A = []
	for i in range(N) :
		A = list(map(int,input().split()))
		mtr_A.append(A)
	collect = 0
	for A_gyo in mtr_A :
		polynomial = [ a*b for a,b in zip(A_gyo,B)]
		res = reduce(lambda x,y:x+y,polynomial) + C
		if res > 0 :
			collect += 1
	print(collect)

if __name__ == "__main__" :
	main()


Measured memory_bytes: 3572
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    int A, B, C, D;
    if (scanf("%d%d%d%d", &A, &B, &C, &D) < 4) return 0;

    printf("%d\n",
        (B - A) + (D - C) <= D - A ? 0 :
            (B - A) + (D - C) <= B - C ? 0 :
                (A <= C) && (D <= B) ? D - C :
                    (C <= A) && (B <= D) ? B - A :
                        (B <= D) && (A <= C) ? B - C : D - A);
    return 0;
}


Measured memory_bytes: 128
/* be name khoda */

// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

// -----------------------------------------------------------------------

const ll maxn = 1000010;
const ll maxnlg = 20;

ll n;
ll two[maxn], ar[maxn];
string S;

ll parity(ll a, ll b) {
    return two[b] == two[a] + two[b - a];
}

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

    forifrom (i, 1, maxn) {
        two[i] = two[i - 1] + __builtin_ctz(i);
    }
    cin >> n >> S;
    ll c1 = 0;
    fori (i, n) {
        ar[i] = S[i] - '1';
        c1 += ar[i] == 1;
    }
    if (c1) {
        fori (i, n) if (ar[i] == 2) ar[i] = 0;
    } else {
        fori (i, n) if (ar[i] == 2) ar[i] = 1;
    }
    ll ans = 0;
    fori (i, n) {
        ans ^= ar[i] && parity(i, n - 1);
    }
    if (c1 == 0) ans <<= 1;
    cout << ans << '\n';

}


Measured memory_bytes: 9116
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];	
	}
	
	sort(a.begin(), a.end());
	
	vector<ll> sum(n + 1, 0LL);
	for(int i = 0; i < n; ++i) {
		sum[i + 1] = sum[i] + a[i];
	}
	
	vector<bool> ok(n + 1, false);
	for(int i = 1; i < n; ++i) {
		if( 2 * sum[i] >= a[i] ) ok[i - 1] = true;
	}
	
	int ans = 1;
	for(int i = 0; i < n - 1; ++i) {
		if( ok[i] ) ans++;
		else ans = 1;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

#define INF int(1e9)

const int maxn=1000005;
int n;
char s[maxn];

bool check(int d){
	pair<int,int>val[2]={make_pair(0,d),make_pair(0,d)};
	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++){
			if(val[j].first%2!=j)val[j].first++;
			if(val[j].second%2!=j)val[j].second--;
		}
		pair<int,int>nval[2]={make_pair(INF,-INF),make_pair(INF,-INF)};
		for(int c=0;c<2;c++)if(s[i]=='?'||s[i]=='0'+c){
			for(int j=0;j<2;j++){
				int vl=val[j].first+2*c-1;
				int vr=val[j].second+2*c-1;
				vl=max(vl,0);
				vr=min(vr,d);
				if(vl>vr)continue;
				nval[j^1].first=min(nval[j^1].first,vl);
				nval[j^1].second=max(nval[j^1].second,vr);
			}
		}
		val[0]=nval[0];
		val[1]=nval[1];
	}
	for(int j=0;j<2;j++){
		if(val[j].first%2!=j)val[j].first++;
		if(val[j].second%2!=j)val[j].second--;
	}
	return val[0].first<=val[0].second||val[1].first<=val[1].second;
}

int main(){
	scanf("%s",s);n=strlen(s);
	int l=0,r=n;
	while(l<r){
		int mid=l+r>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	printf("%d\n",r);
	return 0;
} 

Measured memory_bytes: 4784
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
 
const ll N = 3534567;
const ll mod = 1e9 + 7;
const ld eps = 1e-6;
const ld pi = 3.1415926535;

int a[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cout << fixed << setprecision(12);

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

    rep(i , 1 , n) cin >> a[i];
    int cnt = 0;

    rep(i , 1 , n) {
        if(a[i] >= k) cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640