akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


struct edge{ ll to,cost; };
ll V;
vector<edge> G[500010];
ll d[500010];

void dijkstra(ll s){
    fill(d,d+500010,inf);
    d[s]=0;
    priority_queue<l_l,vector<l_l>,greater<l_l>> que;
    que.push(l_l(0,s));
    while(!que.empty()){
        l_l p=que.top();que.pop();
        ll v=p.second;
        if(d[v]<p.first)continue;
        if(G[v].size()>0){
            rep(i,0,G[v].size()-1){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(l_l(d[e.to],e.to));
                }
            }
        }
    }
}


int main(){fastio
    ll n,C;cin>>n>>C;
    ll d[1+C][1+C];
    rep(i,1,C)rep(j,1,C)cin>>d[i][j];
    ll c[n][n];rep(i,0,n-1)rep(j,0,n-1)cin>>c[i][j];
    ll sum[3][C+1];rep(i,0,2)rep(j,0,C)sum[i][j]=0;
    rep(i,0,n-1)rep(j,0,n-1){
        rep(k,1,C){
            sum[(i+j)%3][k]+=d[c[i][j]][k];
        }
    }
    ll ans=inf;
    rep(i,1,C){
        rep(j,1,C){
            if(i==j)continue;
            rep(k,1,C){
                if(j==k || k==i){
                    continue;
                }
                ans=min(ans,sum[0][i]+sum[1][j]+sum[2][k]);
            }
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int N;
int main()
{
    int g = 0;
    cin >> N;
    for(int i=0; i<N; ++i)
    {
        int t; cin >> t;
        g = __gcd(g, t);
    }
    cout << __builtin_ctz(g&(-g)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const int N=100005;
int v[3],p[N],q[N];
int main(){
    int n;cin >> n;
    string s;
    for(int i=0;i<3;i++)cin >> v[i];
    for(int i=1;i<=n;i++){
        cin >> s;
        p[i]=s[0]-'A';
        q[i]=s[1]-'A';
    }
    for(int i=1;i<=n;i++){
        if(v[p[i]]>v[q[i]])swap(p[i],q[i]);
        else if(v[p[i]]==v[q[i]])
            if(i<n&&(q[i]==q[i+1]||q[i]==p[i+1]))swap(p[i],q[i]);
        if(!v[q[i]])return 0*printf("No\n");
        v[p[i]]++,v[q[i]]--;
    }
    puts("Yes");
    for(int i=1;i<=n;i++) printf("%c\n",'A'+p[i]);
    return 0;
}

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

using namespace std;

int main(){
    int a,b,moke;
    string op;
    while (1) {

      cin >> a >> op >> b;

    if(op == "+")moke=a+b;
    if(op == "-")moke=a-b;
    if(op == "*")moke=a*b;
    if(op == "/")moke=a/b;
    if(op == "?")break;
    cout << moke << endl;

    }

    return 0;
}

Measured memory_bytes: 3116
def main():
    a = list(map(int, input().split()))

    total = a[0]*a[1]

    count = 0
    for i in range(a[0]):
        for j in range(a[1]):
            if ((j+1)%10) >= 2 and ((1+j)//10) >= 2: 
                if (i+1) == ((j+1)%10)*((j+1)//10):
                    count += 1

    print(count)




if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include <utility>
#include <tuple>
#include <climits>
using namespace std;
using Int = long long;

int main()
{
    int M;
    cin >> M;
    cout << 48 - M << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
char x[10];
int main() {
    while(scanf("%s", x) != EOF) {
        for(int i=0; i<9; i++) {
            for(int j=0; j<9-i; j++) {
                x[j] = (x[j] + x[j+1] - 96) % 10 + 48;
            }
        }
        printf("%d\n", x[0]-48);
    }
}



Measured memory_bytes: 2052
N,M,X =map(int,input().split())
min_money = 10**9
books =[None]*N
for i in range(N):
    books[i] = list(map(int,input().split()))

for i in range(1<<N):
    output = []
    for j in range(N):
        if ((i>>j) & 1) == 1:
            output.append(1)
        else:
            output.append(0)

    money = 0
    gakusyuu = [0]*M
    for k in range(N):
        if output[k] == 1:
            money+=books[k][0]
            for l in range(1,M+1):
                gakusyuu[l-1]+=books[k][l]

    for i in range(len(gakusyuu)):
        if gakusyuu[i] < X:
            break
    else:
        if min_money>money:
            min_money = money

if min_money == 10**9:
    print(-1)
else:
    print(min_money)


Measured memory_bytes: 9240
import java.util.Scanner;

public class Main{

	Scanner sc = new Scanner(System.in);
	String a;

	void run() {
		a = sc.next();
		int cnt = 0;
		int A, B;

		for (int i = 0; i < a.length(); i++) {

			if (i != 0) {
				A = Integer.valueOf(a.substring(0, i));
			} else {
				A = 0;
			}
			B = Integer.valueOf(a.substring(i, a.length()));
			if (check(A, B)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

	boolean check(int A, int B) {
		boolean judge = false;
		int x, y, res;

		if ((A + B) % 2 == 0 && (A - B) % 2 == 0) {
			x = (A + B) / 2;
			y = -(A - B) / 2;
			A = x - y;
			B = x + y;
			res = Integer.valueOf(A + "" + B);
			if (res == Integer.valueOf(a) && x >= 0 && y >= 0) {
				judge = true;
			}
		}
		return judge;
	}

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

Measured memory_bytes: 17324
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int[] s, c;
    int n, t, i, j;

    for(;;){
      n = sc.nextInt(); if(n == 0)break;
      s = new int[n]; c = new int[n];
      for(i = 0;i < n;i++)s[i] = sc.nextInt();
      for(t = 0;;t++){
        for(i = 0;i < n;i++)c[i] = 0;
        for(i = 0;i < n;i++)for(j = 0;j < n;j++)if(s[i] == s[j])c[i]++;
        for(i = 0;i < n;i++)if(s[i] != c[i])break;
        if(i == n)break;
        for(i = 0;i < n;i++)s[i] = c[i];
      }
      out.println(t);
      for(i = 0;i < n - 1;i++)out.print(s[i] + " ");
      out.println(s[i]);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 25252
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

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

int main()
{
    int x,y,flag=0;
    cin>>x>>y;
    int min=x*2;
    int max=x*4;
    if(y%2==0){
        if(y>=min && y<=max){
            flag=1;
        }
    }
    if(flag==1){
        cout<<"Yes"<<endl;
    }
    else if(flag==0){
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    deque<int> res;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        if(i % 2 == 0)  res.push_front(a);
        else    res.push_back(a);
    }
    if(n % 2 == 0){
        while(!res.empty()){
            int output = res.back();
            res.pop_back();
            cout << output << " ";
        }
    }
    else{
        while(!res.empty()){
            int output = res.front();
            res.pop_front();
            cout << output << " ";
        }
    }
    cout << "\n";
}

Measured memory_bytes: 3072
#include<iostream>
using namespace std;
int main(){
    int eyep[2][4]={0};
    double eye[2];
    while(cin>>eye[0]>>eye[1]){
        for(int i=0;i<2;i++){
            if(eye[i]>=1.1)eyep[i][0]++;
            else if(eye[i]>=0.6)eyep[i][1]++;
            else if(eye[i]>=0.2)eyep[i][2]++;
            else eyep[i][3]++;
        }

    }
    for(int i=0;i<4;i++){
        cout<<eyep[0][i]<<" "<<eyep[1][i]<<endl;
    }
}

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


void solve() {
  char ch[4+1];
  scanf("%s", &ch);
  sort(ch, ch+4);
  if (ch[0]==ch[1]&&ch[1]!=ch[2]&&ch[2]==ch[3]) {
    std::cout << "Yes" << '\n';
  } else {
    std::cout << "No" << '\n';
  }
}

int main() {
  solve();
  return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main() {
  int N,H,W;
  while( cin >> N >> H >> W ) {
    vector<int> vec(W*N,0);
    rep(i,N) {
      int x;
      cin >> x;
      if( i & 1 ) x = -x;
      int sp = i * W + x;
      REP(j,sp,sp+W) vec[j] = 1;
    }
    int cnt = 0;
    rep(i,W*N) cnt += (!vec[i]);
    cout << cnt * H << endl;
  }
  return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <iterator>
using namespace std;

namespace {

}

int main()
{
	int N;

	cin >> N;
	
	int sq = sqrt(N); // 切り捨て

	int sq2 = sq + 1;

	if (sq2 * sq2 <= N){
		cout << sq2 * sq2 << endl;
		return 0;
	}

	cout << sq * sq << endl;

	return 0;
}

Measured memory_bytes: 3680
// uno {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}

int a,b,c;
void input() {
    RI(a,b,c);
}

void solve() {
    if(a+b+c<22)
        printf("win\n");
    else
        printf("bust\n");
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int a, b, c;
    cin >> a >> b >> c;
    bool f = false;
    if (a <= c && c <= b)
        f = true;
    if (b <= c && c <= a)
        f = true;
    cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

D = sorted(D)
T = sorted(T)


i = len(D)-1
j = len(T)-1

flag = True
while(0<=i and 0<=j):
    if D[i] > T[j]:
        i -= 1
    elif D[i] == T[j]:
        i -= 1
        j -= 1
    else:
        flag = False
        break
        
if flag == False or (i<=-1 and j>-1):
    print("NO")
else:
    print("YES")

Measured memory_bytes: 34768
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << 0 << endl << flush;
  string s0;
  cin >> s0;
  if (s0 == "Vacant") return 0;
  int l = 1, r = n;
  while (true) {
    int mid = (l+r)/2;
    cout << mid << endl << flush;
    string s;
    cin >> s;
    if (s == "Vacant") return 0;
    if (mid%2 && s != s0 || !(mid%2) && s == s0)
      l = mid+1;
    else
      r = mid;
  }
  return 0;
}

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

const int N = 2e5+5 ;
char s1[ N ] , s2[ N ] ;
int a[ N ] , b[ N ] ;

int main() {
	scanf( "%s %s" , s1 , s2 ) ;
	int len1 = strlen( s1 + 1  ) , len2 = strlen( s2 + 1 ) ;
	if( len1 != len2 ) return puts( "No" ) , 0 ; 
	for( int i = 1 ; i <= len1 ; i ++ ) {
		if( !a[ s1[ i ] - 'a' ] && !b[ s2[ i ] - 'a' ] ) {
			a[ s1[ i ] - 'a' ] = s2[ i ] - 'a' ;
			b[ s2[ i ] - 'a' ] = s1[ i ] - 'a' ;
		}else if( a[ s1[ i ] - 'a' ] == s2[ i ] - 'a' && b[ s2[ i ] - 'a' ] == s1[ i ] - 'a' ) continue ;
		else if( a[ s1[ i ] - 'a' ] != s2[ i ] - 'a' || b[ s2[ i ] - 'a' ] != s1[ i ] - 'a' ) return puts("No"),0 ; 
	}
	return puts("Yes") , 0 ;
}


Measured memory_bytes: 640
#include <stdio.h>
int main()
{
	int num[3010][2],i;
	for(i=0;i<3010;i++)
	{
		for(int j=0;j<2;j++)
		scanf("%d",&num[i][j]);
		if(num[i][0]==0&&num[i][1]==0)
		break;
	}
	for(int j=0;j<i;j++)
	{
		if(num[j][0]<num[j][1])
		printf("%d %d\n",num[j][0],num[j][1]);
		else
		printf("%d %d\n",num[j][1],num[j][0]);
	}
	return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
ll arr[305][305];
bool avoid[305][305];
int main()
{
    int n,i,j,k,f=1;
    sd(n);
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)slld(arr[i][j]);
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)for(k=1;k<=n;k++){
        if((arr[i][k]+arr[k][j])<arr[i][j]){
            f=0;
            break;
        }
        if(k!=i && k!=j)if(arr[i][k]+arr[k][j]==arr[i][j])avoid[i][j]=true;
    }
    if(f==0){
        pdn(-1);
        return 0;
    }
    ll answer=0;
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)if(!avoid[i][j])answer+=arr[i][j];
    answer/=2;
    plldn(answer);
    return 0;
}

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

int main()
{
    int n, k, tmp, ans = 0;
    cin >> n >> k;
    vector<int> a(n + 1, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        a[tmp]++;
    }
    sort(a.begin(), a.end());
    auto itr = upper_bound(a.begin(), a.end(), 0);
    int size = (int)(a.end() - itr);
    while (size > k)
    {
        ans += *itr;
        size--;
        itr++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    
    string str;
    str = to_string(n);
    
    for(int i=0; i<3; ++i){
        if(str.at(i)=='9') str.at(i)='1';
        else if(str.at(i)=='1') str.at(i)='9';
        else continue;
    }
    
    cout << str << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a, b, c, k;
  int count = 0;
  
  scanf("%d%d%d%d", &a, &b, &c, &k);
  
  while (a > 0 && k > 0) {
      a--;
      k--;
      count++;
  }
  
  while (b > 0 && k > 0) {
      b--;
      k--;
  }
  
  while (c > 0 && k > 0) {
      c--;
      k--;
      count--;
  }
  
  printf("%d", count);
  return 0;
}
        

Measured memory_bytes: 1696
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;
use std::str::FromStr;

type Error = Box<dyn std::error::Error>;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

struct Scanner {
    buff: Vec<String>,
    pos: usize,
}


impl Scanner {
    pub fn new() -> Self {
        Scanner {
            buff: Vec::new(),
            pos: 0,
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T {
        while self.buff.len() <= self.pos {
            self.pos = 0;
            self.buff = read_line().split_whitespace().map(|s| s.to_owned()).collect();
        }

        let result = self.buff[self.pos].parse::<T>();
        self.pos += 1;
        result.ok().unwrap()
    }

    pub fn next_line(&mut self) -> String {
        let result  = read_line().trim().to_owned();
        self.buff.clear();
        self.pos = 0;

        result
    }

    pub fn next_vec<T: FromStr>(&mut self) -> Vec<T> {
        self.buff.clear();
        self.pos = 0;
        read_line().trim().split_whitespace().map(|s| s.parse().ok().unwrap()).collect()
    }
    
    pub fn next_line_chars(&mut self) -> Vec<char> {
        let result  = read_line().trim().chars().collect();
        self.buff.clear();
        self.pos = 0;

        result
    }
}


fn main() {
    let mut scan = Scanner::new();
    let n: usize = scan.next();
    let m: usize = scan.next();
    let q: usize = scan.next();
    let mut memo = vec![vec![0; n]; n];
    for i in 0..m {
        let l:usize = scan.next::<usize>() - 1;
        let r:usize = scan.next::<usize>() - 1;

        memo[l][r] += 1;
    }

    let mut memo2 = vec![vec![0; n]; n];
    for i in 0..n {
        memo2[i][i] = memo[i][i];
    }
    for k in 1..n {
        for i in 0..n-k {
            memo2[i][i+k] = memo[i][i+k] + memo2[i][i+k-1] + memo2[i+1][i+k] - memo2[i+1][i+k-1];
        }
    }

    for i in 0..q {
        let p: usize = scan.next();
        let q: usize = scan.next();

        println!("{}", memo2[p - 1][q-1]);

    }
}

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

using namespace std;

#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define INF 0x3f3f3f3f
#define f1(n) for(int i=0 ; i<n ; i++)
#define f2(m) for(int j=0 ; j<m ; j++)
#define ll long long
typedef pair<int, int> iPair;
const double epsilon = 1e-7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, t;
  cin >> s >> t;
  int count = 0;
  int n = s.size();
  for (int i=0; i<n; ++i)
    count += s[i] != t[i];
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a=0,b=0,c=0,d=0,e=0,n=0,m=0,ans = 0;
  string s,ss,sss;
  cin>>a>>b>>m;
  vi A(a),B(b);
  ll ami = llINF,bmi = llINF;
  for(auto &aa:A){cin>>aa;ami = min(ami,aa);}
  for(auto &aa:B){cin>>aa;bmi = min(bmi,aa);}
  ans = ami+bmi;
  for(int i=0;i<m;i++){
    ll x,y,z;
    cin>>x>>y>>z;
    ans = min(ans,A[x-1]+B[y-1]-z);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pii pair<int,int>
 
int32_t main(){
    int n,a,b;
    cin>>n>>a>>b;
    
    int cnt=0;
    int x=n/(a+b);
    cnt+=x*a;
    int p=n%(a+b);
    if(p>a) cnt+=a;
    else cnt+=p;
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int X;

    scanf("%d", &X);

    int max = 1;

    for(int i = 2; i <= (int)sqrt(X); i++){
        int t = i;
        while(1){
            if(t * i > X){
                break;
            }else{
                t *= i;
            }
        }
        if(t > max){
            max = t;
        }
    }

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

    return 0;
}

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N;
  cin >> N;
  
  if(N%2 != 0){
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;

  int i = 10;
  while(i <= N){
    ans += N/i;
    i *= 5;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

vector<int> a, b;

vector<int> opt1;
vector<int> opt2;

void solve()
{
    int n, h;
    cin >> n >> h;
    
    for(int i = 0; i < n; i++)
    {
        int ai, bi;
        cin >> ai >> bi;
        a.pb(ai);
        b.pb(bi);
    }
    
    int ind_max = 0;
    for(int i = 0; i < n; i++)
    {
        if(a[i] > a[ind_max])
        {
            ind_max = i;
        }
    }
    
    for(int i = 0; i < n; i++)
    {
        if(ind_max == i || b[i] >= a[ind_max])
        {
            opt1.pb(b[i]);
            if(ind_max != i)
            {
                opt2.pb(b[i]);
            }
        }
    }
    
    sort(opt1.begin(), opt1.end());
    
    int ans = h / a[ind_max] + (h % a[ind_max] != 0);
    
    int T = h;
    int cnt = 0;
    for(int i = (int) opt1.size() - 1; i >= 0; i--)
    {
        T -= opt1[i];
        cnt++;
        if(T <= 0)
        {
            ans = min(ans, cnt);
            break;
        }
    }
    
    sort(opt2.begin(), opt2.end());
    
    T = h;
    cnt = 0;
    for(int i = (int) opt2.size() - 1; i >= 0; i--)
    {
        T -= opt2[i];
        cnt++;
        if(T <= 0)
        {
            ans = min(ans, cnt);
            break;
        }
    }
    
    while(T > 0)
    {
        cnt++;
        if(T - b[ind_max] <= 0)
        {
            T -= b[ind_max];
        }
        else
        {
            T -= a[ind_max];
        }
    }
    
    ans = min(ans, cnt);
    
    cout << ans;
    
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 2292
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main() {
	int H, W;
	cin >> H >> W;
	string S[50];
	rep(i, H) cin >> S[i];

	rep(i, H) {
		rep(j, W) {
			if (S[i][j] == '#') continue;
			int mine = 0;
			for (int dx = 1;dx >= -1;dx--) {
				for (int dy = 1;dy >= -1;dy--) {
					int nx = i + dx;
					int ny = j + dy;
					if (0 <= nx && nx < H && 0 <= ny && ny < W&&S[nx][ny] == '#') mine++;
				}
			}
			S[i][j] = char(mine + '0');
		}
	}
	rep(i, H) cout << S[i]<<endl;
}

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

int main(){
  string a, b, c;
  cin >> a >> b >> c;

  string initial = a.substr(0,1) + b.substr(0,1) + c.substr(0,1);

  for (int i = 0; i < initial.size(); i++){
    if (islower(initial.at(i))){
      initial.at(i) = toupper(initial.at(i));
    }
  }

  cout << initial << endl;

}

Measured memory_bytes: 3612
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;


int main()   {


    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    auto start = chrono::steady_clock::now()

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readstring(s);
        int ss = 0;
        for(char c : s) {
            ss += (c-'0');
        }
        cout << ((ss%9==0) ? "Yes" : "No") << endl;
    }

//    auto end = chrono::steady_clock::now();
//    cerr << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

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

int n,mod=2019,ans=0,pos=1;
int a[200005],suf[200005],visited[200005];

signed main()
{
	string s;
	cin>>s;
	n=s.size();
	for (int i=1;i<=n;i++)  a[i]=s[i-1]-'0';
	for (int i=n;i>=1;i--)
	{
		suf[i]=(suf[i+1]+a[i]*pos)%mod;
		pos=(pos*10)%mod;
	}
	visited[0]++;
	for (int i=1;i<=n;i++)  visited[suf[i]]++;
	for (int i=0;i<=2018;i++)
	{
		int x=visited[i];
		if (x==0||x==1)  continue;
		else ans+=(x*x-x)/2;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 6864
#include <stdio.h>
int main()
{
    int a,b,c,d,e,f;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    e=a+b;
    f=c+d;
    if(e>f)
    {
        printf("Left");
    }
    else if (e==f)
    {
        printf("Balanced");
    }
    else if(e<f)
    {
        printf("Right");
    }
}


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

int main() {
    int x, y;
    scanf("%d%d", &x, &y);
    int ans = x > y ? x : y;
    if (x > y) x--;
    else y--;
    if (x > y) ans += x;
    else ans += y;
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
	int a,b,tambah=0,kurang=0,kali=0;
	scanf("%d %d",&a,&b);
	tambah = a+b;
	kurang = a-b;
	kali = a*b;
	if(tambah >= kurang && tambah >= kali){
		printf("%d",tambah);
	}
	else if(kurang >= tambah && kurang >= kali){
		printf("%d",kurang);
	}
	else if(kali >= tambah && kali >= kurang){
		printf("%d",kali);
	}
	else if(tambah == kurang && tambah == kali){
		printf("%d",tambah);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n, q;
	cin >> n >> q;

	vector<long long> tree(n, 0);

	vector<pair<int, int>> a(n - 1);
	rep(i, n - 1)
	{
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end());
	vector<int> p(q), x(q);
	rep(i, q)
	{
		cin >> p[i] >> x[i];
		tree[p[i]] += x[i];
	}

	for (int i = 0; i < n - 1; i++)
	{
		tree[a[i].second] += tree[a[i].first];
	}
	cout << tree[1];
	for (int i = 2; i <= n; i++)
	{
		cout << " " << tree[i];
	}
	cout << endl;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,ans;
int main () {
	ans=1e18;
	scanf("%lld",&n);
	for (ll i=1;i*i<=n;i++) {
		if (n%i==0) {
			ans=min(ans,i+n/i-2);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    
    ll totalSum = 0;
    for(int tmp = 0; tmp < (1 << (S.length() - 1)); tmp++){
        bitset<9> s(tmp);
        string sum = {S.at(0)};
        for(int i = 0; i < (S.length() - 1); i++){
            if(s.test(i)){
                sum.push_back('+');
            }
            sum.push_back(S.at(i + 1));
        }
        
        string tmp1 = "";
        for(int i = 0; i < sum.length(); i++){
            if(sum.at(i) == '+'){
                ll num = stoll(tmp1);
                totalSum += num;
                tmp1 = "";
            }else{
                tmp1.push_back(sum.at(i));
            }
        }
        ll num = stoll(tmp1);
        totalSum += num;
    }
    cout << totalSum << endl;
}




Measured memory_bytes: 256
N, A, B = map(int, input().split())
X = list(map(int, input().split()))

diff = [X[i + 1] - X[i] for i in range(len(X) - 1)]

fatigue = 0
for i in diff:
    if i * A < B:
        fatigue += i * A
    else:
        fatigue += B

print(fatigue)


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

int main() {
	string s;
	cin >> s;
	rep(i, s.size())cout << 'x';
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int>v;
int main()
{
	cin>>n;
	n*=2;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(i%2==0)
		{
			ans+=v[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define int long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
struct Basis
{
	int t[64];
	void clear(){memset(t,0,sizeof(t));}
	bool insert(int u)
	{
		for(int i=60;i>=0;i--)
		{
			if(u&(1LL<<i))
			{
				if(!t[i]) {t[i]=u; return 1;}
				u^=t[i];
			}
		}
		return 0;
	}
}b;
#define N 205
int a[N];
char s[N];
void work()
{
	int n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	scanf("%s",s+1);
	b.clear();
	for(int i=n;i>=1;i--)
	{
		if(b.insert(a[i])&&s[i]=='1')
		{
			cout<<1<<endl;
			return ;
		}
	}
	cout<<"0\n";
}
signed main()
{
	int T=read(); while(T--) work();
	return 0;
}




Measured memory_bytes: 3700
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int n;
int a[55];
int b[55];

bool vis[55];

long long ans;

bool dfs(int u,int T,int lim)
{
	if (u == T)
		return 1;
	if (vis[u])
		return 0;
	vis[u] = 1;
	for (int i = 1;i <= 50;i++)
		if (i < lim || (i > lim && (ans >> i & 1)))
			if (dfs(u % i,T,lim))
				return 1;
	return 0;
}

int main()
{
	cin >> n;
	for (int i = 1;i <= n;i++)
		cin >> a[i];
	for (int i = 1;i <= n;i++)
		cin >> b[i];
	for (int i = 50;i >= 1;i--)
	{
		bool ok = 1;
		for (int j = 1;j <= n;j++)
		{
			memset(vis,0,sizeof(vis));
			if (!dfs(a[j],b[j],i))
			{
				ok = 0;
				break;
			}
		}
		if (!ok)
			ans += (1ll << i);
	}
	for (int i = 1;i <= n;i++)
	{
		memset(vis,0,sizeof(vis));
		if (!dfs(a[i],b[i],0))
		{
			puts("-1");
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
board = [[0] * (N + 1) for _ in range(max(h))]
for i in range(N):
    for j in range(h[i]):
        board[j][i + 1] = 1
print(sum(row[i] == 0 and row[i + 1] == 1 for row in board for i in range(N)))


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

struct node {
  vector<int> cnt, to;
  node() : cnt(26, 0), to(26, -1) {}
};

struct quer {
  int id;
  string c;
};

int n, q;
vector<string> s;
vector<vector<quer>> queries;
vector<int> res;
vector<node> trie;

void solve();
void add(string &t);

int main() {
  cin >> n;
  s.resize(n);
  for (auto &p : s) cin >> p;
  cin >> q;
  res.assign(q, n);
  queries.resize(n);
  for (int i = 0; i < q; ++i) {
    int k;
    string t;
    cin >> k >> t;
    queries[--k].push_back({i, t});
  }
  solve();
  for (auto p : res) cout << p << endl;
  return 0;
}

void solve() {
  trie.push_back(node());
  for (auto &t : s) add(t);
  for (int i = 0; i < n; ++i) {
    auto t = s[i];
    int len = t.size(), now = 0;
    vector<vector<int>> memo(26, vector<int>(26, 0));
    for (int j = 0; j < len; ++j) {
      int c = t[j] - 'a';
      for (int k = 0; k < 26; ++k) memo[c][k] += trie[now].cnt[k];
      if (j == len - 1)
        for (auto p : queries[i]) res[p.id] -= trie[now].cnt[c] - 1;
      now = trie[now].to[c];
    }
    for (auto p : queries[i])
      for (int j = 0; j < 26; ++j)
        for (int k = j + 1; k < 26; ++k)
          res[p.id] -= memo[p.c[j] - 'a'][p.c[k] - 'a'];
  }
}

void add(string &t) {
  int len = t.size(), now = 0;
  for (int i = 0; i < len; ++i) {
    int to = t[i] - 'a';
    auto nod = &trie[now];
    if (nod->to[to] < 0) {
      nod->to[to] = trie.size();
      trie.push_back(node());
    }
    ++trie[now].cnt[to];
    now = trie[now].to[to];
  }
}

Measured memory_bytes: 119868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;

int main(){
  string S;cin>>S;
  int N=S.size();
  ll dp[N+1][4];

  for (int i=N;i>=0;--i){
    for (int j=3;j>=0;--j){
      if(i==N){(dp[i][j]=(j==3? 1:0));}else{
        dp[i][j]=dp[i+1][j]*(S[i]=='?' ? 3LL:1LL);
        if((j<3)&&(S[i]=='?'|| S[i]=="ABC"[j])){
          dp[i][j]+=dp[i+1][j+1];
        }
      }
      dp[i][j]%=MOD;
    }
  }

  cout << dp[0][0] << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int gcd(int p,int q){
    if(p%q==0)return q;
    return gcd(q,p%q);
}

int main(){
    int K;
    int sum=0;
    int a=1;int b=1;int c=1;
    cin>>K;
    for(int i=0;i<K;i++){
        for(int j=0;j<K;j++){
            for(int k=0;k<K;k++){
        sum+=gcd(a+i,gcd(b+j,c+k));
            }
        }
    }
    cout<<sum;
return 0;
}

Measured memory_bytes: 3116
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

string S;
int N;
int abl[100001]; //-1:不可　0：未定　１：可能

void bs(int a, int b){
  int p = (a + b) / 2;
  if(abl[p]!=0) return;
  //K = pでできるか検査
  int s = N - p;
  int t = p - 1;
  bool is_same = true;
  for(int i=s;i<t;i++){
    if(S[i]!=S[i+1]) is_same = false;
  }
  if(is_same){
    abl[p] = 1;
    bs(p+1,b);
  }
  else{
    abl[p] = -1;
    bs(a,p-1);
  }
  return;
}

int main(){
  cin >> S;
  N = S.size();
  fill(abl,abl+100001,0);

  bs(0,N);

  if(abl[N]==1){
    cout << N << endl;
    return 0;
  }

  for(int i=0;i<N;i++){
    if(abl[i] == 1 && abl[i+1] == -1){
      cout << i << endl;
    }
  }

  /*for(int i=0;i<=N;i++){
    cout << i << " " << abl[i] << endl;
  }*/

  return 0;
}

Measured memory_bytes: 896
/*AOJ 0016*/

#include<iostream>
#include<math.h>

#define M_PI 3.14159265

using namespace std;

double changeDegToRad(double deg){

	return deg*M_PI/180.0;

}

int main(){

	double x = 0,y = 0;
	double deg = 0,walk = 0;
	double rad = M_PI/2.0;
	while(1){
		scanf("%lf,%lf",&walk,&deg);


		if(deg==0&&walk==0){
			break;
		}

		x += walk * cos(rad);
		y += walk * sin(rad);

		rad -= changeDegToRad(deg);

	}

	cout<<(int)x<<endl;
	cout<<(int)y<<endl;
	return 0;
}

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

int main() {
  string S;
  cin>>S;
  int s;
  s=S.size();
  int ans;
  ans=0;
    for(int i=0;i<s/2;i++){
      if(S.at(i)!=S.at(s-1-i)){
        ans++;
      }
    }
  cout<<ans<<endl;
   
    
}

 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <chrono> 
using namespace std::chrono;
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fr(i,a,b) for (int i=(a); i<(b);++i)
#define frr(i,a,b) for(int i=(a-1);i>=(b);--i)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<int,int> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define sz(a) (ll)a.size()
#define endl "\n"
#define po(a,b) (ll)(pow(a,b)+0.5)
#define double long double
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
const ll M=1e9+7;
const int MaxM=501;



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

    int tt=1;
    //cin>>tt;
    while(tt--){

string s,t;
cin>>s>>t;
int n=sz(s);
int ans=0;
fr(i,0,n)if(s[i]!=t[i])ans++;
cout<<ans<<endl;
 
   
  }}



Measured memory_bytes: 3844
n, T = map(int, input().split())
cost = []
time = []
element = []
ans = 1000

for i in range(n):
    c, t = map(int, input().split())
    cost.append(c)
    time.append(t)

for c, t in zip(cost, time):
    if t <= T:
        element.append(c)

if len(element) == 0:
    print('TLE')
else:
    ans = min(element)
    print(ans)



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

using namespace std;
#define ll long long

ll f(ll n)
{
    if (n%2 == 1)
        return 0;
    n /= 2;
    ll ans = 0;
    while(n)
    {
        ans += (n/5);
        n /= 5;
    }
    return ans;
}
int main()
{
    ll n;
    cin >> n;
    cout << f(n);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
void printMatrix(int**,int);
int main(void)
{
  int i,j;//counter
  int v1,v2;//input(v2 adjacent to v1)
  int n;//the number of vertices
  int k;//the number of vertives adjacent to v1
  int **adjList;
  scanf("%d",&n);
  adjList=(int**)malloc(sizeof(int*)*n);
  for(i=0;i<n;i++)
    {
      adjList[i]=(int*)malloc(sizeof(int)*n);
      for(j=0;j<n;j++) adjList[i][j]=0;
    }
  for(i=0;i<n;i++)
    {
      scanf("%d",&v1);
      scanf("%d",&k);
      for(j=0;j<k;j++)
	{
	  scanf("%d",&v2);
	  adjList[v1-1][v2-1]++;
	}
    }
  printMatrix(adjList,n);
  return 0;
}
void printMatrix(int **mat,int n)
{
  int i,j;//counter
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  if(j>0) printf(" ");
	  printf("%d",mat[i][j]);
	}
      printf("\n");
    }
}



Measured memory_bytes: 2056
const input = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n, a, b, c, d, e] = input.split('\n').map(Number)
const min = Math.min(a, b, c, d, e)
if (n % min === 0) {
  console.log(Math.floor(n / min) + 4)
}
else {
  console.log(Math.floor(n / min) + 5)
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  if (N % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  string s1 = S.substr(0, N / 2);
  string s2 = S.substr(N / 2, N / 2);
  if (s1 == s2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
  

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

const int M = 1000000007;

int main() {
    int n, k; cin >> n >> k;
    int a[k]; for (int i = 0; i < k; i++) cin >> a[i];
    long long dp[k+1][n+1], comb[n+1][n+1];
    memset(comb, 0, sizeof comb);
    comb[0][0] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= i; j++)
            comb[i][j] = ((j > 0 ? comb[i-1][j-1] : 0) + comb[i-1][j]) % M;
    for (int i = 0; i <= n; i++) dp[0][i] = i == 0;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j <= n; j++) {
            long long sum = 0;
            for (int l = 0; l <= min(a[i], j); l++) {
                sum += dp[i][j-l] * comb[n-j+l][l] % M * comb[n-l][a[i]-l] % M;
            }
            dp[i+1][j] = sum % M;
        }
    }

    cout << dp[k][n] << endl;
}


Measured memory_bytes: 11172
from operator import mul
from functools import reduce
import bisect
n = int(input())
A = sorted(list(map(int, input().split())))

big_num = A[-1]
near_mid_pointer = bisect.bisect_left(A, big_num / 2)
dif1 = 10**9 + 1
if near_mid_pointer != 0:
        dif1 = big_num / 2 - A[near_mid_pointer - 1]
dif2 = A[near_mid_pointer] - big_num / 2
if dif1 <= dif2:
    num1 = big_num
    num2 = A[near_mid_pointer - 1]

else:
    num1 = big_num
    num2 = A[near_mid_pointer]

print(num1, num2)

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

int main() {
  string a, b;
  cin >> a >> b;
  int res = 0;
  for (int i = 0 ; i < a.length() ; i++){
    if (a[i] != b[i]) res ++;
  }
  cout << res << '\n';
  return 0;
}

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

int main()
{
    int x, n;
    cin >> x >> n;
    if (n == 0)
    {
        cout << x << endl;
        return 0;
    }
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    queue<int>
        not_p;
    int j = 0;
    for (int i = 0; i <= 110; i++)
    {
        if (i == p[j])
        {
            j++;
        }
        else
        {
            not_p.push(i);
        }
    }
    // while (!not_p.empty())
    // {
    //     cout << not_p.front() << endl;
    //     not_p.pop();
    // }

    int ans = 10000000;
    int res = 10000000;
    while (!not_p.empty())
    {
        int tmp = abs(not_p.front() - x);
        // cout << tmp << ' ' << not_p.front() << endl;
        if (res > tmp)
        {
            res = tmp;           //absを保持する変数。小さければ小さいほどよい
            ans = not_p.front(); //表示する結果を保持
        }
        not_p.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628