akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
	int a[3];
	cin>>a[1]>>a[2]>>a[3];
	if(a[1]==a[2]&&a[3]!=a[1])
	cout<<"Yes";
	else if(a[2]==a[3]&&a[1]!=a[3])
	cout<<"Yes";
	else if(a[1]==a[3]&&a[2]!=a[3])
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=1e9+7;
const long double PI = acos(0);
// }}} End Header
int main() {
	ll n, ans = 0, sum = 0;
	cin >> n;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
		sum+=a[i];
	}
	rep(i,n-1){
		sum-=a[i];
		ll t = (a[i]%mod*(sum%mod));
		ans+=t;
		ans%=mod;
	}
	cout << ans << endl;
	//cout << sum << endl;
	return 0;
}

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

#define  int  long long
#define  endl  '\n'
const int mod = 1e9 + 7;


int32_t main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  
  string s,t ;
  cin >> s >> t;  

  int cnt = 0;

  for(int i =0; i < s.size(); i++)
    cnt+= s[i] == t[i];

  cout << cnt;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[33];
map <int, int> mp;
int ans;

int main() {
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		cin >> k;
		for(int j = 1; j <= k; j++) {
			cin >> a[i];
			mp[a[i]]++;
		}
	}
	for(int i = 1; i <= m; i++) {
		if(mp[i] == n) ans++;
	}
	cout << ans << endl;
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,i;
	bool q=true;
	string s;
	cin>>a>>b>>s;
	for (i=0;i<a;i++){
		if (s[i]=='-'){
			q=false;
		}
	}
	if (s[a]!='-'){
		q=false;
	}
	for (i=a+1;i<s.size();i++){
		if (s[i]=='-'){
			q=false;
		}
	}
	if (q==false){
		cout<<"No";
	}
	else {
		cout<<"Yes";
	}
	return 0;
}

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

int solve(long long n)
{
    int ans=1;
    for(int i=2; i<=sqrt(n); i++)
    {
        if(n%i==0) ans++;
        while(n%i==0)
            n/=i;
    }
    if(n>1) ans++;
    return ans;
}

int main()
{
    long long a,b,ans=0;
    cin>>a>>b;
    long long n=__gcd(a,b);
    ans=solve(n);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
//const long double EPS=1E-8;
////////////////////////////////////////
#define MAX_N (ll)2E7///変更！！！！！！！
vector<int>prime;
bool is_prime[MAX_N+1];
void precal(){
    rep(i,0,MAX_N)is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    rep(i,2,MAX_N){
        if(is_prime[i]){
            prime.pb(i);
            for(int j=2*i;j<=MAX_N;j+=i)is_prime[j]=false;
        }
    }
}
vector<i_i> fact(ll n){//ただし2<=n<=MAX_N^2
    vector<i_i>v;
    for(int p:prime){
        if(p*p>n)break;
        int c=0;
        while(n%p==0){
            n/=p;
            c++;
        }
        if(c)v.pb(i_i(p,c));//pという素因数がc個入っている
    }
    if(n!=1){
        int vsize=v.size();
        if(vsize>=1&&v[vsize-1].first==n)v[vsize-1].second++;
        else v.pb(i_i(n,1));
    }
    return v;
}
/////////////////////////////////////////////////////
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    
   // precal();
    ll n,m;cin>>n>>m;
    vector<ll>p;
    for(int i=1;i*i<=m;i++){
        if(m%i==0){
            if(i*i==m)p.pb(i);
            else{
                p.pb(i);p.pb(m/i);
            }
        }
    }
    sort(p.begin(),p.end());
    ll q=*lower_bound(p.begin(),p.end(),n);
    ll ans=m/q;
    cout<<ans<<endl;
    
    return 0;
}
//ios::sync_with_stdio(false);cin.tie(0);


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <climits>
#include <queue>

#define INF INT_MAX

using namespace std;

