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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<ll> h(n);
  vector<unordered_set<int>> path(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    path[a].insert(b);
    path[b].insert(a);
  }

  int cnt = 0;

  for (int i = 0; i < n; i++) {
    bool good = true;
    for (auto& p : path[i]) {
      if (h[i] <= h[p]) {
        good = false;
        break;
      }
    }
    if (good) ++cnt;
  }
  cout << cnt << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 19040
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
int pr(int n)
{
 for(int i=2;i*i<=n;i++)
      {
          if(n%i==0)
          return 0;
      }
      return 1;
}
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {  
        int n;
        cin>>n;
        int sum=0;
      for(int i=1;i<=n;i++)
      {
          for(int j=1;j<=n;j++)
          {
              for(int k=1;k<=n;k++)
              {   
                  int x=__gcd(i,j);
                  sum+=__gcd(x,k);
              }
          }
      }
      cout<<sum;
    }
    
}
// 🍪 🍪 🍪


Measured memory_bytes: 3648
x = int(input())
#6,5,6,5を繰り返す
if x % 11 == 0:
    ans = x // 11 * 2
elif 0 < x % 11 <= 6:
    ans = x // 11 * 2 + 1
else:
    ans = x // 11 * 2 + 2
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K,Q;
    cin >>N>>K>>Q;
    vector<int>point(N,K-Q);
    for(int i=0;i<Q;i++){
        int t;
        cin >>t;
        point[t-1]++;
    }
    for(int i=0;i<N;i++){
        if(point[i]>0){
            cout <<"Yes"<<endl;
        }
        else{
            cout <<"No"<<endl;
        }
    }
}


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

void solve (int test_case) {
   char c ;
   cin >> c ;
   if (c >= 'A' && c<= 'Z') {
      cout << 'A' ;
   } else {
      cout << 'a' ;
   }
}

int main () {
   ios_base::sync_with_stdio(false) ;
   cin.tie(NULL) ;
   cout.tie(NULL) ;
   int tc = 1 ;
   //cin >> tc ;
   for (int i = 1 ; i <= tc ; ++i) {
      solve(i) ;
   }
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        int a = scanner.nextInt();

        int tmp=0;
        int sum=0;
        int max=0;

        for(int i=0;i<a;i++) {
        	tmp = scanner.nextInt();
        	sum += tmp;
        	if(max<tmp) {
        		max=tmp;
        	}
        }
        if(max>=(sum-max)) {
        	System.out.println("No");
        }else {
        	System.out.println("Yes");
        }

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 21204
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double d = Double.parseDouble(sc.next());
		double e = (int)d + 1;
		e = Math.max(e, d / Math.sqrt(2) * 2);
		System.out.println(e);
	}
}


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

using namespace std;

