akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  int N,K;
  int ans = 0;
  scanf("%d%d",&N,&K);

  int x[N];
  for(int i = 0;i < N;i++) scanf("%d",&x[i]);

  for(int i = 0;i < N;i++){
    ans += min(x[i]*2,abs(K-x[i])*2);
  }

  printf("%d",ans);
  return 0;
}

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

#pragma GCC optimize("Ofast")

#define ll long long
#define ull unsigned long long
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<endl
#define dnew cerr<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define f first
#define s second
#define endl '\n'

using namespace std;




signed main () { //[J][O][L][S][K][E][Y]
      int n,r; cin>>n>>r;
      if (n>=10) cout<<r;
      else cout<<100*(10-n)+r;

      return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using ll = long long;
using namespace std;
int main(){
		ll a,b,k;scanf("%lld %lld %lld",&a,&b,&k);
		if(k<=a){
				printf("%lld %lld",a-k,b);
			}	
		else {
			if(k<=a+b){
				printf("0 %lld",b-(k-a));
			}	
			else{
				printf("0 0");
			}
		}		
		return 0;	
	}


Measured memory_bytes: 1724
n, m = (int(i) for i in input().split())
ab = [[int(i) for i in input().split()] for j in range(n)]
cd = [[int(i) for i in input().split()] for j in range(m)]

for i in range(n):
    d_min = 1000000000
    p_num = 0
    for j in range(m):
        cur_d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if cur_d < d_min:
            d_min = cur_d
            p_num = j + 1
    print(p_num)

Measured memory_bytes: 39408
#include<stdio.h>
int main(){
	int a[100];
	int b,c=0,d,e=0;
	scanf("%d",&b);
	for(int i=1;i<=b;i++)
	{scanf("%d",&a[i]);
		c=c+a[i];
	}
	for(int i=1;i<=b;i++)
	{d=c-a[i];
	e=e+d*a[i];

	}e=e/2;
	printf("%d",e);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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;}

int main(){
	ll L,R;
	cin >> L >> R;
	
	ll ans=2019;
	for(ll i=L; i-L<2019 && i<=R; i++){
		for(ll j=i+1; j-i<2019 && j<=R; j++){
			chmin(ans, ((i%2019)*(j%2019))%2019);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int main() {
	int a, b, c, d, e, f;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);

	ll sum = 0;
	ll sug = 0;
	ll aa = -1, bb = 1; // 설탕양, 총양

	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			sum = a * i + b * j;
			sum *= 100;

			if (sum == 0) continue;
			for (int ii = 0; ii <= 100; ii++)
				for (int jj = 0; jj <= 100; jj++) {
					sug = ii * c + jj * d;
					if (sum + sug > f) continue;
					if (sum * e < sug * 100) continue;

					if (aa * (sum + sug) <= bb * sug) {
						aa = sug;
						bb = sum + sug;
					}
				}
		}
	}

	printf("%lld %lld", bb, aa);
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll longinf=1LL<<60;
const int mod=1000000007;    
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
  ll n,k;cin>>n>>k;
  ll a[n+1],sump[n+1],summ[n+1];
  sump[0]=summ[0]=0;
  rep(i,n){
    cin>>a[i+1];
    if(a[i+1]>0){
      sump[i+1]=sump[i]+a[i+1];
      summ[i+1]=summ[i];
      }
    else{
      sump[i+1]=sump[i];
      summ[i+1]=summ[i]+a[i+1];
      }
    }
  ll ans=-longinf;
  rep(i,n-k+1){
    ll ret=max(sump[n]-sump[i+k]+sump[i],sump[n]+summ[i+k]-summ[i]);
    ans=max(ret,ans);
    }
  cout<<ans<<endl;
  return 0; 
  }
       

Measured memory_bytes: 2560
#include <cstdio>
using namespace std;

int main(){
		int n;
		scanf("%d",&n);
		if(n/10==9){
				printf("Yes\n");
		}else if(n-n/10*10==9){
				printf("Yes\n");
		}else{
				printf("No\n");
		}
		return 0;
}


Measured memory_bytes: 888
while n=gets
  (a,b)=n.chomp.split
  a=a.to_i
  b=b.to_i
  x=a*b
  if a<b
    tmp=a
    a=b
    b=tmp
  end
  r=a%b
  while r!=0
    a=b
    b=r
    r=a%b
  end
  puts b.to_s+" "+(x/b).to_s
end



Measured memory_bytes: 6876
#include<stdio.h>

int main(){
  int x,y,a,b; // a > b
  int amari = 0;

  scanf("%d %d",&x,&y);

  if(x > y){
    a = x;
    b = y;
  }else{
    a = y;
    b = x;
  }

  while(a % b != 0){
    amari = a % b;
    a = b;
    b = amari;
  }

  printf("%d\n",b);

  return 0;

}



Measured memory_bytes: 2144
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n; cin >> n;
    vector<int> a(n);
    vector<int> b(n-1);
    REP(i,n-1) cin >> b[i];

    ll ans = 0;
    REP(i, n) {
        if(i==0) {
            ans += b[i];
        }else if (i == n -1) {
            ans += b[i-1];
        }else{
            ans += min(b[i-1], b[i]);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endll "\n"
#define show(a) cerr<<""#a""<<" is "<<a<<endll;
int caseno=0;
#define print_case cout<<"Case "<<++caseno<<": ";
#define fout freopen("output.txt","w",stdout);
#define fin freopen("input.txt","r",stdin);
#define srt(v) sort(v.begin(),v.end());
#define greatersrt(v) sort(v.begin(),v.end(),greater<ll>())
#define pb push_back
#define mp make_pair
#define here cerr<<"here\n";
#define PI acos(-1.0)
#define ll long long
#define ld long double
#define reto exit(0);
#define sspace <<" "<<
#define print(arr,xx) for(int i=1;i<xx;i++)cerr<<arr[i]<<" \n"[i==n];
bool sortbysec(pair<int,int>a,pair<int,int>b){return a.second>b.second;}
ll gc(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
ll lc(ll a,ll b){return a/gc(a,b)*b;}
const int primemod=1e9+7;
const ld eps=1e-9;
#define inl(x) scanf("%lld",&x)
#define in(x) scanf("%d",&x)
#define pii pair<int,int>
/**Code Goes Here**/
#define maxsize 100000+9
#define rshuffle(r...)rshuffle(r,[](int _){return rand()%_;})
int n, dp[maxsize];
vector<int>arr[maxsize];
int dfs(int i){
    if(dp[i]!=-1){
        return dp[i];
    }
    int x=-1;
    for(auto u : arr[i]){   
        x=max(x,dfs(u));
    }
    return dp[i]=1+x;
}
int main()
{
    int m;
    in(n),in(m);
    while(m--){
        int x,y;
        in(x),in(y);
        arr[x].pb(y);
    }
    memset(dp, -1, sizeof dp);
    int l=-1;
    for(int i=1;i<=n;i++){
        l=max(l,dfs(i));
    }
    cout<<l<<endl;
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define FILL(a, b) memset(a, b, sizeof(a))

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1e9 + 7;
const int MAX = 1e6 + 5;

int N;
int L;
vector<piii> edges;

int main() {

    scanf("%d", &L);
    N = sizeof(int) * 8 - __builtin_clz(L);
    int cnt = N;
    while ((L >> 1) > 0) {
        if (L & 1) {
            edges.pb({{1, cnt}, L - 1});
        }
        edges.pb({{cnt - 1, cnt}, L >> 1});
        edges.pb({{cnt - 1, cnt}, 0});
        L >>= 1;
        cnt--;
    }
    printf("%d %d\n", N, (int) edges.size());
    for (auto e : edges) {
        printf("%d %d %d\n", e.f.f, e.f.s, e.s);
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M, K;
  cin>>N>>M>>K;
  vector<vector<int> > friends(N), blocks(N);
  int a, b;
  for(int i=0;i<M;++i) {
    cin>>a>>b;
    a--;
    b--;
    friends[a].push_back(b);
    friends[b].push_back(a);
  }
  for(int i=0;i<K;++i) {
    cin>>a>>b;
    a--;
    b--;
    blocks[a].push_back(b);
    blocks[b].push_back(a);
  }
  int groups[N];
  for(int i=0;i<N;++i) groups[i] = -1;
  int group = 0;
  queue<int> que;
  int state;
  for(int i=0;i<N;++i) {
    if(groups[i]>-1) continue;
    que.push(i);
    while(!que.empty()) {
      state = que.front();que.pop();
      if(groups[state]>-1) continue;
      groups[state] = group;
      for(int j=0;j<friends[state].size();++j) {
        if(groups[friends[state][j]]>-1) continue;
        que.push(friends[state][j]);
      }
    }
    group++;
  }
  int num[group];
  for(int i=0;i<group;++i) num[i] = 0;
  for(int i=0;i<N;++i) num[groups[i]]++;
  int ans[N];
  for(int i=0;i<N;++i) {
    ans[i] = num[groups[i]]-1;
    for(int j=0;j<friends[i].size();++j) {
      if(groups[i]==groups[friends[i][j]]) ans[i]--;
    }
    for(int j=0;j<blocks[i].size();++j) {
      if(groups[i]==groups[blocks[i][j]]) ans[i]--;
    }
  }
  for(int i=0;i<N;++i) cout<<ans[i]<<" ";
  cout<<endl;
}



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

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

    int n;
    cin >> n;

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

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

    ll res = 0;
    rep(i, n){
        ll mid = b[i];

        ll upper = lower_bound(a.begin(), a.end(), mid) - a.begin();
        ll lower = c.end() - upper_bound(c.begin(), c.end(), mid);

        res += upper * lower;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

class UnionFind{
  int num_components;
  std::vector<int> parent;
  std::vector<int> weight;
  std::vector<int> rank;
public:
  UnionFind(int N) : num_components(N),
                     parent(std::vector<int>(N)),
                     weight(std::vector<int>(N, 1)),
                     rank(std::vector<int>(N, 0)){
    for(int i = 0; i < N; i++) parent[i] = i;
  }
  
  int find(int x){
    if(x == parent[x]) return x;
    else return parent[x] = find(parent[x]);
  }
  
  int size(int x){
    return weight[find(x)];
  }

  
  bool same(int x, int y){
    return find(x) == find(y);
  }
    
  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    
    num_components--;
    if(rank[x] < rank[y]){
      weight[y] += weight[x];
      parent[x] = y;
    }else{
      weight[x] += weight[y];
      parent[y] = x;
      if(rank[x] == rank[y]) rank[y]++;
    }
  }
  
  int count(){
    return num_components;
  }
};

int main(){
  ios::sync_with_stdio(false);

  int n, m;
  while (cin >> n >> m && n + m){
    UnionFind uf(n);

    int a, b;
    REP(i, m){
      cin >> a >> b;
      uf.unite(a - 1, b - 1);
    }

    ll res = 1;
    const ll mod = 1000 * 1000 * 1000 + 7;

    REP(i, uf.count()){
      res *= 2;
      res %= mod;
    }
    
    if (m > 0) res = (res + 1) % mod;

    cout << res << endl;
  }
  return 0;
}

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

bool fill(int n, string &s, vector<int> &v, int a, int b) {
  v[0] = a;
  v[1] = b;
  for (int i = 1; i <= n; i++) {
      if ((v[i] == 1 and s[i] == 'o') || (v[i] == 0 and s[i] == 'x')) {
      v[i + 1] = !v[i - 1];
    } else {
      v[i + 1] = v[i - 1];
    }
  }
  return v[0] == v[n] and v[1] == v[n+1];
}

void solve(long long N, std::string s) {
  vector<int> v(N+2);
  s.push_back(s[0]);
  auto fin = [&]() {
    string res = "";
    for (int i = 0; i < N; i++) {
      if (v[i]) {
        res.push_back('W');
      } else {
        res.push_back('S');
      }
    }
    cout << res << endl;
  };

  for (int i = 0; i <= 1; i++) {
    for (int j = 0; j <= 1; j++) {
	if (fill(N, s, v, i, j)) {
        fin();
        return;
      }
    }
  }
  cout << -1 << endl;
}

int main() {

  long long N;
  scanf("%lld", &N);
  std::string s;
  std::cin >> s;
  solve(N, s);
  return 0;
}


Measured memory_bytes: 1152
//Belief yourself,Respect yourself

#include<bits/stdc++.h>
using namespace std;
#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search;
#define lower(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Lower value search;
#define max3(a,b,c) max(max(a,b),c)//maximum value find three value;
#define min3(a,b,c) min(min(a,b),c)//minimum value find three value;
#define rep(i,intial,n) for(int i=intial; i<(n) ; i++)
#define REP(i,intial,n) for(int i=intial; i<=(n) ; i++)
#define PI acos(-1.0)//PI Calculation
#define LL long long
#define MP make_pair
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define MX 1000005
#define MOD 1000000007

//Bit Operation
bool checkBit(LL n, int i) { return n&(1LL<<i); }  //AND
LL setBit(LL n, int i) { return n|(1LL<<i);; }     //OR
LL resetBit(LL n, int i) { return n&(~(1LL<<i)); } //OFF

template<typename T> T POW(T b,T p)          //Pow calculation
{
    T r=1;
    while(p)
    {
        if(p&1)r=(r*b);
        b=(b*b);
        p>>=1;
    }
    return r;
}

LL big_mod(LL n, LL p)
{
    if(p==0) return 1;
    if(!(p&1))
    {
        LL r = big_mod(n,p/2) % MOD;
        return ( (r%MOD) * (r%MOD) ) % MOD;
    }
    else return ( ( n%MOD) * (big_mod(n,p-1) %MOD)) % MOD;
}

long long gcd(long long a, long long b) {
  while (b != 0) {
    long long t = a % b;
    a = b;
    b = t;
  }
  return a;
}

//||--------------------------->||Main_Code_Start_From_Here||<---------------------------------||
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    string s,ss;
    while(cin>>s)
    {
        ss="";
        for(int i=0;i<s.size();i+=2)
        {
           ss+=s[i];
        }
        cout<<ss<<endl;
    }

}



Measured memory_bytes: 512
<?php
$N = trim(fgets(STDIN));
$L = explode(' ', trim(fgets(STDIN)));
sort($L, SORT_NUMERIC);
$cnt = 0;
for($i = 0; $i < $N; $i++) {
  for($j = $i + 1; $j < $N; $j++) {
  	for($k = $j + 1; $k < $N; $k++) {
    	if(($L[$i] + $L[$j]) > $L[$k] && $L[$i] !== $L[$j] && $L[$j] !== $L[$k] && $L[$k] !== $L[$i]) {
          $cnt++;
        }
    }
  }
}

echo $cnt, "\n";


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1000000007;

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

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

  int A,B;
  cin >> A >> B;
  cout << A*B << endl;
}

Measured memory_bytes: 3648
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	if (N % 3 == 0 || M % 3 == 0 || (N + M) % 3 == 0)cout << "Possible\n";
	else cout << "Impossible\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;



int main() {
	int N;
	cin >> N;
	map<string, int> m;
	vector<string> A(N);

	rep(i, N) {
			cin >> A[i];
		m[A[i]] += 1;
	}
 
	int MAX = 0;

	rep(i, N) {
		if (MAX <= m[A[i]]) {
			MAX = m[A[i]];
		}
	}
	for (auto i = m.begin(); i != m.end(); i++) {
		if (i->second == MAX) {
			cout << i->first << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 26752
#include<iostream>
#include<queue>
#include<cstdio>

using namespace std;
priority_queue<int> Q;

int H;
int main(){
  for(int i= 0;i < 10;i++){
     scanf("%d",&H);
     Q.push(H);
  }
  for(int i= 0;i < 3;i++){
    cout << Q.top() <<endl;
    Q.pop();
  }
  return 0;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] gains = new int[n][3];
        for (int i = 0; i < n; ++i) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int c = scanner.nextInt();
            gains[i][0] = a;
            gains[i][1] = b;
            gains[i][2] = c;
        }
        System.out.println(solve(gains));
    }

    private static int solve(int[][] gains) {
        int[][] dp = new int[gains.length][3];
        for (int i = 0; i < gains.length; ++i) {
            Arrays.fill(dp[i], -1);
        }
        return Math.max(
                Math.max(
                        findMax(0, 0, gains, dp),
                        findMax(1, 0, gains, dp)),
                findMax(2, 0, gains, dp));
    }

    private static int findMax(int cur, int ind, int[][] gains, int[][] dp) {
        if (ind == gains.length) {
            return 0;
        }
        if (dp[ind][cur] > 0)
            return dp[ind][cur];
        int res;
        if (cur == 0) {
            res = gains[ind][cur] + Math.max(findMax(1, ind + 1, gains, dp), findMax(2, ind + 1, gains, dp));
        } else if (cur == 1) {
            res = gains[ind][cur] + Math.max(findMax(0, ind + 1, gains, dp), findMax(2, ind + 1, gains, dp));
        } else {
            res = gains[ind][cur] + Math.max(findMax(0, ind + 1, gains, dp), findMax(1, ind + 1, gains, dp));
        }
        dp[ind][cur] = res;
        return res;
    }
}


Measured memory_bytes: 110752
S = input()
T = input()

ans = float('inf')
for i in range(len(S)-len(T)+1):
    diff_count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            diff_count += 1

    ans = min(ans, diff_count)

print(ans)
        

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

int k,n,h[110000],f[110000];
int main(){
    scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&h[i]);
	}
	memset(f,63,sizeof(f));
	f[1]=0;
	for(int i=2;i<=n;i++){
		for(int j=1;j<i&&j<=k;j++){
			f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]));
		}
	}
	printf("%d",f[n]);
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int main(){
	int n;
	double a[4],b[4];
	double d;
	scanf("%d",&n);
	for(;n>0&&scanf("%lf %lf %lf %lf %lf %lf",&a[0],&a[1],&a[2],&b[0],&b[1],&b[2]);n--){
		d=sqrt((a[1]-b[1])*(a[1]-b[1])+(a[0]-b[0])*(a[0]-b[0]));
		if(a[2]+b[2]>=d ){
			if(a[2]>=b[2]){
				if(a[2]-b[2]<=d){
					printf("1\n");
				}
				else {
					printf("2\n");
				}
			}
			else if	(b[2]>=a[2]){
				if(b[2]-a[2]<=d){
					printf("1\n");
				}
				else {
					printf("-2\n");
				}
			}
		}
		else {
			printf("0\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.PriorityQueue;

import java.util.Scanner;

public class Main {
	static int MAX = 1000000;
    static int[] A = new int[MAX];
    static int[] L = new int[MAX/2 + 1];
    static int[] R = new int[MAX/2 + 1];
    static int count;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    int M = sc.nextInt();
	    
	    int X [] = new int [M];

	    for (int i=0;i<M;i++) {
	    	X[i]=sc.nextInt();
	    }
	    
	    sc.close(); 
	    MergeSort(X, 0, M);
	    
	    PriorityQueue <Integer> D = new PriorityQueue<Integer>(); 

	    for (int i=0;i<M-1;i++) {
	    	D.add((X[i]-X[i+1]));
	    	//System.out.println(D.peek());
	    }
	    
	    int size = Math.min(N-1, D.size());
	    
	    for (int i=0;i<size;i++) {
	    	D.poll();
	    }
	    
	    int new_size = D.size();
	    int sum = 0;
	    
	    for (int i=0;i<new_size;i++) {
	    	sum+=D.poll();
	    }
	    System.out.println(-sum);
	}

	public static void Merge(int []A, int left, int mid, int right){
	  int n1 = mid - left;
	  int n2 = right - mid;
	  
	  L[n1] = 1000000001;
	  R[n2] = 1000000001;
	  
	  for (int i = 0; i<n1; i++){
		  L[i] = A[left + i];
	  }
	
	  for (int i = 0; i<n2; i++){
		  R[i] = A[mid + i];
	  }
	  
	  int i = 0, j = 0;
	  for (int k = left;  k < right; k++){
		  count++;
		  if (L[i] <= R[j]){
			  A[k] = L[i];
			  i++;
		  }
		  else {
			  A[k] = R[j];
			  j++;
		  }
	  }
	}


	public static void MergeSort(int [] A, int left, int right){
	  if (left+1 < right){
		  int mid = (left + right)/2;
		  MergeSort(A, left, mid);
	      MergeSort(A, mid, right);
	      Merge(A, left, mid, right);
	  }
	        
	}
}




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

void main_()
{
    string s;
    cin >> s;

    ll Acont = 0;
    ll ans = 0;
    for (ll i = 0; i < (ll)s.size() - 2; ++i) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            ans += Acont + 1;
            s[i] = 'B';
            s[i + 1] = 'C';
            s[i + 2] = 'A';
            i++;
        } else if (s[i] == 'A') {
            Acont++;
        } else if (s[i] != 'A') {
            Acont = 0;
        }
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int a,b; cin>>a>>b;
	ote((a+b+2-1)/2);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main (String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int caseNo = 0;
        String s;
        while ( (s = br.readLine()) != null ) {
            caseNo++;
            int i = Integer.parseInt(s);
            if (i == 0) {
                break;
            }
            System.out.println("Case " + caseNo + ": " + i );
        }
    }
}



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

namespace AtCoderTest
{
    class ShiftOnly
    {
        static int countPowerOfTwo( List<int> list )
        {
            int res = 0;
            int nElement = list.Count();
            while (true)
            {
                for(int i=0; i< nElement; ++i)
                {
                    if (list[i] % 2 == 1)
                        return res;
                    else
                        list[i] = list[i] / 2;
                }
                res++;
            }
        }

        public static string core()
        {
            var inStr = Console.ReadLine();
            var inStr2 = Console.ReadLine();
            var inList = inStr2.Split(' ').Select(x => int.Parse(x)).ToList();

            var retStr = countPowerOfTwo(inList).ToString();
            return retStr;
        }

    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.Write(ShiftOnly.core());
        }
    }
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

//http://hos.ac/slides/20140319_bit.pdf
int MAX_N=1000010;
vector<int>bit(MAX_N+1,0);//1-index
void add(int a,int w){
    for (int x = a; x <=MAX_N; x+=x&-x)bit[x]+=w;
}
int sum(int a){//sum v[1]～v[a]
    int ret=0;
    for (int x = a; x>0;x-=x&-x)ret+=bit[x];
    return ret;
}

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

    ll n,q;cin >>n>>q;
    vector<ll>c(n+1);
    for (int i = 1; i <=n; ++i) {
        cin >>c[i];
    }
    //pre calc ok
    vector<ll>pre(n+1,-1);
    vector<vector<ll>>num(n+1,vector<ll>());
    for (int i = n; i>=1; --i) {
        num[c[i]].push_back(i);
    }

    vector<ll>w(n+1,0);
    for (int i = n; i >=1;--i) {
        if((ll)num[c[i]].size()>w[c[i]]+1) {
            w[c[i]]++;
            pre[i] = num[c[i]][w[c[i]]];
        }
    }

//    for (int i = 1; i <=n; ++i) {
//        cout <<pre[i]<<" ";
//    }
//    cout <<endl;
    vector<pair<ll,P>>rl;
    for (int i = 0; i < q; ++i) {
        ll l,r;cin >>l>>r;
        rl.push_back({r,{l,i}});
    }
    sort(all(rl));
    vector<bool>ch(n+1,true);
    for (int i = rl[0].first; i>=1; --i) {
        if(ch[c[i]]){
            add(i,1);
            ch[c[i]]=false;
        }
    }
    ll r=rl[0].first;
    ll a=0;
    vector<ll>ans(q);
    while(a<q){
        ll l=rl[a].second.first;
        if(rl[a].first==r){
            ans[rl[a].second.second]=sum(r)-sum(l-1);
            a++;
        }
        else {
            r++;
            if(pre[r]>0){
                add(pre[r],-1);
            }
            add(r,1);
        }
    }
    for (int i = 0; i < q; ++i) {
        cout <<ans[i]<<'\n';
    }
}


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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(int i = 0; i < n; ++i)
        cin >> x[i] >> y[i];
    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    double sum = 0;
    int cnt = 0;
    do{
        ++cnt;
        for(int i = 0; i < n - 1; ++i){
            int dx = x[p[i]] - x[p[i + 1]];
            int dy = y[p[i]] - y[p[i + 1]];
            sum += sqrt((dx * dx) + (dy * dy));
        }
    }while(next_permutation(p.begin(), p.end()));
    printf("%.20lf\n", sum / cnt);
}


