akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

int N;

double dp[310][310][310];
double rec(int i, int j, int k){
    if(dp[i][j][k]>=0) return dp[i][j][k];
    if(i==0 && j==0 && k==0) return 0.0;

    double res = 0.0;
    if(i>0) res += rec(i-1,j,k) * i;
    if(j>0) res += rec(i+1,j-1,k) * j;
    if(k>0) res += rec(i,j+1,k-1) * k;
    res += N;
    res *= 1.0 / (i+j+k);

    return dp[i][j][k] = res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N;
    int one=0,two=0,three=0;

    REP(i,N){
        int a;
        cin>>a;
        if(a==1) one++;
        else if(a==2) two++;
        else three++;
    }
    memset(dp,-1,sizeof(dp));
    cout<<fixed<<setprecision(10)<<rec(one,two,three)<<endl;
}

Measured memory_bytes: 233088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;cin>>N>>M;
  vector<string> a(N),b(M);
  for(int i=0;i<N;i++)cin>>a.at(i);
  for(int i=0;i<M;i++)cin>>b.at(i);
  
  int flag=0,ans=0;
  for(int i=0;i<N-M+1;i++){
    for(int j=0;j<N-M+1;j++){
      if(a.at(i).substr(j,M)==b.at(0)){
        flag=0;
        for(int k=0;k<M;k++){
          if(a.at(i+k).substr(j,M)!=b.at(k)){
            flag++;
            break;
          }
        }
        if(flag==0)ans++;
      }
    }
  }
  if(ans==0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  vector<int64> ds(n + 1);
  for (int k = 1; k <= n; k++) {
    for (int x = k; x <= n; x += k) {
      ds[x]++;
    }
  }
  int64 ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += ds[i] * i;
  }
  cout << ans << endl;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  
  int L[M+1];
  int R[M+1];
  
  rep(i,M) {cin >> L[i] >>R[i];}
  L[M] = 0;
  R[M] = 0; 

  rep(i,M-1){
    L[i+1] = max(L[i],L[i+1]);
    R[i+1] = min(R[i],R[i+1]);
    //cout << L[i+1] << endl << R[i+1] << endl;
  }

  //cout << L[M-1] << endl << R[M-1] << endl;
  int ans = 0;
  if(L[M-1]<=R[M-1]){
  	ans = R[M-1]-L[M-1]+1;
  }	else {
  	ans = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R, G;
    cin >> R >> G;
    cout << (G - R) * 2 + R << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e16;
#define int long long

const int MAX_N = 1010;
const int MAX_V = 110;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n / 2; i++) {
		if (i != n - i)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// 2014/11/12 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int L, A, B, C, D;
	cin >> L;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;

	int E = A/C;
	if(A%C!=0){
		E++;
	}

	int F = B/D;
	if(B%D!=0){
		F++;
	}

	if(E>F){
		cout << L-E << endl;
	}
	else{
		cout << L-F << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi; 
typedef pair<int,int> pi;
typedef long long ll;
#define F first 
#define S second 
#define PB push_back 
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)


vector< vector<double> > dp;


int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	
	ll n;
	
	cin >> n; 
	
	double p;
	
	dp.assign( n + 2, vector<double>(n+2,0) );
	
	dp[0][0] = 1;
	
	for(ll i = 1; i <= n; i++){
		
		cin >> p;
		
		for(ll i2 = 0; i2 < i; i2++){
		
			dp[i][i2] += dp[i-1][i2]*(1-p);
			dp[i][i2+1] += dp[i-1][i2]*p;
		}
		
	}
 
	double sum = 0;
 
 	for(ll i = (n+1)/2; i <= n; i++){
 			
 		sum+= dp[n][i];

	}
	
	cout << setprecision(10) << sum << endl;
 
	return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

bool a[200001];
bool b[200001];
int main(){
        int n,m;
        cin >> n >> m;
        int c,d;
        rep(i,m){
                cin >> c;
                cin >> d;
                if(d==n) b[c]=true;
                if(c==1) a[d]=true;
        }
        bool ans=false;
        rep(i,n+1){
                if(a[i]&&b[i]) ans=true;
        }
        if(ans) {
                cout << "POSSIBLE" << endl;
        }
        else {
                cout << "IMPOSSIBLE" << endl;
        }
        return 0;
}


Measured memory_bytes: 640
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, V = LI()
    B, W = LI()
    T = I()

    ans = 'NO'
    if V!=W:
        if 0 <= abs(B-A) <= T*(V-W):
            ans = 'YES'

    print(ans)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9224
m = -2
f = -2 
r = -2
while m != -1 || f != -1 || r != -1 
  m,f,r = gets.split.map(&:to_i)
  if m == -1 && f == -1 && r == -1 
  elsif  m == -1 || f == -1 || m + f < 30
    puts "F"
  elsif m + f < 50 && r < 50
    puts "D"
  elsif m + f < 65
    puts "C"
  elsif m + f < 80 
    puts "B"
  else 
    puts "A"   
  end
end


Measured memory_bytes: 6872
#include<iostream>
#include<algorithm>

using namespace std;

int partition(int *A, int p, int r){
  int x = A[r];
  int i = p - 1;
    for(int j = p;j < r;j++){
      if(A[j] <= x){
        i++;
        swap(A[i], A[j]);
      }
    }
    swap(A[i + 1], A[r]);
  return i + 1;
}

int main(){

  int n, a[100000], q;

  cin >> n;
  for(int i = 0;i < n;i++) cin >> a[i];

  q = partition(a, 0, n - 1);

  for(int i = 0;i < n;i++){
    cout << (i?" ":"");
    if(i == q) cout << '[' << a[i] << ']';
    else cout << a[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3396
-- AtCoder My Practice
-- author: Leonardone @ NEETSDKASU
 
-- 解説読後
-- http://arc060.contest.atcoder.jp/data/arc/060/editorial.pdf
 
import qualified Data.Array as A
import qualified Data.Map as M
import qualified Data.List as L
 
main = print . solve . map read . lines =<< getContents

f b n
    | n < b     = n
    | otherwise = let (dv, md) = divMod n b in md + f b dv
 
solve [n, s]
    | n == s    = n + 1
    | s >  n    = -1
    | n == 1    = s
    | otherwise = ans where
        en = head . reverse . takeWhile (\i -> i * i <= n) $ [1 .. ]
        ans = case L.find ((==) s . snd) . map (\i -> (i, f i n)) $ [2 .. en] of
            Just (i, _) -> i
            Nothing -> if en > 0 then ans' else -1 where
                ans' = case L.find ((==) s . snd) . map (\i -> (i, f i n)) $ bs of
                    Just (j, _) -> j
                    Nothing -> -1
                bs = map ((+) 1 . fst) . filter ((==) 0 . snd) . map (divMod (n - s)) $ [en - k | k <- [0 .. en - 1]]
 

Measured memory_bytes: 19836
x= int(input())
y = x + 10**4
A = [0] * y
i = 2
while i < y:
    while i<y and A[i] == 1:
        i += 1
    j = i*2
    while j < y:
        A[j] = 1
        j += i
    i += 1
ans = x
# print(A[:100])
while A[x] > 0:
    x += 1
print(x)

Measured memory_bytes: 40432
#include<stdio.h>

int main() {
	int x[5];
	for (int i = 0; i < 5; i++) {
		scanf("%d", &x[i]);
	}
	for (int i = 0; i < 5; i++) {
		if (x[i] == 0){
			printf("%d",i+1);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 2152
#include <iostream>

using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    int cnt_5 = 0, cnt_7=0;
    if(a == 5) cnt_5++;
    if(b == 5) cnt_5++;
    if(c == 5) cnt_5++;
    if(a == 7) cnt_7++;
    if(b == 7) cnt_7++;
    if(c == 7) cnt_7++;
    if(cnt_5 == 2 && cnt_7 == 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

class unionFind{
  vector<int> p;
public:
  unionFind(int n){
    p = vector<int>(n, -1);
  }
  int root(int x){
    if (p[x] < 0)
      return x;
    return p[x] = root(p[x]);
  }
  int size(int x){
    return -p[root(x)];
  }
  bool unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x == y){
      return false;
    }
    if(size(x) < size(y))
      swap(x, y);
    p[x] += p[y];
    p[y] = x;
    return true;
  }
};

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> p(N);
  rep(i,N) {
    cin >> p[i];
    p[i]--;
  }
  vector<int> x(M), y(M);
  rep(i,M) {
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;
  }
  unionFind uni(N);
  rep(i,M) uni.unite(x[i], y[i]);
  int ans=0;
  rep(i,N){
    if(uni.root(i)==uni.root(p[i]))
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll A[N]; F0R(i, N) cin >> A[i];
    F0R(i, N) {
        if (A[i] == 0) {
            cout << 0 << nl; return 0;
        }
    }
    ld L = 0;
    F0R(i, N) {
        L += log10(A[i]);
    }
    if (L > 18.1) {
        cout << -1 << nl; return 0;
    }
    ll ans = 1; F0R(i, N) ans *= A[i];
    if (ans > 1000000000000000000) {
        cout << -1 << nl; return 0;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 4652
#include <stdio.h>
#include <math.h>
int A[80][80];
int dp[80][80][8001];
int main()
{
    int H, W, res;
    scanf(" %d %d", &H, &W);
    for (int i = 0; i < H; ++i) 
        for (int j = 0; j < W; ++j)
            scanf(" %d", &A[i][j]);
    for (int i = 0; i < H; ++i)
        for (int j = 0; j < W; ++j) {
            int c;
            scanf(" %d", &c);
            A[i][j] = abs(A[i][j]-c);
        }

    dp[0][0][A[0][0]] = 1;
    for (int i = 0; i < H; ++i)
        for (int j = 0; j < W; ++j)
            for (int k = 0; k <= 8000; ++k) {
                if (dp[i][j][k]) {
                    if (i != H - 1) {
                        int c = k+A[i+1][j];
                        if (c <= 8000) dp[i+1][j][c] = 1;
                        dp[i+1][j][abs(k-A[i+1][j])] = 1;
                    }
                    if (j != W - 1) {
                        int c = k+A[i][j+1];
                        if (c <= 8000) dp[i][j+1][c] = 1;
                        dp[i][j+1][abs(k-A[i][j+1])] = 1;
                    }
                }
            }
    for (res = 0; res <= 8000; ++res) if (dp[H-1][W-1][res]) break;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 199040
def main():
    n = int(input())
    point = int(input())
    A = []
    for i in range(n):
        A.append(i+1)
    for i in range(point):
        a,b = map(int,input().split(","))
        A[a-1],A[b-1] = A[b-1],A[a-1]
    for value in A:
        print(value)
      


if __name__ == '__main__':
    main()

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

#define pii pair<int, int>
#define fi first
#define se second

const int mxN=1e5;
int n, x, y, z;
pii ps[mxN];
long long a1, a2[mxN], a3[mxN+1], ans;
priority_queue<int, vector<int>, greater<int>> pq;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x >> y >> z;
	n=x+y+z;
	for(int i=0; i<n; ++i) {
		int ai, bi, ci;
		cin >> ai >> bi >> ci;
		a1+=ai;
		ps[i]={bi-ai, ci-ai};
	}
	sort(ps, ps+n, [&](const pii &a, const pii &b) {
		return a.se-a.fi<b.se-b.fi;
	});
	for(int i=0; i<y; ++i) {
		a1+=ps[i].fi;
		pq.push(ps[i].fi);
	}
	a2[y]=0;
	for(int i=y; i<n-z; ++i) {
		a2[i+1]=a2[i];
		if(ps[i].fi>pq.top()) {
			a2[i+1]+=ps[i].fi-pq.top();
			pq.pop();
			pq.push(ps[i].fi);
		}
	}
	pq=priority_queue<int, vector<int>, greater<int>>();
	for(int i=n-1; i>=n-z; --i) {
		a1+=ps[i].se;
		pq.push(ps[i].se);
	}
	a3[n-z]=0;
	for(int i=n-z-1; i>=y; --i) {
		a3[i]=a3[i+1];
		if(ps[i].se>pq.top()) {
			a3[i]+=ps[i].se-pq.top();
			pq.pop();
			pq.push(ps[i].se);
		}
		ans=max(a1+a2[i]+a3[i], ans);
	}
	cout << max(a1+a2[n-z], ans);
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }

// max({a, b, c, d})
 

int main()
{
    string s1, s2;
    cin >> s1 >> s2;

    int ans = 0;
    for(int i=0;i<s1.size();i++)
    	if(s1[i] == s2[i])
    		ans++;

    cout << ans << "\n";
}





Measured memory_bytes: 256
mod = int(1e9) + 7
n, a, b = map(int, input().split())

def aaa(base, n):
#     base = 2
    ans = 1
    nn = n
    while True:
    #     print(base, nn)
        if nn == 0:
            break
        if nn % 2 == 0:
            base = base ** 2
            base = base % mod
            nn /= 2
        else:
            ans *= base
            ans = ans % mod
            nn -= 1
    return ans

xn = aaa(2, n)

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))


def fac(start, length, mod):
    x = 1
    for k in range(start, start + length):
        x *= k
        x %= mod
    return x

aa = fac(n - a + 1 , a, mod)
aaa = fac(1, a, mod)
xa = div(aa, aaa)
if aa == 0:
    if aaa == 0:
        xa = 1


bb = fac(n - b + 1 , b, mod)
bbb = fac(1, b, mod)
xb = div(bb, bbb)
if bb == 0:
    if bbb == 0:
        xb = 1
        

x = xn - xa - xb - 1
x = x % mod
if x < 0:
    x += mod
print(x)


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{

    ll n, q;
    cin >> n >> q;
    string ss;
    cin >> ss;

    vector<ll> v(n+2, 0), v2(n+1, 0);
    for(ll i = 1; i < ss.size(); i++)
    {

        ll j = i+1;
        if(ss[i] == 'C' && ss[i-1] == 'A') v[j]=1;
    }
    for(ll i = 1; i <= n; i++) v2[i] = v[i]+v2[i-1];
    for(ll i = 1; i <= q; i++)
    {

        ll l, r;
        cin >> l >> r;
        ll ans = v2[r]-v2[l-1];
        if(v[l] == 1) ans--;
        cout << ans << endl;
    }
}


Measured memory_bytes: 2688
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

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

    ll ans = 0;
    ll tmp = A[0];
    rep(i,1,N) {
        ans += max(0LL, tmp - A[i]);
        tmp = max(tmp, A[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>

const int N = 1000000;

int n;
char string[N + 1];
std::deque <int> letters[26];

int count[N];
bool present[N];

void modify(int k, int v) {
    for(; k < n; k += ~k & k + 1) {
        count[k] += v;
    }
}

int query(int k) {
    int ret = 0;
    for (; k >= 0; k -= ~k & k + 1) {
        ret += count[k];
    }
    return ret;
}

void remove(int i) {
    present[i] = false;
    modify(i, -1);
}

int main() {
    scanf("%s", string);
    n = strlen(string);
    for (int i = 0; i < n; ++ i) {
        letters[(int)(string[i] -= 'a')].push_back(i);
    }

   
    int odd_count = 0;
    for (int i = 0; i < 26; ++ i) {
        odd_count += letters[i].size() & 1;
    }
    if (odd_count != (n & 1)) {
        puts("-1");
        return 0;
    }
    memset(present, true, sizeof(present));
    for (int i = 0; i < n; ++ i) {
        modify(i, 1);
    }
    long long answer = 0;
    for (int l = 0, r = n - 1; l < r; ) {
        if (!present[l]) {
            l ++;
        } else if (!present[r]) {
            r --;
        } else {
            int left_cost = query(n - 1) - query(letters[(int)string[l]].back());
            int right_cost = query(letters[(int)string[r]].front()) - 1;
            answer += std::min(left_cost, right_cost);
            int token = left_cost < right_cost ? string[l] : string[r];
            remove(letters[token].front());
            remove(letters[token].back());
            letters[token].pop_front();
            letters[token].pop_back();
        }
    }
    std::cout << answer << std::endl;
    return 0;
}

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

typedef long long ll;
const int NMAX = 1e5 + 10;
const int MOD = 1e9 + 7;
vector<int>edge[NMAX];
int pre[NMAX];

int main(int argc, char const *argv[])
{
	int n,m;
	int u,v;
	scanf("%d%d",&n,&m);
	while(m--)
	{
		scanf("%d%d",&u,&v);
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	queue<int>q;
	q.push(1);
	while(!q.empty())
	{
		u = q.front();
		q.pop();
		for(register int i = 0;i < edge[u].size();i++)
		{
			v = edge[u][i];
			if(!pre[v])
			{
				pre[v] = u;
				q.push(v);
			}
		}
	}
	for(register int i = 2;i <= n;i++)
		if(!pre[i])	return 0*puts("No");
	puts("Yes");
	for(register int i = 2;i <= n;i++)
		printf("%d\n",pre[i] );
	return 0;
}

Measured memory_bytes: 10548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {
        static void Main(string[] args)
        { 
			int a = int.Parse(Console.ReadLine());
			int b = a/15;
			Console.WriteLine("{0}",a*800-b*200);
			}
	}
}


Measured memory_bytes: 13140
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vpl A(N); 
    F0R(i, N) {
        ll X; cin >> X;
        A[i] = {X, i};
    }
    sort(all(A)); reverse(all(A));
    ll dp[N+1][N+1]; F0R(i, N+1) F0R(j, N+1) dp[i][j] = -1000000000000000;
    dp[0][0] = 0;
    F0R(i, N) {
        F0R(j, i+1) {
            ll X = A[i].f;
            ll P = A[i].s;
            ll D1 = abs(A[i].s - j);
            ll D2 = abs(N-1-(i-j)-A[i].s);
            dp[i+1][j] = max(dp[i+1][j], dp[i][j] + X * D2);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + X * D1);
        }
    }
    ll ans = 0;
    F0R(i, N+1) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 34976
#include <bits/stdc++.h>
using namespace std;
int main() {
    char s[10];
    scanf("%s", s);
    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

  int n,c=0,k;
   //double s;
   cin>>n>>k;
   int arr[n+1];
   for(int i=0;i<n;i++)
   {
      
      cin>>arr[i];
   }
   
   for(int i=0;i<n;i++)
   {

      if(arr[i]>=k)
      {
        c++;
      }
   }
   //double t=n-c;
   cout<<c<<endl;
     // printf("%.10f\n",t/n);
      return 0;
   }




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

int main(){
    int N; cin >> N;
    int res = N;
    for(int i = 0; i <= N; i++){
        int cc = 0;
        int t = i;
        while(t > 0) cc += t % 6, t /= 6;
        t = N - i;
        while(t > 0) cc += t % 9, t /= 9;
        if(res > cc) res = cc;
    }
    cout << res << endl;
}

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

a_i = max(a)
a_j = 0
min_d = float('inf')
for a_k in a:
    if a_k == a_i:
        continue
    d = abs(a_i / 2 - a_k)
    if d < min_d:
        min_d = d
        a_j = a_k
print(a_i, a_j)


Measured memory_bytes: 14064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

int top=0;
int S[1000];


void push(int x){
    S[++top] = x;
}
int  pop(){
    int a=0;
    a = S[top];
    top--;
    return a;
}
int main(){
    char c[150];
    int a,b;
    while(scanf("%s",c) != EOF){
        if(c[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(c[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        }else if(c[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }else
        {
            push(atoi(c));
        }
    }
    printf("%d\n",S[1]);
    return 0;
}



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

using namespace std;

int n, m;
int a[105][105];
int f[105][105], color[105][105];
int dx[2] = {-1, 0}, dy[2] = {0, -1};
queue<pair<int, int>> q;

int BFS(int x, int y, int id)
{
    int Res = 1e9;
    q.push(make_pair(x, y));
    color[x][y] = id;
    while (!q.empty())
    {
        x = q.front().first;
        y = q.front().second;
        q.pop();
        for (int i = 0; i < 2; i++)
        {
            int xx = x + dx[i], yy = y + dy[i];
            if (xx > 0 && yy > 0 && a[xx][yy] == a[x][y] && color[xx][yy] != id)
            {
                color[xx][yy] = id;
                q.push(make_pair(xx, yy));
            }
            if (xx == 0  || yy == 0 || a[xx][yy] != a[x][y])
            {
                Res = min(Res, f[xx][yy]);
            }
        }
        
    }
    return Res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    char ch;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> ch;
            a[i][j] = (ch == '#' ? 1 : 0);
        }
    }
    for (int i = 2; i <= max(n,m); i++)
    {
        f[i][0] = 1e9;
        f[0][i] = 1e9;
    }
    f[1][0] = f[0][1] = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            f[i][j] = BFS(i, j, (i - 1) * m + j) + a[i][j];
        }
    }
    cout << f[n][m];
    return 0;
}


Measured memory_bytes: 384
//include
//------------------------------------------
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

int main(void){
  int N;
  string s;
  string t;
  
  cin >> N;
  cin >> s;
  cin >> t;
  if(s == t) cout << N << endl;
  else{
    for(int i=N-1; i >=1; i--){
      //cout << s.substr(N-i,i) << " " << t.substr(i) << " " << i<<endl;
      if(s.substr(i)==t.substr(0,N-i)){
	cout << N+i << endl;
	return 0;
      }
    }
    cout << s.size()+t.size() << endl;
  }
  return 0;
}


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

int main(){

  int n, v = 0;
  cin >> n;
  int a[100010] = {0};
  int b[100010] = {0};
  int amax, aamax, bmax, bbmax = 0;
  
  for(int i = 0;i < n;i++){
  if(i % 2 == 0){
  cin >> v;
    a[v]++;
  }
  else{
  cin >> v;
    b[v]++;
  }
  }

 for(int i = 1;i <= 100000;i++){
 if(a[i] > a[amax]){
 aamax = amax;
 amax = i;  
 }
 else if(a[i] > a[aamax]){
 aamax = i;
 }  
 } 
  
 for(int i = 1;i <= 100000;i++){
 if(b[i] > b[bmax]){
 bbmax = bmax;
 bmax = i;  
 }
 else if(b[i] > b[bbmax]){
 bbmax = i;
 }  
 } 

  if(amax != bmax) cout << n - a[amax] - b[bmax] << endl;  
  else if((amax == bmax) && (a[aamax] > b[bbmax])) cout << n - (b[bmax] + a[aamax]) << endl;
  else cout << n - (a[amax] + b[bbmax]) << endl;  
  return 0;
  
}  

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

int main() {
	int n, a[20] = {0}; cin >> n;
	bool flag = false;
	int a1 = n / 1000, a2 = n / 100 % 10, a3 = n / 10 % 10, a4 = n % 10;
	if (a1 == a2 && a2 == a3 || a2 == a3 && a3 == a4) flag = true;
	if (flag) cout << "Yes\n";
	else cout << "No\n";
	return 0;	
}

Measured memory_bytes: 256
S = input().strip()

L = len(S)

sum_ = 0
for p in range(1 << (L - 1)):
    val = 0
    for i, c in enumerate(S):
        c = int(c)
        val = val * 10 + c
        if i < L - 1:
            if p & (1 << i) != 0:
                sum_ += val
                val = 0
    sum_ += val
print(sum_)


Measured memory_bytes: 3060
c,t,d[4010]={1};char s[4010];i;main(j){for(gets(s);s[i/2];d[j]=!++i)for(j=c+=s[i]?t+=2,s[i]-48:0;j>i+c-t&&~j;j--)d[j]=(d[j]+d[j-1])%998244353;printf("%d",d[c]);}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOREACH(it,c) for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)

double a[3][3];
int s,t,b;
#define A(v) (a[(v)%3][(v)/3])

int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
bool go(int x, int y) {
  if (x < 0 || x > 2 || y < 0 || y > 2 || y*3+x == b) return false;
  return true;
}

void move() {
  double atmp[3][3] = {0};
  REP(x,3) REP(y,3) {
    double v = a[x][y] / 4.0;
    REP(d,4) {
      if(go(x+dx[d],y+dy[d])) atmp[x+dx[d]][y+dy[d]] += v;
      else atmp[x][y] += v;
    }
  }
  REP(x,3) REP(y,3) a[x][y] = atmp[x][y];
}

int main() {
  int n;
  cout.precision(8);
  cout<<fixed;
  while (cin>>n, n) {
    char ss,tt,bb; cin>>ss>>tt>>bb;
    s=ss-'A', t=tt-'A', b=bb-'A';
    memset(a,0,sizeof(a));
    A(s) = 1;
    REP(_,n) move();
    //REP(y,3) {REP(x,3) cout<<a[x][y]<<" "; cout<<endl;}
    cout<<A(t)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100
#define INF 10000000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N, T;
int c[MAX_N], t[MAX_N];

void solve()
{
  int co = INF;
  for (int i = 0; i < N; i++) {
    if (t[i] <= T) {
      co = min(co, c[i]);
    }
  }
  if (co == INF) {
    cout << "TLE" << endl;
  }
  else {
    cout << co << endl;
  }
}

int main(void)
{
  cin >> N >> T;
  REP(i, N) cin >> c[i] >> t[i];
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...) \
  { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  i64 x, d, n;
  void solve() {
    cin >> n >> x >> d;
    if (d == 0) {
      if (x == 0) {
        cout << 1;
        return;
      } else {
        cout << n + 1;
        return;
      }
    } else if (d < 0) {
      x *= -1;
      d *= -1;
    }
    map<i64, vector<pi64>> mp;
    for (i64 i = 0; i <= n; ++i) {
      i64 L, R, A;
      L = i * (i - 1) / 2;
      R = (n + n - 1 - i) * i / 2;
      A = i * x;
      L += A / d;
      R += A / d;
      A %= d;
      if (A < 0) {
        A += d;
        L--;
        R--;
      }
      mp[A].push_back({L, R});
      assert(L <= R);
    }
    i64 ans = 0;
    for (auto i : mp) {
      auto &v = i.second;
      sort(v.begin(), v.end());
      for (int i = 0; i < v.size();) {
        i64 r = v[i].second, l = v[i].first;
        while (i < v.size() && r >= v[i].first) {
          r = max(v[i].second, r);
          ++i;
        }
        ans += r - l + 1;
      }
    }
    cout << ans << '\n';
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}


Measured memory_bytes: 22144
import copy
import collections
import numpy as np

class Graph(object):
    def __init__(self, v, e):
        self.v = [i for i in range(v)]
        self.e = e
    
    def nodes(self):
        return self.v
    
    def edges(self, v):
        return self.e[v]

def bfs(G):
    V = copy.copy(G.nodes())
    deq = collections.deque([V[0]])
    searched = {v:False for v in V}
    searched[V[0]] = True
    T = [0] * len(G.v)
    while len(deq) != 0:
        v = deq.popleft()
        edges = [(v,i) for i in G.edges(v) if not searched[i]]
        for edge in edges:
            v,i = edge
            deq.append(i)
            T[i] = v+1
            searched[i] = True
    return T

if __name__ == "__main__":
    n,m = map(int,input().split())
    e = [[]*n for _ in range(n)]
    for i in range(m):
        a,b = map(int,input().split())
        e[a-1].append(b-1)
        e[b-1].append(a-1)
    
    G = Graph(n,e)

    T = bfs(G)
    print("Yes")
    print(*T[1:],sep="\n")


Measured memory_bytes: 66024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int sum =0;
    for(int i=0;i<a;i++){
      sum=sum+sc.nextInt();
    }
    if(sum>n){
      System.out.println(-1);
    }
    else{
      System.out.println(n-sum);
    }
  }
}


Measured memory_bytes: 46408
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	nums := make([]float64, n)
	for i := range nums {
		fmt.Scan(&nums[i])
	}
	sort.Float64s(nums)
	ans := nums[0]
	for i := 1; i < n; i++ {
		ans = (ans + nums[i]) / 2
	}
	fmt.Println(ans)
}


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

int asumisu(const void* x, const void* y) {
	double a = *(const double*)x, b = *(const double*)y;
	return a < b ? -1 : a > b;
}

int n;
double x[128], y[128], r[128];

double sx[128], sy[128], dx[128], dy[128];

int sumipe;
double maaya[128 * 4];

int hayamin(double target) {
	int l = 0, r = sumipe - 1;
	while (l <= r) {
		int m = l + (r - l) / 2;
		if (maaya[m] == target) return m;
		else if (maaya[m] < target) l = m + 1;
		else r = m - 1;
	}
	exit(2);
	return 0;
}

int kugyu[128 * 4][128 * 4];

int main(void) {
	int horieyui = 1;
	while (scanf("%d", &n) == 1 && n > 0) {
		int i, j;
		double answer;
		maaya[0] = -1e100;
		sumipe = 1;
		for (i = 0; i < n; i++) {
			if (scanf("%lf%lf%lf", &x[i], &y[i], &r[i]) != 3) return 1;
			maaya[sumipe++] = sx[i] = x[i] - r[i];
			maaya[sumipe++] = dx[i] = x[i] + r[i];
			maaya[sumipe++] = sy[i] = y[i] - r[i];
			maaya[sumipe++] = dy[i] = y[i] + r[i];
		}
		qsort(maaya, sumipe, sizeof(*maaya), asumisu);
		sumipe = 1;
		for (i = 1; i < n * 4 + 1; i++) {
			if (maaya[sumipe - 1] != maaya[i]) maaya[sumipe++] = maaya[i];
		}
		for (i = 0; i < sumipe; i++) {
			memset(kugyu[i], 0, sizeof(kugyu[i][0]) * sumipe);
		}
		for (i = 0; i < n; i++) {
			int sxi = hayamin(sx[i]), dxi = hayamin(dx[i]);
			int syi = hayamin(sy[i]), dyi = hayamin(dy[i]);
			kugyu[syi][sxi]++;
			kugyu[syi][dxi]--;
			kugyu[dyi][sxi]--;
			kugyu[dyi][dxi]++;
		}
		for (i = 1; i < sumipe; i++) {
			for (j = 1; j < sumipe; j++) kugyu[i][j] += kugyu[i - 1][j];
		}
		for (i = 1; i < sumipe; i++) {
			for (j = 1; j < sumipe; j++) kugyu[i][j] += kugyu[i][j - 1];
		}
		answer = 0;
		for (i = 0; i < sumipe; i++) {
			for (j = 0; j < sumipe; j++) {
				if (kugyu[i][j] > 0) answer += (maaya[i + 1] - maaya[i]) * (maaya[j + 1] - maaya[j]);
			}
		}
		printf("%d %.2f\n", horieyui++, round(answer * 100.0) / 100.0);
	}
	return 0;
}



Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long double n,k;
	cin>>n>>k;
	ll i=0;
	long double m=0;
	long double f=1.0,sum=0.0;
	long double x=0;
	for(i=1;i<=n;i++)
	{
		m=i;
		f=1.0;
		while(m<k)
		{
			m=2*m;
			x++;
		}
		sum+=pow(0.5,x);
		x=0;
	}
	sum=sum/n;
	cout<<fixed<<setprecision(12)<<sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
#define PB push_back
#define POP pop_back()
#define PII pair<int,int>
#define FI first
#define SE second
#define ULL unsigned long long
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-11;
const int maxn=2e5+10;
ll a[15][15];
ll c[15];
int main()
{
	ll n,m,x;
	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];
		}
	}	
	ll ans=INF;
	ll tmp=1<<n;
	ll cnt[15];
	for(int i=0;i<tmp;i++){
		for(int j=0;j<m;j++)cnt[j]=0;
		ll tt=i,cc=0,pr=0;
		while(tt){
			if(tt%2==1){
				for(int j=0;j<m;j++){
					cnt[j]+=a[cc][j];
				}
				pr+=c[cc];
			}
			cc++;
			tt/=2;
		} 
		int flag=1;
		for(int j=0;j<m;j++){
			if(cnt[j]<x){
				flag=0;
				break;
			}
		}
		if(flag){
			ans=min(ans,pr);
		}
	}
	if(ans!=INF)cout<<ans<<endl;
 	else cout<<-1<<endl;
	return 0;
}







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

int main( void ) {
    
    int x, y;
    cin >> x >> y;
    
    if( x == 2 )
        x = 1;
    else
    if( x == 4 || x == 6 || x == 9 || x == 11 )
        x = 2;
    else
        x = 3;
    
    if( y == 2 )
        y = 1;
    else
    if( y == 4 || y == 6 || y == 9 || y == 11 )
        y = 2;
    else
        y = 3;
    
    if( x == y )
        cout << "Yes";
    else
        cout << "No";
    
    return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
bool cmp(PII x,PII y){
    return x.S-y.F<y.S-x.F;
}
int main(){
    int N;
    R(N);
    VPII add,sub;
    REP(i,N){
        string s;
        R(s);
        int mi=0,now=0;
        for(char c:s){
            if(c=='(')now++;
            else {
                now--;
                mi=min(mi,now);
            }
        }
        if(now>=0)add.PB(MP(-mi,now));
        else sub.PB(MP(-mi,now));
    }
    sort(ALL(add));
    sort(ALL(sub),cmp);
    int now=0;
    REP(i,SZ(add)){
        if(add[i].F>now){
            W("No");
            return 0;
        }
        now+=add[i].S;
    }
    for(int i=SZ(sub)-1;i>=0;i--){
        if(sub[i].F>now){
            W("No");
            return 0;
        }
        now+=sub[i].S;
    }
    if(now)W("No");
    else W("Yes");
    return 0;
}


Measured memory_bytes: 11408
/*

  _|_|                              _|  _|    _|
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|
_|    _|  _|_|          _|          _|  _|_|
_|    _|  _|          _|      _|    _|  _|  _|
  _|_|    _|        _|_|_|_|    _|_|    _|    _|

*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
int ans[1005][1005];
int main(){
    ios::sync_with_stdio(0);
    int k;
    cin>>k;
    int mx=500,need=k-mx;
    if(k<=mx){
        cout<<k<<endl;
        rep(i,1,k){
            rep(j,1,k)cout<<i<<' ';
            cout<<endl;
        }
        return 0;
    }
   /* int sz;
    if(k&1){
        sz=k/2+1;
        rep(i,1,sz)rep(j,1,sz)ans[i][j]=k;
    }
    else{
        sz=k/2;
        rep(i,1,sz)rep(j,1,sz)ans[i][j]=(j&1)?k:(k-1);
    }
    int cnt=0;
    for(int i=sz;i>1;i--){//枚举行
        int bk1=++cnt,bk2=++cnt,s1=bk1,s2=bk2;
        for(int x=i,y=1;x<=sz&&y<=sz;x++,y++)ans[x][y]=s1,swap(s1,s2);
        s1=bk2,s2=bk1;
        for(int x=1,y=sz-i+2;x<=sz&&y<=sz;x++,y++)ans[x][y]=s1,swap(s1,s2);
    }
    rep(i,1,sz){
        rep(j,1,sz)cout<<ans[i][j]<<' ';
        cout<<endl;
    }*/
   int cnt=0;
    cout<<"500"<<endl;
   rep(i,1,need){
        cnt++;
        int nx=i;
        rep(ny,1,mx){
            ans[nx][ny]=(ny&1)?cnt:(cnt+1);
            nx++;if(nx>mx)nx=1;
        }
        cnt++;
    }
    rep(i,need+1,mx){
        cnt++;
        int nx=i;
        rep(ny,1,mx){
            ans[nx][ny]=cnt;
            nx++;if(nx>mx)nx=1;
        }
   }
    rep(i,1,mx){rep(j,1,mx)cout<<ans[i][j]<<' ';cout<<endl;}
    return 0;
}

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

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

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    string s;cin>>s;
    bool jdg=true;
    int cnt=0;

    if(s[0]!='A'){
        cout<<"WA"<<endl;
        return 0;
    }

    rep2(i,1,s.size()){
        if(isupper(s[i])){
            if(s[i]=='C'&&i!=0&&i!=1&&i!=s.size()-1){
                cnt++;
            }
            else {
                jdg=false;
            }
        }
    }

    if(jdg&&cnt==1){
        cout<<"AC"<<endl;
        return 0;
    }
    cout<<"WA"<<endl;
}


Measured memory_bytes: 256