akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int N; cin >> N;
    int zoro = 0;
    REP(_,N) {
        int a,b;
        cin >> a >> b;
        if (a == b) {
            zoro++;
            if (zoro >= 3) {
                cout << "Yes" << endl;
                return;
            }
        } else zoro = 0;
    }
    cout << "No" << endl;
}

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

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

#define MAX 120
char a[MAX][MAX];
int b[MAX][MAX];
int c[MAX][MAX];

signed main() {
	int N, M, D; cin >> N >> M >> D;
	rep(i, 0, N)rep(j, 0, M)cin >> a[i][j];
	rep(i, 0, N) {
		rep(j, 1, M) {
			if (a[i][j - 1] == '.'&&a[i][j] == '.')b[i][j] = b[i][j - 1] + 1;
		}
	}
	rep(j, 0, M) {
		rep(i, 1, N) {
			if (a[i - 1][j] == '.'&&a[i][j] == '.')c[i][j] = c[i - 1][j] + 1;
		}
	}
	int ans = 0;
	rep(i, 0, N)rep(j, 0, M) {
		if (b[i][j] + 1 >= D)ans++;
		if (c[i][j] + 1 >= D)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3204
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int A1 = Integer.parseInt(sc.next());
        int A2 = Integer.parseInt(sc.next());
        int A3 = Integer.parseInt(sc.next());
        sc.close();

        int A12 = Math.abs(A1 - A2);
        int A13 = Math.abs(A1 - A3);
        int A23 = Math.abs(A2 - A3);
        int min = Integer.MAX_VALUE;
        // A1
        if (A12 + A23 < min) {
            min = A12 + A23;
        }
        if (A13 + A23 < min) {
            min = A13 + A23;
        }
        // A2
        if (A12 + A13 < min) {
            min = A12 + A13;
        }
        if (A23 + A13 < min) {
            min = A23 + A13;
        }
        // A3
        if (A13 + A12 < min) {
            min = A13 + A12;
        }
        if (A23 + A12 < min) {
            min = A23 + A12;
        }
        out.printf("%d\n", min);
        out.flush();
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
#define INF 1000000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll 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;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x, y;
	cin >> x >> y;
	if (x < y)swap(x, y);
	cout << gcd(x, y) << endl;
	return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define per(i,a,b) for(int i=(a);i>=(int)(b);i--)
const int mod = 1e9+7;
const int maxn = 3e5+10;
const int inf = 0x3f3f3f3f;
map<pii,bool> vis;
int a[maxn],b[maxn];
int main()
{
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int h,w,m;
    cin>>h>>w>>m;
    rep(i,1,m) {
        int x,y;
        cin>>x>>y;
        a[x]++;
        b[y]++;
        vis[{x,y}]=true;
    }
    vi hm,wm;
    int Max=0;
    int ans=0;
    rep(i,1,h) if(a[i]>Max) Max=a[i];
    rep(i,1,h) if(a[i]==Max) hm.pb(i);
    ans+=Max;
    Max=0;
    rep(i,1,w) if(b[i]>Max) Max=b[i];
    rep(i,1,w) if(b[i]==Max) wm.pb(i);
    ans+=Max;
    ans--;
    bool f=false;
    for(int x:hm) {
        for(int y:wm) {
            if(!vis[{x,y}]) {
                ans++;
                f=true;
                break;
            }
        }
        if(f) break;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 28488
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int N;
string s[300];

bool check(int k){
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(s[i][j]!=s[(j+N+k)%N][(i+N-k)%N]) return false;
        }
    }
    return true;
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> s[i];
    }
    LL ans=0;
    for(int k=-(N-1);k<N;k++){
        if(check(k)){
            ans+=N-abs(k);
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

#define pb push_back
#define mp make_pair

const int N = 1e5 + 10;
int n, m;
struct Job{
    int a, b;
    void read(){
        scanf("%d %d", &a, &b);
    }
    bool operator < (const Job &A)const{
        return b > A.b;
    }
}s[N];
set<int> ST;
set<int>::iterator it;

int main(){
    scanf("%d %d", &n, &m);
    for(int i=0; i<n; i++)  s[i].read();
    sort(s, s+n);
    LL ans = 0;

    for(int i=0; i<m; i++){
        ST.insert(i);
    }
    int g;

    for(int i=0; i<n && !ST.empty(); i++){
        g = m - s[i].a;
        if(g < 0)   continue;
        it = ST.upper_bound(g);
        if(it == ST.begin()){
            continue;
        }
        it--;
        ans = ans + s[i].b;
        ST.erase(it);
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 5760
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	long[][] comb = new long[3001][3001];
	long M;
	int N;

	void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextLong();
		// f(K,X)=K個から非空かつdisjointな集合をx個、選ぶ方法
		// f(K,X)=f(K-1,X)*K+f(K-1,X-1)+1
		long[][] f = new long[N + 1][N + 1];
		f[0][0] = 1;
		for (int i = 1; i <= N; ++i) {
			for (int j = 0; j <= i; ++j) {
				f[i][j] = f[i - 1][j] * (j + 1) + (j - 1 >= 0 ? f[i - 1][j - 1] : 0);
				f[i][j] %= M;
			}
		}
		comb[0][0] = 1;
		for (int i = 1; i < comb.length; ++i) {
			for (int j = 0; j <= i; ++j) {
				comb[i][j] = (j > 0 ? comb[i - 1][j - 1] : 0) + comb[i - 1][j];
				comb[i][j] %= M;
			}
		}

		long ans = 0;
		for (int i = 0; i <= N; ++i) {
			long sum = 0;
			for (int k = 0; k <= i; ++k) {
				sum += f[i][k] * pow(2, (N - i) * k, M) % M;
				sum %= M;
			}
			ans += (i % 2 == 0 ? 1 : -1) * pow(2, pow(2, N - i, M - 1), M) % M * sum % M * comb[N][i] % M;
			ans = (ans + M) % M;
		}
		System.out.println(ans);
		// comb(N,i)g(i)(-1)^i
		// g(i)=2^2^(N-i) * sum_k f(i,k)2^((n-i)k)
		// (),(A),(B),(AB),(A,B),(AB,A,B),(AB,A),(AB,B) 2^(2^2-1)=2^3=8 - (A,AB),(B,AB)

	}

	long pow(long a, long n, long mod) {
		long ret = 1;
		a %= mod;
		for (; n > 0; n >>= 1, a = a * a % mod) {
			if (n % 2 == 1) {
				ret = ret * a % mod;
			}
		}
		return ret;
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 182604
#include<stdio.h>


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

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

int main (void){
	
	int n,minv=0,maxv=-1000000001,i;
	int r[200001]={0};
	scanf("%d",&n);
	
	scanf("%d",&r[0]);
	minv = r[0];
	for(i=1;i<n;i++){
		scanf("%d",&r[i]);
		
		maxv =large(maxv,r[i]-minv);
		minv =small(minv,r[i]);
	}
	
		printf("%d\n",maxv);
	
return 0;
}

Measured memory_bytes: 1388
N,M = map(int,input().split())
ls2 = []
for i in range(M):
    A,B = map(str,input().split())
    ls = [int(A)-1,B]
    ls2.append(ls)

Pena = 0
corr = 0

#ls3 = sorted(ls2, key=lambda x: x[0])
lsans = [[] for i in range(N)]
for i in range(M):
    lsans[ls2[i][0]].append(ls2[i][1])

for i in range(N):
    if 'AC' in lsans[i]:
        for ans in lsans[i]:
            if ans == 'WA':
                Pena += 1
            if ans == 'AC':
                corr += 1
                break
print(corr,Pena)

Measured memory_bytes: 105632
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#define f(i,n) for(int i=0;i<n;i++)
#define mod 1e9+7
#define chk(d) cout<<d<<endl
using namespace std;


int main()
{ long int n,m,k;
  cin>>n>>k;
  vector<long int>v;
  f(i,n)
  {
     long int a;
      cin>>a;
      v.push_back(a);
  }
long  int dp[n+3];
  f(i,n)dp[i]=mod;
  dp[0]= 0;
   // dp[1] = abs(v[1]-v[0]);
  for(int i = 0;i<n;i++)
  {   for(int j=1;j<=k;j++)
     if(i+j<n)dp[i+j] = min(dp[i]+abs(v[i+j]-v[i]), dp[i+j]);
     // dp[i+1] = min(dp[i]+abs(v[i-1]-v[i+1])-abs(v[i]-v[i-1]),dp[i+1]);

  }
// f(i,n)cout<<dp[i]<<" ";
 cout<<dp[n-1];

}



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

int main(void){
	int alphabet[26];
	for(int i = 0; i < 26; i++)alphabet[i] = 0;
	char s;
	while(true){
		if(scanf("%c",&s) == EOF) break;
		else if(65 <= s&&s <= 90)alphabet[s-65]++;
		else if(97 <= s&&s <= 122)alphabet[s-97]++;
		else continue;
	}
	char c = 'a';
	for(int i = 0; i < 26; i++){
		cout << (char)(c+i) <<" : "<<alphabet[i]<<endl;
	}
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;

#define mod             1000000007
#define what_is(x)      cerr<<#x<<" is "<<x<<"\n";
#define read(x)         freopen("in.txt","r",stdin);
#define write(x)        freopen("out.txt","w",stdout);
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define sz              3000005

int main(){
    Fast;///using Fast I/O
    int a,b,c, i,j,k, t,n,m;

    cin>>a>>b>>c>>k;

    while(k && a>=b){
        k--;
        b=b*2;
    }

    while(k && b>=c){
        k--;
        c=c*2;
    }


    if(a<b && b<c){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }








    return 0;
}



Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX 1e7
int sx[] = {0,0,-1,1};
int sy[] = {1,-1,0,0};
int my[] = {0,0,1,1,1,-1,-1,-1};
int mx[] = {1,-1,0,1,-1,0,1,-1};
int lx[] = {0,0,0,0,1,1,1,2,-1,-1,-1,-2};
int ly[] = {1,-1,2,-2,0,1,-1,0,0,-1,1,0};
int  main(){
    
    vvi v(12,vi(12,0));
    vi x(100,0); vi y(100,0); vi ink(100,0);
    int i =0; char c,d;
    while(cin >> x[i] >>c>>y[i] >>d >> ink[i]){
        v[y[i]][x[i]]+=1;
        if(ink[i] == 1){
            rep(j,4){
                int tx =x[i]+sx[j]; int ty = y[i]+sy[j];
                if(0<=tx && tx<10 && 0<=ty && ty<10)
                    v[ty][tx]+=1;
            }
        }else if(ink[i] == 2){
            rep(j,8){
                int tx =x[i]+mx[j]; int ty = y[i]+my[j];
                if(0<=tx && tx<10 && 0<=ty && ty<10)
                    v[ty][tx]+=1;
                }
        }else if(ink[i] == 3){
                rep(j,12){
                    int tx =x[i]+lx[j]; int ty = y[i]+ly[j];
                    if(0<=tx && tx<10 && 0<=ty && ty<10)
                        v[ty][tx]+=1;
                }
        }
        i++;
    }
        int ans1 = -INF; int ans2 = 0;
        rep(i,10) rep(j,10){
            ans1 = max(ans1,v[i][j]);
            if(v[i][j]  == 0)
                ans2++;
        }
    cout << ans2<< endl;
    cout << ans1<< endl;
        
    return 0;
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

/*
map<ll,ll> dp;
ll a;

ll solve(ll n)
{
	if(n==1) return 0;
	if(n==2) return 1;
	if(dp[n]!=0) return dp[n];
	ll x = floor(sqrt(n)) + 1;
	ll ans = n - 1;
	for(ll i = 2; i <= x; i++)
	{
		ans = min(ans, solve((n+i-1)/i) + a + i);
	}
	for(ll i = 2; i <= x; i++)
	{
		ll y = (n+i-1)/i;
		if((n+y-1)/y != i) continue;
		ans = min(ans, (n+i-1)/i + a + solve(i));
	}
	dp[n] = ans;
	return ans;
}
*/

const ll INF = ll(1e15);

ll mult(ll a, ll b)
{
	if(a > INF/b) return INF;
	else return a*b;
}

ll power(ll a, ll b)
{
	ll r = 1;
	while(b)
	{
		if(b&1)
		{
			r = mult(r,a);
		}
		a = mult(a,a);
		b>>=1;
	}
	return r;
}

ll a;
ll solve(ll t)
{
	ll ans = t;
	for(ll i = 1; (a*i < t && i <= 50); i++)
	{
		ll remtime = t - a*i;
		if(remtime <= i) continue;
		ll mod = remtime%(i+1);
		ll up = (remtime)/(i+1);
		//cerr<<t<<' '<<remtime<<' '<<i+1<<' '<<mod<<' '<<up<<'\n';
		ans = max(ans, mult(power(up+1,mod),power(up,i+1-mod)));
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n;
	cin>>n>>a;
	//cout<<solve(n)+1<<'\n';
	ll lo = 1; ll hi = n;
	ll ans = 0;
	while(lo<=hi)
	{
		ll mid = (lo+hi)>>1;
		//cerr<<mid<<' '<<solve(mid)<<'\n';
		if(solve(mid)>=n)
		{
			ans=mid;
			hi=mid-1;
		}
		else
		{
			lo=mid+1;
		}
	}
	cout<<ans<<'\n';
}


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

int main() {
  int X;
  cin >> X;
  int N;
  cin >> N;
  
  int min = INF, num, def;
  vector<int> p(102);
  rep(i,102) {p.at(i) = 0;} 
  int a;
  rep(i,N) {cin >> a; p.at(a) = 1;} 
  rep(i,102) {
    if(p.at(i)==1) continue;
    
    def = abs(i-X);
    
    if(min > def){
      min = def;
      num = i;
    }
  }
  
  cout << num << endl;
  
}


Measured memory_bytes: 3600
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

const int MOD = 1e9 + 7;

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

  int n; cin >> n;
  string s; cin >> s;

  int64 cnt[26] = {};

  for (auto c : s){
    ++cnt[c - 'a'];
  }

  int64 ans = 1;

  for (int i = 0; i < 26; ++i){
    ans *= cnt[i] + 1;
    ans %= MOD;
  }

  print(ans - 1);

  return 0;
}

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

#define ll long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int c=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i])
        c++;
    }
    cout<<c;
    return 0;
}


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

using namespace std;

#define int long long

vector<int> graph[200005];
void add_edge(int u, int v)
{
    graph[u].push_back(v);
    graph[v].push_back(u);
}

// Function to traverse the undirected graph
// using DFS algorithm and keep a track of
// individual lengths of connected chains
void depthFirst(int v, vector<int> graph[],
                vector<bool>& visited, int& ans)
{
    // Marking the visited vertex as true
    visited[v] = true;

    // Incrementing the count of
    // connected chain length
    ans++;

    for (auto i : graph[v]) {
        if (visited[i] == false) {
            // Recursive call to the DFS algorithm
            depthFirst(i, graph, visited, ans);
        }
    }
}

// Function to initialize the graph
// and display the result
int UniqueConnectedComponent(int n,
                              vector<int> graph[])
{
    int mx = -1 ;

    // Initializing boolean visited array
    // to mark visited vertices
    vector<bool> visited(n + 1, false);

    // Initializing a Set container
    unordered_set<int> result;

    // Following loop invokes DFS algorithm
    for (int i = 1; i <= n; i++) {
        if (visited[i] == false) {
            // ans variable stores the
            // individual counts
            int ans = 0;

            // DFS algorithm
            depthFirst(i, graph, visited, ans);

            // Inserting the counts of connected
            // components in set
            result.insert(ans);
            mx = max (mx,ans);
        }
    }
    return mx ;
}
int32_t  main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >>a>>b;
        add_edge(a,b);
    }
    cout << UniqueConnectedComponent(n,graph);
    return 0;
}

Measured memory_bytes: 26916
//SomethingonIt.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int price=700;
        for(int i=0;i<3;i++){
            if(s.charAt(i)=='o'){
                price+=100;
            }
        }
        System.out.println(price);
        sc.close();
    }
}

Measured memory_bytes: 24276
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=100005;
int n,m;
vi g[M];
priority_queue<int> q;

int main(){
	cin>>m>>n;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
	}
	int t=0;
	for(int i=n;i>0;i--){
		for(auto j:g[n-i+1]) q.push(j);
		if(!q.empty()){
			t+=q.top();
			q.pop();
		}
	}
	cout<<t<<endl;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t N,A,B; cin>>N>>A>>B;

    int64_t ans;
    if((B-A)%2){
        ans=min(A-1,N-B)+1;
        ans+=(B-A-1)/2;
    }else{
        ans=(B-A)/2;
    }

    cout<<ans<<endl;
}

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

int main(){
  ll n; cin >> n;
  
  ll ans;
  for(ll i=0; i<=sqrt(n); i++){
    if(i*i <= n)
      ans = i*i;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

bool DEBUG=0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	char c; cin>>c;
	if(isupper(c)) cout<<'A';
	else cout<<'a';
	
	return 0;
}


Measured memory_bytes: 3656
A = int(input())
B = int(input())
C = int(input())
X = int(input())

n=0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a+100*b+50*c == X:
                n += 1
                
print(n)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1, i##_end_ = (n); i <= i##_end_; ++i)
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

#define gc() getchar()
template<typename T> void read(T &x){
    x = 0; int f = 1; char ch = gc();
    while(!isdigit(ch) ) { if(ch == '-') f = -1; ch = gc();}
    while( isdigit(ch) ) {x = x * 10 + ch - 48; ch = gc();}
    x *= f;
}
template<typename T, typename... Args> void read(T& x, Args&... args)
{ read(x), read(args...); }
template<typename T> void write(T x) {
    if(x < 0) putchar('-'), write(-x);
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

const int maxs = (1 << 21) + 1, maxn = 555555;
int last[maxs], a[maxn], n, xs[maxn], zero[maxn], nxt[maxn], dp[maxn][2];
bool vis[maxn];

const int MOD = 1000000007;
int muln(int x, int y) { return 1LL * x * y % MOD; }
int qpow(int x, int y) {
    int ret = 1;
    for(; y; y >>= 1, x = muln(x, x))
        if(y & 1) ret = muln(ret, x);
    return ret;
}
int mo(int x) { if(x >= MOD) x -= MOD; if(x < 0) x += MOD; return x; }

int main() {
    #ifdef FREOPEN
        freopen("in.txt", "r", stdin);
        // freopen("out.txt", "w", stdout);
    #endif
    scanf("%d", &n);
    fill(nxt, nxt + n + 1, n + 10);
    rep(i, n) read(a[i]);
    rep(i, n) {
        xs[i] = xs[i - 1] ^ a[i];
        zero[i] = zero[i-1] + (xs[i] == 0);
        if(last[xs[i]]) nxt[last[xs[i]]] = i;
        last[xs[i]] = i;
    }

    int ans = 0;
    if(xs[n]==0) ans = qpow(2, zero[n]-1);
    rep(i, n) if(!vis[i] && xs[i] != 0) {
        if(xs[n]==0 || xs[n] == xs[i]) {
            // printf("\nRUN from %d, xor sum = %d: \n", i, xs[i]);

            int p = i;
            vis[p] = true;
            dp[p][1] = 1;
            while(p <= n) {
                if(p == n) {
                    ans = mo(ans + dp[p][0]);
                    ans = mo(ans + dp[p][1]);
                    vis[n] = true;
                    break;
                } else {
                    if(nxt[p] > n) {
                        if(xs[n]==0) ans = mo(ans + dp[p][1]);
                        else ans = mo(ans + dp[p][0]);
                        break;
                    } else if(nxt[p] == n)  {
                        int zr = zero[n] - zero[p];
                        dp[n][1] = mo(muln(zr,dp[p][1]) + dp[p][0] + 1);
                        ans = mo(ans + dp[n][1]);
                        vis[n] = true;
                        break;
                    } else {
                        int np = nxt[p], zr = zero[np] - zero[p];
                        dp[np][0] = mo(dp[p][0] + muln(dp[p][1], zr));
                        dp[np][1] = mo(muln(zr+1,dp[p][1]) + dp[p][0] + 1);
                        p = np;
                        // printf("> dp[%d]: {%d, %d}\n", p, dp[p][0], dp[p][1]);
                        vis[p] = true;
                    }
                }
            }

            // printf("Answer updated to %d\n", ans);
        } else {
            int p = i;
            while(p <= n) vis[p] = true, p = nxt[p];
        }
    }
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 18560
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A = list(map(int, input().split()))

d = dict()
for elem in A:
    if elem not in d:
        d[elem] = 1
    else:
        d[elem] = d[elem] + 1

std = sorted(d.values())
if len(std) <= K:
    print(0)
else:
    print(sum(std[0:len(std)-K]))


Measured memory_bytes: 32184
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

ll a[100010];

int main(){
  ll n;cin>>n;
  rep(i,n)cin>>a[i];
  ll sum = 0;
  rep(i,n) sum+=a[i];
  ll ral = n*(n+1)/2;
  if(sum%ral!=0) {
    cout<<"NO"<<endl;
    return 0;
  }
  ll num = sum/ral;
  ll cnt=0;
  rep(i,n) {
    ll b = a[(i+1)%n]-a[i]-num;
    if(b%n!=0 || b>0) {
      cout<<"NO"<<endl;
      return 0;
    } else {
      cnt += ((-1)*b)/n;
    }
  }
  if(cnt==num) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

signed main() {
    SPEED;
    
     int n;
    cin >> n;
    
    int arr[n];
    
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    
    for (int i = 0; i < n; i++) {
        if (arr[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    
    int product = 1;
    
    for (int i = 0; i < n; i++) {
        if (arr[i] <= 1000000000000000000/product) {
            product*=arr[i];
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << product << endl;
    
    return 0;
    
}

Measured memory_bytes: 4428
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

//価値が小さくて重さがデカイKnapsack DP
/*
v[i]<10^3
w[i]<10^9
今回は重みがバカでかいのでdpが持つのが重みにしないと終わらない。
dp[v]がもつのはその価値を達成するのに必要最低限な重み
v[i]をどう組み合わせてもvを達成できないならLINFがdpにずっとはいりっぱ
なので、最後上から見ていって初めて重みが目標以下になったところが答え

なんで上から走査するん？？
→更新が無限に続いちゃうからだろバカか？
→個数制限なしのときはそれで下まで埋めればいいのか天才じゃん
 */

int main(){
    ll N,W;
    cin>>N>>W;
    vector<ll> w(N),v(N);
    rep(i,N)    cin>>w[i]>>v[i];
    vector<ll> dp(100001,LINF);
    dp[0]=0;
    rep(i,N){
        for(int j=100000;j>=0;j--){
            if(dp[j]==LINF)   continue;
            dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
        }
    }
    ll ans=0;
    for(ll i=100000;i>=0;i--){
        if(dp[i]<=W){ans=i;break;}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int m,f,r;
    char i;
    while(1){
        cin>>m>>f>>r;
        if(m==-1||f==-1){i='F';}
        else if(m+f>=80){i='A';}
        else if(m+f>=65&&m+f<=79){i='B';}
        else if(m+f>=50&&m+f<=64){i='C';}
        else if(m+f>=30&&m+f<=49){if(r>=50){i='C';}else{i='D';}}
        else if(m+f<=29){i='F';}
        if(m==-1&&f==-1&&r==-1){break;}
        cout<<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0; i<n; ++i)

void func(int, int);
void f(int, int);

char s[51][51];
int a[51][51] = {};

int h, w;

int main() {

  cin >> h >> w;
  rep(i, h) {
    rep(j, w) cin >> s[i][j];
  }

  rep(i, h) {
    rep(j, w) {
      if(s[i][j]=='#') func(i, j);
    }
  }

  rep(i, h) {
    rep(j, w) {
      if(a[i][j] != -1)
        cout << a[i][j];
      else
        cout << '#';
    }
    cout << endl;
  }

  return 0;
}

void func(int y, int x) {
  a[y][x] = -1;

  if(y-1 >= 0) {
    f(y-1, x);
    if(x-1 >= 0)
      f(y-1, x-1);
    if(x+1 < w)
      f(y-1, x+1);
  }

  if(x-1 >= 0)
    f(y, x-1);
  if(x+1 < w)
    f(y, x+1);

  if(y+1 < h) {
    f(y+1, x);
    if(x-1 >= 0)
      f(y+1, x-1);
      if(x+1 < w)
      f(y+1, x+1);
  }

}

void f(int y, int x) {
  if(s[y][x] != '#')
    a[y][x] += 1;
}


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

using namespace std;

#define MODULE 1000000007
#define MP make_pair

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9
const int MAXN = 100001;

/*struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/

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

int t;
int n[1001];
unsigned char d[1001];

int main(){
    ios::sync_with_stdio(false);
    scanf("%d",&t);
    for (int i = 0; i < t; ++i) {
        scanf("%d%d",&n[i],&d[i]);
        //cin>>n[i]>>d[i];
    }
    for (int i = 0; i < t; ++i) {
        if(n[i]==1){
            printf("%d\n",d[i]);
        }else if(n[i]%2==1) {
            printf("%d\n",d[i] + 127 * (n[i] - 1));
        }else{
            printf("%d\n",127*(n[i]-1)+(~d[i]&0b01111111));
        }
    }
}

Measured memory_bytes: 384
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

namespace Doubling{
  static const int N = 101010;
  int t[N] , wa[N] , wb[N] , sa[N] , h[N];
  void sort(int *x,int *y,int n,int m){
    rep(i,0,m) t[i] = 0;
    rep(i,0,n) t[x[y[i]]]++;
    rep(i,1,m) t[i] += t[i-1];
    per(i,0,n) sa[--t[x[y[i]]]] = y[i];
  }
  bool cmp(int *x,int a,int b,int d){
    return x[a] == x[b] && x[a+d] == x[b+d];
  }
  void da(int *s,int n,int m){
    int *x=wa,*y=wb;
    rep(i,0,n) x[i] = s[i] , y[i] = i;
    sort(x , y , n , m);
    for(int j=1,p=1;p<n;m=p,j<<=1){
      p = 0;rep(i,n-j,n) y[p++] = i;
      rep(i,0,n) if(sa[i] >= j) y[p++] = sa[i] - j;
      sort(x , y , n , m);
      swap(x , y);p = 1;x[sa[0]] = 0;
      rep(i,1,n) x[sa[i]] = cmp(y,sa[i],sa[i-1],j)?p-1:p++;
    }
  }
  void cal_h(int *s,int n,int *rk){
    int j,k=0;
    for(int i=1;i<=n;++i) rk[sa[i]] = i;
    for(int i=0;i<n;h[rk[i++]] = k)
      for(k&&--k,j=sa[rk[i]-1];s[i+k]==s[j+k];++k);
  }
}
static const int N = 101010;
int rk[N] , in[N] , Log[N] , n;

int main(){
  string s;
  cin >> s;
  n = sz(s);
  rep(i,0,n) in[i] = s[i];
  in[n] = 0;
  Doubling::da(in,n+1,300);
  Doubling::cal_h(in,n,rk);
  vi height;
  rep(i,1,n+1) height.pb(Doubling::h[i]);
  sort(all(height));
  int ans = 0 , cur = 0 , sum = 0;
  rep(i,0,n) {
    while(cur < sz(height) && height[cur] == i)
      ++cur , sum++;
    ans = max(ans , sum);
    sum--;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int M,D;
    cin >> M >> D;
    int count = 0;

    for(int i=1; i<=M; ++i){
        for(int j=22; j<=D; ++j){
            if(j%10>=2 && j/10>=2){
                if((j%10)*(j/10) == i) count++;
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 384
a,b,c=map(int, input().split())
S=[a,b,c]
s=sorted(S,key=abs)
M=max(S,key=abs)
m=min(S,key=abs)
n=s[1]
if abs(a==b==c):
	print(0)
else:
	print(abs(n-m)+abs(M-n))

Measured memory_bytes: 3064
from collections import deque

N, M, Q = map(int, input().split())
queries = [list(map(int, input().split())) for _ in range(Q)]
patterns = []

ptn = deque([])
for i in range(M):
  ptn.append([i])
while len(ptn) > 0:
  p = ptn.pop()
  if len(p) < N:
    for i in range(p[-1], M):
      ptn.append(p+[i])
  else:
    patterns.append(p)
answer = 0
for p in patterns:
  point = 0
  for a, b, c, d in queries:
    if p[b-1]-p[a-1] == c:
      point += d
  answer = max(answer, point)
print(answer)
      

Measured memory_bytes: 95644
n = int(input())
al = list(map(int, input().split()))

# n0, n1, n2 = 0, 0, 0

# def how_many_dev_by_2(x, cnt=0):
#     if x%2 == 0:
#         x /= 2
#         cnt += 1
#         return how_many_dev_by_2(x, cnt)
#     else:
#         return cnt
#
# for a in al:
#     a_cnt = how_many_dev_by_2(a)
#     if a_cnt == 0:
#         n0 += 1
#     elif a_cnt == 1:
#         n1 += 1
#     else:
#         n2 += 1
#
# if n2 + 1 >= n0 + n1//2:
#     print('Yes')
# else:
#     print('No')

n0, n2, n4 = 0, 0, 0

for a in al:
    if a % 4 == 0:
        n4 += 1
    elif a % 2 == 0:
        n2 += 1
    else:
        n0 += 1

print('Yes' if n4+1 >= n0+n2%2 else 'No')

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

using namespace std;

int main()
{
	int a, b, c;
	int x, y;
	cin >> a >> b >> c >> x >> y;
	int ans = 0;
	int needBoth = min(x, y);
	int needA = x - needBoth;
	int needB = y - needBoth;

	if(needBoth > 0){
		if(a+b < 2*c) ans += needBoth * (a+b);
		else ans += needBoth * 2 * c;
	}
	if(needA > 0){
		if(a < 2*c) ans += needA * a;
		else ans += needA * 2 * c;
	}
	if(needB > 0){
		if(b < 2*c) ans += needB * b;
		else ans += needB * 2 * c;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int a = 0, b = 0, i = 0,j = 0, k =0;
    for(k=0 ;; k++){
        cin >> a >> b;
        if((a==0)||(b==0))break;

        for(i = 0; i < a; i++){
            for(j = 0; j < b; j++){
                if((i+j)%2==0){cout<<'#';}
                else {cout<<'.';}
            }
            cout << endl;
        }

        cout << endl;
    }

}

Measured memory_bytes: 1152
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextLong();
            var v = cin.nextLong();
            var b = cin.nextLong();
            var w = cin.nextLong();
            var t = cin.nextLong();

            var dx = v - w;
            if (a <= b)
            {
                var sa = b - a;
               
                Console.WriteLine(sa-(dx*t)<=0?"YES":"NO");
            }
            else
            {
                var sa = a - b;
                Console.WriteLine(sa- (dx * t) <= 0 ? "YES" : "NO");
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
int N, K;
int main(){
    cin >> N >> K;
    double result = 0.0;
    for(int i = 1; i <= N; i++){
        double curr_p = 1.0 / N;
        int curr_s = i;
        while(curr_s < K){
            curr_p *= 0.5;
            curr_s *= 2;
        }
        result += curr_p;
    }
    cout <<fixed << setprecision(15) << result << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#include <iomanip>
using namespace std;
    
//#define __int64 long long
//#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

long double w,h,x,y;
int main(){
    cin >> w >> h >> x >> y;

    long double S = h * w / 2.0;
    int multi = (w/2.0==x && h/2.0==y ? 1 : 0);

    //printf("%.16f", S);
    cout << fixed;
    cout << setprecision(30) << S;
    cout << " " << multi << endl;
        
}

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

using namespace std;

int main() {
    int h, n;
    cin >> h >> n;
    
    vector<int> a(n);
    vector<int> b(n);
    vector<int> dp(h+1);
     
    for (int i=0; i < n; i++) {
        cin >> a.at(i) >> b.at(i);
    }
    

    for (int i=1; i<=h; i++) {
        dp.at(i) = 1e9;

        for (int j=0; j<n; j++) {
            dp.at(i) = min(dp.at(i), dp.at(max(0, i - a[j])) + b[j]);
        }
    }

    int ans = dp[h];

    cout << ans << endl;


    return 0;

}



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

int main() {
  string s, t; cin >> s >> t;
  int cnt = 0;
  rep(i, s.size()) {
    if (s[i] != t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3916
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

double fact(double N) {
    if(N == 0)
        return 1;
    return fact(N - 1) * N;
}

int main() {
    int N;
    cin >> N;
    using pdd = pair<double, double>;
    vector<pdd> A(N);
    rep(i, N) {
        double x, y;
        cin >> x >> y;
        A[i] = MP(x, y);
    }
    double sum = 0;
    sort(All(A));
    do {
        double dist = 0;
        for(int i = 1; i < N; i++) {
            dist += sqrt((A[i].first - A[i - 1].first) *
                             (A[i].first - A[i - 1].first) +
                         (A[i].second - A[i - 1].second) *
                             (A[i].second - A[i - 1].second));
        }
        // rep(i, N) { cout << A[i].first << " " << A[i].second << endl; }

        // cout << endl << endl;
        // cout << dist << endl;
        sum += dist;
    } while(next_permutation(All(A)));
    // cout << fact((double)N) << endl;
    cout << fixed << setprecision(10) << sum / fact((double)N) << endl;

    return 0;
}

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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;




void one_case() {
    ll x;
    cin >> x;
    if (x == 1) {
        cout << "0 -1\n";
        return;
    }

    for (ll d = 1; d * d <= x; ++d) {
        if (x % d) {
            continue;
        }
        ll a = 0;
        while (true) {
            if (a > 1e4) {
                break;
            }
            auto b = a - d;
            ll sec = a * a * a * a +a * a * a * b + b * b * a * a +  b * b * b * a + b * b * b * b;

//            if (sec < 0 or sec > x) {
//                break;
//            }
            if (d * sec == x) {
                cout << a << " " << b << "\n";
                return;
            }
            ++a;
        }
    }
}

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

    int t = 1;
//    cin >> t;
    while (t--) {
       one_case();
    }

    return 0;
}


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

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a; i<= b; ++i)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define Ld long double

using namespace std;
typedef long long ll;
const int mx = 1001;
int a[mx];
vector<int> v;

int main(){
    optimize();
    string s,t;
    cin>>s>>t;
    int n = s.length(),m = t.length();
    int cnt = 0;
    int mn = n;

    for(int i=0; i<=(n-m); i++){
        for(int j=0; j<m; j++){
            if(s[i+j] != t[j]){
                cnt++;
            }
        }
        mn = min(mn,cnt);
        cnt = 0;
    }
    cout<<mn<<endl;
    return 0;
}


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

int data[1 << 23];
int v[1 << 20];
int r, c, q, r1, r2, c1, c2;

template <typename T>
class SegmentTree2 {
	using func_t = function<T(T, T)>;
	const int h, w;
	const T id;
	func_t merge;
	int size(int n) {
		int res;
		for (res = 1; res < n; res <<= 1);
		return res;
	}
	T sub_h(int li, int lj, int ri, int rj, int si, int ti, int k) {
		if (ri <= si || ti <= li) return id;
		if (li <= si && ti <= ri) return sub_w(lj, rj, 0, w, k, 1);
		const int mi = (si + ti) / 2;
		return merge(sub_h(li, lj, ri, rj, si, mi, k * 2), sub_h(li, lj, ri, rj, mi, ti, k * 2 + 1));
	}
	T sub_w(int lj, int rj, int sj, int tj, int i, int k) {
		if (rj <= sj || tj <= lj) return id;
		if (lj <= sj && tj <= rj) return data[i * w * 2 + k];
		const int mj = (sj + tj) / 2;
		return merge(sub_w(lj, rj, sj, mj, i, k * 2), sub_w(lj, rj, mj, tj, i, k * 2 + 1));
	}
public:
	SegmentTree2(int h_, int w_, T id_, func_t merge_) :
		h(size(h_)), w(size(w_)), id(id_), merge(merge_) {
		fill(data, data + (1 << 23), id);
		for (int i = 0; i < h_; i++)
			for (int j = 0; j < w_; j++)
				data[(h + i) * w * 2 + w + j] = v[i * w_ + j];
		for (int i = h * 2 - 1; i >= h; i--)
			for (int j = w - 1; j > 0; j--)
				data[i * w * 2 + j] = merge(data[i * w * 2 + j * 2], data[i * w * 2 + j * 2 + 1]);
		for (int i = h - 1; i > 0; i--)
			for (int j = 1; j < w * 2; j++)
				data[i * w * 2 + j] = merge(data[i * 2 * w * 2 + j], data[(i * 2 + 1) * w * 2 + j]);
	}
	//void Update(int pi, int pj, T val) { }
	//void Add(int pi, int pj, T val) { }
	T Find(int li, int lj, int ri, int rj) {
		return sub_h(li, lj, ri + 1, rj + 1, 0, h, 1);
	}
};

int main()
{
	while (cin >> r >> c >> q, r | c | q) {
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				cin >> v[i * c + j];
			}
		}
		SegmentTree2<int> st2(r, c, INT_MAX, [](int l, int r) { return min(l, r); });
		while (q--) {
			cin >> r1 >> c1 >> r2 >> c2;
			cout << st2.Find(r1, c1, r2, c2) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 39792