int main(){
  int n; cin >> n;
  vector<pair<int,int> > G[n];
  for(int i=0;i<n;i++){
    int u,k; cin >> u >> k;
    for(int j=0;j<k;j++){
      int v,c; cin >> v >> c;
      G[u].push_back(make_pair(v,c));
    }
  }
  //dijkstra from 0
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > PQ;
  int visited[n],d[n];
  for(int i=0;i<n;i++){
    visited[i]=0;
    d[i]=INF;
  }
  d[0]=0;
  PQ.push(make_pair(d[0],0));
  while(PQ.empty()==false){
    int u=PQ.top().second;
    int u_first=PQ.top().first;
    PQ.pop();
    //cout << "u:" << u << endl;
    visited[u]=1;
    if(d[u]<u_first) continue;
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i].first;
      //cout << "v:" << v << endl;
      if(visited[v]==0){
        if(d[u]+G[u][i].second<d[v]){
          d[v]=d[u]+G[u][i].second;
          PQ.push(make_pair(d[v],v));
        }
      }
    }
  }
  for(int i=0;i<n;i++) cout << i << " " << d[i] << endl;
}

Measured memory_bytes: 7732
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

struct unionFind {
    vector<int> data;
    unionFind(int size) : data(size, -1) {}
    
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if(data[y] < data[x]) {
                swap(x, y);
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int root(int x) {
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }

    int rank(int x) {
        return -data[root(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    ll A[M], B[M];
    REP(i, 0, M) {
        cin >> A[i] >> B[i];
    }
    unionFind u(N);
    REP(i, 0, M) {
        u.unite(A[i] - 1, B[i] - 1);
    }
    ll ans = 0;
    REP(i, 0, N) {
        ans = max(ans, (ll)u.rank(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 7124
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#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 print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 
 
int main() {
    int n, mc = 0;
    cin >> n;
    unordered_map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s] += 1;
        mc = max(mc ,mp[s]);
    }
    vector<string> vm;
    for (auto& p : mp)  {
        if (p.second == mc) vm.push_back(p.first);
    }
    sort(vm.begin(), vm.end());
    for (auto& v : vm) {
        cout << v << endl;
    }
    return 0;
}

Measured memory_bytes: 26692
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
const LL MAX_V = 1000000000000000LL;
int s(LL x){
    if(x<10)return x;
    return x%10+s(x/10);
}
int main(){
    VL an;
    FOR(i,1,9){
        an.PB(i);
    }
    LL nine=9;
    LL ten=10;
    while(nine<=MAX_V){
        for(LL now=ten+nine;now<=MAX_V;now+=ten){
            LL v1=s(now);
            LL nxt2=now+ten;
            LL nxt=now+ten;
            while(s(nxt+now)>s(nxt))nxt+=now;
            LL v2=s(nxt);
            LL v3=s(nxt2);
            if(now*v2<=nxt*v1&&now*v3<=nxt2*v1)an.PB(now);
            else break;
        }
        nine=nine*10+9;
        ten*=10;
    }
    int K;
    R(K);
    SORT_UNIQUE(an);
    REP(i,K)W(an[i]);
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
MOD = 10**9 + 7
D = [[0]*(K+1) for i in range(N+1)]
D[0][0] = 1
for n in range(1, N+1):
    for k in range(1, K+1):
        D[n][k] = (D[n-1][k-1]+k*D[n-1][k]) % MOD
print(sum(D[N])%MOD)


Measured memory_bytes: 29348
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 2e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  int m = n.size();
  if (m < k) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  if (k == 1) {
    ans += (m - 1) * 9;
    ans += n[0] - '0';
  }
  else if (k == 2) {
    ans += (m - 1) * (m - 2) / 2 * 9 * 9;
    ans += (n[0] - '1') * (m - 1) * 9;
    int idx = 1;
    while (idx < m && n[idx] == '0') idx++;
    if (idx < m) ans += (m - 1 - idx) * 9 + (n[idx] - '0');
  }
  else {
    ans += (m - 1) * (m - 2) * (m - 3) / 6 * 9 * 9 * 9;
    ans += (n[0] - '1') * (m - 1) * (m - 2) / 2 * 9 * 9;
    int idx = 1;
    while (idx < m && n[idx] == '0') idx++;
    if (idx < m - 1) {
      ans += (m - 1 - idx) * (m - 2 - idx) / 2 * 9 * 9 + (n[idx] - '1') * (m - 1 - idx) * 9;
      idx++;
      while (idx < m && n[idx] == '0') idx++;
      if (idx < m) {
        ans += (m - 1 - idx) * 9 + (n[idx] - '0');
      }
    }
  }
  cout << ans << endl;





  
  return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
    int a, b;
    cin >> a >> b;
    for(int c = 1; c <= 3; c++){
        if(a * b * c % 2 != 0){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}



Measured memory_bytes: 256
"use strict";

function Main(input) {
	var input = input.split("\n");
	if(input[0] === input[1].substring(0, input[1].length - 1)){
    	console.log('Yes');
    } else {
      	console.log('No');
    }
}

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


Measured memory_bytes: 29604
N = int(input())
a = list(map(int, input().split()))

dp = [[0] * 2 for _ in range(N+1)]
dp[0][0] = 0
dp[0][1] = -10**18

for i in range(1, N+1):
    dp[i][0] = max(dp[i-1][0]+a[i-1], dp[i-1][1]-a[i-1])
    dp[i][1] = max(dp[i-1][0]-a[i-1], dp[i-1][1]+a[i-1])
print(dp[N][0])



Measured memory_bytes: 31024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    long a[n][2];
    long c[m][2];
    int i,j;
    for(i=0;i<n;i++){
        cin >> a[i][0] >> a[i][1];
    }
    for(i=0;i<m;i++){
        cin >> c[i][0] >> c[i][1];
    }
    long tmp;
    long x;
    for(i=0;i<n;i++){
        tmp=pow(10,9);
        for(j=0;j<m;j++){
            if((abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]))<tmp){
                tmp=abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]);
                x=j+1;   
            }
        }
        cout <<x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
dem = [[0, 0] for i in range(M)]
for i in range(M):
    dem[i][0], dem[i][1] = map(int, input().split())
dem.sort(key=lambda x: (x[1]))
br_flag = [False for i in range(N-1)]
count = 0
a = 0
for i in range(M):
    if a < dem[i][0]:
        br_flag[dem[i][1]-2] = True
        a = dem[i][1] - 1
        count += 1
print(count)


Measured memory_bytes: 21288
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define vll vector<ll> 
#define vvl vector<vll>
#define pii pair<ll,ll>
#define F first
#define S second
#define endl "\n"
#define M 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
 
/*ll po(ll x, ll y){
    if(y==0)
    return 1;
    if(y%2){
        return ((x)(po(x,y/2)%M)(po(x,y/2)%M) + M)%M;
    }
   return ((po(x,y/2)%M)*(po(x,y/2)%M) + M)%M;
}*/
 
void seive(bool prime[]){
    //bool prime[100002]; 
     
  
    for (ll p=2; p*p<=1000001; p++) 
    { 
        if (prime[p]) 
        { 
            for (ll i=p*p; i<=1000001; i+=p) 
                prime[i] = false; 
        } 
    }
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
    //cin>>t;
	while(t--){
	  ll n;
	  cin>>n;
	  vll v(n);
	  fo(i,n)
	  cin>>v[i];
	  vll m(n);
	  m[0]=v[0];
	  ll mx=m[0];
	  for(ll i=1; i<n; i++){
	      if(v[i]>mx)
	      mx=v[i];
	      m[i]=mx;
	  }
	  ll ans=0;
	  fo(i,n){
	      ans+=m[i]-v[i];
	  }
	  cout<<ans<<endl;
	}
return 0;
}

Measured memory_bytes: 6360
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n;
cin>>n;
vector<pair<int,int> > vc;
int x;
int i=1;
int h=n;
while(n--)
{
cin>>x;
vc.push_back({x,i});
i++;
}
sort(vc.begin(),vc.end());
for(int i=0;i<h;i++)
{
cout<<vc[i].second<<" ";
}
}

Measured memory_bytes: 4324
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef pair<int, int> P;
#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
bool prime(int p) {
	for (int i = 2;i <= sqrt(p);i++) {
		if (p%i==0)return false;
	}
	return true;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}
// Library End !
int g[] = { 0,1,0,-1 };
int f[] = { 1,0,-1,0 };
int h, w;
char s[55][55];
int main() {
	int t[55][55];
	cin >> h >> w;
	int cnt = 0;
	rep(i, h) {
		rep(j, w) {
			cin >> s[i][j];
			if(s[i][j]=='.')cnt++;
			t[i][j] = -1;
		}
	}
	queue <P> q;
	q.push({ 0,0 });
	t[0][0] = 1;
	while (!q.empty()) {
		P p = q.front();
		int x = p.first;
		int y = p.second;
		q.pop();
		rep(i, 4) {
			int xx = x + g[i];
			int yy = y + f[i];
			if (xx < 0 || xx>= h || yy < 0 || yy >= w || s[xx][yy] == '#' || t[xx][yy] != -1)continue;
			q.push({ p.first + g[i],p.second + f[i] });
			t[xx][yy] = t[x][y]+1;
		}
		if (t[h - 1][w - 1] != -1) {
			cout << cnt - t[h - 1][w - 1] << endl;
			return 0;
		}
	}
	cout <<-1<< endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n, k, q = map(int, input().split())
    ac = [0 for _ in range(n)]

    for i in range(q):
        ai = int(input()) - 1
        ac[ai] += 1

    for j in ac:
        if k + j - q > 0:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 4684
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  string s;
  cin>>s;
  ll ans=0;
  ll k=0;
  for(ll i=0;i<s.size();i++){
    if(s[i]==((i&1)+'0'))k++;
  }
  ans=k;
  k=0;
  for(ll i=0;i<s.size();i++){
    if(s[i]==((!(i&1))+'0'))k++;
  }
  ans=min(ans,k);
  cout<<ans<<endl;
}


Measured memory_bytes: 512
N = int(input())
a_list = list(map(int, input().split()))

color_set = set()
all = 0

for a in a_list:
    if 1 <= a <= 399:
        color_set.add("gray")
    elif 400 <= a <= 799:
        color_set.add("brown")
    elif 800 <= a <= 1199:
        color_set.add("green")
    elif 1200 <= a <= 1599:
        color_set.add("lightblue")
    elif 1600 <= a <= 1999:
        color_set.add("blue")
    elif 2000 <= a <= 2399:
        color_set.add("yellow")
    elif 2400 <= a <= 2799:
        color_set.add("orange")
    elif 2800 <= a <= 3199:
        color_set.add("red")
    else:
        all += 1
print(max(len(color_set),1), all+len(color_set))

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
int Prime(int x) {
	vector<int> prime(x+1,1);
	int num = 2;
	while (num <= sqrt(x)) {
		for (int i = 2;i <= x / num;i++) {
			prime[num*i] = 0;
		}
		num++;
		while (prime[num] == 0)
			num++;
	}
	int count = 0;
	for (int i = 2;i < x + 1;i++) {
		if (prime[i] == 1) count++;
	}
	return count;
}
int main(){
	int n;
	cin >> n;
	char a[8];
	long long int max,min;
	for (int i = 0;i < n;i++) {
		max = 0;
		min = 0;
		for (int j = 0;j < 8;j++) {
			cin >> a[j];
		}
		sort(a, a + 8);
		for (int i = 0;i < 8;i++) {
			max += (a[i] - '0')*pow(10, i);
			min += (a[7 - i] - '0')*pow(10, i);
		}
		cout << max-min << endl;
	}


	}
	

Measured memory_bytes: 1220
import scala.collection.immutable.ListMap
import scala.collection.mutable
import scala.io.StdIn.{readInt, readLine}

object Main extends App {
  val nums = 1 to 13
  val cards = ListMap(
    "S" -> nums.to[mutable.Set],
    "H" -> nums.to[mutable.Set],
    "C" -> nums.to[mutable.Set],
    "D" -> nums.to[mutable.Set]
  )

  val n = readInt()

  for (_ <- 1 to n) {
    val Array(suit, x) = readLine.split(" ")
    cards(suit) -= x.toInt
  }

  for ((s, xs) <- cards; x <- xs.toList.sorted) {
    println(s"$s $x")
  }

}



Measured memory_bytes: 44116
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=1e6+20;
const int mod=998244353;

int jc[maxn],inv[maxn],jcn[maxn];

int n,k;

inline void prepare()
{
	jc[0]=jc[1]=jcn[0]=jcn[1]=inv[1]=1;
	REP(i,2,1e6)jc[i]=(ll)i*jc[i-1]%mod,inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod,jcn[i]=(ll)jcn[i-1]*inv[i]%mod;
}

inline void init()
{
	n=read();k=read();
}

inline int C(int n,int m){ if(m<0 || n<m)return 0;return 1ll*jc[n]*jcn[m]%mod*jcn[n-m]%mod;}

inline void doing()
{
	int ans=0;
	REP(a,k+1>>1,k)
	{
		int b=k-a;
		if(a>=n)
		{
			int t=a-n;
			if(a>b)ans=(ans+C(k,a)-C(k,a+t+1))%mod;
			else ans=(ans+C(k-1,a)-C(k-1,a+t+1))%mod;
		}
	}
	ans=(ans+mod)%mod;
	printf("%d\n",ans);
}

int main()
{
	prepare();
	init();
	doing();
	return 0;
}


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

# 初期化
max_num = max(max(x), a)
dp = [[[0 for _ in range(max_num * n + 1)]
       for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1

for j in range(1, n+1):
    for k in range(j+1):
        for s in range(max_num * k + 1):
            if s < x[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
            elif k >= 1 and s >= x[j-1]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]

ans = 0
for k in range(1, n+1):
    ans += dp[n][k][k*a]
print(ans)

Measured memory_bytes: 65504
#include <iostream>
#include <vector>
#define llint long long
#define mod 1000000007

using namespace std;

llint n, x;
llint a[105];
llint dp[105][105][305];

const int FACT_MAX = 205;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}


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

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

	dp[0][0][0] = 1;
  for(int i = 0; i < n; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k < 256; k++){
				dp[i+1][j][k] += dp[i][j][k], dp[i+1][j][k] %= mod;
				if(j+1 <= n) dp[i+1][j+1][k^a[i+1]] += dp[i][j][k], dp[i+1][j+1][k^a[i+1]] %= mod;
			}
		}
	}
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		ans += dp[n][i][x] * fact[i] % mod;
		ans %= mod;
	}
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 25216
#include <stdio.h>
int main(void) {
    int ltime[10000],rtime[10000],diff,temp,before,left,right,i,j;
    while (1) {
        scanf("%d %d",&left,&right);
        if (left==0&&right==0) break;
        diff=0,before=0;
        for (i=0; i<left; i++) scanf("%d",&ltime[i]);
        for (i=0; i<right; i++) scanf("%d",&rtime[i]);
        for (i=0,j=0; i+j<left+right; ) {
            if (i<left&&j<right) {
                if (ltime[i]<rtime[j]) {
                    temp=ltime[i]-before;
                    if (temp>diff) diff=temp;
                    before = ltime[i];
                    i++;
                } else {
                    temp=rtime[j]-before;
                    if (temp>diff) diff=temp;
                    before = rtime[j];
                    j++;
                }
            } else if (i==left) {
                temp=rtime[j]-before;
                if (temp>diff) diff=temp;
                before = rtime[j];
                j++;
            } else {
                temp=ltime[i]-before;
                if (temp>diff) diff=temp;
                before = ltime[i];
                i++;
            }
        }
        printf("%d\n",diff);
    }
    return 0;
}

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

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

  if (N % 500 == 0) {
    cout << "Yes" << endl;
  }
  else if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int n, m, a[4];
string s;

int main()
{
	cin >> s;
	string u;
	n = s.size();
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i > j)
				continue;
			u = s.substr(0, i) + s.substr(j, n - j);
			if (u == "keyence")
			{
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
}


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

int main() {

    long double a, b, x;
    cin >> a >> b >> x;

    long double ans;

    if ( x <= a * b / 2 * a ) {
        long double d = x / a * 2 / b;
        ans = atanl( b / d );
    } else {
        long double d = ( a * b - x / a ) * 2 / a;
        ans = 0.50L * M_PI - atanl( a / d );
    }

    cout << fixed << setprecision(15) << ans * 180 / M_PI << endl;

    return 0;

}


Measured memory_bytes: 256
from collections import deque
n, m = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

flag = [0 for i in range(n)]

def bfs(s):
    d = 0
    flag[s] = 1
    q = deque([(s, d)])

    while len(q) > 0:
        v = q.popleft()
        for i in g[v[0]]:
            if flag[i]:
                continue
            flag[i] = 1
            if v[1] < 1:
                q.append((i, d+1))
            if v[1] == 1 and i == n-1:
                return True
    return False

print("POSSIBLE" if bfs(0) else "IMPOSSIBLE")

Measured memory_bytes: 46780
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

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

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

	int n, m;
	cin >> n >> m;

	vector<int> love(m);
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;

		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			v--;

			love[v]++;
		}
	}

	int ans = 0;
	for (auto v : love) {
		ans += (v == n);
	}

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


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

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

    long long AB = A + B;

    long long cnt = N / AB;
    long long ans = cnt * A;
    ans += min(A, N - cnt * AB);

    cout << ans << 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 all(x) x.begin(),x.end()

