akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector> 

#define PB push_back
#define X first
#define Y second

using namespace std;

typedef long long ll;

const int N = 1e5 + 500;

int n, A[N];
vector < int > v[N];
bool mogu = 1;

ll dfs(int x,int lst){
	if((int)v[x].size() == 1)	
		return A[x];
	ll sm = 0;
	for(int y : v[x]){
		if(y == lst) continue;
		ll dj = dfs(y, x);
		if(dj > A[x])
			mogu = 0;
		sm += dj;
	}
	if(sm < A[x] || sm > 2LL * A[x])
		mogu = 0;
	if(x == lst && sm != 2LL * A[x])
		mogu = 0;
	return 2LL * A[x] - sm;
}

int main(){
	scanf("%d", &n);
	for(int i = 1;i <= n;i++)
		scanf("%d", A + i);
	if(n == 2){
		printf(A[1] == A[2] ? "YES\n" : "NO\n");
		return 0;
	}
	for(int i = 1;i < n;i++){
		int x, y; scanf("%d%d", &x, &y);	
		v[x].PB(y), v[y].PB(x);
	}
	for(int i = 1;i <= n;i++){
		if((int)v[i].size() > 1){
			dfs(i, i);
			break;
		}
	}
	printf(mogu ? "YES\n" : "NO\n");
	return 0;
}

Measured memory_bytes: 15512
h =[2, 4, 5, 7, 9]
b = [0, 1, 6, 8]
p = [3]
n = int(input())
x = int(n) - (int(int(n)/10)*10)
for i in h:
    if i == x:
        print("hon")
for i in b:
    if i == x:
        print("pon")
for i in p:
    if i == x:
        print("bon")

Measured memory_bytes: 9140
N = int(input())
A = list(map(int, input().split()))

A.insert(0, 0)
ans = 0
for i in range(1, N+1):
    if A[i-1] > A[i]:
        dai = A[i-1] - A[i]
        ans += dai
        A[i] += dai
print(ans)


Measured memory_bytes: 32240
#include <bits/stdc++.h>
using namespace std;
string x[110];
char a[110];
char b[110];
set<string>s;
int main(void)
{
    int n;
    cin>>n;
    for(int i=0;i<n;++i)
    {
        cin>>x[i];
        a[i]=x[i][0];
        b[i]=x[i][x[i].length()-1];
        s.insert(x[i]);
    }
    if(s.size()==n)
    {
        for(int i=0;i<n-1;i++)
        {
            if(b[i]!=a[i+1])
            {
                cout <<"No"<<endl;
                return 0;
            }
        }
        cout <<"Yes"<<endl;
    }
    else
    {
        cout <<"No"<<endl;
        return 0;
    }

    return 0;
}


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

#define el '\n'
#define ll long long

const int MAXN = 405;
const ll INF = 1e18L+5;

ll dp[MAXN][MAXN]; // dp[l][r] the min cost of combining l r into one vertex

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

  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> pref(n);
  for(int i = 0; i< n; i++){
    cin >> a[i];
    if(i==0) pref[i] = a[i];
    else pref[i] += pref[i-1]+a[i];
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      dp[i][j] = INF;
    }
  }

  for(int L = n-1; L >= 0; L--){
    for(int R = L; R < n; R++){
      if(L==R){
        dp[L][R] = 0;
      }else{
        for(int i = L; i < n; i++){
          dp[L][R] = min(dp[L][R], dp[L][i]+dp[i+1][R]+pref[R]-(L > 0 ? pref[L-1] : 0));
        }
      }
    }
  }

  cout << dp[0][n-1] << el;

  return 0;
}


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

int main(){
    int N; cin >> N;
    vector<int> X(N); for(int i = 0; i < N; ++i) cin >> X[i];

    long long min_n = 10000000000;
    int max_n = *max_element(X.begin(), X.end());
    for(int i = 0; i < max_n; ++i) {
        int cnt = 0;
        for(int k = 0; k < N; ++k) {
            cnt += (X[k] - (i + 1)) * (X[k] - (i + 1));
        }

        if(min_n > cnt) {
            min_n = cnt;
        }
    }

    cout << min_n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b) cout << c << endl;
    if(b == c) cout << a << endl;
    if(c == a) cout << b << endl;
    return 0;
}

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

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

sat=0

pre = A[0]
for i in range(1,N):
    if A[i]==pre+1:
        sat+=C[A[i]-2]
    pre = A[i]
sat+=sum(B)
print(sat)

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

