akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int find(int a,int x,int y)
{
    if(abs(a-x)>abs(a-y))
        printf("B\n");
        else printf("A\n");

}
int main()
{
    int a,x,y;
    while(scanf("%d %d %d",&a,&x,&y)!=EOF)
    {
        find(a,x,y);
    }
    return 0;
}


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

int main() {
    int N; cin >> N;
    int ans[10010] = {};
    pair<int, int> ma = make_pair(0, 1);
    for(int i=2; i<=N; i++) {
        printf("? 1 %d\n", i);
        fflush(stdout);
        int serve; scanf("%d", &serve);
        if(ma.first < serve) ma = make_pair(serve, i);
    }

    ans[0] = ma.second;
    for(int i=1; i<=N; i++) {
        printf("? %d %d\n", ma.second, i);
        fflush(stdout);
        int serve; scanf("%d", &serve);
        ans[serve] = i;
    }

    int l = ans[0], r = ans[N-1];
    printf("!");
    for(int i=0; i<N; i++) printf(" %d", ans[i]);
    printf("\n");
    fflush(stdout);
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define pii pair<int, int> 
#define pll pair<long , long>
#define all(a) a.begin(), a.end()
#define int long long
#define ll long long
#define mod 998244353
//#define int long long
#define loop(i,a,b) for(int i=a;i<b;i++)
#define bloop(i,a,b) for(int i=a;i>=b;i--)

int max(int a, int b) { return (a > b)? a : b; } 
bool cmp(char ch,char c)
{
    return ch>c;
}
using namespace std;

int32_t main()
{
    //  freopen("input.txt", "r", stdin);
	//  freopen("output.txt", "w", stdout);
 //  #ifndef ONLINE_JUDGE 
  //  	freopen("input.txt", "r", stdin); 
    //	freopen("output.txt", "w", stdout); 
    	//freopen("error.txt", "w", stderr); 
   //#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
     //cin>>t;
    while(t--)
        {
           int a,b,c;
           cin>>a>>b>>c;
           if((a==b && b!=c)||(b==c && c!=a) || (a==c && c!=b)) cout<<"Yes"<<endl;
           else cout<<"No"<<endl;
        }
    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N=int(input())

lr=[]
ma=0
for _ in range(N):
    l,r=map(int,input().split())
    ma=max(l,r,ma)
    lr.append([l,r])

#print(ma)

l=[0]*(ma+1)

for n in range(3,ma+1)[::2]:
    temp=(n*(n+1))//2
    flag=True
    for i in range(2,-int(-temp**0.5//1)):
        if temp%i==0:
            if i!=(n+1)//2:
                #print(n,i)
                flag=False
                break
    if flag:
        l[n]=l[n-2]+1
    else:
        l[n]=l[n-2]

#print(l)
for item in lr:
    print(l[item[1]]-l[item[0]] if l[item[0]-2]==l[item[0]] or item[0]==1 else l[item[1]]-l[item[0]]+1)
    


Measured memory_bytes: 68312
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    string a,b,c; cin >> a >> b >> c;
    cout << 'A' << b[0] << 'C' << endl;
    
}


Measured memory_bytes: 256
N = int(input())
K = int(input())

s = str(N)
n = len(s)

dp = [[[0]*2 for i in range(4)] for j in range(105)]
dp[0][0][0] = 1

for i in range(n):
    for j in range(4):
        for k in range(2):
            nd = int(s[i])
            for d in range(10):
                ni = i+1
                nj = j
                nk = k
                if d != 0:
                    nj += 1
                if k == 0:
                    if d > nd:
                        continue
                    elif d < nd:
                        nk = 1
                    else:
                        pass
                if nj <= 3:
                    dp[ni][nj][nk] += dp[i][j][k]
#print(dp)
print(dp[n][K][0]+dp[n][K][1])


Measured memory_bytes: 41328
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll n,k;
vector<ll> a;
ll len[200010];
ll rev[200010];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k;
    a.resize(n);
    rep(i,0,n) cin>>a[i];
    rep(i,0,n) len[i]=-1;
    set<ll> s;
    rep(i,0,n){
        if(s.count(a[i])){
            len[rev[a[i]]]=i-rev[a[i]]+1;
            rev[a[i]]=i;
        }
        else{
            s.insert(a[i]);
            rev[a[i]]=i;
        }
    }
    rep(i,0,n){
        if(s.count(a[i])){
            if(len[rev[a[i]]]==-1) len[rev[a[i]]]=i+n-rev[a[i]]+1;
        }
    }
    set<ll> t;
    ll x=0;
    while(!t.count(x)){
        t.insert(x);
        x+=len[x];
        x%=n;
    }
    ll res=0, now=0;
    while(now!=x){
        res+=len[now];
        now=(now+len[now])%n;
    }
    ll p=0;
    p+=len[now];
    now=(now+len[now])%n;
    while(now!=x){
        p+=len[now];
        now=(now+len[now])%n;
    }
    ll rest=n*k-res;
    rep(i,0,200010) rev[i]=-1;
    if(rest<=0){
        rest=n*k;
        now=0;
        while(rest>len[now]){
            rest-=len[now];
            now=(now+len[now])%n;
        }
    }
    else{
        rest%=p;
        while(rest>len[now]){
            rest-=len[now];
            now=(now+len[now])%n;
        }
    }
    vector<ll> ans;
    set<ll> S;
    ll c=0;
    rep(i,0,rest){
        if(!S.count(a[now])){
            ans.pb(a[now]);
            S.insert(a[now]);
            rev[a[now]]=c;
            c++;
        }
        else{
            rep(j,rev[a[now]],c){
                S.erase(ans[j]);
            }
            ans.erase(ans.begin()+rev[a[now]], ans.end());
            c=rev[a[now]];
            rev[a[now]]=-1;
        }
        now++;
        now%=n;
    }
    rep(i,0,c){
        cout <<ans[i]<<" ";
    }
    cout<<"\n";
}

Measured memory_bytes: 35952
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    ll c;
    cin >> n >> c;
    vl x(n+1),v(n+1);
    x[0] = 0;
    v[0] = 0;
    rep(i,n) cin >> x[i+1] >> v[i+1];
    x.pb(c);
    v.pb(0);
    n += 2;
    vl mxr(n, 0),mxl(n,0);
    rep2(i,1,n) mxl[i] = mxl[i-1]-(x[i]-x[i-1])+v[i];
    rep2(i,1,n) chmax(mxl[i],mxl[i-1]);
    rrep(i,n-1) mxr[i] = mxr[i + 1] - (x[i + 1] - x[i]) + v[i];
    rrep(i,n-1) chmax(mxr[i], mxr[i + 1]);
    ll ans = 0;
    rep(i,n-1) {
        ll nans = max({mxl[i],mxr[i+1],mxl[i]+mxr[i+1]-min(x[i],(c-x[i+1]))});
        chmax(ans,nans);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3424
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mx 200005
#define fr first
#define se second
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll dp[100005],coin[100005];
ll n;
ll func(ll i)
{
    if(i>=n) return 0;
    if(dp[i]!=-1) return dp[i];
    ll ans1=INT_MAX,ans2=INT_MAX;
        if(i+1<=n) ans1=abs(coin[i]-coin[i+1])+func(i+1);
        if(i+2<=n) ans2=abs(coin[i]-coin[i+2])+func(i+2);
    return dp[i] = min(ans1,ans2);
}

int main()
{
   fast;
   cin >> n;
   memset(dp,-1,sizeof dp);
   for(ll i=1; i<=n; i++) cin >> coin[i];
   cout << func(1) << "\n";
   return 0;
}


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    bool x = false;
    for (int i = 0; i <= N / 7; i++)
        if ((N - i * 7) % 4 == 0)
            x = true;
    cout << (x ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }





ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}





void solve() {
    ll s;
    cin>>s;
    ll ans = 0;
    ll n = s;
    COMinit();
    rep2(i,1,n){
        if(i * 3 > s) continue;
        ll sum = s - i*3;
        // cout<<i<<" "<<sum<<" "<<COM(i+sum-1,sum)<<endl;;
        ans += COM(i + sum-1, sum);
        ans %= MOD;
    }
    cout<<ans<<endl;



}




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    ll t=1;
    
    // cin>>t;

    rep(i,t){
        solve(); 
    }

    return 0;
}


Measured memory_bytes: 52872
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;


import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final char s = sc.next().charAt(0);
			
			if('a' <= s && s <= 'z') {
				System.out.println("a");
			}else {
				System.out.println("A");
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32692
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf, atoi
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require sqrt ceil floor
#include <climits>	// require INT_MAX etc
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <stdint.h>	// require uint64_t
#include <fstream>	// require freopen

using namespace std;

bool check (string w, int n )
{
	if (n % 15 == 0 ){
		return (w == "FizzBuzz" );
	} // end if

	if (n % 3 == 0 ){
		return (w == "Fizz" );
	} // end if

	if (n % 5 == 0 ){
		return (w == "Buzz" );
	} // end if
	
	for (int i = 0; i < w.length(); ++i ){
		if (w[i] < '0' || w[i] > '9' ){
			return false;
		} // end if
	} // end for

	return (atoi(w.c_str() ) == n );
}


int main()
{
//	cut here before submit 
//	freopen ("testcase.fizzbuzz", "r", stdin );
	int m, n;

	while (cin >> m >> n && m && n ){
		vector <int> player (m, 1 );
		vector <string> word (n+1 );
		for (int i = 1; i <= n; ++i ){
			cin >> word[i];
		} // end for
		int j = 0;
		for (int i = 1; i <= n; ++i ){
			if (check (word[i], i ) ){
				j = (j + 1 ) % m;
				while (!player[j] ){
					j = (j + 1) % m;
				} // end while
			}else{
				player[j] = 0;
				if ((int)count (player.begin(), player.end(), 1 ) < 2 ){
					break;
				} // end if
				while (!player[j] ) {
					j = (j + 1) % m;
				} // end while
			} // end if
		} // end for

		vector <int> res;
		res.clear();

		for (int i = 0; i < m; ++i ){
			if (player[i] ){
				res.push_back (i+1);
			} // end if
		} // end for

		for (int i = 0; i < res.size(); ++i ){
			cout << res[i];
			if (i != res.size() - 1 ){
				cout << ' ';
			} // end if
		} // end for
		cout << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
n, x = map(int, input().split())
A = list(map(int, input().split()))
cnt = [0] * (n - 1)
ans1 = 0
for i in range(n - 1):
    cnt[i] = A[i] + A[i + 1]
    cnt[i] -= x
    cnt[i] = max(cnt[i], 0)
temp_cnt = cnt[::]
# print(cnt)
for i in range(n - 1):
    if temp_cnt[i] == 0:
        continue
    if i < n - 2:
        ans1 += temp_cnt[i]
        temp_cnt[i + 1] -= min(A[i + 1], temp_cnt[i])
        temp_cnt[i] = 0
        temp_cnt[i + 1] = max(temp_cnt[i + 1], 0)
    # print(ans1)
ans1 += temp_cnt[-1]


print(ans1)


Measured memory_bytes: 19908
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
int main(){
    int A, B;
    cin >> A >> B;
    if(A > 8 || B > 8){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
str1 = list(input())
str2 = list(input())
ans = []
for i in range(len(str1)):
    ans.extend(str1[i])
    if len(str2) != len(str1) and i == len(str1) - 1:
        break
    ans.extend(str2[i])
print("".join(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

int digitSum(int n){
   int res = 0;
   while(n){
       res += n % 10;
       n /= 10;
   }
   return res;
}

void solve(){
    int cnt = 0;
    for(int i = 1; i <= 1000000; i++){
        bool f = true;
        for(int j = i + 1; j <= 10000000; j++){
            if(i * digitSum(j) > j * digitSum(i)){
                f = false; break;
            }
        }
        if(f){
            cout << ++cnt << " " << i << endl;
        }
    }
}



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    vector<int> cand;
    set<int> st;
    for(int j = 0; j <= 12; j++){
        for(int i = 1; i <= 999; i++){
            int now = i;
            for(int k = 0; k < j; k++){
                now = now * 10 + 9;
            }
            if(st.count(now)) continue;            
            cand.push_back(now);
            st.insert(now);
        }
    }
    int cnt = 0;
    rep(i, 0, cand.size()){
        bool f = true;
        rep(j, i + 1, cand.size()){
            if(cand[i] * digitSum(cand[j]) > cand[j] * digitSum(cand[i])){
                f = false; break;
            }
        }
        if(f){
            cout << cand[i] << endl;
            cnt++;
            if(cnt == k) break;
        }
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int a,b,c,n,x;
int main()
{
      cin>>n>>a>>b;
      x=min(a,b);
      cout<<x<<" ";
      if ((a==0)||(b==0))
      {
          cout<<0;
      }
      else
      {
          if ((a+b)>n)
          {
              x=a+b-n;
               cout<<x;
          }
          else
          {
              cout<<0;
          }
      }
    return 0;
}

Measured memory_bytes: 256
/***********************************************
 *                                             *
 *   author: raghav_0901 (Raghav Dalmia)       *
 *   updated on: 27-06-2020,  5:33:18 pm IST   *
 *                                             *
\***********************************************/

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define endl '\n'
#define f(i, begin, end) \
    for (__typeof(end) i = (begin); i != (end) - (begin > end); i += 1 - 2 * ((begin) > (end)))
#define ff(i, begin, end, fl) \
    for (__typeof(end) i = (begin); i != (end)(begin > end) && fl; i += 1 - 2 * ((begin) > (end)))
#define int long long int

const int mod = INT_MAX;

signed main( )
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s, t;
    cin >> s >> t;
    int cnt = 0;
    f(i, 0, s.length( )) { cnt += (s[i] != t[i]); }
    cout << cnt << endl;
    return 0;
}


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

def solve(N: int):
    string = "abcdefghijk"
    if N == 1:
        print("a")
        return


    answer = []
    def dfs(s,various):
        if len(s) == N:
            return s
        new = dfs(s+string[various],various+1)
        if new:
            answer.append(new)

        for i in range(various):
            n = dfs(s+string[i],various)
            if n:
                answer.append(n)

    dfs("a",1)
    answer.sort()
    for i in range(len(answer)):
        print(answer[i])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12676
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << (60 * (h2 - h1) + m2 - m1 - k);

    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
main(){
  char a[11],b[11],c[11];
  int anum,bnum;
  anum = 0;
  bnum = 0;
  
  scanf("%s %s",a,b);
  scanf("%d %d",&anum,&bnum);
  scanf("%s",c);
  
  if(0 == strcmp(a,c)){
    anum--;
  }else{
    bnum--;
  }
  
  printf("%d %d",anum,bnum);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
 
 
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;
 
signed main() {
    FAST_IO;
 
    int n;
    cin >> n;
    int jumps[n];
    vector<int> dp(n, 0); // dp[i] : Minimum cost for the frog to reach position i.
    for (int i = 0; i < n; i++) cin >> jumps[i];
    dp[1] = abs(jumps[1] - jumps[0]); // Base value
    for (int i = 2; i < n; i++)
        dp[i] = min(abs(jumps[i] - jumps[i - 1]) + dp[i - 1], abs(jumps[i] - jumps[i - 2]) + dp[i - 2]);
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 3976
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++) cin>>s[i];

  map<string,int> mp;
  for(int i=0;i<n;i++){
    auto itr = mp.find(s[i]);
    if(itr != mp.end()){
      itr->second++;
    }else{
      mp.insert(make_pair(s[i],1));
    }
  }

  auto begin = mp.begin(),end = mp.end();
  int max=0;
  for(auto itr = begin;itr != end;itr++){
    if(itr->second > max) max = itr->second;
  }

  vector<string> ans;
  for(auto itr=begin;itr!=end;itr++){
    if(itr->second == max){
      ans.push_back(itr->first);
    }
  }

  sort(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 28404
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
ans = 0
for i in range(1, n + 1, 2):
    if len(make_divisors(i)) == 8:
        ans += 1
print(ans)

Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
int dp[100][20000];
int main(){
	int n,W;	cin>>n>>W;
	int v[n],w[n];
	for(int i=0;i<n;i++)	cin>>v[i]>>w[i];
	for(int i=w[0];i<=W;i++)	dp[0][i]=v[0]+dp[0][i-w[0]];
	for(int i=1;i<n;i++){
		for(int j=0;j<=W;j++){
			dp[i][j]=dp[i-1][j];
			if(j>=w[i]){
				dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
				dp[i][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
			}
		}
	}
	cout<<dp[n-1][W]<<endl;
	return 0;
}

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

const int INF = 1e9;

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

    int k;
    cin >> k;
    int l = 9 * k;
    if (k % 7 == 0)
        l /= 7;
    int resto, i;
    i = 1;
    resto = 10 % l;
    for (i = 2; i <= l && resto != 1; i++) {
        resto = (resto * 10) % l;
    }
    int resp = -1;
    if (resto == 1)
        resp = i - 1;
    cout << resp << endl;

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 50;


int main(){
  int data;
  cin >> data;
  int x = data / 100;
  int y = data % 100;
  if(x && x < 12){
    cout << (y && y <= 12 ? "AMBIGUOUS" : "MMYY") << endl;
  }else{
    cout << (y && y <= 12 ? "YYMM" : "NA") << endl;
  }
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;

#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second

string s;

int main() {
    cin >> s;
    int a = 0, b = 0;
    rep(i, s.size()) {
        if (s[i] == 'A')a++;
        if (s[i] == 'B')b++;
    }
    if (a > 0 && b > 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(ll (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

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

    string a, b;
    cin >> a >> b;
    int ab = stoi(a + b);
    cout << (pow((int)sqrt(ab), 2) == ab ? "Yes" : "No") << "\n";
}

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

int A[100000];
int B[100000];
int C[100000];

int max(int a, int b) {
	if (a < b)
		return b;
	else
		return a;
}

int main()
{
	int days = 0;
	int sumA = 0,sumB = 0, sumC = 0;
	int maxdays = pow(10, 5);
	int maxpoint = pow(10, 4);
	int i = 0;
	int nowptA = 0, nowptB = 0, nowptC = 0;
	int sum = 0;

if (scanf("%d,\n", &days) > 0) {
		if (0 >= days || days > maxdays) 
			exit(1);
		}

	for (i = 0; i < days; i++)
	{
		if (scanf("%d,\t", &A[i]) < 0) {
			if (0 >= A[i] || A[i] > maxpoint)
			{
				exit(1);
			}
			exit(1);
		}
		if (scanf("%d,\t", &B[i]) < 0) {
			if (0 >= B[i] || B[i] > maxpoint) 
			{
				exit(1);
			}
			exit(1);
		}
		if (scanf("%d,\n", &C[i]) < 0) {
			if (0 >= C[i] || C[i] > maxpoint) 
			{
				exit(1);
			}
			exit(1);
		}
	}

	for (i = 0; i < days; i++)
	{
		if(i == 0)
		{
			sumA = A[i];
			sumB = B[i];
			sumC = C[i];
			nowptA = sumA;
			nowptB = sumB;
			nowptC = sumC;
			continue;
		}
		sumA = A[i] + max(nowptB, nowptC);
		sumB = B[i] + max(nowptA, nowptC);
		sumC = C[i] + max(nowptA, nowptB);

		nowptA = sumA;
		nowptB = sumB;
		nowptC = sumC;
	}

	if (nowptA <= nowptC && nowptB <= nowptC) 
	{
		sum = nowptC;
	}
	else if (nowptA <= nowptB && nowptC <= nowptB)
	{
		sum = nowptB;
	}
	else if(nowptB <= nowptA && nowptC <= nowptA)
	{
		sum = nowptA;
	}

	printf("%d", sum);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n;
  cin >> m;
  if(n * 4 < m){
	   cout << "No" << endl;
     return 0;
   }
  if(m % 2 == 1){
    cout << "No" << endl;
    return 0;
  }
  if(n * 2 > m){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

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

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

  bool isCost[n];
  for (int i = 0; i < n; i++) {
    isCost[i] = false;
  }
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    isCost[a] = true;
  }

  int costToN = 0;
  for (int i = x + 1; i < n; i++) {
    if (isCost[i]) {
      costToN++;
    }
  }

  int costTo0 = 0;
  for (int i = x - 1; i > 0; i--) {
    if (isCost[i]) {
      costTo0++;
    }
  }

  cout << min(costToN, costTo0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	string s;cin >> s;
	vector<int> a;
	int cnt = 0;
	char c = s.at(0);
	rep(i,n){
		if(s.at(i) == c) cnt++;
		else{
			a.pb(cnt);
			cnt = 1;
		}
		c = s.at(i);
	}
	a.pb(cnt);
	if(a.size() <= 2 * k + 1){
		cout << n-1 << endl;
		return 0;
	}
	vector<int> b(a.size()+1);
	vector<int> d(a.size()+1);
	rep(i,a.size()){
		b.at(i+1) = b.at(i) + a.at(i);
		d.at(i+1) = d.at(i) + (a.at(i) - 1);
	}
	int ans = 0;
	for(int i = 2 * k + 1; i < b.size(); i++){
		ans = max(ans, b.at(i) - b.at(i - (2 * k + 1)) - 1 + d.at(i - (2 * k + 1)) + (d.at(d.size()-1) - d.at(i)));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1608
s = input()

cnt0 = 0                 # 010101...にする場合に必要な塗る回数
for i in range(len(s)):
    if s[i] != str(i%2):
        cnt0 = cnt0 + 1


cnt1 = 0                # 10101010..にする場合に必要な塗る回数
for i in range(len(s)):
    if s[i] == str(i%2):
        cnt1 = cnt1 + 1


if cnt0 < cnt1:
    print(cnt0)
else:
    print(cnt1)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ


signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    vector<P> v(n);
    rep(i,n){
        cin >> v[i].fi >> v[i].se;
    }
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    int ans=100;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int p=v[j].fi-v[i].fi,q=v[j].se-v[i].se;
            if(p==0&&q==0) continue;
            int res=n;
            for(int k=0;k<n;k++){
                bool ok=0;
                for(int l=0;l<n;l++){
                    if(p==v[l].fi-v[k].fi&&q==v[l].se-v[k].se) ok=1;
                }
                if(ok) res--;
            }
            chmin(ans,res);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3552
//N+10個のボールのうち15個を黒く塗る。前半5個のボールまでは、
//手前の黒いボール(or先頭)までにあるボールが偶数個になってほしい。何通りの入れ方があるか？
#include <iostream>
#include <vector>
#define int long long
using namespace std;
typedef vector<int> Array;
typedef vector<Array> Mat;

Mat identify(int n) {
	Mat mat(n, Array(n, 0));
	for (int i = 0; i < n; i++) mat[i][i] = 1;
	return mat;
}

Mat multiply(Mat a, Mat b, int mod) {
	Mat mat(a.size(), Array(b[0].size(), 0));
	for (int i = 0; i < a.size(); i++) {
		for (int j = 0; j < b[0].size(); j++) {
			for (int k = 0; k < b.size(); k++) {
				mat[i][j] += a[i][k] * b[k][j];
				mat[i][j] %= mod;
			}
		}
	}
	return mat;
}

Mat powmat(Mat a, int n, int mod) {
	if (n == 0) return identify(a.size());
	if (n % 2 == 0) return powmat(multiply(a, a, mod), n / 2, mod);
	return multiply(a, powmat(a, n - 1, mod), mod);
}

//a * b(縦ベクトル). a[0].size() == b.size()
Array multiply(Mat a, Array b, int mod) {
	Array ret(a.size(), 0);
	for (int i = 0; i < a.size(); i++) {
		for (int j = 0; j < b.size(); j++) {
			ret[i] += a[i][j] * b[j];
		}
	}
	return ret;
}

int solve(int n) {
	int mod = 1000000007;
	int i, j;
	
	//dp[i][仕切り数j][個数偶奇k]. vector(i)[2 * j + k] = dp[i][j][k]と表現すると、
	//初期値：vector(0)[0] = 1, vector(0)[0以外] = 0.
	//求めたい：vector(n + 10)[30] + vector(n + 10)[31].
	//
	//dp[i][j][k] -> dp[i+1][j'][k']と遷移するとき、2j' + k'行2j + k列目に遷移数(1)を書いた行列mat
	//を作ると、vector(n) = mat^n * vector(0). mat部分は繰り返し累乗で32^3 * logNくらい.
	Array vec0(32, 0);
	vec0[0] = 1;
	
	Mat mat(32, Array(32, 0));
	
	//遷移行列の生成. [仕切り数i][個数偶奇j].
	for (i = 0; i <= 15; i++) {
		for (j = 0; j < 2; j++) {
			//仕切る
			if (i < 15 && (i >= 5 || j == 0)) {
				mat[2 * (i + 1) + 0][2 * i + j] += 1;
			}
			//仕切らない
			mat[2 * i + (!j)][2 * i + j] += 1;
		}
	}
	
	//行列計算
	Mat resMat = powmat(mat, n + 10, mod);
	Array resVec = multiply(resMat, vec0, mod);
	
	return (resVec[30] + resVec[31]) % mod;
}

signed main() {
	int T;
	cin >> T;
	while (T--) {
		int n;
		cin >> n;
		cout << solve(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 4616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    vector<ll> c(3);
    ll N;
    cin >> c[0] >> c[1] >> c[2] >> N;

    sort(ALL(c), greater<ll>());

    ll ans = 0;

    ll ni = N / c[0];
    rep(i, ni + 1) {
        ll resi = N - i * c[0];
        ll nj = resi / c[1];
        rep(j, nj + 1) {
            ll resj = resi - j * c[1];
            // cout << "(" << i << ", " << j << ") res:" << resj << endl;
            if (resj % c[2] == 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

ll f(ll b, ll n) {
  if (b < 2) return -1;
  if (n < b) return n;
  else return f(b, n/b) + (n%b);
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, s; cin >> n >> s;
  if (n == s){
    cout << n+1 << "\n";
    return 0;
  }
  ll r = sqrt(n);
  for (ll b = 2; b <= r; ++b) {
    if (f(b,n) == s) {
      cout << b << "\n";
      return 0;
    }
  }
  for (ll p = r; p > 0; --p) {
    ll b = (n-s)/p+1;
    if (f(b,n) == s) {
      cout << b << "\n";
      return 0;
    }
  }
  cout << "-1\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;


int main()
{
	iostream::sync_with_stdio(false);
	int r;
	
	cin >> r;





	cout << pow(r, 2);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MOD = 1e9 + 7;
const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
const ll MAX = 2e5 + 50 ;
const ll oo = 1e16;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
long long gcd(long long  a, long long  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n , m , q , ans; string s ;
vector < pair < char , char > > qr ;

bool solve(int ind , bool left){
    //cout << ind << "-> ";
    -- ind ;

    for(int i = 0 ; i < q && ind != -1 && ind != n; ++i){
        if(qr[i].f != s[ind]) continue;
        if(qr[i].s =='L') --ind;
        else ++ind;
    }
   // cout << ind << ' ' << left << '\n';
    if((ind != -1 && ind!= n) || (ind == -1 && !left) ||(ind == n && left))
            return false;

    return true;
}

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

    cin >> n >> q ;
    cin >> s ;
    for(int i = 0 ; i < q ; ++i){
        char a , b ;
        cin >> a >> b ;
        qr.pb({a , b});
    }

    ans = n ;

    int lo = 1 , hi = n ;
    int best = 0 ;
    while(lo <= hi){
        int mid = (lo + hi) >> 1;
        if(solve(mid , true)){
            best = mid ;
            lo = mid + 1;
        }
        else
            hi = mid - 1;
    }

    ans -= best;
    lo = 1 , hi = n;
    //cout << best << '\n';
    best = n + 1 ;

    while(lo <= hi){
        int mid = (lo + hi) >> 1;
        if(solve(mid , false)){
            best = mid ;
            hi = mid - 1;
        }
        else
            lo = mid + 1;
    }

    ans -= (n - best + 1);
    //cout << best << '\n';
    cout << ans << '\n';

     return 0;
}


Measured memory_bytes: 1100
N = int(input())
Ai_list=[]
Ai_product=1
Ai_sum=0

for Ai in input().split(' '):
  Ai = int(Ai)
  Ai_product *= Ai
  Ai_list.append(Ai)
  
for Ai in Ai_list:
  Ai_sum += Ai_product/Ai
  
print(Ai_product/Ai_sum)

Measured memory_bytes: 3060
// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }

using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 100005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
int p[MAX_N];
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
//  WF("output.txt");
	DF("err.txt");

	int N;
	scanf("%d", &N);
	map <int, int> M;
	for (int i = 0; i < N; i++) {
		int val;
		scanf("%d", &val);
		M[val]++;
	}
	int res = 0;
	for (auto em : M) {
		res += em.Y & 1;
	}
	printf("%d\n", res);
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;

const int maxn = 1e5 + 1;
const ll inf = 2e18, mod = 1e9 + 7;

int n, a[maxn], mn, mx, ind;
pii ans[maxn];

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

	cin >> n;
	fori (i, 0, n)
		cin >> a[i];
	mn = min_element(a, a + n) - a;
	mx = max_element(a, a + n) - a;
	if (abs(a[mx]) < abs(a[mn]))
		fori (i, 0, n)
		{
			ans[ind++] = mp(mn + 1, i + 1);
			a[i] += a[mn];
		}
	else
		fori (i, 0, n)
		{
			ans[ind++] = mp(mx + 1, i + 1);
			a[i] += a[mx];
		}
	if (a[mx] != 0)
	{
		if (a[mx] < 0)
			forb (i, n - 1, 1)
				ans[ind++] = mp(i + 1, i);
		else
			fori (i, 1, n)
				ans[ind++] = mp(i, i + 1);
	}
	else if (a[mn] != 0)
		forb (i, n - 1, 1)
			ans[ind++] = mp(i + 1, i);
	cout << ind << endl;
	fori (i, 0, ind)
		cout << ans[i].ff << ' ' << ans[i].ss << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int N, prev, next, con, res;
    cin >> N;
    con = 1;
    res = 0;
    prev = 0;
    for (int n = 0; n < N; n++) {
        cin >> next;
        if (prev == next) {
            con++;
        } else {
            res += con / 2;
            con = 1;
        }
        prev = next;
    }
    res += con / 2;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
s=[]

#与えられた領域の上下左右を塗れないマスで埋める
s.append('.'*(W+2))
for i in range(H):
  s.append('.'+input()+'.')
s.append('.'*(W+2))

#隣接領域について判定
for j in range(1,H+1):
  for i in range(1,W+1):
    if s[j][i]=='#' and (s[j-1][i]=='.' and s[j+1][i]=='.' and s[j][i-1]=='.' and s[j][i+1]=='.'):
      print('No')
      exit()
      
print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define maxn 250010
#define N 1010
using namespace std;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int prime[maxn], tot_prime;
ll res[N][N];
set<ll> S;
ll gcd(ll a, ll b)
{
	ll y = a % b;
	while (y)
	{
		a = b;
		b = y;
		y = a % b;
	}
	return b;
}
bool check(int x)
{
	for (int i = 2; i <= x - 1; i++)
		if (x % i == 0) return false;
	return true;
}
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			res[i][j] = 1;
	ll T = 1e15;
	for (int i = 2; i <= 10000; i++)
		if (check(i)) prime[++tot_prime] = i;
	int cur = 0;
	for (int i = 2; i <= n + n; i += 2)
	{
		cur++;
		for (int j = 1; j <= i && j <= n; j++)
		{
			int x = j, y = i - j;
			if (y <= n) res[x][y] *= prime[cur];
		}
	}
	int st = 1 - n;
	if (st % 2) st++;
	for (int i = st; i <= n - 1; i += 2)
	{
		cur++;
		for (int j = 1; j <= n; j++)
		{
			int x = j, y = x - i;
			if (x > 0 && y > 0 && x <= n && y <= n) res[x][y] *= prime[cur];
		}
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if ((i + j) % 2 == 0) S.insert(res[i][j]);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if ((i + j) % 2)
			{
				for (int k = 0; k <= 3; k++)
				{
					int tx = i + dx[k], ty = j + dy[k];
					if (tx && ty && tx <= n && ty <= n)
					{
						res[i][j] = res[i][j] / gcd(res[i][j], res[tx][ty]) * res[tx][ty];
						assert(res[i][j] <= T);
					}
				}
			ll pre = res[i][j];
			while (S.find(res[i][j]) != S.end()) res[i][j] += pre;
			S.insert(res[i][j]);
			res[i][j]++;
			}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			printf("%lld ", res[i][j]);
		}
		puts("");
	}
}

Measured memory_bytes: 20992
#include<stdio.h>
#define MAX 10000
#define NUL -1

struct Node{
  int l,p,r;
};


int D[MAX], H[MAX];
struct Node T[MAX];
int n;

void ST(int);
int DE(int);
int SI(int);

int main()
{
  int l,r,v,i;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    T[i].p = NUL;
  }

  for ( i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l, &r);

    T[v].l = l;
    T[v].r = r;

    if ( l != NUL ) T[l].p = v;
    if ( r != NUL ) T[r].p = v;

  }

  for ( i = 0; i < n; i++ ){

    D[i] = DE(i);
    H[i] = 0;

  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NUL && T[i].r == NUL ) { // leaf
      H[i] = 0;
      int p = T[i].p;
      int z = 1;
      while(1){
    if ( p == NUL ) break;
    if ( H[p] < z ) H[p] = z;
    z++;
    p = T[p].p;
      }
    }
  }

  for ( i = 0; i < n; i++ ) ST(i);


  return 0;
}

int SI(int u){
  if ( T[u].p == NUL ) return NUL;
  if ( T[T[u].p].l != u && T[T[u].p].l != NUL ) return T[T[u].p].l;
  if ( T[T[u].p].r != u && T[T[u].p].r != NUL ) return T[T[u].p].r;
  return NUL;
}

int DE(int u){
  int d = 0;
  while(1){
    u = T[u].p;
    if ( u == NUL ) break;
    d++;
  }
  return d;
}


void ST(int u){
  int deg = 0;

  printf("node %d: ", u);

  printf("parent = %d, ", T[u].p);
  printf("sibling = %d, ", SI(u));

  if ( T[u].l != NUL ) deg++;
  if ( T[u].r != NUL ) deg++;

  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].p == NUL ){
    printf("root\n");
  } else if ( T[u].l == NUL && T[u].r == NUL ){
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

Measured memory_bytes: 2764