akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
MOD = 10**9+7

n, m = map(int, input().split())
a = [1]+[-1]*(n)
cnt = 0
for _ in range(m):
    a[int(input())] = 0

a[1] *= -1
for i in range(2, n+1):
    if a[i] != 0:
        a[i] = ( max(0, a[i-1]) + max(0, a[i-2]) ) % MOD

print(a[-1])

Measured memory_bytes: 41804
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
const ll M = 1e9+7;
const int maxn = 2e5+5;
int n;
int fa[maxn],sz[maxn],p[maxn],p2[maxn];
vector<int> G[maxn];
ll quick_pow(ll a,ll b)
{
    if(b==0) return 1;
    if(b&1) return (ll)a%M*quick_pow(a,b-1)%M;
    ll t=quick_pow(a,b/2)%M;
    return t*t%M;
}
ll inv(ll a,ll m)
{
    return quick_pow(a,m-2);
}
void dfs(int now,int f)
{
    fa[now] = f;
    sz[now] = 1;
    for(int i=0;i<G[now].size();i++)
    {
        if(G[now][i]==f) continue;
        dfs(G[now][i],now);
        sz[now]+=sz[G[now][i]];
    }
}
int main()
{
    ios::sync_with_stdio(0);
    p2[0] = 1;
    cin>>n;
    for(int i=1;i<=n;i++) p2[i] = p2[i-1]*2%M;
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1,-1);
    ll ans = 0;
    ll inv2 = inv(2,M);
    for(int i=1;i<=n;i++)
    {
        ll now = 1;
        int tot = G[i].size();
        if(tot==1) continue;
        for(int j=0;j<tot;j++)
        {
            int siz;
            int v = G[i][j];
            if(v==fa[i]) siz = n-sz[i];
            else siz = sz[v];
            p[j] = (1-inv(p2[siz],M)%M+M)%M;  //连通块中至少含有一个黑点的概率
            now = (now*(1-p[j]+M)%M)%M;
        }
        ll cur = now;
        for(int j=0;j<tot;j++)
        {
            cur = (cur+now*inv((1-p[j]+M)%M,M)%M*p[j]%M)%M;
        }
        ans = (ans+inv2*(1-cur+M)%M)%M;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 23168
using System;
using System.Text;

class Program
{

    public class Node
    {
        public static Node First = null;
        public static Node Last = null;
        public int Number;
        public Node Prev = null;
        public Node Next = null;

        public void Delete()
        {
            if(this.Prev != null)
            {
                this.Prev.Next = this.Next; 
            } else
            {
                First = this.Next;
            }
            if(this.Next != null)
            {
                this.Next.Prev = this.Prev;
            } else
            {
                Last = this.Prev;
            }
        }

        public void Add()
        {
            if(First == null)
            {
                First = this;
                Last = this;
            } else
            {
                First.Prev = this;
                this.Next = First;
                First = this;
            }
        }


    }
    public void Proc()
    {
        int commandCount = int.Parse(Console.ReadLine());
        for(int i=0; i<commandCount; i++)
        {
            string[] inpt = Console.ReadLine().Split(' ');
            int num = 0;
            if(inpt.Length > 1)
            {
                num = int.Parse(inpt[1]);
            }

            switch(inpt[0])
            {
                case "insert":
                    Node nd = new Node();
                    nd.Number = num;
                    nd.Add();
                    break;
                case "delete":
                    Node n = Node.First;
                    while(n != null)
                    {
                        if(n.Number == num)
                        {
                            n.Delete();
                            break;
                        } else
                        {
                            n = n.Next;
                        }
                    }
                    break;
                case "deleteFirst":
                    Node.First.Delete();
                    break;
                case "deleteLast":
                    Node.Last.Delete();
                    break;
            }
        }
        StringBuilder ans = new StringBuilder();
        Node node = Node.First;
        while (node != null)
        {
            if (ans.Length > 0)
            {
                ans.Append(" ");
            }
            ans.Append(node.Number);
            node = node.Next;
        }

        Console.WriteLine(ans.ToString());

    }

    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

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

int a,b;
char grid[111][111];
int main(){
    scanf("%d%d",&a,&b);
    for(int i=0;i<50;i++){
        for(int j=0;j<100;j++){
            if(i%2==0 && j%2==0 && a>1)grid[i][j] = '.', a--;
            else grid[i][j] = '#';
        }
    }
    for(int i=99;i>=50;i--){
        for(int j=0;j<100;j++){
            if(i%2==0 && j%2 == 0 && b>1)grid[i][j] = '#', b--;
            else grid[i][j] = '.';
        }
    }
    printf("100 100\n");
    for(int i=0;i<100;i++){
        printf("%s\n", grid[i]);
    }
}



Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
	int n, m;
	scanf("%d", &n);
	m = n;

	int a[n];

	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}

	while (n > 0) {
		printf("%d ", a[n - 1]);
		n -= 2;
	}
	if (n % 2) {
		n = 2;
	} else {
		n = 1;
	}
	while (n < m) {
		printf("%d ", a[n - 1]);
		n += 2;
	}


	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3640
X, N = map(int, input().split())
P = set(map(int, input().split()))

for i in range(100):
    if not X + i in P:
        p = X + i
        break

for i in range(100):
    if not X - i in P:
        q = X - i
        break

if abs(X-p) == abs(X-q):
    print(q)
elif abs(X-p) > abs(X-q):
    print(q)
else:
    print(p)

Measured memory_bytes: 61868
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main()  {
	var N, T, A, H int
	fmt.Scan(&N)
	fmt.Scan(&T)
	fmt.Scan(&A)

	minDiff := math.MaxFloat64
	min := N+1
	for i := 0; i < N; i++ {
		fmt.Scan(&H)
		t := math.Abs(float64(A) - (float64(T) - float64(H)*0.006))
		if t < minDiff {
			min = i
			minDiff = t
		}
	}
	fmt.Println(min+1)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
#ifdef _WIN32
#include <windows.h>
#define print(x) PRINT(x, #x)
template<typename T> inline const void PRINT(T VARIABLE, string NAME)
{
#ifndef ONLINE_JUDGE /// ONLINE_JUDGE IS DEFINED ON CODEFORCES
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, 10);
    cerr << NAME << " = " << VARIABLE;
    SetConsoleTextAttribute(hConsole, 7);
    cerr << '\n';
#endif
}
#else
#define print(x) 0
#endif
struct pair_hash
{
    template<typename T1, typename T2>
    size_t operator () (const pair<T1, T2> &p) const
    {
        auto h1 = hash<T1> {}(p.first);
        auto h2 = hash<T2> {}(p.second);
        return h1 ^ h2;
    }
};
typedef long long ll;
typedef unsigned long long ull;
const ll INFLL = 2 * (ll)1e18 + 100;
const int INFINT = 2 * (int)1e9 + 100;
//ifstream fin(".in");
//ofstream fout(".out");
void die()
{
    cout << "-1\n";
    exit(0);
}
const int NMAX = 3 * 1e5 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;
const int seed = 1e3 + 7;

int n;
int a[NMAX];
ll sol = 1, scd = 1;

int main()
{
    FASTIO;
    cin >> n;
    for1(i, n) cin >> a[i];
    for1(i, n)
       sol *= 3;
    for1(i, n)
        if(a[i] % 2 == 0) scd *= 2;

    cout << sol - scd;

    return 0;
}




Measured memory_bytes: 256
import copy

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

N = int(input())
A = list(map(int, input().split()))
F = copy.copy(A)
B = copy.copy(A)
for i in range(N - 1):
  F[i + 1] = gcd(F[i + 1], F[i])
for i in range(N - 2, -1, -1):
  B[i] = gcd(B[i], B[i + 1])
ans = max(F[N-2], B[1])
for i in range(1, N - 1):
  ans = max(ans, gcd(F[i-1], B[i+1]))
print(ans)


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

int main ()
{
	int array[3];
    int countFive = 0;
    int countSeven = 0;
    cin >> array[0] >> array[1] >> array[2];

    for(int i=0;i<3;i++){
        if(array[i] == 5){
            countFive++;
        }
        if(array[i] == 7){
            countSeven++;
        }
    }
    if(countFive == 2 && countSeven == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int Time[3][2][3] = {0} ;
    int stay[3] = {0} ;

    for ( int i = 0 ; i < 3 ; i++ )
    {
        for ( int j = 0 ; j < 2 ; j++ )
        {
            for ( int k = 0 ; k < 3 ; k++ )
            {
                cin >> Time[i][j][k] ;
            }
        }
    }

    for ( int i = 0 ; i < 3 ; i++ )
    {
        if ( Time[i][1][2] < Time[i][0][2] )
        {
            if ( Time[i][1][1] == 0 )
            {
                Time[i][1][0]-- ;
                Time[i][1][1] += 59 ;
                Time[i][1][2] += 60 ;
            }
            else
            {
                Time[i][1][1]-- ;
                Time[i][1][2] += 60 ;
            }
        }
        if ( Time[i][1][1] < Time[i][0][1] )
        {
            Time[i][1][0]-- ;
            Time[i][1][1] += 60 ;
        }

        for ( int j = 0 ; j < 3 ; j++ )
        {
            stay[j] = Time[i][1][j] - Time[i][0][j] ;
        }

        printf( "%d %d %d\n", stay[0] , stay[1] , stay[2] ) ;
    }

    return 0 ;
}

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

#define  prec(n)        fixed<<setprecision(n)
#define  optimize       ios::sync_with_stdio(0); cin.tie(0);
#define  PI             acos(-1.0)
#define  RESET(a, b)    memset(a, b, sizeof(a))
#define  pb             push_back
#define  pii            pair<int,int>
#define  pll            pair<ll,ll>
#define  vv             vector<int>
#define  ff             first
#define  ss             second
#define  sz(v)          v.size()
#define  all(v)         v.begin(),v.end()

int const MOD=(int) 1e9+7;
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
inline ll mod(ll a, ll m){ if(a<0) return m-(abs(a)%m); else if(a<m) return a; else return (a%m); }
const int N = 2000007;
const int MAX=1000005;
int main()
{
    optimize
    ll n;
    cin>>n;
    ll x=modPow(10,n);
    ll y=modMul(2,modPow(9,n));
    ll ans=modAdd(modSub(x,y),modPow(8,n));
    cout<<ans<<endl;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int K,X;
    Scd2(K,X);

    YesNo( K*500 >= X );

    return 0;
}



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

int main(){
  int64_t N;
  cin>>N;
  vector<int64_t> A(5);

  for(int i=0;i<5;++i){
    cin>>A.at(i);
  }

  vector<int64_t> m(5);
  m.at(0)=A.at(0);
  for(int i=1;i<5;++i){
    m.at(i)=min(m.at(i-1),A.at(i));
  }

  vector<int64_t> e(5);
  
  for(int i=0;i<5;++i){
    
    if(i==0){
    e.at(0)=(N+A.at(0)-1)/A.at(0);
    }
    
    else{
    if(m.at(i-1)<=A.at(i)){
      e.at(i)=e.at(i-1)+1;
    }
    else{
      e.at(i)=((N+A.at(i)-1)/A.at(i))+i;
    }
  }
  }

  cout<<e.at(4)<<endl;

}

Measured memory_bytes: 256
#include "iostream"
#include "random"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"
#include "set"
#include "climits"
#include "iomanip"

using namespace std;
using ll = long long int;


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

	int N, M;
	cin >> N;
	map<string, int>m;
	vector<int>v(N);
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s >> v[i];
		m[s] = i;
	}
	cin >> M;
	vector<vector<int>>edge(N);
	for (int i = 0; i < M; i++) {
		string s, t;
		cin >> s >> t;
		int a = m[s], b = m[t];
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	vector<int>p(N, -1);
	for (int i = 0; i < N; i++) {
		if (p[i] != -1)continue;
		queue<int>Q;
		p[i] = i;
		Q.push(i);
		while (!Q.empty()) {
			int cn = Q.front();
			Q.pop();
			for (auto j : edge[cn]) {
				if (p[j] == -1) {
					p[j] = i;
					Q.push(j);
				}
			}
		}
	}
	vector<int>mi(N, 1000000000);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		mi[p[i]] = min(mi[p[i]], v[i]);
	}
	for (int i = 0; i < N; i++) {
		ans += mi[p[i]];
	}
	cout << ans << endl;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

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

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

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

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

bool Palind(string s) {
	return s == string(s.rbegin(), s.rend());
}

int main() {
	int sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty;
	int xdist=tx-sx, ydist=ty-sy;

	for(int i=0; i<xdist; i++) cout<<"R";
	for(int i=0; i<ydist; i++) cout<<"U";
	for(int i=0; i<xdist; i++) cout<<"L";
	for(int i=0; i<ydist+1; i++) cout<<"D";
	for(int i=0; i<xdist+1; i++) cout<<"R";
	for(int i=0; i<ydist+1; i++) cout<<"U";
	cout<<"LU";
	for(int i=0; i<xdist+1; i++) cout<<"L";
	for(int i=0; i<ydist+1; i++) cout<<"D";
	cout<<"R"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main() {

	int a, b, c, ob=0, dia=0;

	while(scanf("%d, %d, %d", &a, &b, &c)!=EOF) {
		if(c*c==a*a+b*b)
			ob++;
		else if(a==b)
			dia++;
	}

	cout << ob << endl << dia << endl;

	return 0;

}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define rep(i,n) for(i=0;i<n;i++)
#define PI 3.14159265358979323846264338327950L
int main(){
    int n,i,j;
    scanf("%d",&n);
    int a[n],cnt=0;
    rep(i,n) scanf("%d",&a[i]);
    int min=a[0];
    rep(i,n){
        if(a[i]<=min){
            min=a[i];
            cnt++;
        }
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 2512
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
num = [0] * 100010
b = [0] * q
c = [0] * q
for i in range(q):
    b[i], c[i] = map(int, input().split())

for i in a:
    num[i] += 1

s = sum(a)

for i in range(q):
  s+=(c[i]-b[i])*num[b[i]]
  num[c[i]] += num[b[i]]
  num[b[i]] = 0
  print(s)

Measured memory_bytes: 86960
///apigs property
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
using namespace std;
typedef long long ll;
ll q, dp[105][100005], a[555555] , b[555555], k, l, m, n, o, p;
map < ll , ll > mp;
vll adj[555555];
const ll mod = 1e9+7;
ll mem(ll idx , ll ct){
    if(idx > n)return 0;
    if(ct + b[idx] > m){
        return mem(idx + 1 , ct);
    }
    ll &r = dp[idx][ct];
    if(r != -1)return r;
    return r = max(mem(idx + 1 , ct + b[idx]) + a[idx] , mem(idx + 1 , ct));
}
int main() {
    memset(dp , -1 , sizeof dp);
    fast , cin >> n >> m;
    for(ll i = 1 ; i <= n ; i++)cin >> b[i] >> a[i];
    cout << mem(1 , 0);
}


Measured memory_bytes: 98664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    string S;
    cin >> S;
    int N = S.size();
    ll ans = 0;
    REP(bit, 1 << (N-1)) {
        int s = 0;
        REP(i, N-1) {
            if (bit >> i & 1) {
                ans += stoll(S.substr(s, i-s+1));
                s = i + 1;
            }
        }
        ans += stoll(S.substr(s, N));
    }
    cout << ans << endl;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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


const string YES = "Yes";
const string NO = "No";

void func(std::string S){

    if(S=="AAA" || S=="BBB"){
        cout<<NO<<endl;
    }
    else{
        cout<<YES<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    func(S);
    return 0;
}


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

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

  string s; cin >> s;
  for(int i = 0; i < s.size()-1; i++){
    if(s[i] == s[i+1]){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
    if(i+2 < s.size() && s[i] == s[i+2]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;

  return 0;
}


Measured memory_bytes: 512
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] info = new String[n];

        for(int i = 0;i < n;i++){
            info[i] = sc.next() + "_" + (1100 - sc.nextInt()) + "_" +(i+1);
        }
        Arrays.sort(info);
        for(int i = 0;i < n;i++){
            String[] s = info[i].split("_");
            System.out.println(s[2]);
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  vector<int> T(N);
  for (int i = 0; i < N; i++) cin >> S.at(i) >> T.at(i);
  string X;
  cin >> X;
  bool F = false;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (F) ans += T.at(i);
    if (X == S.at(i)) F = true;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        String s = sc.next();
        Set<String> setA = new HashSet<>(), setB = new HashSet<>();

        int max = 0;
        for (int i = 1; i < n; i++) {
            int count = 0;
            String ss = s.substring(0, i);
            String st = s.substring(i, s.length());
            for (int j = 0; j < ss.length(); j++) {
                setA.add(ss.substring(j, j + 1));
            }
            for (int j = 0; j < st.length(); j++) {
                setB.add(st.substring(j, j + 1));
            }
            List<String> list = new ArrayList<>(setA);
            for (String str : list) {
                if (setB.contains(str)) {
                    count++;
                }
            }
            max = Math.max(max, count);
            setA.clear();
            setB.clear();
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 22996
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int d = 0;
        int m = 0;
        String str;
        char s[][] = new char [H][W];
        int Cost[][] = new int [H][W];
        for(int i=0;i<H;i++){
          str = sc.next();
          for(int j=0;j<W;j++){
            s[i][j] = str.charAt(j);
            Cost[i][j] = 10000;
            if(s[i][j]=='.')
              d++;
          }
        }
        Cost[0][0] = 0;

        for(int k=0;k<H*W;k++){
          for(int i=0;i<H;i++){
            for(int j=0;j<W-1;j++){
              if(s[i][j]=='.' && s[i][j+1]=='.'){
                Cost[i][j]=Math.min(Cost[i][j+1]+1,Cost[i][j]);
                Cost[i][j+1]=Math.min(Cost[i][j]+1,Cost[i][j+1]);
              }  
              else{
                Cost[i][j]=Math.min(Cost[i][j+1]+10000,Cost[i][j]);
                Cost[i][j+1]=Math.min(Cost[i][j]+10000,Cost[i][j+1]);
              }
            }
          }
          for(int i=0;i<H-1;i++){
            for(int j=0;j<W;j++){
              if(s[i][j]=='.' && s[i+1][j]=='.'){
                Cost[i][j]=Math.min(Cost[i+1][j]+1,Cost[i][j]);
                Cost[i+1][j]=Math.min(Cost[i][j]+1,Cost[i+1][j]);
              }  
              else{
                Cost[i][j]=Math.min(Cost[i+1][j]+10000,Cost[i][j]);
                Cost[i+1][j]=Math.min(Cost[i][j]+10000,Cost[i+1][j]);
              }
            }
          }

        } 
        if(Cost[H-1][W-1]<10000){
          m = Cost[H-1][W-1];
          System.out.println(d-m-1);
        }
        else
          System.out.println(-1);
//        System.out.println(d +" "+ m);
         
	}

}


Measured memory_bytes: 25296
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <cstring>
using namespace std;

vector<string> split(string s,const string &t) {
  vector<string> v;
  for (int p = 0; (p = s.find(t)) != s.npos; ) {
    v.push_back(s.substr(0,p));
    s = s.substr(p+t.size());
  }
  v.push_back(s);
  return v;
}

typedef long long ll;
const int MAX_LEN = 201;
const ll mod = 1000000007ll;
ll dp[52][52][52][52];
int Na,Nt,Ng,Nc;
int m;

map<string, vector<string> > rules;

void update(const char symbol,const int sum) {
  for (int a = 0; a <= sum && a <= Na; ++a) {
    for (int t = 0; a+t <= sum && t <= Nt; ++t) {
      for (int g = 0; a+t+g <= sum && g <= Ng; ++g) {
        int c = sum-a-t-g;
        if (c > Nc) continue;
        switch(symbol) {
        case 'A':
          dp[a+1][t][g][c] += dp[a][t][g][c];
          dp[a+1][t][g][c] %= mod;
          break;
        case 'T':
          dp[a][t+1][g][c] += dp[a][t][g][c];
          dp[a][t+1][g][c] %= mod;
          break;
        case 'G':
          dp[a][t][g+1][c] += dp[a][t][g][c];
          dp[a][t][g+1][c] %= mod;
          break;
        case 'C':
          dp[a][t][g][c+1] += dp[a][t][g][c];
          dp[a][t][g][c+1] %= mod;
          break;
        }
      }
    }
  }
}

vector<string> terminals;

void dfs(const string &rule) {
  const vector<string> &children = rules[rule];
  for(vector<string>::const_iterator it = children.begin();
      it != children.end(); ++it) {
    const string &term = *it;
    if(terminals.size() > Na+Nt+Nc+Ng) break;
    if(term[0] == '[') {
      // terminal
      terminals.push_back(term);
      if(terminals.size() > Na+Nt+Nc+Ng) break;
    } else {
      dfs(term);
    }
  }
}

int main() {
  cin>>Na>>Nt>>Ng>>Nc;
  cin>>m; cin.ignore();
  terminals.clear();

  string firstRule = "";
  string line;
  for (int i=0; i<m; ++i) {
    getline(cin, line);
    vector<string> vs = split(line, " ");
    vector<string> children;
    for (int j=1; j<vs.size(); ++j) children.push_back(vs[j]);
    rules[vs[0].substr(0,vs[0].length()-1)] = children;
    if (firstRule == "") firstRule = vs[0].substr(0,vs[0].length()-1);
  }

  memset(dp, 0, sizeof(dp));
  dp[0][0][0][0] = 1;
  dfs(firstRule);
  if (terminals.size() != Na+Nt+Nc+Ng) {
    cout<<0<<endl;
    return 0;
  }

  for (int i=0; i<terminals.size(); ++i) {
    const string &term = terminals[i];
    for (int j=1; j<term.length()-1; ++j)
      update(term[j], i);
  }
  cout<<dp[Na][Nt][Ng][Nc]<<endl;
}

Measured memory_bytes: 58380
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int s1 = Integer.parseInt(s.substring(0,2));
        int s2 = Integer.parseInt(s.substring(2,4));
        int jnum = 4;//1,yymm 2,mmyy 3,ambiguous 4,na

        if((s1 > 12 && (1<=s2 && s2<=12)) || (s1 == 0 && (1<=s2 && s2<=12))){
            jnum = 1;
        }else if(((1<=s1 && s1<=12) && s2 > 12) || ((1<=s1 && s1<=12) && s2 == 0)){
            jnum = 2;
        }else if((1<=s1 && s1<=12) && (1<=s2 && s2<=12)){
            jnum = 3;
        }else if((s1 > 12 && s2> 12)||(s1 == 0 && s2 == 0)){
            jnum = 4;
        }

        if(jnum == 1){
            System.out.println("YYMM");
        }else if(jnum == 2){
            System.out.println("MMYY");
        }else if(jnum == 3){
            System.out.println("AMBIGUOUS");
        }else if(jnum == 4){
            System.out.println("NA");
        }
    }
}


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

int main()
{
    int n;
    cin >> n;
    ll ans = 1e18;
    ll tmp = 0;
    ll a[n];
    rep(i, n)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
        ans /= a[i];
    }
    if (ans == 0)
    {
        cout << -1 << endl;
        return 0;
    }
    rep(i, n)
    {
        if (i == 0)
        {
            ans = a[0];
        }
        else
        {
            tmp = a[i];
            ans *= tmp;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4376
// D - Maze Master
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using vi = vector<int>;
using vvi = vector<vi>;

// BFS (幅優先探索)
// 文字列迷路Sについて、S[sh][sw]から各マスまでの最短コストをdist[h][w]に求める
#define HMAX 20
#define WMAX 20
#define INF 100000
vvi dist(HMAX+2, vi(WMAX+2, INF));//外周を壁で囲む (-1:未訪問, 0~<INF:訪問済&コスト, INF:壁)
void bfs(int sh, int sw){
	int dx[4]={0,-1,0,1}, dy[4]={-1,0,1,0};
	dist[sh][sw] = 0;//最短コスト
	queue<pair<int,int>> q;
	q.push({sh,sw});
	while(!q.empty()){
		int ph,pw; tie(ph,pw) = q.front(); q.pop();
		rp(k, 0, 4){//四方向
			int h = ph + dy[k], w = pw + dx[k];
			if(dist[h][w] > -1) continue;//壁・訪問済み
			dist[h][w] = dist[ph][pw] + 1;//最短コスト
			q.push({h,w});
		}
	}
}

int main(){
	int H,W; cin>>H>>W;
	rp(h, 1, H+1){
		string s; cin>>s;
		rp(w, 1, W+1) if(s[w-1]=='.') dist[h][w] = -1;//未訪問
	}

	int ans = 0;
	vvi dist_temp = dist;
	rp(h, 1, H+1){
		rp(w, 1, W+1){
			if(dist_temp[h][w]<0){
				dist = dist_temp;
				bfs(h,w);
				for(vi v:dist)for(int d:v) ans = max(ans, d==INF?-1:d);//壁は未訪問とみなす
			}
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); 
	cout.tie(0);
	int n, m, num, tmp;
	cin >> n >> m;
	vector<pair<pair<int,int>, pair<int,int> > > v;
	for(int i = 1, j = 0; i <= n; i++){
		cin >> num;
		tmp = num % 2;
		for(int j = 2; j <= m; j++){
			cin >> num;
			if(tmp){
				v.push_back({{i, j - 1}, {i, j}});
			}if(num % 2){
				tmp ^= 1;
			}
		}
		if(j & 1){
			v.push_back({{i - 1, m}, {i, m}});
		}if(tmp % 2){
			j ^= 1;
		}
	}
	cout << v.size() << endl;
	for(int i = 0; i < v.size(); i++){
		cout << v[i].first.first << " " 
				 << v[i].first.second << " " 
				 << v[i].second.first << " "
				 << v[i].second.second << endl;
	}
}

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

#define REP(w, n) for(int w=0;w<int(n);++w)

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

Measured memory_bytes: 256
H, W = map(int, input().split())
A = [list(input()) for h in range(H)]

currentNode = [0, 0]
visited = [["." for w in range(W)] for h in range(H)]
search = [(0, 1), (1, 0)]

while currentNode != [H-1, W-1]:
    visited[currentNode[0]][currentNode[1]] = "#"
    tovisit = []
    for s in search:
        nexth, nextw = currentNode[0] + s[0], currentNode[1] + s[1]
        if 0 <= nexth <= H-1 and 0 <= nextw <= W-1:
            if A[nexth][nextw] == "#" and visited[nexth][nextw] == ".":
                tovisit.append([nexth, nextw])
    if len(tovisit) == 1:
        currentNode = tovisit[0]
    else:
        print("Impossible")
        break
else:
    visited[currentNode[0]][currentNode[1]] = "#"
    flag = True
    for h in range(H):
        for w in range(W):
            if A[h][w] != visited[h][w]:
                flag = False
                break
        if not flag:
            print("Impossible")
            break
    else: print("Possible")

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
  int S, h, m, s;

  scanf("%d", &S);
  h = S/3600;
  m = (S - 3600*h)/60;
  s = S - 3600*h - 60*m;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define REPS(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define RREP(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define RREPS(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define BIT(n) ((int)(1) << (n))
#define ALL(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    std::string s;
    cin >> n >> s;
    std::vector<int> r(n, 0);
    std::vector<int> g(n, 0);
    std::vector<int> b(n, 0);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            r[i] = 1;
        } else if (s[i] == 'G') {
            g[i] = 1;
        } else {
            b[i] = 1;
        }
        if (i != 0) {
            r[i] += r[i - 1];
            g[i] += g[i - 1];
            b[i] += b[i - 1];
        }
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (s[i] == s[j]) {
                continue;
            }
            int k = 2 * j - i;
            if (j + 1 >= n) {
                continue;
            }
            if ((s[i] == 'R' && s[j] == 'G') || (s[j] == 'R' && s[i] == 'G')) {
                sum += b[n - 1] - b[j];
                if (k < n) {
                    if (b[k] - b[k - 1] > 0) {
                        sum--;
                    }
                }
            } else if ((s[i] == 'B' && s[j] == 'G') || (s[j] == 'B' && s[i] == 'G')) {
                sum += r[n - 1] - r[j];
                if (k < n) {
                    if (r[k] - r[k - 1] > 0) {
                        sum--;
                    }
                }
            } else {
                sum += g[n - 1] - g[j];
                if (k < n) {
                    if (g[k] - g[k - 1] > 0) {
                        sum--;
                    }
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3720
#include<iostream>
#include<vector>
#include<cassert>

using namespace std;
typedef vector<char> vc;
typedef vector<vc> vvc;

/*
row:6 column:8
vector<string> G;
G.resize(6);
G[0] = "";
G[1] = "";
G[2] = "";
G[3] = "";
G[4] = "";
G[5] = "";
class RC2x2 RC(G);
*/
class RC2x2
{
public:
  vector<string> G;
  
  RC2x2(vector<string> G2){
    G.resize(G2.size());
    for(int i=0;i<G2.size();i++)
      G[i] = G2[i]; 
  }
  
  void S(int x,int y)
  {
    char c = G[x][y];
    G[x][y] = G[x+1][y];
    G[x+1][y] = G[x+1][y+1];
    G[x+1][y+1] = G[x][y+1];
    G[x][y+1] = c;
  }
  
  void U()
  {
  S(0,2);
  char c;
  for(int i=0;i<2;i++)
    {
      c = G[2][0];
      G[2][0] = G[2][1];
      G[2][1] = G[2][2];
      G[2][2] = G[2][3];      
      G[2][3] = G[2][4];
      G[2][4] = G[2][5];
      G[2][5] = G[2][6];
      G[2][6] = G[2][7];
      G[2][7] = c;
    }
  }
  
  
  void D()
  { 
    S(4,2);
    char c;
    for(int i=0;i<2;i++)
      {
	c = G[3][7];
	G[3][7] = G[3][6];
	G[3][6] = G[3][5];
	G[3][5] = G[3][4];
	G[3][4] = G[3][3];
	G[3][3] = G[3][2];
	G[3][2] = G[3][1];
	G[3][1] = G[3][0];
	G[3][0] = c;
      }
  }
  
  
  void L()
  {
    S(2,0);
    char c;
    for(int i=0;i<2;i++)
      {
	c = G[0][2];
	G[0][2] = G[2][7];
	G[2][7] = G[3][7];
	G[3][7] = G[5][2];
	G[5][2] = G[4][2];
	G[4][2] = G[3][2];
	G[3][2] = G[2][2]; 
	G[2][2] = G[1][2];
	G[1][2] = c;
      }
  }
  
  
  void R()
  {
    S(2,4);
    char c;
    for(int i=0;i<2;i++)
      {
	c = G[5][3];
	G[5][3] = G[3][6];
	G[3][6] = G[2][6];
	G[2][6] = G[0][3];
	G[0][3] = G[1][3];
	G[1][3] = G[2][3];
	G[2][3] = G[3][3];
	G[3][3] = G[4][3];
	G[4][3] = c;
      }
  }
  
  
  void F()
  {
    S(2,2);
    char c;
    for(int i=0;i<2;i++)
      {
	c = G[1][2];
	G[1][2] = G[2][1];
	G[2][1] = G[3][1];
	G[3][1] = G[4][2];
	G[4][2] = G[4][3];     
	G[4][3] = G[3][4];
	G[3][4] = G[2][4];
	G[2][4] = G[1][3];
	G[1][3] = c; 
      }
  }
  
  void B()
  {
    S(2,6);
    char c;
    for(int i=0;i<2;i++)
      {
	c = G[2][5];
	G[2][5] = G[3][5];
	G[3][5] = G[5][3];
	G[5][3] = G[5][2];
	G[5][2] = G[3][0];
	G[3][0] = G[2][0];
	G[2][0] = G[0][2];
	G[0][2] = G[0][3];
	G[0][3] = c;
    }
  }
  
  void print()
  {
    for(int i=0;i<6;i++)
      {
	for(int j=0;j<8;j++)
	  {
	    cout << G[i][j];
	  }
	cout << endl;
      }
  }
  
};

int main()
{
  vector<string> G;
  G.resize(6);
  G[0] = "..rr....";
  G[1] = "..rr....";
  G[2] = "ggyybbww";
  G[3] = "ggyybbww";
  G[4] = "..oo....";
  G[5] = "..oo....";
  class RC2x2 RC(G);

  string s;
  cin >> s;
  for(int i=0;i<s.size();i++)
    {
      if(s[i] == 'U')
	RC.U();
      else if(s[i] ==  'D')
	RC.D();
      else if(s[i] == 'L')
	RC.L();
      else if(s[i] == 'R')
	RC.R();
      else if(s[i] == 'F')
	RC.F();
      else if(s[i] == 'B')
	RC.B();
      else 
	assert(false);
    }
  RC.print();

  return 0;
}

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

int main(){
  long s,c; cin >> s >> c;
  long ans;
  if(s >= c){
    ans = c/2;
  }else if(s != 0){
    ans = s + (c-2*s)/4;
  }else{
    ans = c/4;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<fstream>
#include<typeinfo>
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define repi(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j, a, b) for (ll j = a; j < b;j++)
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pii >
#define mod 1000000007
#define lim 100001
 
using namespace std;
ll factorial(ll n){return (n==1 || n==0) ? 1: n * factorial(n - 1); }
int max3(int a,int b,int c){ return max(a, max(c, b));}
int gcd(int a,int b){if(a==0){return b;}else{return gcd(b % a, a);}}
ll power(ll a, ll n){if(n==1) return a; else if(n==0) return 1; else{ ll r = power(a, n / 2); if(n%2==0) return r * r; else return r * a * r;}}
ll nCr(ll n, ll r) { return ((factorial(n)) / (factorial(n - r) * factorial(r))); }
void dfs(vector< vector<int > >& v,vi& check,int start){check[start - 1] = 1;repj(j, 0, v[start-1].size()){if(!check[v[start-1][j]-1]){dfs(v, check, v[start - 1][j]);}}}
bool isPrime(ll n) { if (n <= 1) return false;if (n <= 3)return true; if (n % 2 == 0 || n % 3 == 0)return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
//works under 2 till 1e12
 
int i, j;
 
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   string s1,s2;
   cin>>s1>>s2;
   ll ans=0;
   for(int i=0;i<s1.size();i++){
       if(s1[i]!=s2[i]) ans++;
   }
   cout<<ans;
   return 0;
}



Measured memory_bytes: 3812
/**
 * Training to the municipal stage of ROI
**/ 
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn for(int i=0;i<n;i++)
#define form for(int j=0;j<m;j++)
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define kek cout<<"\n"
#define all(v)        ((v).begin()), ((v).end())
#define pob pop_back()
int main()
{
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
int n; 
cin >> n; 
int* arr = new int[n]; 
for (int i = 0; i < n; i++) { 
cin >> arr[i]; 
} 
sort(arr, arr + n); 
int ans = 0; 
for (int i = 0; i < (n - 2); i++) { 
int k = i + 2; 
for (int j = i + 1; j < (n - 1); j++) { 
while (k < n && arr[i] + arr[j] > arr[k]) k++; 
ans += k - j - 1; 
} 
} 
cout<<ans;
return 0;


 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for(size_t i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    int left = 0;
    int right = K;
    ll ret = h[K-1] - h[0];
    ll temp = ret;
    for(size_t i = 0; i < (N-K); i++)
    {
        temp = temp + (h[K+i]-h[K+i-1]) - (h[i+1]-h[i]);
        if (temp < ret)
            ret = temp;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 640
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 100;
int n , a[N];

int main(){
  cin >> n;
  rep(i,0,n) cin >> a[i];
  int x = 0;
  rep(i,0,n) if(abs(a[i]) > abs(a[x]))
    x = i;
  vector<pii> op;
  auto go = [&](int x,int y) {
    a[y] += a[x];
    op.pb(mp(x , y));
  };
  rep(i,0,n) if(i != x) go(x , i);
  if(*min_element(a , a + n) >= 0) {
    rep(i,1,n) go(i - 1 , i);
  } else {
    per(i,1,n) go(i , i - 1);
  }
  cout << sz(op) << endl;
  rep(i,0,sz(op))
    cout << op[i].fi + 1 << " " << op[i].se + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#C - Count Order
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
l = list(range(1,N+1))
count = 0
ans_p = 0
ans_q = 0
for i in permutations(l):
    count += 1
#    print(i)
#    print(P)
    if i == P:
        ans_p = count
    else:
        pass
    if i == Q:
        ans_q = count
    else:
        pass
#print(ans_p,ans_q)
print(abs(ans_p - ans_q))

Measured memory_bytes: 39024
n = gets.to_i
abs = []
n.times do
  abs << gets.split.map(&:to_i)
end
cds = []
n.times do
  cds << gets.split.map(&:to_i)
end

abs.sort_by! { |a, b| [a, -b] }
cds.sort_by! { |c, d| [c, d] }

ans = 0
(0..n-1).each do |j|
  c = cds[j][0]
  d = cds[j][1]
  if abs.delete(abs.select { |a, b| a < c && b < d }.max_by { |a, b| b })
    ans += 1
  end
end

puts ans

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int p;cin>>p;
  int n;vector<int> ashu;cin>>n;
  for(int i=0;i<n;i++)
  {
    int x;cin>>x;
    ashu.push_back(x);
  }
  int max=p-ashu[ashu.size()-1]+ashu[0];
  for(int i=0;i<ashu.size()-1;i++) 
    {
        int y=ashu[i+1]-ashu[i];
        if(y>max){max=y;}
    }
   cout<<p-max;
}

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

int main() {
   ll n;
   cin>>n;
   
   string res = "";
   while(n>0)
   {
       ll rem = n%26;
       if(rem == 0)
       {
           res += 'z';
           n = n/26 - 1;
       }
       else
       {
           res += (rem-1) + 'a';
           n = n/26;
       }
   }
   
   reverse(res.begin(),res.end());
   cout<<res<<"\n";
    
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

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


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

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

vector<pair<ll, int>> facts(ll n)
{
    vector<pair<ll, int>> res;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) {
        res.emplace_back(n, 1);
    }
    return res;
}
int main(void)
{
    ll a, b;
    cin >> a >> b;
    ll g    = gcd(a, b);
    auto f  = facts(g);
    int ans = f.size() + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
x,y,z,k = map(int, input().split())
a_lst = sorted(list(map(int, input().split())), reverse=True)
b_lst = sorted(list(map(int, input().split())), reverse=True)
c_lst = sorted(list(map(int, input().split())), reverse=True)

candidate = []
for n in range(x):
    for m in range(y):
        if (n+1)*(m+1) > k:
            break
        else:
            for l in range(z):
                if (n+1)*(m+1)*(l+1) > k:
                    break
                else:
                    candidate.append(a_lst[n]+b_lst[m]+c_lst[l])
for i in sorted(candidate, reverse=True)[:k]:
    print(i)

Measured memory_bytes: 9548
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

input_n = lambda: int(readline())
input_nn = lambda: map(int, readline().split())
input_s = lambda: readline().rstrip().decode('utf-8')
input_ss = lambda: readline().rstrip().decode('utf-8').split()


def main():
    N, Q = input_nn()
    S = list(input_s())

    ac_check = [0] * (N)
    tsum = [0] * (N + 1)

    for i in range(N - 1):
        if S[i] == 'A' and S[i + 1] == 'C':
            tsum[i + 2] += 1
            ac_check[i] = 1
            ac_check[i + 1] = 2

    for i in range(N):
        tsum[i + 1] += tsum[i]

    ans = []
    for i in range(Q):
        l, r = input_nn()
        count = tsum[r] - tsum[l - 1]
        if ac_check[l - 1] == 2:
            count -= 1
        ans.append(count)

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 19608