akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 

 int main(){
  ll n,k ; cin>>n>>k ;
  vector<ll> A(n),B(n) ;
  rep(i,n) cin>>A[i] ;
  rep(i,n) cin>>B[i] ;
  sort(A.begin(),A.end()) ;
  sort(B.rbegin(),B.rend()) ;

  vector<ll> sum(n) ;
  ll end=0 ;
  ll big=0 ;
  rep(i,n){
     sum[i]=A[i]*B[i] ;
     big+= A[i] ;
   chmax(end,sum[i]) ;
  }

  ll l=0 ; ll r= end ;

  while(r-l>1){
    ll m = (r+l)/2 ;
    ll res= 0 ;
    rep(i,n){
      if(m<sum[i]) res+= (sum[i]-m+B[i]-1)/B[i] ;
    }
    if(res<=k) r=m ;
    else l=m ;
  }
  if(big<=k) cout<<0<<endl ;
  else cout<<r<<endl ;
  

   return 0 ;
 }



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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  int n=b-a;
  if(n<=0){
    cout << "delicious" << endl;
  }
  else if(n<=x){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

signed main()
{
	ios_base::sync_with_stdio(false);   
    cin.tie(NULL);

	// #ifndef ONLINE_JUDGE
 //      	freopen("input.txt", "r", stdin);
 //      	freopen("output.txt", "w", stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	string str;
    	cin>>str;
    	ll k;
    	cin>>k;
    	//map<char,int> mp;
    	ll count=1;
    	ll count1=1;
    	ll count2=1;
    	ll ans;
    	ll n=str.length();
         ll sum=0;
    	if(str[0]!=str[n-1]){
    	for(ll i=1;i<str.length();i++)
    	{
    		if(str[i]==str[i-1])
    		{
    			count++;
    		}
    		else{
    			//cout<<count<<" ";
    			sum=sum+count/2;
    			count=1;
    			//cout<<sum<<" ";
    		}



    	}
    	sum=sum+count/2;
    	cout<<k*sum;
    	return 0;
    }
    	else
    	{

    		for(ll i=1;i<n;i++)
    		{
    			if(str[i]==str[i-1])
    				count1++;
    			else
    				break;
    		}
    		for(ll i=1;i<str.length();i++)
    	     {
    		    if(str[i]==str[i-1])
    		    {
    			count++;
    		     }
    		   else{
    			//cout<<count<<" ";
    			sum=sum+count/2;
    			count=1;
    			//cout<<sum<<" ";
    		       }
            }
            //cout<<sum;
            sum=sum-count1/2;
            //cout<<sum<<count1;
            if(count1==n)
            {
            	//count=count1;
            	cout<<k*count/2;
            	return 0;
            }
    	count2=count;
            ans=count2/2+count1/2+((k-1)*((count1+count2)/2))+sum*k;
            cout<<ans;
    	
    	}
    	//cout<<sum<<endl;
    	//cout<<k*sum;
    	//cout<<n;

    	
    }
    return 0;
}

Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
map = [list(input()) for i in range(h)]
def bfs():
    d = [[float("inf")] * w for i in range(h)]
    sx = 0
    sy = 0
    dx = [0, -1, 0, 1]
    dy = [1, 0, -1, 0]
    d[sx][sy] = 0
    que = deque([])
    que.append((sx, sy))
    while que:
        p = que.popleft()
        if p[0] == h-1 and p[1] == w-1:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < h and 0 <= ny < w and map[nx][ny] != "#"\
            and d[nx][ny] == float("inf"):
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1
    return d[h-1][w-1]
count = 0
for i in range(h):
    for j in range(w):
        if map[i][j] == '#':
            count += 1
short = bfs()
if short == float("inf"):
    ans = -1
else:
    ans = h * w - count - short - 1
print(ans)           



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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 2e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
#define int long long
int n;
pair < ll, ll > a[N];
vector < ll > all;
pair < ll, ll > t[N * 4];
ll suff[N], pref[N];

void upd (int pos, int x, int v = 1, int tl = 1, int tr = sz(all)) {
    if (tl == tr) {
        t[v].S ++;
        t[v].F += x;
        return ;
    }
    
    int tm = (tl + tr) >> 1;
    if (pos <= tm) {
        upd (pos, x, (v << 1), tl, tm);
    } else {
        upd (pos, x, (v << 1) | 1, tm + 1, tr);
    }
    
    t[v].F = t[(v << 1)].F + t[(v << 1) | 1].F;
    t[v].S = t[(v << 1)].S + t[(v << 1) | 1].S;
}

ll get (ll k, int v = 1, int tl = 1, int tr = sz(all)) {
    if (!k) return 0;
    if (tl == tr) {
        if (!t[v].S) return 0;
        return k * (ll)(t[v].F / t[v].S);
    }
    ll tm = (tl + tr) >> 1;
    if (t[(v << 1) | 1].S >= k) return get(k, (v << 1) | 1, tm + 1, tr);
    return get(k - t[(v << 1) | 1].S, (v << 1), tl, tm) + t[(v << 1) | 1].F;
}