int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int total = total;
    int count = 0;
    for(int r=0; R*r<=N; ++r){
        total = N - R*r;
        for(int g=0; G*g<=total; ++g){
            if((total-G*g)%B==0) ++count;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    int d,n;
    scanf("%d%d",&d,&n);
    if(d==0){
        printf("%d\n",n+(n==100));
    }else if(d==1){
        printf("%d\n",100*(n+(n==100)));
    }else if(d==2){
        printf("%d\n",10000*(n+(n==100)));
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n; cin>>n;
    if (n%2) {
        cout << 0 << '\n';
        return 0;
    }
    
    n/=2;
    ll ans = 0;
    ll cnt = 5;

    while (n/cnt>0) {
        ans += (n/cnt);
        cnt *= 5;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <climits>
#include <cstring>
#include <utility>
#include <cmath>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define F first
#define S second 
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl "\n"


void print() { cout << endl; }

template <typename T, typename... Types>
void print(T arg, Types... args) {
    cout << arg << " ";
    print(args...);
}

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef vector < int > vi;

const int mod = 1e9 + 7;
const int N = 2e5 + 7;


ll gcdExtended(ll a, ll b, ll *x, ll *y){
    if (a == 0){
        *x = 0, *y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}

ll modInv(ll a, ll m){
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);
    ll res = (x%m + m) % m;
    return res;
}
 
 
ll mpower(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while(y > 0){
        if(y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
 
ll power(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}
 
bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    ll p=sqrt(n);
    for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}

int arr[105];

int main()
{
    IOS;
    int n, m, sum = 0;
    double threshold;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        sum += arr[i];
    }
    threshold = (sum*1.0d / (4.0d * m));
    sort(arr, arr+n, greater<int>());
    
    if (arr[m-1] < threshold)
    {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

//深さ優先
vector<int> seen;
vector<ll> h;

//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){
    seen[v] = 0; //v探索済み

    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }

    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}

bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }

    return false;
}

int main(){
    /*
    int n,m;
    cin>>n>>m;

    h.assign(n,0);
    rep(i,0,n) cin>>h[i];

    Graph G(n);
    rep(i,0,m){
        int a,b; cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    seen.assign(n,-1);

    rep(i,0,n){
        if(seen[i]==-1){
            dfs(G,i);
        }
    }

    int sum=accumulate(all(seen),0);

    cout<<sum<<endl;*/

    string s; cin>>s;
    map<char,int> ch;
    int n=s.size();

    if(n==1){
        cout<<"YES"<<endl;
        return 0;
    }

    for(int i=0;i<s.size();i++){
        ch[s[i]]+=1;
    }

    vector<int> num;
    for(auto i:ch){
        int numb=i.second;
        num.push_back(numb);
    }

    sort(all(num));
    int max_=num[num.size()-1];
    int m2=num[num.size()-2];

    int poss=n/3+min(1,n%3);

    if(max_>=poss+1){
        cout<<"NO"<<endl;
        return 0;
    }

    if(n%2==0){
        if(n==2){
            cout<<"YES"<<endl;
            return 0;
        }
        if(max_==(n/2)&&max_==m2){
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;
    return 0;


}

Measured memory_bytes: 512
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll p = a - b;
	ll qa = b + c;
	ll qb = a + c;
	ll qc = a + b;
	ll q = qa - qb;

	if (k % 2 == 0 && p < 1000000000000000000) {
		cout << p << endl;
	}
	else if (k % 2 == 1 && p < 1000000000000000000) {
		cout << q << endl;
	}
	else cout << "Unfair"<< endl;
}


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

int main(){
	int N,M;
	cin >> N >> M;
	set<int> prob;
	map<int,int> v;
	for(int i = 1 ; i <= N ; i++) v[i] = 1;
	prob.insert(1);
	for(int i = 0 ; i < M ; i++){
		int x,y;
		cin >> x >> y;
		
		v[y]++;
		v[x]--;
		if( prob.count(x) ){
			prob.insert(y);		
		}
		if( v[x] == 0 ){
			prob.erase(x);
		}
	}
	cout << prob.size() << endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 a, b;
    cin >> a >> b;
    if(a > b)swap(a,b);
    // int64 gcd = 1;
    // int64 c = 1;
    // for(; c * c <= a; c++){
    //     if(a % c == 0){
    //         if(b % (a / c) == 0){
    //             gcd = a / c;
    //             break;
    //         }
    //     }
    // }
    // ANS(gcd);
    int64 g = gcd(a, b);
    int64 ans = 1;
    int64 p = 2;
    while(g >= 2 && p * p <= g){
        if(g % p == 0){
            ans++;
            while(g % p == 0){
                g /= p;
            }
        }
        p++;
    }
    if(g >= 2)ans++;
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
#include <chrono>
#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

void hora(int tc) {
	ll A, B;
	ll T, V, W;
	cin>>A>>V;
	cin>>B>>W;
	cin>>T;
	ll diff = abs(B - A);
	ll diffspeed = V - W;
	if(diffspeed < 0) cout<<"NO"<<endl;
	else if(T * diffspeed >= diff) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 3648
while s=gets
s = s.chomp
for _ in 0...27
  for i in 0...s.length
    c = s[i].ord
    if "a".ord <= c && c <= "z".ord
      c = (c-"a".ord+1)%26+"a".ord
    elsif "A".ord <= c && c <= "Z".ord
      c = (c-"A".ord+1)%26+"A".ord
    end
    s[i] = c.chr
  end
  t = s.downcase
  if t.index("this")!=nil || t.index("that")!=nil || t.index("the")!=nil
    puts s
    break
  end
end
end

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

int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++) 
    cin >> W.at(i);
  
  int omo = 0;
  int LCOUNT = 0;
  int RCOUNT = 1;
  for (int i = 0; i < N; i++) {
    if (omo > 0){
    omo -= W.at(LCOUNT);
    LCOUNT++;
      }
    else{
    omo += W.at(N-RCOUNT);
    RCOUNT++;
    }
  }
    if (omo < 0)
      omo *= -1;
 cout << omo << endl;
}

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

bool ans=true;
   int n;
  cin>>n;
  int x;
  vector<int> arr;
  for(int i=0;i<n;i++)
  {
    cin>>x;
    arr.push_back(x);
  }
 for(int i=0;i<arr.size();i++)
 {
 if(arr[i]%2==0&&arr[i]%3!=0&&arr[i]%5!=0)
 {cout<<"DENIED"<<endl;
  return 0;
 }
 }
cout<<"APPROVED"<<endl;
    
 } 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
      
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		System.out.println((B - A )*( B - A +1)/2 - B );
	}
}


Measured memory_bytes: 21716
import java.util.*;

public class Main {
	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<Path>[] graph = new ArrayList[n + 1];
		for (int i = 1; i <= n; i++) {
			graph[i] = new ArrayList<Path>();
		}
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			graph[a].add(new Path(b, c));
		}
		long[] values = new long[n + 1];
		Arrays.fill(values, Integer.MIN_VALUE * 1000L);
		ArrayDeque<Order> deq = new ArrayDeque<>();
		deq.add(new Order(new Path(1, 0), 0));
		int count = 0;
		long tmp = 0;
		while (deq.size() > 0) {
			Order o = deq.poll();
			if (values[o.p.to] < o.value + o.p.value) {
				values[o.p.to] = o.value + o.p.value;
				for (Path p : graph[o.p.to]) {
					deq.add(new Order(p, values[o.p.to]));
				}
			}
			if (count == n * 100) {
				tmp = values[n];
			} else if (count == n * 1000) {
				if (tmp < values[n]) {
					System.out.println("inf");
					return;
				}
				break;
			}
			count++;
		}
		System.out.println(values[n]);
	}
	static class Order {
		Path p;
		long value;
		public Order(Path p, long value) {
			this.p = p;
			this.value = value;
		}
	}
	
	static class Path {
		int to;
		int value;
		public Path(int to, int value) {
			this.to = to;
			this.value = value;
		}
	}
}


