akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;
signed main(){
    int n,k;
    cin>>n>>k;
    int r=n%k;
    if(k==1){
        cout<<0<<endl;
        return 0;
    }
    
    cout<<min(r,abs(k-r))<<endl;
    return 0;
}

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

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);
}

int main() {
    fast();
    ll n,W;
    cin >>n >>W;
    
    pair<ll,ll> arr[n];

    ll weight[n],value[n];
    for(ll i=0;i<n;i++){
        cin >>arr[i].first >>arr[i].second;
    }
    sort(arr, arr+n);
    
    for(ll i=0;i<n;i++){
        weight[i] = arr[i].first;
        value[i] = arr[i].second;
    }
    
    ll dp[n+1][W+1];
    memset(dp, 0, sizeof(dp));
    
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=W;j++){
            if(j>=weight[i-1]){
                dp[i][j] = max( value[i-1]+dp[i-1][j-weight[i-1]], dp[i-1][j] );
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    
    cout<<dp[n][W];
    
    return 0;
}


Measured memory_bytes: 82428
#include <iostream>
#include <utility>
#include <set>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

int n;
llint x[55], y[55];
set<P> S;

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	
	llint ans = n+1;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i == j) continue;
			if(x[i] == x[j] && y[i] == y[j]) continue;
			if(x[i] > x[j]) continue;
			llint p = x[j]-x[i], q = y[j]-y[i];
			
			S.clear();
			for(int i = 1; i <= n; i++) S.insert(make_pair(x[i], y[i]));
			llint tmp = 0;
			P pre; bool first = true;
			while(S.size()){
				P nx = make_pair(pre.first + p, pre.second + q);
				if(!first && S.count(nx)){
					pre = nx;
					S.erase(nx);
				}
				else{
					pre = *S.begin();
					S.erase(S.begin());
					tmp++;
				}
				first = false;
			}
			//cout << p << " " << q << " " << tmp << endl;
			ans = min(ans, tmp);
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int h,w;
  cin >> h >> w;

  vector<string> c(h);

  rep(i,h) cin >> c[i];

  rep(i,h) cout << c[i] << endl << c[i] << endl;
  return 0;
} 

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <random> 
#include <vector>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_map>

#define ID(x,y) (((x)-1) * m + (y))
#define CL clear
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define low_bit(x) ((x)&(-(x)))
#define dmp(x) cerr<<#x<<"="<<x<<"\n"  
#define MIN(a,b,c) min(a,min(b,c))
#define MAX(a,b,c) max(a,max(b,c))
#define SZ(x) ((int)(x.size())) 
#define sc scanf
#define pf printf
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define dep(i,a,b) for(int i=(a);i>=(b);i--)

#define int long long

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;

const int N = (int)1e6+10;
const int mod = 1e9+7;
const int inf = 1e9;
const double eps = 1e-16;
const double pi = acos(-1);


inline int rd() {
  int p=0; int f=1; char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-') f*=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+ch-'0'; ch=getchar();}
  return p*f;
}



signed main() {
  // freopen("a.in","r",stdin);
  // freopen("a.out","w",stdout);
  int x = rd();
  int s = 100;
  rep(i,1,inf) {
  	s = (s + s/100);
  	if(s >= x){printf("%lld\n",i); return 0;}
  }

  return 0;
}

/*
*/


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

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

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans=0,total=0;
    for(int i=0;i<n;i++){
        if(total<=x) ans++;
        total+=a[i];
    }
    if(total<=x) ans++;
    cout << ans << endl;
    return 0;
}











Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
	int a,b;
	cin >> a >> b;
	
	cout << max(a+b, max(a-b, a*b)) << endl;
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A =list(map(int,input().split()))
B =list(map(int,input().split()))
C = list(map(int,input().split()))

S = sum(B)
for i in range(N-1):
 if A[i+1]-A[i]==1:
  S += C[A[i]-1]
print(S)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

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

int main()
{
    int n;
    cin >> n;
    vector<int> dp(n);
    dp.assign(2*n,2*n);
    dp[0] = 0;
    reps(i,1,n+1){
        chmin(dp[i],dp[i-1]+1);
        int sixpow = 6;
        while(i-sixpow >= 0){
            chmin(dp[i],dp[i-sixpow]+1);
            sixpow *= 6;
        }
        int ninepow = 9;
        while(i-ninepow >= 0){
            chmin(dp[i],dp[i-ninepow]+1);
            ninepow *= 9;
        }        
    }
    cout << dp[n];
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
  	string s;
  	cin >> s;
	if(s[0] != 'A'){
		cout << "WA" << endl;
		return 0;
	}
  	int foundC = 0;
 	for(int i = 1; i < (int)s.length(); i++){
  		if(s[i] == 'C' && i > 1 && i < (int)s.length()-1){
   	  	  	if(foundC){
    		    cout << "WA" << endl;
    		    return 0;
     	 	}
			else{
       		 	foundC = 1;
      		    continue;
   		    }
        }
        if(s[i] < 'a' || s[i] > 'z'){
            cout << "WA" << endl;
            return 0;
        }
  }
  if(!foundC) cout << "WA" << endl;
  else cout << "AC" << endl;
  return 0;
}

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