Measured memory_bytes: 256
main=map read.words<$>getLine>>=print.(\(a:[b])->f a b)
 where f a b |(even a)&&(even b) = b+(mod(quot(b-a)2)2)
             |(even a)&&(odd b)  = mod(quot(b-a+1)2)2
             |(odd a)&&(even b)  = g a b (mod(quot(b-a-1)2)2)
             |(odd a)&&(odd b)   = a-(mod(quot(b-a)2)2)
       g a b i =(if(mod a 2)==(mod b 2)then(+)else(-)) (h a b 0) i
       h 0 0 _ =0
       h a b e =(mod(a+b)2)*(2^e)+(h (quot a 2) (quot b 2) (e+1))

Measured memory_bytes: 508
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element

int N;

signed main()
{
	cin >> N;
	switch (N % 10)
	{
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			cout << "hon" << endl;
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			cout << "pon" << endl;
			break;
		case 3:
			cout << "bon" << endl;
			break;

	}
}




Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N,A,B; cin >> N >> A >> B;
    string s; cin >> s;
    int rank = 0;
    int cnt = 0;
    rep(i,N){
        if(s[i] == 'a'){
            if(cnt < A+B){
                cout << "Yes" << endl;
                cnt++;
            }
            else cout << "No" << endl;
        }
        else if(s[i] == 'b'){
            if(cnt < A+B && rank < B){
                cout << "Yes" << endl;
                cnt++;
                rank++;
            }
            else cout << "No" << endl;
        }
        else cout << "No" << endl;
    }
}

    