Measured memory_bytes: 47220
program Diskon_Perjalanan;
uses crt;
var
x,y:Integer;
function harga:Integer;
begin
harga:=x+(y div 2)
end;
begin
clrscr;
read(x);
readln(y);
if (1<=x) and (x<=100) and (1<=y) and (y<=100) and (y mod 2 =0) then
writeln(harga);
end.

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

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

    if(s[k-1] == 'A')s[k-1] = 'a';
    if(s[k-1] == 'B')s[k-1] = 'b';
    if(s[k-1] == 'C')s[k-1] = 'c';

    cout << s << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 999999;


queue<pair<int, int> > que;
int maze[300][300];
int d[300][300];
int dx[6] = {0, 1, 1, 0, -1, -1};
int dy[6] = {1, 1, 0, -1, -1, 0};


//今回 arr[y][x] で設計する
void bfs(int sx, int sy){
	que.push(make_pair(sy, sx));
	d[sy][sx] = 0;


	while(que.size()){
		int y = que.front().first;
		int x = que.front().second;
		que.pop();

		//seach around
		for(int i = 0; i < 6; i++){
			int ny = y + dy[i];
			int nx = x + dx[i];
			if(0 <= ny and ny < 300 and 0 <= nx and nx < 300 and d[ny][nx] == INF and maze[ny][nx]){
				que.push(make_pair(ny, nx));
				d[ny][nx] = d[y][x] + 1;
			}
		}
	}
}

