akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int n, k;
    cin >> n >> k;
    cout << (n - 2) / (k - 1) + 1;


    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int, input().split())
ans = []
for _ in range(ty-sy):
  ans.append("U")
for i in range(tx-sx):
    ans.append("R")
for i in range(abs(sy-ty)):
    ans.append("D")
for i in range(abs(sx-tx)):
    ans.append("L")

ans.append("L")
for i in range(ty-sy+1):
    ans.append("U")
for i in range(tx-sx+1):
    ans.append("R")
ans.append("D")
ans.append("R")
for i in range(abs(sy-ty)+1):
    ans.append("D")
for i in range(abs(sx-tx)+1):
    ans.append("L")
ans.append("U")

print("".join(ans))

Measured memory_bytes: 3188
N,A,B=map(int,input().split())
C=[]
D=[]
tmp=1
for i in range(N):
    if A^tmp>A:
        C.append(0)
    else:
        C.append(1)
    if B^tmp>B:
        D.append(0)
    else:
        D.append(1)
    tmp=tmp*2
X=[];Y=[]
S=0
T=0
for i in range(N):
    if C[i]==D[i]:
        X.append(i)
        if C[i]==1:
            S+=2**i
    else:
        Y.append(i)
        if C[i]==1:
            T+=2**i
#print(X,Y)
if len(Y)%2==0:
    print("NO")
    exit()
def xadd(Lst,k):
    Res=[]
    for i in Lst:
        Res.append(i)
    for i in Lst[::-1]:
        Res.append(i+2**k)
    return Res
XL=[0]
if len(X)!=0:
    XL.append(2**X[0])
for i in range(1,len(X)):
    XL=xadd(XL,X[i])
XL=[i^S for i in XL]
YL=[0,2**Y[0]]
def yadd2(Lst,k1,k2):
    Res=[]
    for i in range(len(Lst)-1):
        if i%2==0:
            Res.append(Lst[i]+0*2**k1+0*2**k2)
            Res.append(Lst[i]+0*2**k1+1*2**k2)
            Res.append(Lst[i]+1*2**k1+1*2**k2)
            Res.append(Lst[i]+1*2**k1+0*2**k2)
        else:
            Res.append(Lst[i]+1*2**k1+0*2**k2)
            Res.append(Lst[i]+1*2**k1+1*2**k2)
            Res.append(Lst[i]+0*2**k1+1*2**k2)
            Res.append(Lst[i]+0*2**k1+0*2**k2)
    Res.append(Lst[-1]+1*2**k1+0*2**k2)
    Res.append(Lst[-1]+0*2**k1+0*2**k2)
    Res.append(Lst[-1]+0*2**k1+1*2**k2)
    Res.append(Lst[-1]+1*2**k1+1*2**k2)
    return Res
for i in range(len(Y)//2):
    YL=yadd2(YL,Y[-1-2*i],Y[-2-2*i])
YL=[i^T for i in YL]
#print(YL)
ans=[]
for i in range(len(YL)):
    for j in range(len(XL)):
        if i%2==0:
            ans.append(YL[i]+XL[j])
        else:
            ans.append(YL[i]+XL[-j-1])
print("YES")
print(" ".join([str(i) for i in ans]))


Measured memory_bytes: 17788
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
#define re register
#define ll long long
using namespace std;
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'|| ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return sum*f;
}
const int N=100010,Mod=1e9+7;
int f[N][13],n;char s[N];
int main(){
	scanf("%s",s);n=strlen(s);
	f[0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<13;j++)
			if(f[i][j]){
				if(s[i]!='?')
					f[i+1][(j*10+s[i]-'0')%13]=(f[i+1][(j*10+s[i]-'0')%13]+f[i][j])%Mod;
				else
					for(int k=0;k<10;k++)
						f[i+1][(j*10+k)%13]=(f[i+1][(j*10+k)%13]+f[i][j])%Mod;
			}
	printf("%d\n",f[n][5]);
	return 0;
}


Measured memory_bytes: 5376
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int n,i;
    int b,f,r,p;
    int H[5][4][11];
    
    for(b=1; b<=4; b++){
        for(f=1; f<=3; f++){
            for(r=1; r<=10; r++){
                H[b][f][r] = 0;
            }
        }
    }
    
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d %d %d %d",&b, &f, &r, &p);
        H[b][f][r] += p;
    }
    
    for(b=1; b<=4; b++){
        for(f=1; f<=3; f++){
            for(r=1; r<=10; r++){
                printf(" %d",H[b][f][r]);
            }
            printf("\n");
        }
        if(b<4)printf("####################\n");
    }

    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ll long long
