akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e5 + 100;
const LL INF = 1e9;

VI g[MX];
bool vis[MX];

void bfs(int s)
{
    int u, v;
    queue<int> q;

    vis[s] = true;
    q.push(s);

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

        for(int i = 0;i < g[u].size(); ++i)
        {
            v = g[u][i];
            if(!vis[v])
            {
                vis[v] = true; q.push(v);
            }
        }
    }
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, m, u, v;
    cin>>n>>m;

    loop(i,0,m)
    {
        cin>>u>>v;
        g[u].PB(v);
        g[v].PB(u);
    }

    int ans = 0;
    loop(i,1,n+1)
    {
        if(!vis[i])
        {
            bfs(i);
            ++ans;
        }
    }

    --ans;
    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 8956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e6+3;
const int N=1e6+10;
int n,k;
ll a[1005];
int f[45][1000005];
int b[1000005];
vector<ll>v;
int main(){
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;i++) scanf("%lld",&a[i]);

    for (int i=1;i<=n;i++)
    {
        ll tmp=0;
        for (int j=i;j<=n;j++)
        {
            tmp+=a[j];
//            c//out<<tmp<<endl;
            v.push_back(tmp);
        }
    }
    for (int i=0;i<v.size();i++)
    {
        for (int j=0;j<42;j++)
        {
            if ((v[i]&((1ll)<<j)))
            {
                f[j][i]=1;
            }
        }
    }
    ll ans=0;
    for (int i=41;i>=0;i--)
    {
        int num=0;
        for (int j=0;j<v.size();j++)
        {
            if (b[j]==0 && f[i][j])
            {
                num++;
            }
        }
        if (num>=k)
        {
            ans+=((1ll)<<i);
            for (int j=0;j<v.size();j++)
            {
                if (b[j]==0 && f[i][j]==0)
                {
                    b[j]=1;
                }
            }
        }
    }

    printf("%lld\n",ans);
}


Measured memory_bytes: 159980
#include <stdint.h>

#include <iostream>
using namespace std;

int main(void) {
  int64_t N;
  cin >> N;
  int64_t a[5];
  for (int64_t i = 0; i < 5; ++i) cin >> a[i];
  int64_t mn = 1000000000000000;

  for (int64_t i = 0; i < 5; ++i) {
    if (a[i] < mn) {
      mn = a[i];
    }
  }
  cout << (N + mn - 1) / mn + 4 << endl;

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	string S;
	cin >> S;
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < S.size(); i++)
	{
		if (i%2 == 0 && S[i] == '0' ||
			i%2 != 0 && S[i] == '1')
			cnt1++;
		if (i%2 == 0 && S[i] == '1' ||
			i%2 != 0 && S[i] == '0')
			cnt2++;
	}
	cout << min(cnt1, cnt2) << endl;
}



Measured memory_bytes: 512
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> dp(n+1,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  dp[0] = 1000;
  for(int i=1;i<=n;i++){
    dp[i] = dp[i-1];
    for(int j=0;j<i;j++){
      ll val = (dp[j]/a[j])*a[i-1] + dp[j]%a[j];
      dp[i] = max(val,dp[i]);
    }
  }
  cout << dp[n]<<endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }



int dp[2][1010];

int main() {
	int casenum = 0;
	int W, n;
	
	while (1) {
		cin >> W;
		if (W==0) break;
		
		casenum++;
		
		cin >> n;
		vci v(n), w(n); char c;
		for_(i, 0, n) cin >> v[i] >> c >> w[i];
		
		minit(dp, 0);
		
		dp[0][w[0]] = v[0];
		for_(i, 1, n) {
			int now = i%2, nxt = (i+1)%2;
			for_(j, 0, W+1) {
				dp[now][j] = max(dp[now][j], dp[nxt][j]);
				if (j+w[i]<=W) {
					dp[now][j+w[i]] = max(dp[now][j+w[i]], dp[nxt][j] + v[i]);
				}
			}
		}
		
		int maxv = 0, maxw = 0;
		for_(j, 0, W+1) {
			if (maxv < dp[(n+1)%2][j]) {
				maxv = dp[(n+1)%2][j];
				maxw = j;
			}
		}
		
		cout << "Case " << casenum << ":" << endl;
		cout << maxv << endl << maxw << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var b = Array.ConvertAll(line, int.Parse);
        var ans = 0;
        for (int i = 0; i < m; i++)
        {
            var t = getAns(a, b, n, m, i);
            ans = Max(ans, t);
        }
        Console.WriteLine(ans);
    }
    static int getAns(int[] a, int[] b, int n, int m, int start)
    {
        var ans = 0;
        var p = 0; var q = start;
        var pend = false;
        while (q < m)
        {
            while (true)
            {
                if (p == n) { pend = true; break; }
                if (a[p] == b[q]) { p++; ans = q - start + 1; q++; break; }
                else p++;
            }
            if (pend) break;
        }
        return ans;
    }
}



