akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int main() {
    //c_p_c();
    string c;   cin>>c;
    if(c[2]==c[3]&&c[4]==c[5]){
        cout<<"Yes";
    } else  cout<<"No";
    return 0;
//    lli c;  cin>>c;
//    lli hap=0;
//    hap+=c/500;
//    hap*=1000;
//    c-=500*(c/500);
//    hap+=5*(c/5);
//    cout<<hap;
//    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s; cin >> s;
    int len = s.size();
    bool ans = true;
    if (len%2==1) ans = false;
    for (int i = 0; i < len; i+=2)
    {
        if (s[i]=='h' && s[i+1]=='i') {}
        else ans = false;
    }

    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
INF = 10 ** 9
MOD = 10 ** 9 + 7

def main():  
    h,w =map(int,input().split())

    ans = 0
    if h == 1 :
        ans = 1
    elif w == 1:
        ans = 1
    else:
        if w%2 == 0:
            ans = h * (w//2)
        else:
            if h % 2 == 0:
                ans = (h//2) * w
            else:
                ans = (h//2) * w + (w//2) + 1

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

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

int main(void) {
    int n;
    cin >> n;
    int array[n];
    for (int i = 0; i < n; i ++){
        cin >> array[i];
    }

    int max;
    int bangou = 0;
    max = array[0];
    for(int i = 0; i < n; i ++){
        if(array[i] > max){
            max = array[i];
            bangou = i;
        }
    }
    int kingaku = 0;
    for(int i = 0; i < n; i ++){
        if(i == bangou){
            kingaku += array[i] / 2;
        }else{
            kingaku += array[i];
        }
        }
    cout << kingaku << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
#define SIZE 1005
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll k;
set<string> st;

int main() {
	io(); cin >> k;
	queue<string> q;
	rep(i, 1, 9) q.push(to_string(i));
	vector<ll> vec;
	while (st.size() <= 2e5) {
		string top = q.front();
		q.pop();
		st.insert(top);
		if (top.back() != '9' && top.back() != '0') {
			char ch = top.back(); --ch;
			q.push(top + ch);
			q.push(top + top.back());
			ch += 2;
			q.push(top + ch);
		}
		else if (top.back() == '0') {
			char ch = top.back(); ++ch;
			q.push(top + top.back());
			q.push(top + ch);
		}
		else {
			char ch = top.back(); --ch;
			q.push(top + ch);
			q.push(top + top.back());
		}
	}
	for (auto i : st) vec.emplace_back((ll)stoll(i));
	sort(vec.begin(), vec.end());
	cout << vec[k - 1];
}

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

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

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int dup=0;
    for(int i = 1; i < n; i++) {
        if(a[i]==a[i-1]) dup++;
    }
    int ans=n-dup;
    if(dup%2!=0) ans--;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(System.in);
    try {
      long N = scanner.nextLong();
      long T = scanner.nextLong();
      long pre = -10000000000L;
      long ans = 0;
      for (int i = 0; i < N; i++) {
        long now = scanner.nextLong();
        long t = now - pre;
        if (T < t) {
          ans += T;
        } else {
          ans += t;
        }
        pre = now;
      }
      System.out.println(ans);
    }
    finally {
      scanner.close();
    }
  }
}

Measured memory_bytes: 60760
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

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

	vv(ll) info(n, vector<ll>(3));
	vector<ll> ping(3);
	for (int i = 0; i < n; ++i)
	{
		cin >> info[i][0] >> info[i][1] >> info[i][2];
		if (info[i][2] > 0)
		{
			ping[0] = info[i][0];
			ping[1] = info[i][1];
			ping[2] = info[i][2];
		}
	}

	for (ll x = 0; x <= 100; ++x)
	{
		for (ll y = 0; y <= 100; ++y)
		{
			ll h = ping[2] + abs(ping[0] - x) + abs(ping[1] - y);
			h = max(h, 0LL);
			int f = 1;
			for (int i = 0; i < n; ++i)
			{
				ll tmp = h - abs(info[i][0] - x) - abs(info[i][1] - y);
				tmp = max(tmp, 0LL);
				if (tmp != info[i][2])
					f = 0;
			}
			if (f)
			{
				printf("%lld %lld %lld\n", x, y, h);
				return 0;
			}
		}
	}
}



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

int main() {
  string A,B; cin >> A >> B;
  int lenA = A.length();
  int lenB = B.length();
  if( lenA > lenB ) cout << "GREATER" << endl;
  else if ( lenA < lenB ) cout << "LESS" << endl;
  else if ( lenA == lenB ){
    if ( A[0] > B[0] ) cout <<"GREATER" << endl;
    else if ( A[0] < B[0] ) cout <<"LESS" << endl;
    else cout << "EQUAL" << endl;
  }
  return 0;
}


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


int main() {
  int n;
  long long all = 0, ans = 0;
  cin >> n;

  vector<int>a(n);

  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    all += a.at(i);
  }
  long long store;
  for (int i = 0; i < n-1; i++) {
    all -= a.at(i);
    store = all % (1000000007);
    ans += a.at(i) * store;
    ans = ans % (1000000007);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4040
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();

        int i = 2;
        while (true) {
            if (i == x) {
                System.out.println(i);
                return;
            }
            if (x % i == 0) {
                x++;
                i = 2;
                continue;
            } else {
                i++;
            }
        }
    }
}


Measured memory_bytes: 23380
#define    ll           long long
#define    dn           double
#define    mp           make_pair
#define    pb           push_back
#define    se           second
#define    fi           first
#define    mod          1000000007
#define    sob(v)       v.begin(),v.end()
#define    sobr(v)      v.rbegin(),v.rend()
#define    fr(i,a,b)    for(int i=a;i<=b;++i)
#define    frr(i,a,b)   for(int i=a;i>=b;--i)
#define    pi           acos(-1.00)
#define    check        cout<<"*"<<endl
#define    ffix(x)      cout<<fixed<<setprecision(x)
#define    fast         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#include<bits/stdc++.h>
#include<string.h>
using namespace std;

typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<int,vi> pp;

int dr[8]= {0,0,-1,1,-1,-1,+1,+1};
int dc[8]= {-1,1,0,0,-1,+1,-1,+1};

const int inf=1e9;
const int N=200005;

/*inline void normal(ll &a){if(a>mod) a%=mod; (a<0) && (a+=mod);}
inline ll mod_mul(ll a,ll b){normal(a),normal(b); return (a*b)%mod;}
inline ll mod_add(ll a,ll b){normal(a),normal(b); return (a+b)%mod;}
inline ll mod_sub(ll a,ll b){normal(a),normal(b); a-=b; normal(a); return a;}
inline ll mod_pow(ll a,ll b){ll r=1; while(b>0){if(b&1)r=mod_mul(r,a); a=mod_mul(a,a); b>>=1;} return r;}
inline ll mod_inverse(ll a){return mod_pow(a,mod-2);}
inline ll mod_div(ll a,ll b){return mod_mul(a,mod_inverse(b));}*/


int main()
{
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll x=a*c;
   x=max(x,a*d);
   x=max(x,c*b);
   x=max(x,b*d);
   cout<<x<<endl;
}


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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP				make_pair
#define X				first.first
#define Y				first.second

typedef pair<int, int> P;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

struct Edge {
	int to, cost;
};

vector<Edge> G[100001];
int d[100001];
int V, E;

signed main() {
	int r;
	cin >> V >> E >> r;
	REP( i, E ) {
		int from, to, cost; cin >> from >> to >> cost;
		G[from].emplace_back( Edge{ to, cost } );
	}

	fill( d, d + 100001, INF );
	d[r] = 0;

	priority_queue<P, vector<P>, greater<P> > que;
	que.emplace( 0, r );
	while( !que.empty() ) {
		P p = que.top(); que.pop();
		int v = p.second;

		if( d[v] < p.first ) continue;

		REP( i, G[v].size() ) {
			Edge e = G[v][i];
			if( chmin( d[e.to], d[v] + e.cost ) ) {
				que.emplace( d[e.to], e.to );
			}
		}
	}

	REP( i, V ) {
		if( d[i] != INF) cout << d[i] << endl;
		else			 cout << "INF" << endl;
	}

}


Measured memory_bytes: 19484
#include <cstdio>
#include <algorithm>

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	long long h[200000];
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld", h + i);
	}
	std::sort(h, h + n);
	long long ans = 0;
	for (int i = 0; i < n - k; ++i)
	{
		ans += h[i];
	}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

