akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	lli A, B;
	cin >> A >> B;
	//cout << (A - B) % 2 <<endl;
	 if ((A - B) % 2 != 0){
cout <<"IMPOSSIBLE"<<endl;
	}else{
cout <<(A+B)/2<<endl;
	} 
}



Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string n; cin >> n;
	int ans = 0;
	bool up = false;
	int cnt5 = 0;
	for(int i=n.size()-1;i>=0;i--){
		int k = 0;
		switch (n[i])
		{
		case '0':
			k = 0;
			break;
		case '1':
			k = 1;
			break;
		case '2':
			k = 2;
			break;
		case '3':
			k = 3;
			break;
		case '4':
			k = 4;
			break;
		case '5':
			k = 5;
			break;
		case '6':
			k = 6;
			break;
		case '7':
			k = 7;
			break;
		case '8':
			k = 8;
			break;
		case '9':
			k = 9;
			break;
		default:
			break;
		}
		if (up) k++;
		up = false;
		if (cnt5 >= 2) {
			k++;
			ans--;
			cnt5 = 0;
		}
		if (k >= 6) {
			if (cnt5>0) {
				k++;
				ans -= cnt5 - 1;
				cnt5 = 0;
			}
			ans += 10 - k;
			up = true;
		}
		else if(k <= 4){
			if (cnt5>0) {
				cnt5 = 0;
			}
			ans += k;
		}
		else {
			cnt5++;
			ans += k;
		}
	}
	if (up) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 1948
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

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

	if (x < t)
		cout << "0\n";
	else
		cout << x - t;

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
// finish date: 2018/06/10
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <functional>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pii pair<int,int>
const int bigmod = 1000000007;
#define INF 1050000000


int main() {
    string S;
    cin >> S;
    int N = S.length();
    if (N != 26) {
        for (char c = 'a'; c <= 'z'; c++) {
            if (S.find(c) == string::npos) {
                cout << S + c << endl;
                return 0;
            }
        }
    }
    for (int i = N - 2; i >= 0; i--) {
        if (S[i] < S[i + 1]) {
            char mi = 'z';
            FOR(j,i+1,N){
                if(S[j] > S[i]){
                    mi = min(mi,S[j]);
                }
            }
            S[i] = mi;
            cout<<S.substr(0,i+1)<<endl;
            return 0;
        }
    }
    cout << -1 << endl;


    return 0;
}






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

//namespace _1_C
//{
class Program
{
    static void Main(string[] args)
    {
        //????????????
        string a = Console.ReadLine();
        //??????????????????
        string[] b = a.Split(' ');
        //??°????????????
        int tate = int.Parse(b[0]);
        int yoko = int.Parse(b[1]);
        Console.WriteLine(tate * yoko +" "+ 2*(yoko + tate));

    }
}

Measured memory_bytes: 9064
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define pli pair<long long , int>
#define pil pair<int ,long long>
#define pi acos(-1)
#define pb push_back
#define mkp make_pair
#define all(a) a.begin(), a.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
using namespace std;


int main(){
    IOS
    //freopen("output.txt","w",stdout);
    double a,b,c;
    cin>>a>>b>>c;
    double o = max(a,max(b,c));
    double h,v;
    if(o==c){
        h=a;
        v=b;
    }
    else if(o==b){
        h=a;
        v=c;
    }
    else if(o==a){
        h=c;
        v=b;
    }
    cout<<(h*v)/2;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define debug cout<<"****************"<<endl
using namespace std;
typedef long long ll;
inline void ju() {
	freopen("***.in","r",stdin);
	freopen("***.out","w",stdout);
}
inline ll rd() {
	ll x=0,f=1; char c=getchar();
	while((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if(c=='-') f=-1,c=getchar();
	while(c>='0'&&c<='9') {
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	return x*f;
}
const int N=1e5+10;
int a[N];
int main() {
	int n=rd(),k=rd(),ans=1e9;
	for(int i=1;i<=n;++i) a[i]=rd();
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k+1;++i) ans=min(ans,min(abs(a[i+k-1])+a[i+k-1]-a[i],abs(a[i])+a[i+k-1]-a[i]));
	printf("%d\n",ans);
}


Measured memory_bytes: 640
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    int s, w;
    scan(s, w);
    if (s <= w) {
        print("unsafe");
    } else {
        print("safe");
    }

    return 0;
}

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

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

  if((A==B) && (C!=A)){
    cout << C << endl;
  }
  else if((A==C) && (A!=B)){
    cout << B << endl;
  }
  else if((B==C) && (A!=B)){
    cout << A << endl;
  }

  return 0;
}



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

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

    int n = s.size();
    int m = 0;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            bool no = false;
            for(int t=i;t<=j;t++) if(!(s[t]=='A'||s[t]=='C'||s[t]=='G'||s[t]=='T')) no = true;
            if(no) break;
            m = max(m, j-i+1);
        }
    }

    cout << m << endl;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)

