akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> d(k);
    for(int i=0;i<k;i++)cin>>d[i];
    while(1){
        bool f=true;
        string m=to_string(n);
        for(char c:m){
            for(int i:d){
                if(c==(char)i+'0'){
                    f=false;
                    break;
                }
            }
            if(f==false)break;
        }
        if(f==true)break;
        n++;
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<60)

const ll MOD = 1e9+7;

signed main(){
    int n,m;
    cin>>n>>m;
    vector<int> w(n);
    rep(i,n)cin>>w[i];
    w.pb(INF);
    
    static int dp[2][10001][201];
    rep(i,2)rep(j,10000)rep(k,201)dp[i][j][k] = 0;
    dp[0][0][n] = 1;
    
    auto f = [&](int a,int b){
        if(w[a]<w[b])return a;
        else return b;
    };
    
    rep(l,n){
        int i = l%2;
        rep(j,m+1)rep(k,n+1)dp[!i][j][k] = 0;
        rep(j,m+1){
            rep(k,n+1){
                (dp[!i][j][f(k,l)] += dp[i][j][k])%=MOD;
                if(j+w[l]<=m){
                    (dp[!i][j+w[l]][k] += dp[i][j][k])%=MOD;
                }
            }
        }
    }
    
    int ans = 0;
    int i = n%2;
    rep(j,m+1){
        rep(k,n+1){
            if( m==INF || j+w[k]>m ){
                (ans+=dp[i][j][k])%=MOD;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 34552
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

int n;
lin a[10001], b[10001];

int main(void)
{
    cin >> n;

    rep(i, n)
    {
        cin >> a[i];
    }

    rep(i, n)
    {
        cin >> b[i];
    }

    lin mx = 0;
    lin ns = 0;
    rep(i, n)
    {
        mx += b[i] - a[i];
        if (b[i] > a[i])
        {
            ns += ((b[i] - a[i] + 1) / 2);
        }
    }

    if (mx >= ns)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 384
eval'*A=#'+`tr ' ' ,`;f=->a{l=[[0,i=0]];a.map{l.pop while(t=l[-1])[0]>_1;l<<[_1,i+=1];i-t[1]}}
p A.zip(f[A],f[A.reverse].reverse).sum{_1*_2*_3}

Measured memory_bytes: 42508
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n; cin >>n;
	vector<int> a(n);
	cinf(n,a);
	int cnt=1;
	int num=-1;
	int ans=0;
	for(int i=0;i<n;i++){
		ans++;
		if(a[cnt-1]==2){
			cout << ans << endl;
			return 0;
		}
		cnt=a[cnt-1];
	}
	cout <<-1 << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
long long a[200500],c[200500],d[200500],e[200500];
int main()
{
   long long n;
   while(~scanf("%lld",&n))
   {
     long long sum=0;
     for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
     for(int i=0;i<n;i++)
        sum+=a[i];  long long suml=sum;
     for(int i=0;i<n-1;i++)
       {
           sum-=a[i];
           c[i]=suml-sum;
           d[i]=suml-c[i];
       }
     for(int i=0;i<n-1;i++)
            e[i]=fabs(c[i]-d[i]);
     long long min=e[0];
     for(int i=0;i<n-1;i++)
        if(e[i]<min) min=e[i];
     printf("%lld\n",min);
   }
}


Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		long all = a + b;

		if (k <= a) {
			System.out.println(a - k + " " + b);
		} else if (a < k && k <= all) {
			System.out.println("0 " + (all - k));
		} else {
			System.out.println("0 0");
		}

		sc.close();
	}

}


Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
int main()
{
    int n,max = 0;
    cin >> n;
    vector<int> h;
    int x;
    for(int i = 0;i < n;i++)
    {
        cin >> x;
        h.push_back(x);
    }
    int count = 0;
    for(int i = 0;i < n - 1;i++)
    {
        if(h.at(i) >=h.at(i + 1))
        {
            count++;
        }
        else
        {
            count = 0;
        }
        if(count > max)
        {
            max = count;
        }
    }
    cout << max;

    return 0;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I1000000007 (1000000007)
#define I998244353   (998244353)
#define IINF             (1<<28)
#define LINF           (1LL<<60)
#define ALL(a)         (a).begin(), (a).end()
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  int N, K;
  vector<int> A;

  void init() {
    cin >> N >> K;
    A.resize(N);
    rep(i, N) {
      cin >> A[i];
    }
  }

  void solve() {
    int max_gcd = A[0];
    rep(i, N-1) {
      chmin(max_gcd, __gcd(max_gcd, A[i+1]));
    }
    rep(i, N) if(A[i] >= K && (K-A[i])%max_gcd == 0) {
      cout << "POSSIBLE" << "\n";
      return;
    }
    cout << "IMPOSSIBLE" << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

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

int main(void){
    int n, k;
    cin >> n >> k;
    if ((n - 1) % (k - 1) == 0) cout << (n - 1) / (k - 1);
    else cout << (n - 1) / (k - 1) + 1;
    return 0;
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111
#define MOD 1000000007

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int a[N] ;

int bigMod(int n , int p) {
  if(!p) return  1 ;

  ll result = bigMod(n, p>>1) % MOD ;
  result = ((result%MOD)*(result%MOD))%MOD ;

  if(p&1) result = (result*n) % MOD ;

  return result%MOD ;
}


int main() {
  int n , diff, count = 0;
  ll ans = 1LL ;
  scanf("%d", &n) ;

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

  if(((n&1) && a[0]>1) || (!(n&1) && a[0])){
    printf("0\n") ;
    return 0 ;
  }

  for(int i = 1 ;i<n ;i++){
    if(a[i] > 2){
      printf("0\n") ;
      return 0 ;
    }
    if(a[i])count++ ;
  }

  printf("%d\n", bigMod(2, count)) ;
	
  return 0 ;
}



Measured memory_bytes: 640
n,k = map(int, input().split())
h_list = list(map(int, input().split()))
dp = [10**9]*n
dp[0] = 0
for i in range(1, n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i], dp[j] + abs(h_list[i]-h_list[j]))
print(dp[-1])

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


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

    int R;
    cin >> R;


    cout << 2*R*3.14159<<endl;


}


Measured memory_bytes: 3796
x, y = map(int, input().split())

ans = 10 ** 18
# 最初にB押す、最後にB押す
X, Y = -x, -y
if X <= Y:
    ans = min(ans, Y - X + 2)

# 最初にB押さない、最後にB押す
X, Y = x, -y
if X <= Y:
    ans = min(ans, Y - X + 1)

# 最初にB押す、最後にB押さない
X, Y = -x, y
if X <= Y:
    ans = min(ans, Y - X + 1)

# 最初にB押さない、最後にB押さない
X, Y = x, y
if X <= Y:
    ans = min(ans, Y - X)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int a, b, x;

	cin >> a >> b >> x;

	if (a <= x && a + b >= x)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    short a,b,c;
    cin>>a>>b>>c;
    if(2*b==a+c)cout<<"YES"<<'\n';
    else cout<<"NO"<<'\n';
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let p: Vec<usize> = read_vec();
    let mut cnt: u32 = 0;
    for i in 0..n {
        if p[i] != i + 1 {
            cnt += 1
        }
    }
    if cnt <= 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int,input().split()))
p = 0
c = len(A) - 1
total = 0
while 0 < c:
    p += A[c]
    total = total + p * A[c-1]
    if total >= 1000000007:
        total %= 1000000007
    c -= 1

print(total)


Measured memory_bytes: 31440
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, C[505], S[505], F[505];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N; N--;
    rep(i, 0, N) cin >> C[i] >> S[i] >> F[i];

    rep(i, 0, N) {
        int ans = 0;
        rep(j, i, N) {
            ans = max(ans, S[j]);
            
            int d = ans - S[j];
            if (d % F[j]) d = F[j] - (d % F[j]);
            else d = 0;

            ans += d + C[j];
        }

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

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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

int leap[20][100000];
int xs[100000],N,L,Q;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i=0;i<N;i++) cin >> xs[i];
	int cr=N-1;
	cin >> L;
	for (int i=N-1;i>=0;i--) {
		while (xs[cr]-xs[i]>L) cr--;
		leap[0][i]=cr;
	}

	for (int i=1;i<20;i++) for (int j=0;j<N;j++) leap[i][j]=leap[i-1][leap[i-1][j]];

	cin >> Q;
	while (Q--) {
		int a,b;
		cin >> a >> b;
		a--;b--;
		if (a>b) swap(a,b);
		int sum=0,cur=a;
		for (int i=19;i>=0;i--) {
			if (leap[i][cur]<b) {
				cur=leap[i][cur];
				sum|=1<<i;
			}
		}
		sum++;
		/*while(cur!=b) {
			for (int i=0;;i++) {
				if (leap[i+1][cur]>b) {
					cur=leap[i][cur];
					sum+=1<<i;
					break;
				}
			}
		}*/

		cout << sum << '\n';
	}

}

Measured memory_bytes: 9088
while True:
    try:
        y, m, d = map(int, raw_input().split())
        ymd = 10000*y + 100*m + d
        if ymd < 18680908:
            print "pre-meiji"
        elif ymd < 19120730:
            print "meiji",y-1867,m,d
        elif ymd < 19261225:
            print "taisho",y-1911,m,d
        elif ymd < 19890108:
            print "showa",y-1925,m,d
        else:
            print "heisei",y-1988,m,d
    except:
        break

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

int n;
int a[202020];
int b[202020];
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        b[i] = a[i];
    }
    sort(b,b+n);
    for(int i=0;i<n;i++){
        printf("%d\n", b[n/2] > a[i] ? b[n/2] : b[n/2-1]);
    }

}