int main(){

   string str;
   cin>>str;
   int n=str.size();
   char last=str[n-1];
   if(last =='s'){
       cout<<str<<"es"<<endl;
   }else{
       cout<<str<<"s"<<endl;
   }
    return 0;

}

Measured memory_bytes: 3588
while True:
    a,op,b=(input().split())
    if op=="+":
        print(int(a)+int(b))
    elif op=="-":
        print(int(a)-int(b))
    elif op=="*":
        print(int(a)*int(b))
    elif op=="/":
        print(int(a)//int(b))
    else:
        break


Measured memory_bytes: 5596
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    x = [[B[i],C[i]] for i in range(M)]
    x = sorted(x, key=lambda x: -x[1])

    A.sort()

    dn = 0
    for b, c in x:
        for j in range(b):
            if(dn >= N):
                break
            if(A[dn] < c):
                A[dn] = c
                dn += 1
            else:
                break


    print(sum(A))

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]" 
    C = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 31096
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
vector<string> ans;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A,B;cin>>A>>B;
  A--;B--;
  FOR(i,0,100){
    string s="";
    FOR(j,0,50)s+='#';
    FOR(j,50,100)s+='.';
    ans.push_back(s);
  }
  int cnt=0;
  for(int h=1;h<100&&cnt<A;h+=2){
    for(int w=1;w<49&&cnt<A;w+=2){
        ans[h][w]='.';
        cnt++;
    }
  }
  cnt=0;
  for(int h=1;h<100&&cnt<B;h+=2){
    for(int w=51;w<99&&cnt<B;w+=2){
        ans[h][w]='#';
        cnt++;
    }
  }
  cout<<100<<" "<<100<<endl;
  FOR(i,0,100)cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int N;