string s;

i64 MOD =1e9 + 7;

i64 X[101010],A[101010],B[101010],C[101010];

int h(int i){
  if(s[i - 1] == '?') return 3;
  return 1;
}

int main(){
  cin >> s;
  int N = s.size();
  X[0] = 1;
  rep(i,1,N){
    X[i] = X[i - 1] * h(i);
    X[i] %= MOD;
  }
  rep(i,1,N){
    A[i] = A[i - 1] * h(i) + X[i - 1] * (s[i - 1] == 'A' || s[i - 1] == '?');
    A[i] %= MOD;
  }
  rep(i,1,N){
    B[i] = B[i - 1] * h(i) + A[i - 1] * (s[i - 1] == 'B' || s[i - 1] == '?');
    B[i] %= MOD;
  }
  rep(i,1,N){
    C[i] = C[i - 1] * h(i) + B[i - 1] * (s[i - 1] == 'C' || s[i - 1] == '?');
    C[i] %= MOD;
  }
  cout << C[N] << endl;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int a,b; cin >> a >> b;
    int sum=0;
    if(a>b){
        sum += a;
        a--;
    }else{
        sum += b;
        b--;
    }
    if(a>=b){
        sum += a;
    }else{
        sum += b;
    }
    cout << sum << endl;
    return 0;
}


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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}