using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define f_in freopen("test.in","r",stdin);
#define f_out freopen("test.in","w",stdout);
#define debug(x) cerr << #x << " : " << x << "\n";
#define _ cin.sync_with_stdio(0); cin.tie(0);
#define tl cout <<"\nTime elapsed: "<<(1000 * clock() / CLOCKS_PER_SEC)<<"ms\n"


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

inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

template<typename T = int>
inline T nxt(){
    char c=nc();T x=0; int f=1;
    for(;c>'9'||c<'0';c=nc())if(c=='-')f=-1;
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc()); x*=f;
    return x;
}

const int N = (int) 1e5 + 123;
int cost[N];
vi G[N], a, b;
bool vis[N];

void dfs(int u){
    if(vis[u]) return;
    vis[u] = true;
    a.push_back(cost[u]);
    trav(v, G[u]) dfs(v);
}

int main(){
    int n = nxt(), m = nxt();
    if(n < 2 * (n - m - 1)){
        cout << "Impossible\n";
        return 0;
    }
    if(m == n-1){
        cout << "0\n";
        return 0;
    }
    rep(i,0,n) cost[i] = nxt();
    rep(i,0,m){
        int u = nxt(), v = nxt();
        G[u].push_back(v);
        G[v].push_back(u);
    }
    memset(vis, 0, sizeof vis);
    ll ans = 0;
    int cc = 0;
    rep(i,0,n){
        if(vis[i]) continue;
        dfs(i);
        sort(all(a));
        ans += a[0];
        rep(j,1,sz(a)) b.push_back(a[j]);
        a.clear();
        ++cc;
    }
    int idx = 0;
    sort(all(b));
    rep(i, cc, 2*(n-m-1)) ans += b[idx++];
    cout << ans << '\n';
}


Measured memory_bytes: 7548
import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))

c = collections.Counter(a)
num_list = list(c.values())
key_list = list(c.keys())
num_list.sort(key=lambda x: x)
m = max(len(key_list)-k, 0)
ans = 0
for i in range(m):
    ans += num_list[i]
print(ans)


Measured memory_bytes: 32544
#include <bits/stdc++.h>
using namespace std;
// Structure to represent an interval 
struct Interval 
{ 
    double low, high; 
}; 
  
// Structure to represent a node in Interval Search Tree 
struct ITNode 
{ 
    Interval *i;  // 'i' could also be a normal variable 
    double max; 
    ITNode *left, *right; 
}; 
  
// A utility function to create a new Interval Search Tree Node 
ITNode * newNode(Interval i) 
{ 
    ITNode *temp = new ITNode; 
    temp->i = new Interval(i); 
    temp->max = i.high; 
    temp->left = temp->right = NULL; 
    return temp; 
}; 
  
// A utility function to insert a new Interval Search Tree Node 
// This is similar to BST Insert.  Here the low value of interval 
// is used tomaintain BST property 
ITNode *insert(ITNode *root, Interval i) 
{ 
    // Base case: Tree is empty, new node becomes root 
    if (root == NULL) 
        return newNode(i); 
  
    // Get low value of interval at root 
    int l = root->i->low; 
  
    // If root's low value is smaller, then new interval goes to 
    // left subtree 
    if (i.low < l) 
        root->left = insert(root->left, i); 
  
    // Else, new node goes to right subtree. 
    else
        root->right = insert(root->right, i); 
  
    // Update the max value of this ancestor if needed 
    if (root->max < i.high) 
        root->max = i.high; 
  
    return root; 
} 
  
// A utility function to check if given two intervals overlap 
bool doOVerlap(Interval i1, double i2) 
{ 
    if (i1.low <= i2 && i2 < i1.high) 
        return true; 
    return false; 
} 
  