int main(){
while(1){//start
	int t, n;
	cin >> t >> n;
	if(t == 0 and n == 0) break;

	//init
	for(int i = 0; i < 300; i++){
		for(int j = 0; j < 300; j++){
			d[i][j] = INF;
			maze[i][j] = 1;
		}
	}

	//0なら移動不可　1なら移動可能
	for(int i = 0; i < n; i++){
		int tx, ty;
		cin >> tx >> ty;
		maze[ty + 150][tx + 150] = 0;
	}
	int sx, sy;
	cin >> sx >> sy;

	bfs(sx + 150, sy + 150);

	int cnt = 0;
	for(int i = 0; i < 300; i++){
		for(int j = 0; j < 300; j++){
			if(d[i][j] <= t) cnt++;
		}
	}

	cout << cnt << endl;
}//end
	return 0;
}



Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define re register
#define ll long long
using namespace std;
inline ll read(){
	ll sum=0;int k=1;
	char c=getchar();
	for(;c<'0' || c>'9';c=getchar()) if(c=='-') k=-1;
	for(;c>='0' && c<='9';c=getchar()) sum=sum*10+c-48;
	return sum*k;
}
int n;
const int N=2e5+10,inf=2e9;
struct Ball{
	int x,y;
	bool operator<(const Ball &qwq)const{
		return x<qwq.x;
	}
}a[N];
ll ans;
multiset<int> R,W;
inline ll calc(){
	return 1ll*(*(--R.end())-*R.begin())*(*(--W.end())-*W.begin()); 
}
int main(){
	n=read();
	for(re int i=1;i<=n;++i){
		int x=read(),y=read();
		if(x>y) swap(x,y);
		a[i]=(Ball){x,y};
		R.insert(x);W.insert(y);
	}
	ans=calc();
	sort(a+1,a+n+1);
	for(re int i=1;i<=n;++i){
		int x=a[i].x,y=a[i].y;
		R.erase(R.find(x));W.insert(x);
		W.erase(W.find(y));R.insert(y);
		ans=min(ans,calc());
	}
	cout<<ans;
	return 0;
}
/*
3 815 6901 3839 178 199 10007 

*/

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

using namespace std;

const int mod = 1e9+7;

long long x[100000];

int main()
{
    int n;
    long long a, b;
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++)
        cin >> x[i];

    long long ans = 0;
    for (int i = 1; i < n; i++){
        ans += min((x[i] - x[i - 1]) * a, b);
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
    int i,count=0,t;
    int n=0;
    while(1){
        char ch[200]={},ch1[200]={};
        //??¢?????????????????????????????????
        scanf("%s\n",ch);
        //'-'???????????????????????????
        if(ch[0] == '-'){
            return 0;
        }else{
            //??¢???????????????????????°?????°??????
            count=0;
            for(i=0;i<200;i++){
                if(ch[i]==0){
                    break;
                }else{
                    count++;
                }   
            }
            //printf("%d\n",count);
            n=0;
            scanf("%d",&n);//?????£??????????????°
            //printf("%d\n",n);
            int h[n];
            for(i=0;i<n;i++){
                scanf("%d",&h[i]);
                //printf("%d\n",h[i]);
            }
            //n????????£?????????
            for(i=0;i<n;i++){
                for(t=0;t<count;t++){
                    if(t<(count-h[i])){
                        ch1[t]=ch[h[i]+t];
                    }else{
                        ch1[t]=ch[t+h[i]-count];
                    }
                }
                /*for(t=0;t<count;t++){
                    printf("%c",ch1[t]);
                }
                printf("\n");*/
                for(t=0;t<count;t++){
                    ch[t]=ch1[t];
                }
            }
            //output
            for(i=0;i<count;i++){
                printf("%c",ch[i]);
            }
            printf("\n");
        }
    }
    return 0; /*0?????????*/
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m,l=0,r=2*1e5,num=0,mid=0,k=0;cin>>n>>m;
  vector<ll> a(n),s(n);rep(i,n) cin>>a[i];
  sort(a.begin(),a.end(),greater<ll>());
  s[0]=a[0];for(ll i=1;i<n;++i) s[i]=s[i-1]+a[i];
  while(r-l>1) {
    mid=(l+r)/2;num=0;k=n-1;
    for(ll i=0;i<n;++i) {
      for(ll j=k;j>-1;--j) {
        if(a[j]>mid-a[i]) break;
        k-=1;
      }
      num+=k+1;
    }
    if(num>m) l=mid;else r=mid;
  }
  ll ans=0;num=0;k=n-1;
  for(ll i=0;i<n;++i){
    for(ll j=k;j>-1;--j){
      if(a[j]>r-a[i]) break;
      k-=1;
    }
    if(k!=-1) ans+=s[k]+(k+1)*a[i];
    num+=k+1;
  }
  ans+=(m-num)*r;print(ans);
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;

int main()
{
    long long int n;
    while(~scanf("%lld",&n))
    {
        int sum=0;long long int x=n;
        while(x)
        {
            sum+=x%10;
            x=x/10;
        }
       /// printf("%d %d",n,sum)
        if(n%sum==0)
            printf("Yes\n");
        else
            printf("No\n");
    }

    return 0;
}


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

#define ub upper_bound
#define sum(a) accumulate(all(a),0ll)
#define lb lower_bound
#define all(v) begin(v),end(v)
#define allr(v) rbegin(v),rend(v)
#define sort_dec(v) sort(all(v),[](auto e1,auto e2){return e1>e2;})
#define For(n) for(ll i=0;i<n;i++)
#define Forj(n) for(ll j=0;j<n;j++)
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define Mp 1e9+7
#define vpll vector< pair<ll,ll> >
#define bug(n) {cout<<n;return;}
#define cont(n) {cout<<n<<endl;continue;}
#define pb push_back
 
void solve()
{
	ll n;
	cin>>n;
	ll a[n],b[n],c[n];
	For(n)cin>>a[i]>>b[i]>>c[i];
	ll dp[n][3];
	memset(dp,0,sizeof(dp));
	dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
	rep(i,1,n)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
	}
	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}
 
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	 
	// freopen("error.txt", "w", stderr);
	 
	int t=1;
	 
	while(t--)
	{
		solve();
	}

	cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	 
	return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const ll N=800005;