Measured memory_bytes: 896
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w,k = inpl()
s = [input() for i in range(h)]
a = [['' for i in range(w)] for j in range(h)]

cnt = 1
nl = [True] * h
for y in range(h):
    if s[y].count('.') == w:
        nl[y] = False
        continue
    stb = s[y].count('#')
    fl = False
    for x in range(w):
        if s[y][x] == '#':
            if not fl:
                fl = True
            else:
                cnt += 1
        a[y][x] = cnt
    cnt += 1
# print(nl)
# for y in range(h):
#     if not y in nl:
#         continue
#     st = [y]
#     tmp = y
#     while True:
#         if tmp + 1 in nl:
#             st.append(tmp+1)
#             tmp += 1
#         else:
#             for _ in st:
#                 for x in range(w):
#                     a[_][x] = a[tmp+1][x]
y = 0
st = []
while y < h:
    if nl[y]:
        y += 1
        continue
    st = [y]
    # print(st)
    if y+1 >= h:
        break
    while y+1< h:
        if nl[y+1]:
            for _ in st:
                for x in range(w):
                    a[_][x] = a[y+1][x]
            y += 1
            break
        else:
            st.append(y+1)
            y += 1
# print(nl)
if not nl[h-1]:
    st = [h-1]
    for y in range(h-1)[::-1]:
        if nl[y]:
            for _ in st:
                for x in range(w):
                    a[_][x] = a[y][x]
            break
        else:
            st.append(y)