int main() {
  string s,t;
  cin >> s >> t;
  set<char> cnt;
  map<char,vector<int>> mp;
  ll res=0,now=-1;
  rep(i,s.size()){
    cnt.insert(s[i]);
    mp[s[i]].push_back(i);
  }
  rep(i,t.size()){
    if (cnt.find(t[i])==cnt.end()) {
      cout << -1 << endl;
      return 0;
    }
  }

  rep(i,t.size()){
    char tmp = t[i];
    auto ix = upper_bound(mp[tmp].begin(),mp[tmp].end(),now);
    if (ix==mp[tmp].end()) {
      res++;
      now=mp[tmp][0];
    }
    else {
      now=*ix;
    }
  }
  cout << res*s.size() + now + 1 << endl;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
	io;
	int n;
	cin>>n;
	string s;
	cin>>s;
	ll cnt=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='R')cnt++;
	}int cnt1=cnt;
	for(int i=0;i<cnt1;i++){
		if(s[i]=='R')cnt--;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}


int main() {
    int n,a;
    cin >> n;
    map<int, int> mp;
    rep(i,n) {
        cin >> a;
        mp[a] = i+1;
    }
    rep(i, n) {
        cout << mp.at(i+1) << " ";
    }
    cout << "\n";
}


Measured memory_bytes: 5504
a = set([1,3,5,7,8,10,12])
b = set([4,6,9,11])
c = set([2])
x,y=map(int,input().split())
if x in a and y in a or x in b and y in b or x in c and y in c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
using System;
using System.Linq;