int a[10], w[10];
int ans = INT_MAX;

void solve(int already, vector<int> now){
    bool tmp[10] = {};
    for(int i=0; i<already; i++) tmp[now[i]] = true;
    if(already == N){
        int W = 0;
        for(int i=0; i<N-1; i++){
            if(a[now[i]] == 0 && a[now[i+1]] == 1) W += w[now[i]] + w[now[i+1]];
        }
        if(a[now[N-1]] == 0 && a[now[0]] == 1) W += w[now[N-1]] + w[now[0]];
        ans = min(ans, W);
        return;
    }
    for(int i=0; i<N; i++){
        if(tmp[i] == false){
            now[already] = i;
            solve(already+1, now);
            now[already] = -1;
        }
    }
}

int main(){
    iostream::sync_with_stdio(false);
    
    cin >> N;
    for(int i=0; i<N; i++) cin >> a[i];
    for(int i=0; i<N; i++) cin >> w[i];
    vector<int> tmp;
    tmp.push_back(0);
    for(int i=1; i<N; i++) tmp.push_back(-1);
    solve(1, tmp);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}



int main(void){
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
struct plant{std::string name; double per;plant(std::string,double);};

plant::plant(std::string _name, double _per)
	:name(_name), per(_per) {}

bool psort(const plant &l, const plant &r){
	if(l.per == r.per){
		if(strcmp(l.name.c_str(), r.name.c_str()) > 0)return 0;
		return 1;
	}

	return l.per > r.per;
}

int main(){
	int n;
	while(std::cin >> n, n){
		std::string l;
		int p, a, b, c, d, e, f, s, m;
		std::vector<plant> v;
		while(n--){
			std::cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			int time = a + b + c + (d + e) * m,
				value = f * s * m - p;
			double per = (double)value / (double)time;
			plant pl = plant(l, per);
			v.push_back(pl);
		}
		
		std::sort(v.begin(), v.end(), psort);
		
		std::vector<plant>::iterator it = v.begin();
		while(it != v.end()){
			std::cout << (*it).name << std::endl;
			it++;
		}

		std::cout << "#" << std::endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  int S, W; cin >> S >> W;
  if (W >= S) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}


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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
   
    
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; i++){
        if(i % d == 0)ans++;
    }
    cout << ans << '\n';
    return 0;
}
// Write Here


Measured memory_bytes: 3608
n,m =gets.split(' ').map(&:to_i)
h = Array.new(m, 0)
n.times do |i|
  a = gets.split(' ').map(&:to_i)
  a.shift
  a.each {|e| h[e-1] = h[e-1]+1  }