Measured memory_bytes: 20032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main()
{
  string S;
  cin >> S;

  int len = (int)(S.size());
  vector<vector<ll>> dp(len+1, vector<ll>(13, 0));
  dp[0][0] = 1;

  for (int i=0; i<len; i++) {
    int c = -1;
    if (S[i] != '?') c = S[i] - '0';

    for (int j=0; j<=9; j++) {
      if (c >= 0 && j != c) continue;
      for (int k=0; k<13; k++) {
        dp[i+1][(10*k+j)%13] += dp[i][k];
      }
    }
    for (int j=0; j<13; j++) {
      dp[i+1][j] %= mod;
    }
  }
  cout << dp[len][5] << endl;

  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<int32_t mod>
struct ModInt{
	int32_t a;
	inline int32_t normalize(int64_t x){
		x%=mod;
		if(x<0)x+=mod;
		return x;
	}
	ModInt(const int64_t a=0):a(normalize(a)){}

	ModInt& operator+=(const ModInt &x){
		a+=x.a;
		if(a>=mod)a-=mod;
		return *this;
	}
	ModInt& operator-=(const ModInt &x){
		a-=x.a;
		if(a<0)a+=mod;
		return *this;
	}
	ModInt& operator*=(const ModInt &x){
		a=(int64_t)a*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt x){return ModInt(*this)+=x;}
	ModInt operator-(const ModInt x){return ModInt(*this)-=x;}
	ModInt operator*(const ModInt x){return ModInt(*this)*=x;}
	ModInt operator/(const ModInt x){return ModInt(*this)/=x;}
	bool operator==(const ModInt x){return a==x.a;}
	bool operator!=(const ModInt x){return a!=x.a;}

	ModInt operator-(){return ModInt(0)-ModInt(*this);}
	ModInt pow(int64_t ex)const{
		int64_t x=a;
		int64_t res=1;
		while(ex){
			if(ex&1)res=res*x%mod;
			x=x*x%mod;
			ex>>=1;
		}
		return ModInt(res);
	}
	ModInt inv()const{return pow(mod-2);}
};

template<int32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<int32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<1000000007>;

int N,K;
int A[2222];

signed main(){
	cin>>N>>K;
	rep(i,N)cin>>A[i];


	mint ans;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(A[i]>A[j])ans+=K;
			if(A[i]!=A[j])ans+=K*(K-1)/2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val lrList = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
        .map { Pair(it[0], it[1]) }

    val leftMax = lrList.maxBy { pair -> pair.first }?.first!!
    val rightMin = lrList.minBy { pair -> pair.second }?.second!!
    val answer = Math.max(rightMin - leftMax + 1, 0)
    println(answer)
}


Measured memory_bytes: 62904
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    C = [list(map(int, input().split())) for _ in range(10)]
    A = [list(map(int, input().split())) for _ in range(H)]
    
    for k in range(10):
        for i in range(10):
            for j in range(10):
                if C[i][j] > C[i][k] + C[k][j]:
                    C[i][j] = C[i][k] + C[k][j]
                    
    ans = 0
    for row in A:
        for n in row:
            if n != -1:
                ans += C[n][1]
    
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<int> t(n);
    rep(i, n) cin >> t.at(i);
    int m;
    cin >> m;
    vector<int> p(m), x(m);
    rep(i, m) cin >> p.at(i) >> x.at(i);

    rep(i, m)
    {
        int answer = 0;
        rep(j, n)
        {
            if (p.at(i) != j + 1)
            {
                answer += t.at(j);
            }
            else
            {
                answer += x.at(i);
            }
        }
        cout << answer << endl;
    }
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    double n;
    cin >> n;
    printf("%.5lf",2*n*3.1415926);

    return 0;
}

Measured memory_bytes: 3780
import sys

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
M = sorted(A)
if M[-1] == M[-2]:
    for i in range(N):
        print(M[-1])
    sys.exit()
high_num = M[-1]
for i in range(N):
    if A[i] == high_num:
        print(M[-2])
    else:
        print(M[-1])


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    } else {
        cout << min(n - b , a - 1) + 1 + (b - a - 1) / 2 << endl; 
    }
    
    return 0;
}