Measured memory_bytes: 3712
import heapq
import math
n, m = map(int, input().split())
a = list(int(x) for x in input().split())
h = []
for value in a:
    heapq.heappush(h, value*(-1))
for i in range(m):
    a = heapq.heappop(h)
    heapq.heappush(h, a/2)
ans = 0
for i in range(n):
    ans += math.floor(h[i]*(-1))
print(ans)

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

int main() {
  
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if (e-a <= k) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }

return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
int main(){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a==b&&c==d)printf("yes\n");
    else if(a==c&&b==d)printf("yes\n");
    else if(a==d&&b==c)printf("yes\n");
    else printf("no\n");
}


Measured memory_bytes: 2580
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    sumA = [0] * (N + 1)
    for i, a in enumerate(A): sumA[i+1] = sumA[i] + a

    left, right = 0, 1
    count = 0
    current = A[0]
    while left < N:
        count += right - left
        while right < N:
            if current ^ A[right] == sumA[right + 1] - sumA[left]:
                count += 1
                current ^= A[right]
                right += 1
            else: break
        current ^= A[left]
        left += 1
    print(count)

    return 0

if __name__ == "__main__":
    solve()

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

const int INF = 0x3f3f3f3f;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector<int> dp(n, INF);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    if (i < n - 1) {
      dp[i + 1] = min(dp[i + 1], dp[i] + (int) abs(h[i] - h[i + 1]));
    }
    if (i < n - 2) {
      dp[i + 2] = min(dp[i + 2], dp[i] + (int) abs(h[i] - h[i + 2]));
    }
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    long n, k, mod;
    cin >> n >> k;
    if(n>k){
        mod = n%k;
    }else{
        mod = n;
    }
    cout << min(mod, k-mod) << endl;
    return 0;
}

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