end
p h.select{|s| s == n}.count


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (2e9)
#define EPS (1e-6)
#define NATHANLEE_IS_EVIL true
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<"\n";}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(!NATHANLEE_IS_EVIL);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

#define LO(x) (x&(-x))
struct BIT{
	int n;
	int b[500050];

	void init(int _n){
		n=_n;
		memset(b,0,sizeof(b));
	}

	void add(int i,int x){
		i++;
		while(i<=n){
			b[i]+=x;
			i+=LO(i);
		}
	}

	int ask(int i){
		i++;
		int ans=0;
		while(i>0){
			ans+=b[i];
			i-=LO(i);
		}
		return ans;
	}

	friend inline ostream& operator<<(ostream &s,BIT &bit){
		s<<"BIT("<<bit.n<<")(0 ";
		For(i,0,bit.n-1) s<<bit.ask(i)<<" )"[i==bit.n-1];
		return s;
	}
};

struct Query{
	int l,r,ans,id;
	friend inline ostream& operator<<(ostream &s,const Query &p){
		s<<"Q(#"<<p.id<<","<<p.l<<"~"<<p.r<<"="<<p.ans<<")";
		return s;
	}
};
bool cmp1(const Query &a,const Query &b){
	return a.r<b.r;
}
bool cmp2(const Query &a,const Query &b){
	return a.id<b.id;
}

BIT bit;
int last[500050];

int32_t main() {
	INIT();
	//code...
	int n,q; cin>>n>>q;
	vector<int> c(n);
	for(auto &i:c)
		cin>>i;
	vector<Query> que(q);
	For(i,0,q-1){
		cin>>que[i].l>>que[i].r;
		que[i].l--; que[i].r--;
		que[i].id=i;
	}
	sort(all(que),cmp1);
	memset(last,-1,sizeof(last));
	int now=0;
	bit.init(n);
	For(r,0,n-1){
		if(last[c[r]]!=-1) bit.add(last[c[r]],-1);
		bit.add(r,1);
		last[c[r]]=r;
		while(now<q && que[now].r==r){
			que[now].ans=bit.ask(que[now].r)-bit.ask(que[now].l-1);
			//debug(now,que[now]);
			now++;
		}
	}
	sort(all(que),cmp2);
	for(auto &i:que)
		cout<<i.ans<<"\n";
	return 0;
}

Measured memory_bytes: 17404
def main():
    N, M = (int(i) for i in input().split())
    from heapq import heapify, heappop, heappush
    from collections import defaultdict
    sche = defaultdict(list)
    for i in range(N):
        a, b = (int(i) for i in input().split())
        sche[a].append(b)

    q = []
    heapify(q)

    ans = 0
    for i in range(1, M+1):
        for s in sche[i]:
            heappush(q, -s)
        if q:
            ans += -heappop(q)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 80600
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long N, long long D){
    int k = D * 2 + 1;
    cout << (N + k - 1) / k << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    solve(N, D);
    return 0;
}