Measured memory_bytes: 256
a=gets.to_i
b=gets.to_i
c=gets.to_i
x=gets.to_i/50

cnt = 0
for i in 0 .. a
  for j in 0 .. b
    for k in 0 .. c
      if 10 * i + 2 * j + k == x
        cnt += 1
      end
    end
  end
end
puts cnt

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n;
	while (cin >> n) {
		if (!n) break;
		string s; read(s);
		bool done = false;

		vector<int> indeg(26);
		vector<vi> g(26);

		rep(i, 1, n) {
			string t; read(t);
			if (done) continue;

			if (s == t || t.substr(0, sz(s)) == s) {
				s = t; continue;
			}

			if (s.substr(0, sz(t)) == t) {
				write("no"); done = true; continue;
			}

			// build edge
			int id = 0;
			while (s[id] == t[id]) ++id;
			int p = s[id] - 'a', q = t[id] - 'a';
			if (find(all(g[p]), q) == g[p].end()) {
				g[p].push_back(q);
				indeg[q]++;
			}

			s = t;
		}

		if (!done) {
			vector<int> ord;
			queue<int> q;
			rep(i, 0, 26) if (!indeg[i]) q.push(i);
			while (!q.empty()) {
				int h = q.front(); q.pop();
				ord.push_back(h);
				for (int e : g[h]) {
					indeg[e]--;
					if (!indeg[e])
						q.push(e);
				}
			}

			write(sz(ord) == 26 ? "yes" : "no");
		}
	}
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
  
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  vi x(3);
  x.at(0) = A;
  x.at(1) = B;
  x.at(2) = C;
  
  cout << ( count(all(x),5) == 2 && count(all(x),7) == 1 ? "YES" : "NO")
       << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1)
const int M = 1000000007;
const int N=1e6+5;
const int INF = 1e18+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif

void solve()
{
    double a, b, h, m;
    cin >> a >> b >>  h >> m;
    double angleH = 0 , angleM = 0;
    angleH = 30.0*h + 360.0/(12.0*60.0)*m;
    angleM = 6*m;
    double angle = angleH - angleM;
    if(angle < 0 ) {
        angle+=360.0;
    }
    if(angle == 180){
        cout << a + b << endl;
        return;
    }
    double ans = sqrt(a*a + b*b - 2.0*a*b*cos((angle*PI)/180.0));
    setpre(12) << ans << endl;
}

signed main()
{
    FAST;
    //TODO:  check test cases.
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++)
    {
        solve();
    }
}

/*TODO: (Extra Cares)
 * 1)Sometimes long long creates MLE.
 * 2)Check whether int to long long typecasting is commented or not?
 * 3)Check overflows.
*/

Measured memory_bytes: 4080
n=int(input())
a_=list(map(int,input().split()))
a=[[i+1,ai] for i,ai in enumerate(a_)]
a.sort(key=lambda x:x[1],reverse=True)
dp=[[0]*(n+1) for _ in range(n+1)]
# dp[i][j]:大きい順にi+j人のうち、i人を左に、j人を右に移した時の最大値。
dp[1][0]=a[0][1]*abs(a[0][0]-1)
dp[0][1]=a[0][1]*abs(a[0][0]-n)
for k in range(2,n+1):
    for i in range(k+1):
        j=k-i
        if j==0:
            dp[i][j]=dp[i-1][j]+a[i+j-1][1]*abs(a[i+j-1][0]-i)
        elif i==0:
            dp[i][j]=dp[i][j-1]+a[i+j-1][1]*abs(n-a[i+j-1][0]-j+1)
        else:
            dp[i][j]=max(dp[i-1][j]+a[i+j-1][1]*abs(a[i+j-1][0]-i),dp[i][j-1]+a[i+j-1][1]*abs(n-a[i+j-1][0]-j+1))
ans=0
for i in range(n+1):
    ans=max(dp[i][n-i],ans)
print(ans)



Measured memory_bytes: 100744
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a = [list(map(int,input().split())) for i in range(n)]
count=0
for i in range(n):
    ans=0
    for j in range(m):
        ans+=a[i][j]*b[j]
    ans+=c
    if ans > 0:
        count+=1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <list>
#include <string>
using namespace std;

