akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, ai, a[200001], sum1, sum2, m;

int main()
{
  sum2 = 0;

  cin >> N;
  REP(i, N)
  {
    cin >> ai;
    sum2 += ai;
    a[i] = ai;
  }

  sum1 = a[0];
  sum2 -= a[0];
  m = abs(sum1 - sum2);
  FOR(i, 1, N - 1)
  {
    sum1 += a[i];
    sum2 -= a[i];
    m = min(m, abs(sum1 - sum2));
  }

  cout << m << '\n';

  return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		double ans = 1 / Arrays.stream(sc.nextLine().split(" ")).mapToDouble(Double::valueOf).map(e -> 1d / e).sum();
		System.out.println(ans);
	}
}


Measured memory_bytes: 27220
#include<cstdio>
const long long mod = 998244353;
long long f[6005], invf[6005];

long long power(long long a,long long b){
    long long res = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
        b /= 2;
    }
    return res;
}

long long inv(long long u){ return power(u,mod-2); } 

void preWork(int n){
    f[0] = invf[0] = 1;
    for(int i = 1; i <= n; i++){
        f[i] = f[i-1]*(long long)i%mod;
        invf[i] = inv(f[i]);
    }
}

long long getC(long long n,long long m){
    if(m>n || m<0) return 0;
    else{
        long long res = f[n];
        res = res*invf[m]%mod;
        res = res*invf[n-m]%mod;
        return res;
    }
}

int min(int a,int b){ return a>b?b:a; }