#define vi vector <int>
#define vll vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF -1000000000
#define pi atan(1)*4
#define MOD 1000000000+7L
#define eps 0.0000006
#define MAX_V 10000
 
using namespace std;

vi a;
vi estado;

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

	cin >> n;

	a.assign(n,0);
	estado.assign(n,INF);

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

	estado[0] = 0;
	estado[1] = abs(a[1]-a[0]);

	for (int i = 2; i < n; ++i){
		estado[i] = min(estado[i-1]+abs(a[i]-a[i-1]),estado[i-2]+abs(a[i]-a[i-2]));
	}

	cout << estado[n-1] << '\n';

	

	return 0;
}

Measured memory_bytes: 1024
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

int A,B,M,a[100010],b[100010],x[100010],y[100010],c[100010];
pair<int,int> ind[100010];

int main(){
  cin>>A>>B>>M;

  REP(i,A)cin>>a[i];
  REP(i,B)cin>>b[i];
  REP(i,M){
    int X,Y;
    cin>>X>>Y>>c[i];
    X--;Y--;
    ind[i].first=X;
    ind[i].second=Y;
  }
  int mina=INF,minb=INF;
  REP(i,A)if(mina>a[i])mina=a[i];
  REP(i,B)if(minb>b[i])minb=b[i];
  int ans=mina+minb;
  REP(i,M){
    ans=min(ans,a[ind[i].first]+b[ind[i].second]-c[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define MOD (1000000007LL)
#define PI (3.1415926535897932384)
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }



// 1次元vectorの出力
template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(void){
	//cout << fixed << setprecision(20);
	int n,m; cin >> n >> m;
	Rep(m){
		int t;
		cin >> t;
		n -= t;
	}
	cout << (n<0 ? -1 : n) << endl;
}

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

void cas(int i,char ch) {
    cout<<"Case "<<i<<":"<<ch;
}

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

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,m; cin>>n>>m;

    ll res=0;

    n--;m--;
    if(n>0) res+=(n*(n+1))/2;
    if(m>0) res+=(m*(m+1))/2;
    cout<<res<<endl;
}


Measured memory_bytes: 256
n = [list(map(int, input().split())) for _ in range(3)]
c = [0] * 4
for i in n:
    for j in i:
        c[j - 1] += 1
a = len(list(filter(lambda x : x % 2 == 1, c)))
if a == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
from collections import Counter

N, K = [int(elem) for elem in input().split(' ')]
A_list = [int(elem) for elem in input().split(' ')]
assert len(A_list) == N

counter = Counter(A_list)
current_num_categories = len(counter)

count = 0
for i, num in enumerate(sorted(counter.values()), start=1):
    if i <= current_num_categories - K:
        count += num
    else:
        break

print(count)


Measured memory_bytes: 32516
#include <stdio.h>

int main()
{
  
  int x, y, r, tmp;
  
  scanf("%d%d", &x, &y);
  
  if(x < y){
    tmp = x;
    x = y;
    y = tmp;
  }
  
  while(1){
    r = x % y;
    x = y;
    y = r;
    if(r == 0) break;
  }
  
  printf("%d", x);
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll k,a,b;
        cin>>k>>a>>b;
        ll flag = 0;
        for(ll i=a;i<=b;i++)
        {
            if(i%k==0)
            {
                flag =1;
                break;
            }
        }
        if(flag)
            cout<<"OK";
        else
            cout<<"NG";
        cout<<endl;
    }
    return 0;
}




Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		int b1 = scan.nextInt();
		int b2 = scan.nextInt();
		int b3 = scan.nextInt();
		if((b1 == 0 && b2 == 0 && b3 == 0) || (b1 == 1 && b2 == 0 && b3 == 0) || (b1 == 0 && b2 == 1 && b3 == 0)){
			System.out.println("Close");
		}else{
			System.out.println("Open");
		}
	}
}

Measured memory_bytes: 17288
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define forx(i, n) for(int i = 1 ; (i) <= (n) ; ++i)
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x) * (x)
#define debug(x) cout << #x <<" = " << x << endl
#define printvpair(v) for(auto x : v) cout << x.first  <<" " << x.second;
#define printv(v) for(auto x : v) cout << x << " "; cout << endl;

const int N = 505;
int a[N][N];
int n,m;



struct fuck{
    int a,b,c,d;
};
vector<fuck > ans;