vi a[N];
bool vis[N];
vi top;
void dfs(ll u)
{
  vis[u]=true;
  for(auto x:a[u]) if(!vis[x]) dfs(x);
  top.pb(u);
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,m;
  cin>>n>>m;
  forn(i,m)
  {
    ll x,y;
    cin>>x>>y;
    a[x].pb(y);
  }
  for1(i,n) if(!vis[i]) dfs(i);
  vi dp(n+1,0);
  ll ans=0;
  for(auto u:top)
  {
    for(auto x:a[u])
    {
      dp[u]=max(dp[x]+1,dp[u]);
    }
    ans=max(ans,dp[u]);
  }
  cout<<ans;
}
//nothing is impossible

Measured memory_bytes: 25972
#include<iostream>
 
using namespace std;
int main()
{
	int N;
	cin >>N;
	string s;
	int cnt[26] = {0};
	for(int i=0; i<N; i++){
		cin >> s;
		cnt[s[0]-'A']++;
	}
	int ans = 0;
	for(int i=0; i<26; i++){
		if(cnt[i] > 0)
			ans++;
	}
	if(ans == 3)
		cout << "Three" << endl;
	else
		cout << "Four" << endl;
	
	return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    char a[130];
    char b[130];
    bool f=true;
    int n=s.size();
    for(char i='a';i<='z';i++){
        a[i]='A';
        b[i]='A';
    }
    int c=0;
    rep(i,n){
        c++;
        if (a[s[i]]=='A') a[s[i]]=t[i];
        else{
            if(a[s[i]]!=t[i]){
                f=false;
                break;
            }
        }
        if (b[t[i]]=='A') b[t[i]]=s[i];
        else{
            if(b[t[i]]!=s[i]){
                f=false;
                break;
            }
        }
    }
    if(f==true) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 776
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string gen(string s, string t, int i) {
  string ret;
  for (int j = 0; j < i; ++j) {
    if (s[j] == '?')
      ret += 'a';
    else
      ret += s[j];
  }
  ret.append(t);
  for (int j = ret.size(); j < s.size(); ++j) {
    if (s[j] == '?')
      ret += 'a';
    else
      ret += s[j];
  }
  return ret;
}

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

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

  auto contains = [&](int offset, int len) {
    if (len < t.size()) return false;
    for (size_t i = 0; i < t.size(); ++i) {
      if (s[offset + i] == t[i] || s[offset + i] == '?') continue;
      return false;
    }
    return true;
  };

  const int len = s.size();
  vector<string> v;
  for (int i = 0; i < len; ++i) {
    if (contains(i, len - i)) {
      v.push_back(gen(s, t, i));
    }
  }
  if (v.size() == 0) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  sort(v.begin(), v.end());
  cout << v[0] << endl;

  return 0;
}