namespace AtCoderMake.ABC171
{
    class ABC171B
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select((x) => int.Parse(x)).ToArray();
            var p = Console.ReadLine().Split().Select((x) => int.Parse(x)).ToArray();
            int ans = 0;

            Array.Sort(p);
            for(int i = 0; i < nk[1]; i++)
            {
                ans += p[i];
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28504
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int d,s,t;
    cin>>d>>s>>t;
    if(d<=t*s) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	ll x, k, d, ans = INFLL;
	cin >> x >> k >> d;

	ll cnt = min(k, abs(x) / d);
	if (x > 0) {
		x -= cnt * d;
	} else {
		x += cnt * d;
	}
	k -= cnt;

	clog << x << " " << k << endl;
	if (k == 0) {
		cout << abs(x) << endl;
		return 0;
	}
	if (k % 2 == 0) {
		cout << abs(x) << endl;
		return 0;
	} else {
		cout<<min(abs(x-d),abs(x+d))<<endl;
	}
	//cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define PrintLn(X) cout << X << endl
#define Loop(n) for(int loop_ = n; loop_; --loop_)
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, a, b) for(int i = a; i < (int)(b); ++i)

int main(void)
{
	int N, x;
	cin >> N >> x;
	int A[100000];
	ll ans = 0;
	cin >> A[0];
	Rep(i, N - 1){
		cin >> A[i + 1];
		int extra = A[i] + A[i + 1] - x;
		if(extra > 0){
			if(A[i + 1] >= extra){
				A[i + 1] -= extra;
				ans += extra;
			}else{
				A[i + 1] = 0;
				ans += extra;
			}
		}
	}
	PrintLn(ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main ()
{
  int A, B;
  cin >> A >> B;
  
  vector<int> compare(3, 0);
  compare.at(0) = A + B;
  compare.at(1) = A - B;
  compare.at(2) = A * B;
  
  sort(compare.begin(), compare.end());
  
  cout << compare.at(2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int, int> pii;
const int MAXN = 1e3 + 5;
char mp[MAXN][MAXN];
int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int path[MAXN][MAXN], n, m;
bool vis[MAXN][MAXN];
pair<int, int> C, D;
int bfs()
{
    deque<pair<int, int>> q;
    memset(path, -1, sizeof(path));
    q.push_front(C);
    path[C.x][C.y] = 0;
    while (!q.empty())
    {
        pii now = q.front();
        q.pop_front();
        if (now.x == D.x && now.y == D.y)
            return path[now.x][now.y];
        for (int i = 0; i < 4; ++i)
        {
            int dx = now.x + dir[i][0];
            int dy = now.y + dir[i][1];
            if (mp[dx][dy] == '.' && (path[dx][dy] == -1 || path[dx][dy] > path[now.x][now.y]))
            {
                path[dx][dy] = path[now.x][now.y];
                q.push_front(pii(dx, dy));
            }
        }
        for (int dx = now.x - 2; dx <= now.x + 2; ++dx)
        {
            for (int dy = now.y - 2; dy <= now.y + 2; ++dy)
            {
                if (dx < 1 || dy < 1 || dx > n || dy > m)
                    continue;
                if (mp[dx][dy] == '.' && path[dx][dy] == -1)
                {
                    path[dx][dy] = path[now.x][now.y] + 1;
                    q.push_back(pii(dx, dy));
                }
            }
        }
    }
    return -1;
}
int main()
{
    scanf("%d %d", &n, &m);
    scanf("%d %d %d %d", &C.first, &C.second, &D.first, &D.second);
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            cin >> mp[i][j];
        }
    }
    printf("%d\n", bfs());
    // int T;
    // cin >> T;
}


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

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Sushi
        {
            public readonly long x;
            public readonly long v;
            public Sushi(long[] V)
            {
                x = V[0];
                v = V[1];
            }
        }
        static long Solve(int N, long C, Sushi[] sushis)
        {
            long[][] memo = new long[N][];
            for (int i = 0; i < N; ++i) { memo[i] = new long[2]; }
            long max = 0;
            {
                long max1 = 0;
                long max2 = 0;
                long sum1 = 0;
                long sum2 = 0;
                for (int i = 0; i < N; ++i)
                {
                    int j = N - 1 - i;
                    sum1 += sushis[i].v;
                    max1 = Math.Max(sum1 - sushis[i].x, max1);
                    memo[i][0] = max1;
                    sum2 += sushis[j].v;
                    max2 = Math.Max(sum2 - (C - sushis[j].x), max2);
                    memo[j][1] = max2;
                    max = Math.Max(max1, max);
                    max = Math.Max(max2, max);
                }
            }
            {
                long sum1 = 0;
                long sum2 = 0;
                for (int i = 0; i < N; ++i)
                {
                    int j = N - 1 - i;
                    sum1 += sushis[i].v;
                    if (i + 1 < N)
                    {
                        max = Math.Max(sum1 - sushis[i].x * 2 + memo[i + 1][1], max);
                    }
                    sum2 += sushis[j].v;
                    if (j - 1 >= 0)
                    {
                        max = Math.Max(sum2 - (C - sushis[j].x) * 2 + memo[j - 1][0], max);
                    }
                }
            }
            return max;
        }
        static void Main(string[] args)
        {
            var V = ReadLongs();
            int N = (int)V[0];
            var sushis = new Sushi[N];
            for (int i = 0; i < N; ++i) { sushis[i] = new Sushi(ReadLongs()); }
            Console.WriteLine(Solve(N, V[1], sushis));
        }
    }
}


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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  vector<int> A(N);
  for(int i=0;i<N;i++){
    char c = S.at(i);
    if(c=='A'||c=='T'||c=='C'||c=='G'){
      A.at(i) = 1;
    }else{
      A.at(i) = 0;
    }
  }
  bool ok = false;
  int ans = 0;
  //for(int i=0;i<N;i++){
  //  cout << A.at(i) << " " ;
  //}
  cout << endl;
  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
      ok = true;
      for(int k=i;k<=j;k++){
        if(A.at(k) == 0){
          ok = false;
        }
      }
      if(ok){
        ans = max(ans,j-i+1);
      }
    }
  }
  cout << ans << endl;
}

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