#define MOD 1000000007
#define double long double
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	vector<double> probs;
	for (int i = 0; i < n; i++)
	{
		double pr;
		cin >> pr;

		probs.push_back(pr);
	}
	vector<double> tmp(3001);
	vector<vector<double>> dp(3001, tmp);
	//first i coins, j heads
	dp[0][0] = 1;
	for (int i = 1; i < n+1; i++)
	{
		dp[i][0] = (1 - probs[i - 1]) * dp[i-1][0];
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= i; j++)
		{
			dp[i][j] = dp[i - 1][j] * (1 - probs[i-1]) + dp[i - 1][j - 1] * probs[i-1];
		}
	}
	double ans = 0;
	for (int i = n / 2 + 1; i <= n; i++)
	{
		ans += dp[n][i];
	}
	cout << fixed << setprecision(30) << ans << "\n";
}


Measured memory_bytes: 141184
#include <iostream>
#include <vector>

typedef long long ll;

using namespace std;
int main(){
    int a,b,c;cin >> a >> b >> c;
    int x;cin >> x;
    int cnt=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i+100*j+50*k==x)cnt++;
            }
        }
        
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
# 平均ではなく中央値だから
# それぞれの集合の中央値が
# 第一四分位数と第三四分位数になり中央値はその間全てありうる
def median(q):
    # 例題1だと2種
    l=len(q)
    q=sorted(q,reverse=True)
    # qの出力結果[2, 1][3, 2]
    if l%2==0:
        # q0とq1を足して2でわる　4の場合q2とq3
        return (q[int(l/2)]+q[int(l/2)-1])/2
    else:
        # 3の場合q1、5の場合q２真ん中を出す
        return q[int((l+1)/2-1)]
n=int(input())

a=[]
b=[]

for i in range(n):
   x,y=map(int,input().split())
   a.append(x)
   b.append(y)
# 集合bの中央値
med_a=median(a)
med_b=median(b)
# もし偶数なら
if n%2==0:
    print(int(2*(med_b-med_a)+1))

else:
    print((med_b-med_a)+1)

Measured memory_bytes: 27012
a = input().split(" ")
mem = [0] * int(a[0])
for i in range(int(a[2])):
  mem[int(input())-1] += 1
for i in range(int(a[0])):
  if int(a[1])-int(a[2])+mem[i] < 1:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 4680
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (int i = 0; i < (n); ++i)
#define reps(i,s,t) for (int i = (s); i <= (t); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

int N;
int c[1005];
int w[1005];
int sum[1005];
bool can[1005][1005];
int dp[1005];

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

    cin >> N;
    reps(i, 1, N) cin >> c[i] >> w[i];
    reps(i, 1, N) sum[i] = sum[i-1] + w[i];
    reps(i, 1, N) can[i][i] = true;

    reps(len, 1, N) {
        for (int L = 1; L+len <= N; ++L) {
            const int R = L + len;
            if (can[L+1][R]) {
                can[L][R] |= (sum[R] - sum[L] <= c[L]);
            }
            if (can[L][R-1]) {
                can[L][R] |= (sum[R-1] - sum[L-1] <= c[R]);
            }
        }
    }

    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;

    reps(L, 1, N) {
        reps(R, L, N) {
            if (can[L][R]) chmin(dp[R], dp[L-1] + 1);
        }
    }

    cout << dp[N] << endl;

    return 0;
}




Measured memory_bytes: 4196
#include<stdio.h>
#include<math.h>


int main(){
    int a,k,i;
    double c,n,p=0.0;
    scanf("%lf %d",&n,&k);
    for(i=1;i<n+1;i++){
        c=0.0;
        a=i;
        while(k>a){
            c++;
            a=a*2;
        }
        p += 1/(n*exp2(c));
    }
    printf("%.12f\n",p);
    return 0;
}

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

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	double n, d;
	cin >> n >> d;
	
	int cnt=0;
	double x, y;
	while(n--){
		cin >> x >> y;
		
		double dis = sqrt(x*x+y*y);
		if(dis <= d)cnt++;
	}
	
	cout << cnt;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3820
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MAX(a,b) ((a >= b) ? (a) : (b))
#define MIN(a,b) ((a >= b) ? (b) : (a))
#define ABS(a) (((a) > 0) ? (a) : (-a))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define clrbit(s, b) (s &= ~(1<<b))


int main() {

	int k, l, i = 0;
	char s[110], s1[110];
	scanf("%d", &k);
	scanf("%s", s);

	l = strlen(s);

	if(l <= k) {
		printf("%s\n", s);
	} else {

		for(i = 0 ; i <k ;i++) {
			printf("%c", s[i]);
		}
		printf("...\n");
	}

	return 0;
}

Measured memory_bytes: 3764
object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n");
    println(solve(input).trim());
  }

  def solve(input:String):String={
    if(input=="Sunny"){
      return "Cloudy";
    }else if(input=="Cloudy"){
      return "Rainy";
    }else{
      return "Sunny";
    }
  }
}