int main(){
    preWork(6000);
    int n,x;
    scanf("%d%d",&n,&x);
    long long ans = 0;
    for(int cnt0 = 0; cnt0 <= n; cnt0++){
        int m = n-cnt0;
        long long res = 0;
        if(x<=m) res = x%2;
        else{
            for(int i = 0; i < x-m; i++){
                res += getC(m,i);
                if(res>=mod) res -= mod;
            }
            for(int i = x/2; i <= min(x-1,m-1); i++){
                int cnt2 = x-1-i, left2 = m-i;
                if(left2<=cnt2){
                    res += getC(i-left2,cnt2-left2);
                    if(res>=mod) res -= mod;
                }
            }
            //printf("n = %d, x = %d: %lld\n",m,x,res);
        } 
        ans = ans + getC(n,cnt0)*res%mod;
        if(ans>=mod) ans -= mod;
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    vector<char> vec;
    for(int i = 0 ; i < 26 ; i++){
        vec.push_back('a' + i);
    }
    bool MAX = false;
    if(s.size() == 26){
        MAX = true;
        int i = 25;
        while(s[i] < s[i-1]){
            i--;
            if(s[i] == 'z'){
                break;
            }
        }
        s = s.substr(0, i);
    }
    for(int i = 0 ; i < vec.size() ; i++){
        for(int j = 0 ; j < s.size(); j++){
            if(vec[i] == s[j]){
                vec.erase(vec.begin()+i);
                i--;
                break;
            }
        }
    }
    if(s.size() == 0){
        cout << -1 << endl;
    }else if(MAX){
        while(vec[0] <= s[s.size()-1]){
            vec.erase(vec.begin());
        }
        s[s.size()-1] = vec[0];
        cout << s << endl;
    }else{
        cout << s << vec[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def q4():
    N, K = (int(i) for i in input().split())

    ans = 0
    for k in range(K, N+2):
        ans += int(k*(2*N - k + 1)/2 - k*(k-1)/2 + 1)

    d, ans = divmod(ans, 10**9 + 7)
    print(ans)


if __name__ == '__main__':
    q4()


Measured memory_bytes: 9116
//
// Created by watemus on 02.05.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;

#ifdef LOCAL
#else
#endif


void run() {
    int x;
    cin >> x;
    int c = 100;
    int ans = 0;
    while (c < x) {
        c += c / 100;
        ans++;
    }
    cout << ans << '\n';
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  string s,t;cin >> s >> t;
  int ans = 0;
  for(int i=0;i<3;i++){
    if(s[i]==t[i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# D - Sum of Large Numbers

n, k = map(int, input().split())

modulus = 10 ** 9 + 7

s = 0
# m個選ぶ
for m in range(k, n + 2):
    s += (m * (n - m + 1) + 1) % modulus  # 最小から最大までの個数

print(s % modulus)


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s[0]==s[1] && s[0]!=s[2])
    {
        if (s[2]==s[3])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else if (s[0]==s[2] && s[0]!=s[1])
    {
        if (s[1]==s[3])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else if (s[0]==s[3] && s[0]!=s[1])
    {
        if (s[2]==s[1])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else
        cout << "No" <<endl;
}


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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF INT_MAX
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;


int main(){
    /*1 0 -1 0 1
    1 0 1 0 1 0 -1 -2 -1 0 1 0
    1 2 3 4 5 4 3 2
    */
   int n;
   string s;
   cin>>n>>s;
   vector<int> w(n,0),e(n,0);
   rep(i,0,n){
       if(s[i]=='W')w[i]=1;
       else e[i]=1;
       if(i){
           w[i]+=w[i-1];
           e[i]+=e[i-1];
       }
   }

    int ans=100000000;
   rep(i,0,n){
       if(i==0){
           if(s[i]=='W')ans=min(ans,e[n-1]);
           else ans=min(ans,e[n-1]-1);
       }
       if(s[i]=='W'){
           ans=min(ans,(w[i-1]+e[n-1]-e[i]));
       }else ans=min(ans,(w[i-1]+e[n-1]-e[i]));
       //cout<<ans<<" "<<i<<endl;
   }
   cout<<ans<<endl;

    
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int main(){
    int w,h,n;
    cin >> w >> h >> n;
    vector<vector<int>> order(n,vector<int>(3));
    int minx,maxx,miny,maxy;
    minx = w;
  	miny = h;
    maxy = maxx = 0;
    for(int i = 0;i < n;i++){
        cin >> order[i][0] >> order[i][1] >> order[i][2];
        if(order[i][2] == 1){
            if(order[i][0] > maxx) maxx = order[i][0];
        }else if(order[i][2] == 2){
            if(order[i][0] < minx) minx = order[i][0];
        }else if(order[i][2] == 3){
            if(order[i][1] > maxy) maxy = order[i][1];
        }else if(order[i][2] == 4){
            if(order[i][1] < miny) miny = order[i][1];
        }
    }
    if(minx - maxx < 0 || miny - maxy < 0) cout << 0 << endl;
    else cout << (minx-maxx)*(miny-maxy) << endl;
}

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

    int ti, xi, yi;
    int t0, x0, y0;
    t0 = x0 = y0 = 0;
    for (int i = 0; i < N; i++) {
        cin >> ti >> xi >> yi;

        int dist = abs(xi - x0) + abs(yi - y0);
        int t = ti - t0;
        if (dist <= t) {
            if (t % 2 != dist % 2) {
                cout << "No\n";
                return 0;
            }
            t0 = ti;
            x0 = xi;
            y0 = yi;

        } else {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp>
  using namespace __gnu_pbds;
  using namespace std;
  #define int         long long
  #define mod         1000000007
  #define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  #define f(i,n)      for(int i=0;i<n;i++)
  #define fp(i,k,n)   for(int i=k;i<=n;i++)
  #define fr(i,k,n)   for(int i=k;i>=n;i--)
  #define pb          push_back
  #define pii         pair<int,int>
  #define vi          vector<int>
  #define vii         vector<pii>
  #define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
  #define F           first
  #define S           second
  #define sz(x)       (int)(x).size()
  #define lb          lower_bound
  #define ub          upper_bound
  #define mems(x)     memset(x,0,sizeof(x))
  #define all(a)      a.begin(),a.end()
  typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

  /*---------------------------------------------------------------------------------------------------*/

  void solve()
  {
    int n,d;
    cin >> n >> d;
    int ans=0;
    f(i,n)
    {
        int x,y;
        cin >> x >> y;
        int val=(x*x)+(y*y);
        if(val<=(d*d))
            ans++;
    }
    cout << ans << '\n';
    return;
  } 

  signed main()
  {
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    FAST
    int T=1;
    // cin >> T;
    while(T--)
    {
      solve();
    }
    return 0;
  }


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S[1515];
int M[2][1515][1515];

int id[1515][1515];
ll mo=998244353;
int V[1500],E[1500],P[1500];

template<int um> class UF {
	public:
	vector<int> par,rank;
	UF() {rank=vector<int>(um,0); for(int i=0;i<um;i++) par.push_back(i);}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};

ll hoge(int t,int N) {
	int a,b;
	ll pat=1;
	if(N%2==0) {
		FOR(b,N) FOR(a,b) pat=pat*(2-__builtin_popcount(M[t][a][b]))%mo;
	}
	else {
		UF<1510> uf;
		FOR(b,N) FOR(a,b) {
			if(M[t][a][b]==3) return 0;
			if(M[t][a][b]==0) uf(a,b);
		}
		ZERO(V);
		ZERO(E);
		ZERO(P);
		FOR(a,N) {
			V[uf[a]]++;
			FOR(b,a) if(M[t][b][a]==0) E[uf[a]]++;
		}
		FOR(a,N) FOR(b,a) if(M[t][b][a]==2) {
			P[uf[a]]^=1;
			P[uf[b]]^=1;
		}
		FOR(a,N) if(uf[a]==a) {
			FOR(b,E[a]-(V[a]-1)) pat=pat*2%mo;
			if(P[a]) return 0;
		}
		
	}
	return pat;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	for(y=1;y<=N-1;y++) {
		cin>>S[y];
		for(x=1;x<=N-1;x++) {
			int a=abs(x-y);
			int b=x+y;
			if(b>N) b=2*N-b;
			assert(a<=b && (a%2==b%2));
			if(S[y][x-1]=='o') M[a%2][a/2][b/2]|=1;
			if(S[y][x-1]=='x') M[a%2][a/2][b/2]|=2;
		}
	}
	
	ll ret=hoge(0,1+N/2)*hoge(1,(N+1)/2)%mo;
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 14976
#include <bits/stdc++.h>	
#define ll long long 
#define pb push_back
#define N 100005
using namespace std;

//ll A[N],ans;
ll n,k,a,b,c,d;
 
#pragma region
void ingresoInt(int A[]){
	for (int i = 0; i < n; ++i)scanf("%d",&A[i]);
}
void ingresoLL(ll A[]){
	for (int i = 0; i < n; ++i)scanf("%lld",&A[i]);
}
void mostrarInt(int A[]){
	for (int i = 0; i < n; ++i)printf("%d ",A[i]);printf("\n");
}
void mostrarLL(ll A[]){
	for (int i = 0; i < n; ++i)printf("%lld ",A[i]);printf("\n");
}
#pragma endregion




bool esIso(vector<int> a[],vector<int> b[],int u, int v){
	
	if(a[u].size()==0 && b[v].size()==0) return true;
	
	if(a[u].size() != b[v].size())return false;

	if(a[u].size()==1)
		return esIso(a,b,a[u][0],b[v][0]);

	return esIso(a,b,a[u][1],b[v][1])&&esIso(a,b,a[u][0],b[v][0]) || esIso(a,b,a[u][0],b[v][1])&&esIso(a,b,a[u][1],b[v][0]);

}


typedef struct 
{
	int x,y,t;
}tres;

bool ordenar(tres a,tres b){
	return a.x<b.x;
}


int main(){
	
	int n,x,y;
	vector<tres> puntos;
	int ans=0;
	scanf("%d",&n);

	for (int i = 0; i < n; ++i)
	{	
		scanf("%d%d",&x,&y);
		puntos.pb({x,y,0});
	}

	for (int i = 0; i < n; ++i)
	{	
		scanf("%d%d",&x,&y);
		puntos.pb({x,y,1});
	}
	
	sort(puntos.begin(),puntos.end(),ordenar);
	
	multiset<int> q;
	multiset<int>::iterator itlow; 

	for(int i=0; i<2*n; i++){
		if(puntos[i].t==0) {q.insert(puntos[i].y);continue;}

		itlow = q.lower_bound(puntos[i].y);

		if (itlow != q.begin()) {
 			itlow--;
 			q.erase(itlow);
  			ans++;
		}
	
	}

	return !printf("%d", ans);

}

Measured memory_bytes: 256
<?php
$l;
$r;
$d;

fscanf(STDIN, "%d %d %d", $l, $r, $d);

$count = 0;

for ($i = $l; $i <= $r; $i++) {
    if ($i % $d == 0) {
        $count++;
    }
}

echo $count;

Measured memory_bytes: 16284
sx, sy, tx, ty = map(int, input().split())
print((ty-sy)*"U"+(tx-sx)*"R"+(ty-sy)*"D"+(tx-sx)*"L"\
+1*"L"+(ty-sy+1)*"U"+(tx-sx+1)*"R"+1*"D"\
+1*"R"+(ty-sy+1)*"D"+(tx-sx+1)*"L"+1*"U")


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
typedef pair<ll,ll> LL_LLP;
#define MOD 1000000007
#define MAX_H 100005

ll factorial[2*MAX_H];//階乗
ll inverse[2*MAX_H];//逆元


/*mod Mでの割り算は割る数aのM-2をかける*/
/*ここではaのb乗をpで割った余りを返す*/
ll calc(ll a,ll b,ll p){

    if(b == 0){
        return 1;
    }else if(b % 2 == 0){
        ll tmp = (calc(a,b/2,p)) % p;
        return ((tmp%p)*(tmp%p))%p;
    }else{
        return ((a%p)*(calc(a,b-1,p)%p)) % p;
    }
}

ll calc_nCr(ll n,ll r){
    return ((((factorial[n]%MOD) * (inverse[r]%MOD))%MOD) * (inverse[n-r]%MOD))%MOD;
}
    

int main(){

    ll h,w,a,b,ans = 0;
    cin >> h >> w >> a >> b;
    factorial[0] = factorial[1] = 1;
    for(ll i = 2;i <= h+w-2;i++){
        factorial[i] = factorial[i-1] * i % MOD;
    }
    for(int i = 0;i <= h+w-2;i++){
        inverse[i] = calc(factorial[i],MOD-2,MOD);
    }

    for(ll i = b;i < w;i++){
        ll n = h - a - 1;
        ll down = a - 1;
        ll right = w - i - 1;
        ans = (ans + ((calc_nCr(n+i,i)%MOD) * (calc_nCr(down+right,right)%MOD))%MOD)%MOD;
    }
    cout << ans << endl;
   
    
    return 0;
}

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

int main()
{
	char ch, ch2, ch3;
	int num;
	int counter[26] = {0};
	
	while (cin >> ch ){
		ch2 = tolower(ch);
		num = ch2 - 'a';
		
		counter[num]++;
	}
	
	for(int i = 0; i < 26; i++){
		ch3 = 'a' + i;
		cout << ch3 << " : " << counter[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	int n;

	cin>>n;
	vector<int> pn(n,0);

	for (int i = 0; i < n; ++i)
	{
		cin >> pn[i];
	}
	int count = 0;
	for (int i = 1; i < n - 1; ++i)
	{
		if ((pn[i]<pn[i - 1] && pn[i]>pn[i + 1]) || (pn[i]>pn[i - 1] && pn[i] < pn[i + 1]))
		{
			++count;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
#define NMAX 100005
#define LAST 1000000000002
int main()
{      
    ll p,n,z,k;
    cin>>p>>z>>n>>k;
    if(k<p)cout<<k<<endl;
    else if(p+z>=k)cout<<p<<endl;
    else cout<<2*p+z-k<<endl;
   return 0;
}


Measured memory_bytes: 3644
def kp(vv, wv, w)
	dp1 = Array.new(w + 1, 0)
	vv.length.times do |i|
		dp2 = dp1.clone
		(w + 1).times do |j|
			if j < wv[i] || dp2[j] > dp2[j - wv[i]] + vv[i]
				dp1[j] = dp2[j]
			else
				dp1[j] = dp2[j - wv[i]] + vv[i]
			end
		end
	end
	return dp1[w]
end

if __FILE__ == $0
	vv = Array.new(0)
	wv = Array.new(0)
	n, w = gets.split.map(&:to_i)
	n.times do
		vi, wi = gets.split.map(&:to_i)
		vv << vi
		wv << wi
	end
	puts("#{kp(vv, wv, w)}")
end



Measured memory_bytes: 14764
#include <bits/stdc++.h>
using namespace std;
#define N 505

int n,he = 0,k;
int tot = 0,Ans = 0;

int F1[N],F2[N],A[N],mo[N];

void Calc(int x) {
	if(x < Ans) return ;
	int z = 0;
	for(int i=1; i<=n; i++) mo[i] = A[i]%x,z += mo[i];
	sort(mo+1,mo+n+1);
	int q = z/x;
	for(int i=n; i>=1 && q>=1; q--,i--) z -= mo[i];
//	cout<<x<<" "<<z<<endl;
	Ans = z <= k? max(Ans,x):Ans;
	return ;
}

void dfs(int pos,int S) {
	if(pos == tot+1) Calc(S);
	else {
		for(int i=1; i<=F2[pos]; i++) S *= F1[pos];
		for(int i=1; i<=F2[pos]+1; i++) {
			dfs(pos+1,S);
			S /= F1[pos];
		}
	}
	return ;
}
int main() {
	cin >> n >> k;
	for(int i=1; i<=n; i++) scanf("%d",&A[i]),he += A[i];
	sort(A+1,A+n+1);
	for(int i=2; i*i<=he; i++) {
		if(he%i) continue;
		int cnt = 0;
		while(he%i == 0) he /= i,cnt ++;
		F1[++tot] = i,F2[tot] = cnt;
	}
	if(he > 1) F1[++tot] = he,F2[tot] = 1;
	dfs(1,1);
	cout<<Ans;
	return 0;
}

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

const long long INF = 1001001001;

int main(){
    int n, k; cin >> n >> k;
    mcf_graph<int, long long> ans(2 * n + 2);
    int s = 2 * n, t = s + 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            long long a; cin >> a;
            ans.add_edge(i, n + j, 1, INF - a);
        }
    }
    for (int i = 0; i < n; i++) {
        ans.add_edge(s, i, k, 0ll);
        ans.add_edge(n + i, t, k, 0ll);
    }
    ans.add_edge(s, t, n * k, INF);

    cout << INF * n * k - ans.flow(s, t, n * k).second << "\n";

    vector<string> res(n, string(n, '.'));
    for (auto p : ans.edges()) {
        if (p.from == s || p.to == t || p.flow == 0) continue;
        res[p.from][p.to - n] = 'X';
    }

    for (int i = 0; i < n; i++)  cout << res[i] << "\n";
    return 0;
}

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


int GCD( int a, int b )
{
	while( true )
	{
		if( a % b == 0 ) return b;

		a %= b;
		if( b % a == 0 ) return a;

		b %= a;
	}
}


int main()
{
int i;
int j;
int N;
int X;
int x;
int D;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> X;
	cin >> x;

	D = abs( x - X );
	for( i = 1; i < N; i++ )
	{
		cin >> x;

		D = GCD( D, abs( x - X ) );
	}

	cout << D << endl;

	return 0;
}






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

void fnInput(int64_t& rnNumber)
{
  cin >> rnNumber;
}

int64_t fnMinStepGet(int64_t nNumber)
{
  int nSqrtInt = sqrt(nNumber);
  int64_t nMultplcand, nMultpler;
  int64_t nMinDiff = INT64_MAX;

  for (int n = 1; n <= nSqrtInt; n++)
  {
    if (nNumber % n == 0)
    {
      int64_t nOther = nNumber / n;
      if (nOther - n < nMinDiff)
      {
        nMultplcand = nOther;
        nMultpler = n;
        nMinDiff = nMultplcand - nMultpler;
      }
    }
  }

  return (nMultplcand + nMultpler - 2);
}

int main()
{
  int64_t nNumber;

  fnInput(nNumber);
  cout << fnMinStepGet(nNumber) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<array>
#include<deque>
#include<queue>
#include<map>
#include<cmath>
#include<stdio.h>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::array;
using std::queue;
using std::deque;
using std::priority_queue;
using std::multimap;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;
using std::sin;
using std::cos;
using std::log;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;
#define MOD 1000000007;
#define PI 3.141592653589793;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

string S;
lli K, i=0;

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

	cin >> S;
	cin >> K;
	while(S[i] == '1'){
		i++;
	}
	if(K <= i) cout << "1";
	else cout << S[i];
	return 0;
}


Measured memory_bytes: 256
/*=======================
Author    : Shounak Dey
Filename  : c.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int main()
{
	fast_io;
	double x;
	cin >> x;
	double p = x/3;
	cout << setprecision(6) << fixed;
	cout << p*p*p << endl;
	return 0;
}

Measured memory_bytes: 256
A,B,C,D,E,F = (int(x) for x in input().split())

CCT = {}
#可能な操作を全探索
for a in range(F//(100*A) +1): #Aをa回
    for b in range((F-a*A*100)//(100*B) +1): #Bをb回
        water = (a*A+b*B)*100
        max_suger = water*E//100
        for c in range(max_suger//C +1): #Cをc回
            for d in range((max_suger-c*C)//D +1): #Dをd回
                suger = c*C+d*D
                total = water + suger
                if total > F or total == 0 or max_suger < suger:
                    continue
                CCT[water,suger] = suger/total

ans = (A*100, 0)
max_cct = 0
for (water,suger),cct in CCT.items():
    if cct > max_cct:
        max_cct = cct
        ans = (water+suger, suger)
print(*ans)


Measured memory_bytes: 10064
import math


def averageLength():
    def calc(a, b):
        return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)

    N = int(input())
    x = []
    for _ in range(N):
        x.append(list(map(int, input().split())))

    d = 0
    for i in range(N):
        for j in range(i, N):
            d += calc(x[i], x[j])

    N_fac = math.factorial(N)
    a = 0 if N < 2 else math.factorial(N-2) * (N-1) * 2

    print(d * a / N_fac)


averageLength()


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    bool ans = false;
    if (a == b && a != c)ans = true;
    if (b == c && b != a)ans = true;
    if (c == a && c != b)ans = true;
    if (ans)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    sort(p.begin(), p.end());
    int sum = 0;
    for (int i = 0; i < k; i++) sum += p[i];
    cout << sum << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

string s;
int main(void) {
	cin >> s;
	bool f = false;
	rep(i, s.size() - 1) {
		if(s.substr(i, 2) == "AC") f = true;
	}
	if(f) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
module Main where
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B
import Data.Graph
import Control.Monad
import Data.List(sortOn, foldl')
import qualified Data.Array.IO as MV
import qualified Data.Array as A

readIntPair :: B.ByteString -> (Int,Int)
readIntPair s = p
    where
    Just p = do
        (n1, s') <- B.readInt s
        (n2, _ ) <- B.readInt (B.tail s')
        return (n1,n2)

main :: IO ()
main = do
    (n,m) <- fmap readIntPair B.getLine 
    es <- fmap (map readIntPair . B.lines) B.getContents
    let g = buildG (1,n) es
        vs = topSort g
    par <- MV.newArray (1,n) 0 :: IO (MV.IOUArray Int Int)
    forM_ vs $ \v -> do
        let cs = g A.! v 
        forM_ cs $ \w ->
            MV.writeArray par w v
    ps <- MV.getElems par
    putStr $ unlines $ map show ps


Measured memory_bytes: 37244
X, K, D = map(int, input().split())
if X + K * D <= 0:
    print(-X - K * D)
elif X - K * D >= 0:
    print(X - K * D)
else:
    div = X // D
    mod = X % D
    if (K-div) % 2 == 0:
        print(mod)
    else:
        print(abs(mod-D))


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;

//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//def function
//------------------------------------------


//main
//------------------------------------------

int main(){
  string S;
  cin >> S;
  int m_count=0;

  REP(i, S.size()){
    int count=0;
    FOR(j, i, S.size()){
      if(S.at(j)=='A'||S.at(j)=='C'||S.at(j)=='G'||S.at(j)=='T'){
        count++;
      }else{
        break;
      }
    }
    m_count = max(m_count, count);
  }

  cout << m_count << endl;
  return 0;
}


Measured memory_bytes: 256
#ifdef __APPLE__
#include <cassert>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cctype>
#include <list>
#include <cmath>
#include <limits>
#include <bitset>
#include <numeric>
#include <climits>
#include <complex>
#else
#include<bits/stdc++.h>
#endif // __APPLE__
using namespace std;
typedef pair<int,int>   II;
typedef vector<II>     VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int LL;
typedef  unsigned long long int ULL;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define ALL(c) (c).begin(),(c).end()
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i,a,b) for(int i = (int)a; i < (int)b; i++)
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)	{
cerr << name << " : " << arg1 << std::endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
     const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif
//C


LL func(LL a ,LL b)
{
    LL l1=0,l2=0;
    while(a>0)
    {
        l1++;
        a/=10;
    }
    while(b>0)
    {
        l2++;
        b/=10;
    }
    return max(l1,l2);
}



int main()
{
	//fr;fw;
	fast_io;
    LL n;
    cin>>n;
    LL tmp=(LL)(sqrt(n))+1;
    LL ans=LLONG_MAX;
    REP(i,1,tmp+1)
    {
        if(n%i==0)
        ans=min(ans,func(i,n/i));
    }
    cout<<ans<<endl;

	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
  cin>>n;
    int a[n];
     int b[n];
     for(int i=0;i<n;i++)
        cin>>a[i];
      b[0]=0;
      for(int i=1;i<n;i++)
      {   int p,q;
         p=a[i]-a[i-1];
        if(i>=2)
         q=a[i]-a[i-2];
       if(p<0)
         p=-p;
       if(q<0)
         q=-q;
         //cout<<"p="<<p<<" q="<<q<<endl;
           if(i>=2)
             b[i]=min(p+b[i-1],q+b[i-2]);
           else if(i==1)
             b[i]=p;

      }
     /* for(int i=0;i<n;i++)
        cout<<b[i]<<" ";
        cout<<endl;*/
     cout<<b[n-1];
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <queue>


/**
 * @Author MaxHeap
 **/

using namespace std;
	
typedef struct state {
  int a, x, y, z;
  state(int _a, int _x, int _y, int _z): a(_a), x(_x), y(_y), z(_z){}
}state;
void fail(){
  cout << "-1 -1 -1" << endl;
  exit(0);
}
int main(){
  int n, k; cin >> n >> k;
  int x = 0, y = 0, z = 0;
  while(1){
    if(k >= 10000){
      k-=10000;
      ++x;
      n--;
    }else if(k >= 5000){
      k-=5000;
      ++y;
      n--;
    }else if(k >= 1000){
      k -= 1000;
      ++z;
      n--;
    }else{
      cout << "-1 -1 -1" << endl;
      return 0;
    }
    if(n == 0 || k == 0) break;
  }
  if(n > 0 && k == 0){
    while(1){
      if(n >= 9 && x > 0){
        x--;
        n -= 9;
        z += 10;
      }else if(n >= 4 && y > 0){
        y--;
        n -= 4;
        z += 5;
      }else if (n >= 1 && x > 0){
        x--;
        n -= 1;
        y += 2;
      }else{
        fail();
      }
      if(n == 0){
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }else if(k == 0){
    cout << x << " " << y << " " << z << endl;
  }else{
    cout << "-1 -1 -1" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

ll n,k;
vector<ll> a,f;
void input(){
    cin >> n >> k;
    rep(i,n){
        ll x;cin >> x;
        a.pb(x);
    }
    sort(all(a));
    rep(i,n){
        ll x;cin >> x;
        f.pb(x);
    }
    sort(all(f));
    reverse(all(f));
}

bool judge(ll x){
    ll cost = 0;
    rep(i,n){
        cost += max(0ll,a[i] - x/f[i]);
    }
    if(cost > k)return false;
    else return true;
}

int main(void){
    input();
    ll l = 0,r = LONG_MAX;
    for(int i = 0;i < 100;i++){
        ll mid = (r+l)/2;
        if(judge(mid)){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << r << endl;
}

Measured memory_bytes: 5488
use proconio::{input, fastout, marker::Usize1};
#[fastout]
fn main() {
    input!{
        n: usize,
        k: usize,
        a: [Usize1; n],
    }

    let mut vec = vec![vec![0;64]; n];
    for i in 0..n {
        vec[i][0] = a[i];
    }

    for j in 1..64 {
        for i in 0..n {
            vec[i][j] = vec[vec[i][j-1]][j-1];
        }
    }

    let mut current = 0;
    for i in 0..64 {
        if (k >> i) & 1 == 1 {
            current = vec[current][i];
        }
    }


    println!("{}", current + 1);

}


Measured memory_bytes: 112784
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
int d[100005];

signed main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>d[i];
    sort(d,d+N);
    int mid=N/2;
    cout<<d[mid]-d[mid-1]<<endl;
}


Measured memory_bytes: 1024
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        var w1 = (long)Math.Pow(n / k, 3);
        if (k % 2 == 0)
        {
            var k2 = k / 2;
            var te = n >= k2 ? (n - k2) / k + 1 : 0;
            w1 += (long)Math.Pow(te, 3);
        }
        Console.WriteLine(w1);
    }
}


Measured memory_bytes: 13140
n,m=map(int, input().split())
a=list(map(int,input().split()))
a.sort()
cb=[0]*m
for i in range(m):
    b,c=map(int, input().split())
    cb[i]=(c,b)
cb.sort(reverse=True)

i=0
for j in range(m):
    for k in range(cb[j][1]):
        a[i]=max(cb[j][0],a[i])
        i+=1
        if i>=n:
            break
    else:
        continue
    break
print(sum(a))

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

void sort(vector<double> &v){
  for(int i=0; i<v.size(); i++){
  	for(int j=0; j<v.size()-i-1; j++){
      if(v[j] > v[j+1]){
      	double tmp = v[j];
        v[j] = v[j+1];
        v[j+1] = tmp;
      }
    }
  }
}

int main(){
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  
  
  while(v.size() > 1){
    sort(v);
    cerr << v[0] << " " << v[1] << endl;
    double tmp = (v[0] + v[1])/2;
    v.erase(v.begin());
    v.erase(v.begin());
    v.push_back(tmp);
  }
  
  cout << *v.begin() << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define MP make_pair
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

using Graph = vector<vector<pair<int, int>>>;
using vvec = vector<vector<int>>;
using vec = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int h,a;
    cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
    
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;};
void qmod(ll &a,ll b){a=(a*b)%MOD;};
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  char x,y;cin>>x>>y;
  if(x<y)cout<<"<"<<endl;
  else if(x>y)cout<<">"<<endl;
  else cout<<"="<<endl;


  return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

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

int h,w;
int A[60][60];

void bfs(int u,int v){
  queue<pair<int,int>> q;
  q.push({u,v});
  while(!q.empty()){
    auto t=q.front(); q.pop();
    int nx,ny;
    for(int i=0;i<4;i++){
      ny=t.first+dy[i], nx=t.second+dx[i];
      if(ny<0 || ny>=h || nx<0 || nx>=w) continue;
      if(A[ny][nx]!=0) continue;
      A[ny][nx]=A[t.first][t.second]+1;
      q.push({ny,nx});
    }
  }
}

int main() {
  cin>>h>>w;
  
  char c;
  int cnt=0;
  rep(i,h){
    rep(j,w){
      cin>>c;
      if(c=='#'){
        A[i][j]=-1;
        cnt++;
      }
      else A[i][j]=0;
    }
  }
  A[0][0]=1;
  
  bfs(0,0);
  if(A[h-1][w-1]==0) cout<<-1<<endl;
  else cout<<h*w-cnt-A[h-1][w-1]<<endl;
  
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

int mod_calc(int x, int y){
    if (y == 0) return 0;
    return x%y;
}

int main()
{
    int n; string s;
    cin >> n >> s;

    int cnt = 0;
    vector<int> sn(n); 
    rep(i, n) {
        if (s[i] == '1') cnt++;
        sn[i] = s[i] - '0';
    }

    vector<int> mod_first_minus(n), mod_first_plus(n); //0(minus), 1(plus)

    mod_first_minus[0] = mod_calc(1, cnt-1);
    mod_first_plus[0] = mod_calc(1, cnt+1);

    for (int i = 1; i < n; i++)
    {
        mod_first_minus[i] = mod_calc(mod_first_minus[i-1]*2, cnt-1);
        mod_first_plus[i] = mod_calc(mod_first_plus[i-1]*2, cnt+1);
    }

    int smod_plus = 0;
    int smod_minus = 0;
    rep(i, n){
        if (sn[i]){
            smod_plus += mod_first_plus[n-1-i]; smod_plus = mod_calc(smod_plus, cnt+1);
            smod_minus += mod_first_minus[n-1-i]; smod_minus = mod_calc(smod_minus, cnt-1);
        }
    }

    rep(i, n){
        int ans = 1;
        int second; 
        if (sn[i] == 0){
            //plus
            second = smod_plus + mod_first_plus[n-1-i]; second = mod_calc(second, cnt+1);
        } else {
            //minus
            second = smod_minus - mod_first_minus[n-1-i] + cnt-1; second = mod_calc(second, cnt-1);
            if (cnt-1 == 0) ans = 0;
        }

        while(second != 0){
            int bit = __builtin_popcountll(second);
            if (bit == 0) break;
            second %= bit;
            ans++;
        }
        cout << ans << endl;
    }

}



Measured memory_bytes: 6012
let () = Scanf.scanf "%d %d\n" @@ fun n t ->
  let abs = Array.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun a b -> a, b in
  Array.sort compare abs;
  let dp = Array.make 6001 0 in
  Array.iter (fun (a, b) ->
    for i = a + t - 1 downto a do
      dp.(i) <- max dp.(i) (b + dp.(i - a))
    done) abs;
  Printf.printf "%d\n" @@ Array.fold_left max min_int dp



Measured memory_bytes: 2944
#include<stdio.h>
#include<math.h>
int  min(int x,int y)
{   if(x>y)return y;
    else   return x;
}
int  min1(int a,int b,int c)
{   return min(min(a,b),c);
}

int main()
{ int a1,a2,a3,s1,s2,s3;
  scanf("%d %d %d",&a1,&a2,&a3);
  s1=fabs(a2-a1)+fabs(a3-a1);
  s2=fabs(a3-a2)+fabs(a1-a2);	
  s3=fabs(a1-a3)+fabs(a2-a3);
 
  printf("%d",min1(s1,s2,s3));
}

Measured memory_bytes: 128
function Main(input) {
	input = input.trim(); 
	input = input.split("\n");

	var slime = input[0];
	var colors = input[1].split("");

	var slime_cnt = slime;
	var color_back = "";
	for (var i = 0; i < slime; i++) {

		if (color_back === colors[i]) {
			slime_cnt--;
		}
		color_back = colors[i];
	}

	console.log(slime_cnt);
 
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 8396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n,k;
    cin >> n >> k;
    int cnt = 0;
    while(n > 0){
        n /= k;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#!/bin/env python
  
import sys

def validate(input):
    if input < 0 or input > 20:
        return False
    return True

def biscuitGen(input_a, input_b, input_t):
    biscuits = 0
    if validate(input_a) and validate(input_b) and validate(input_t):
        biscuits = int(input_t / input_a) * input_b
    return biscuits

if __name__=='__main__':
    '''
    print how many biscuit will be generated 
    A: Seconds to generate biscuit
    B: Number of biscuit pieces to generate once
    T: Limit of the seconds to generate biscuit
    1 <= A,B,T <= 20
    '''
    biscuit = 0
    inarray = list(map(int,input().split()))
    if len(inarray) != 3:
        print("Please input 3 numbers")
        sys.exit()
    biscuit = biscuitGen(inarray[0], inarray[1], inarray[2])
    print(biscuit)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		string line = Console.ReadLine();
		if(line.Contains("a") && line.Contains("b") && line.Contains("c"))
			Console.WriteLine("Yes");
		else
			Console.WriteLine("No");

	}

	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int n,r;
    cin>>n>>r;
    if(n>=10)
    {cout<<r;
    return 0;}
    else
    {
      cout<<r+100*(10-n);
      return 0;
    }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    int n; cin >> n;
    vector<int> a(n);
    int s = 0;
    rep(i, n) {
        cin >> a[i];
        s ^= a[i];
    }
    int ans;
    rep(i, n) {
        ans = s^a[i];
        cout << ans << endl;
    }
    
    return 0;
}

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

 using namespace std;

 int main() {
   int N, M, i;

   cin >> N >> M;

   vector<int> a(M + 1);
   vector<int> b(M + 1);
   vector<int> count(N + 1);

   for (i = 1; i <= M; i ++) cin >> a.at(i) >> b.at(i);

   for (i = 1; i <= M; i++) {
     count.at(a.at(i))++;
     count.at(b.at(i))++;
   }

   for (i = 1; i <= N; i++) {
     cout << count.at(i) << endl;
   }
 }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }
    double ave = accumulate(a.begin(), a.end(), 0.0) / N;
    int ans;
    double min_diff = 1.0e9;
    for(int i=0; i<N; i++) {
        if(abs(ave - a[i]) < min_diff) {
            min_diff = abs(ave - a[i]);
            ans = i;
        }       
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
for times in range(n):
	s=input()
	ans="NA"

	#A???????????§
	if s[:2]==">'" and s[-1]=="~":
		t=s[2:-1].split("#")

		if len(t)==2 and len(t[0])>0:
			valid=True
			for v in t[0]:
				if v!="=":
					valid=False
					break
			if valid and t[0]==t[1]:
				ans="A"

	#B???????????§
	elif s[:2]==">^" and s[-2:]=="~~":
		t=s[2:-2]

		if len(t)>0 and len(t)%2==0:
			valid=True
			for i in range(0,len(t),2):
				if t[i:i+2]!="Q=":
					valid=False
					break
			if valid:
				ans="B"

	print(ans)

Measured memory_bytes: 7636