void add (ll x) {
    int id = lower_bound(every(all), x) - all.begin() + 1;
    upd(id, x);
}

ll solve (int Y, int Z) {
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    For (i, 1, n) {
        all.pb(a[i].S);
        all.pb(a[i].S - a[i].F);
    }
    sort(every(all));
    FOr(i, n, 1) {
        if (i >= Y && i <= Y + Z) {
            suff[i] = get(Y + Z - i);
        }
        
        add(a[i].S);
    }
    For (i, 1, N * 4 - 1) t[i] = mp(0, 0);
    ll ans = -INF;
    For(i, 1, Y + Z) {
        pref[i] = pref[i - 1] + a[i].F;
        add (a[i].S - a[i].F);
        if (i >= Y) {
            ans = max(ans, pref[i] + suff[i] + get(i - Y));
        }
    }
    
    return ans;
}

 main () {
    ll x, y, z;
    cin >> x >> y >> z;
    pair < ll, ll > SOOO = mp(y, z);
    ll sum = 0;
    n = x + y + z;
    For (i, 1, n) {
        cin >> x >> y >> z;
        y -= x;
        z -= x;
        a[i] = mp(y, z);
        sum += x;
    }
    
    cout << sum + solve (SOOO.F, SOOO.S);
}

// Coded By OB


Measured memory_bytes: 19312
#include <iostream>

using namespace std;

int main()
{
	int v[10000];
	for (int a = 0; a < 10000; a++) {
		cin >> v[a];
		if (v[a] == 0)break;
	}
	for (int a = 0; a < 10000; a++) {
		if (v[a] == 0)break;
		cout << "Case " << a+1 << ": " << v[a] << endl;
	}
}


Measured memory_bytes: 3056
n=int(input())
p=list( float(s) for s in input().split() )
 