Measured memory_bytes: 25416
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<map>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B)
		cout << C << endl;
	else if (A == C)
		cout << B << endl;
	else
		cout << A << endl;
	return 0;
}

Measured memory_bytes: 256
def solve(n, g):
    mod = 10 ** 9 + 7

    stack = [0]
    order = []
    parent = [-1] * n
    checked = [False] * n
    checked[0] = True

    while stack:
        v = stack.pop()
        order.append(v)
        for u in g[v]:
            if checked[u]:
                continue
            checked[u] = True
            parent[u] = v
            stack.append(u)

    order.reverse()

    checked = [False] * n

    dp_w = [1] * n
    dp_b = [1] * n

    for v in order:
        checked[v] = True
        par = parent[v]
        if par == -1:
            continue
        dp_w[par] = (dp_w[par] * (dp_w[v] + dp_b[v])) % mod
        dp_b[par] = (dp_b[par] * dp_w[v]) % mod

    v = order[-1]
    return (dp_w[v] + dp_b[v]) % mod


if __name__ == '__main__':
    import sys

    input = sys.stdin.readline

    n = int(input())
    g = tuple(set() for _ in range(n))
    for _ in range(n - 1):
        x, y = (int(j) - 1 for j in input().rstrip().split())
        g[x].add(y)
        g[y].add(x)
    print(solve(n, g))

# https://atcoder.jp/contests/dp/submissions/8270981
# 参考にした

# 適当な頂点を根とする
# 2次元配列でdpするより、1次元*2本の方が若干速い

# 再帰関数でdfsしたらTLEした

# 葉から根（0にした）に向かって、
# 親に掛け算する

# https://atcoder.jp/contests/dp/submissions/3950379
# メモ化再帰で解いていたので、これを参考にしたかった
# しかし、自分では要旨をつかめず、真似ても2000msを超えてしまったので、あきらめた


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

const int INF = 1 << 30;