Measured memory_bytes: 256
N,A,B=map(int,input().split())
if (0<A+B<=10**18)and(0<N<=10**18)and(A>=0)and(B>=0):
    if N%(A+B)<=A:
        c=(N//(A+B))*A+N%(A+B)
        print(c)
    else:
        d=(N//(A+B))*A+A
        print(d)

Measured memory_bytes: 3060
module BinaryTree = struct
  let nil = -1

  type t = {
    mutable parent : int;
    mutable left : int;
    mutable right : int;
  }

  let make () = {
    parent = nil;
    left = nil;
    right = nil;
  }
end

module T = BinaryTree

let _ =
  let n = read_int () in
  let t = Array.init n (fun _ -> T.make ()) in
  Array.iteri (fun i _ ->
    let id, l, r = Scanf.scanf "%d %d %d\n" (fun id l r -> id, l, r) in
    t.(id).T.left <- l;
    t.(id).T.right <- r;
    if l <> T.nil then t.(l).T.parent <- id;
    if r <> T.nil then t.(r).T.parent <- id
  ) t;
  let rec search_root i =
    if i = n then T.nil
    else if t.(i).T.parent = T.nil then i
    else search_root (i + 1)
  in
  let rec preorder i f =
    f i;
    if t.(i).T.left <> T.nil then preorder t.(i).T.left f;
    if t.(i).T.right <> T.nil then preorder t.(i).T.right f;
  in
  let rec inorder i f =
    if t.(i).T.left <> T.nil then inorder t.(i).T.left f;
    f i;
    if t.(i).T.right <> T.nil then inorder t.(i).T.right f;
  in
  let rec postorder i f =
    if t.(i).T.left <> T.nil then postorder t.(i).T.left f;
    if t.(i).T.right <> T.nil then postorder t.(i).T.right f;
    f i;
  in
  let root = search_root 0 in
  print_endline "Preorder";
  preorder root (fun i -> Printf.printf " %d" i);
  print_newline ();
  print_endline "Inorder";
  inorder root (fun i -> Printf.printf " %d" i);
  print_newline ();
  print_endline "Postorder";
  postorder root (fun i -> Printf.printf " %d" i);
  print_newline ()

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

using namespace std;

int main()
{
  int N, A[100001] = {};

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

  int ret = 0;
  for(int i = 1; i < 100000; i++) {
    ret = max(ret, A[i - 1] + A[i] + A[i + 1]);
  }

  cout << ret << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll n;
cin>>n;
ll ans=infll;
for(int i=1;i<=100000;i++){
    if(n%i==0){
        ll a=i;
        ll b=n/a;
        ll f=max(ketasuu(a),ketasuu(b));
        chmin(ans,f);
    }
}
cout<<ans<<endl;
}






Measured memory_bytes: 256
# coding: utf-8

N = int(input())
A = [int(x) for x in input().split()]

count = 0
while True:
	flag = True

	for A_i in A:
		if A_i % 2 != 0:
			flag = False
			break

	if flag == False:
		break

	for index in range(N):
		A[index] = A[index] / 2

	count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;
class DSU {
	private:
		int *data;
	public:
		DSU(int n) {
			data = new int[n];
			for(int i = 0; i < n; i++) {
				data[i] = -1;
			}
		}

		~DSU() {delete[] data;}

		// path compression without recursion
		int find(int i) {
			int parent;
			int back_to = -1;
			for(; (parent = data[i]) >= 0; i = parent) {
				data[i] = back_to;
				back_to = i;
			}
			int root = i;
			while(back_to != -1) {
				i = back_to;
				back_to = data[i];
				data[i] = root;
			}
			return root;
		}

		// union by size
		// returns 0 if union not performed
		// note that 'union' is reserved word
		int merge(int i, int j) {
			int ri = find(i), rj = find(j);
			if (ri == rj)
				return 0;
			if (data[ri] > data[rj]) {
				int t = ri;
				ri = rj;
				rj = t;
			}
			data[ri] += data[rj];
			data[rj] = ri;
			return 1;
		}

		int get_size(int i) {
			return -data[find(i)];
		}
};
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i, m) {
		int ai, bi;
		cin >> ai >> bi;
		a[i] = --ai;
		b[i] = --bi;
	}
	DSU d(n);
	vector<ll> ans(m);
	ll now = (ll)n * (n - 1) / 2;
	for(int i = m - 1; i >= 0; i--) {
		ans[i] = now;
		if (d.find(a[i]) != d.find(b[i])) {
			now -= d.get_size(a[i]) * d.get_size(b[i]);
			d.merge(a[i], b[i]);
		}
	}
	rep(i, m) cout << ans[i] << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
          for(int i=n-2;i>0;i--)
            if(a[i]>a[i+1])
          {

              a[i]--;
              if(a[i]>a[i+1])
              {
                  cout<<"No"<<endl;
                  return 0;
              }


          }
          cout<<"Yes"<<endl;




}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int N;
bool ans = false;