int main() {
  
  int N; cin >> N; vector<int> vec(N); int minDif = 10000;
  
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  
  for (int i = 1; i < N; i++) {
    
    int sumLeft = 0; int sumRight = 0;
    
    for (int j = 0; j < i; j++) {
      sumLeft += vec.at(j);
    }
    
    for (int j = i; j < N; j++) {
      sumRight += vec.at(j);
    }
    
    minDif = min(minDif, abs(sumLeft - sumRight));
    
  }
  
  cout << minDif << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
//
struct BIT{
	//
	int n;
	vector<int> dat;
	//
	BIT(int n_){
		init(n_);
	}
	//
	void init(int n_){
		n=n_;
		dat=vector<int>(n+1,0);
	}
	//
	void add(int k,int a){
		k++;
		while(k<=n){
			dat[k]+=a;
			k+=k&-k;
		}
	}
	//
	int query(int k){
		k++;
		int res=0;
		while(k){
			res+=dat[k];
			k-=k&-k;
		}
		return res;
	}
};
//
int main(){
	int N,Q;
	cin>>N>>Q;
	BIT bit(N);
	while(Q--){
		int C,X,Y;
		cin>>C>>X>>Y;
		if(C==1){
			cout<<bit.query(Y-1)-bit.query(X-2)<<endl;
		}else{
			bit.add(X-1,Y);
		}
	}
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
int main()
{
    ll i,j,k,l,n,m;
    in(n);
    string s;
    cin>>s;
    char c;
    ll arr[n],brr[n],crr[n];
    arr[0]=s[0]=='R'?1:0;
    brr[0]=s[0]=='G'?1:0;
    crr[0]=s[0]=='B'?1:0;
    for(i=1;i<n;i++)
    {
        arr[i]=s[i]=='R'?1:0;
        brr[i]=s[i]=='G'?1:0;
        crr[i]=s[i]=='B'?1:0;
        arr[i]+=arr[i-1];
        brr[i]+=brr[i-1];
        crr[i]+=crr[i-1];
    }
    ll ans=0;
    ll man='R'+'B'+'G';
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            l=man-s[i]-s[j];
            if(s[i]==s[j])continue;
            if(l=='G')
            {
                k=j-i+j;
                if(k<n)ans+=brr[n-1]-brr[k];
                k=min(k-1,n-1);
                ans+=brr[k]-brr[j];
            }
            else if(l=='B')
            {
                k=j-i+j;
                if(k<n)ans+=crr[n-1]-crr[k];
                k=min(k-1,n-1);
                ans+=crr[k]-crr[j];
            }
            else if(l=='R')
            {
                k=j-i+j;
                if(k<n)ans+=arr[n-1]-arr[k];
                k=min(k-1,n-1);
                ans+=arr[k]-arr[j];
            }
//            cout<<i<<" "<<j;endl;
//            cout<<ans;endl;
        }
    }
    out(ans);endl;
}


Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, m, p=0, q, x, y, sum=0, maax=0, ex;
    cin>>n>>m;
    int a[m];
    for(int i=0; i<m; i++){
        cin>>a[i];
    }
    for(int i=0; i<m-1; i++){
        p=a[i+1]-a[i];
        if(p>maax){
            maax=p;
            x=i+1;
            y=i;
        }
    }
    q=n-a[m-1]+a[0];
    for(int i=0; i<m-1; i++){
            sum+=a[i+1]-a[i];
        }
    if(maax<=q){
        cout<<sum<<endl;
    }
    else{
        ex=a[x]-a[y];
        cout<<sum-ex+q<<endl;
    }
}


Measured memory_bytes: 4380
#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin>>s;
    int n=s.size();
    int x_0=0;
    int x_1=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0')
            x_0++;
        else {
            x_1++;
        }
    }
    cout<<n-abs(x_1-x_0)<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int turn[] = new int[num];
		int px[] = new int[num];
		int py[] = new int[num];

		for(int k=0;k<num;k++){
			turn[k] = sc.nextInt();
			px[k] = sc.nextInt();
			py[k] = sc.nextInt();
		}

		int x = 0;
		int y = 0;

		int t=0;
		int n=0;
		while(n<num){
			if(((Math.abs(x - px[n]) + Math.abs(y - py[n])) > turn[n] - t) ||
				((Math.abs(x - px[n]) + Math.abs(y - py[n])) %2 != (turn[n] - t)%2 )){

				break;
			}
			x = px[n];
			y = py[n];
			t = turn[n];
			n++;
		}

		if(n == num) System.out.println("Yes");
		else System.out.println("No");

	}
}

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

const int vmax=100010;

int N,M;
struct node{ int to,cost;};
vector<node> graph[vmax];

int dist[vmax];

int diameter(int n){
	function<void(int,int,int)> dfs=[&dfs](int v,int p,int c){
		dist[v]=c;
		for(auto &e:graph[v]) if(e.to!=p) dfs(e.to,v,c+e.cost);
	};
	dfs(0,-1,0);
	int root=max_element(dist,dist+n)-dist;
	dfs(root,-1,0);
	return *max_element(dist,dist+n);
}

int main(void){
	cin >> N;
	rep(i,N-1){
		int a,b,c;
		cin >> a >> b >> c;
		graph[a].push_back({b,c});
		graph[b].push_back({a,c});
	}
	cout << diameter(N) << endl;
	return 0;
}

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

void solve()
{
	ll n; cin >> n;
	vector<ll>base;
	while (n > 0)
	{
		base.push_back( (n - 1) % 26);
		n = (n - 1) / 26;
	}
	reverse(base.begin() , base.end());
	for (ll i = 0; i < base.size() ; ++i)
	{
		cout << (char)('a' + (base[i] ) );
	}

}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}



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

using namespace std;

using ll = long long;