int main() {
    int N, K; cin >> N >> K;
    vector<int> V(N);
    for(auto &e : V) cin >> e;
    int ans = -INF;
    for(int left = 0; left <= min(N, K); ++left) {
        for(int right = 0; left + right <= min(N, K); ++right) {
            priority_queue<int, vector<int>, greater<int>> que;
            for(int i = 0; i < left; ++i) que.push(V[i]);
            for(int i = 0; i < right; ++i) que.push(V[N - 1 - i]);
            for(int i = left + right; i < K and !que.empty() and que.top() < 0; ++i) que.pop();
            int tmp = 0;
            while(!que.empty()) tmp += que.top(), que.pop();
            ans = max(ans, tmp);
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N = 1e5 + 5;
const int M = 1e9 + 7;
ll f[N];


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\
    int n, m;
    f[0] = 1;
    for(int i = 1; i <= N; i++)
        f[i] = (i * f[i - 1]) % M;
    cin >> n >> m;
    if(abs(n - m) > 1) return cout << 0, 0;
    if((n + m) & 1)
    cout << (f[n] * f[m] % M);
    else cout << 2 * f[n] * f[m] % M;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
static const int MAX=100;
static const int INFTY=(1<<30);
class edge{
public:
    int target, cap, cost, rev;
    edge(int target = 0, int cap =0, int cost = 0, int rev =0) : target(target), cap(cap), cost(cost), rev(rev) {}
};
int V;
std::vector<edge> G[MAX];
int h[MAX], dist[MAX], prevv[MAX], preve[MAX];

void add_edge(const int &source, const int &target, const int &cap, const int &cost) {
    G[source].push_back(edge(target, cap, cost, G[target].size()));
    G[target].push_back(edge(source, 0, -cost, G[source].size()-1));
}

int min_cost_flow(int s, int t, int f) {
    int res = 0;
    std::fill(h, h+V, 0);
    while(f > 0) {
        std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > > pq;
        std::fill(dist, dist + V, INFTY);
        dist[s] = 0;
        pq.push({0, s});
        while (!pq.empty()) {
            std::pair<int, int> p = pq.top(); pq.pop();
            int current = p.second;
            if (dist[current] < p.first) continue;
            for (int i = 0; i < G[current].size(); i++) {
                edge &e = G[current][i];
                if (e.cap > 0 && dist[e.target] > dist[current] + e.cost + h[current] - h[e.target]) {
                    dist[e.target] = dist[current] + e.cost + h[current] - h[e.target];
                    prevv[e.target] = current; preve[e.target] = i;
                    pq.push({dist[e.target], e.target});
                }
            }
        }
        if (dist[t] == INFTY) return -1;
        for (int v = 0; v < V; v++) h[v] += dist[v];

        int d = f;
        for (int v = t; v != s; v = prevv[v]) {
            d = std::min(d, G[prevv[v]][preve[v]].cap);
        }
        f -= d;
        res += d * h[t];
        for (int v = t; v!=s; v = prevv[v]) {
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}

int main()
{
    int E, f, source, target, cap, cost;
    std::scanf("%d %d %d", &V, &E, &f);
    for (int i = 0; i < E; i++) {
        std::scanf("%d %d %d %d", &source, &target, &cap, &cost);
        add_edge(source, target, cap, cost);
    }
    std::printf("%d\n", min_cost_flow(0, V-1, f));
    return 0;
}



Measured memory_bytes: 3304
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/arc103/tasks/arc103_c

//参考：https://phyllo-algo.hatenablog.com/entry/2018/09/30/023710
//https://betrue12.hateblo.jp/entry/2018/09/30/125042

//キャタピラ木という木がある

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S;

int flag = -1;
vector<pair<LL,LL>> ans;

void solve(){
	int N = S.size();
	if(S[0]!='1' || S[N-1]!='0') return;
	for(int i=0;i<=(N-2)/2;i++){
		if(S[i]!=S[N-2-i]) return;
	}
	flag = 1;

	int focus = 1;
	int counter = 2;
	for(int i=0;i<=N-2;i++){
		ans.push_back(pair<LL,LL>(focus,counter));
		if(S[i]=='1') focus = counter;
		counter++;
	}
}

int main(){
    cin >> S;

    solve();
    if(flag==-1){
    	cout << -1 << endl;
    	return 0;
    }
    for(int i=0;i<ans.size();i++)cout << ans[i].first << " " << ans[i].second << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(){
	string S;
	set<char> st;

	cin>>S;
	REP(i,(int)S.length()){
		if(st.find(S[i])==st.end()) st.insert(S[i]);
		else{
			puts("no");
			break;
		}
		if(i==(int)S.length()-1) puts("yes");
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
ll n,k,q;
bool p[2020];
ll a[2020];
ll f(ll val){
    rep(i,n){
        if(a[i]<val)p[i]=true;
        else p[i]=false;
    }
    vl s,t;
    rep(i,n+1){
        if(p[i]||i==n){
            sort(t.begin(),t.end());
            if(sz(t)>=k){
                for(int j=0;j<sz(t)-k+1;j++){
                    s.pb(t[j]);
                }
            }
            t.clear();
        }else t.pb(a[i]);
    }
    sort(s.begin(),s.end());
    if(sz(s)<q)return LINF;
    else return s[q-1]-s[0];
}
int main(){
    cin>>n>>k>>q;
    rep(i,n)cin>>a[i];
    ll ans=LINF;
    rep(i,n){
        chmin(ans,f(a[i]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3680
N,K=map(int, input().split())
A=list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**8)
import numpy as np
done=np.array([0]*N)
X=[0]*2
L=[]
F=[True]
def dfs(start, steps):
    done[start-1]+=1
    L.append(start)
    if done[start-1]==3:
        X[1]=steps
        return
    elif done[start-1]==2 and F[0]:
        X[0]=steps
        F[0]=False
    nex=A[start-1]
    dfs(nex, steps+1)
dfs(1,0)
#print(done)
#print(X)
#print(L)
first=L[:X[0]-(X[1]-X[0])]
sec=L[X[0]-(X[1]-X[0]):X[0]-(X[1]-X[0])+(X[1]-X[0])]
#print(first, sec)
if len(first)==0:
    first=sec
if K+1<=len(first):
    print(first[K])
else:
    K=K-len(first)
    print(sec[(K%len(sec))])


Measured memory_bytes: 342964
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<iostream>
#include <stdlib.h>
#include<ctime>
#include <string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;

int main()
{
	long long int a;
	cin >> a;
	long long int minm = 1e18;
	long long int j;
	for (long long int i = 1; i*i <= a; i++)
	{
		if (a%i == 0)
		{
			j = a / i;
			minm = min(minm, i + j - 2);
		}
	}
	cout << minm << endl;
	return 0;
}

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

int main(){
  long long n;
  long long cnt = 1;

  scanf("%lld", &n);

  while(n){
    n = n/2;
    cnt = cnt*2;
  }

  printf("%lld\n", cnt - 1);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
ll a;
cin >> a;
cout << 2*3.14159*a <<endl;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
#define lint long long int
using namespace std;
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}


lint inf=pow(2,50);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(19);
	lint n;
	scanf("%lld",&n);
	lint ans=n-1;
	lint hoge=sqrt(n);
	for(lint i=1;i<=hoge;i++)if(n%i==0)chmin(ans,i-2+(n/i));
	printf("%ld",ans);
	return 0;
}


Measured memory_bytes: 3804
#include<iostream>
#include<vector>
#define lli long long int
#include<climits>
#include<unordered_map>
#include<algorithm>
#include<bitset>
#include<map>
#define pb push_back
using namespace std;

int main()
{
   
    int a,b;
    cin>>a>>b;
    vector<bool>arr(4);
    arr[a] = true;
    arr[b] = true;
    for(int i=1;i<4;i++)
        if(!arr[i])  cout<<i<<endl;
    
}



Measured memory_bytes: 3624
#include<iostream>
#include<cstring>

using namespace std  ;


int main()

{
    string str ;

    getline(cin, str) ;

    if(str=="Sunny")
    {
        cout<<"Cloudy"<<endl ;
    }

    else if(str=="Cloudy")
    {
        cout<<"Rainy"<<endl ;
    }

    if(str=="Rainy")
    {
        cout<<"Sunny"<<endl ;
    }

    return 0;
}

Measured memory_bytes: 2832
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int *h=new int[n+2];
    for(int i=0;i<n;i++)
        cin>>h[i];
    int *dp=new int[n+2];
    memset(dp,0,sizeof(dp));
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    cout<<dp[n-1];
}

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

int main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int t;t=1;while(t--)
   {
       int k,n;cin>>k>>n;
       int a[n];
       
       for(int i=0;i<n;i++) cin>>a[i];
       int max_dis=-2;
       for(int i=0;i<n-1;i++)
       {
           int dis=a[i+1]-a[i];
           dis=min(dis,k-dis);
           max_dis=max(max_dis,dis);
       }
       
       int dis=a[n-1]-a[0];
       dis=min(dis,k-dis);
       max_dis=max(dis,max_dis);
       
       cout<<k-max_dis;
   }
}

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

bool ispa(string s){
	for(int i = 0; i < s.length()/2; i++){
		if (s[i] != s[s.length()-1-i])	return false;
	}
	return true;
}

int main(){
    string s;
	std::cin >> s;
	string noxs = "";
	for(int i = 0; i < s.length(); i++){
		if (s[i] != 'x'){
			noxs = noxs+s[i];
		}
	}
	if (!ispa(noxs)){
		std::cout << -1;
		return 0;
	}
	int j = s.length()-1;
	int i = 0;
	int count = 0;
	while(j>i){
		if (s[i] == 'x'){
			if(s[j] != 'x') {
				count ++;
				i++;
			}
			else{
				i++;
				j--;
			}
		}
		else if(s[j] == 'x'){
			count ++;
			j--;
		}
		else{
			i++;
			j--;		
		}
	}
	std::cout << count;
	return 0;
}
	

Measured memory_bytes: 696
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define LLBIG 1999999999999999999
#define INTBIG 1111111111
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>


int main() {
	string s; int N, Q;
	int AC[100002];
	cin >> N >> Q >> s;
	for (int i = 1; i < s.size(); i++) {
		AC[i] = AC[i - 1];
		if (s[i] == 'C'&& s[i - 1] == 'A') AC[i]++;
	}
	for (int i = 0; i < Q; i++) {
		int l, r; cin >> l >> r;
		cout << AC[r - 1] - AC[l - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b;i>=a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;

int a[10] = {}; 

int main(){
	int n, k, x;
	cin >> n >> k;
	rep(i, k){
		cin >> x;
		a[x] ++;
	}
	
	while(true){
		int tmp = n, ok = 1;
		while(tmp){
			if(a[tmp % 10]){
				ok = 0;
				break;
			}
			tmp /= 10;
		}
		if(ok){
			print(n);
			return 0;
		}
		n++;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())

cnt = 0
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        break
    if i == N-1 and cnt != 3:
        print("No")

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

int main()
{
    int n, x, a, b;
    
    a = 1000000;
    
    cin >> n >> x;
    
    for (int i = 0; i < n; i++){
        cin >> b;
        x = x - b;
        if (b < a){
            a = b;
        }
    }
    b = x % a;
    x = x - b;
    x = x / a;
    cout <<n + x<< endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.D
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			string s = cin.next();
			char now='0';
			int ans = s.Length;
			for (int i = 0; i < s.Length; i++)
			{
				if (s[i] != now)
				{
					ans = Math.Min(ans, Math.Max(i, s.Length - i));
				}
				now = s[i];
			}

			Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

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

Measured memory_bytes: 13792
import itertools
n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int,input().split())
A_list = []
for p in itertools.combinations_with_replacement(range(1,m+1),n):
    A_list.append(p)
# print(A_list)

ans = 0
for v in A_list:
    cur_score = 0
    for i in range(q):
        if v[b[i]-1] - v[a[i]-1] == c[i]:
            cur_score += d[i]
    ans = max(ans,cur_score)
print(ans)

Measured memory_bytes: 21736
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] count = new int[9];
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if(1<=a&&a<400) count[0]++;
			else if(400<=a&&a<800) count[1]++;
			else if(800<=a&&a<1200) count[2]++;
			else if(1200<=a&&a<1600) count[3]++;
			else if(1600<=a&&a<2000) count[4]++;
			else if(2000<=a&&a<2400) count[5]++;
			else if(2400<=a&&a<2800) count[6]++;
			else if(2800<=a&&a<3200) count[7]++;
			else if(3200<=a) count[8]++;
		}
		int min = 0;
		int max = 0;
		for(int i = 0; i < 8; i++) {
			if(count[i]!=0) {
				min++;
				max++;
			}
		}
		max+=count[8];
		if(min==0) {
			min++;
		}
		System.out.println(min+" "+max);
	}
}

Measured memory_bytes: 38840
import numpy as np
s_list = "abcdefghijklmnopqrstuvwxyz"
N,L=map(int, input().split())
S=[]
Ls=[]
for i in range(N):
  s = str(input())
  S.append(s)
  ls=0
  for k in range(L):
    ls = ls + s_list.index(s[L-k-1])*(100**k)
  Ls.append(ls)
  
Ls = np.array(Ls)

ind = Ls.argsort()
ans = ""
for i in range(N):
  ans = ans + S[ind[i]]
print(ans)

Measured memory_bytes: 17948
#include<bits/stdc++.h>
using namespace std;
double dp[3001][3001];
int n;
double p[3001];
/*
double fun(int i, int j)
{
  if(i==n && j==n)
    return 1.0;
    else if(i>n || j>n)
       return 0.0;
    if(dp[i][j]>-1)
      return dp[i][j];
      
      double ans=p[i]*fun(i+1,j+1) + (1.0-p[i])*fun(i+1,j);
      
      dp[i][j]=ans;
      
      return ans;
 }
*/
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	
	for(int i=1;i<=n;i++)
	  cin>>p[i];
	
	
	dp[0][0]=1.0;   
  for(int i=1;i<=n;i++)
     for(int j=0;j<=i;j++)
		{  if(j==0)
			 dp[i][j]=(1-p[i])*dp[i-1][j];
			 
			 else
			 dp[i][j]=p[i]*(dp[i-1][j-1]) + (1-p[i])*(dp[i-1][j]);
	    }
	   
	   /*
	   for(int i=1;i<=n;i++)
	    { for(int j=0;j<=i;j++)
	      cout<<dp[i][j]<<" ";
	      cout<<endl;
	     } */
	     double ans=0;
	   for(int i=(n+1)/2;i<=n;i++)
	     ans+=dp[n][i];
	     cout<<setprecision(10);
	     cout<<ans<<endl;
	

return 0;
}


Measured memory_bytes: 68992
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int n, k, ats = 1;

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

    for (int i = 0; i < n; i++) {
        if (ats * 2 < ats + k) ats *= 2;
        else ats += k;
    }

    printf("%d\n", ats);
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,edge[3];
	cin >>n;
	while(n--){
		cin>>edge[0]>>edge[1]>>edge[2];
		if(edge[0]*edge[0]+edge[1]*edge[1] == edge[2]*edge[2] || edge[1]*edge[1]+edge[2]*edge[2] == edge[0]*edge[0] || edge[2]*edge[2]+edge[0]*edge[0] == edge[1]*edge[1]){cout <<"YES"<<endl;}
		else{cout<<"NO"<<endl;}
	}
	return 0;
}

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

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

  if (a < b) {
    if ((a + w) > b) {
      cout << 0 << endl;
    } else {
      cout << b - (a + w) << endl;
    }
  } else {
    if ((b + w) > a) {
      cout << 0 << endl;
    } else {
      cout << a - (b + w) << endl;
    }
  }
}

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

const int MAX = 2010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();

    long long n, k;
    cin >> n >> k;

    for(int i = 0; i < k; i++){
        long long x = COM(n - k + 1, i + 1);
        long long y = COM(k - 1, i);
        long long ans = x * y % MOD;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256