int main(){

  cin >> N;

  for(int i = 0; 4*i <= N; i++){
    int sum = 4*i;
    for(int j = 0; 4 *i + 7*j <= N; j++){
      if(sum == N){
        ans = true;
        break;
      }
      sum += 7;
    }
  }
  if(ans)
    cout << "Yes" << '\n';
  else
    cout << "No" << '\n';
    
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<iostream>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <cstring>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <map>
#include <unordered_map>
#include <vector> 
#include <bitset>
#include <cctype>
#include <set>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>
#include <random>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN = 300005;
const int MAXM = 50005;
const int MOD = 1e9+7;

#define MP make_pair
#define INF 0x3f3f3f3f
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mst(X,Y) memset(X,Y,sizeof(X)) 
#define rep(i, a, n) for (int i=(a); i<=(n); i++)
#define per(i, a, n) for (int i=(a); i>=(n); i--)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) { cerr << " " << to_string(H);    debug_out(T...);}


struct Node{
    int cr;
    int val;
    bool operator< (const Node& x)const 
    {
        return val > x.val;
    }
};
int r[MAXN];
int c[MAXN];
map<pii,int> mp;
int main()
{closeSync;
#ifdef DEBUG
	//freopen("C:/Users/86159/Desktop/a2.in.txt", "r", stdin);
	//freopen("C:/Users/86159/Desktop/output.txt", "w", stdout);
#endif
	//clock_t c1 = clock();
    int h,w,k;
    cin>>h>>w>>k;
    rep (i,1,k)
    {   
        int hh,ww;
        cin>>hh>>ww;
        mp[MP(hh,ww)]++;
        r[hh]++,c[ww]++;
    }
    vector<Node> vr;
    vector<Node> vc;
    rep (i,1,h)
        if (r[i])
            vr.push_back({i,r[i]});
    rep (i,1,w)
        if (c[i])
            vc.push_back({i,c[i]});
    sort(vr.begin(),vr.end());
    sort(vc.begin(),vc.end());
    int endr = vr.size() - 1,endc = vc.size() - 1;
    int tick1 = 1,tick2 = 1;
    while (tick1<=endr && vr[tick1].val == vr[tick1-1].val)
    {
        tick1++;
    }
    while (tick2<=endc && vc[tick2].val == vc[tick2-1].val)
    {
        tick2++;
    }
    int ans = -1;
    //bool flag = false;
    rep (i,0,tick1-1)
    {
        Node cur = vr[i];
        rep (j,0,tick2-1)
        {
            ans = max(ans,   cur.val + vc[j].val - mp[MP(cur.cr,vc[j].cr)]  );
            if (!mp[MP(cur.cr,vc[j].cr)])
                break;
        }
    }
    cout<<ans<<endl;


    //cerr << "Time:" << clock() - c1 << "ms" <<endl;
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define PI 3.141592653589793
#define mod 1000000007

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

int n,z,w;
int a[2005];
int dp[2005][2][2005];
int solve(int node,int chance,int prev)
{
	//trace3(node,chance,prev);
	if(node==n)
	{
		if(prev==-1)
		{
				return abs(w-a[n-1]);
		}
		return abs(a[prev]-a[n-1]);
	}
	if(dp[node][chance][prev+1]!=-1)
		return dp[node][chance][prev+1];
	int ans1 =-1;
	int ans2=1000000009;
	for(int i=node;i<n;i++)
	{
		if(chance==0)
		{
			if(i!=(n-1))
			{
				ans1=max(ans1,solve(i+1,1,i));
			}
			else
				ans1=max(ans1,solve(i+1,1,prev));
			//trace1(ans1);
			//return ans1;
		}
	    else if(chance==1)
	   {
	   	 if(i!=(n-1))
	   	 {
	   	 	ans2=min(ans2,solve(i+1,0,i));
	   	 }
	   	 else
	   	 	ans2=min(ans2,solve(i+1,0,prev));
	   	 //trace1(ans2);
	   	  //return ans2;
	   }
	  
	}
	if(chance==0)
		return dp[node][chance][prev+1]= ans1;
	if(chance==1)
		return dp[node][chance][prev+1]= ans2;
	//trace1(ans);
	//return ans;

}
int main()
{
	IOS;
	cin >>  n >> z >> w;
	memset(dp,-1,sizeof dp);
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		//solve(0,0,-1);
	}
	cout << solve(0,0,-1);
	return 0;
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

string s;

int main(){
	cin >> s;
	int n = s.size();
	int cg = 0, cp = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'g') cg++;
		else cp++;
	}
	
	cout << (cg - cp) / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<utility>
#include<functional>
#include<iomanip>
#include<sstream>
#include<ctime>
#include<cassert>
using namespace std;
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fil(a,b) memset((a),(b),sizeof(a))
#define cl(a) fil(a,0)
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define rep(i,a,b) for (int i=(a),_ed=(b);i<_ed;i++)
#define per(i,a,b) for (int i=(b)-1,_ed=(a);i>=_ed;i--)
#define forg(i,gu) for (int i=gu;~i;i=e[i].next)
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
void getre(){int x=0;printf("%d\n",1/x);}
void gettle(){int res=1;while(1)res<<=1;printf("%d\n",res);}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}
template<typename N,typename PN>inline N flo(N a,PN b){return a>=0?a/b:-((-a-1)/b)-1;}
template<typename N,typename PN>inline N cei(N a,PN b){return a>0?(a-1)/b+1:-(-a/b);}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
template<typename N>inline int sgn(N a){return a>0?1:(a<0?-1:0);}
#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
#define lld "%I64d"
#else
#define lld "%lld"
#endif
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');
	c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