int main()
{
	long long a;
	cin >> a;
	string b;
	cin >> b;

	long long lb = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0') * 1;
	cout << a * lb / 100 << endl;

	return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 100
char s[MAXN+5],t[MAXN+5];
int sum,n;
int main(){
    scanf("%d%s%s",&n,s,t);
    for(int i=0;i<n;i++)
        if(s[i]==t[0]){
            int lim=1,l=i+1,r=1;
            while(s[l]==t[r]&&l<n&&r<n)
                l++,r++,lim++;
            sum=max(sum,lim);
        }
    printf("%d",2*n-sum);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;

const int N = 1e5;
const int INF = 1e9;
typedef long long int ll;
typedef pair<int,int> ii;

int n,a,b;
double sum = 0;
vector<ii> pontos;

double dist(ii a, ii b)
{
	double A = a.x - b.x, B = a.y - b.y;
	return sqrt(A*A + B*B);
}

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

	cin>>n;
	for(int i=0;i<n;++i)
	{
		cin>>a>>b;
		pontos.pb(mp(a,b));
	}

	sort(all(pontos));

	int qnt = 0;
	do
	{
		qnt++;
		double now = 0;
		for(int i=0;i<n-1;++i)
			sum+=dist(pontos[i],pontos[i+1]);		
		
	}while(next_permutation(all(pontos)));
	
	cout<<fixed<<setprecision(8);
	cout<<sum/qnt<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}

void yes() {
	cout << "Yes" << endl;
}

void no() {
	cout << "No" << endl;
}

int main() {
	int n, k,count=0;
	cin >> n >> k;
	while (n) {
		n /= k;
		count++;
	}

	cout << count << endl;
	

	system("pause");
	return 0;
}

Measured memory_bytes: 504