adj = [set() for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    adj[a].add(b)
    adj[b].add(a)

if len(adj[0] & adj[N - 1]) > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 73688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		scan.useDelimiter("\\D+");

		int w = scan.nextInt();
		int n = scan.nextInt();
		
		int[] a = new int[w];
		for(int i=0;i<w;i++)
			a[i] = i+1;
		
		for(int i=0;i<n;i++) {
			int x = scan.nextInt()-1;
			int y = scan.nextInt()-1;
			
			int t = a[x];
			a[x] = a[y];
			a[y] = t;
		}
		
		for(int i=0;i<w;i++){
			System.out.println(a[i]);
		}
		
		scan.close();
	}
}

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

int main() {
	// your code goes here
	ll i,j,n,w;
	cin>>n>>w;
	ll wt[n+1],val[n+1];
	ll dp[n+1][w+1];
	for(i=1;i<=n;i++)
	cin>>wt[i]>>val[i];
	for(i=0;i<=n;i++)
	{
	    for(j=0;j<=w;j++)
	    dp[i][j]=-1;
	}
	for(i=0;i<=w;i++)
	dp[0][i]=0;
	for(j=0;j<=n;j++)
	dp[j][0]=0;
	for(i=1;i<=n;i++)
	{
	    for(j=1;j<=w;j++)
	    {
	        if(j>=wt[i])
	        {
	            dp[i][j]=max(val[i]+dp[i-1][j-wt[i]],dp[i-1][j]);
	        }
	        else
	        dp[i][j]=dp[i-1][j];
	    }
	}
	cout<<dp[n][w];
	return 0;
}