// The main function that searches a given interval i in a given 
// Interval Tree. 
Interval *overlapSearch(ITNode *root, double i) 
{ 
    // Base Case, tree is empty 
    if (root == NULL) return NULL; 
  
    // If given interval overlaps with root 
    if (doOVerlap(*(root->i), i)) 
        return root->i; 
  
    // If left child of root is present and max of left child is 
    // greater than or equal to given interval, then i may 
    // overlap with an interval is left subtree 
    if (root->left != NULL && root->left->max > i) 
        return overlapSearch(root->left, i); 
  
    // Else interval can only overlap with right subtree 
    return overlapSearch(root->right, i); 
} 
int main() {
  int N, C, x = 1, c;
  double S = INT_MAX, T = 0, s, t;
  cin >> N >> C;
  ITNode *intervals[C];
  for (int i = 0; i < C; i++) {
    intervals[i] = NULL;
  }
  while (N--) {
    cin >> s >> t >> c;
    intervals[c-1] = insert(intervals[c-1],{s-0.5,t});
    S = min(S,s-0.5);
    T = max(T,t);
  }
  for (int y = 0; S < T; y = 0, S += 0.5) {
   	for (int i = 0; i < C; i++) {
      y += overlapSearch(intervals[i],S) != NULL;
    }
    x = max(x,y);
  }
  cout << x;
}

Measured memory_bytes: 11492
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<queue>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<functional>
#include<limits.h>
#include<numeric>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int *a=new int[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int *dp=new int[k+1];
	//dp[0]=false;
	for(int i=1;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i-a[j]<0) dp[i]=false;
      		else if(!dp[i-a[j]]){
        	dp[i]=true;
        	break;
		}
	}
}
	if(dp[k])
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;


	return 0;

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
int main(){
    int N;
    std::cin >> N;

    std::vector<int> P(N);
    for (int i = 0;i < N;i++){
        std::cin >> P[i];
    }

    //min
    std::vector<int> min_ary(N);
    for (int i = 0;i < N;i++){
        if (i == 0){
            min_ary[0] = P[0];
        }else{
            min_ary[i] = std::min(P[i],min_ary[i-1]);
        }
    }

    //count
    int count = 0;
    for (int i = 0;i < N;i++){
        if (P[i] <= min_ary[i]){
            count++;
        }
    }
    std::cout << count << "\n";
}

Measured memory_bytes: 1792
N, K = map(int, input().split())

d = []
a = []

for i in range(K):
    d.append(int(input()))
    a.append(list(map(int, input().split())))

a_set = set(a[0])
for i in a:
    a_set = a_set | set(i)

ans = set((range(1, N+1))) - a_set
print(len(ans))



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