#ifdef JCVB
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
typedef long long ll;
typedef double db;
inline ll sqr(ll a){return a*a;}
inline db sqrf(db a){return a*a;}
const int inf=0x3f3f3f3f;
//const ll inf=0x3f3f3f3f3f3f3f3fll;
const db pi=3.14159265358979323846264338327950288L;
const db eps=1e-6;
//const int mo=0;
//int qp(int a,ll b){int n=1;do{if(b&1)n=1ll*n*a%mo;a=1ll*a*a%mo;}while(b>>=1);return n;}

int n;
ll a[111];
ll s[111];
int main()
{
	gn(n);
	ll b;gn(b);
	rep(i,1,n+1)gn(a[i]);
	sort(a+1,a+1+n);
	rep(i,1,n+1)s[i]=s[i-1]+a[i];
	if(s[n]==b){
		printf("%d\n",n);
		return 0;
	}
	if(b>s[n]) {
		printf("%d\n",n-1);
		return 0;
	}
	per(i,0,n+1)if(b>=s[i]) {
		printf("%d\n",i);
		return 0;
	}




}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll INF = 1e18;
void mainsolve(){

	ll n,c;
	cin >> n >> c;
	vector<vector<ll>> d(c, vector<ll>(c));
	rep(i,c) rep(j,c) cin >> d[i][j];
	vector<vector<ll>> grid(n, vector<ll>(n));
	rep(i,n) rep(j,n) {
		ll tmp;
		cin >> tmp;
		grid[i][j] = --tmp;
	}

	vector<vector<ll>> cost(3,vector<ll>(c));
	rep(i,n) rep(j,n) rep(k,c){
		ll nowc = grid[i][j];
		cost[(i+j)%3][k] += d[nowc][k];
	}

	ll res = INF;
	rep(i,c) rep(j,c) rep(k,c){
		if(i==j || j==k || k==i) continue;

		res = min(res, cost[0][i] + cost[1][j] + cost[2][k]);
	}
	cout << res << endl;

	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int x;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> x;
    if(x >= 30) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3624
def main():
    s = list(input())
    n = len(s)

    ans = 0
    l, r = 0, n-1
    while l < r:
        if s[l] == s[r]:
            l += 1
            r -= 1
        elif s[l] == "x":
            l += 1
            ans += 1
        elif s[r] == "x":
            r -= 1
            ans += 1
        else:
            print(-1)
            exit()
    print(ans)


if __name__ == '__main__':
    main()

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

const long mod = 1000000007;

int main()
{
  long l, r;
  cin >> l >> r;
  long dp[61][2][2][2] = { }; // 上からi桁確定、L<=x確定?、y<=R確定?、桁数同じ?
  dp[0][0][0][0] = 1;
  for (int i = 1; i <= 60; i++) { // 上からi桁確定
    for (int j = 0; j < 2; j++) { // L <= x ?
      for (int k = 0; k < 2; k++) { // y <= R ?
        for (int s = 0; s < 2; s++) { // 桁数同じ?
          for (int x = 0; x < 2; x++) { // xの上からi桁目
            for (int y = 0; y < 2; y++) { // yの上からi桁目
              if (x == 1 && y == 0) continue;
              if (s == 0 && x != y) continue; // 桁数が合わない
              if (j == 0 && (l >> (60 - i)) % 2 == 1 && x == 0) continue; // L > x
              if (k == 0 && (r >> (60 - i)) % 2 == 0 && y == 1) continue; // y > R
              int jnew = j, knew = k, snew = s;
              if ((l >> (60 - i)) % 2 == 0 && x == 1) jnew = 1;
              if ((r >> (60 - i)) % 2 == 1 && y == 0) knew = 1;
              if (x == 1 && y == 1) snew = 1;
              dp[i][jnew][knew][snew] += dp[i - 1][j][k][s];
              dp[i][jnew][knew][snew] %= mod;
            }
          }
        }
      }
    }
  }
  long ans = 0;
  for (int j = 0; j < 2; j++) {
    for (int k = 0; k < 2; k++) {
      for (int s = 0; s < 2; s++) {
        ans = (ans + dp[60][j][k][s]) % mod;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

set<string> st;
int main() {
	int n;
	string s;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 19232
#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <bitset>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;

vector<int> ans(0);

void dfs(vector<vector<int>> &da, int now,vector<bool> &ju){
    int size=da[now].size();
    rip(i,size,0){
        if(ju[da[now][i]]){
            ju[da[now][i]]=false;
            ans.push_back(da[now][i]);
            dfs(da, da[now][i],ju);
            break;
        }
    }
    return;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> da(n,vector<int>(0));
    int a, b;
    rip(i,m,0){
        cin >> a >> b;
        a--;b--;
        da[a].push_back(b);
        da[b].push_back(a);
    }
    ans.push_back(0);
    vector<bool> ju(n,true);
    ju[0]=false;
    dfs(da,0,ju);
    reverse(all(ans));
    dfs(da,0,ju);
    int size=ans.size();
    printf("%d\n",size);
    for(int i=size-1;i>-1;i--){
        if(i==0){
            cout << ans[i] + 1 << endl;
        }
        else{
            cout << ans[i] + 1 << ' ';
        }
    }
}

Measured memory_bytes: 6776
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  int m,n;
  cin>>m>>n;
  string c;
  cin>>c;
  if(c==a){
    m-=1;
  }
  else{
    n-=1;
  }
  cout<<m<<" "<<n<<endl;
 return 0; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

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

  int c = 0;
  int base = (D * 2) + 1;

  cout << (N / base) + (N % base != 0 ? 1 : 0) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    ll ans = 0;
    
    for(int b=K+1; b<=N; b++){
        ans += (b-K)*(N/b);
        ans += max(0, N%b+1-K);
        if(K==0) ans--;
        //printf("%d %d %d\n", b, (b-K)*(N/b), N%b+1-K);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[11][11],t,x;
bool flag[11][11];
int main()
{
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>a[i][j];
		}
	}
	cin>>t;
	while(t--)
	{
		cin>>x;
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(a[i][j]==x) flag[i][j]=1;
			}
		} 	
	}
	if(flag[0][0]&&flag[0][1]&&flag[0][2]||flag[1][0]&&flag[1][1]&&flag[1][2]||flag[2][0]&&flag[2][1]&&flag[2][2]||flag[0][0]&&flag[1][0]&&flag[2][0]||flag[0][1]&&flag[1][1]&&flag[2][1]||flag[0][2]&&flag[1][2]&&flag[2][2]||flag[0][0]&&flag[1][1]&&flag[2][2]||flag[0][2]&&flag[1][1]&&flag[2][0]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main()
{
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)
    cout<<1;
  else if(b==0)
    cout<<2;
  
   else if(c==0)
    cout<<3;
   else if(d==0)
    cout<<4;
  else 
    cout<<5;
  
  return 0;
}

Measured memory_bytes: 3180
n, m = map(int, raw_input().split())
graph = [[] for _ in xrange(n)]
ind = [0 for _ in xrange(n)]
outd = [0 for _ in xrange(n)]
used = [False for _ in xrange(n)]
topo = []
cnt = 0

for i in xrange(m):
    u, v = map(int, raw_input().split())
    ind[v-1] += 1
    outd[u-1] += 1
    graph[u-1].append(v-1)
    
for i in xrange(n):
    if ind[i] == 0 and used[i] == False:
        topo.append(i)
        used[i] = True

while cnt < n:
    u = topo[cnt]
    for v in graph[u]:
        ind[v] -= 1
        if ind[v] == 0 and used[v] == False:
            used[v] = True
            topo.append(v)
    cnt += 1
    
dp = [0 for _ in xrange(n)]
for u in topo:
    for v in graph[u]:
        dp[v] = max(dp[v], dp[u] + 1)
res = max(dp)
print res
    



Measured memory_bytes: 53660