Measured memory_bytes: 82444
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections
INF = 10**10

N, = map(int, sys.stdin.readline().rstrip().split(" "))
costs = map(int, sys.stdin.readline().rstrip().split(" "))


def solve(costs):
    dp = [0] + [INF for _ in costs]
    for i in range(len(costs)-2):
        dp[i+1] = min(dp[i+1], dp[i] + abs(costs[i+1] - costs[i]))
        dp[i+2] = min(dp[i+2], dp[i] + abs(costs[i+2] - costs[i]))
    #print(dp)
    return dp[-4]

ans = solve(costs + [INF] * 2)
assert ans < INF
print(ans)
exit(0)


Measured memory_bytes: 13324
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

bool ok(string s) {
    int n = s.size();
    rep(i,n/2) {
        if (s[i] != s[n-1-i]) return false;
    }
    return true;
}

int main() {
    string s;
	cin >> s;
    int n = s.size();
    if (ok(s) && ok(s.substr(0, n/2))) cout << "Yes" << endl;
    else                               cout << "No" << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

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

	ll f = 100;
	ll t = 0;
	ll x;
	cin >> x;

	while(f < x){
		f += f / 100;
		t++;
	}

	cout << t << endl;


}


Measured memory_bytes: 3664
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	int min =2*10*10*10*10*10+1;
	int count = 0;
	for(int i = 0; i < n; i++){
		int p;
		cin >> p;
		if(p <= min){
			min = p;
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> vec(n+1,0);
	vec.at(0) = 1000000;
	for (int i = 1; i < n; i++) cin >> vec.at(i);
	vec.at(n) = 1000000;
	int answer = 0;
	for (int i = 0; i < n; i++) {
		answer += min(vec.at(i), vec.at(i + 1));
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  string odd,even;
  cin >> odd >> even;
  
  int l_odd = odd.length();
  int l_even = even.length();
  
  if(l_odd == l_even){
    for(int i=0;i<l_odd;i++){
      cout << odd[i] << even[i];
    }
    cout << endl;
  }
  else{
    cout << odd[0];
    for(int i=0;i<l_even;i++){
      cout << even[i] << odd[i + 1];
    }
      cout << endl;
  }
  
  return 0;
}
  

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

int main() {
  int N,A,B;
  int P1,P2;
  cin >> N >> A >> B;
  
  P1 = A * N;
  P2 = B;
  
  if (P1 <= P2) {
    cout << P1 << endl;
  }
  else {
    cout << P2 << endl;
  }
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k,n;cin>>k>>n;
  vi A(n);
  for(auto &a:A)cin>>a;
  ll ans = llINF;
  for(int i=0;i<n-1;i++)
    ans = min(ans,k-(A[(i+1)]-A[i]));
  ans = min(ans,A[n-1]-A[0]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	int a;
	bool flag = true;
	rep(i, 0, N)
	{
		cin >> a;
		if (a % 2 == 1)
		{
			flag = false;
			break;
		}
	}

	cout << (flag ? "second" : "first") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	string s;
	ll N=0;
	cin>>s;
	rep(i,15){
		if(i<s.size()){
			if(s[i]=='o')N++;
			else continue;
		}
		else N++;
	}
	if(N>=8)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) cerr << #x << " = " << (x) << " " << endl;
#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
 
template<typename T>
T gcd(T a, T b)
{
  T c;
  while (a != 0) {
    c = a; a = b%a;  b = c;
  }
  return b;
}
 
void solve();
 
class Solver {
public:
  int a, b;
  string s;

  bool ans() {
    auto vec = split(s, '-');
    if (vec.size() != 2) return false;
    if (vec[0].size() != a or vec[1].size() != b) return false;
    return true;
  }

  void solve() {
    cin >> a >> b;
    cin >> s;
    cout << (ans() ? "Yes" : "No") << endl;
  }
};
 
signed main()
{
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {    
  //     auto ptr = new Solver();
  //     ptr->solve();
  //     delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'


Measured memory_bytes: 256
from collections import*
n,*a=map(int,open(0).read().split())
d=defaultdict(int)
l=[]
for i in a:
    if d[i]%2:l.append(i)
    d[i]+=1
if len(l)>1:
    *_,a,b=sorted(l)
    print(a*b)
else:
    print(0)

Measured memory_bytes: 18528
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main(){
    int H,W,K;
    cin >> H >> W >> K;
    
    char mp[H][W];
  	int hcnt[H];
  	int wcnt[W];

    int all = 0;

    REP(i,H){
        REP(j,W){
          char s;
          cin >> s;
          if('#' == s){
            all++;
          }
		  mp[i][j] = s;
        }
    }
  
  	K = all - K;
  
  	REP(i,H){
      int cnt = 0;
      REP(j,W){
        if('#' == mp[i][j]) cnt++;
      }
      hcnt[i]=cnt;
    }

    REP(i,W){
      int cnt = 0;
      REP(j,H){
        if('#' == mp[j][i]) cnt++;
      }
      wcnt[i]=cnt;
    }
  
  	int ans = 0;
  	for(int w = 0; w < (1 << W); w++){
      int sub=0;
      vint idx;
      
      for(int i = 0; i < W; i++){
        if((w >> i) & 1){
          sub += wcnt[i];
          idx.pb(i);
        }
   	  }
      
      for(int h = 0; h < (1 << H); h++){
        int allsub = sub;
        for(int j = 0; j < H; j++){
          if((h >> j) & 1){
            allsub += hcnt[j];
            for(auto i : idx){
              if('#' == mp[j][i]){
                allsub -= 1;
              }
            }
          }
        }
        if(K==allsub){
            ans++;
        }
      }
    }
    cout << ans << endl;
}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 200010, M = 1010, mod = 998244353;

int n, m, k;
int fact[N], infact[N];

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = (LL)res * a % mod;
		a = (LL)a * a % mod;
		b >>= 1;
	}
	return res;
}

int C(int a, int b)
{
	int res = (LL)fact[a] * infact[b] % mod * infact[a - b] % mod;
	return res;
}

int main()
{
	cin >> n >> m >> k;
	
	fact[0] = infact[0] = 1;
	for (int i = 1; i <= n; i ++ )
	{
		fact[i] = (LL)fact[i - 1] * i % mod;
		infact[i] = (LL)infact[i - 1] * qp(i, mod - 2) % mod;
	}
	
	int res = 0;
	for (int i = 0; i <= k; i ++ )
		res = (res + (LL)m * C(n - 1, i) % mod * qp(m - 1, n - 1 - i)) % mod;
		
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 5132
#include<iostream>
#include<vector>
#include<iomanip>
#include<math.h>
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<vector<int>> t(N,vector<int>(2));
    for(int i=0;i<N;i++){
        for(int j=0;j<2;j++){
            cin>>t.at(i).at(j);
        }
    }

    double sum=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            sum+=sqrt(pow(t.at(i).at(0)-t.at(j).at(0),2)+pow(t.at(i).at(1)-t.at(j).at(1),2));
        }
    }
    cout<<fixed<<setprecision(10)<<sum*2/N<<endl;
}

Measured memory_bytes: 256
n=int(input())
alist = list(map(int, input().split()))

alist=sorted(alist, reverse=True)
kati=0
for i in range(n-1):
    kati+=(alist[i]/(2**(i+1)))

kati+=(alist[n-1]/(2**(n-1)))

print(kati)

Measured memory_bytes: 38384
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n :u32 = read();
    let mut sn: Vec<String> = Vec::new(); // M A R C H 探索
    for _ in 0..n {
        sn.push(read::<String>())
    }
    let mut counts:Vec<f64> = vec![0.,0.,0.,0.,0.];
    let first :Vec<usize> = vec![0,0,0,0,0,0,1,1,1,2];
    let second:Vec<usize> = vec![1,1,1,2,2,3,2,2,3,3];
    let third :Vec<usize> = vec![2,3,4,3,4,4,3,4,4,4];
    for i in 0..sn.len() {
        match sn[i as usize].chars().nth(0).unwrap() {
            'M' => counts[0] += 1.,
            'A' => counts[1] += 1.,
            'R' => counts[2] += 1.,
            'C' => counts[3] += 1.,
            'H' => counts[4] += 1.,
            _ => (),
        }
    }
    let mut ans = 0.;
    for i in 0..10 {    
        ans += counts[first[i as usize]] * counts[second[i as usize]] * counts[third[i as usize]];
    }
    println!("{}",ans);
}

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

