akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 13 19:20:01 2020

@author: dantitussalajan
"""
'''
# get a integer
a = int(input())
# get two integers separated with half-width break
b, c = map(int, input().split())
# get a string
s = input()
# output
print(str(a+b+c) + " " + s)
'''

S=input()
R=''
for k in range(len(S)):
    R=R+'x'    
print(R)    

    


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

int a, b, c, k, l;

int main() {
  cin >> a >> b >> c >> k;
  l = 0;
  while (a >= b) {
    b *= 2;
    l++;
  }
  while (b >= c) {
    c *= 2;
    l++;
  }
  cout << (l <= k ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){

   int x,y,i =0;

   while(i>=0){

   scanf("%d %d",&x,&y);

   if( x == 0 && y == 0){

      break;
 } else if( x > y){

   printf("%d %d\n",y,x);
 } else{
   printf("%d %d\n",x,y);
 }

}
return 0;

}

   


Measured memory_bytes: 2016
#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<stack>
#include<algorithm>
#include<vector>
#include<utility>
#include<deque>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define eps 1e-8
#define mem(n,a) memset(n,a,sizeof(n))
#define rep(i,be,en) for(int i=be;i<=en;++i)
#define pre(i,be,en) for(int i=en;i>=be;--i)
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lowbit(int x) { return x & -x; }


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
const int N = 1e5 + 10;

int main() {
	int k;
	int a, b;
	cin >> k >> a >> b;
	if (a % k == 0) {
		printf("OK\n");
		return 0;
	}
	else {
		int t = a / k;
		t = (t + 1) * k;
		if (a <= t && b >= t)printf("OK\n");
		else printf("NG\n");
	}
	return 0;
}


Measured memory_bytes: 3028
using System;
using System.Linq;

namespace ABC112
{
    class B2
    {
        static void Main(string[] args)
        {
            Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
            var h = read();
            Console.WriteLine(Enumerable.Repeat(0, h[0]).Select(_ => read()).OrderBy(r => r[0]).FirstOrDefault(r => r[1] <= h[1])?[0].ToString() ?? "TLE");
        }
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
	int a,b,c,d,e;
	
	cin >>a >> b>>c>>d>>e;
	if(a==0)cout <<1;
	else if(b==0)cout <<2;
	else if(c==0)cout <<3;
	else if(d==0)cout <<4;
	else if(e==0)cout <<5;
	
return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    int h,j,m,j1,m1,x,y;
    cin>>h>>j>>m>>j1>>m1;
    
    if(j%j1>=1) x=j/j1+1;
    else x=j/j1;
    
    if(m%m1>=1) y=m/m1+1;
    else y=m/m1;
    
    int z;
    if(x>=y) z=x;
    
    else z=y;
    
    cout<<h-z<<endl;
}



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

#define int long long int

signed main() {
  // int t;
  // cin >> t;
  // while(t--) {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
    	cin >> a[i];
      	a[i]++;
    }
    double curr = 0, ans = 0;
    for(int i = 0; i < k; i++) {
    	curr += a[i];
    }
  	ans = curr / (double)2.0;
  	for(int i = k; i < n; i++) {
      curr += a[i];
      curr -= a[i - k];
      ans = max(ans, curr / (double)2.0);
    }
    cout << fixed << setprecision(10) << ans;
  // }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int L;
    cin >> L;
    int c[L];
    for (int i = 0; i < L; i++) {
        cin >> c[i];
    }
    if (c[0] < 0) {
        cout << "1\n";
        return 0;
    }
    deque<int> q;
    q.push_back(c[0]);
    int s[101]{};
    s[c[0]]++;
    for (int i = 1; i < L; i++) {
        if (c[i] < 0) {
            if (q.back() != -c[i]) {
                cout << i + 1 << "\n";
                return 0;
            } else {
                s[q.back()]--;
                q.pop_back();
            }
        } else {
            if (s[c[i]] == 0) {
                s[c[i]] = 1;
                q.push_back(c[i]);
            } else {
                cout << i + 1 << "\n";
                return 0;
            }
        }
    }
    cout << "OK\n";
    return 0;
}


Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    int A = sc.nextInt();
    int B = sc.nextInt();
    String U = sc.next();

    int A1 = 0;
    int B1 = 0;

    if(S.equals(U)){
      A1 = A - 1;
      System.out.println(A1 + " "+ B);
    }else if(T.equals(U)){
      B1 = B - 1;
      System.out.println(A +" "+B1);
    }
  }
}

Measured memory_bytes: 21716
object Main
  extends App {
  val (a, b, c, x, y) = readLine.split(" ").map(_.toInt) match {
    case Array(a, b, c, x, y) => (a, b, c, x, y)
  }
  println(if (a + b >= 2 * c) {
    math.min(x, y) * 2 * c + (if (x > y) math.min((x - y) * a, (x - y) * 2 * c) else math.min((y - x) * b, (y - x) * 2 * c))
  } else {
    a * x + b * y
  })
}

Measured memory_bytes: 25668
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
inline int rd() {
    char ch=getchar(); int i=0,f=1;
    while(!isdigit(ch)) {if(ch=='-')f=-1; ch=getchar();}
    while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=getchar();}
    return i*f;
}
const int N=2e5+50;
const LL INF=0x3f3f3f3f3f3f3f3f;
int n,q;
LL bit[2][N],tag,mn=0;
inline void inc(LL *a,int i,LL v) {for(;i<=n;i+=(i&(-i))) a[i]=min(a[i],v);}
inline LL ask(LL *a,int i,LL v=INF) {for(;i;i-=(i&(-i))) v=min(a[i],v); return v;}
int main() {
    n=rd(), q=rd(); 
    int a=rd(), b=rd();
    memset(bit[0],0x3f,sizeof(bit[0]));
    memset(bit[1],0x3f,sizeof(bit[1]));
    inc(bit[0],a,-a); inc(bit[1],n-a+1,a);
    for(int i=1;i<=q;i++) {
        int x=rd();
        LL v=min(ask(bit[0],x)+x,ask(bit[1],n-x+1)-x);
        tag+=abs(x-b); v-=abs(x-b); mn=min(mn,v);
        inc(bit[0],b,v-b); inc(bit[1],n-b+1,v+b);
        b=x;
    }
    printf("%lld\n",mn+tag);
}

Measured memory_bytes: 3328
def pow(m, n):
	if n == 0:
		return 1
	if n % 2 == 1:
		return (m * (pow(m, n//2)**2)) % (10**9+7)
	return (pow(m, n//2)**2) % (10**9+7)

M, N = map(int, input().split())
print(pow(M, N))


Measured memory_bytes: 5604
if __name__ == "__main__":
	lis = []
	while True:
		a, b = map( int, input().split() )
		if a == b == 0:
			break
		lis.append([a,b])
	for i in lis:
		for j in range(i[0]):
			print('#'*i[1])
		print()

Measured memory_bytes: 7684
#include <bits/stdc++.h>
#include <atcoder/scc>
using namespace std;
using namespace atcoder;
int main(){
  int N, M;
  cin >> N >> M;
  scc_graph G(N);
  for (int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    G.add_edge(a, b);
  }
  vector<vector<int>> ans = G.scc();
  int K = ans.size();
  cout << K << endl;
  for (int i = 0; i < K; i++){
    int l = ans[i].size();
    cout << l;
    for (int j = 0; j < l; j++){
      cout << ' ' << ans[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 40092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int[] numbers = new int[220];
		int num;

		int N = sc.nextInt();
		for (int i=0; i<N; i++) {
			num = sc.nextInt();
			numbers[i] = num;
		}
		sc.close();

		int cnt=0;
		String judge = "all_even";
		while(true) {

			for (int i=0; i<N; i++) {
				if (numbers[i]%2!=0) {
					judge = "has_odd";
				}
			}
			if(judge=="has_odd") break;

			for (int i=0; i<N; i++) {
				numbers[i]/=2;
			}

			cnt ++;
		}
		System.out.println(cnt);


	}

}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000

ll N, M;
map<ll, ll> exist;
int main()
{
    cin >> N;
    REP(i, N) {
        ll tmp;
        scanf("%lld", &tmp);
        exist[tmp]++;
    }
    cin >> M;
    REP(i, M) {
        ll tmp;
        scanf("%lld", &tmp);
        if(exist.count(tmp) == 0) {
            printf("NO\n");
            return 0;
        }
        if(exist[tmp] > 0) {
            exist[tmp] -= 1;
        } else {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


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

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

	cin >> S;

	h = S / (60 * 60);
	m = (S - h * 60 * 60) / 60;
	s = S - h * 60 * 60 - m * 60;

	cout << h << ':' << m << ':' << s << endl;

	return 0;
}

Measured memory_bytes: 1160
def S(i,x,y):
	if 2*x >= A: return 2*x-A
	if 2*y >= A: return 2*y-A
	return min(S(i+1,x+a[i],y),S(i+1,x,y+a[i]))
while 1:
	n = input()
	if n == 0: break
	a = sorted(map(int,raw_input().split()))[::-1]
	A = sum(a)
	print S(1,a[0],0)

Measured memory_bytes: 4244
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}

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

  LLI a,b,c; cin >> a >> b >> c;

  LLI ans = 0;
  if(c<=a+b) ans = c;
  else ans = a+b+1;

  ans += b;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
list=[]
ans=0
for i in range(5):
    list.append(int(input()))
k=int(input())
for i in range(5):
    for j in range(i-1):
        if abs(list[i]-list[j])>ans:
            ans=abs(list[i]-list[j])
if ans>k:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 3060
#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    s = input()
    t = input()
    if t.startswith(s):
        print('Yes')
    else:
        print('No')
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 9100
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	ans = 0
	d1,d2 = defaultdict(int),defaultdict(int)
	L = []
	for i in range(n):
		L.append([l[i],i])
	ans = 0
	L = sorted(L)
	for j in range(n):
		i = L[j][1]
		zz = L[j][0]
		d1[i-zz] += 1
		d2[i+zz] += 1
	for i in d1:
		ans += d1[i]*d2[i]
	return ans

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print(ans)



Measured memory_bytes: 179996
S = raw_input()
T = raw_input()
ans = 'UNRESTORABLE'
n = len(S)-len(T)+1
if n > 0:
	for i in range(0, n):
		flag = False
		for j in range(0, len(T)):
			if S[-1-i-j] != '?' and S[-1-i-j] != T[-1-j]: break
			if j == len(T)-1: flag = True
		if flag:
			ans = ''
			for j in range(0, len(S)-i-len(T)):
				if S[j] == '?': ans = ans + 'a'
				else: ans = ans + S[j]
			ans = ans + T
			for j in range(len(S)-i, len(S)):
				if S[j] == '?': ans = ans + 'a'
				else: ans = ans + S[j]
			break
print ans

Measured memory_bytes: 2696
#include<stdio.h>

int main(){
  int n=0;
  int y=0;
  int a=0;
  int b=0;
  int flag = 0;
  int senen = -1;
  int gosenen = -1;
  int mansatsu = -1;
  scanf("%d %d",&n,&y);
  for(a=0;a<=n;a++){
    for(b=0;b<=n;b++){
      if(((y-(a*1000+b*5000)) == (n-a-b)*10000) && (y-(a*1000+b*5000))>=0){
        flag = 1;
        senen = a;
        gosenen = b;
        mansatsu = n-a-b;
        break;
      }
    }
  }
  printf("%d %d %d",mansatsu,gosenen,senen);
  return 0;
}

Measured memory_bytes: 128
n=int(input())
l=list(map(int,input().split()))
count=0
lcount=[0]*(10**5+1)
for i in l:
    if i>10**5:
        count+=1
    else:
        lcount[i]+=1
        if lcount[i]>i:
            count+=1
for j in l:
    if j<=10**5 and lcount[j]<j:
        count+=1
print(count)


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

#define ll long long
const ll MOD = 1e9+7;

int h[100000+5];
int n, k;
int dp[100000+5];
int rec(int i)
{
    if(i >= n-1){
        return 0;
    }
    if(dp[i] != -1) return dp[i];

    int ans = INT_MAX;
    for(int j=1; j<=k; j++)
        if(j+i < n)
            ans = min(ans, rec(i+j)+abs(h[i]-h[i+j]));
    return dp[i] = ans;
}
int main()
{
    memset(dp, -1, sizeof(dp));
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> h[i];
//    h[n] = INT_MAX;
    cout << rec(0) << endl;
}


Measured memory_bytes: 10632
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
#define MAX_heap 150000
int dc=100000;
#define MAX 100010

typedef struct _cell{
  int day;
  int wg;
}cell;

typedef struct _heap{
  cell cells[MAX_heap+1]; // 1-origin
  int length;
}heap;

typedef unsigned char boolean;

void init_heap_univ(heap* H);
boolean compare_cell(cell x, cell y);
void put_heap_univ(heap* H,cell x);
cell pull_heap_univ(heap* H);
int flag_heap_univ(heap* H, int itr,cell temp);
void print_cell(cell c){
  printf("(%d %d) ",c.day,c.wg);
}
void print_heap(heap H){
  int i;
  for(i=1;i<=H.length;i++){
    print_cell(H.cells[i]);
  }
  printf("\n");
}
int cmp(const void* a,const void* b){
  cell x=*((cell *)a),y=*((cell *)b);
  if(x.day==y.day)return y.wg-x.wg;
  return x.day-y.day;
}

int main(){
  if(df)printf("*** debug mode ***\n");
  int n,m;
  scanf("%d%d",&n,&m);
  int i;
  cell work[n];
  for(i=0;i<n;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    work[i].day=a;
    work[i].wg=b;
  }
  qsort(work,n,sizeof(cell),cmp);
  if(df){
    for(i=0;i<n;i++){
      printf("(%d %d) ",work[i].day,work[i].wg);
    }
    printf("\n");
  }
  int j=0;
  heap H;
  int ans[m];
  for(i=0;i<m;i++){
    while(j<n &&  work[j].day<=i+1){
      put_heap_univ(&H,work[j]);
      j++;
    }
    if(df)print_heap(H);
    if(H.length>0) {
      cell w=pull_heap_univ(&H);
      ans[i]=w.wg;
    }else ans[i]=0;
  }
  int sum=0;
  for(i=0;i<m;i++){
    sum+=ans[i];
  }
  printf("%d",sum);
  return 0;
}

void init_heap_univ(heap* H){
  H->length=0;
}

boolean compare_cell(cell x, cell y){
  if(x.wg>y.wg)return 1;
  return 0;
}

void put_heap_univ(heap* H,cell x){
  H->length++;
  int i=H->length;
  while(i>1 && compare_cell(x,H->cells[i/2])){
    H->cells[i]=H->cells[i/2];
    i/=2;
  }
  H->cells[i]=x;
  //  for(i=0; i<=heap[0];i++)
  //    printf("%lu ",heap[i]);
  //  printf("\n",heap[i]);
}

cell pull_heap_univ(heap* H){
  cell x=H->cells[1],temp=H->cells[H->length];
  int itr=1,itr2,flag;
  H->length--;
  flag=flag_heap_univ(H,itr,temp);
  while(flag){
    itr2=2*itr+flag-1;
    H->cells[itr]=H->cells[itr2];
    itr=itr2;
    flag=flag_heap_univ(H,itr,temp);
  }
  H->cells[itr]=temp;
  return x;
}

int flag_heap_univ(heap* H, int itr,cell temp){
  int flag;
  if(H->length<itr*2) flag=0;
  else if(H->length==itr*2)
    flag=(compare_cell(temp,H->cells[itr*2])?0:1);
  else if(compare_cell(H->cells[itr*2],H->cells[itr*2+1]))
    flag=(compare_cell(temp,H->cells[itr*2])?0:1);
  else flag=(compare_cell(temp,H->cells[itr*2+1])?0:2);

  //  printf("%d ",flag);
  return flag;
}


/// confirm df==0 ///


Measured memory_bytes: 2164
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    // #pragma GCC optimize("Ofast")
    using namespace std;
    //library
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define F first
    #define S second
    #define pb push_back
    #define mkp make_pair
    #define int long long
    #define ld long double
    //scankar
    #define sz(x) (int)(x).size()
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    typedef map<int,int> mii;
    typedef map<int,bool> mib;
    typedef map<char,int> mci;
    typedef map<string,int> msi;
    
    const int INF = 1e18L + 5;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    //direction
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ D $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;
    //debugger

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    msi mp;
    string s;
    
    void solve()
    {
        cin>>n;
        fo(i,0,n)
        {
            cin>>s;
            mp[s]++;
        }
        cout<<"AC x "<<mp["AC"]<<endl;
        cout<<"WA x "<<mp["WA"]<<endl;
        cout<<"TLE x "<<mp["TLE"]<<endl;
        cout<<"RE x "<<mp["RE"]<<endl;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          THE GAME STARTS HERE                             //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        
        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 3620
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

food = [a, b, c, d, e]

tmp = 10
for i, f in enumerate(food):
    if (f - 1) % 10 < tmp:
        tmp = (f - 1) % 10
        index = i

ans = 0
for i, f in enumerate(food):
    if i != index:
        ans += ((f - 1) // 10 + 1) * 10
    else:
        ans += f

print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

ll dp[102][4][4][4] = {};

bool ok(int a1, int a2, int a3, int a4) {
	bool ans = true;
	if (a2 == 0 && a3 == 1 && a4 == 2) ans = false;
	if (a2 == 0 && a3 == 2 && a4 == 1) ans = false;
	if (a2 == 1 && a3 == 0 && a4 == 2) ans = false;
	if (a1 == 0 && a3 == 1 && a4 == 2) ans = false;
	if (a1 == 0 && a2 == 1 && a4 == 2) ans = false;
	return ans;
}

signed main() {
	IOS();
	ll n;
	cin >> n;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				if (ok(4, i, j, k)) dp[3][i][j][k] = 1;
				//cout << i << " " << j << " " << k << " " << dp[3][i][j][k] << endl;
			}
		}
	}
	for (int i = 3; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 4; l++) { //i文字目がl, i - 1文字目がk, i - 2がj
					for (int a = 0; a < 4; a++) {
						if (ok(a, j, k, l)) dp[i + 1][j][k][l] += dp[i][a][j][k];
						dp[i][j][k][l] %= MOD;
					}
				}
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				ans += dp[n][i][j][k];
				ans %= MOD;
			}
		}
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		
		int[] a = new int[n];
		
		int[] rleft = new int[n];
		int[] gleft = new int[n];
		int[] bleft = new int[n];
		
		int sumr = 0;
		int sumg = 0;
		int sumb = 0;
		for(int i = 0; i < n; i++)
		{
			if(s.charAt(i) == 'R')
			{
				a[i] = 0; sumr++;
			}
			else if(s.charAt(i) == 'G')
			{
				a[i] = 1; sumg++;
			}
			else if(s.charAt(i) == 'B')
			{
				a[i] = 2; sumb++;
			}
			rleft[i] = sumr;
			gleft[i] = sumg;
			bleft[i] = sumb;
		}

		
//		System.out.println("Start");
		
		int[][] trans = new int[3][3];
		
		long gross = 0;
//		System.out.println(Arrays.toString(a));
		
		int[] sum = new int[3];
		for(int i = n-1; i >= 0; i--)
		{
			sum[a[i]]++;
			
			for(int j = 0; j < 3; j++)
			{
				if(j != a[i])
				{
					trans[a[i]][j] += sum[j];
				}
			}
			int other1 = (a[i]+1)%3; if(other1<0)other1+=3;
			int other2 = (a[i]+2)%3; if(other2<0)other2+=3;
			//n12
			int cur = trans[other1][other2] + trans[other2][other1];
			gross += cur;
			
//			System.out.println("i " + i + ": " + cur);
		}
		
		long an = gross;
		for(int i = 0; i < n; i++)
		{ //i: center
			for(int k = 1; i-k>=0 && i+k < n; k++)
			{ //k: offset
				if(a[i-k] != a[i+k] && a[i-k] != a[i] && a[i+k] != a[i])
					an--;
			}
			
		}
		
//		System.out.println("gross " + gross);
		System.out.println(an);
	}

}


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

#define P 1000000000LL

int divs(ll x, ll r) {
  int k;
  for (k = 0; x % r == 0 && x > 0; k++) {
    x /= r;
  }
  return k;
}

ll pow(ll x, ll k) {
  ll r = 1;
  for (ll i = 0; i < k; i++) {
    r *= x;
  }
  return r;
}

void print_pair(const pair<ll, ll> &p) {
  cout << "(" << p.first << "," << p.second << ")";
}

int main() {
  ll N; cin >> N;
  map<pair<ll, ll>, ll> d;

  for (ll i = 0; i < N; i++) {
    double tmp; cin >> tmp;
    ll f = round(tmp * P);
    ll twos = min(divs(f, 2), 18);
    ll fives = min(divs(f, 5), 18);
    
    pair<ll, ll> p = make_pair(twos, fives);

    if (d.find(p) == d.end()) {
      d[p] = 1;
    } else {
      d[p]++;
    }
  }

  vector<pair<ll, ll>> prod;
  vector<ll> cnt;
  ll n = d.size();

  for (auto &p : d) {
    prod.push_back(p.first);
    cnt.push_back(p.second);
  }

  ll sum = 0;
  for (ll i = 0; i < n; i++) {
    if (prod[i].first >= 9 && prod[i].second >= 9) {
      sum += cnt[i] * (cnt[i] - 1) / 2;
//      print_pair(prod[i]);
//      cout << endl;
    }

    for (ll j = 0; j < i; j++) {
      if (prod[i].first + prod[j].first >= 18 &&
          prod[i].second+ prod[j].second>= 18) {
        sum += cnt[i] * cnt[j];
//        print_pair(prod[i]);
//        cout << " ";
//        print_pair(prod[j]);
//        cout << endl;
      }
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 3636
#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>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;


int main() {
    int n;
    vector<int> sv;

    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        sv.push_back(tmp);
        sum += tmp;
    }

    sort(sv.begin(), sv.end());

    if (sum % 10 != 0) {
        cout << sum << endl;
    } else {
        int not10mul = sum;
        for (int i = 0; i < sv.size(); i++) {
            if (sv[i] % 10 != 0) {
                not10mul = sv[i];
                break;
            }
        }
        sum -= not10mul;
        cout << sum << endl;
    }


}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif
using namespace std;

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
typedef unsigned char byte;
typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

int main()
{
    llong val = 1;
    for (; val <= 1e10; val *= 10)
    {
        cout << "? " << to_string(val) << endl;
        string s;
        cin >> s;
        if (s == "N")
            break;
    }
    if (val == 1e11)
    {
        val = 9;
        for (; val <= 1e10; val = 10 * val + 9)
        {
            cout << "? " << to_string(val) << endl;
            string s;
            cin >> s;
            if (s == "Y")
            {
                val *= 10;
                break;
            }
        }
    }
    llong len = to_string(val).size() - 1;
    llong l = pow(10, len - 1);
    llong r = pow(10, len) - 1;
    while (l < r)
    {
        llong mid = (l + r) / 2;
        cout << "? " << to_string(mid * 10) << endl;
        string s;
        cin >> s;
        if (s == "Y")
            r = mid;
        else
            l = mid + 1;
    }
    cout << "! " << r << endl;
    return 0;
}

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

using namespace std;

int main(){
	while(1){
		int n, x, y, h, w;
		long p=0;
		
		cin >> n;
		if(n==0) break;
		
		for(int i=0; i<n; ++i){
			scanf(" %d %d %d %d", &x, &y, &h, &w);
			
			int s = x+y+h;
			
			if(s<=60 && w<=2) p+=600;
			else if(s<=80 && w<=5) p+=800;
			else if(s<=100 && w<=10) p+=1000;
			else if(s<=120 && w<=15) p+=1200;
			else if(s<=140 && w<=20) p+=1400;
			else if(s<=160 && w<=25) p+=1600;
			else ;
		}
	
		printf("%ld\n", p);
	}

	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
#define INF 1e18
int N;
vector<long long> a;
long long memo[2][3001][3001];
long long dfs(int t, int l, int r) {
  // cerr << t << " " << l << " " << r << endl;
  if (memo[t % 2][l][r] != INF) return memo[t % 2][l][r];
  if ((N % 2 == 0 && l + r == N - 1) || (N % 2 == 1 && l + r == N)) {
    return 0;
  }
  long long ret;
  if (t % 2 == 0) {
    ret = -INF;
    ret = max(ret, dfs(t + 1, l + 1, r) + a[l]);
    ret = max(ret, dfs(t + 1, l, r + 1) + a[N - r - 1]);
  }
  else {
    ret = INF;
    ret = min(ret, dfs(t + 1, l + 1, r));
    ret = min(ret, dfs(t + 1, l, r + 1));
  }
  return memo[t % 2][l][r] = ret;
}

int main(void) {
  cin >> N;
  a = vector<long long>(N);
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }

  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 3001; j++) {
      for (int k = 0; k < 3001; k++) {
        memo[i][j][k] = INF;
      }
    }
  }

  long long X = dfs(0, 0, 0);
  // cerr << X << endl;
  long long Y = sum - X;
  cout << X - Y << endl;

  return 0;
}

Measured memory_bytes: 141312
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,r = map(int, input().split())
if n >= 10:
    ans = r
else:
    ans = r + 100*(10-n)
print(ans)

Measured memory_bytes: 61884
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n; cin>>n;
    vector<int> color(9);
    int a;
    rep(i,n){
        cin>>a;
        if(a/400>=8) color[8]++;
        else color[a/400]++;
    }
    int mini=0;
    rep(i,8) if(color[i]!=0) mini++;
    if(mini==0) cout<<1<<" "<<color[8];
    else cout<<mini<<" "<<mini+color[8];
}

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

int main()
{
  int A, B;
  cin >> A >> B;
  for (int i = 1; i <= 1000; i++) {
    int val_a = floor(i * 0.08);
    int val_b = floor(i * 0.1);
    if (val_a == A && val_b == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)


using namespace std;


int main(void)
{
    int a[250][2] ={0};
    int i = 0,j = 0,k = 0,l = 0;
    int answer[220] = {0};
    bool judge = true;
    int tempjudge = 0;
    
    while(cin >> a[i][0])
    {
        if(a[i][0] == 0)
        {
            a[i][1] = 1;
            RFOR(j,i,-1)
            if(a[j][1] != 1 )
            {
                answer[l] = a[j][0];
                a[j][1] = 1;
                cout << answer[l] << endl;
                l++;
                break;
            }
        }
        
        i++;
    }
    
    return 0;
}

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

int main(){    
    int long long N; cin >> N; N--;
    bool flag = 1;
    string ans;

    while (flag)
    {
        flag = 0;
        ans.push_back(N%26);
        if (N/26 != 0)
        {
            N = N/26 - 1;
            flag = 1;
        }
    }
    
    for (int i = ans.size() - 1; i >= 0 ; i--)
    {
        char a = 'a' + ans[i];
        cout << a;
    }
    cout << endl;
    

    
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
    int k;
    cin >> k;
    string s = "ACL";
    for(int i=0; i<k; i++){
      cout << s;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3628
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)


vector<int> G[100010];
vector<int> ans;
bool used[100010];

void dfs(int u, vector<int> &a) {
	a.push_back(u);
	for (int i = 0; i < G[u].size(); i++) {
		int v = G[u][i];
		if (used[v]) continue;
		used[v] = true;
		dfs(v, a);
		return;
	}
}

int main(void) {
	int n, m;
	cin >> n >> m;

	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	used[a] = used[b] = true;

	dfs(a, ans);
	reverse(ans.begin(), ans.end());
	dfs(b, ans);

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 9336
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion


int32_t main() {
    make(int, a, b, c, k);
    int sm = 0;
    int d = min(k, a);
    sm += d;
    k -= d;
    d = min(k, b);
    k -= d;
    d = min(k, c);
    sm -= d;
    cout << sm;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int mod = 1e9 + 7;
 
int main(){ 
  string s;
  cin >> s;
  int n = s.size();
 
  vector<ll> dp(5, 0);
 
  dp[0] = 1;
 
  for (int i = 0; i < n; i++) {
    vector<ll> ndp(5, 0);
 
    for (int j = 0; j < 4; j++) {
      if (s[i] == '?') (ndp[j] += dp[j] * 3 % mod) %= mod; 
      else (ndp[j] += dp[j]) %= mod;
    }
    
    if (s[i] == '?' || s[i] == 'A') (ndp[1] += dp[0]) %= mod;
    if (s[i] == '?' || s[i] == 'B') (ndp[2] += dp[1]) %= mod;
    if (s[i] == '?' || s[i] == 'C') (ndp[3] += dp[2]) %= mod;
    swap(dp, ndp);
  }
 
  cout << dp[3] << endl;
  return 0;
} 

Measured memory_bytes: 3728
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int INF = 2147483647;

int main() {
    string s;
    cin >> s;
    int Na=0;
    int Nb=0;
    int Nc=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='a') Na++;
        if(s[i]=='b') Nb++;
        if(s[i]=='c') Nc++;
    }
    bool can=false;
    if(abs(Na-Nb)<=1&&abs(Nb-Nc)<=1&&abs(Nc-Na)<=1)
        can = true;
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#define maxn 10010
#define maxe 100010
typedef long long ll;
using namespace std;
const double eps=1e-5;
const int inf=0x3f3f3f3f3f;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
    ll x,y;
    while(scanf("%lld%lld",&x,&y)==2)
    {
        if(x%y==0)puts("-1");
        else
        {
            ll p=x*y/gcd(x,y);
            for(ll i=2;i*x<=1e18;i++)
            {
                if(x*i%p!=0)
                {
                    printf("%lld\n",i*x);
                    break;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
    long long int a, b;
    cin >> a >> b;
    long long int ans;
    long long int i;
    for (i = min(a, b); i <= a * b; i += min(a, b))
    {
        if (i % a == 0 && i % b == 0)
        {
            ans = i;
            break;
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define F first
#define S second
#define all_white first
#define sth_is_black second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
//~ const ll inf = 1e18+5;
const ll maxn= 1e5+5;
ll n, mod;
ll mult(ll a, ll b){
	//~ ll mod = mod;
	return (a%mod*b%mod)%mod;
}
ll add(ll a, ll b){
	//~ ll mod = modd;
	return (a%mod+b%mod+mod)%mod;
}
vector<ll> adjlist[maxn];
vector<ll> children[maxn];
pi down[maxn], up[maxn];
vector<pi> downs[maxn], pre[maxn], suf[maxn];

pi merge(pi &a, pi &b){
	pi p = mp(0, 0);
	p.all_white = mult(a.all_white, b.all_white);
	p.sth_is_black = add(mult(a.all_white, b.sth_is_black), (mult(a.sth_is_black, add(b.all_white, b.sth_is_black))));
	return p;
}
pi process(pi p){
	pi g = mp(p.all_white, add(p.sth_is_black, p.all_white));
	return g;
}
void dfs_one(ll x, ll par){
	pi p = mp(1,0);
		for (auto i:adjlist[x]){
		if (i == par)continue;
		children[x].pb(i);
		dfs_one(i, x);
		//~ cout << "hi";
		p = merge(p, down[i]);
		downs[x].pb(down[i]);
	}
	down[x] = process(p);
}
void dfs_two(ll x, ll par){
	for (ll i = 0; i < children[x].size(); i++){
		pi p = mp(1, 0);
		if (i != 0){
			p = merge(p, pre[x][i-1]);
		}
		if (i != (ll)children[x].size()-1){
			p = merge(p, suf[x][i+1]);
		}
		if (x != 1)p = merge(p, up[x]);
		ll b = children[x][i];
		up[b] = process(p);
		dfs_two(b, x);
	}
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> mod;
	//~ cout << down[0].first;
	for (ll i = 0; i < n-1; i++){
		ll aa, bb;
		cin >> aa >> bb;
		adjlist[aa].push_back(bb);
		adjlist[bb].push_back(aa);
		//~ cout << "ok";
	}
	//~ for (ll i = 1; i <= n; i++){
		//~ for (auto j:adjlist[i])cout << j << ' ';
	//~ }
	//~ cout << "hi";
	dfs_one(1, 1);
	//~ cout << "beibi";
	for (ll i = 1; i <= n; i++){
		ll k = downs[i].size();
		pi p = mp(1, 0);
		for (ll j= 0; j < k; j++){
			p = merge(p, downs[i][j]);
			pre[i].pb(p);
		}
		p = {1, 0};
		for (ll j = k-1; j >= 0; j--){
			p = merge(p, downs[i][j]);
			suf[i].pb(p);
		}
		reverse(suf[i].begin(), suf[i].end());
	}
	dfs_two(1, -1);
	for (ll a = 1; a <= n; a++){
		pi p = mp(1, 0);
		if (a != 1)p = merge(p, up[a]);
		if (!children[a].empty())p = merge(p, pre[a].back());
		p = process(p);
		cout << p.S << '\n';
		assert(p.F == 1);
	}
}


Measured memory_bytes: 37632
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

C = gcd(A, B)
ans = []  

def p(X):
	for i in range(2, int(sqrt(X))+1):
		if X%i == 0:
			return False
			break
	else:
		return True


for i in range(1, int(sqrt(C))+1):
	if C%i == 0:
		ans.append(p(i))
		if i != C//i:
			ans.append(p(C//i))

print(sum(ans))

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);
    int u,v,w;

    using pii = pair<int,int>;
    static vector< pii > e[100003];

    Rep(i,N-1){
        Scd3(u,v,w);
        e[--u].push_back( pii(--v,w%2) );
        e[v].push_back( pii(u,w%2) );
    }

    deque<pii> s;
    s.push_back( pii(0,0) );

    vector<int> ans(N);
    vector<bool> sa(N,false);
    sa[0] = true;
    while( !s.empty() ){
        int from = s.front().first;
        int dep =  s.front().second;
        sa[from] = true;
        ans[from] = dep%2;
        for( pii t: e[from] ){
            int to = t.first;
            int wei = t.second;
            if( sa[to] ) continue;
            s.push_back( pii(to,dep+wei) );
        }
        s.pop_front();
    }

    Rep(i,N){
        printf ("%d\n", ans[i]);
    }


    return 0;
}



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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long double ld;

const int MAX = 501,IINF = INT_MAX;
const ld LDINF = 1e100;
int H,W,sx,sy,gx,gy;
ld mincost[MAX][MAX][2]; // mincost[][][0] => from start, [1] = > from star
char c[MAX][MAX];
bool ban[MAX][MAX];
vector<int> star,plane;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

inline bool isValid(int x,int y) { return 0 <= x && x < W && 0 <= y && y < H; }

inline void bfs(vector<int> sp,vector<int> Forbidden,int type){
  rep(i,H)rep(j,W) mincost[i][j][type] = LDINF, ban[i][j] = false;
  queue<int> que;
  rep(i,(int)sp.size()) que.push(sp[i]), mincost[sp[i]/W][sp[i]%W][type] = 0;
  rep(i,(int)Forbidden.size()) ban[Forbidden[i]/W][Forbidden[i]%W] = true;

  while(!que.empty()){
    int cur = que.front(); que.pop();
    rep(i,4){
      int nx = cur % W + dx[i], ny = cur / W + dy[i];
      if( c[ny][nx] == '#' ) continue;
      if( ban[ny][nx] ) continue;
      if( mincost[ny][nx][type] == LDINF ) {
        mincost[ny][nx][type] = mincost[cur/W][cur%W][type] + 1;
        que.push(nx+ny*W);
      }
    }
  }
}

bool check(ld E){
  ld T = 0;

  rep(i,(int)plane.size()){
    int x = plane[i] % W, y = plane[i] / W;
    T += min(mincost[y][x][0],mincost[y][x][1]+E);
  }

  ld len = plane.size();
  return len * E > T;
}

int main(){
  cin >> W >> H;
  rep(i,H)rep(j,W){
    cin >> c[i][j];
    if( c[i][j] == 's' ) sx = j, sy = i, c[i][j] = '.';
    if( c[i][j] == 'g' ) gx = j, gy = i;
    if( c[i][j] == '*' ) star.push_back(j+i*W);
    if( c[i][j] == '.' ) plane.push_back(j+i*W);
  }

  vector<int> sp,forbidden;
  sp.push_back(gx+gy*W);
  forbidden = star;
  forbidden.push_back(gx+gy*W);
  bfs(sp,forbidden,0);

  sp = star;
  forbidden.push_back(gx+gy*W);
  //forbidden.clear();
  bfs(sp,forbidden,1);

  ld L = 0, R = 1e10, M = 0;
  rep(i,65){
    M = ( L + R ) * (ld)0.5;
    if( check(M) ) R = M;
    else           L = M;
  }

  cout << setiosflags(ios::fixed) << setprecision(20) << min((ld)mincost[sy][sx][0],(ld)mincost[sy][sx][1]+L) << endl;

  return 0;
}

Measured memory_bytes: 10456
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_N=2e5+5;

int n,m;
vector<int> intervals[MAX_N];
ll a[MAX_N];
struct Node
{
	ll data, tag;
	Node operator += (const ll &x)
	{
		data+=x;
		tag+=x;
		return (*this);
	}
	ll operator () () const
	{ return data; }
	void down(Node &l, Node &r)
	{
		l+=tag;
		r+=tag;
		tag=0;
	}
	void up(Node &l, Node &r)
	{
		data=max(l.data, r.data);
	}
};
struct ST
{
	Node a[4*MAX_N];
	void up(int idx)
	{}
	void mod(int L, int R, int l, int r, ll d, int idx=1)
	{
		if(R<l||r<L) return;
		if(l!=r) a[idx].down(a[idx<<1], a[idx<<1|1]);
		if(L<=l&&r<=R)
		{
			a[idx]+=d;
			return;
		}
		int mid=(l+r)/2;
		mod(L, R, l, mid, d, idx<<1);
		mod(L, R, mid+1, r, d, idx<<1|1);
		a[idx].up(a[idx<<1], a[idx<<1|1]);
	}
	ll query(int L, int R, int l, int r, int idx=1)
	{
		if(R<l||r<L) return LLONG_MIN;
		if(l!=r) a[idx].down(a[idx<<1], a[idx<<1|1]);
		if(L<=l&&r<=R) return a[idx]();
		int mid=(l+r)/2;
		return max(query(L, R, l, mid, idx<<1), query(L, R, mid+1, r, idx<<1|1));
	}
} st;
int l[MAX_N], r[MAX_N];
ll ans;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%lld",&l[i],&r[i],&a[i]);
		intervals[l[i]].emplace_back(i);
		intervals[r[i]+1].emplace_back(-i);
	}
	n++;
	for(int i=1;i<=n;i++)
	{
		for(auto &j:intervals[i])
		{
			if(j>0) st.mod(1, n, 1, n, a[j]);
			else
			{
				st.mod(1, l[-j]-1, 1, n, -a[-j]);
				st.mod(r[-j]+1, n, 1, n, -a[-j]);
			}
		}
		ll tmp=st.query(1, n, 1, n);
		ans=max(ans, tmp);
		ll t2=st.query(i, i, 1, n);
		st.mod(i, i, 1, n, -t2+tmp);
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 24704
/*
ID: skipian1
PROB: 
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF = 2000000000
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define X first
#define Y second

int main() {
  int m, d;
  cin >> m >> d;
  int ans = 0;
  for (int i = 2; i < 10; i++) {
    for (int j = 2; j < 10; j++) {
      if (10*i+j <= d && i*j <= m) ans++;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
count = 1
for i in range(N):
    if count == N:
        break
    if i == 0:
        count += 1
        ans += A[i]
    else:
        if count + 1 == N:
            count += 1
            ans += A[i]
        else:
            count += 2
            ans += A[i]*2
print(ans)
    

Measured memory_bytes: 93968