Measured memory_bytes: 256
from sys import exit
# A,B,C = [int(n) for n in input().split()]
# N = int(input())
A = [0]*5
last = 129

for _ in range(5):
    A[_] = int(input())
    if(A[_]%10 != 0 and last%10 >= A[_]%10):
        last = A[_]
ans = 0
once = False
for a in A:
    if(a == last and not once):
        once = True
        continue
    if(a%10 != 0 ):
        a+=10 - a%10
    ans+=a
if(last == 129):
    print(ans)
else:
    print(ans+last)
# S = str(input())
# L = len(S)
# T = str(input())
# exit()


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
#include <numeric>
#include "math.h"
using namespace std;

#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for (long long i=(b)-1;i>=(a);i--)
#define REP(i,n) for (long long i=0;i<(n);i++)
#define RREP(i,n) for (long long i=(n)-1;i>=0;i--)

#define inf long long_MAX/3
#define INF long long_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<long long,long long>
#define pii pair<long long,long long>
#define pcc pair<char,char>
#define pic pair<long long,char>
#define pci pair<char,long long>
#define VS vector<string>
#define VI vector<long long>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out prlong longf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

long long a,b;
long long c,d;

long long ggd(long long number1,long long number2){
	long long m = number1;
	long long n = number2;

	if(number2 > number1){
		m = number2;
		n = number1;
	}

	while(m % n != 0){
		long long temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

long long lcm(long long number1,long long number2){
	return number1 * number2 / ggd(number1,number2);
}


int main(){

	cin >> a >> b >> c >> d;
//	cout << ggd(c,d);
	long long sum = b-a+1;
	long long ccount = b/c-(a-1)/c;

	long long dcount = b/d-(a-1)/d;
//	cout << dcount;

	long long cd = lcm(c,d);
	long long cdcount = b/cd-(a-1)/cd;
//	debug(sum);
//	debug(ccount);
//	debug(dcount);
//	debug(cdcount);
//	debug(lcm(2,2));
	cout << sum - ccount - dcount + cdcount;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int l = sc.nextInt();
	String[] s = new String[101];
	String stemp;
	int i,j;

	for (i=1;i<=n;i++){
	    s[i] =  sc.next();
	}

	for(i=1;i<=n;i++){
	    for(j=i+1;j<=n;j++){
		if (s[i].compareTo(s[j]) > 0){
		    stemp = s[i];
		    s[i]  = s[j];
		    s[j]  = stemp;
		}
	    }
	}

	for (i=1;i<=n;i++){
	    System.out.print(s[i]);
	}
	System.out.println("");
    }
}



Measured memory_bytes: 9940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

string to_str(int x) {
	stringstream ss;
	ss << x;
	return ss.str();
}

int main() {
	string N;
	
	while (cin >> N, N != "0000") {
		bool ng = true;
		REP(i, 3) if (N[i] != N[i + 1]) ng = false;
		
		if (ng) puts("NA");
		else {
			int ans = 0;
			
			while (N != "6174") {
				string s = N, l = N;
				
				sort(ALL(s));
				sort(ALL(l), greater<char>());
				
				string next = to_str(atoi(l.c_str()) - atoi(s.c_str()));
				
				reverse(ALL(next));
				while (next.size() < 4) next += '0';
				reverse(ALL(next));
				N = next;
				
				ans++;
			}
			
			cout << ans << endl;
		} 
	}
	
	return 0;
}

Measured memory_bytes: 3184
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int IMF = 1'000'000'000; //1e9
const int MIL = -1;
const long long LIMF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}