namespace ABC_082A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            c = a + b;

            if (c % 2 == 0)
            {
                Console.WriteLine(c / 2);
            }

            else
            {
                Console.WriteLine(c / 2 + 1);
            }

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;using L=long long;using V=pair<L,L>;
#define F first
#define S second
#define I X[i]
#define R for(L i=0;i<N;i++)
L N,D,A,n=0,r=0,t;V X[200005];queue<V>P;
main(){cin>>N>>D>>A;R cin>>I.F>>I.S;sort(X,X+N);R{while(!P.empty()&P.front().F<I.F){n-=P.front().S;P.pop();}I.S-=n;if(I.S>0){t=(I.S+A-1)/A;r+=t;P.push({I.F+2*D,t*A});n+=t*A;}}cout<<r;} 

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
typedef long long ll;
const double PI = acos(-1);
using namespace std;

int counter(int x){
    if(x==0)return 0;
    return counter(x>>1)+(x&1);
}

int main(void){
    int N;cin>>N;
    int A[20],x[20][20],y[20][20];
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans=0;
    for(int bit=1;bit<(1<<N);++bit){
        bool ok=true;
        for(int i = 1; i <= N; i++) {
            if(!(bit & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++) {
                if(((bit >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans=max(ans,counter(bit));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll R,G,B,N;
  cin>>R>>G>>B>>N;
  ll num=0;
  for(int r=0;r<=N;r+=R){
    for(int g=0;g<=N;g+=G){
      if(r+g>N)break;
      if((N-(r+g))%B==0)num++;
      /*for(int b=0;b<=N;b+=B){
        if(r+g+b>N)break;
        if(r+g+b==N)num++;
      }*/
    }
  }
  cout<<num<<endl;
  return 0;
}


Measured memory_bytes: 384
def RSQ_add(i, x, y):
    while True:
        if i > n:
            break
        BIT[y][i] += x
        i += i & -i

def RSQ_getsum(i, x):
    s = 0
    while True:
        if i <= 0:
            break
        s += BIT[x][i]
        i -= i & -i
    return s

n = int(input())
s = list(input())
q = int(input())
BIT = [[0] * (n + 1) for _ in range(26)]
for i in range(n):
    y = ord(s[i]) - 97
    RSQ_add(i + 1, 1, y)
for _ in range(q):
    com, a, b = map(str, input().split())
    com, a = int(com), int(a)
    if com == 1:
        RSQ_add(a, -1, ord(s[a - 1]) - 97)
        RSQ_add(a, 1, ord(b) - 97)
        s[a - 1] = b
    else:
        b = int(b)
        ans = 0
        for i in range(26):
            if RSQ_getsum(b, i) - RSQ_getsum(a - 1, i) >= 1:
                ans += 1
        print(ans)

Measured memory_bytes: 168732
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	long long n, t;
	cin >> n >> t;
	vector<long long> t2;
	REP(i, n) {
		int a;
		cin >> a;
		t2.push_back(a);
	}
	long long ans = 0;
	for (int i = 1;i < n;++i) {
		ans += min(t2[i] - t2[i - 1], t);
	}
	cout << ans + t << endl;
	return 0;
}

Measured memory_bytes: 2420
N ,M, X = list(map(int,input().split()))
C = []
A = []
for i in range(N):
    B  = list(map(int, input().split()))
    C.append(B[0])
    A.append(B[1:])

money =[]
for i in range(2** N):
    tmp=[]
    for j in range(N):
        if ((i>>j)&1):
            tmp.append(C[j])
    money.append(sum(tmp))

result = [0 for i in range(2**N)]
for k in range(M):
    for i in range(2** N):
        tmp=[]
        for j in range(N):
            if ((i>>j)&1):
                tmp.append(A[j][k])
        if sum(tmp) >= X:
            result[i] +=1
book_price =[]
for i in range(len(result)):
    if result[i] == M:
        book_price.append(money[i])

if book_price:
    print(min(book_price))
else:
    print(-1)

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

int main() {
	string S;
	cin >> S;
	int ans = 0;
	char now = ' ';
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != now) now = S[i];
		else {
			i++;
			now = ' ';
			if (i == S.length()) ans--;
		}
		ans++;
	}
	cout << ans << endl;
}


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

using namespace std;

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

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int main() {
  int N;
  cin >> N;
  vector<int> C(N);
  vector<set<int>> st(200001);
  REP(i, N) {
    cin >> C[i];
    st[C[i]].insert(i);
  }
  vector<mint> dp(N + 1);
  dp[0] = 1;
  for (int i = 0; i < N; i++) {
    auto it = st[C[i]].upper_bound(i);
    if (it != st[C[i]].end()) {
      int j = *it;
      if (j > i + 1) {
        dp[j] += dp[i];
      }
    }
    dp[i + 1] += dp[i];
  }
  cout << dp[N].n << endl;
}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  string s;
  cin>>s;
  int ans=-1;
  int ss=0;
  REP(i,s.size())ss+=(s[i]-'0');
  ans=max(ans,ss);
  REP(i,s.size()){
    int tmp=0;
    if(s[i]=='0'){
      for(int j=0;j<i-1;j++)tmp+=(s[j]-'0');
      tmp+=(s[i-1]-'0')-1;
      for(int k=i;k<s.size();k++)tmp+=9;
      ans=max(ans,tmp);
    }else{
      tmp+=(s[i]-'0')-1;
      for(int j=0;j<i;j++)tmp+=(s[j]-'0');
      for(int k=i+1;k<s.size();k++)tmp+=9;
      ans=max(ans,tmp);
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h> 
using namespace std;
 
int main(){
  int n;
  cin>>n;
  vector <string> S(n);
  for(int i=0;i<n;i++){
    cin>>S[i];
  }
  for(int i=0;i<26;i++){
    long cnt=50;
    for(int j=0;j<n;j++){
      cnt = min(cnt, count(S[j].cbegin(), S[j].cend(), 'a'+i));
    }
    for(int j=0;j<cnt;j++){
      cout<<char('a'+i);
    }
  }
  cout<<endl;
}


Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=998244353;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
string s;
int dp[200005][3][3][2];//sum same prev
inline void add(int &x,int y){
	x+=y;if(x>=mod)x-=mod;
}
int main(){
	cin>>s;
	if(s.size()==2){
		if(s[0]==s[1])cout<<1<<endl;
		else cout<<2<<endl;
		return 0;
	}else if(s.size()==3){
		if(s[0]==s[1]&&s[1]==s[2])cout<<1<<endl;
		else if(s[0]==s[1]||s[1]==s[2])cout<<6<<endl;
		else if(s[0]==s[2])cout<<7<<endl;
		else cout<<3<<endl;
		return 0;
	}
	bool all_same=1,all_dif=1;int sum=0;
	for(char c:s)sum+=(c-'a');sum%=3;
	for(int i=1;i<s.size();i++)all_same&=(s[i]==s[i-1]),all_dif&=(s[i]!=s[i-1]);
	if(all_same){
		cout<<1<<endl;
		return 0;
	}
	dp[1][0][0][0]=1;
	dp[1][1][1][0]=1;
	dp[1][2][2][0]=1;
	for(int i=1;i<s.size();i++){
		for(int sum=0;sum<3;sum++){
			for(int pre=0;pre<3;pre++){
				for(int same=0;same<2;same++){
					for(int nxt=0;nxt<3;nxt++){
						add(dp[i+1][nxt][(sum+nxt)%3][same|(nxt==pre)],dp[i][pre][sum][same]);
					}
				}
			}
		}
	}
	int ans=all_dif;
	for(int i=0;i<3;i++)add(ans,dp[s.size()][i][sum][1]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14596
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n = int(input())
    s = [input() for i in range(n)]
    print(len(set(s)))
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 36428
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair
#define pb push_back
#define pp pop_back
#define pii pair<int,int>
#define fi first
#define se second 
#define in insert
#define er erase
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
using namespace std;
const int mx=1e5+10;
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	ll n;cin>>n;
	cout<<n*800-(n/15)*200;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
int main() {
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    if (x1==0) cout << 1 << endl;
    else if (x2==0) cout << 2 << endl;
    else if (x3==0) cout << 3 << endl;
    else if (x4==0) cout << 4 << endl;
    else if (x5==0) cout << 5 << endl;
    return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		if(input.charAt(0) == input.charAt(2)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22228
local rand = math.random
local read = io.read

math.randomseed(os.time())

local D = read("*n")
local c = {}
for i = 1, 26 do
	c[i] = read("*n")
end
for i = 1, D + 1 do
	read("*l")
end

--[[
local function randNoDuplication(list)
	local num = rand(1, #list)
	for i = 1, #list do
		if list[i] == num then
			return randNoDuplication(list)
		end
	end
	return num
end
]]

for i = 1, D do
	print(rand(1, 26))
end


Measured memory_bytes: 2776
l,r=map(int,input().split())
if r-l>=2018:
  ans=0
else:
  x=l%2019
  y=r%2019
  ans=10**4
  for i in range(x,y+1):
    for j in range(i+1,y+1):
      z=(i*j)%2019
      if z<ans:
        ans=z
print(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, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

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


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $m);
$ret = array_pad([], $n, 0);
for($i = 0; $i < $m; $i++) {
    fscanf(STDIN, "%d %d", $a, $b);
    if(array_key_exists($a - 1, $ret)) $ret[$a - 1]++;
    if(array_key_exists($b - 1, $ret)) $ret[$b - 1]++;
}
foreach($ret as $key => $v) echo $v. "\n";

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 A, B, C, D;
  cin >> A >> B >> C >> D;
  bool T = true;
  while(A>0 and C>0){
    if(T){
      C -= B;
      T = !T;
    } else {
      A -= D;
      T = !T;
    }
  }
  if(T) cout << "No\n";
  else cout << "Yes\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	
	int distance_a = (x - a > 0) ? x - a : a - x;
	int distance_b = (x - b > 0) ? x - b : b - x;
	
	if(distance_a > distance_b)
	{
		cout << 'B' << endl;
	}
	else
	{
		cout << 'A' << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	char s[101];
	int len ,i;
	scanf("%s",s);
	len=strlen(s);
	printf("%c%d%c\n",s[0],len-2,s[len-1]);
	return 0;
}

Measured memory_bytes: 128