int main() {
    cin >> n >> m;
    forx(i,n) forx(j,m) cin >> a[i][j];

    forx(i,n)
        forx(j,m){
            if (a[i][j] % 2 == 1){
                if (i + 1 <= n){
                    ans.push_back({i,j,i + 1,j});
                    a[i + 1][j]++;
                    }
                    else if (j + 1 <= m){
                    ans.push_back({i,j,i,j+1});
                    a[i][j + 1]++;
                }
            }
        }
    cout << ans.size()  << endl;

    for (int i = 0; i < ans.size(); i ++) {
        cout << ans[i].a << " " << ans[i].b << " " << ans[i].c << " " << ans[i].d << endl;
     }
    return 0;
}

Measured memory_bytes: 5232
<?php
list($n, $a, $b) = ints();
list($s) = strs();
$cnt = $cntb = 0;

for ($i = 0; $i < $n; ++$i) {
    if ($s[$i] === 'a') {
        if ($cnt < $a + $b) {
            $ans[] = 'Yes';
            ++$cnt;
        } else {
            $ans[] = 'No';
        }
    } elseif ($s[$i] === 'b') {
        if ($cnt < $a + $b && $cntb < $b) {
            $ans[] = 'Yes';
            ++$cnt;
            ++$cntb;
        } else {
            $ans[] = 'No';
        }
    } else {
        $ans[] = 'No';
    }
}
echo implode(PHP_EOL, $ans) . PHP_EOL;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