res=[1-p[0], p[0]]+[0]*(n//2 - 1)
for i in range(1,n):
    for j in range(len(res)-1, 0, -1):
        res[j]=(res[j]*(1-p[i]) + (res[j-1]*p[i]) )
    res[0]=res[0]*(1-p[i])
print( (1-sum(res[:1+n//2])) )

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;
LL INF = 1000000007;

struct abc{
  LL a, b, c;
};

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

  LL N, Ma, Mb;
  cin >> N >> Ma >> Mb;

  vector<abc> yakuhin;
  REP(i,N){
    LL a, b, c;
    cin >> a >> b >> c;
    yakuhin.push_back({a, b, c});
  }

  vector<vector<vector<LL>>> dp(N + 1, vector<vector<LL>>(401, vector<LL>(401, INF)));
  dp[0][0][0] = 0;

  REP(i,N){
    REP(j,401){
      REP(k,401){
        dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
        if (j+yakuhin[i].a < 401&&k+yakuhin[i].b<401){
          dp[i + 1][j + yakuhin[i].a][k + yakuhin[i].b] =
              min(dp[i + 1][j + yakuhin[i].a][k + yakuhin[i].b], dp[i][j][k] + yakuhin[i].c);
        }
      }
    }
  }

  LL ans = INF;

  LL mma = 0;
  LL mmb = 0;
  while (true)
  {
    mma += Ma;
    mmb += Mb;
    if(mma>=401||mmb>=401){
      break;
    }

    ans = min(dp[N][mma][mmb], ans);
  }

  if(ans==INF){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
}

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

int main(void){
    int n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);

    rep(i, n) cin>>a[i];
    rep(i, n) cin>>b[i];
    rep(i, n) cin>>c[i];

    vector<pair<ll, ll> > v(2*n);
    rep(i, n) v[i]=make_pair(a[i], 1);
    rep(i, n) v[i+n]=make_pair(b[i], 2);
    sort(v.begin(), v.end());

    vector<pair<ll, ll> > v2(2*n);
    rep(i, n) v2[i]=make_pair(b[i], 1);
    rep(i, n) v2[i+n]=make_pair(c[i], 2);
    sort(v2.begin(), v2.end());

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll now=0;
    ll j=n-1;
    vector<ll> first_row(n);
    for(ll i=2*n-1;i>=0;i--){
        if(v[i].first>a[j]&&v[i].second==2) {
            now++;
        }
        else if(v[i].first==a[j]){
            first_row[j]=now;
            j--;
            i++;
        }
    }
    ll now2=0;
    ll j2=n-1;
    vector<ll> second_row(n);
    for(ll i=2*n-1;i>=0;i--){
        if(v2[i].first>b[j2]&&v2[i].second==2) {
            now2++;
        }
        else if(v2[i].first==b[j2]){
            second_row[j2]=now2;
            j2--;
            i++;
        }
    }
    vector<ll> ans(n);
    ans[0]=second_row[n-1];
    for(ll i=1;i<n;i++){
        ans[i]+=second_row[n-i-1]+ans[i-1];
    }
    ll res=0;
    rep(i, n) {
        if(first_row[i]>=1) res+=ans[first_row[i]-1];
    }
    /*rep(i, n) cout<<first_row[i]<<" ";
    cout<<endl;
    rep(i, n) cout<<second_row[i]<<" ";
    cout<<endl;
    rep(i, n) cout<<ans[i]<<" ";
    cout<<endl;*/
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    if(r < 1200){
        cout << "ABC" << endl;
    }else if(r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    
    return 0;
}


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

string s, t;

int main() {
	cin>>s>>t;
	int ans = 0;
	for(int i = 0 ; i< 3;i++)	ans += (s[i] == t[i]);
	cout<<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
def resolve():
    def dfs1(topo, par):
        for idx in reversed(topo):
            ret = 0
            child = 0
            for to in G[idx]:
                if to == par[idx]:
                    continue
                ret += EV[to] + 1.0
                child += 1
            #EV[idx] = 0
            if child >= 1:
                EV[idx] += ret / child


    def dfs2(idx, d_par, par):
        stack = [(idx, d_par, par)]
        while stack:
            idx, d_par, par = stack.pop()
            ret = 0
            for to in G[idx]:
                if to == par:
                    ret += d_par + 1.0
                else:
                    ret += EV[to] + 1.0
            ans[idx] = ret / len(G[idx])
            for to in G[idx]:
                if to == par:
                    continue
                max_l = max(1, len(G[idx]) - 1)
                nx_d_par = (ret - EV[to] - 1.0) / max_l
                stack.append((to, nx_d_par, idx))

    N = int(input())
    G = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)

    topo = []
    P = [-1] * N
    node = [0]
    while node:
        v = node.pop()
        topo.append(v)
        for to in G[v]:
            if to == P[v]:
                continue
            P[to] = v
            node.append(to)

    EV = [0] * N
    ans = [0] * N
    dfs1(topo, P)
    dfs2(0, 0, -1)
    for i in range(N):
        print(ans[i])

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 50468
n = int(input())
r_list = list(map(int, input().split()))
ans_list = []

for i in range(len(r_list)):
    if i == 0:
        a = sum(r_list)
        for j in range(1, len(r_list)):
            if j % 2 == 1:
                a -= r_list[j] * 2
    else:
        a = (2 * r_list[i-1]) - ans_list[i-1]
    ans_list.append(a)

print(' '.join(map(str, ans_list)))

Measured memory_bytes: 19092
#include<stdio.h>
int main(){
	int n,ans;
  	scanf("%d",&n);
  	if(n==1)ans=1;
  	if(n>=2)ans=2;
  	if(n>=4)ans=4;
  	if(n>=8)ans=8;
  	if(n>=16)ans=16;
  	if(n>=32)ans=32;
  	if(n>=64)ans=64;
 	printf("%d\n",ans);
  	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int x,a;
   cin >> x >> a;
   cout << (x<a ? 0 : 10) << endl;
 }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll X, Y; cin >> X >> Y;
	ll a = X;
	ll b = 1;

	rep(i, 0, 100000) {
		a *= 2;
		if (Y >= a) {
			b++;
		}
		else {
			break;
		}
	}

	cout << b << endl;
	return 0;
}

Measured memory_bytes: 256
def bfs(u)
  $q.push([u,nil])
  $pre[u] = nil
  while $q != []
    f = $q.first
    $l[f[0]].each do |i|
      if $pre[i] == nil && i != 1
        $q.push([i,f[0]])
        $pre[i] = f[0]
      end
    end
    $q.shift
  end
end
N,M = gets.chomp.split(" ").map(&:to_i)
$l = []
M.times do
  a,b = gets.chomp.split(" ").map(&:to_i)
  if $l[a]
    $l[a].push(b)
  else
    $l[a] = [b]
  end
  if $l[b]
    $l[b].push(a)
  else
    $l[b] = [a]
  end
end
$q=[]
$pre=[]
bfs(1)
puts "Yes"
$pre.each do |val|
  next if val == nil
  puts val
end

Measured memory_bytes: 34640
#include<iostream>
#include<string>
#include<algorithm>
int main(){
    int n;
    std::string s[100];
    std::cin >> n;
    for(int i=0;i<n;i++)std::cin >> s[i];
    for(int i=1;i<n;i++){
        if(s[i-1].back()!=s[i].front()){
            std::cout << "No";
            return 0;
        }
    }
    std::sort(s,s+n);
    for(int i=1;i<n;i++){
        if(s[i-1]==s[i]){
            std::cout << "No";
            return 0;
        }
    }
    std::cout << "Yes";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
const ll  big =2e5+5;
pair <int,int> p[1005];
ll a[1005],b[1005];

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
ll s,w;
cin>>s>>w;
if(w>=s)cout<<"unsafe";
else cout<<"safe";

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(void)
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    for (int i = sx; i < tx; ++i) cout << "R";
    for (int i = sy; i <= ty; ++i) cout << "U";
    for (int i = sx; i <= tx; ++i) cout << "L";
    for (int i = sy; i <= ty; ++i) cout << "D";
    cout << "R" << "D";
    for (int i = sx; i <= tx; ++i) cout << "R";
    for (int i = sy; i <= ty; ++i) cout << "U";
    for (int i = sx; i <= tx; ++i) cout << "L";
    for (int i = sy; i < ty; ++i) cout << "D";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
using namespace std;
#define maxn 100000
double h[maxn],s[maxn];
/*double fabs(int a,int b)
{
    if((a-b)>0)
        return a-b;
    else
        return b-a;
}*/
int main()
{
    int n,t,a;
    while(cin>>n>>t>>a)
    {
        for(int i=1;i<=n;i++)
    {
        cin>>h[i];
        s[i]=t-0.006*h[i];
    }
    double minn=999999;
   int cnt;
    for(int i=1;i<=n;i++)
    {

        if(minn>=fabs(s[i]-a))
        {
            minn=fabs(s[i]-a);
            cnt=i;
        }
    }
    cout<<cnt<<endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
std::ostream& operator<<(std::ostream& os, __int128 T)
{
    if (T<0) os<<"-";if (T>=10 ) os<<T/10;if (T<=-10) os<<(-(T/10));
    return os<<( (int) (T%10) >0 ? (int) (T%10) : -(int) (T%10) ) ;
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a+b+c-max(max(a,b),c));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int P, Q;
  while(cin>>P>>Q && P){
    vector<string> pcode(P); 
    vector<string> qcode(Q);
    REP(i, P) cin>>pcode[i];
    REP(i, Q) cin>>qcode[i];
    vector<int> indent(P - 1);
    int rcs[9][3] = {};
    int rcs2[10][3] = {};
    {
      int cnt[3] = {};
      string add = "({[";
      string sub = ")}]";
      REP(i, P){
        int idt = 0;
        bool bgn = false;
        REP(j, pcode[i].size()){
          if(pcode[i][j] == '.' && !bgn) idt++;
          else bgn = true;
          REP(k, 3) {
            if(pcode[i][j] == add[k]) cnt[k]++;
            if(pcode[i][j] == sub[k]) cnt[k]--;
          }
        }
        if(i != 0) indent[i - 1] = idt;
        if(i != P - 1) memcpy(rcs[i], cnt, sizeof(cnt));
      }
    }
    {
      int cnt[3] = {};
      string add = "({[";
      string sub = ")}]";
      REP(i, Q){
        REP(j, qcode[i].size()){
          REP(k, 3) {
            if(add[k] == qcode[i][j]) cnt[k]++;
            if(sub[k] == qcode[i][j]) cnt[k]--;
          }
        }
        if(i != Q - 1) memcpy(rcs2[i + 1], cnt, sizeof(cnt));
      }
    }
    set<int> ans[10];
    for(int R = 1; R <= 20; R++){
      for(int C = 1; C <= 20; C++){
        for(int S = 1; S <= 20; S++){
          bool ok = true;
          REP(i, P - 1) if(R * rcs[i][0] + C * rcs[i][1] + S * rcs[i][2] != indent[i]) ok = false;
          if(!ok) continue;
          REP(i, Q) ans[i].insert(R * rcs2[i][0] + C * rcs2[i][1] + S * rcs2[i][2]);
        }
      }
    }
    REP(i, Q){
      if(ans[i].size() == 1) cout<<*ans[i].begin();
      else cout<<-1;
      if(i == Q - 1) cout<<endl;
      else cout<<" ";
    }

  }
  return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int>S(N);
  for(int i=0; i<N; i++){
    cin>>S.at(i);
  }
 sort(S.begin(),S.end());
  reverse(S.begin(),S.end());
  int A=0;
  int B=0;
  for(int j=0; j<N;j+=2){
A+=S.at(j);
  }
  for(int j=1; j<N;j+=2){
    B+=S.at(j);
  }
  cout<<A-B<<endl;
}


Measured memory_bytes: 256
N,Q = map(int,input().split())
g = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    g[a-1].append(b-1)


ans = [0]*N
for i in range(Q):
    p,x = map(int,input().split())
    ans[p-1] += x

q = [0]
while q:
    p = q.pop()
    for c in g[p]:
        ans[c] += ans[p]
        q.append(c)

print(' '.join([str(x) for x in ans]))

Measured memory_bytes: 110336
<?php
/*
    Problem URL : http://arc074.contest.atcoder.jp/tasks/arc074_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */


fscanf(STDIN, "%s", $s);
$a = str_split($s);
$cnt = count($a);
$arr = array();

for ($i = 0; $i < $cnt; $i++) {
    $arr[$a[$i]] = 1;
}

$k = array_keys($arr);

if (count($k) == 1) {
    echo  "0" . PHP_EOL;
    exit;
}

$ans = PHP_INT_MAX;

foreach ($k as $moji) {
    $res = solve($s, $moji);
    $ans = min($res, $ans);
}

echo $ans . "\n";

function solve($s, $moji) {
    $cnt = 0;
    while(true) {
        $cnt++;
        $newS = "";
        for ($i = 0; $i < strlen($s) - 1; $i++) {
            if (substr($s, $i, 1) == $moji) {
                $newS .= substr($s, $i, 1);
            } elseif (substr($s, $i+1, 1) == $moji ) {
                $newS .= substr($s, $i+1, 1);
            } else {
                $newS .= substr($s, $i, 1);
            }
        }
        $flg = true;
        for ($i = 1; $i < strlen($newS); $i++) {
            if (substr($newS, 0, 1) != substr($newS, $i, 1)) {
                $flg = false;
            }
        }

        if ($flg === true) {
            return $cnt;
        } else {
            $s = $newS;
        }
    }
}


Measured memory_bytes: 4728
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string init(n, ' ');
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        init[i] = '0' + a - 1;
    }

    string goal(n, ' ');
    for(int i=0; i<n; ++i)
        goal[i] = '0' + i;
    if(init == goal){
        cout << 0 << endl;
        return 0;
    }

    vector<set<string> > history(2);
    history[0].insert(init);
    history[1].insert(goal);
    vector<queue<string> > q(2);
    q[0].push(init);
    q[1].push(goal);

    int ret = 1;
    for(int k=0; ; k=(k+1)%2){
        int m = q[k].size();
        while(--m >= 0){
            string s = q[k].front();
            q[k].pop();

            for(int i=0; i<n; ++i){
                for(int j=i+1; j<n; ++j){
                    string t = s;
                    reverse(t.begin()+i, t.begin()+j+1);

                    if(history[k^1].find(t) != history[k^1].end()){
                        cout << ret << endl;
                        return 0;
                    }

                    if(history[k].find(t) == history[k].end()){
                        history[k].insert(t);
                        q[k].push(t);
                    }
                }
            }
        }
        ++ ret;
    }
}

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

int main() {
  int N;
  int i;
  cin >> N;
  int A[N];
  for(i=0;i<N;i++){
    cin >> A[i];
  }
   sort(A,A+N,greater<int>());
   int ret = 0;
   for (i=0;i<N;i++)
   ret +=A[i]*(i&1?-1:1);
   cout << ret << endl;
   return 0;
 }

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: String = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let ans = if S.find("AC") != None { "Yes" } else { "No" };

    println!("{}", ans);
}


Measured memory_bytes: 4352
def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return cnt


def shellSort(A, n):
    cnt = 0
    m = 0
    G = [1]
    while G[-1] < n:
        G.append(G[m] * 3 + 1)
        m += 1
    if len(G) != 1:
        del G[-1]
        G.reverse()
    else:
        m = 1
    for i in range(m):
        cnt = insertionSort(A, n, G[i], cnt)
    return m, G, cnt


n = int(input())
a = [int(input()) for _ in range(n)]
m, G, cnt = shellSort(a, n)
print(m)
print(" ".join(map(str, G)))
print(cnt)
for i in range(n):
    print(str(a[i]))



Measured memory_bytes: 45520
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,d,e,f,v1,v2,v3,w=0,v=0;
    double maxx=0;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    for(int i=0;i<=3000;i++)
        for(int j=0;j<=3000;j++)
    {
        v1=c*i+d*j;
        if(v1<f)
        {
            if(v1%e==0)
            v2=v1/e;
            else
                v2=v1/e+1;
            if(v2%a!=0&&v2%b!=0)
            {
                v3=v2%a;
                if(v3%b==0)
                    v2=v2/a*a+v3;
                else
                    v2=v2/a*a+(v3/b+1)*b;
            }
            if(v2*100+v1<=f)
            {
                if(v1*100.0/(v2*100+v1)>maxx)
                {
                    maxx=v1*100.0/(v2*100+v1);
                    w=v2*100+v1;
                    v=v1;
                }
            }
        }
    }
    for(int i=0;i<=3000;i++)
        for(int j=0;j<=3000;j++)
    {
        v1=c*i+d*j;
        if(v1<f)
        {
            if(v1%e==0)
            v2=v1/e;
            else
                v2=v1/e+1;
            if(v2%a!=0&&v2%b!=0)
            {
                v3=v2%b;
                if(v3%a==0)
                    v2=v2/b*b+v3;
                else
                    v2=v2/b*b+(v3/a+1)*a;
            }
            if(v2*100+v1<=f)
            {
                if(v1*100.0/(v2*100+v1)>maxx)
                {
                    maxx=v1*100.0/(v2*100+v1);
                    w=v2*100+v1;
                    v=v1;
                }
            }
        }
    }
    if(maxx==0)
        printf("%d %d\n",100*a,0);
    else
    printf("%d %d\n",w,v);
    return 0;
}


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

int cmpnum(const void * n1, const void * n2)
{
	if (*(int *)n1 > *(int *)n2)
	{
		return -1;
	}
	else if (*(int *)n1 < *(int *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  int n[3];
  scanf("%d %d %d", &n[0], &n[1], &n[2]);
  qsort(n, 3, sizeof(int), cmpnum);
  int count = n[0]-n[1];
  n[2] += count;
  count += (n[0]-n[2])/2;
  if ((n[0]-n[2])%2 != 0) {
    count += 2;
  }
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 128
N = int(input())
*A, = map(int, input().split())
# 山1の雨の量を2分探索
l, r = 0, 2*min(A[0], A[-1])
while l <= r:
    m1 = (l+r)//2
    m = m1
    for i in range(N):
        m = 2*A[i]-m
    if m == m1:
        l = m
        break
    elif m1 < m:
        l = m1 + m1 % 2
    else:
        r = m1 - m1 % 2

m = [0]*N
m[0] = l
for i in range(1, N):
    m[i] = 2*A[i-1]-m[i-1]
print(*m)


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

template<typename T>
T gcd(T x,T y){return y?gcd(y,x%y):x;}

int main()
{
	int T; scanf("%d",&T);
	unsigned long int A,B,C,D;
	for(;0<T;T--)
	{
		scanf("%ld%ld%ld%ld",&A,&B,&C,&D);
		if(A<B||D<B||C<A%B||C<B-gcd(B,D)) puts("No");
		else puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>

int n,t[55],Ans;
std::string s[55],f;

int main()
{
    std::cin>>n;
    for(int i=1;i<=n;++i)std::cin>>s[i]>>t[i];
    std::cin>>f;
    for(int i=1,j=0;i<=n;++i)
    {
        if(j)Ans+=t[i];
        if(!j&&f==s[i])j=1;
    }
    std::cout<<Ans<<std::endl;
    return 0;
}


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

#define int long long

int N,D[2];
int bit[1010][1010];
signed main(){
  cin >> N >> D[0] >> D[1];
  for(int c = 0;c < 2;c++){
    int d = D[c];
    int p = 0;
    while(d % 2 == 0){
      p++;
      d /= 2;
    }
    if(p & 1){
      // ボーダー
      int h = (1 << (p / 2));
      rep(i,0,N * 2 - 1) rep(j,0,N * 2 - 1){
        if((j % (h * 2)) >= h) bit[i][j] = 1;
      }
    }
    else{
      int h = (1 << (p / 2));
      rep(i,0,N * 2 - 1) rep(j,0,N * 2 - 1){
        if(((i % (h * 2)) >= h) xor ((j % (h * 2)) >= h)){
          bit[i][j] = 1;
        }
      }
    }
  }

  int cou = 0;
  rep(i,0,N * 2 - 1) rep(j,0,N * 2 - 1){
    if(!bit[i][j]){
      cou++;
      cout << i << " " << j << endl;
    }
    if(cou == N * N) return 0;
  }
  if(cou != N * N){
    int a = 0;
    cout << 4 / a << endl;
  }
}


Measured memory_bytes: 7040
"use strict";

function main(input) {
  //かかる秒数　開業からの運行開始　運行間隔
  input = input.split("\n");
  // const n = ~~input.shift()
  // const n = ~~input[0];
  input = input.slice(1, input.length - 1);
  input = input.map(v => v.split(/\s/).map(x => ~~x));

  let ans = [];
  for (let i = 0; i < input.length; i++) {
    let time = 0;
    for (let j = i; j < input.length; j++) {
      if (time < input[j][1]) {
        //到着した駅の発車時刻が到着時刻より大きい
        time = input[j][1]; // 発車時刻を待つ
      } else if (time % input[j][2] != 0) {
        //到着時に発車間隔が合わなければ、 合わない分だけ待つ
        time += input[j][2] - (time % input[j][2]);
      }
      // time += (time > input[j][1]) ? 0 : input[j][1] - (time)
      time += input[j][0];
    }
    ans.push(time);
    // ans += time + '\n';
  }
  ans.push(0);
  //   ans += "0";

  console.log(ans.join("\n"));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7996
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int x=1+2*(k-1);
		if(n<x) {
			System.out.println("NO");
		}else {System.out.println("YES");}
	}
}


Measured memory_bytes: 22996
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define ll              long long
#define ull             unsigned long long
#define pb              push_back
#define fastread()      (ios_base:: sync_with_stdio(false),cin.tie(NULL));
using namespace std;
int main()
{
    fastread();
    int n,N;
    string s,t;
    cin>>s>>t;
    n = s.length();
    N = t.length();

    int c = 0;
    for(int i=0; i<n; i++){
        if(s[i] != t[i]){
            c++;
        }
    }
    cout<<c<<endl;

    return 0;
}

Measured memory_bytes: 3768
import numpy as np
N, K = map(int,input().split())
td = np.empty((N,2),dtype=np.int64)
for i in range(N):
    td[i] = list(map(int,input().split()))

t = td[:,0]-1
d = td[:,1]
order1=np.argsort(d)[::-1]
mins = len(set(t[order1[:K]]))

best = -np.ones(N,dtype=np.int64)
for i in range(N):
    if best[t[i]] < 0 or d[i] > d[best[t[i]]]:
        best[t[i]]=i

bestmenu = np.array(list(set(best) - set([-1])),dtype=np.int64)
othermenu = np.array(list(set(range(N)) - set(bestmenu)),dtype=np.int64)

maxs = min(len(bestmenu),K)
ans = 0
bests=0
sorted_d_best=np.sort(d[bestmenu])[::-1]
sorted_d_other=np.sort(d[othermenu])[::-1]
for s in range(mins,maxs+1):
    score = s*s + sorted_d_best[:s].sum() + sorted_d_other[:(K-s)].sum()
    if score > ans:
        bests=s
        ans = score

print(ans)

Measured memory_bytes: 34748
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;

int main(){
    // input
    vector<int> X(3);
    cin >> X.at(0) >> X.at(1) >> X.at(2);
    
    // compute
    sort(X.begin(),X.end());
    int ans = X.at(0) + X.at(1);
    
    // output
    cout << ans << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int depth(int i) {
	if (i == 1) return 1;
	return 1 + depth(i / 2);
}

int N;
vector<int> V, W;

void input(void) {
	cin >> N;
	V.resize(N); W.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> V[i] >> W[i];
}

vector<vector<int>> dp;

void dfs(int s, vector<int>& res, int dep) {
	if (s > N) return;
	if (dep > 9) return;
	dp[s] = res;
	for (int w = 0; w <= 100000; ++w) 
		if (w >= W[s - 1])
			dp[s][w] = max(dp[s][w], res[w - W[s - 1]] + V[s - 1]);
	dfs(s * 2, dp[s], dep + 1);
	dfs(s * 2 + 1, dp[s], dep + 1);
}

void build(void) {
	dp.resize(N + 1);
	vector<int> dp(100001, 0);
	dfs(1, dp, 1);
}

vector<pair<int, int>> all_find(int st, int gl = 0) {
	vector<pair<int, int>> res(1, {0, 0});
	while (st > gl) {
		int v = V[st - 1], w = W[st - 1];
		vector<pair<int, int>> tmp = res;
		for (auto p : res) 
			tmp.emplace_back(p.first + w, p.second + v);
		res = tmp;
		st /= 2;
	}
	return res;
}

void solve(int x, int L) {
	if (depth(x) <= 9) {
		cout << dp[x][L] << endl;
		return;
	}
	int _x = x;
	while (depth(_x) > 9) _x /= 2;
	auto tmp = all_find(x, _x);
	int res = 0;
	for (auto p : tmp) 
		if (p.first <= L)
			res = max(res, p.second + dp[_x][L - p.first]);
	cout << res << endl;
}

int main(void) {
	input();
	build();
	int Q; cin >> Q;
	while (Q--) {
		int v, L; cin >> v >> L;
		solve(v, L);
	}
	return 0;
}

Measured memory_bytes: 212092
#include <bits/stdc++.h>
using namespace std;
int n,m,l,r,L,R=1234567;
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>l>>r;
		if(L<l)L=l;
		if(R>r)R=r;
	}
	if((R-L+1)>=0)cout<<(R-L+1)<<endl;
	else cout<<0<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N,A,B;cin >> N >> A >> B;
    LL ans = 0;
    LL a = A*(N-1) + B;
    LL b = B*(N-1) + A;

    ans = b - a + 1;

    if(ans < 0)ans = 0;
    
    cout << ans <<  endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {public static void main(String[] args) throws Exception{
    Scanner sc = new Scanner(System.in);
    int i,j,m,h;
    String f;
    for(i=0;i<10;i++){
        f=sc.next();
        if(f.equals("-"))break;
        m=sc.nextInt();
        for(j=0;j<m;j++){
            h=sc.nextInt();
            f=f.substring(h)+f.substring(0,h);
        }
        System.out.println(f);
        
    }
    }
}


Measured memory_bytes: 26436
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
 #define all(v) (v).begin(),(v).end()
 using ll = long long;
using Graph = vector<vector<int>>;
const int MAX = 510000;
const int MOD = 1000000007;
 
 
 
int main(){
ll a;
  cin>>a;
  cout<<a*(a-1)/2;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef tuple<ll,ll,int> P;
typedef pair<ll,P> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// combination mod prime
// mintが必要
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

mint dp[5010][5010];

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l=s.size();
    dp[0][0]=1;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=5000;j++){
            if(j!=0)dp[i+1][j]+=dp[i][j-1]*2;//add
            if(j==0)dp[i+1][j]+=dp[i][j];//back(j=0)
            dp[i+1][j]+=dp[i][j+1];//back(j!=0)
        }
    }
    mint ans = dp[n][l];
    rep(i,l){
        ans /= 2;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int k,x;
  cin>> k >> x;
  
  for (int i=x-k+1; i<x+k; i++){
    if (i>x-k+1) cout<< " ";
    cout<< i;
  }
  cout<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <random>
#include <map>
#include <set>
#include <boost/lexical_cast.hpp>

using namespace std;


using ULL = decltype(0ull);
constexpr auto DIV = 1000000007ull;
constexpr auto MAX = numeric_limits<ULL>::max();
int main() {
  string str;
  cin >> str;
  ULL result = 0;
  char color = str[0];
  for (int i = 1; i < str.size(); ++i) {
    if (color != str[i]) {
      ++result;
      color = str[i];
    }
  }
  cout << result << endl;
  return 0;
}


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

string s;
int cum[26][200010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j+1 < s.size(); j++) {
      cum[i][j+1] = cum[i][j] + (s[j]-'a' == i);
    }
  }
  ll ans = 1;
  for (int i = 0; i < s.size(); i++) {
    ans += i - cum[s[i]-'a'][i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 20884
//Created by: Aditya Singh
//Bleed Blue
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define unm unordered_map<int,int>
#define pb emplace_back
#define nt _int128
#define PI 3.1415926535897932384626433
#define inf 1e18

const int N = 100005;

int dp[N], ar[N];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    // int t;cin>>t;while(t--)
    {
        int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
        cin >> n >> k;
        for (i = 0; i < n; i++)
        {
            cin >> ar[i];
            dp[i] = inf;
        }
        dp[0] = 0;
        for (i = 0; i < n; i++)
        {
            for (j = i + 1; j <= min(i + k, n - 1); j++)
                dp[j] = min(dp[j], dp[i] + abs(ar[i] - ar[j]));
        }
        cout << dp[n - 1];
    }
    return 0;
}

Measured memory_bytes: 5160
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

long long gcd(int a, int b){
  if (a%b == 0){
    return(b);
  }
  else{
    return(gcd(b, a%b));
  }
}

int main(){    
  long long N,M;
  cin >> N >>M;
  
  long long A[M],sum=0,a;

  for(int i=0;i<M;i++){
    cin >> a;
    N = N-a;
  }

  if(N<0){
    cout << "-1" << endl;
  }
  else{
  cout << N << endl;
  }
}
 



Measured memory_bytes: 3636
//                        Bismillahir Rahmanir Rahim
//ALGO:
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define mx 1000010
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=01;
int state[100010], a[110], n;
int check(int x){
    if(x<0) return 1;
    if(~state[x]) return state[x];
    int ret=1;
    for(int i=0; i<n; i++) ret*=check(x-a[i]);
    return state[x]=1-ret;
}
int main() {
    FILL(state, -1);
    int k;
    cin>>n>>k;
    for(int i=0; i<n; i++) cin>>a[i];
    if(check(k))cout<<"First";
    else cout<<"Second";
}



Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		// スペース区切りの整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		
        if((a == 2)|(b == 2)){
			// 出力
			System.out.println("No");
			return;
        }
        if ((a == 1 ) | (a ==  3) | (a == 5) | ( a == 7 ) |
           (a ==  8 ) | ( a == 10 ) | ( a == 12 )){
            if ((b == 1 ) | (b ==  3) | (b == 5) | ( b == 7 ) |
                    (b ==  8 ) | ( b == 10 ) | ( b == 12 )){
			// 出力
			System.out.println("Yes");
            }else{
    			System.out.println("No");
            }
        }else{
            if ((b == 1 ) | (b ==  3) | (b == 5) | ( b == 7 ) |
                    (b ==  8 ) | ( b == 10 ) | ( b == 12 )){
			// 出力
			System.out.println("No");
            }else{
    			System.out.println("Yes");
            }

        }

	}
}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
  int p;
  int count=0;
  int ans=0;
   for(int i=1;i<=n;i++)
   {
       p=i;
      count=0;

      while(p!=0)
      {
        count++;
        p=p/10;
      }
      if(count%2!=0)
      {
        ans++;
      }
      
   }
   cout<<ans;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,c,i,d[]={500,100,50,10,5,1};
  while(1){
    scanf("%d",&n);
    if(!n)break;
    n=1000-n;
    c=0;
    for(i=0;i<6;i++){
      c+=n/d[i];
      n%=d[i];
    }
    printf("%d\n",c);
  }
  return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi 1
#define LL long long
#define ULL unsigned long long
#define LD long double

using namespace std;

#define MAX_N 1000
#define MAX_M 1000;

int N, M, K;

int main()
{
  cin >> N >> M >> K;

  bool flag = false;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M; j++) {
      int ans = 0;
      ans += i * M;
      ans += j * N - i*j*2;
      //cerr << i << " " << j << " " << ans << endl;
      if(ans == K) {
        flag = true;
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 200003;
int n;
LL ans, d, a[N], f[N], g[N];
int main(){
	scanf("%d%lld", &n, &d);
	for(Rint i = 1;i <= n;i ++){
		scanf("%lld", a + i);
		ans += a[i];
	}
	f[1] = a[1];
	for(Rint i = 2;i <= n;i ++) f[i] = min(f[i - 1] + d, a[i]);
	g[n] = a[n];
	for(Rint i = n - 1;i;i --) g[i] = min(g[i + 1] + d, a[i]);
	for(Rint i = 2;i < n;i ++) ans += min(f[i], g[i]);
	printf("%lld\n", ans + (n - 1) * d);
}

Measured memory_bytes: 4864
x1,y1,x2,y2=map(int,input().split())
x3,y3=x2-(y2-y1),y2+(x2-x1)
x4,y4=x3-(x2-x1),y3-(y2-y1)
print('{} {} {} {}'.format(x3,y3,x4,y4))

Measured memory_bytes: 2940
import math


def main():
    a, b = map(int, input().split())
    data = input().split('-')
    if len(data) == 2:
        if len(data[0]) == a and len(data[1]) == b:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int n;
  cin>>n;
  string s;
  map<string,int>dic;
  int mx=0;
  rep(i,n){
    cin>>s;
    dic[s]++;
    mx=max(dic[s],mx);
  }
  for(auto p:dic){
    if(p.sc==mx)
      cout<<p.fs<<endl;
  }
}

Measured memory_bytes: 25216