akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdbool.h>
#include <string.h>

typedef struct _card_ {
  char suit;
  int val;
} _card_t;

int pos(_card_t target, _card_t C[]) {
  int ret = 0;
  while (1) {
    if ((C[ret].suit == target.suit) && (C[ret].val == target.val))
      return ret;
    ret++;
  }
}

bool isStable(_card_t C[], _card_t C1[], int n) {
  int i;
  for (i = 0; i < n; i++)
    if ((C1[i].val == C1[i + 1].val) && (pos(C1[i], C) > pos(C1[i + 1], C))) {
      return false;
    }
  return true;
}

void BubbleSort(_card_t C[], int n) {
  int i;
  _card_t C1[n];
  memcpy(C1, C, sizeof(_card_t) * n);
  for (i = 0; i < n; i++) {
    int j;
    for (j = n - 1; j >= i; j--) {
      if (C1[j].val < C1[j - 1].val) {
        _card_t temp = C1[j]; C1[j] = C1[j - 1]; C1[j - 1] = temp;
      }
    }
    printf("%c%d", C1[i].suit, C1[i].val);
    if (i != (n - 1))
      printf(" ");
  }
  printf("\n%s\n", isStable(C, C1, n) ? "Stable" : "Not stable");
}

void SelectionSort(_card_t C[], int n) {
  int i;
  _card_t C1[n];
  memcpy(C1, C, sizeof(_card_t) * n);
  for (i = 0; i < n; i++) {
    int minj = i, j;
    for (j = i; j < n; j++) {
      if (C1[j].val < C1[minj].val)
        minj = j;
    }
    _card_t temp = C1[i]; C1[i] = C1[minj]; C1[minj] = temp;
    printf("%c%d", C1[i].suit, C1[i].val);
    if (i != (n - 1))
      printf(" ");
  }
  printf("\n%s\n", isStable(C, C1, n) ? "Stable" : "Not stable");
}

int main() {
  int i, n;
  scanf("%d\n", &n);
  _card_t C[n];
  for (i = 0; i < n; i++) {
    if (i != n - 1)
      scanf("%c%d ", &C[i].suit, &C[i].val);
    else
      scanf("%c%d", &C[i].suit, &C[i].val);
  }
  BubbleSort(C, n);
  SelectionSort(C, n);
  return 0;
}

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


int main() {
    ll n,m; cin >> n >> m;
    ll change = 1;
    if(n==1) change*=(-1);
    if(m==1) change*=(-1);
    cout << (n-2)*(m-2)*change << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define i64 long long int
int n,m,d[5005];
int a[5005][202];
int z[202];
i64 res;
int st[202][5005],top[5005];

i64 ss[5005];
void inc(int s,int e,int w){
	ss[s] += w;
	ss[e+1] -= w;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1; i<n; i++)
		scanf("%d",&d[i]);
	for(int i=1; i<=n; i++)for(int j=1; j<=m; j++)
		scanf("%d",&a[i][j]);
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			while(top[j] > 0 && a[st[j][top[j]-1]][j] <= a[i][j]){
				top[j]--;
				inc(top[j] == 0 ? 1 : st[j][top[j]-1] + 1, st[j][top[j]], a[i][j] - a[st[j][top[j]]][j]);
			}
			st[j][top[j]++] = i;
			inc(i, i, a[i][j]);
		}
		i64 cur = 0;
		for(int k=1; k<i; k++)
			cur -= d[k];
		for(int k=1; k<=i; k++){
			cur += ss[k];
			res = max(res, cur);
			cur += d[k];
		}
	}
	cout << res <<endl;
	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int a,p;
  cin >> a >> p;
  int x = a*3+p;
  cout<<x/2<<endl;
  return 0;
}

Measured memory_bytes: 3644
#094b
N,M,X = map(int, input().split())
A_list = [int(e) for e in input().split()]

#あなたは，最初マス X にいます． 
#隣り合うマスの間は自由に移動することができ，マス 0 またはマス N にたどり着くとゴールすることができます． 
#ただし，i=1,2,...,M について，マス Ai には料金所があり，そのためマス Ai に移動してくる際には 1 のコストがかかります．
#なお，マス 0，マス X，マス N には料金所がないことが保証されます．

#ゴールするまでにかかるコストの最小値を求めてください．

#X < N - 1

cost_to_0 = 0
cost_to_M = 0

for i in range(M):
    if A_list[i] < X:
        cost_to_0 += 1
    else:
        cost_to_M += 1
          