for i in range(h):
    print(*a[i])

Measured memory_bytes: 73176
n = int(input())
arr = list(map(int, input().split()))

cnt = 1

if len(arr) == 1:
    print(cnt)
    exit()

a = arr[0]
cmode = 0
nmode = 0
sz = 1
for i in range(1, len(arr)):

    if a > arr[i]:
        nmode = 1
    elif a == arr[i]:
        nmode = cmode
    else:
        nmode = 2

    if cmode != 0:
        if nmode != cmode:
            cnt += 1
            cmode = 0
            sz = 1
        else:
            cmode = nmode
            sz += 1
    else:
        cmode = nmode

    a = arr[i]

print(cnt)


Measured memory_bytes: 14228
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys
import math

w = int(input())
n = int(input())
s = []

for _ in range(n):
    x = input().split(',')
    s.append((int(x[0]), int(x[1])))

result = [i for i in range(1, w+1)]

for x, y in s:
    result[x-1], result[y-1] = result[y-1], result[x-1]

for x in result:
    print(x)

Measured memory_bytes: 6784
#include<bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
long long BIT[262145];
long long dp[262145];
int n;
int h[262145];
long long a[262145];
long long query(int x){
	long long ret=0LL;
	for(;x;x-=lowbit(x))
		ret=max(ret,BIT[x]);
	return ret;
}
long long add(int x,long long y){
	for(;x<=262144;x+=lowbit(x))
		BIT[x]=max(BIT[x],y);
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++){
		dp[h[i]]=query(h[i])+a[i];
		add(h[i],dp[h[i]]);
	}
	cout<<query(n)<<endl;
	return 0;
}


Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.BitSet;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bf.readLine());
        StringBuilder sb = new StringBuilder();
        BitSet bitSet = new BitSet(13554432);
        final char[] key = new char[128];
        key['A'] = 0;
        key['C'] = 1;
        key['G'] = 2;
        key['T'] = 3;
        for (int i = 0; i < n; i++) {
            String sp = bf.readLine();
            if (sp.charAt(0) == 'i') {
                int hash = 1;
                for (int j = 7; j < sp.length(); j++) {
                    hash <<= 2;
                    hash+=key[sp.charAt(j)];
                }
                bitSet.set(hash);
            } else {
                int hash = 1;
                for (int j = 5; j < sp.length(); j++) {
                    hash <<= 2;
                    hash+=key[sp.charAt(j)];
                }
                sb.append(bitSet.get(hash) ? "yes\n" : "no\n");
            }
        }
        bf.close();
        System.out.print(sb.toString());
    }
}