int main() {
  int r, a = 0;
  cin >> r;
  cout << r * r << endl;
}  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, m, l;
    
    cin >> n >> m >> l;
    int a[m][n];
    int b[l][m];
    long c[l][n];
    
    for(int i=0; i < n; i++){
        for(int j=0; j < m; j++){
            cin >> a[j][i];
        }
    }
    for(int i=0; i < m; i++){
        for(int j=0; j < l; j++){
            cin >> b[j][i];
        }
    }
    for(int i=0; i < n; i++){
        for(int j=0; j < l; j++){
            c[j][i] = 0;
        }
    }
    
    for(int i=0; i < n; i++){
        for(int j=0; j < l; j++){
            for(int k=0; k < m; k++){
                c[j][i] += a[k][i]*b[j][k];   
            }
        }
    }
    
    for(int i=0; i < n; i++){
        for(int j=0; j < l; j++){
            cout << c[j][i];
            if(j != l-1)
                cout << " ";
            else
                cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3228
#include<stdio.h>

int main(){
  int i,j,k,u,n,l;
  int adj[1000];
  int finish[1000][1000];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&adj[j]);
      for(l=0;l<n;l++){
	if(adj[j]==l+1){
	  finish[i][l]=1;
	}/*else{
	  finish[i][l]=0;
	  }*/
      }
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j>0){
	printf(" ");
      }
      printf("%d",finish[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 2948
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int aru[1000005];

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep (i, n) {
		cin >> a[i];
		aru[a[i]]++;
		
	}
	

	int ans = 0;
	rep (j, n) {
		if (aru[a[j]] >= 2) continue;
		vector<ll> tmp = divisor(a[j]);
		int sz = tmp.size();
		bool ok = true;
		rep (i, sz - 1) if (aru[tmp[i]]) ok = false;
		if (ok) ans++; 
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7752
def main
  n, k = gets.chomp.split(' ').map(&:to_i)
  list = gets.chomp.split(' ').map(&:to_i)
  solve(n, k, list)
end

def solve(n, k, list)
  c = 0
  while(n > 1) do
    n = n - k + 1
    c += 1
  end
  puts c
end

main if $0 == __FILE__

Measured memory_bytes: 8708
#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];
  }
  int sum = 0;

for(int k = 0; k < n; k++){
 for(int i = 0; i < n - k -1; i++){
     if(a[i] > a[i + 1]){
         int d;
         d = a[i];
         a[i] = a[i + 1];
         a[i + 1] = d;
     }
}
if(k % 2 == 0){
    sum += a[n-k-1];
}else{
    sum -= a[n-k-1];
}

 }
    cout << sum << endl;
}

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

long long int dp[100010];

int main(){
  dp[0] = 0;
  for(int i = 1; i <= 100000; i++){
    dp[i] = 100000000;
    long long int pow = 1;
    while(pow <= i){
      dp[i] = min(dp[i], dp[i-pow] + 1);
      pow *= 6;
    }
    pow = 1;
    while(pow <= i){
      dp[i] = min(dp[i], dp[i-pow] + 1);
      pow *= 9;
    }
  }
  int N;
  cin >> N;
  cout << dp[N] << endl;
  return 0;
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s;
    cin >> s;

    // 処理
    // 出力
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    vector<int64_t> lucas_number(n+1);
    lucas_number.at(0)= 2LL;
    lucas_number.at(1)= 1LL;
    
    for(int i = 2; i <=n;i++){
        lucas_number.at(i)=lucas_number.at(i-1)+lucas_number.at(i-2);
    }
    cout<<lucas_number.at(n)<<endl;
}
  

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int price[4] = {6000, 4000, 3000, 2000};

int main()
{
    int t, n;
    for (int i = 0; i < 4; i++) {
        cin >> t >> n;
        cout << price[t - 1] * n << endl;
    }

    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=1e5+5;
int n,a[105],b[105],cache[102][N],w;

int dp(int pos,int val)
{
     if(val==0)
          return 0;
     if(val<0)
          return 1e15;
     if(pos==n+1)
          return 1e15;
     
     int &ans=cache[pos][val];
     if(ans!=-1)
          return ans;
          
     return ans=min(dp(pos+1,val),a[pos]+dp(pos+1,val-b[pos]));
}

int32_t main()
{
	IOS;

     memset(cache,-1,sizeof cache);
	cin>>n>>w;
	
	for(int i=1;i<=n;i++)
	     cin>>a[i]>>b[i];
	
	int ans=0;
	
	for(int i=1;i<=1e5;i++)
	{
	     int temp=dp(1,i);
	     if(temp<=w)
	          ans=i;
	}
	cout<<ans;     
	return 0;
}

Measured memory_bytes: 80000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    string s;
    cin >> s;
    ll n=s.size();
    string f =s.substr(0,(n-1)/2);
    string r =s.substr((n+3)/2-1,(n-1)/2);
    string _f =s.substr(0,(n-1)/2);
    string _r =s.substr((n+3)/2-1,(n-1)/2);
    string _s =s;
    reverse(_s.begin(),_s.end());
    reverse(_f.begin(),_f.end());
    reverse(_r.begin(),_r.end());
    if(f == _f &&r==_r&& s==_s){
        cout <<"Yes"<<endl;
    }else{
    cout <<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int D;
	cin >> D;
	if(D == 22){
		cout << "Christmas Eve Eve Eve" << endl;
	} else if(D == 23){
		cout << "Christmas Eve Eve" << endl;
	} else if(D == 24){
		cout << "Christmas Eve" << endl;
	} else{
		cout << "Christmas" << endl;
	}
	return 0;
}

Measured memory_bytes: 888
#dj 16D8101012J ito jun
import sys
def search(a,b):
    na=len(a)
    nb=len(b)
    array = [[0]*(nb+1) for _ in range(na+1)]
    for i,x in enumerate(a,1):
        prerow=array[i-1]
        row=array[i]
        for j,y in enumerate(b,1):
            if x == y:
                row[j]=prerow[j-1]+1
            elif prerow[j] < row[j-1]:
                row[j] = row[j-1]
            else:
                row[j] = prerow[j]
    return array[-1][-1]

n = int(input())
strs = [list(i) for i in sys.stdin.read().splitlines()]
result = [search(strs[i*2], strs[i*2+1]) for i in range(n)]
print(*result, sep="\n")



Measured memory_bytes: 31040
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str1,str2;
    cin>>a>>b>>c;
    while(1){
        if(a%2||b%2||c%2) {cout<<sum<<endl; return 0;}
                if(a==b&&b==c) {cout<<-1<<endl; return 0;}

        sum++;
        d=b/2+c/2;
        m=a/2+c/2;
        n=a/2+b/2;
        a=d;
        b=m;
        c=n;
       // cout<<a<<" "<<b<<" "<<c<<endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<utility>
#include<algorithm>

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 100007
#define P pair<ll,ll>

using namespace std;

int main(){
    int n,ans=0;
    cin>>n;
    const int MAX_N = 100000;
    const ll MAX_V = 1000000000;
    P p[n];
    ll x[n],l[n];
    pan(i,n) cin>>x[i]>>l[i];
    pan(i,n){
        p[i]=P(x[i]+l[i],x[i]-l[i]);
    }
    sort(p,p+n);
    ll c=-MAX_V;
    for (size_t i = 0; i < n; i++)
    {
        if(c<=p[i].second){
            ans++;
            c=p[i].first;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3328
// macro_rules! debug {
//     ($($a:expr),*) => {
//         eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
//     }
// }

fn main() {
    // unimplemented!();
    let input: Vec<i32> = read_vec();
    let n = input[0];
    let r = n % 1000;
    let result = if r == 0 { 0 } else { 1000 - r };
    println!("{}", result);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*左からカウントして初めて見つけたAと、右からカウントして初めて見つけたZ
の間の文字数を出力*/
int main(){
  string s;
  cin >> s;
  int l = 0;
  int r = 0;
  for(int i = 0;i<s.size();i++){
    if(s[i] == 'A'){
      l = i;
      break;
    }
  }
  for(int i = s.size()-1;i>0;i--){
    if(s[i] == 'Z'){
      r = i;
      break;
    }
  }

  cout << r-l +1 << endl;
 }

Measured memory_bytes: 640
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

const int maxn = 800 + 5;
int k, n, m;
int h[maxn][maxn];
string a[maxn];
queue < pll > q;

bool isvl(int x, int y){
    return (x >= 0) and (x < n) and (y >= 0) and (y < m);
}

void dfs(int x0, int y0){
    int aa[4] = {0, 0, 1, -1}, b[4] = {1, -1, 0, 0};
    q.push({x0, y0});
    while(SZ(q)){
        int x = q.front().F, y = q.front().S;
        q.pop();
        for(int i = 0; i < 4; i ++){
            int X = x + aa[i], Y = y + b[i];
            if(isvl(X, Y) and !h[X][Y] and h[x][y] <= k and a[X][Y] == '.'){
                h[X][Y] = h[x][y] + 1;
                q.push({X, Y});
            }
        }

    }
    return;
}

int32_t main(){
    int x, y;
    cin >>n >>m >>k;
    for(int i = 0; i < n; i ++){
        cin >>a[i];
        for(int j = 0; j < m; j ++){
            if(a[i][j] == 'S'){
                x = i;
                y = j;
            }
        }
    }
    int ans = n;
    h[x][y] = 1;
    dfs(x, y);
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < m; j ++){
            if(h[i][j]){
                int z = (min(min(i, n - i - 1), min(j, m - j - 1)) + k - 1)/ k;
                z ++;
                xmin(ans, z);
            }
        }
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {
	static int count;
	static int n;
	static int m;
	static int t[];
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			count=0;
			n=sc.nextInt();
			m=sc.nextInt();
			if(n==0 && m==0) break;
			t=new int[10];
			sum(0,0,0);
			System.out.println(count);
		}
	}
	public static void sum(int i,int k,int s){
		if(i==10){
			if(k==n && s==m){
				count++;
				return;
			}
			return;
		}
		sum(i+1,k,s);
		t[k]=i;
		sum(i+1,k+1,s+i);
	}
}

Measured memory_bytes: 11000
// quote from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

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

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

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

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

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

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

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

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

macro_rules! out {
    ($x:expr) => {
        println!("{}", $x)
    };
}

macro_rules! debug {
    ($x:expr) => {
        println!("{:?}", $x)
    };
}

fn main() {
    input! {
        n: u32,
        s: String,
    }
    let mut s: String = s;
    if n % 2 == 1 {
        out! { "No" }
        return;
    }
    unsafe {
        let v = s.as_mut_vec();
        v.sort();
        let mut ans = v.chunks(2).all(|x| x[0] == x[1]);
        out!(if ans { "Yes" } else { "No" });
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int a, b;
	cin >> a >> b;
	bool ans = false;
	if (a % 3 == 0) ans = true;
	if (b % 3 == 0) ans = true;
	if ((a + b) % 3 == 0) ans = true;
	if (ans) dump("Possible") else dump("Impossible")
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

N=ri()
A=list(rl())
L=[0]*(N+2)
R=[0]*(N+2)
L[0] = A[0]
R[N-1] = A[N-1]
for i in range(1,N):
    L[i] = gcd(L[i-1],A[i])
for i in range(N-2,-1,-1):
    R[i] = gcd(R[i+1],A[i])

ans = 0
for i in range(N):
    ans = max(ans,gcd(L[i-1],R[i+1]))
print(ans)

Measured memory_bytes: 14196
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    H = list(map(int, input().split()))

    for i in range(1, n):
        if H[i - 1] < H[i]:
            H[i] -= 1

    for j in range(1, n):
        if H[j - 1] > H[j]:
            print("No")
            break
    else:
        print("Yes")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 14480
n = int(input())
s = []
ans = 0
a,b,c = 0,0,0
for i in range(n):
    S = input()
    ans += S.count("AB")
    if S[0] == "B" and S[len(S)-1] == "A":
        a += 1
    elif S[0] == "B":
        b += 1
    elif S[len(S)-1] == "A":
        c += 1
    s.append(S)

if a >= 1:
    if b >= 1 and c >= 1:
        ans += a-1+2+min(b-1,c-1)
    elif b >= 1 or c >= 1:
        ans += a
    else:
        ans += a-1
else:
    if b >= 1 and c >= 1:
        ans += min(b,c)
print(ans)


Measured memory_bytes: 3700
fun main(args: Array<String>) {
    val S = readLine()!!

    val odd = listOf('R', 'U', 'D')
    val even = listOf('L', 'U', 'D')

    for (i in S.indices) {
        // 偶数
        if (i % 2 == 0) {
            if (!odd.contains(S[i])) {
                println("No")
                return
            }
        } else {
            if (!even.contains(S[i])) {
                println("No")
                return
            }
        }
    }
    println("Yes")
}

Measured memory_bytes: 35880
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template< typename T >
vector< T > slide_min(const vector< T > &v, int k)
{
	deque< int > deq;
	vector< T > ret;
	for (int i = 0; i < v.size(); i++) {
		while (!deq.empty() && v[deq.back()] >= v[i]) {
			deq.pop_back();
		}
		deq.push_back(i);
		if (i - k + 1 >= 0) {
			ret.emplace_back(v[deq.front()]);
			if (deq.front() == i - k + 1) deq.pop_front();
		}
	}
	return ret;
}

template< typename T >
vector< T > operator-(const vector< T > &v) {
	vector< T > res(v.size());
	for (int i = 0; i < v.size(); i++) res[i] = -v[i];
	return res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	vector<int> P(N);
	for (int i = 0; i < N; i++) {
		int p; cin >> p;
		P[i] = p;
	}

	auto smin = slide_min(P, K);
	auto smax = -slide_min(-P, K);
	DMP(smin, smax);

	int cnt1 = 0;
	for (int i = 0; i < N - K; i++) if (smin[i] == P[i] && smax[i + 1] == P[i + K]) cnt1++;

	int seq = 0, cnt2 = 0;
	for (int i = 0; i < N - 1; i++) {
		if (P[i] < P[i + 1]) seq++;
		else seq = 0;
		if (seq == K - 1) cnt2++;
	}

	DMP(N - K + 1, cnt1, cnt2);
	cout << N - K - cnt1 - max(cnt2 - 2, -1) << "\n";

	return 0;
}

Measured memory_bytes: 4344
#include<bits/stdc++.h>
using namespace std;
int a[100005][4];
int dp[100005][4];
int n;

int func(int ind, int flag) {

	if (ind == n) return 0;

	if (dp[ind][flag] != -1) return dp[ind][flag];

	int maxi = 0;
	if (flag == 0) {
		maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
		maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
		maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
	}
	else if (flag == 1) {
		maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
		maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
	}
	else if (flag == 2) {
		maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
		maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
	}
	else {
		maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
		maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
	}

	return dp[ind][flag] = maxi;
}

int main() {

	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= 3; j++) {
			cin >> a[i][j];
		}
	}

	memset(dp, -1, sizeof dp);

	cout << func(0, 0);

	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N; int ans=999999999;
    int a[N]; rep(i,N) cin >> a[i];
    for(int i=-100; i<=100; i++){
        int pos=0;
        rep(j,N){
            pos+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,pos);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int nums[21]={0};
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>nums[i];
  }
  int ans=0;
  for(int i=1;i<=n-2;i++){
    if(nums[i]<nums[i-1]&&nums[i]<nums[i+1]) continue;
    if(nums[i]>nums[i-1]&&nums[i]>nums[i+1]) continue;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

#define endl "\n"
#define int long long
 
const int N = 2005;
const int MOD = 1e9 + 7;
 
int n, k, ans = 0;
int a[N];
 
int32_t main()
{
	
   
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(a[i] > a[j])
			{
				int cur = k * (k - 1) / 2;
				cur %= MOD;
				ans += cur;
				if(i < j)
					ans += k;
				ans %= MOD;
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
import string

def counterWithDefaultValue(arr, defaultValue):
    dic = Counter(arr)
    for k in dic.keys():
        dic[k] = defaultValue
    return dic

def answer(arr, n):
    _max = 50
    alphabets = [c for c in string.ascii_lowercase]
    dic = Counter(alphabets)
    for i in range(n):
        for a in alphabets:
            if a in arr[i]: dic[a] += 1
    commonAlphabets = []
    for k, v in dic.items():
        if v == (n+1): commonAlphabets.append(k)
    if len(commonAlphabets) == 0: return ''
    dic = counterWithDefaultValue(commonAlphabets, _max)
    for i in range(n):
        _dic = Counter(arr[i])
        for k in dic.keys():
            dic[k] = min(dic[k], _dic[k])
    lexicalSortedKeys = sorted(dic.keys())
    result = []
    for i in range(len(lexicalSortedKeys)):
        k = lexicalSortedKeys[i]
        result = result + ([k] * dic[k])
    return "".join(result)

n = int(input())
arr = []
for _ in range(n):
    s = input().rstrip()
    arr.append([c for c in s])
print(answer(arr, n))

Measured memory_bytes: 40176
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  REP(i,n){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  int ans=1e9;
  for(int i=0;i+k-1<n;i++){
    ans = min(ans,h[i+k-1]-h[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int n,s=0;
  cin >> n;
  vector<int> a(2*n);
  rep(i,2*n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  rep(i,n){
    s+=a[2*i];
  }
  cout << s;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x,y,xi,yi;
  scanf("%d%d",&x,&y);
  
  switch(x){
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12: xi=1; break;
    case 4:
    case 6:
    case 9:
    case 11: xi=2; break;
    case 2: xi=3; break;
  }
  
  switch(y){
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12: yi=1; break;
    case 4:
    case 6:
    case 9:
    case 11: yi=2; break;
    case 2: yi=3; break;
  }
  if(xi==yi) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        long yen0 = 0;
        long stock0 = 0;
        long yen1 = 0;
        long stock1 = 0;

        yen0 = 1000;
        foreach (var a in A)
        {
            long nextYen0 = yen0;
            long nextStock0 = stock0;
            long nextYen1 = yen1;
            long nextStock1 = stock1;

            // 0 買い
            {
                var yen = yen0;
                var stock = stock0;
                stock += yen / a;
                yen %= a;

                if (stock > nextStock1)
                {
                    nextStock1 = stock;
                    nextYen1 = yen;
                }
                else if (stock == nextStock1)
                {
                    nextYen1 = Math.Max(nextYen1, yen);
                }
            }
            // 0 売り
            {
                var yen = yen0;
                var stock = stock0;
                yen += stock * a;
                nextYen0 = Math.Max(nextYen0, yen);
            }
            // 1 買い
            {
                var yen = yen1;
                var stock = stock1;
                stock += yen / a;
                yen %= a;

                if (stock > nextStock1)
                {
                    nextStock1 = stock;
                    nextYen1 = yen;
                }
                else if (stock == nextStock1)
                {
                    nextYen1 = Math.Max(nextYen1, yen);
                }
            }
            // 1 売り
            {
                var yen = yen1;
                var stock = stock1;
                yen += stock * a;
                nextYen0 = Math.Max(nextYen0, yen);
            }

            yen0 = nextYen0;
            yen1 = nextYen1;
            stock0 = nextStock0;
            stock1 = nextStock1;
        }

        Console.WriteLine(yen0);
    }
}

Measured memory_bytes: 28204
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=list(ss())
lens=len(s)
cnt_odd=0
cnt_even=0
for i in range(lens):
    if i%2==0:
        if s[i]=="0":
            cnt_even+=1
        else:
            cnt_odd+=1
    else:
        if s[i]=="0":
            cnt_odd+=1
        else:
            cnt_even+=1
print(min(lens-cnt_even,lens-cnt_odd))

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

import sys


def input():
    return sys.stdin.readline()


def resolve():
    s = input().rstrip()

    ans = 0
    int_list = []
    for bit in range(1<<len(s)-1):

        plus_list = []
        for i in range(len(s)-1):
            #print(bit, i)
            if bit & (1<<i):
                plus_list.append(i)

        #print(plus_list)

        if len(plus_list) == 0:
            int_list.append(s)
        else:
            pre = 0
            temp_list = []
            for i, plus in enumerate(plus_list):
                if i == 0:
                    temp_list.append(s[:plus+1])
                    temp_list.append(s[plus+1:])
                    pre = plus+1
                else:
                    temp_s = temp_list.pop(i)
                    temp_list.append(temp_s[:plus+1-pre])
                    temp_list.append(temp_s[plus+1-pre:])
                    pre = plus+1

            for s2 in temp_list:
                int_list.append(s2)


        #print(bit, i, int_list)


    for num in int_list:
        ans += int(num)




    print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 40688
#include <stdio.h>

#define MAX 100000

typedef struct {
  char name[10];
  int time;
} process;

void enqueue(process);
process dequeue(void);

int head = 0;
int tail = 0;
process Q[MAX];

int main(){
  int i, n, q, total=0;
  process p;

  scanf("%d%d", &n, &q);

  for(i=0; i<n; i++){
    scanf("%s%d", p.name, &p.time);
    enqueue(p);
  }

  while(1){

    if(head == tail){
      break;
    }

    if(Q[head].time > q){
      p = dequeue();
      p.time -= q;
      enqueue(p);
      total += q;
    }else{
      p = dequeue();
      printf("%s %d\n", p.name, p.time + total);
      total += p.time;
    }
  }     

  return 0;
 
}

void enqueue(process p){
  Q[tail] = p;
  if(tail+1 == MAX){
    tail = 0;
  }else{
  tail++;
  }
}

process dequeue(){
  process x;

  x = Q[head];

  if(head+1 == MAX){
    head = 0;
  }else{
    head++;
  }
  return x;
}

Measured memory_bytes: 2160
double a,b,c,d,e,f,g,h;main(){for(;~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f,&g,&h);puts(a>g||e>c||b>h||f>d?"NO":"YES"));exit(0);}

Measured memory_bytes: 612
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; }
    public static void Main()
    {
        int N = NextInt();
        int[,] dp = new int[N + 1, 3];
        dp[0, 0] = dp[0, 1] = dp[0, 2] = 0;
        for (int i = 0; i < N; i++)
        {
            int a = NextInt();
            int b = NextInt();
            int c = NextInt();
            dp[i + 1, 0] = Math.Max(dp[i, 1] + a, dp[i, 2] + a);
            dp[i + 1, 1] = Math.Max(dp[i, 0] + b, dp[i, 2] + b);
            dp[i + 1, 2] = Math.Max(dp[i, 0] + c, dp[i, 1] + c);
        }
        Console.WriteLine(Math.Max(dp[N, 0], Math.Max(dp[N, 1], dp[N, 2])));
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 16320
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    map <int,int>mp;
    int  n,cnt=1;  cin>>n;
    mp[n]++;
    while (true){
        cnt++;
        if (n&1) n = 3 * n + 1 ; 
        else n /= 2 ; 
        mp[n]++;
        if (mp[n]==2 and !(n&(n-1))) break;
    }
    cout << cnt << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3608
N, W = map(int, input().split())
p = []
for it in range(N):
    p.append(list(map(int,input().split())))
    
dp = [[0 for i in range(W+1)] for j in range(N+1)]
i = 0
for w, v in p:
    i += 1
    for w_limit in range(1, W+1):
        if w_limit < w:
            dp[i][w_limit]=dp[i-1][w_limit]
            continue
        if (dp[i-1][w_limit-w] + v) > dp[i-1][w_limit]:
            dp[i][w_limit] = dp[i-1][w_limit-w] + v
        else:
            dp[i][w_limit]=dp[i-1][w_limit]
print(max(max(dp)))

Measured memory_bytes: 171656
#include <iostream>

using namespace std;

int n;
int k;
int q;

int main () {
    cin >> n >> k >> q;
    int players[n] = {0};
    for(int i = 0; i < n; i++){
        players[i] = k - q;
    }
    int x;
    for(int i = 0; i < q; i++){
        cin >> x;
        players[x - 1]++;
    }

    for(int i = 0; i < n; i++){
        if(players[i] <= 0){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }

    return 0;
    
}

Measured memory_bytes: 1024
scores = Array.new(2, 0)
gets.to_i.times do
  taro, hanako = gets.chomp.split(' ')
  if taro == hanako
    scores.map! {|s| s += 1}
  elsif taro > hanako
    scores[0] += 3
  else
    scores[1] += 3
  end
end
puts scores.join(' ')


Measured memory_bytes: 6860
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int h = Integer.parseInt(sc.next());
    int n = Integer.parseInt(sc.next());
    long total = 0;
    for (int i = 0; i < n; i++) {
      total += Integer.parseInt(sc.next());
      if (total >= h) {
        pw.println("Yes");
        return;
      }
    }
    pw.println("No");
  }
}


Measured memory_bytes: 48152
#include <stdio.h>

int main(){
   int i, n, a, b, c;
   scanf("%d %d %d",&a,&b,&c);
   for(i=a,n=0;i<=b;i++){
      if(c%i==0) ++n;
   }
   printf("%d\n",n);
   return 0;
}

Measured memory_bytes: 596