int main(){
    std::string T; std::cin >> T;
    for(int i(0), i_len(T.length()); i < i_len; ++i){
        if(T[i] == '?') T[i] = 'D';
    }
    std::cout << T << std::endl;
    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <iomanip>

int main(int argc, char *argv[])
{
    int x;

    std::cin >> x;

    if (x >= 30) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    
    int n;
    cin >> n;
    double a[n];
    for(ll i =0 ; i <n ; i++)cin >> a[i];

    double dp[n+1][n+1];

    memset(dp ,0 , sizeof(dp));
    double p =1;
    dp[0][0] = 1;
    for(ll i = 1 ; i <= n ; i++)
    {
        p *= (1 - a[i-1]);
        dp[i][0] = p;
        for(ll j = 1 ; j <= i ; j++)
        {
            dp[i][j] += dp[i-1][j-1]*(a[i-1]);
            dp[i][j] += dp[i-1][j]*(1-a[i-1]);
        }
    }

  

    double ans = 0;
    ll s = ceil((double)n/2);
    for(ll i = s ; i <= n ; i++)
    {
        ans += dp[n][i];
    }

    cout << setprecision(20) << ans;


    return 0;
}


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

namespace Atc_0042
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            long A = long.Parse(S.Split(' ')[0]);
            long B = long.Parse(S.Split(' ')[1]);
            long C = long.Parse(S.Split(' ')[2]);
            long X = long.Parse(S.Split(' ')[3]);
            long Y = long.Parse(S.Split(' ')[4]);

            long R = long.MaxValue;

            for (int i = 0; i <= 200000; i++)
            {
                long result = (2 * C * i);

                if (0 < (X - i))
                {
                    result += A * (X - i);
                }

                if (0 < (Y - i))
                {
                    result += B * (Y - i);
                }

                if (result <= R)
                {
                    R = result;
                }
            }

            Console.WriteLine(R);
        }
    }
}


Measured memory_bytes: 27488
#入力
N = int(input())
S = input()

count = 0
temp = 0

for i in range(1,N):
    temp = 0
    s_tmp = S
    for j in range(i):
        if( s_tmp[i:].find(s_tmp[j]) >= 0 and s_tmp[j]!=','):
            temp = temp + 1;
            s_tmp = s_tmp.replace(s_tmp[j], ",")
            if(temp>count):
                count = temp
        
print(count)

Measured memory_bytes: 3064
// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define	ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(v) v.begin(), v.end()
#define bpc(v) __builtin_popcountll(v)
#define IOS ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define itr iterator                                          	
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define ub upper_bound
#define lb lower_bound

const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const int mod = 1e9 + 7;
const double eps = 1e-15;
const int pw = 257;

ll sum, ans;
string s;