Measured memory_bytes: 68504
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 

int main(){
  ll a;
  string b;
  cin >> a >>b;
  int B;
  B=(b.at(0)-48)*100+(b.at(2)-48)*10+b.at(3)-48;
  ll x=a*B/100;
    cout << x << endl;
}

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

#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi acos(-1.0)
#define oo 1000000007
#define loo 0x7fffffffffffffff

#define prime 1000000007

ll mod;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    int c = 0,f = 0;
    for (int i = 0; i < n; ++i){
        int a, b; cin >> a >> b;
        if(a == b) c++;
        else c = 0;
        if(c == 3) f = 1;
    }
    if(f) cout << "Yes\n";
    else cout << "No\n";



    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using treap = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
template <class T, class S> ostream& operator<<(ostream& s, unordered_map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  string s; cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)

	if n < 1000 {
		fmt.Println(1000 - n)
	} else {
		for n > 1000 {
			n = n - 1000
		}
		fmt.Println(1000 - n)
	}
}


Measured memory_bytes: 1836
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int a = stdIn.nextInt();
    int b = stdIn.nextInt();
    int c = stdIn.nextInt();
    if((10*b+c)%4==0){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


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

int main(void)
{
  int h, m, s;
  cin >> s;

  h = s / 3600;
  m = (s - h * 3600) / 60;
  s = s - h * 3600 - m * 60;

  // cout << s / 3600 << ":" << s % 3600 / 60 << ":" << s % 3600 % 60 << endl;
  cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int x,y;
    int r = 0;
    cin >> x >> y;
    if(x < y) swap(x,y);
    while(y > 0){
    	r = x%y;
    	x = y;
    	y = r;
    }
    cout << x<<endl;
    return 0;
}



Measured memory_bytes: 3064
R,r=range,raw_input
N,K=map(int,r().split())
L=K+1
P,Q=R(K),R(L)
D=[L*[0]for i in Q]
a=b=0
for i in R(N):
 x,y,c=r().split()
 x,y=int(x),int(y)
 p=(x/K+y/K+ord(c))%2
 D[y%K+1][x%K+1]+=1-2*p
 b+=p
for k in R(2):
 for i in P:
  for j in Q:D[(i+1,j)[k]][(j,i+1)[k]]+=D[(i,j)[k]][(j,i)[k]]
for i in Q:
 for j in Q:
  S=D[i][K]+D[K][j]-D[i][j]*2
  a=max(a,S,D[K][K]-S)
print a+b

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



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

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    string a,b,c;
    cin>>a>>b>>c;

    int diff='A'-'a';

    cout<<(char)(a[0]+diff)<<(char)(b[0]+diff)<<(char)(c[0]+diff)<<endl;

}