int a[2][105], dp[2][105];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            if (i > 0) dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if (j > 0) dp[i][j] = max(dp[i][j], dp[i][j - 1]);
            dp[i][j] += a[i][j];
        }
    }

    cout << dp[1][n - 1] << endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  for(int i = 0; i < 4;i++){
    reverse((divide[i]).begin(), (divide[i]).end());
  }
  bool can = true;
  for(int i = 0; i < s.size();){
    bool can2 = false;
    for(int j = 0; j < 4; j++){
      string d = divide[j];
      if(s.substr(i, d.size()) == d){
        can2 = true;
        i += d.size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}
  


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
  for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
  T x;
  cin >> x;
  return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
  cin >> head;
  CIN(move(tail)...);
}
#define CINT(...)                                                              \
  int __VA_ARGS__;                                                           \
  CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
  ll __VA_ARGS__;                                                            \
  CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
  string __VA_ARGS__;                                                        \
  CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
  {                                                                          \
  FOREACH(x, v) { cout << x << " "; }                                    \
    cout << "\n";                                                          \
    }

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, M, H;
ll res;
vector<VL> g;

bool check(ll i){
  ll win=0,lose=0;
  REP(j,N){
    if(i!=j){
      if(g[i][j]==1) win++;
      if(g[i][j]==0) lose++;
    }
  }
  return (win<=H && lose<=H)?true:false;
}


void dfs(ll i, ll j){
  if(i==N-1 && j==N){
    res++;
    return;
  }
  ll ni,nj;
  if(j==N-1){
    ni=i+1,nj=ni+1;
  }else{
    ni=i,nj=j+1;
  }
  if(g[i][j]!=-1){
    if(check(i) && check(j)) dfs(ni,nj);
  }else{
    g[i][j]=0, g[j][i]=1;
    if(check(i) && check(j)) dfs(ni,nj);
    g[i][j]=1, g[j][i]=0;
    if(check(i) && check(j)) dfs(ni,nj);
    g[i][j]=-1, g[j][i]=-1;
  }
  return;
}
signed main(){
  while(1){
    cin>>N;
    if(N==0) break;
    H=N/2;
    cin>>M;
    g.assign(N,VL(N,-1));
    REP(i,M){
      LCIN(a,b);
      a--,b--;
      g[a][b]=1;
      g[b][a]=0;
    }
    res=0;
    dfs(0,1);
    cout << res << "\n";
  }
}



Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;



int main(){
  int n,t;
  cin >> n >> t;
  int ans = 10000;
  rep(i,n){
    int ca,ta;
    cin >> ca >> ta;
    if(ta<=t){
      if(ca<ans){
        ans = ca;
      }
    }
  }
  if(ans!=10000){
    cout << ans << endl;
  }else{
    cout << "TLE" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int H,W;
char S,T;
int d[26][26];
string s[5000];
int main(){
	cin>>H>>W>>S>>T;
	rep(i,H) cin>>s[i];

	rep(i,26) rep(j,26) if(i!=j) d[i][j] = 1e9;

	rep(i,H) rep(j,W){
		if(s[i][j]=='-'){
			char a = s[i][j-2];
			int k = j;
			while(s[i][k]=='-') k++;
			char b = s[i][k+1];
			assert(isupper(a) && isupper(b));
			d[a-'A'][b-'A'] = d[b-'A'][a-'A'] = 1;
			for(int l=j;l<k;l++) s[i][l] = '.';
		}
		if(s[i][j]=='|'){
			char a = s[i-2][j];
			int k = i;
			while(s[k][j]=='|') k++;
			char b = s[k+1][j];
			assert(isupper(a) && isupper(b));
			d[a-'A'][b-'A'] = d[b-'A'][a-'A'] = 1;
			for(int l=i;l<k;l++) s[l][j] = '.';
		}
	}
	rep(i,26) rep(j,26) rep(k,26) chmin(d[j][k],d[j][i]+d[i][k]);
	cout<<d[S-'A'][T-'A']<<endl;
}



Measured memory_bytes: 3264
@n = gets.to_i
@arr = gets.split.map(&:to_i) # n個の要素をもつ配列。これらをつかってmrrの各要素を作れるか判定する
q = gets.to_i
mrr = gets.split.map(&:to_i) # q個の要素を持つ配列。それぞれの要素を作れるかを判定する

def solve(i, m)
  return true if m == 0
  return false if i >= @n
  
  res = solve(i + 1, m) || solve(i+1, m - @arr[i])
end

mrr.each do |m|
  puts solve(0, m) ? 'yes' : 'no'
end


Measured memory_bytes: 6872
import itertools

N, M = map(int,input().split())


def main():
	k = []
	s = []
	answers = []

	for i in range(M + 1):
		inputs = list(map(int,input().split()))
		if i == M:
			answers = inputs.copy()
		else:
			k.append(inputs[0])
			s.append(inputs[1:])

	allCandidates = (list(itertools.product(range(2), repeat=N)))

	result = []
	for c in allCandidates:
		ok = True
		for i, ss in enumerate(s):
			sumBulk = 0
			for sNumber in ss:
				sumBulk += c[sNumber - 1]
			if sumBulk % 2 != answers[i]:
				ok = False
		if ok:
			result.append(c)

	print(len(list(set(result))))

if __name__ == '__main__':
	main()

Measured memory_bytes: 3188
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    sc.close();
    String C = Integer.toString(A, B);
    System.out.println(C.length());
  }
}


Measured memory_bytes: 23760
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define endl        '\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repp(i,a,b)    for(ll int i=b-1;i>=a;i--)
#define tr(container,it) for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define mpi         map<pair<ll int,ll int>,ll int>
#define vii         vector<pair<ll,pair<ll,ll> > >
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        998244353
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
#define N  300005
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";


// class MemoryGame{
// public:
// // vs construct(int n){
void solve(){
	ll n,m;
	cin>>n>>m;
	string s[n];
	rep(i,0,n) cin>>s[i];
	ll dp[n+5][m+5];
	rep(i,0,n+2)
	rep(j,0,m+2)
	dp[i][j]=0;
	if(s[0][0]=='#')
	dp[0][0]++;
	rep(i,0,n){
		rep(j,0,m){
			if(i==0&&j==0) continue;
			if(i==0){
				if(s[i][j]=='.')
					dp[i][j]=dp[i][j-1];
				if(s[i][j]=='#'){
					if(s[i][j-1]=='#')
						dp[i][j]=dp[i][j-1];
					else
						dp[i][j]=dp[i][j-1]+1;
				}
			}
			else if(j==0){
				if(s[i][j]=='.')
					dp[i][j]=dp[i-1][j];
				if(s[i][j]=='#'){
					if(s[i-1][j]=='#')
						dp[i][j]=dp[i-1][j];
					else
						dp[i][j]=dp[i-1][j]+1;
				}
			}
			else{
				if(s[i][j]=='.')
					dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
				if(s[i][j]=='#'){
					if(s[i-1][j]=='#'&&s[i][j-1]=='#')
						dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
					else if(s[i-1][j]=='#')
						dp[i][j]=min(dp[i-1][j],dp[i][j-1]+1);
					else if(s[i][j-1]=='#')
						dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]);
					else
						dp[i][j]=min(dp[i-1][j],dp[i][j-1])+1;
				}	
			}
		}
	}	
	cout<<dp[n-1][m-1];
}
// };
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll TESTS=1,an=1,a,b;
    // cin>>TESTS;
    while(TESTS--){
        // cout<<"Case #"<<an<<": ";
        an++;
        solve();

    }
    return 0;
}


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