int main() {
	#ifdef Madi      
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
	#endif
	IOS                

	cin >> s;
	rep(i, 0, sz(s) - 1) {
		sum += int(s[i] - '0');
		if (s[i] != '0')
			ans = max(ans, sum - 1 + (sz(s) - i - 1) * 9);
	}

	cout << max(sum, ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 1000020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

ll a[maxn],b[maxn],c[maxn],ans,tot;
int n,k,cnt[120],tmp = 45;

inline void modify(ll x,int d){
	rep(i,0,tmp) if ( (x >> i) & 1ll ) cnt[i] += d;
}
void del(int id){
	int tot2 = 0;
	rep(i,1,tot){
		if ( ((b[i] >> id) & 1ll) == 0 ) modify(b[i],-1);
		else c[++tot2] = b[i];
	}
	rep(i,1,tot2) b[i] = c[i];
	tot = tot2;
}
int main(){
	scanf("%d %d",&n,&k);
	rep(i,1,n) scanf("%lld",&a[i]) , a[i] += a[i - 1];
	rep(i,1,n) rep(j,i,n) b[++tot] = a[j] - a[i - 1] , modify(b[tot],1);
	repd(i,tmp,0){
		if ( cnt[i] >= k ){
			ans += 1ll << i;
			del(i);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 9344
n=int(raw_input())
game=0
while game<n:
    run=0
    score=0
    out=0
    while out<3:
        ev=raw_input()
        if ev=='OUT':
            out=out+1
        elif ev=='HIT':
            run=run+1
            if run>3:
                run=3
                score=score+1
        else:
            score=score+run+1
            run=0
    print score
    game=game+1
    

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

int main(){
  int N,M;  cin >> N >> M;
  int maxL = -1;
  int minR = N;
  for(int i=0;i<M;i++){
    int L,R;  cin >> L >> R;
    if(L > maxL)  maxL = L;
    if(R < minR)  minR = R;
  }
  int ans = minR - maxL + 1;
  if(ans < 0) ans = 0;
  cout << ans << endl;
}


Measured memory_bytes: 256
turn=str(input())
corrected=str(input())
correct=False
count=0
while(True):
    count=count+1
    if(turn==corrected):
        print('Yes')
        break
    else:
        last=turn[len(turn)-1]
        turn=turn[0:len(turn)-1]
        turn=last+turn
    if(count>100):
        print('No')
        break

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

int main(){
    int n;
    cin>>n;
    vector<long long> a(n),x(n);
    for(int i=0;i<n;++i) cin>>a[i];
    long long sum=0;
    for(int i=0;i<n;++i) sum+=a[i];
    //cout<<"sum: "<<sum<<endl;
    x[0]=sum;
    for(int i=1;i<n;i+=2){
        x[0]-=2*a[i];
    }
    //cout<<"x0: "<<x[0]<<endl;
    for(int i=0;i<n-1;++i){
        x[i+1]=2*a[i]-x[i];
    }

    for(int i=0;i<n;++i) cout<<x[i]<<' ';
    cout<<endl;
}


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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;

int find_first(vector<int> &v, int t)
{
    int start = 0;
    int end = v.size()-1;
    int ans = -1;
    int mid;

    while(start<=end)
    {
        mid = start + (end-start)/2;

        if(v[mid]>=t)
            end = mid-1;
        else
        {
            start = mid + 1;
            ans = mid;
        }
    }

    return ans;
}


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

    vector<int> v;
    int temp;

    FOR0(i, n)
    {
        cin>>temp;
        v.push_back(temp);
    }

    sort(v.begin(), v.end());

    // for (std::vector<int>::iterator i = v.begin(); i != v.end(); ++i)
    // {
    //     cout<<*i<<" ";
    // }
    // cout<<endl;

    // for (int i = 0; i < 20; ++i)
    // {
    //     int index = find_first(v, 0, n-1, i);
        
    //     cout<<i<<" "<<v[index]<<" "<<index<<endl;
    // }

    int count = 0;

    for (int i = 0; i < n; ++i)
    {
        for (int j = i+1; j < n; ++j)
        {
            int a =find_first(v, v[i]+v[j]);

            if(a>j&&a!=-1)
            {
                count+=a-j;
                // cout<<v[i]<<" "<<v[j]<<" "<<v[a]<<" "<<a<<endl;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.read().split()

def main():

    score = defaultdict(int)
    for w in s[:n]:
        score[w] += 1
    for w in s[n+1:]:
        score[w] -= 1

    ans = max(max(score.values()), 0)
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

class Tree{
public:
	Tree(){}
	int key;
	Tree *parent;
	Tree *left;
	Tree *right;
};

Tree *root,*NIL;

void insert(int key);
void inorder(Tree *t);
void preorder(Tree *t);
void search(int key);

int main(){
	int m,i;
	cin>>m;
	string order;
	int key;
	loop(i,0,m){
		cin>>order;
		if(order[0]=='i'){
			cin>>key;
			insert(key);
		}else if(order[0]=='p'){
			inorder(root);
			cout<<endl;
			preorder(root);
			cout<<endl;
		}else{
			cin>>key;
			search(key);
		}
	}
}


void search(int key){
	Tree *x=root;
	while(x!=NIL){
		if(x->key==key){
			cout<<"yes"<<endl;
			return;
		}else if((x->key)>key){
			x=x->left;
		}else{
			x=x->right;
		}
	}
	cout<<"no"<<endl;
}

void insert(int key){
	Tree *x=root,*y=NIL,*z;
	z=(Tree *)malloc(sizeof(Tree));
	z->key=key;
	z->left=NIL;
	z->right=NIL;
	while(x!=NIL){
		y=x;
		if(z->key < x->key){
			x=x->left;
		}else{
			x=x->right;
		}
	}
	z->parent=y;
	if(y==NIL){
		root=z;
	}else if(z->key < y->key){
		y->left=z;
	}else{
		y->right=z;
	}
}

void preorder(Tree *t){
	if(t==NIL){
		return;
	}
	cout<<" "<<t->key;
	preorder(t->left);
	preorder(t->right);
}


void inorder(Tree *t){
	if(t==NIL){
		return;
	}
	inorder(t->left);
	cout<<" "<<t->key;
	inorder(t->right);
}

Measured memory_bytes: 21932