print(min(cost_to_M,cost_to_0)) 

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int N;
	vector<llong> A, B;

	cin >> N;
	A.resize(N), B.resize(N);
	for(int i = 0; i < N; i++)
		cin >> A[i];
	for(int i = 0; i < N; i++)
		cin >> B[i];

	llong a = 0, b = 0, sum = 0;
	for(int i = 0; i < N; i++){
		if(A[i] > B[i])
			b += A[i] - B[i];
		else
			a += (B[i] - A[i])/2*2;
	}

	if(a >= b*2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

#define maxN 100010

int n, m;
vvi points;
int cache[maxN];

int rec(int i) {
    if (cache[i] != -1) return cache[i];
    int m = 0;
    for (int other : points[i]) {
        int score = rec(other);
        if (score > m) m = score;
    }
    return cache[i] = 1+m;
}

int main() {
    cin >> n >> m;
    points.assign(n+1, vi());
    for (int i = 0; i<=n; i++) cache[i] = -1;
    for (int i = 0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        points[a].push_back(b);
    }
    int m = -1;
    for (int i = 1; i<=n; i++) {
        m = max(m, rec(i));
    }
    cout << (m-1) << endl;
    return 0;
}

Measured memory_bytes: 8192
#!/usr/bin python3
# -*- coding: utf-8 -*-

H, W = map(int,input().split())
sth, stw = 0, 0
glh, glw = H-1, W-1

INF = -1
Gmap = [list(input()) for _ in range(H)]
Dist = [[INF]*W for _ in range(H)]
direc = {(1,0), (0,1)}
init_q =[]

from collections import deque

def bfs(init):
    next_q = deque([])
    for i in init:
        next_q.append(i)
        Dist[i[0]][i[1]] = 1

    while len(next_q)!=0:
        #キュー取り出し(先頭)
        h,w = next_q.popleft()
        for d in direc:
            hs, ws = h + d[0], w + d[1]
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='#' and Dist[hs][ws]==INF:
                next_q.append([hs,ws])
                Dist[hs][ws] = Dist[h][w] + 1
    return Dist

def main():
    #固定
    init_q.append([sth, stw])

    ret = bfs(init_q)
    if ret[glh][glw]>0 and ret[glh][glw]==sum([a.count('#') for a in Gmap]):
        print('Possible')
    else:
        print('Impossible')

if __name__ == '__main__':
    main()

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

int main() {
  while (true) {
    int H, W;
    cin >> H >> W;
    if (H == 0 and W == 0) break;
    for (int h = 0; h < H; h++) {
      for (int w = 0; w < W; w++) {
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = K; i < N; i++) {
    cout << ((A.at(i) > A.at(i - K)) ? "Yes" : "No") << "\n";
  }
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 2e5 + 5;

ll n, a[nax];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	ll sum = 0;
	for(ll i = 1; i <= n; i++){
		cin >> a[i];
		sum ^= a[i];
	}
	for(ll i = 1; i <= n; i++){
		ll temp = sum;
		ll ans = temp ^ a[i];
		cout << ans << ' ';
	}
	cout << '\n';
}


Measured memory_bytes: 5100
#include <stdio.h>
int main()
{
    int n;
    int A[101];
    int x = 0, cnt = 0, i, tmp;
    scanf("%d", &n);



    for(i = 0; i < n; i++) scanf("%d", &A[i]);


    while(x < n)
    {
        for(i = n - 1; i > x; i--)
        {
            if(A[i - 1] > A[i])
            {
                tmp = A[i - 1];
                A[i - 1] = A[i];
                A[i] = tmp;
                cnt++;
            }
        }
        x++;
    }



    for(i = 0; i < n; i++)
    {
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }


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



Measured memory_bytes: 2108
n = int(input())
r = [0]*n
c = [0]*n
for i in range(n):
    r[i], c[i] = map(int, input().split())


# T[i][j]  stands for the minimum number of product operation (of real numbers)
# that has to be performed in calculating 
# the matrix chain product $M_i \times \dots \times M_j$
T = [[0]*n for _ in range(n)]

# p = j -i
for p in range(1, n):
    for i in range(n-p):
        j = i + p
        val = float("inf")
        for k in range(i,j):
            val_tmp = T[i][k] + T[k+1][j] + r[i]*c[k]*c[j]
            if val_tmp < val:
                val = val_tmp
        T[i][j] = val
        
print(T[0][n-1])


Measured memory_bytes: 5668
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B, T; cin >> A >> B >> T;

    cout << T / A * B << endl;

    return 0;
}


Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 2005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

LL dp[MAX][MAX];
LL count_seq(vector<int> &S, int m, int n) //n = sum, m = size of values
{ 
    int i, j;
    LL x, y;  
     
    for (i = 0; i < m; i++) dp[0][i] = 1; 
   
    for (i = 1; i < n + 1; i++) { 
        for (j = 0; j < m; j++) { 
            x = (i-S[j] >= 0) ? dp[i - S[j]][m-1] : 0; 
            y = (j >= 1) ? dp[i][j - 1] : 0; 
            dp[i][j] = (x + y) % MOD; 
            //~chk3(i, j, dp[i][j]);
        } 
    } 
    return dp[n][m - 1]; 
} 

void solve() {
	int sum;in(sum);
	vector<int> S;
	for(int i=3;i<=sum;i++) {
		S.PB(i);
	}
	int m = S.size();
	cout<<count_seq(S, m, sum)<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
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;}

const int mod=1000000007;
const int MAX=1000000;
int fact[MAX],inv[MAX];
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}

int C(int n,int k){
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}

int pow3[MAX];
signed main(){
    fact[0]=1;
    for(int i=1;i<MAX;i++)fact[i]=fact[i-1]*i%mod;
    inv[MAX-1]=mpow(fact[MAX-1],mod-2);
    for(int i=MAX-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    pow3[0]=1;
    for(int i=1;i<MAX;i++)pow3[i]=pow3[i-1]*3%mod;

    int N,M,K;
    cin>>N>>M>>K;
    int ans=0;
    int cur=1;
    for(int i=0;i<=M+K;i++){
        ans=(ans+cur*C(N-1+i,i)%mod*pow3[M+K-i])%mod;
        cur=cur*2%mod;
        if(i>=M)cur=(cur-C(i,M)+mod)%mod;
        if(i>=K)cur=(cur-C(i,i-K)+mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 23680
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    ll a; cin>>a;
    ll o = 0;
    for(int q=1; q<=a; q++){
        if(to_string(q).size()%2) o++;
    }
    cout<<o;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

cnt = 0
def insection_sort(a, g):
    global cnt
    for i in range(g, len(a)):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j -= g
            cnt += 1
        a[j+g] = v

def shell_sort(a):
    g = [1]
    temp = 4
    while temp < len(a):
        g.append(temp)
        temp = 3 * temp + 1

    print(len(g))
    for youso in reversed(g):
        if youso != 1:
            print(youso, end=' ')
        else:
            print(youso)
        insection_sort(a, youso)

inp_num = int(input())
a = list()
for i in range(inp_num):
    a.append(int(input()))
shell_sort(a)
print(cnt)
for i in a:
    print(i)

Measured memory_bytes: 47528
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(Math.Max(0, C - (A - B)));
		
		
	}
	int A,B,C;
	public Sol(){
		var d = ria();
		A = d[0]; B = d[1]; C = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
import java.util.*

object MainKt {
    @JvmStatic
    fun main(args: Array<String>) {
        val scanner = Scanner(System.`in`)
        val n = scanner.nextInt()

        var ans = euc(scanner.nextInt(), scanner.nextInt())
        for (i in 2..n-1) ans = euc(ans, scanner.nextInt())

        println(ans)
    }

    @JvmStatic
    fun euc(one: Int, two: Int): Int{
        val args = intArrayOf(one, two)
        if (args[0]>args[1]) {
            args[0] = two
            args[1] = one
        }
        //0<=1
        val mod = args[1]%args[0]
        if (mod==0) return args[0]
        else return euc(args[0], mod)
    }

}

Measured memory_bytes: 54080
import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val list = Array(N) { i ->
        val (S, P) = readLine()!!.split(" ")
        Triple(i, S, P.toInt())
    }
    val result = list.sortedArrayWith(Comparator { o1, o2 -> if (o1.second != o2.second) o1.second.compareTo(o2.second) else o2.third.compareTo(o1.third) })
    println(result.map { it.first + 1 }.joinToString("\n"))
}

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

long long int N, M, a = 0;

int main(){
    scanf("%lld%lld", &N, &M);
    for(long long i = 1; i * i <= M; ++i){
        if(M % i == 0){
            if(i >= N)a = max(a, M / i);
            if(M / i >= N)a = max(a, i);
        }
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MN 2000000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,K,top[2],L,A,B,cnt;
struct eve{int a,b,t,flag;}q[2][MN*2+5];
struct edge{int t,next;}e[MN*10+5];
char a[MN+5],b[MN+5];
void add(int a,int b,int t,int s)
{
    if(a&b&1) 
    {
        if(top[s]&&q[s][top[s]].a&q[s][top[s]].b&1)
            e[++cnt]=(edge){t-q[s][top[s]].flag,q[s][top[s]].t},q[s][top[s]].t=cnt;
        else e[++cnt]=(edge){t,0},q[s][++top[s]]=(eve){1,1,cnt,0};
    }
    else q[s][++top[s]]=(eve){a,b,t,0};
}
void Add(int a,int b,int t,int s)
{
  //  cout<<"Add"<<a<<" "<<b<<" "<<t<<" "<<s<<endl;
    A+=a;B+=b;
    if(A>=2||B>=2) add(A>>1,B>>1,t,s),A&=1,B&=1;
    if(A&B&1&&t<K) add(1,1,t+1,s),A=B=0;
}
void Solve(int x,int ad,int s)
{
    if(e[x].next) Solve(e[x].next,ad,s);
    if(e[x].t+ad<=K) Add(1,1,e[x].t+ad,s);
}
int main()
{
    n=read();m=read();K=read();L=max(n,m)+K;
    scanf("%s",a+1);for(int i=1;i<=n;++i) a[i]-='0';
    scanf("%s",b+1);for(int i=1;i<=m;++i) b[i]-='0';
    for(int l=1,r=n;l<r;++l,--r) swap(a[l],a[r]);
    for(int l=1,r=m;l<r;++l,--r) swap(b[l],b[r]);
    for(int i=1;i<=L;++i)
    {
     //   cout<<"Solve"<<i<<endl;
        A=B=0;top[~i&1]=0;
        if(a[i]||b[i]) Add(a[i],b[i],0,~i&1);
        int S=i&1;
        for(int j=1;j<=top[S];++j)
        {
            if(q[S][j].a&q[S][j].b&1)
            {
                if(A==0&&B==0) 
                {
              //      cout<<"getspecial"<<endl;
                    int t=q[S][j].t,ad=q[S][j].flag;
                    if(t&&e[t].t+ad==K) A=B=1,t=e[t].next;
                    if(t) q[S^1][++top[S^1]]=(eve){1,1,t,q[S][j].flag+1};
                }
                else Solve(q[S][j].t,q[S][j].flag,~i&1);
            }
            else Add(q[S][j].a,q[S][j].b,q[S][j].t,~i&1); 
        }
        a[i]=A;b[i]=B;
       // cout<<"A="<<A<<"B="<<B<<endl;
    }
    int n1=L,n2=L;
    while(n1&&a[n1]==0) --n1;
    while(n2&&b[n2]==0) --n2;
    for(int i=n1;i;--i) printf("%d",a[i]);puts("");
    for(int i=n2;i;--i) printf("%d",b[i]);
    return 0;
}

Measured memory_bytes: 24576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        int input = int.Parse(Console.ReadLine());
        long ans = 0;
        for (int i = 0; i <= input; i++)
        {
            if (i % 3 != 0 && i % 5 != 0) { ans += i; }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27472
N = int(input())
H = list(map(int,input().split()))

def main():
    ans = 0
    tmp = 0
    for i in range(N-1):
        if H[i] >= H[i+1]:
            tmp += 1
        else:
            tmp = 0
        ans = max(ans,tmp)
    print(ans)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 14252
def inner_product(v1, v2):
    return v1.real * v2.real + v1.imag * v2.imag


# ????????????b???????????????a??????????????´????????£?°???±???????????????????????????
def projection(a, b):
    return a * inner_product(a, b) / (abs(a) ** 2)


def solve(p0, p1, p2):
    a = p1 - p0
    b = p2 - p0
    pro = projection(a, b)
    t = p0 + pro
    return t


def main():
    x_p0, y_p0, x_p1, y_p1 = map(float, input().split())
    p0 = complex(x_p0, y_p0)
    p1 = complex(x_p1, y_p1)
    q = int(input())
    for _ in range(q):
        p2 = complex(*map(float, input().split()))
        t = solve(p0, p1, p2)
        print("{:.10f} {:.10f}".format(t.real, t.imag))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5652
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).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; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

typedef std::pair<ll,ll> P;

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N, H; std::cin >> N >> H;
  std::vector<P> K(N);
  rep(i,N) std::cin >> K[i].first >> K[i].second;
  std::sort( all(K), [](P &x, P &y) { return x.second > y.second; } );
  
  ll amax = -1;
  ll amaxindx = 0;
  rep(i,N) {
    if ( amax <= K[i].first ) {
      amax = K[i].first;
      amaxindx = i;
    }
  }

  ll ans = 0;
  rep(i,N) {
    if ( i != amaxindx && amax <= K[i].second ) {
      H -= K[i].second;
      ans++;
      if ( H <= 0 ) {
        std::cout << ans << std::endl;
        return 0;
      }
    }
  }

  if ( K[amaxindx].first <= K[amaxindx].second ) {
    H -= K[amaxindx].second;
    ans++;
    if ( H <= 0 ) {
      std::cout << ans << std::endl;
      return 0;
    }
  }
  ans += (std::ceil( (double)H/K[amaxindx].first ));
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)


{


    char number[1001];


    int i,sum;


    while(1){


        scanf("%s",number);


        if(number[0]=='0')break;


        sum=0;


        for(i=0;number[i]!='\0';i++){


            sum+=number[i]-'0';


        }


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


    }


    return 0;


}

Measured memory_bytes: 536
fun main(args: Array<String>) {
    val str = readLine()!!
    val k = readLine()!!.toInt()
    val str2 = str + str
    val str3 = str2 + str
    val p = str.toCharArray()
    val q = str2.toCharArray()
    val r = str3.toCharArray()

    val x = cntOperationNum(p)
    val y = cntOperationNum(q)
    val z = cntOperationNum(r)

    when {
        y == 2 * x -> println(x.toLong() * k.toLong())
        y - x == z - y -> println(x.toLong() + (y - x).toLong() * (k - 1).toLong())
        z - y == x -> println(y.toLong() * (k / 2).toLong() + (k % 2).toLong() * x.toLong())
    }
}

fun cntOperationNum(s : CharArray) : Int{
    var cnt = 1
    var x = 0
    for (i in 1 until s.size) {
        if (s[i - 1] == s[i]) {
            cnt += 1
        } else {
            x += cnt / 2
            cnt = 1
        }
    }
    x += cnt / 2
    return x
}

Measured memory_bytes: 31900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/


int main(){
    string s; cin >> s;
    int N = stoi(s.substr(0, s.size()));

    int fn = 0;
    for(int i=0; i<s.size(); i++) fn += stoi(s.substr(i, 1));

    if(N%fn == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#include <sstream>
#include <complex>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double complex<long double>
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	
#define LL_HALFMAX 9223372036854775807 / 2	
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#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 repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

using namespace std;


signed main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int AB = min(A + B, 2 * C);
	int ans = LL_HALFMAX;

	REP(ABCand, 0, max(X, Y) + 1) {
		int Asingle = max(0LL, X - ABCand);
		int Bsingle = max(0LL, Y - ABCand);

		int cand = AB * ABCand + A * Asingle + B * Bsingle;
		chmin(ans, cand);
	}

	cout << ans << "\n";
}

Measured memory_bytes: 256
def compress(n, s)
  list = []
  
  obj = [s[0].to_i, 0]
  
  n.times do |i|
    if obj[0] != s[i].to_i then
      list.push(obj.dup)
      
      obj[0] = s[i].to_i
      obj[1] = 1
    else
      obj[1] += 1
    end
  end
  
  list.push(obj.dup)
  
  return list
end

def main(argv)
  (n, k) = gets.chomp.split(' ').map(&:to_i)
  s = gets.chomp
  
  list = compress(n, s)
  
  cumsum = [0] * (list.size + 1)
  list.size.times do |i|
    cumsum[i + 1] = cumsum[i] + list[i][1]
  end
  
  if (list[0][0] == 0) && (list.size < (k + 2)) then
    puts cumsum[list.size].to_s
  elsif (list[0][0] == 1) && (list.size < (k + 3)) then
    puts cumsum[list.size].to_s
  else
    max = 0
    
    i = 0
    while i < list.size do
      m = -1
      if list[i][0] == 0 then
        m = [list.size, (2 * k + 0) + i].min
      else # list[i][0] == 1
        m = [list.size, (2 * k + 1) + i].min
      end
      
      max = [max, cumsum[m] - cumsum[i]].max
      
      i += 1
    end
    
    puts max.to_s
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

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

int main()
{
  int n; 
  cin >> n;
  string sh;
  cin >> sh;
  int t1 = 0;
  for(int i = 0; i < n; i++)
  {
    if(sh[i] == 'R')
    {
      t1++;
    }
  }
  int t2 = 0;
  for(int i = 0; i < t1; i++)
  {
    if(sh[i] == 'R')
    {
      t2++;
    }
  }
  cout << t1 - t2 << endl;
}

Measured memory_bytes: 3664
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int a, b; string s;
	cin >> a >> b >> s;
	rep(i,s.size()){
		if(i==a) {
			if(s[i] != '-'){
				puts("No");
				return;
			}
		}else{
			int temp = s[i]-'0';
			if(temp < 0 || temp > 9){
				puts("No");
				return;
			}
		}
	}
	puts("Yes");
	return;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;

int main() {
    int n;
    vi v;
    cin>>n;
    pan(i,n) {
        int a;
        cin>>a;
        v.pb(a);
    }
    int minimum=v[0];
    int ans=1;
    for(int i=1;i<n;i++){
        if(minimum>v[i]){
            minimum=min(v[i],minimum);
            ans++;
            //cout<<minimum<<endl;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 1400
/*#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  ff first
#define  ss second
*/
#include <iostream>
using namespace std;
int main(){
   int a,b;
   cin>>a>>b;
   if(a*b%2==1)
    cout<<"Yes";
   else
    cout<<"No";
    return 0;
}


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

int main(){
    int N, M, ans = 0;

    cin >> N >> M;
    
    int H[N], ma[N];

    for(int i=0; i < N; i++){
        cin >> H[i];
        ma[i] = 0;
    }

    for(int i=0; i < M; i++){
        int a, b;

        cin >> a >> b;

        ma[a-1] = max(ma[a-1], H[b-1]);
        ma[b-1] = max(ma[b-1], H[a-1]);
    }

    for(int i=0; i < N; i++){
        if(H[i] > ma[i]) ans++;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 4312
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
	set<int> d;
	cin >> N;
	for(int i=0; i<N; i++){
		int temp;
		cin >> temp; 
		d.insert(temp);
	}
	cout << d.size() << endl;
	return 0;
}

Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)
*/

f(N, Z) :- f(N, 0, Z).
f(0, S, S).
f(N, S, Z) :- g(N, S, S2), N2 is N - 1, f(N2, S2, Z).

g(N, S, S2) :- N mod 3 =\= 0, N mod 5 =\= 0, S2 is N + S, !.
g(_, S, S).

main :-
    get_number(N),
    f(N, Z),
    writeln(Z).


Measured memory_bytes: 8224
#include<stdio.h>

int main(void) {
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0) break;
    for(i=0;i<H;i++){
      for(j=0;j<W;j++)
	printf("#");
      printf("\n");
    }
    printf("\n");
  }
  return(0);
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
# define maxh 2000
# define maxn 3000
// # define mod 1e9+7

int main() {
  int N,sum(0);
  ll a[maxn]={0};
  cin>>N;
  for (int i(0);i<N;i++) cin>>a[i];
  for (int i(0);i<N;i++) sum+=a[i];
  cout << sum-N;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char const *argv[])
{
  int n;
  char s[n],t[n];
  scanf("%d",&n);
  scanf("%s",s);
  scanf("%s",t);
  for(int i=0;i<n;i++){
    printf("%c%c",s[i],t[i]);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define P 998244353
#define B ((ll)1e18%P)
#define MAX 500005
using namespace std;

int n, m, cnt, id;
int head[MAX], vet[MAX], Next[MAX], sg[3][MAX];
ll p[MAX], f[3][MAX];

void add(int x, int y){
    cnt++;
    Next[cnt] = head[x];
    head[x] = cnt;
    vet[cnt] = y;
}

int dfs(int x){
    if(sg[id][x] != -1) return sg[id][x];
    sg[id][x] = 0;
    map<int, bool> mp;
    for(int i = head[x]; i; i = Next[i]){
        int v = vet[i];
        mp[dfs(v)] = true;
    }
    while(mp[sg[id][x]]) sg[id][x]++;
    return sg[id][x];
}

int main()
{
    cin >> n;
    p[0] = 1;
    for(int i = 1; i < MAX; i++){
        p[i] = p[i-1]*B%P;
    }
    memset(sg, -1, sizeof(sg));
    for(id = 0; id < 3; id++){
        memset(head, 0, sizeof(head));
        cnt = 0;
        cin >> m;
        int x, y;
        for(int i = 1; i <= m; i++){
            scanf("%d%d", &x, &y);
            if(x > y) swap(x, y);
            add(x, y);
        }
        for(int i = 1; i <= n; i++){
            if(sg[id][i] == -1) dfs(i);
        }
        for(int i = 1; i <= n; i++){
            (f[id][sg[id][i]] += p[i]) %= P;
        }
    }

    ll ans = 0;
    for(int i = 0; i < 500; i++){
        for(int j = 0; j < 500; j++){
            ans = (ans + f[0][i]*f[1][j]%P*f[2][i^j]%P)%P;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 21504
#include <stdio.h>

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

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

	return 0;
}


Measured memory_bytes: 2708
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=200005;
int n;
char s[N];
int a[N];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int cnt1=0;
	For(i,1,n){
		a[i]=s[i]=='1';
		cnt1+=a[i];
	}
	LL ans=(LL)cnt1/2*(cnt1/2+1);
	if (cnt1&1)
		ans+=(cnt1+1)/2;
	int cnt0=n-cnt1;
	vi v;
	int c0=0,c1=0;
	int p0=0,p1=0;
	For(i,1,n)
		if (a[i]==0){
			if (c1){
				v.pb(c0),c1=c0=0;
				if ((i-1)&1)
					p1++;
				else
					p0++;
			}
			c0++;
		}
		else {
			if (c1)
				ans+=cnt0;
			c1^=1;
		}
	v.pb(c0);
	if (c1){
		v.pb(0);
		if (n&1)
			p1++;
		else
			p0++;
	}
	if (v.size()==1)
		return printf("%lld\n",ans),0;
	while (v[0]>0){
		ans+=p1;
		swap(p0,p1);
		v[0]--;
	}
	For(i,1,(int)v.size()-1){
		p1--;
		while (v[i]>1){
			ans+=i;
			ans+=p1;
			swap(p0,p1);
			v[i]--;
		}
	}
	int flag=0;
	if (v.back()==0){
		if ((int)v.size()==2)
			return printf("%lld\n",ans),0;
		ans+=(int)v.size()-1;
		v.pop_back();
		flag=1;
	}
	int vsz=(int)v.size()-1;
	For(i,0,vsz-1-flag)
		ans+=(vsz+(vsz-i)+1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4900
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll n,x,d,cnt=0;
	cin>>n>>d>>x;
	REP(i,1,n)
	{
		ll a;
		cin>>a;
		cnt+=((d-1)/a)+1;
	}
	cout<<cnt+x;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  map<char,set<ll>> ct;
  map<char,set<ll>> cs;
  for(ll i=0;i<s.size();i++) {
    ct[t[i]].insert(i);
    cs[s[i]].insert(i);
  }
  for(auto p:ct) {
    char temp='0';
    for(ll n:p.second) {
      if(temp=='0') {
        temp=s[n];
      }
      else {
        if(s[n]!=temp) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  for(auto p:cs) {
    char temp='0';
    for(ll n:p.second) {
      if(temp=='0') {
        temp=t[n];
      }
      else {
        if(t[n]!=temp) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 24072
import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int n;

    Scanner in = new Scanner(System.in);

    n = in.nextInt();

    in.nextLine();

    int [] input = new int[n];

    for(int i=0; i<n; i++){
        input[i] = in.nextInt();
    }
    for(int i=n-1; i>0; i--){
        System.out.print(input[i] + " ");
    }
    System.out.println(input[0]);
  }
}

Measured memory_bytes: 26336
#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() {
    ll h,w;
    cin >> h >> w;
    if(min(h,w)==1) cout << 1 << endl;
    else if(h%2==0) cout << h/2*w << endl;
    else if(w%2==0) cout << w/2*h << endl;
    else cout << h/2*w+w/2+1 << endl;
}


Measured memory_bytes: 3580
from operator import itemgetter

def solve():
    N = int(input())
    As = list(map(int, input().split()))
    Bs = list(map(int, input().split()))

    Cs = sorted(As)
    Ds = sorted(Bs)

    for A, B in zip(Cs, Ds):
        if A > B:
            return False

    for i in range(N-1):
        if Cs[i] <= Ds[i+1] and Cs[i+1] <= Ds[i]:
            return True

    ABs = [(A, B) for A, B in zip(As, Bs)]
    ABs.sort(key=itemgetter(1))

    As = [A for A, B in ABs]
    Bs = [B for A, B in ABs]
    iAs = list(range(N))
    iAs.sort(key=lambda iA: As[iA])
    convs = dict()
    for i in range(N):
        convs[As[iAs[i]]] = i

    for i in range(N-2):
        if As[i] <= Bs[i]:
            return True
        X, Y = As[i], As[iAs[i]]
        As[i], As[iAs[i]] = As[iAs[i]], As[i]
        iAs[convs[X]], iAs[convs[Y]] = iAs[convs[Y]], iAs[convs[X]]

    if As[N-2] <= Bs[N-2] and As[N-1] <= Bs[N-1]:
        return True
    else:
        return False

if solve():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 37516
import java.io.*;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int ans = 0;
        char [] s = sc.next().toCharArray();
        int n = s.length;
        for (int i = 0 ; i< n/2 ; i++)
            if (s[i]!=s[n-1-i])ans++;
        out.println(ans);
        out.flush();
        out.close();
    }
    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }


        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

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

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


        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }

}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int a, b, c, d; cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d) << endl;
}


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


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b,c,d;cin >> n >> a >> b >> c >> d;
	string s;cin >> s;
	bool flg1=true,flg2=true,flg3=false;
	a--;b--;c--;d--;
	for(;b<d;++b){
		if(s.at(b-1)=='.' && s.at(b+1)=='.') flg3=true;
		if(s.at(b+1)=='#' && s.at(b+2)=='.') b++;
		else if(s.at(b+1)=='#' && s.at(b+2)=='#') flg2=false;
	}
	if(d+1<n && s.at(d-1)=='.' && s.at(d+1)=='.') flg3=true;
	for(;a<c;++a){
		if(s.at(a+1)=='#' && s.at(a+2)=='.') a++;
		else if(s.at(a+1)=='#' && s.at(a+2)=='#') flg1=false;
	}
	if(flg1 && flg2 && (c<d || flg3)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define mo 1000000007
using namespace std;
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS
int main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     char a;
     cin>>a;
     if(isupper(a))
         cout<<"A"<<endl;
     else
         cout<<"a"<<endl;
     
 return 0;    
}

Measured memory_bytes: 3628
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))


n,a,b,c = mp()
ans_ar = []
q = []
for i in range(n):
    s = input()
    q.append(s)
for i in range(n):
    s = q[i]
    if s == "AB":
        if a == b == 0:
            print("No")
            exit()
        elif a == b == 1 and i != n-1:
            if q[i+1] == "AC":
                a += 1
                b -= 1
                ans_ar.append("A")
            else:
                a -= 1
                b += 1
                ans_ar.append("B")
        elif a >= b:
            a -= 1
            b += 1
            ans_ar.append("B")
        else:
            a += 1
            b -= 1
            ans_ar.append("A")
    if s == "AC":
        if a == c == 0:
            print("No")
            exit()
        elif a == c == 1 and i != n - 1:
            if q[i + 1] == "AB":
                a += 1
                c -= 1
                ans_ar.append("A")
            else:
                a -= 1
                c += 1
                ans_ar.append("C")

        elif a >= c:
            a -= 1
            c += 1
            ans_ar.append("C")
        else:
            a += 1
            c -= 1
            ans_ar.append("A")
    if s == "BC":
        if c == b == 0:
            print("No")
            exit()
        elif c == b == 1 and i != n-1:
            if q[i+1] == "AC":
                c += 1
                b -= 1
                ans_ar.append("C")
            else:
                c -= 1
                b += 1
                ans_ar.append("B")

        elif c >= b:
            c -= 1
            b += 1
            ans_ar.append("B")
        else:
            c += 1
            b -= 1
            ans_ar.append("C")
print("Yes")
for i in ans_ar:
    print(i)



Measured memory_bytes: 85912
def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  s=[list(map(int,input().split()))[1:] for _ in [0]*m]
  p=list(map(int,input().split()))
  count=0
  for i in range(pow(2,n)):
    x=0
    for j in range(m):
      if sum(i&(1<<(k-1))> 0 for k in s[j]) % 2 == p[j]:
        x+=1
    if x==m:
      count+=1
  print(count)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    int n;
    while(cin>>n){
        n%=39;
        if(n==0)n=39;
        printf("3C%02d\n",n);
    }
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    int ans=0;
    for (int i=0;i<n;i++){
        cin>>arr[i];
        ans+=min(abs(k-arr[i]),abs(arr[i]));
    }cout<<ans*2;
    return 0;
}


Measured memory_bytes: 256