Measured memory_bytes: 3560
a, b, c = map(int, input().split())
k = int(input())

if max([a,b,c]) == c:
    ans = c*(2**k) + b + a
elif max([a,b,c]) == b:
    ans = b*(2**k) + a + c
else:
    ans = a*(2**k) + b + c
print(ans)

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5005,mod=1e9+7;
int n,k,f[N],s[N],si[N],a[N],dp[N];
int getf(int x){return f[x]==x?x:f[x]=getf(f[x]);}
ll ans;
vector<int>v;
ll qpow(ll a,ll n)
{
    ll ans=1;
    for(;n;n>>=1,a=a*a%mod)if(n&1) ans=ans*a%mod;
    return ans;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),f[i]=i;
    for(int i=1;i<=n;i++) if(a[i]!=-1) f[getf(i)]=getf(a[i]);
    for(int i=1;i<=n;i++) if(a[i]==-1) s[getf(i)]++;
    for(int i=1;i<=n;i++) si[getf(i)]++;
    for(int i=1;i<=n;i++)
        if(f[i]==i)
        {
            if(s[i]==0) ans++;
            else v.push_back(si[i]);
        }
    k=v.size();
    dp[0]=1;
    for(int i=0;i<k;i++)
        for(int j=i+1;j>=1;j--)
    {
        dp[j]=(dp[j]+(ll)dp[j-1]*v[i]%mod*max(1,j-1)%mod)%mod;
    }
    ans=ans*qpow(n-1,k)%mod;
    for(int i=2;i<=k;i++) ans=(ans+qpow(n-1,k-i)*dp[i])%mod;
    for(int i=0;i<k;i++) ans=(ans+qpow(n-1,k-1)*(v[i]-1)%mod)%mod;
    ans=n*qpow(n-1,k)-ans;
    ans=(ans%mod+mod)%mod;
    printf("%lld\n",ans);
}
//(m-1)!*a[1]*a[2]*...*a[m] * (n-1)^(k-m)