int main() {   
 int N,A;
 cin>>N>>A;
  
  if(A>498){
    cout<<"Yes"<<endl;
  }
  else if(A%500>=N%500){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3544
#include <iostream>

int main()
{
    while( true )
    {
        int x, y;

        std::cin >> x >> y;
        if( x == 0 && y == 0 )
        {
            break;
        }

        if( x <= y )
        {
            std::cout << x << ' ' << y << std::endl;
        }
        else
        {
            std::cout << y << ' ' << x << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3096
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int ans,n;
    bool flag=false;
    
    cin >> n;
    for(int i=0;(i<n/4+1) && !flag;i++){
        for(int j=0;j<(n-4*i)+1;j++){
            if(n == 4*i+7*j){
                flag=true;
                break;
            }
        }
    }

    cout << (flag ? "Yes" : "No") << endl;
    //cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<iostream>

using namespace std;

int n;
int card[11];
int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		string s;
		cin >> s;
		int field=0,j=0;
		for(int i=0;i<100;i++){
			if(s[i]=='M')card[j]++;
			if(s[i]=='S'){
				field+=card[j]+1;
				card[j]=0;
			}
			if(s[i]=='L'){
				card[j]+=field+1;
				field=0;
			}
			j=(j+1)%n;
		}
		sort(card,card+n);
		for(int i=0;i<n;i++)printf("%d ",card[i]);
		printf("%d\n",field);
		memset(card,0,sizeof(card));
	}
	return 0;
}

Measured memory_bytes: 1252
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

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


int main(){
  ll n; cin >> n; vl num(n+1);
  for(ll i=1; i <= n-1; i++){ ll x; cin >> x; num[x]++; }
  
  for(ll i=1; i <= n; i++){ cout << num[i] << endl; }
}

Measured memory_bytes: 4840
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#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 drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    string s; cin >> s;
    if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}






































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

int main(){
  int a,b,kari=0,kotae=0,i,n;
  cin>>n>>a;
  for(i=1;i<n;i++){
    cin>>b;
    if(a>=b){
      kari++;
    }else{
      kotae=max(kotae,kari);
      kari=0;
    }
    a=b;
  }
  kotae=max(kotae,kari);
  cout<<kotae;
}

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

#define PI 3.1415926535



int main() {
    string s;
    cin >> s;
    bool test = true;
    for (int i = 0; i < s.size(); i++){
        if(i%2==0&&s.at(i)=='L'){
            test =false ;
            cout << "No" << endl;
            return 0;
        }
        else if(i%2==1&&s.at(i)=='R'){
            test = false;
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const int N = 1e5 + 9;

int cnt[N];

signed main(){
   IOS;
   int n; cin >> n;
   int s = 0;
   for(int i = 0; i < n; i++) {
      int x; cin >> x;
      cnt[x]++;
      s+=x;
   }
   int q; cin >> q;
   while(q--) {
      int b, c; cin >> b >> c;
      cnt[c] += cnt[b];
      s += (c-b)*cnt[b];
      cnt[b] = 0;
      cout << s << "\n";
   }
}

Measured memory_bytes: 4472
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);
const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================
string getString(char t){
  string s(1, t);
  return s;
}

bool check(string s){
  int t = stoi(s);
  if((t%8)==0)
    return true;
  else
    return false;
}

// void solve() {

// }


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    //cin >> t;
    while(t--) {
       string s; string t; cin>>s>>t;
       int len = s.size();
       int count = 0;
       for(int i=0; i<len; i++){
        if(s[i]!=t[i]){
          count++;
        }
       }
       cout<<count<<"\n";
    }
    return 0;
}

// int mpow(int base, int exp) {
//   base %= mod;
//   int result = 1;
//   while (exp > 0) {
//     if (exp & 1) result = ((ll)result * base) % mod;
//     base = ((ll)base * base) % mod;
//     exp >>= 1;
//   }
//   return result;
// }

// void ipgraph(int n, int m){
//     int i, u, v;
//     while(m--){
//         cin>>u>>v;
//     u--, v--;
//         g[u].pb(v);
//         g[v].pb(u);
//     }
// }

// void dfs(int u, int par){
//     for(int v:g[u]){
//         if (v == par) continue;
//         dfs(v, u);
//     }
// }


Measured memory_bytes: 3888
/**Author:Sagor*/

#include<bits/stdc++.h>
#include<numeric>

using namespace std;
#define pri(n)          printf("%d\n",n)
#define prll(n)         printf("%lld\n",n)
#define prd(n)          printf("%lf\n",n)
#define scll(n)         scanf("%lld",&n)
#define sci(n)          scanf("%d",&n)
#define scd(n)          scanf("%lf",&n)
#define pi              acos(-1)//inbuilt M_PI
#define ll              long long
#define pb              push_back
#define vsort(v)        sort(v.begin(),v.end())
#define asort(n)        sort(ar,ar+n)
#define for1(i,n)       for(i=1;i<=n;i++)
#define for0(i,n)       for(i=0;i<n;i++)
#define mod             1000000007
#define watch(x)        cout << (#x) << " is " << (x) <<"\n";

/** for print with quote \"hello world\"
    1LL is used to convert into long long*/

bool isprime(int n)
{
    if(n%2==0 && n!=2)
    {
        return 0;
    }
    else
    {
        int root=sqrt(n);
        for(int i=3; i<=root; i+=2)
        {
            if(n%i==0)
            {
                return 0;
            }
        }
        return 1;
    }

}

int main()
{
    /**freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);/**Dont't use scanf of printf*/
    ll n,i;
    cin>>n;
    if(n==2){
        cout<<"2\n";
        return 0;
    }
    if(n & 1){
        for(i=n; ;i+=2){
            if(isprime(i)){
                cout<<i<<"\n";
                return 0;
            }
        }
    }
    else{
        for(i=n+1; ;i+=2){
            if(isprime(i)){
                cout<<i<<"\n";
                return 0;
            }
        }
    }


    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

if n==1:
    start=0
    stop=10
elif n==2:
    start=10
    stop=100
else:
    start=100
    stop=1000

ans=114514
for i in range(start,stop):
    flag=True
    for j in range(m):
        if str(sc[j][1])!=str(i)[sc[j][0]-1]:
            flag=False
    if flag:
        ans=i
        break
print(ans if ans!=114514 else -1)


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

int main(){
    int r,c,i,j,k;
    int v[102][102]={};
    cin>>r>>c;
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            cin>>v[i][j];
            v[i][c]+=v[i][j];
            v[r][j]+=v[i][j];
            v[r][c]+=v[i][j];
        }
    }
    for(i=0;i<r+1;i++){
        for(j=0;j<c;j++){
            cout<<v[i][j]<<" ";
            
        }
        cout<<v[i][c]<<endl;
    }
    return 0;
}




Measured memory_bytes: 3116
n=str(input())
flag=0
for iii in range(8):
  bincalc='{:03b}'.format(iii)
  siki=n[0]
  for jjj in range(3):
    if bincalc[jjj]=="0":
      siki+="+"+n[jjj+1]
    else:
      siki+="-"+n[jjj+1]
  if eval(siki)==7:
    print(siki+"=7")
    break

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

using namespace std;

int main(){
    char c[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer[] ary = new Integer[N];
        for (int i = 0; i < N; i++) {
            int a = Integer.parseInt(sc.next());
            ary[i] = a;
        }
        Integer[] sortAry = ary.clone();
        Arrays.sort(sortAry, Comparator.reverseOrder());
        int maxNum = sortAry[0];
        int secondNum = sortAry[1];
        for (int i = 0; i < N; i++) {
            if (maxNum > ary[i]) {
                System.out.println(maxNum);
            } else {
                System.out.println(secondNum);
            }
        }
    }
}

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

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

const int GAME_OVER=-1;
const int GOAL=1;
int ans;

bool in(int x,int y){
	if(x<0 || y<0 || x>=W || y>=H) return false;
	return true;
}

int update(vector<vector<int> > & field,int &x,int &y,const int r){
	int tx=x+dx[r],ty=y+dy[r];
	if(!in(tx,ty) || field[ty][tx]==1) return GAME_OVER;
	while(true){
		x+=dx[r];y+=dy[r];
		if(x<0 || x>=W || y<0 || y>=H) return GAME_OVER;
		else if(field[y][x]==3) return GOAL;
		else if(field[y][x]==1){
			field[y][x]=0;
			x-=dx[r];y-=dy[r];
			break;
		}
	}
	return 0;
}

void search(const int depth,const vector<vector<int> > &field,const int sx,const int sy){
	if(depth==11 || ans<=depth) return;
	for(int r=0;r<4;r++){
		vector<vector<int> > copy=field;
		int nx=sx,ny=sy;
		int state=update(copy,nx,ny,r);
		if(state==GOAL) ans=min(ans,depth);
		else if(state==GAME_OVER) continue;
		else{
			search(depth+1,copy,nx,ny);
		}
	}
}

int main()
{
	int sx,sy;
	while(cin>>W>>H){
		if(W==0) return 0;
		vector<vector<int > > field(H,vector<int>(W));
		for(int y=0;y<H;y++){
			for(int x=0;x<W;x++){
				cin>>field[y][x];
				if(field[y][x]==2){
					sx=x;sy=y;
				}
			}
		}
		ans=100;
		search(1,field,sx,sy);
		if(ans==100) cout<<-1<<endl;
		else cout<<ans<<endl;
	}
}

Measured memory_bytes: 1276
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;

ll bit[400010];
int N;

void init(ll n) {
	N = 1;
	while (N < n)	N <<= 1;
}

void add(int k, ll a) {
	while (k <= N) {
		bit[k] += a;
		k += k&(-k);
	}
}

ll sum(int k) {
	ll ret = 0;
	while (k > 0) {
		ret += bit[k];
		k -= k&(-k);
	}
	return ret;
}

int main() {
	ll n, k;	cin >> n >> k;
	vector<ll> a(n),b(n+1,0);
	rep(i, n)	cin >> a[i];
	rep(i, n)	a[i] -= k;
	rep(i, n)	b[i + 1] = b[i] + a[i];
	vector<ll> s(n + 1);
	REP(i, n)	s[i] = b[i];
	sort(s.begin(), s.end());
	vector<ll> c(n + 1);
	REP(i, n)	c[i] = distance(s.begin(), lower_bound(s.begin(), s.end(), b[i]));
	init(n + 1);
	ll ret = 0;
	REP(i, n) {
		ret += sum(c[i] + 1);
		add(c[i] + 1, 1);
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 4000
#define offset 8010
using namespace std;
typedef long long  ll;
typedef pair<int,int> ii;
typedef pair<ll,ii> iii;
typedef pair<map<ll,ll> ,ll> mi;
typedef pair<ii,ii> iiii;
typedef vector<ll> vi;
const ll MOD=1e9+7;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int a;
    string s;
    cin>>a>>s;
    if (a>=3200)
        cout<<s<<endl;
    else
        cout<<"red\n";
}


Measured memory_bytes: 892
#include <stdio.h>

int minimum(int a, int b) { return a < b ? a : b; }

int main(){
    int D, G, p[10], c[10], i, j, k, a, ans=100000, num, max;

    scanf("%d %d", &D, &G);

    for(i=0; i<D; i++){
        scanf("%d %d", &p[i], &c[i]);
    }

    for(i=0; i<(1<<D); i++){
        a=0;
        num=0;
        max=-1;
        for(j=0; j<D; j++){
            if((i>>j) & 1){
                a += p[j]*(j+1)*100 + c[j];
                num += p[j];
            }
            else
                max = j;
        }

        j=0;
        while(a < G && j < p[max]){
            a += (max+1)*100;
            num++;
            j++;
        }

        if(a >= G)
            ans = minimum(ans, num);
    }

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

    return 0;
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;
#define repeat(i,n) for(int i=0;i<(n);i++)

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
11 5 5
)");
#define cin input
#endif

int main()
{
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;

	cout << max({a1, a2, a3}) - min({a1, a2, a3}) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  cout << (n <= 999? "ABC" : "ABD") << '\n';
  return 0;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m;
    cin >> n >> m;

    priority_queue<int> pq;
    rep(i, n) {
        int a;
        cin >> a;
        pq.push(a);
    }

    rep(i, m) {
        int e = pq.top();
        pq.pop();
        e /= 2;
        pq.push(e);
    }

    ll ans = 0;
    while (!pq.empty()) {
        ans += pq.top(); pq.pop();
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
import java.util.Arrays;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);

	void solve(){
		int n=gInt();
		int[]a=INTS(n).toArray();
		int[]b=Arrays.stream(a).sorted().toArray();
		int l=b[n/2-1],r=b[n/2];
		for(int i:a)
			System.out.println(i<=l?r:l);
	}

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

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}


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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    long long N, K;
    cin >> N >> K;
    long long max = N/K;
    long long ans = N - K*max;
    long long ans_ = std::abs(ans - K);
    cout << std::min(ans, ans_);
}

Measured memory_bytes: 256
#include <stdio.h>

int abs(int a){
	if(a<0) return -a;
	else return a;
}

int main() {
	int a,b,c,r;
	scanf("%d %d %d %d",&a,&b,&c,&r);
	if(abs(a-c)<=r||(abs(a-b)<=r&&abs(b-c)<=r)) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] w = new int[n];
		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
		}

		int[] cumsum = new int[n + 1];
		for (int i = 0; i < n; i++) {
			cumsum[i + 1] = cumsum[i] + w[i];
		}

		int min = Integer.MAX_VALUE;
		for (int i = 1; i < n; i++) {
			min = Math.min(min, Math.abs(cumsum[n] - cumsum[i] - cumsum[i]));
		}
		
		pr.println(min);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23252
N = int(input())
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
ans = 1;
flg = True
A.sort()
for i in range(N):
    ans*=A[i]
    if(ans>1000000000000000000):
        flg = False
        break
if(flg):
    print(ans)
else:
    print(-1)

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

#define ll long long

int main() {
	char s[100]; ll k; scanf("%s%lld", &s, &k); int ans;

	if (k <= 100) {
		for (int i = 0; i < k; i++) {
			if (s[i] != '1') {
				ans = s[i] - '0'; break;
			}
			if (i == k - 1) {
				ans = 1;
			}
		}
	}
	else {
		int len = strlen(s);
		for (int i = 0; i < len; i++) {
			if (s[i] == '1') {
				continue;
			}
			else {
				ans = s[i] - '0'; break;
			}
		}
	}

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

	return 0;
}

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

int main() {
	string S;
	cin >> S;
	if (S == "Sunny") {
		cout << "Cloudy" << endl;
 	}
	if (S == "Cloudy") {
		cout << "Rainy" << endl;
	}
	if (S == "Rainy") {
		cout << "Sunny" << endl;
	}
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,m;
    cin >> n >> m;
    cout << (1900*m+100*(n-m))*(1<<m) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int N, res;
    cin >> N;
    res = N;
    for (int i=0;i<=N;i++) {
        int c = 0;
        int t = i;
        while (t) { c += t%6; t /= 6; }
        t = N - i;
        while (t) { c += t%9; t /= 9; }
        res = min(res,c);
    }
    cout << res << endl;

    return 0;
}

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

//------------------------- DEBUGGING -----------------------------------------------------------------------
#ifdef DEBUG
#define debug( args... ) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) {
    vector<string> v;
    stringstream ss( s);
    string x;
    while ( getline( ss, x, c))
        v.emplace_back( x);
    return move( v);
}
void err( vector<string>::iterator it) { }
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t';
    err( ++it, args...);
}
#else
#define debug(...)
#endif
//------------------------ MACROS ----------------------------------------------------------------------------

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define bck(i,j,k) for(i = j; i > (k); i--)
#define all(x) x.begin(), x.end()
#define el '\n'

