akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  int c[3];
  for(int i=1;i<n;i++)
  {
    int x,y,z;
    cin>>x>>y>>z;
    c[0]=x+max(a[1],a[2]);
    c[1]=y+max(a[0],a[2]);
    c[2]=z+max(a[1],a[0]);
    a[0]=c[0];
    a[1]=c[1];
    a[2]=c[2];
  }
  cout<<max(a[0],max(a[1],a[2]));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n, a;
  cin >> n >> a;
  cout << n * n - a << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N, Y = map(int, input().split())
    for i in range(N+1):
        for j in range(N+1-i):
            if i*10000 + j*5000 + (N-i-j)*1000 == Y:
                print(i, j, N-i-j)
                break
        else:
            continue
        break
    else:
        print(-1,-1,-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列


    a=K*2+1
    print(math.ceil(N/a))



if __name__ == "__main__":
    main()

Measured memory_bytes: 77464
n = input()
lst = map(int, raw_input().split())
flag = True
cnt=0
while flag:
    flag = False
    for j in range(n-1,0,-1):
        if lst[j] < lst[j-1]:
            tmp=lst[j-1]
            lst[j-1] = lst[j]
            lst[j] = tmp
            flag = True
            cnt+=1

print " ".join(map(str, (lst)))
print cnt

Measured memory_bytes: 6456
#include<iostream>
#include<cstdlib>

using namespace std;

struct Process {
	char name[10];
	int time;
};

static const int LEN = 100005;

Process Q[LEN];
int head, tail, n;

//void initialize();
//bool isEmpty();
//bool isFull();
void enqueue(Process x);
Process dequeue();
int min(int a, int b);

int main() {
	int q,c;
	int elaps=0;
	Process u;
	cin >> n;
	cin >> q;

	for (int i = 1; i < n+1; i++)
	{
		cin >> Q[i].name;
		cin >> Q[i].time;
	}

	head = 1; tail = n + 1;

	while (head != tail) {
		u = dequeue();
		c = min(q, u.time);
		u.time = u.time - c;
		elaps = elaps + c;
		if (u.time > 0) {
			enqueue(u);
		}
		else {
			cout << u.name << " " << elaps << endl;
		}
	}
	return 0;
}


void enqueue(Process x) {
	Q[tail] = x;
	tail = (tail+ 1) % LEN;
}

Process dequeue() {
	Process x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b) {
	if (a > b) {
		return b;
	}
	else {
		return a;
	}
}


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

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

	long long a;
	string b;
	cin >> a >> b;
	long long t = 0;
	for(auto i : b) {
		if(i == '.')
			continue;
		int dig = i - '0';
		t = t * 10 + dig;
	}
	// cerr << t << "\n";
	long long ans = a * t / 100;
	cout << ans << "\n";
	return 0;

}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <numeric>
#include<algorithm>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    int n,k;
    cin >>n>>k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans;
    ans = accumulate(p.begin(), p.begin()+k,0);
    cout << ans << endl;
}

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

using namespace std;

map <int64_t, int64_t> m1;
int64_t res = 0;