int main() {
	int a,b,c,d;
  cin >> a>>b>>c>>d;
  a=a+b;c=c+d;
  if(a>c)
    cout<<"Left"<<endl;
  else if (a<c)
    cout<<"Right"<<endl;
  else
    cout<<"Balanced"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (){

    int n;
    int AC=0, WA=0, TL=0, R=0;
    scanf("%d", &n);

    char str[105];

    while(n--){
        scanf("%s", &str);
        if(str[0]=='A'){
            AC++;
        } else if(str[0]=='W'){
            WA++;
        } else if(str[0]=='T'){
            TL++;
        } else if(str[0]=='R'){
            R++;
        }
    }
    printf("AC x %d\n", AC);
    printf("WA x %d\n", WA);
    printf("TLE x %d\n", TL);
    printf("RE x %d\n", R);



    return 0;
}

Measured memory_bytes: 1704
#include <cstdio>

int main(){
    int a[3];
    for(int i = 0; i < 3; i++){
        scanf("%d",&a[i]);
    }
    int v;
    for(int i = 0; i < 3; i++){
        for(int j = i + 1; j < 3; j++){
            if(a[i] < a[j]){
                v = a[i];
                a[i] = a[j];
                a[j] = v;
            }
        }
    }

    printf("%d\n",a[0] * 10 + a[1] + a[2]);

    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> V1(N);
    vector<int> V2(N);
    for (int i = 0; i < N; i++) {
        cin >> V1[i];
        V2[N - 1 - i] = V1[i];
    }

    int ans = 0;
    for (int i = 1; i <= min(N, K); i++) {
        for (int j = 0; j <= i; j++) {
            int res = K - i;
            int sum = 0;
            int A = i - j;
            int B = j;
            vector<int> cnt = {};
            for (int a = 0; a < A; a++) cnt.push_back(V1[a]);
            for (int b = 0; b < B; b++) cnt.push_back(V2[b]);
            sort(cnt.begin(), cnt.end());
            //for (int i = 0; i < cnt.size(); i++) cout << cnt[i] << " ";
            //cout << ":" << res << endl;
            
            for (int k = 0; k < cnt.size(); k++) {
                if (res > 0) {
                	if (cnt[k] < 0) {
                  		cnt[k] = 0;
                    	res--;
                	}
                    else break;
                }
                else break;
            }
            for (int k = 0; k < cnt.size(); k++) sum += cnt[k];
            //cout << sum << endl;
            ans = max(ans, sum);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long k = scanner.nextLong();
        if(b-a+1 <= 2*k) {
            for(long i = a;i <= b;i++) {
                System.out.println(i);
            }
        } else {
            long i,j;
            for(i = a;i < k+a;i++) {
                System.out.println(i);
            }
            for(j = b-k+1;j <= b;j++) {
                System.out.println(j);
            }
        }
    }
}

Measured memory_bytes: 23764
#include<cstdio>
#include<stack>
#include<iostream>
int main()
{
  using namespace std;
  int input;
  stack<int> st;
  while(~scanf("%d",&input))
    {
      if(input == 0)
        {
          cout<<st.top()<<endl;
          st.pop();
        }else
        {
          st.push(input);
        }
    }
  return 0;
}

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

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

    vector<bool> a(26);
    
    for(int i = 0; i < 26; i++){
        a[i] = false;
    }
    
    for(int i = 0; s[i] != 0; i++){
        a[s[i] - 'a'] = true;
    }
    
    int flag = 0;
    for(int i = 0; i < 26; i++){
        if(!a[i]){
            flag = 1;
            char c = i + 'a';
            cout << c;
            return 0;
        }
    }
    if(!flag) cout << "None";
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

namespace {
	int gcd(int x, int y)
	{
		if (x % y == 0)
			return y;
		else
			return gcd(y, x % y);
	}
}

int main()
{
	int x, y;
	cin >> x >> y;

	cout << gcd(x, y) << endl;

	return 0;
}

Measured memory_bytes: 1160
a, b, c, d = map(int, input().split())

def calc_lcd(x, y):
    if x < y:
        temp = x
        x = y
        y = temp
    
    r = x % y
    z = x * y
    while r != 0:
        x = y
        y = r
        r = x % y
    
    return z // y

lcd = calc_lcd(c, d)
a -= 1
#print(b // d)
#print("b:{0} b / c:{1} b / d:{2} b / lcd:{3} a:{4} a / c:{5} a / d:{6} a / lcd:{7}".format(b, b // c, b // d, b // lcd, a, a // c, a // d, a // lcd))
print(b - b // c - b // d + b // lcd - (a - a // c - a // d + a // lcd))


Measured memory_bytes: 3060
def main():
  a, b, c, d = list(input())
  sign = "+-"
  for i in range(2):
    for j in range(2):
      for k in range(2):
        if eval(a+sign[i]+b+sign[j]+c+sign[k]+d)==7:
          print(str(a+sign[i]+b+sign[j]+c+sign[k]+d)+"=7")
          exit()
if __name__ == "__main__":
  main()

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9+3;
const ll INF = 1e18+3;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    ll N, D, A;
    cin >> N >> D >> A;
    pll p[N];
    rep(i, N) cin >> p[i].first >> p[i].second;
    sort(p, p+N);
    //更新情報
    queue<pll> que;
    ll sum = 0, ans = 0;
    rep(i, N){
        while(!que.empty() && que.front().first+2*D < p[i].first){
            sum -= que.front().second;
            que.pop();
        }
        if(sum >= p[i].second) continue;
        ll n = (p[i].second-sum+A-1)/A;
        ans += n;
        sum += A*n;
        que.push(pll(p[i].first, A*n));
    }
    cout << ans << endl;
}

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

bool f(int x) {
  int keta = 0;
  // xが0までLoopする
  while (x) {
    //xが0でないなら変数をインクリメントして、桁数を１桁下げる
    keta++;
    x /= 10;
  }
  return keta%2 == 1;
}

int main() {
  int N;
  int ans = 0;

  cin >> N;

  for (int i = 1; i <= N; i++) {
    if (f(i)) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int D,T,S;
    cin >> D>>T>>S;
    if(((D-1)/S)+1<=T){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3632
# coding: utf-8
# Your code here!
import math

def main():
    n, d = map(int, input().split())
    count = 0
    for i in range(n):
        x, y = map(int, input().split())
        distance = math.sqrt(x ** 2 + y ** 2)
        if distance <= d:
            count += 1
    print(count)
    
main()

Measured memory_bytes: 9104
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

class UnionFind {
    int n;
    vector<int> uni;
    int forest_size;
public:
    explicit UnionFind(int n) : n(n), uni(static_cast<u32>(n), -1), forest_size(n) {};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        forest_size--;
        return true;
    }
    int size(){ return forest_size; }
    int size(int i){ return -uni[root(i)]; }
    bool same(int a, int b) { return root(a) == root(b); }
};

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> A(n), B(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &A[i].first);
        A[i].second = i;
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &B[i].first);
        B[i].second = i;
    }

    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    UnionFind uf(n);
    int ok = 0;
    for (int i = 0; i < n; ++i) {
        uf.unite(A[i].second, B[i].second);
        if(i && A[i].first < B[i-1].first){
            ok = 1;
        }
        if(A[i].first > B[i].first){
            puts("No");
            return 0;
        }
    }
    puts(uf.size() == 1 && !ok ? "No" : "Yes");
    return 0;
}

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

#define MAX_N 200000
#define MAX_K 100000
#define MAX_L 100000

// Union-Find tree
int UFpar[MAX_N*2+2];
int UFrank[MAX_N*2+2];
void init(int n);
int find(int x);
void unite(int x, int y);
bool same(int x, int y);


int main() {
    int N, K, L;
    cin >> N >> K >> L;
    init((N+1)*2);                  // i : 道路について、 i+N : 鉄道について
    for (int i = 0; i < K; i++) {
        int p, q;
        cin >> p >> q;
        unite(p, q);
    }
    for (int i = 0; i < L; i++) {
        int r, s;
        cin >> r >> s;
        unite(r+N, s+N);
    }


    vector<pair<int, int>> com(N+1);
    map<pair<int, int>, int> m;
    for (int i = 1; i <= N; i++) {
        com[i].first = find(i);
        com[i].second = find(i+N);
        m[com[i]]++;
    }
    for (int i = 1; i <= N; i++) {
        cout << m[com[i]];
        if (i < N) cout << " ";
        else cout << endl;
    }
    return 0;
}


void init(int n) {
    for (int i = 0; i < n; i++) {
        UFpar[i] = i;
        UFrank[i] = 0;
    }
}

// 木の根を求める
int find(int x) {
    if (UFpar[x] == x) {
        return x;
    } else {
        return UFpar[x] = find(UFpar[x]);
    }
}

// xとyの属する集合を併合
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (UFrank[x] < UFrank[y]) {
        UFpar[x] = y;
    } else {
        UFpar[y] = x;
        if (UFrank[x] == UFrank[y]) UFrank[x]++;
    }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y) {
    return find(x) == find(y);
}