Measured memory_bytes: 3976
n,m=map(int,input().split())
L1=[]
L2=[]
for i in range(n):
    a=list(map(int,input().split()))
    L1.append(a)
L1.sort()
money=0
for x,y in L1:
    if y <= m:
        money = money + y*x
        m -= y
    elif y > m >= 0:
        money = money + x*m
        break
print(money)


Measured memory_bytes: 60888
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;

lli dp[5005][5005] = {};
int main()
{
    int n;
    cin >> n;
    using pp = pair<lli, pair<lli, lli>>;
    vector<pp> v;
    lli a, b, c;
    rep(i, n)
    {
        cin >> a >> b;
        v.push_back(pp(a + b, make_pair(a, b)));
    }
    sort(v.begin(), v.end());
    lli inf = 1e18;
    rep(i, 5005) rep(j, 5005) dp[i][j] = (j == 0 ? 0 : inf);
    // iまでやったときにj人選んだときの最小高さ

    rep(i, n)
    {
        lli h = v[i].second.first;
        lli p = v[i].second.second;
        rep(j, n)
        {
            // if (dp[i][j] == inf)
            //     break;
            if (dp[i][j] <= h)
                dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + p);
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
        }
    }
    lli ans = 0;
    rep(j, n + 1)
    {
        if (dp[n][j] != inf) {
            ans = j;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 196288
#include <bits/stdc++.h>
using namespace std;  
#define ll long long int
#define All(a) (a).begin(),(a).end()

void solve(){
  int n;
  scanf("%d",&n);
  vector<int> a(n),b(n),c(n);

  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(int i=0;i<n;i++){
    scanf("%d",&b[i]);
  }

  for(int i=0;i<n;i++){
    scanf("%d",&c[i]);
  }
  sort(All(a));
  sort(All(b));
  sort(All(c));
  ll count=0;
  for (int j = 0; j < n; j++)
  {
    auto tmp = lower_bound(All(a),b[j]);
    ll l=tmp-a.begin();
    ll tmp2 = c.end()-upper_bound(All(c),b[j]);
    count+=l*tmp2;
      
    
  }
  printf("%lld\n",count);
}
int main(){
  /*
  int q;
  scanf("%d",&q);
  while(--q)solve();
  */
  solve();

  return 0;
}

Measured memory_bytes: 4576
#include <stdio.h>

int main(void){

	int n, a, b, max, min;
	scanf("%d %d %d", &n, &a, &b);
	
	min = a + b - n;

	if(min < 0){
		min = 0;
	}
	
	if(a > b){
		max = b;
	}else{
		max = a;
	}
	
	printf("%d %d", max, min);
	
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;
const int maxn = 100000;
int n,a[maxn+1];
map<int,int> M;
int res;
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n;
	M.clear();
	for (int i=1; i<=n; i++)
	{
		cin >> a[i];
		M[a[i]]++;
		M[a[i]+1]++;
		M[a[i]-1]++;
	}
	res=0;
	for (auto it=M.begin(); it!=M.end(); it++)
	res=max(res,(*it).second);
	cout << res;
	return 0;
}

Measured memory_bytes: 5120
S= input()
x = int(S[0:2])
y = int(S[2:])

mmyy = False
yymm = False
if 0 < x and x < 13:
    mmyy = True
if 0 < y and y < 13:
    yymm = True

if yymm and mmyy:
    print('AMBIGUOUS')
elif yymm:
    print('YYMM')
elif mmyy:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
#define double long double
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	double n,m,d;
	cin >> n >> m >> d;
	if(d) printf("%.20llf\n",(n - d) * 2 * (m - 1.0) / n / n);
	else printf("%.20llf\n",(n - d) * (m - 1.0) / n / n);
	return 0;
}

Measured memory_bytes: 256