int main(){
    int n, m; cin >> n >> m;
    int res = 0;
    while(n > 0){
        res++;
        n /= m;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
if N%2 == 1:
    print("No")
else:
    a = 0
    for i in range(N//2):
        if S[i] != S[N//2+i]:
            a += 1
    if  a == 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
    ll x;
    cin >> x;
    bitset<32> x_bit(x);
    cout << x_bit << endl;
    cout << ~x_bit << endl;
    cout << (x_bit << 1) << endl;
    cout << (x_bit >> 1) << endl;
}



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

struct Node {
	int v;
	Node* l;
	Node* r;
	Node() : v(0), l(nullptr), r(nullptr) {}
};

int N, c;
string s;

Node* f() {
	Node* r = nullptr;
	if(c < N && s[c] == '(') {
		c++;
		r = new Node();
		r->l = f();
		assert(s[c] == ')');
		c++;
	}
	if(c < N && s[c] == '[') {
		if(r == nullptr) r = new Node();
		c++;
		while(s[c] != ']') {
			r->v = r->v * 10 + s[c] - '0';
			c++;
		}
		c++;
	}
	if(c < N && s[c] == '(') {
		if(r == nullptr) r = new Node();
		c++;
		r->r = f();
		assert(s[c] == ')');
		c++;
	}
	return r;
}

Node* r[2];

void g(Node* n1, Node* n2) {
	if(n1 == nullptr || n2 == nullptr) return;
	cout << '(';
	g(n1->l, n2->l);
	cout << ')';
	cout << '[' << n1->v + n2->v << ']';
	cout << '(';
	g(n1->r, n2->r);
	cout << ')';
}

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

	for(int i = 0; i < 2; i++) {
		cin >> s;
		N = s.size();
		c = 0;
		r[i] = f();
	}
	g(r[0], r[1]);
	cout << endl;
}

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


int main(){
  ll x,y,a,b,c; cin >> x >> y >> a >> b >> c;
  vl av(a); vl bv(b); vl cv(c); vl dv(x+y+c);
  rep(i,a){ ll f; cin >> f; av[i] = f; }
  rep(i,b){ ll f; cin >> f; bv[i] = f; }
  rep(i,c){ ll f; cin >> f; cv[i] = f; }
  
  sort(all(av)); sort(all(bv));
  
  for(ll i=0; i < x; i++){
    dv[i] = av[a-1-i];
  }
  for(ll i=0; i < y; i++){
    dv[x+i] = bv[b-1-i];
  }
  for(ll i=0; i < c; i++){
    dv[x+y+i] = cv[i];
  }
  
  sort(all(dv));
  
  ll sum = 0;
  for(ll i=0; i < x+y; i++){
    sum += dv[x+y+c-1-i];
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define ll long long
using namespace std;
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; }
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
  ll N,ans=0;
  cin>>N;
  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> C(N);
  for(ll i=0;i<N;i++) cin>>A[i];
  for(ll i=0;i<N;i++) cin>>B[i];
  for(ll i=0;i<N;i++) cin>>C[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  for(ll i=0;i<N;i++){
    ll a,c;
    ll l=-1,r=N;
    while(r-l>1){
      ll m=(r+l)/2;
      if(A[m]>=B[i]) r=m;
      else l=m;
      a=r;
    }
    l=-1,r=N;
    while(r-l>1){
      ll m=(r+l)/2;
      if(C[m]>B[i]) r=m;
      else l=m;
      c=r;
    }
    ans+=a*(N-c);
  }
  cout<<ans<<endl;
}


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

int main(){
    string S, T;
    char temp;
    int i, j, n;

    cin >> S;
    cin >> T;

    n = S.length();

    if(S == T){
        cout << "Yes" << endl;
        return 0;
    }

    for(i=0; i<n; i++){
        temp = S[n-1];

        for(j=n-2; j>=0; j--){
            S[j+1] = S[j];
        }
        S[0] = temp;

        if(S == T){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int X;
  cin >> X;
  if (X>=2000) cout << 1 << endl;
  else {
    bool can = false;
    for (int i=0; i<20; i++) {
      for (int j=0; j<20; j++) {
        for (int k=0; k<20; k++) {
          for (int l=0; l<20; l++) {
            for (int m=0; m<20; m++) {
              for (int n=0; n<20; n++) {
                if (100*i+101*j+102*k+103*l+104*m+105*n==X) {
                  can = true;
                  break;
                }
              }
              if (can) break;
            }
            if (can) break;
          }
          if (can) break;
        }
        if (can) break;
      }
      if (can) break;
    }
    if (can) cout << 1 << endl;
    else cout << 0 << endl;
  }
}

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

#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF					INT_MAX
#define LLINF					LLONG_MAX
#define DEBUG					false

typedef long long				ll;
typedef pair <int, int> ii;

int main() {

	set<int> s;
	rep(i, 3){
		int tmp;
		cin >> tmp;
		s.insert(tmp);
	}
	
	cout << s.size() << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,res=0;
    cin >> n;
    rep(i,n) res += i+1;
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 1000
 
int main()
{
    int N, Num[MAX], P[MAX], Q[MAX], R[MAX], Cal[MAX];
 
    while (cin >> N, N) {
	int p, q, r, c;
	for (int i = 0; i < N; i++) {
	    cin >> Num[i] >> P[i] >> Q[i] >> R[i];
	    Cal[i] = P[i]*4 + Q[i]*9 + R[i]*4;
	}
 
	vector<int> ans;
	cin >> p >> q >> r >> c;
	for (int i = 0; i < N; i++) {
	    if (P[i] <= p && Q[i] <= q && R[i] <= r && Cal[i] <= c) {
		ans.push_back(Num[i]);
	    }
	}
	int size = ans.size();
	if (size) {
	    for (int i = 0; i < size; i++) {
		cout << ans[i] << endl;
	    }
	} else {
	    cout << "NA" << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3168
// 
// 問題URL: 
// 中央*右
// 

#include <iostream>

using namespace std;

int N, u, k, v, Adj[105][105]={};

int main(){
    cin >> N;

    for(int i = 1; i <= N; i++){
        cin >> u >> k;
        for(int j = 1; j <= k; j++){
            cin >> v;
            Adj[i][v] = 1;
        } 
    }

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            cout << Adj[i][j];
            if(j==N) cout << endl;
            else cout << " ";
        }
    }
}



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

int descending_compare(const void *a, const void *b){
    if (*(long long*)a > *(long long*)b){
        return -1;
    }else if (*(long long*)a == *(long long*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/


long long v[51];
unsigned long long triangle[100][100] = {0};

int main(void){
    for (int i = 0; i < 100; i++){
        triangle[i][0] = 1;
    }
    triangle[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
            triangle[i][j] = (triangle[i-1][j-1]+triangle[i-1][j]);
        }
    }
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    for (int i = 0; i < n; i++){
        scanf("%lld", &v[i]);
    }
    qsort(v, n, sizeof(long long), descending_compare);
    long long min = v[a-1];
    int lcnt = 0;
    int rcnt = 0;
    double ave = 0;
    unsigned long long ans = 0;
    for (int i = 0; i < n; i++){
        if (i < a){
            ave += (double)v[i];
        }
        if (v[i] == min){
            lcnt++;
        }
        if (v[i] == min && i < a){
            rcnt++;
        }
    }
    if (min == v[0]){
        for (int i = a; i <= b && i <= lcnt; i++){
            ans += triangle[lcnt][i];
        }
    }else{
        ans = triangle[lcnt][rcnt];
    }
    ave /= a;
    printf("%f\n%llu\n", ave, ans);

}


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

int main() {
    string S;
    cin >> S;
    
    int N = S.size();
    
    vector<int> cnt(N-1,0), R(N-1,0),L(N-1);
    int r = 0, l = 0;
    int pos;
    for ( int i = 0; i < N-1; ++i){
        if ( S.at(i) == 'R' and S.at(i+1) == 'L') {
            ++r;
            R.at(i) = r;
            r = 0;
            cnt.at(i) = 1;
            pos = i;
        } else if ( S.at(i) == 'L' and S.at(i+1) == 'R') {
            ++l;
            L.at(pos) = l;
            l = 0;
        } else if ( S.at(i) == 'R' and S.at(i+1) == 'R'){
            ++r;
        } else {
            ++l;
        }
    }
    L.at(pos) = l + 1;
    
    vector<int> ans (N,0);
    for ( int i = 0; i < N-1; ++i){
        if ( cnt.at(i) == 1 ){
            ans.at(i) = ( R.at(i) + 1 ) / 2 + L.at(i) / 2;
            ans.at(i+1) =  R.at(i)  / 2 + ( L.at(i) + 1 ) / 2;
        }
    }

    for ( int i = 0; i < N; ++i){
        cout << ans.at(i) << " " ;
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const ll INF=1000100010001000;
const int MAX_N=103;
struct edge{
    int to,rev;ll cap;
    edge(int to,ll cap,int rev):
    to(to),cap(cap),rev(rev){}
    };

vector<edge> g[MAX_N];
bool used[MAX_N];
void add_edge(int src,int dst,ll cap){
    g[src].pb(edge(dst,cap,g[dst].size()));
    g[dst].pb(edge(src,0,g[src].size()-1));
}
ll dfs(int v,int t,ll f){
    if(v==t) return f;
    used[v]=true;
    rep(i,g[v].size()){
        edge &e=g[v][i];
        if(!used[e.to]&&e.cap>0){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                g[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
ll max_flow(int s,int t){
    ll flow=0;
    while(1){
        memset(used,0,sizeof(used));
        ll f=dfs(s,t,INF);
        if(f==0) return flow;
        flow+=f;
    }
}
int main(){
    int n,ai;
    ll sum=0;
    cin>>n;
    int s=101,t=102;
    FOR(i,1,n+1){
        cin>>ai;
        if(ai>0){
            sum+=ai;
            add_edge(i,t,ai);
        }
        else add_edge(s,i,-ai);
    }
    FOR(i,1,n+1){
        for(int j=2;j*i<=n;++j){
            add_edge(i,j*i,INF);
        }
    }
    ll c=max_flow(s,t);
    cout<<sum-c<<endl;
    return 0;
}

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

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int N, M; cin >> N >> M;
    vector<pii> ba(M);
    REP(i, M) cin >> ba[i].second >> ba[i].first;
    
    sort(ba.begin(), ba.end());

    int x = 0;
    int ans = 0;
    REP(i, M) {
        if (ba[i].second > x) {
            x = ba[i].first - 1;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  ll X, Y; cin >> X >> Y;
  if(abs(X - Y) <= 1) cout << "Brown" << endl;
  else cout << "Alice" << endl;
}


Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new bool[n];
        var b = new bool[n];
        var c = new bool[n];
        setArray(a, b, c);
        var count = 0;
        for (int i = 0; i < n; i++)
            if ((!a[i] && c[i]) || (b[i] && c[i])) count++;
        Console.WriteLine(count);
    }
    public static void setArray(bool[] a, bool[] b, bool[] c)
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        for (int i = 0; i < n; i++)
        {
            var w = int.Parse(line[i + 1]) - 1;
            a[w] = true;
        }
        line = Console.ReadLine().Trim().Split(' ');
        n = int.Parse(line[0]);
        for (int i = 0; i < n; i++)
        {
            var w = int.Parse(line[i + 1]) - 1;
            b[w] = true;
        }
        line = Console.ReadLine().Trim().Split(' ');
        n = int.Parse(line[0]);
        for (int i = 0; i < n; i++)
        {
            var w = int.Parse(line[i + 1]) - 1;
            c[w] = true;
        }
    }
}




Measured memory_bytes: 17928
s=list(map(int,input().split()))
mod=10**9+7
a=s[0]
b=s[1]
e=0
if b==1:
  b+=1
  e+=(a+1)
c=sum(range(0,b))
d=sum(range(a+1-b,a+1))
for i in range(b,a+2):
  if i!=b:
    c+=(i-1)
    d+=(a-i+1)
  e+=(d-c+1)
  e%=mod
print(e)

Measured memory_bytes: 9192
#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 ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n;
  string s,ss,sss;
  cin>>a>>b;
  if(a==b)
  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main implements Comparable<Main>{

	int l;
	public Main(int l) {
		this.l = l;
	}
	
	public int compareTo(Main o) {
		if(l < o.l)return 1;
		else if(l > o.l)return -1;
		else return 0;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int l[] = new int[2 * n];
		for(int i = 0; i < 2 * n; ++i)l[i] = sc.nextInt();
		sc.close();
		Arrays.sort(l);
		int ans = 0;
		for(int i = 0; i < 2 * n - 1; i += 2) {
			ans += l[i];
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22484
#include <iostream>
#include <algorithm>
using namespace std;
int H, W, ra, o, a[40][40], sum[40][40]; pair<int, int> dp[40][40][40][40];
inline int rng(int x1, int y1, int x2, int y2) {
	return sum[y2][x2] + sum[y1][x1] - sum[y2][x1] - sum[y1][x2];
}
pair<int, int> solve(int x1, int y1, int x2, int y2) {
	if (dp[y1][x1][y2][x2].first != -1) return dp[y1][x1][y2][x2];
	int rng_ = rng(x1, y1, x2, y2);
	pair<int, int> ret = make_pair(1, rng_);
	for (int i = x1 + 1; i < x2; i++) {
		int petl = rng(x1, y1, i, y2);
		int petr = rng(i, y1, x2, y2);
		if (min(petl, petr) >= o) {
			pair<int, int> resl = solve(x1, y1, i, y2);
			pair<int, int> resr = solve(i, y1, x2, y2);
			pair<int, int> res = make_pair(resl.first + resr.first, min(resl.second, resr.second));
			ret = max(ret, res);
		}
	}
	for (int i = y1 + 1; i < y2; i++) {
		int petl = rng(x1, y1, x2, i);
		int petr = rng(x1, i, x2, y2);
		if (min(petl, petr) >= o) {
			pair<int, int> resl = solve(x1, y1, x2, i);
			pair<int, int> resr = solve(x1, i, x2, y2);
			pair<int, int> res = make_pair(resl.first + resr.first, min(resl.second, resr.second));
			ret = max(ret, res);
		}
	}
	return dp[y1][x1][y2][x2] = ret;
}
int main() {
	while (cin >> H >> W >> ra, H) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) cin >> a[i][j];
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + a[i][j];
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				for (int k = i + 1; k <= H; k++) {
					for (int l = j + 1; l <= W; l++) dp[i][j][k][l].first = -1;
				}
			}
		}
		o = sum[H][W] - ra;
		pair<int, int> ret = solve(0, 0, W, H);
		cout << ret.first << ' ' << ret.second - o << endl;
	}
}

Measured memory_bytes: 12020
import java.util.ArrayList;
import java.util.BitSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			if(n==0) break;
			BitSet[] info = new BitSet[n];
			for(int i=0; i<n; i++){
				int m = in.nextInt();
				info[i] = new BitSet(n);
				for(int j=0; j<m; j++){
					info[i].set(in.nextInt()-1);
				}
				info[i].flip(0, n);
			}
			BitSet flow = new BitSet(n);
			int k=in.nextInt();
			for(int i=0; i<k; i++){
				flow.set(in.nextInt()-1);
			}
			int mem = -1;
			BitSet tmp = new BitSet(n);
			for(int i=0; i<n; i++){
				tmp.clear(0, n);
				tmp.or(flow);
				tmp.and(info[i]);
				if(tmp.cardinality()==0){
					if(mem == -1) mem = i+1;
					else{
						mem = -1;
						break;
					}
				}
			}
			System.out.println(mem);
		}
	}
}

Measured memory_bytes: 68420
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MAXN 100001
#define MOD 1e9+5

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

int main(){
    ll H, N;
    cin >> H >> N;
    vi v(MAXN,0);
    ll sum = 0;
    for(int i = 0; i < N; i++){
        scanf("%d", &v[i]);
        sum += v[i];
    }
    if( sum >= H )
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

a, b, k = Is()
g = gcd(a, b)
count = 0
for i in reversed(range(1, g+1)):
    if g % i == 0:
        count += 1
        if count == k:
            print(i)
            exit()


Measured memory_bytes: 63212
import numpy as np
import itertools
h,w,k=map(int,input().split())
g=np.ones((h,w))
l=['' for _ in range(h)]
for i in range(h):
  l[i]=str(input())
for i in range(h):
  for j in range(w):
    if l[i][j]=='.': g[i][j]=0
s=np.sum(g)
ans=0
for i in range(h):
  for j in range(w):
    u=list(itertools.combinations(range(h),i))
    v=list(itertools.combinations(range(w),j))
    for x in u:
      for y in v:
        a=0
        b=0
        c=0
        for p in x:
          a+=np.sum(g[p,:])
        for q in y:
          b+=np.sum(g[:,q])
        for p in x:
          for q in y:
            c+=g[p][q]
        if s-a-b+c==k: 
          ans+=1
print(ans)

Measured memory_bytes: 26984
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {

	int n;
	cin >> n;
	bool OK = false;
	for (int i = 1; i <= 9; i++)
	{
		for (int j = 0; j <= 9; j++)
		{
			if (i * j == n) {
				OK = true;
				break;
			}
		}
	}

	if (OK)cout << "Yes" << endl;
	else cout << "No" << endl;


}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int N;
	int i = 0;
	int count = 0;
	cin >> N;
	while (true) {
		if (N > count) {
			count += 1000;
		}
		else {
			cout << count - N;
			break;
		}
	}

}

Measured memory_bytes: 3156
h,w=gets.split.map(&:to_i)
board = h.times.map{ gets.chomp.strip }

dx = [1,0,-1,0,1,-1,-1,1]
dy = [0,1,0,-1,1,1,-1,-1]

for i in 0..h-1
  for j in 0..w-1
    next if board[i][j] == '#'

    num = 0
    for d in 0..7
      ni = i + dy[d]
      nj = j + dx[d]

      next if (ni < 0 or h <= ni)
      next if (nj < 0 or w <= nj)
      num += 1 if board[ni][nj] == '#'
    end
    board[i][j] = num.to_s
  end
end
puts board

Measured memory_bytes: 1788
import numpy as np

S = input()
X = list(int(x) for x in S)


def test(Z):
    a = X[0]
    b = X[1] if Z[0] else -X[1]
    c = X[2] if Z[1] else -X[2]
    d = X[3] if Z[2] else -X[3]
    return a + b + c + d == 7


Y = [None] * (2 * len(X) - 1)
Y[::2] = X
for i in range(8):
    Z = [i & 1, i & 2, i & 4]
    if test(Z):
        Y[1::2] = ['+' if z else '-' for z in Z]
        break
print(*Y, sep='', end='=7\n')


Measured memory_bytes: 14488
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] histOdd = new int[100001];
        int[] histEven = new int[100001];
        for (int i = 0; i<n; i++) {
            int t = sc.nextInt();
            if (i%2==0) {
                histEven[t]++;
            }
            else {
                histOdd[t]++;
            }
        }

        int oddMax = 0;
        int omValue = 0;
        int oddSecondMax = 0;
      
        int evenMax = 0;
        int emValue = 0;
        int evenSecondMax = 0;
        for (int i = 0; i<100001; i++) {
            if (evenMax < histEven[i]) {
                emValue = i;
                evenMax = histEven[i];
            }
            if (oddMax < histOdd[i]) {
                omValue = i;
                oddMax = histOdd[i];
            }
        }
      
         for (int i = 0; i<100001; i++) {
            if (evenSecondMax < histEven[i] && emValue != i) {
                evenSecondMax = histEven[i];
            }
            if (oddSecondMax < histOdd[i] && omValue != i) {
                oddSecondMax = histOdd[i];
            }
        }        
      
        if (emValue == omValue) {
        	oddMax = Math.max(evenSecondMax, oddSecondMax);
        }

        int result = n - oddMax - evenMax; 
        System.out.println(result);
    }
}

Measured memory_bytes: 51268
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
E = []
for i in range(N):
    s, t, x = map(int, input().split())
    E.append((s - x, t - x, x))

D = []
for i in range(Q):
    d = int(input())
    D.append(d)

E = sorted(E)

que = []

s, t, x = E[0]
j = 1
y, e = N, N
ans = [-1] * Q
for i, d in enumerate(D):
    while j < N + 1 and s <= d:
        heappush(que, (x, t))
        y, e = que[0]
        if j < N:
            s, t, x = E[j]
        j += 1
    while que and e <= d:
        heappop(que)
        if que:
            y, e = que[0]

    if que:
        ans[i] = y

for i in ans:
    print(i)

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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D;
    cin >> D;
    if(D == 25){
    	cout << "Christmas" << endl;
    }
    else if(D == 24){
    	cout << "Christmas Eve" << endl;
    }
    else if(D == 23){
    	cout << "Christmas Eve Eve" << endl;
    }
    else if(D == 22){
    	cout << "Christmas Eve Eve Eve" << endl;
    }
    ED
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n; cin>>n;
    vi perm(n);
    rep(i, n) perm[i] = i;
    vi x(n), y(n);
    rep(i, n) cin>>x[i]>>y[i];

    int num=0;
    double sum = 0.0;
    do{
        rep(i, n-1){
            int prev = perm[i], next = perm[i+1];
            int dx = x[next]-x[prev];
            int dy = y[next]-y[prev];
            sum += sqrt(dx*dx+dy*dy);
        }
        num++;
    }while(next_permutation(perm.begin(), perm.end()));
    double ans = sum/num;
    cout << setp(12) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,k,q,a; cin >> n >> k >> q;
    int A[n]={0};
    for (int i=0; i<q; i++){
        cin >> a;
        A[a-1] += 1; 
    }
    for (int i=0; i<n; i++){
        A[i] += k-q;
        cout << (A[i]>0 ? "Yes" : "No") << endl;
    }
} 

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define re register
#define FOR(i,a,b) for(re int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(re int i=(a);i>=(b);i--)
#define temT template<typename T>
using namespace std;
typedef long long ll;
const int N=int(2e5)+10;
const ll mo=ll(1e9)+7;
const int inf=int(2e9)+7;

temT inline T add(T x,T y){return (x+y)%mo;}
temT inline T dec(T x,T y){return (x-y+mo)%mo;}
temT inline T mul(T x,T y){return (ll)x*y%mo;}
temT inline int mpw(int x,T y){
	int res=1;
	for(;y;y>>=1,x=mul(x,x))
		if(y&1)	res=mul(res,x);
	return res;
}

int a[N],n,K,pi,pj,ct,ze;	int res=1;

inline void fix(){
	int m=0;	static int tmp[N];
	FOR(i,1,n)	if(a[i]!=0)	tmp[++m]=a[i];
	FOR(i,1,m)	a[i]=tmp[i];	n=m;
}
inline bool allmi(){FOR(i,1,n) if(a[i]>0) return 0;	return 1;}
inline bool cmp(int a1,int b1,int a2,int b2){//compare a1/b1,a2/b2
	return (ll)a1*b2>(ll)a2*b1;
}

int main(){
	cin>>n>>K;	FOR(i,1,n)	cin>>a[i];
	FOR(i,1,n)	if(a[i]==0) ze++;
	if(n-ze<K)	return cout<<0,0;
	fix();	sort(a+1,a+n+1);
	if(allmi()){
		if((K&1)==0){
			FOR(i,1,K)	res=mul(res,abs(a[i]));
			cout<<res;
		}else{
			ROF(i,n,n-K+1)	res=mul(res,abs(a[i]));
			cout<<(ze?0:mo-res);
		}return 0;
	}
	for(pi=1,pj=n,ct=0;K--;){
		if(abs(a[pi])>abs(a[pj]))
			res=mul(res,abs(a[pi])),ct+=a[pi]<0,pi++;
		else
			res=mul(res,abs(a[pj])),ct+=a[pj]<0,pj--;
	}
	if(ct&1){
		int a1=-inf,b1=-inf;//a1:min <0 , b1:max >0
		int a2=inf,b2=inf;//a2:min >0 , b2:max <0
		FOR(i,1,pi-1) if(a[i]<0) a1=max(a1,a[i]);
		FOR(i,pi,pj)	if(a[i]>0)	b1=max(b1,a[i]);
		FOR(i,pj+1,n) if(a[i]>0) a2=min(a2,a[i]);
		FOR(i,pi,pj)	if(a[i]<0)	b2=min(b2,a[i]);
		a1=abs(a1),b1=abs(b1),a2=abs(a2),b2=abs(b2);
		if((a1==inf || b1==inf) && (a2==inf || b2==inf)){
			if(ze)	res=0;
			else 	res=mo-res;
		}
		else if(a1==inf || b1==inf)
			res=mul(res,mul(b2,mpw(a2,mo-2)));
		else if(a2==inf || b2==inf)
			res=mul(res,mul(b1,mpw(a1,mo-2)));
		else{
			if(cmp(b1,a1,b2,a2))
				res=mul(res,mul(b1,mpw(a1,mo-2)));
			else
				res=mul(res,mul(b2,mpw(a2,mo-2)));
		}
	}
	cout<<res;
	return 0;
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(a >= 0 && c >= 0)
    {
        c = c - b;
        if(c <= 0)
        {
             cout << "Yes \n";
             break;
        }
        a = a - d;
        if(a <= 0)
        {
            cout << "No \n";
            break;
        }
    }




    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int N,a=0,i,count=0,j,max=0;
	int H[100];
	cin >> N;
	for( i = 0; i < N; i++ )
	{
		cin >> H[i];
	}

	for( i = 0; i < N; i++ )
	{
		count = 0;
		for( j = 0; j < i; j++ )
		{
			if( H[i] >= H[j] )
			{
				count++;
			}
		}
		if( count == i )
		{
			max++;
		}
	}

	cout << max <<endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<ll, int> ll_i;
struct edge { int u, v; double w; };

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return (v[x] < 0) ? x : (v[x] = find(v[x])); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x != y) {
			if (-v[x] < -v[y]) swap(x, y);
			v[x] += v[y]; v[y] = x;
		}
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

bool kr_cmp(const edge& l, const edge& r) { return l.w < r.w; }

double kruskal(int n, vector<edge>& E) {
	sort(E.begin(), E.end(), kr_cmp);
	union_find uf(n);
	double res = 0;
	for (int i = 0; i < E.size(); i++) {
		edge e = E[i];
		if (uf.same(e.u, e.v)) continue;
		uf.unite(e.u, e.v);
		res += e.w;
	}
	return res;
}

int x[10000], y[10000];

int main() {
	int N, M; scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++)
		scanf("%d%d", &x[i], &y[i]);
	vector<edge> E;
	double ans = 0;
	for (; M > 0; M--) {
		int p, q; scanf("%d%d", &p, &q);
		int dx = x[p - 1] - x[q - 1];
		int dy = y[p - 1] - y[q - 1];
		double l = sqrt((double)(dx * dx + dy * dy));
		ans += l;
		edge e = {p - 1, q - 1, -l}; E.push_back(e);
	}
	printf("%lf\n", ans + kruskal(N, E));
}

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

int main() {
    string s,t;
    cin >> s;
    cin >> t;

    int tekichu = 0;
    if(s[0] == t[0]) tekichu++;
    if(s[1] == t[1]) tekichu++;
    if(s[2] == t[2]) tekichu++;
    cout << tekichu;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	LLi x, k, d, kai, d1, d2;

	cin>> x >> k >> d;

	x=abs(x);
	kai=x/d;

	if(k<=kai){
		cout<< abs(x-k*d) <<endl;
		return 0;
	}

	k-=kai;

	d1=abs(x-kai*d);
	d2=d-d1;

	if(k%2==0) cout<< d1 << endl;
	else cout<< d2 << endl;
 
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <math.h>

int main() {
    double N, X, Y;
    scanf("%lf %lf %lf", &N, &X, &Y);
    int count[(int) N];
    for (int i = 0; i < N; i++) {
        count[i] = 0;
    }
    for (int i = 1; i < N; i++) {
        for (int j = i + 1; j < N + 1; j++) {
            count[(int)fmin(abs(i - j), fmin(fabs(X - i) + 1 + fabs(j - Y), fabs(Y - i) + 1 + fabs(j - X)))] += 1;
        }
    }
    for (int i = 1; i < N; i++) {
        printf("%d\n", count[i]);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void bitrow(vector<int> &vec,int x,int n){
    for(int i=n-1;i>=0;i--){
        vec.at(i)=x/(int)pow(2,i);
        x%=(int)pow(2,i);
    }
}

int main(){
    int n,tmp1,tmp2;
    cin >> n;
    vector<int> a(0);
    vector<vector<int> > x(n,vector<int>(0));
    vector<vector<int> > y(n,vector<int>(0));
    for(int i=0;i<n;i++){
        cin >> tmp1;
        a.push_back(tmp1);
        for(int j=0;j<a.at(i);j++){
            cin >> tmp1 >> tmp2;
            x.at(i).push_back(tmp1-1);
            y.at(i).push_back(tmp2);
        }
    }
    vector<int> vec(n);
    int count=0;
    for(int i=0;i<pow(2,n);i++){
        int flag=1;
        bitrow(vec,i,n);
        vector<int> hantei(n);
        for(int j=0;j<n;j++)hantei.at(j)=vec.at(j);
        for(int j=0;j<n;j++){
            for(int k=0;k<a.at(j);k++){
                if(vec.at(j)==1){   //正直な場合
                    if(hantei.at(x.at(j).at(k))!=y.at(j).at(k)){
                        flag=0;
                        break;
                    }
                }
            }
            if(flag==0)break;
        }
        if(flag==1){
            int sum=0;
            for(int j=0;j<n;j++){
                sum+=vec.at(j);
            }
            count=max(count,sum);
        }
    }
    cout << count << endl;
}

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

int calcTime(int sh, int sm, int eh, int em) {
    int hour, minute;
    int t;
    hour = eh - sh;
    minute = em - sm;
    t = hour * 60 + minute;
    return t;
}

void calcEndTime(int* h, int* m, int k) {
    int minute;
    minute = *m - k;
    while (true) {
        if (minute < 0) {
            *h = *h - 1;
            minute = 60 + minute;
        }
        if (minute >= 0) {
            *m = minute;
            break;
        }
    }
}

int main(void) {
    int h1, h2, m1, m2, k;
    int ans;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    calcEndTime(&h2, &m2, k);
    ans = calcTime(h1, m1, h2, m2);
    if (ans < 0) { ans = 0; }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class UnionFind():
    def __init__(self):
        self.__table = {}
        self.__size = defaultdict(lambda: 1)

    def __root(self, x):
        if x not in self.__table:
            self.__table[x] = x
        elif x != self.__table[x]:
            self.__table[x] = self.__root(self.__table[x])

        return self.__table[x]

    def same(self, x, y):
        return self.__root(x) == self.__root(y)

    def union(self, x, y):
        x = self.__root(x)
        y = self.__root(y)
        if x != y:
            # self.__size[x] += self.__size[y]
            self.__size[y] += self.__size[x]
            self.__table[x] = y
            

    def size(self, x):
        return self.__size[self.__root(x)]

@mt
def slv(N, M, AB):
    uf = UnionFind()

    ans = [N*(N-1)//2]
    for a, b in reversed(AB):
        if uf.same(a, b):
            ans.append(ans[-1])
        else:
            s1, s2 = uf.size(a), uf.size(b)
            uf.union(a, b)
            ans.append(ans[-1] - s1*s2)
            
    ans.pop()

    for a in reversed(ans):
        print(a)
            

    # return ans


def main():
    # N = read_int()
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    slv(N, M, AB)



if __name__ == '__main__':
    main()


Measured memory_bytes: 51736
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                        ll n;
                        ll ans=0;
                        string test="ABC";
                        string str;
                        cin>>n>>str;
                        rep(i,0,n-2){
                                rep(j,0,3)
                                        if(str[i+j]!=test[j])
                                                break;
                                        else{
                                                if(j==2)
                                                        ++ans;
                                        }
                        }
                        cout<<ans;
                }
                int main(){
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                // cout<<"Case "<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

//The Secret Number
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if((w|h)==0)break;
			char[][] m = new char[h][w];
			for(int i=0;i<h;i++)m[i]=sc.next().toCharArray();
			String[][] dp = new String[h][w];
			String res = "0";
			for(int i=h-1;i>=0;i--)for(int j=w-1;j>=0;j--){
				if(Character.isUpperCase(m[i][j]))continue;
				String l = m[i][j]+"";
				String d = m[i][j]+"";
				if(i+1<h&&!Character.isUpperCase(m[i+1][j]))d+=dp[i+1][j];
				if(j+1<w&&!Character.isUpperCase(m[i][j+1]))l+=dp[i][j+1];
				if(l.length()!=d.length()){
					dp[i][j] = l.length()>d.length()?l:d;
				}
				else{
					BigInteger bl = new BigInteger(l);
					BigInteger bd = new BigInteger(d);
					if(bl.compareTo(bd)>0)dp[i][j] = l;
					else dp[i][j] = d;
				}
				BigInteger b = new BigInteger(dp[i][j]);
				if(b.compareTo(new BigInteger(res))>0){
					res = dp[i][j];
				}
			}
			System.out.println(new BigInteger(res).toString());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 14000