typedef long long int ll;
typedef long double DO;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
//---------------------------  TEMPLATE ENDS, MAKE CHANGES FROM HERE ----------------------------------------

const int mod = 1e9+7;
const ll inf = 2e18;
const DO eps = 1e-9;
const int NN = 1e5 + 2;

vvi adj;
int ar[NN];

void solve(){
    int i = 0, j = 0, k = 0, n = 0, m = 0;
    cin>>n>>m;
    int ans = 5000;
    fr(i, 0, n){
        cin>>j>>k;
        if(k <= m)
            ans = min(ans, j);

    }
    if(ans == 5000) cout << "TLE\n";
     else cout << ans << el;
}

int main(){
#ifndef DEBUG
    ios::sync_with_stdio(false); cin.tie(0); 
#endif
    int T = 1, tc;
    for(tc = 1; tc <= T; tc++){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
using namespace std;
ll a[3][4005];
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll sum=0;
    map<char,int>m;
    a[0][n]=0;
    a[1][n]=0;
    a[2][n]=0;
    for(int i=n-1;i>=0;i--)
    {
        a[0][i]=a[0][i+1];
        a[1][i]=a[1][i+1];
        a[2][i]=a[2][i+1];
        if(s[i]=='R')a[0][i]++;
        if(s[i]=='G')a[1][i]++;
        if(s[i]=='B')a[2][i]++;
    }
    for(int i=0;i+2<n;i++)
    {
        m.clear();
        m[s[i]]=1;
        int dex1=i;
        for(int j=i+1;j+1<n;j++)
        {
            if(m.count(s[j])==0)
            {
                m[s[j]]=1;
                int dex2=j;
                if(m.count('R')==0)
                {
                    sum+=a[0][j];
                    if(s[2*j-i]=='R')
                        sum--;
                }
                else if(m.count('G')==0)
                {
                    sum+=a[1][j];
                    if(s[2*j-i]=='G')
                        sum--;
                }
                else if(m.count('B')==0)
                {
                    sum+=a[2][j];
                    if(s[2*j-i]=='B')
                        sum--;
                }
                m.erase(s[j]);
            }
        }
    }
    cout<<sum;
    return 0;
}


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

ll md=1e9+7;
ll jc[100010];
void init(){
	ll res=1;
	for(ll i=1;i<=100005;i++){
		res*=i;
		res%=md;
		jc[i]=res;
	}
}
ll qmod(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1){
			res*=a;
			res%=md;
			
		}
		b=b>>1;
		a*=a;
		a%=md;
	}
	return res%md;
}
ll C(ll n,ll m){//n!/((n-m)i*mi)
	if(m>n)
	return 0;
	if(m==0||n==m)
	return 1;
	ll a,b;
	a=jc[n];
	b=jc[n-m]*jc[m];
	b%=md;
	ll ny=qmod(b,md-2);
	ll ans=(a*ny)%md;
	return ans;
}
ll an[100005];
 map<ll,ll>mp;