Measured memory_bytes: 16640
//Kaori Miyazono, did I reach you ?
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;              

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if ( a == b ) cout << c;
	else if ( a == c ) cout << b;
	else cout << a;
	return 0;	
}    

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

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

void dfs(int y,int x,vector<vector<int> >&m){
    m[y][x]=0;
    for(int i=0;i<8;i++){
        int nexty=y+dy[i];
        int nextx=x+dx[i];
        if(nexty<0||nexty>m.size()-1||nextx<0||nextx>m[0].size()-1)continue;
        if(m[nexty][nextx]==1)dfs(nexty,nextx,m);
    }
}


int main(void){
    int h,w;
    int ans;
    vector<vector<int> >m;
    while(true){
        cin>>w>>h;
        if(h==0)break;
        ans=0;
        m=vector<vector<int> >(h,vector<int>(w));
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>m[i][j];
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(m[i][j]==1){dfs(i,j,m);ans++;}
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main() {
  int n;  cin >> n;
  string blue[100];
  for (int i = 0; i < n; i++) cin >> blue[i];
  
  int m;  cin >> m;
  string red[100];
  for (int i = 0; i < m; i++) cin >> red[i];
  
  int yen, max = 0;
  for (int i = 0; i < n; i++) {
    yen = 1;
    for (int j = i + 1; j < n; j++) {
      if (blue[i] == blue[j])
        yen++;
    }
    for (int k = 0; k < m; k++) {
      if (blue[i] == red[k])
        yen--;
    }
    if (max < yen)
      max = yen;
  }
  
  cout << max << endl;
}


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

int main()
{
 int n ;
 cin >> n;
 cout << "ABC" << n << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
vector<int>v[100100];
int dist1[100100],dist2[100100];
void dfs1(int pos,int depth)
{
	if(dist1[pos]!=-1)return;
	dist1[pos]=depth;
	for(int j=0;j<v[pos].size();j++)
	{
		dfs1(v[pos][j],depth+1);
	}
}
void dfs2(int pos,int depth)
{
	if(dist2[pos]!=-1)return;
	dist2[pos]=depth;
	for(int j=0;j<v[pos].size();j++)
	{
		dfs2(v[pos][j],depth+1);
	}
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	memset(dist1,-1,sizeof(dist1));
	memset(dist2,-1,sizeof(dist2));
	dfs1(1,0);
	dfs2(n,0);
	int cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++)
	{
		if(dist1[i]<=dist2[i])cnt1++;
		else cnt2++;
	}
	cout<<(cnt1>cnt2?"Fennec\n":"Snuke\n");
	return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;

int main(){
	int h,w;
	cin >> h >> w;
	vector<string> s(h,"");
	for(int i=0;i<h;i++){
		cin >> s[i];
	}
	
	for(int i=0;i<h;i++){
		cout << s[i] << endl;
		cout << s[i] << endl;
	}
	return 0;
}


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

int main() {
string n;
	cin >> n;
	string a[3] = { "Sunny","Cloudy","Rainy" };
	if (n == a[0])cout << a[1];
	if (n == a[1])cout << a[2];
	if (n == a[2])cout << a[0];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
#define MXN 200005
/*
4+4*2+3+4
*/
LL dp[2005][2005][2];
int mod=924844033;
LL dp2[2005];
LL fra[2005];
int main(){
    int n,K;
    scanf("%d %d",&n,&K);
    fra[0]=1;
    for(int i = 1;i<=n;i++)
    fra[i]=fra[i-1]*i%mod;
    vector<int> v[4005];
    for(int i = 1;i<=n;i++){
        v[i%(2*K)].pb(i);
    } 
    vector<vector<pii> > tmp;
    for(int i = 0;i<2*K;i++){
        for(int j = 0;j<=v[i].size();j++){
            for(int k=0;k<=v[i].size();k++){
                dp[j][k][0]=dp[j][k][1]=0;
            }
        }
        dp[0][0][0]=1;
        for(int j =0;j<v[i].size();j++){
            for(int k=0;k<=j;k++){
                dp[j+1][k][0]+=dp[j][k][0];
                if(v[i][j]>K)
                dp[j+1][k+1][0]+=dp[j][k][0];
                if(n-v[i][j]>=K)
                dp[j+1][k+1][1]+=dp[j][k][0];
                dp[j+1][k][0]+=dp[j][k][1];
                if(n-v[i][j]>=K)
                dp[j+1][k+1][1]+=dp[j][k][1];
                dp[j+1][k][0]%=mod;
                dp[j+1][k+1][1]%=mod;
                dp[j+1][k+1][0]%=mod;
            }
        }
        vector<pii> temp;
        for(int j=0;j<=v[i].size();j++){
            temp.pb(mp(j,(dp[v[i].size()][j][0]+dp[v[i].size()][j][1])%mod));
         //   printf("%d %d\n",temp.back().x,temp.back().y);
        }
      //  printf("?\n");
        tmp.pb(temp);
    }
    dp2[0]=1;
    for(auto it:tmp){
        for(int i = n;i>=1;i--){
            LL tot=0;
            for(auto it2:it){
                if(i>=it2.x){
                    tot+=dp2[i-it2.x]*it2.y;
                    tot%=mod;
                }
            }
            dp2[i]=tot;
        }
    }
    for(int i = 0;i<=n;i++){
        dp2[i]=dp2[i]*fra[n-i]%mod;
      //  printf("%lld ",dp2[i]);
    }
    LL ans=0;
    for(int i =0;i<=n;i++){
        if(i&1)ans-=dp2[i];
        else ans+=dp2[i];
        ans%=mod;
       // printf("%lld ",dp2[i]);
    }
    printf("%lld\n",(ans+mod)%mod);
}


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

struct UnionFind {
    vector<int> par; 

    UnionFind(int N) : par(N) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { 
        int rx = root(x);
        int ry = root(y); 
        if (rx == ry) return; 
        par[rx] = ry; 
    }

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

int main(){
 int n,k,l;
   cin >> n >> k >> l;
  
 UnionFind ar(n),br(n);
  
  rep(i,k) {
   int p,q;
    cin >> p >> q;
   p--;
   q--;
    ar.unite(p,q);
  }
  
  rep(i,l) {
   int p,q;
    cin >> p >> q;
   p--;
   q--;
   br.unite(p,q);
  }
  
  map<pair<int,int>,int> mp;
  rep(i,n) mp[make_pair(ar.root(i),br.root(i))]++;
  rep(i,n-1) cout << mp[make_pair(ar.root(i),br.root(i))] << " ";
    cout << mp[make_pair(ar.root(n-1),br.root(n-1))] << endl;

}  

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

int main(void){
    int N;
    cin>>N;
    vector<int> a(N);
    for (int i=0;i<N;i++) cin>>a[i];
    vector<int> c(8,0);
    int pro = 0;
    for (int i=0;i<N;i++) {
        if (a[i]>=3200) pro++;
        for (int j=0;j<8;j++) {
            if (a[i]>=400*j && a[i]<=400*j+399) {
                c[j]++;
            }
        }
    }
    int num = 0;
    for (int i=0;i<8;i++) if (c[i]!=0) num++;
    cout<<max(1,num)<<" "<<num+pro<<endl;
    
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars,
    }
    println!("{}", if s[0] == s[2] { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	ll A, B;
	cin >> A >> B;

	ll ans = 0;

	if (A == B)
	{
		ans = A + B;
	}
	else
	{
		ans = max(A, B) * 2 - 1;
	}

	cout << ans << endl;

	//system("pause");
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<functional>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const LL mod=1000000007;
LL dp[100010][30]={};
LL N;
string s,t;
int main(){
    cin>>N;
    cin>>s;
    cin>>t;
    dp[1][s[0]-'a']=1;
    for(int i=2;i<=N-1;i++){
        char sc=s[i-1]-'a';
        char tc=t[i-1]-'a';
        for(int j=0;j<='z'-'a';j++){
            dp[i][j]=dp[i-1][j];
        }
        dp[i][sc]=(dp[i-1][sc]+dp[i-1][tc])%mod;
        
    }
    /*for(int i=1;i<=N;i++){
        cout<<"["<<i-1<<"]"<<"["<<s[i-1]<<"]:"<<dp[i-1][s[i-1]-'a']<<endl;
    }*/
    //cout<<"[1][u]:"<<dp[1]['u'-'a']<<endl;
    cout<<dp[N-1][t[N-1]-'a']<<endl;
    return 0;
}


Measured memory_bytes: 26716
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N, K = sc.nextLong

  val z =
    if (N % K == 0) 0
    else {
      var x = N % K
      var y = Set.empty[Long]
      while (!y.contains(x)) {
        y += x
        x = math.abs(x - K)
      }

      y.min
    }
  println(z)
}


Measured memory_bytes: 27332
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;

    char buf[10]{};
    string s;
    cin >> s;
    int idx = 0;
    for (auto ch : s) {
        if (ch == '0') {
            buf[idx++] = ch;
        } else if (ch == '1') {
            buf[idx++] = ch;
        } else if (ch == 'B') {
            if (idx > 0)
                idx--;
        }
    }
    for (int i = 0; i < idx; i++) cout << buf[i];
    cout << endl;
}


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



int main(void)
{
	int i,j,c;
	int *a;
	int n,p;
	
	while(1)
	{
		scanf("%d",&n);
		scanf("%d",&p);
	
		if(n == 0 && p == 0){break;}
	
		a = (int *)malloc(sizeof(int)*n);
		if(a == NULL){
			printf("memory allocation fault.");
			exit(0);
		}
	
		for(i=0;i<n;i++){
		  a[i] = 0;
		}
	
		i = 0;
		while(1){
			while(1){
				a[i] += 1;
				i++;
				if(i==n){
					i -= n;}
				p--;
				if(p==0){break;}
			}
			
				c = 0;
			for(j=0;j<n;j++)
			{
				if(a[j] != 0){
	  			c++;
	  		}
			}
			if(c == 1){
				if(i==0){i=n;}
				printf("%d\n",i-1);
				break;}
		
			while(a[i]==0){
				i++;
				if(i==n){
			  i = 0;}
			}

			p = a[i];
			a[i] = 0;
			i++;
			if(i==n){
			  i = 0;}

		}
	
	}
  return 0;
}

Measured memory_bytes: 456
def isPrime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    k = 3
    while k < x:
        if x % k == 0:
            return False
        k += 2
    return True
    
X = int(input())

while True:
    if isPrime(X):
        print(X)
        exit(0)
    X += 1


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MAXN    (200020)
#define inf     (0x3fffffff)
typedef priority_queue< int , vector<int> , greater<int> > spq;

int sl;
char s[MAXN];
int f[MAXN];
int dp[MAXN];
int m[67108864];

int main(void)
{
    int i, j;
    scanf("%s", s+1); sl = strlen(s+1);
    for(i = 1;i <= sl;++i)
    {
        f[i] = 1 << (s[i]-'a');
        f[i] ^= f[i-1];
    }
    for(i = 1;i < 67108864;++i) m[i] = inf;
    m[0] = 0;
    for(i = 1;i <= sl;++i)
    {
        int dpi = m[f[i]];
        for(j = 0;j < 26;++j)
            dpi = min(dpi, m[f[i]^(1<<j)]);
        dp[i] = dpi+1;
        m[f[i]] = min(m[f[i]], dp[i]);
    }
    printf("%d\n", dp[sl]);
    return 0;
}


Measured memory_bytes: 264192
#include <iostream>
#include <map>
#include <bitset>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair

using namespace std;
typedef long long ll;

ll dp[60][60][2600];
int main()
{
  int N, A;
  cin >> N >> A;
  vector<int> x(N); REP(i, N) cin >> x[i];
  dp[0][0][0] = 1;
  REP(i, N) {
    REP(j, N) {
      REP(k, 2501) {
        dp[i + 1][j][k] += dp[i][j][k];
        dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
      }
    }
  }

  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += dp[N][i][A*i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 62592
#include <iostream>

using namespace std;

int main(){
	int P, Q, R;
	cin >> P;
	cin >> Q;
	cin >> R;
	int pq = P+Q;
	int pr = P+R;
	int qr = Q+R;
	int min = pq;
	if(min>pr) min=pr;
	if(min>qr) min=qr;
	cout << min << endl;
	return 0;
}


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

int main(){
    long long H, atk = 0;
    cin >> H;

    while(H > 0){
        H /= 2;
        atk++;
    }
    
    cout << (long long)pow(2, atk) - 1 << endl;
    
    return 0;
}

Measured memory_bytes: 4100
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;  //これで"std::cout"が"cout"と書ける

//MACRO
typedef long long ll;                  //64bit以上を表現可能な型
#define INF 100000000                  //ほぼ無限
#define itn int                        //タイポ対策
#define all(x) (x).begin(), (x).end()  //sort(all(x))などとする
#define SZ(x) ((int)(x).size())        //size()簡略化
//repetition
#define FOR(i, p, b) for (int i = (p); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define repR(i, n) for (int i = n; i >= 0; i--)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \<< " " << __FILE__ << endl;
template <class T>
bool chMAX(T &a, const T &b) {  //aよりbが大きければaに代入
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chMIN(T &a, const T &b) {  //aよりbが小さければaに代入
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

//
//
//

int main() {
    int n, m;
    cin >> n;
    string s[n];

    rep(i, n) {
        cin >> s[i];
    }

    cin >> m;
    string t[m];

    rep(i, m) {
        cin >> t[i];
    }

    int s_cnt = 0, t_cnt = 0, max = 0;
    string find;
    rep(i, n) {
        find = s[i];
        s_cnt = 0;
        t_cnt = 0;

        rep(i, n) {
            if (s[i] == find) {
                s_cnt++;
            }
        }
        rep(i, m) {
            if (t[i] == find) {
                t_cnt++;
            }
        }
        chMAX(max, s_cnt - t_cnt);
    }
    if (max > 0) {
        cout << max << endl;
    } else {
        cout << 0 << endl;
    }

}

Measured memory_bytes: 256