int main(){
  int n,d;
  cin>>n>>d;
  if(n%(2*d+1)==0){
    cout<<n/(2*d+1)<<endl;
  }
  else{
    cout<<n/(2*d+1)+1<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	new_data_set;
//   <<implemented_sorted_vector>>  new_data_set p;
//   <<insert_like_set>>           insert(key):log(n)
//<<accessing_iterator_by_index>> find_by_order(idx):log(n)
//	    <<accessing_by_value>>   order_of_key(key):log(n)
// << replace less<int> by greater<int> for descending order>>
// find(key), erase(find(key)) works the same!
typedef long long ll;
typedef long l;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ERR(x) cout<<"#x:"<<x<<endl
#define ERR2(x,y) cout<<"#x:"<<x<<" "<<"#y:"<<y<<endl;
#define ERR3(x,y,z) cout<<"#x:"<<x<<" "<<"#y:"<<y<<" "<<"#z:"<<z<<endl;
#define show(v) for(auto e: v) cout<<e<<" ";
#define showArr(A,n) for(int i=0;i<n;i++) cout<<A[i]<<" ";
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define mp make_pair
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()

const ll N = 1e6+5;
//prime factors in O(log n)
int primechk[N];
int fprime[N];
void preprocess(void)
{
    int i, j;
    for(i=2 ; i<N ; i++)
    {
        primechk[i]=1;
    }
    for(i=2 ; i<N ; i++)
    {
        if(primechk[i]==1)
        {
            fprime[i]=i;
            for(j=2 ; i*j<N ; j++)
            {
                primechk[i*j]=0;
                if(fprime[i*j]==0)
                {
                    fprime[i*j]=i;
                }
            }
        }
    }
}
/**
 * Prime factorization in log n using sieve
**/
vector<ll> primefactlogn(ll n)
{
	vector<ll>temp;
	while(n!=1)
    {
        temp.pb(fprime[n]);
        n=n/fprime[n];
    }
    return temp;
}


int main()
{
	preprocess();
	ll n;
	cin>>n;
	vector<ll>A(n);
	FOR(i,0,n){
		cin>>A[i];
	}
	int flag = 1;
	unordered_map<ll,ll>mp1;
	FOR(i,0,n){
		vector<ll>temp = primefactlogn(A[i]);// o(100)
		set<ll>s1;
		for(auto e: temp){
			s1.insert(e);
		}
		for(auto e: s1){
			if(mp1[e] > 0){
				flag = 0;
				break;
			} else {
				mp1[e] = 1;
			}
		}
	}
	ll gcd=0;
	FOR(i,0,n){
		gcd = __gcd(A[i], gcd);
	}
	if(flag == 0){
		if(gcd == 1){
			cout<<"setwise coprime";
		} else {
			cout<<"not coprime";
		}
	} else {
		cout<<"pairwise coprime";
	}
	return 0;
}


Measured memory_bytes: 22124
from collections import deque
n,m = map(int,input().split())
path = [[] for _ in range(n)]
ab = [[] for _ in range(m)]
for i in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  ab[i] = (a,b)
  path[a].append(b)
  path[b].append(a)
def dfs(a,b):
  que = deque()
  reach = [False]*n
  reach[0] = True
  que.append(0)
  while que:
    p = que.pop()
    for i in path[p]:
      if (p,i)!=(a,b)!=(i,p) and not reach[i]:
        que.append(i)
        reach[i] = True
  return reach != [True] * n
ans = 0
for a,b in ab:
  ans += dfs(a,b)
print(ans)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

lli body(lli a, lli b){
	return (a-b)*(a-b);
}
int main()
{
	lli N, M;
	cin >> N >> M;

	vector<int>oks(N+1, true);
	rep(i,M){
		int a;
		cin >> a;
		oks[a] = false;
	}

	vector<lli> dp(N+1);
	dp[0] = 1;
	rep(now, N){
		for(lli next=now+1; next<=min(N, now+2); next++){
			if(oks[next]){
				dp[next] +=dp[now];
				dp[next] = dp[next]%mod;
			}
		}
	}
	cout << dp[N] << endl;
 	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<iomanip>
using namespace std;
double a[200010] , dp[200010];
int main()
{
	int n,k;	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=k;i++)
		dp[i]=dp[i-1]+a[i];
	for(int i=k+1;i<=n;i++)
		dp[i]=dp[i-1]+a[i]-a[i-k];
	int bi=0 , index;
	for(int i=k;i<=n;i++){
		if(dp[i]>bi)
			bi=dp[i] , index=i;
		//cout<<dp[i]<<endl;
	}
	double ans=0;
	//cout<<"index=> "<<index<<endl;
	for(int i=index;i>index-k;i--)
		ans+=(a[i]+1)/2;
	cout<<fixed<<setprecision(8)<<ans<<endl;
}

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

using namespace std;

int jz[5][5]={};
int ans=0;

int main(){
    ios::sync_with_stdio(false);
    cin>>jz[1][1]>>jz[1][2]>>jz[2][2];
    ans=jz[2][2]*3;
    jz[1][3]=ans-jz[1][1]-jz[1][2];
    jz[3][2]=ans-jz[1][2]-jz[2][2];
    jz[3][1]=ans-jz[2][2]-jz[1][3];
    jz[2][1]=ans-jz[3][1]-jz[1][1];
    jz[2][3]=ans-jz[2][1]-jz[2][2];
    jz[3][3]=ans-jz[3][1]-jz[3][2];
    cout<<jz[1][1]<<' '<<jz[1][2]<<' '<<jz[1][3]<<endl;
    cout<<jz[2][1]<<' '<<jz[2][2]<<' '<<jz[2][3]<<endl;
    cout<<jz[3][1]<<' '<<jz[3][2]<<' '<<jz[3][3];
    return 0;
}

Measured memory_bytes: 384
import sys
import os

def file_input():
    f = open('ABC066/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    n=int(input())
    a=list(map(int, input().split()))

    out=[""]*n

    for i in range(n):
        if i%2==0:
            out[n//2+i//2]=str(a[i])
        else:
            out[n//2-(-(-i//2))]=str(a[i])
    if n%2!=0:
        out.reverse()

    print(*out)

if __name__ == '__main__':
    main()


Measured memory_bytes: 31268
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
    int n;
    char a[101],b[101];
    scanf("%d", &n);
    scanf("%s %s", a, b);

    for(int i = 0; i < n; i++){
        printf("%c%c", a[i],b[i]);

    }
    printf("\n");
    

    
  

    return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005];

void Main() {
    int N;
    cin >> N;
    rep(i, 100005) dp[i] = INF;
    dp[0] = 0;
    rep(i, N) {
        dp[i + 1] = min(dp[i] + 1, dp[i + 1]);
        ll j = 1;
        while (i + (int) pow(6, j) < N + 1) {
            dp[i + (int) pow(6, j)] = min(dp[i +  (int) pow(6, j)], dp[i] + 1);
            j++;
        }
        j = 1;
        while (i + (int) pow(9, j) < N + 1) {
            dp[i + (int) pow(9, j)] = min(dp[i +  (int) pow(9, j)], dp[i] + 1);
            j++;
        }
    }
    cout << dp[N] << endl;
}

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


Measured memory_bytes: 1024
a = list(input())
ans = [0] * len(a)
even_r, odd_r = 0, 0
# 正直変数ガチャ
for i in range(len(a)):
    if a[i] == "R":
        if i % 2 == 0:
            odd_r += 1
        else:
            even_r += 1
    else:
        if i % 2 == 0:
            ans[i - 1] += even_r
            ans[i] += odd_r
        else:
            ans[i - 1] += odd_r
            ans[i] += even_r
        odd_r = 0
        even_r = 0
even_l, odd_l = 0, 0
for i in range(len(a) - 1, -1, -1):
    if a[i] == "L":
        if i % 2 == 0:
            odd_l += 1
        else:
            even_l += 1
    else:
        if i % 2 == 0:
            ans[i + 1] += even_l
            ans[i] += odd_l
        else:
            ans[i + 1] += odd_l
            ans[i] += even_l
        odd_l = 0
        even_l = 0
print(" ".join(list(map(str, ans))))

Measured memory_bytes: 17756
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    if(a+5*b+10*c+50*d+100*e+500*f>=1000){
      cout<<1<<endl;
    }
    else{
          cout<<0<<endl;
    }
}


Measured memory_bytes: 3108
/*
                    Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }      
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
} 
signed main()
{   jaldi
    string str;
    cin>>str;
    if(str=="Sunny")
    cout<<"Cloudy";
    if(str=="Rainy")
    cout<<"Sunny";
    if(str=="Cloudy")
    cout<<"Rainy";
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>

using namespace std;
typedef long long ll;

int main(){
    int A,B;

    cin >> A >> B;
    if (A<=5){
        cout << "0";
    }
    else if (A < 13){
        cout << B/2 ;
    }
    else {
        cout << B;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main(){
    ll n,m;
    cin>>n>>m;
    V dp(1<<n,INT_MAX);
    dp[0]=0;
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        ll d=0;
        rep(j,b){
            ll c;
            cin>>c;
            c--;
            d+=(1<<c);
        }
        rep(j,1<<n){
            dp[j | d]=min(dp[j | d],dp[j]+a);
        }
    }
    if(dp[(1<<n)-1]==INT_MAX){
        cout<<-1<<endl;
    }else{
        cout<<dp[(1<<n)-1]<<endl;
    }
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int A[110000];
signed main() {
    cin >> N;
    rep(i, N) { cin >> A[i]; }
    sort(A, A + N);
    vpint ans;
    int i = 1;
    while (i < N - 1 && A[i] < 0) {
        ans.push_back({A[N - 1], A[i]});
        A[N - 1] -= A[i];
        i++;
    }
    i = N - 2;
    while (i > 0 && A[i] >= 0) {
        ans.push_back({A[0], A[i]});
        A[0] -= A[i];
        i--;
    }
    ans.push_back({A[N - 1], A[0]});
    cout << A[N - 1] - A[0] << endl;
    rep(i, N - 1) { cout << ans[i].first << " " << ans[i].second << endl; }
}


Measured memory_bytes: 4336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
  int n;
  cin >> n;
  char top,end;
  vector<string> strs(n);
  rep(i,n) cin >> strs[i];
  map<string,int> mp;
  
  rep(i,n){
    string tmp = strs[i];
    mp[tmp]++;
    if (i == 0) {
      end = tmp[tmp.size()-1];
      continue;
    }
    else{
      if (mp[tmp] > 1){
        cout << "No" << endl;
        return 0;
      }
      else if (end != tmp[0]){
        cout << "No" << endl;
        return 0;
      }
      else {
        end = tmp[tmp.size()-1];
      }
    }
  }
  cout << "Yes" << endl;
  
  


  return 0; 
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
#define mp make_pair
#define MAX 20000
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<ii> vii;
#define EPS 1e-9
#define LSOne(S) (S & (-S))
#define INF 1000*1000*1000+889
const int N = 1e5+10;
int n;
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    vector<ll> dp(3,0);
    for(int days = 0; days < n; ++days)
    {
        vector<ll> new_dp(3,0);
        vector<ll> c(3,0);
        for(int i = 0; i < 3; ++i)
            cin>>c[i];
        for(int i = 0; i < 3; ++i)
        {
            ll mx = 0;
            for(int j = 0; j < 3; ++j)
            {
                if(i != j)
                    mx = max( mx , dp[j]+c[i] );
            }
            new_dp[i] = mx;
        }
        dp = new_dp;
    }
    cout<<max(dp[0],max(dp[1],dp[2]));
}


Measured memory_bytes: 256
h,w = map(int, input().split())
list_prob = []
for i in range(0,h):
    list_prob.append(list(str(input())))
i = 0
while i < h:
    #print(i)
    if list_prob[i].count("#") == 0:
        del list_prob[i]
        h -= 1
        i -= 1
    i += 1
    #print(list_prob)

#print(list_prob)
j = 0
while j < w:
    list_j = []
    for i in range(0,h):
        list_j.append(list_prob[i][j])
    if list_j.count("#") == 0:
        for i in range(0,h):
            del list_prob[i][j]
        w -= 1
        j -= 1
    j += 1

for row in list_prob:
    print("".join(row))


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

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  if (x == w * 0.5 && y == h * 0.5) {
    printf("%.10f 1\n", 0.5 * w * h);
  } else {
    printf("%.10f 0\n", 0.5 * w * h);
  }
}


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

	const int NN = 3001;
	int matrix[NN+1][NN+1];
	int visited[NN+1][NN+1];
	int arr[5002];
	int n,m;
	int dx[]={1,-1,0,0};
	int dy[]={0,0,-1,1};

	bool check(int x,int y){
		return x>=0 && y>=0 && x<n&& y<m;
	}

	int main() {

		#ifndef ONLINE_JUDGE
	        freopen("input.txt","r",stdin);
	        // freopen("output.txt","w",stdout);
	    #endif
	    ios::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);  

	    int d,t,s;
	    cin>>d>>t>>s;
	    if(s*t >= d){
	    	cout<<"Yes"<<endl;
	    }  
	    else{
	    	cout<<"No"<<endl;
	    }
	}



	


Measured memory_bytes: 3600
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

plans = inputs[1..-1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
cur = [0, 0, 0]
res = "Yes"
plans.each do |p_i|
  time = p_i[0] - cur[0]
  dist = (p_i[1] - cur[1]).abs + (p_i[2] - cur[2]).abs
  if (time < dist) or ((dist - time) % 2 != 0)
    res = "No"
    break
  end
end

puts res

Measured memory_bytes: 9724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  vector<ll> arr(n);
  for(ll i=0;i<n;i++)
    cin>>arr[i];
  ll neg=0;
  for(ll i=0;i<n;i++)
  	if(arr[i]<0)
    	{neg++;arr[i] = -arr[i];}
  
  sort(arr.begin(),arr.end());
  ll sum =0;
  for(ll i=1;i<n;i++)
    sum+=arr[i];
  if(neg%2==0)
  sum += arr[0];
  else sum -= arr[0];
  cout<<sum<<endl;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while (true) {
        int s;
        cin >> s;
        if (s == 0)
            return 0;
        int tot = 0;
        int nax = -1, nin = 10000;
        for (int i = 0; i < s; ++i) {
            int x;
            cin >> x;
            chmax(nax, x);
            chmin(nin, x);
            tot += x;
        }
        cout << (tot - nax - nin) / (s - 2) << "\n";
    }
    return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> c(n),s(n),f(n);
    FOR(i,1,n){
        cin>>c[i]>>s[i]>>f[i];
    }
    FOR(i,1,n){
        int ans=0;
        FOR(j,i,n){
            while(ans<s[j] || ans%f[j]!=0){
                ans++;
            }
            ans+=c[j];
            //cout<<i<<' '<<j<<' '<<ans<<'\n';
        }
        cout<<ans<<'\n';
    }
    cout<<0<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int x,y;
    scanf("%d %d",&x,&y);
    if(x==2||y==2)printf("No");
    else{
        int x1,y1;
        x1=(x==4||x==6||x==9||x==11);
        y1=(y==4||y==6||y==9||y==11);
        if(x1+y1==1)printf("No");
        else printf("Yes");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main(){
    
    string a; cin >> a;
    int n = (int)a.size();

    vector<int> al(26);
    rep(i, 26){
        a += 'a' + i;
        al[i] = n + i + 1;
    }

    vector<vector<int>> pl(n + 1, vector<int>(26));
    for(int i = n; i >= 0; i--){
        rep(j, 26)pl[i][j] = al[j];
        if(i == 0)break;
        al[a[i - 1] - 'a'] = i;
    }

    const int inf = 100000000;
    vector<int> prev(n + 27, -1);
    vector<int> dist(n + 27, inf);
    dist[0] = 0;

    queue<int> que;
    que.push(0);
    while(que.size()){
        int v = que.front(); que.pop();
        rep(i, 26){
            int u = pl[v][i];
            if(chmin(dist[u], dist[v] + 1)){
                prev[u] = v;
                if(u <= n)que.push(u);
            }
        }
    }

    string ans = "";
    rep(i, n + 27)ans += 'z';

    int dans = inf;
    rep(i, 26){
        if(dans >= dist[n + i + 1]){
            bool must = dans > dist[n + i + 1];
            dans = dist[n + i + 1];
            string tmp = "";
            for(int t = n + i + 1; t > 0; t = prev[t]){
                tmp += a[t - 1];
            }
            reverse(all(tmp));
            if(must)ans = tmp;
            else chmin<string>(ans, tmp);
        }
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 28940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n,t;
multiset<int,greater<int> > s;
vector<int> g;
int main(){
	cin >> n;
	for(int i=0;i<1<<n;i++)
		t=read(),s.insert(t);
	g.push_back(*s.begin()),s.erase(s.begin());
	for(int i=0;i<n;i++)
		for(int j=0;j<1<<i;j++){
			multiset<int,greater<int> >::iterator x=s.upper_bound(g[j]);
			if(x==s.end())return puts("No"),0;
			g.push_back(*x),s.erase(x);
		}
	puts("Yes");
	return 0;
}

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

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define range(i, a, b, s) for (int i = (a), __##i = (b); i < __##i; i += (s))
#define down(i, a, b, s) for (int i = (a), __##i = (b); __##i < i; i += (s))

int x, a;

int main(int argc, char const *argv[]) {
  // freopen("A.txt", "r", stdin);

  while (cin >> x >> a) {
    if (x < a)
      cout << 0 << endl;
    else
      cout << 10 << endl;
  }
  return 0;
}

Measured memory_bytes: 888
// Charan Sriramula

#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll logx=30;
const ll N=1e6+5;
const ll M=1e3+5;
const ll mod=998244353;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b,ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b,ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b,ll p){ ll c = a + b; if(c > p) c -= p; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

vector<ll> g[N];
ll x[N],y[N],z[N],vis[N];

void DFS(ll cur)
{
  vis[cur]=1;
  for(auto i:g[cur])
  {
    if(vis[i]){continue;}
    DFS(i);
  }
}

int main()
{
  ll n,q;
  cin>>n>>q;
  ll ans=0;
  for(ll i=0;i<q;i++)
  {
    cin>>x[i]>>y[i]>>z[i];
    g[x[i]].pb(y[i]);
    g[y[i]].pb(x[i]);
  }
  for(ll i=1;i<=n;i++)
  {
    if(vis[i]){continue;}
    ans++;
    DFS(i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 41472
//
import java.math.*;
import java.util.*;
import java.io.*;
  
public class Main { 
  
    static BufferedReader in;
    static PrintWriter out = new PrintWriter(System.out);
    static String file = "../in";
    static int test = 10; // 0 for local testing, 1 for std input
    static int inf = 1_000_000, mod = 1_000_000_007;

    void swap(int[]ary, int i, int j)
    {
        int t = ary[i];
        ary[i] = ary[j];
        ary[j] = t;
    }
    
    String[] split() throws Exception
    {
        return in.readLine().split(" ");
    }

    int readInt() throws Exception
    {
        return Integer.valueOf(in.readLine());
    }

    int[] toIntArray() throws Exception
    {
        String[] sp = split();
        int n = sp.length;
        int[] ary = new int[n];
        for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);
        return ary;
    }

    long pow(long a, int pow)
    {
        long res = 1;
        while(pow > 0)
        {
            if(pow % 2 != 0) {
                res *= a;
                res %= mod;
            }
            a = a * a;
            a %= mod;
            pow /= 2;
        }

        return res;
    }


    String reverse(String str)
    {
        return new StringBuilder(str).reverse().toString();
    }

    public static void main(String[] args) throws Exception
    {
        int _k = Integer.valueOf("1");
        if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));
        else in = new BufferedReader(new FileReader(file));
        if(test < 0) {String[] str = in.readLine().split(" ");}
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
        // System.out.println((-100 + 0) / 2);

        new Main().b();
        out.flush();
    }
    
    void b() throws Exception
    {
        String str = in.readLine();
        int n = str.length();
        
        long op = 0, countA = 0;
        boolean flag = false;
 
 
        for(int i = 0; i < n - 1; i++)
        {
            char c = str.charAt(i);
            if(c == 'B' && str.charAt(i + 1) == 'C')
            {
                op += countA;
                i++;
            }
            else if(c == 'A') countA++;
            else countA = 0;

        }
        System.out.println(op);
    }

}


Measured memory_bytes: 25300
lis = []
count = 0

for i in range(5):
  a = int(input())
  lis.append(a)
  
k = int(input())
for x in lis:
  for y in lis:
    if x-y>k:
      count += 1
      
if count != 0:
  print(':(')
else:
  print('Yay!')

Measured memory_bytes: 3060
using System;

namespace Submit
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] num = Console.ReadLine().Split();
            double n = double.Parse(num[0]);
            double x = double.Parse(num[1]);
            Console.WriteLine(3 * (Math.Abs(n - MCD(n, x))));
        }
        static double MCD(double n, double x)
        {
            if (x == 0) return n;
            else return MCD(x, n % x);
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222


ll a[MAX];

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


  cin >> n >> m;
  rep(i, n) cin >> a[i+1];
  FOR(i, 1, n) a[i + 1] += a[i];
  vll sum, an[55];
  rep(i, n + 1)FOR(j, i + 1, n + 1) {
    sum.pb(a[j] - a[i]);
  }
  rep(i, sum.size()) an[53].pb(sum[i]);
  rrep(i, 53) {
    cnt = 0;
    rep(j, an[i + 1].size()) if (an[i + 1][j] >> i & 1) cnt++;
    rep(j, an[i + 1].size()) if (an[i + 1][j] >> i & 1) an[i].pb(an[i + 1][j]);
    if (cnt >= m) {
      ans += powl(2, i);
    }
    else {
      an[i].clear();
      an[i] = an[i+1];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 75628
#include <stdio.h>

int main() {
  int a,b,i;
  int answer = 0;
  scanf("%d %d", &a, &b);
  for(i = 0; i < 2; i++){
     if(a >= b) {
      answer += a;
      a--;
    } else {
      answer += b;
      b--;
    }
  }
  
  printf("%d\n", answer);

  return 0;
}


Measured memory_bytes: 128
/*==========================================================================*/
/*
    AUTHOR:    BPZ
	CREATED:   10.09.2020 14:52:25

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  int cnt = 0;
  for (int i = 1; i < n + 1; i++) {
  	cin >> a[i];
  	if (i % 2 && a[i] % 2) {
  		cnt++;
  	}
  }
  cout << cnt << '\n';
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
#define in_arr(type, a, n) for(int i = 0; i < n; i++) scanf(type, &((a)[i]));
#define ll long long int

int main(){
    int n;
    scanf("%d", &n);
    ll a[n];
    rep(i, n) scanf("%lld", &a[i]);
    ll max = 0, min = 10000000000;
    rep(i, n){
        if(a[i] < min){
            min = a[i];
        }

        if(max < a[i]){
            max = a[i];
        }
    }
    printf("%lld\n", max - min);
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<stack>
#include<map>
using namespace std;
map<long long,long long>mp,mp1;
long long a[200005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		mp[a[i]]++;
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		if(mp1[a[i]]==0)
		{
			ans+=mp[a[i]]*(mp[a[i]]-1)/2;
			mp1[a[i]]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		printf("%lld\n",ans-mp[a[i]]+1);
	}
	return 0;
}

Measured memory_bytes: 18944
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int[] b = new int[m];
        int[][] a = new int[n][m];
        for(int i=0;i<m;i++){
        	b[i] = sc.nextInt();
        }
        for(int i=0;i<n;i++){
        	for(int j=0;j<m;j++){
        		a[i][j] = sc.nextInt();
        	}
        }
        int ans = 0;
        for(int i=0;i<n;i++){
        	int counter = 0;
        	for(int j=0;j<m;j++){
        		counter += a[i][j]*b[j];
        	}
        	counter += c;

        	if(counter>0){
        		ans++;
        	}
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 22356
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException {
		char[][] alphabet = new char[2][26];
		for (int i = 0; i < 26; i++) {
			alphabet[0][i] = (char) (i + 97);
		}
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while ((str = br.readLine()) != null) {
			char[] input = str.toCharArray();
			for (int i = 0; i < input.length; i++) {
				int j = (int) input[i];
				if (64 < j && j < 91) j += 32;
				j -= 97;
				if (j < 0 || 27 < j) continue;
				alphabet[1][j]++;
			}
		}
		for (int i = 0; i < 26; i++) {
			System.out.println(String.valueOf(alphabet[0][i]) + " : " + (int) alphabet[1][i]);
		}
	}
}

Measured memory_bytes: 24464
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x-a) < abs(x-b)){
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }
    return 0;
}


Measured memory_bytes: 256