int main(){
	init();
	ll n;
	cin>>n;
	ll ix;
	ll v;
	for(ll i=1;i<=n+1;i++){
		cin>>an[i];
		mp[an[i]]++;
		if(mp[an[i]]==2)
		v=an[i],ix=i;
	}
	ll preix;
	for(ll i=1;i<=n+1;i++){
		if(an[i]==v){
			preix=i;
			break;
		}
	}
//	cout<<v<<"v ix pre "<<ix<<" "<<preix<<endl;
	ll prerest=preix-1;
	ll m=n+1;
	ll rest=m-ix;
//	cout<<prerest<<" "<<rest<<endl;
		for(ll i=1;i<=m;i++){
		if(i==1){
			cout<<n<<endl;
			continue;
		}
		if(i==m){
			cout<<"1"<<endl;
			continue;
		}
		ll ans=C(m,i);
		ll repeat=C(rest+prerest,i-1);
		//ll repeat1=C(prerest,i-1);
	//	cout<<repeat<<" "<<repeat1<<" ";
		ans=(ans%md-repeat%md+md)%md;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 8960
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

struct choten{
    bool color;
    vector<pair<int, ll>> child;
};

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

    vector<choten> c(n+1);
    rep(i, n-1){
        int v, u;
        ll w;
        cin >> v >> u >> w;
        c[v].child.push_back(make_pair(u, w));
        c[u].child.push_back(make_pair(v, w));
    }
    queue<int> q;
    c[1].color = 0;
    q.push(1);
    int res[n+1];
    rep(i, n+1)res[i] = -1;
    res[1] = 0;

    int o = 0;
    while(!q.empty()){
        int pos = q.front();
        q.pop();
        // cout << "pos" << pos << endl;
        rep(i, c[pos].child.size()){
            int x = c[pos].child[i].first;
            int y = c[pos].child[i].second;
            if(res[x] >= 0)continue;
            if(y %2 == 0)c[x].color = c[pos].color;
            else c[x].color = !c[pos].color;
            res[x] = c[x].color;
            q.push(x);
        }
    }

    rep(i, n)cout << res[i+1] << endl;


}

Measured memory_bytes: 9088
#include<stdio.h>
int main(){
  long long i,j,n;
  scanf("%lld",&n);
  for(i=-1000;i<1010;i++){
    for(j=-1000;j<1010;j++){
      if(i*i*i*i*i-j*j*j*j*j==n){
	printf("%lld %lld\n",i,j);
	return 0;
      }
    }
  }
}


Measured memory_bytes: 1736
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem1129 : Hanafuda Shuffle **/
int main()
{
	vector<int> card;
	int n, r, p, c;
	
	while (cin >> n >> r, n||r) {
		card.clear();
		rep(i, n)
			card.push_back(n-i);
		
		rep(k, r) {
			cin >> p >> c;
			vector<int> tmp;
			rep(i, c)
				tmp.push_back(card[i+p-1]);
			rep(i, p-1)
				tmp.push_back(card[i]);
			REP(i, p+c-1, n) {
				tmp.push_back(card[i]);
			}
			card = tmp;
		}
		cout << card[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <set>
#include <iostream>
#include <cassert>
#include <queue>
using namespace std;


int main()
{
    int x, y;
    cin >> x >> y;
    if (x * 500 >= y)
	  	cout << "Yes";
  	else
      	cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
int n,k,s;
int main()
{
	cin>>n>>k>>s;
	for(int i=0;i<k;i++)
	{
		cout<<s<<' ';
	}
	if(s<1e9)
	{
		for(int i=k;i<n;i++)
		{
			cout<<s+1<<' ';
		}
	}
	else
	{
		for(int i=k;i<n;i++)
		{
			cout<<1<<' ';
		}
	}
	return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int count = 1;
  if(a != b && b != c && c != a){
    count += 2;
  }else if(a == b && b != c && c != a){
    count++;
  }else if(a != b && b == c && c != a){
    count++;
  }else if(a != b && b != c && c == a){
    count++;
  }
  cout << count << endl;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int x = 0;
    for(int i = 0; i < m; i++)
    {
        int num;
        cin >> num;
        x += num;
    }
    if(x > n)
        cout << -1;
    else
        cout << n - x;
}

Measured memory_bytes: 3632
#coding=UTF-8

mozir=input()
hyo=mozir.split(' ')
N=int(hyo[0])
W=int(hyo[1])

weight=[]
values=[]
for idx in range(0,N,1):
    mozir=input()
    hyo=mozir.split(' ')
    weight.append(int(hyo[0]))
    values.append(int(hyo[1]))

minimum_weight=min(weight)
weight_values=list(range(0,4,1))
for idx in range(0,4,1):
    weight_values[idx]=[]

for idx in range(0,N,1):
    weight_values[weight[idx]-minimum_weight].append(values[idx])

for idx in range(0,4,1):
    weight_values[idx].sort(reverse=True)

#print(weight_values)

jogen=min(W//minimum_weight,len(weight_values[0]))

tmpten=[0,0,0]
tmpomo=[0,0,0]
ans=0
for idx in range(0,jogen+1,1):
    tmpten[0]=sum(weight_values[0][0:idx])
    tmpomo[0]=minimum_weight*idx

    jogen=min((W-tmpomo[0])//(minimum_weight+1),len(weight_values[1]))
    for idy in range(0,jogen+1,1):
        tmpten[1]=tmpten[0]+sum(weight_values[1][0:idy])
        tmpomo[1]=tmpomo[0]+(minimum_weight+1)*idy

        jogen=min((W-tmpomo[1])//(minimum_weight+2),len(weight_values[2]))
        for idz in range(0,jogen+1,1):
            tmpten[2]=tmpten[1]+sum(weight_values[2][0:idz])
            tmpomo[2]=tmpomo[1]+(minimum_weight+2)*idz

            kosuu=min((W-tmpomo[2])//(minimum_weight+3),len(weight_values[3]))
            tmpans=tmpten[2]+sum(weight_values[3][0:kosuu])
            #print(tmpans)
            ans=max(ans,tmpans)

print(ans)


Measured memory_bytes: 3192
N=int(input())
alist=list(map(int,input().split()))

avg=sum(alist)/N
min_index=-1
min_diff=1000
for i in range(N):
  diff=abs(avg-alist[i])
  if diff<min_diff:
    min_diff=diff
    min_index=i
    
print(min_index)

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

int main(){
  int N;
  string S,T;
  cin >> N >> S >> T;
  
  string U = "";
  int j,k;
  j = k = 0;
  rep(i,2*N){
    if(0 == i%2){
      U += S.at(j);
      j++;
    }else{
      U += T.at(k);
      k++;
    }
  }
  
  cout << U << endl;
}

Measured memory_bytes: 256