akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
using namespace std;

#define MAX 110
#define MENMAX 6
#define DICEMAX 2

typedef struct {
	int top;
	int S;
	int E;
	int W;
	int N;
	int down;
} stDicInfo;

typedef union {
	int Array[MENMAX];
	stDicInfo Dic;
} unionDiceInfo;

void input(int *dice)
{
	char *c;
	char str[MAX];
	int i;

	fgets(str, sizeof(str), stdin);
	if ((c=strchr(str,'\n')) != NULL) {
		*c = '\0';
	}

	for (i=0; i<MENMAX; i++) {
		if (i == 0) {
			c = strtok(str, " ");
		}
		else {
			c = strtok(NULL, " ");
		}
		dice[i] = strtol(c, NULL, 10);
	}
}

int main(void)
{
	unionDiceInfo dice[DICEMAX];
	stDicInfo *Rp1, *Rp2;
	int tmp, search;
	int cnt = 0;
	int cnt1 = 4;
	unsigned char flg = 0;

	input(dice[0].Array);
	input(dice[1].Array);

	Rp1 = &dice[0].Dic;
	Rp2 = &dice[1].Dic;
	while (1) {
		if ((flg&0x01) == 0x01) {
			search = 2;
		}
		else if ((flg&0x02) == 0x02) {
			search = 1;
		}
		else if ((flg&0x04) == 0x04) {
			search = 0;
		}
		else {
			if (cnt < 4) {
				search = 0;
			}
			else if ((cnt >=4) && (cnt<8)) {
				search = 1;
			}
			else {
				search = 2;
			}
		}
		switch(search) {
		case 0:
			tmp = Rp1->top;
			Rp1->top	= Rp1->S;
			Rp1->S		= Rp1->down;
			Rp1->down	= Rp1->N;
			Rp1->N		= tmp;
			break;
		case 1:
			tmp = Rp1->top;
			Rp1->top	= Rp1->W;
			Rp1->W		= Rp1->down;
			Rp1->down	= Rp1->E;
			Rp1->E		= tmp;
			break;
		case 2:
			tmp		= Rp1->S;
			Rp1->S	= Rp1->W;
			Rp1->W	= Rp1->N;
			Rp1->N	= Rp1->E;
			Rp1->E	= tmp;
			break;
		default:
			break;
		}
		if ((Rp1->top == Rp2->top) && (Rp1->down == Rp2->down)) {
			flg |= 0x01;
		}
		if ((Rp1->S == Rp2->S) && (Rp1->N == Rp2->N)) {
			flg |= 0x02;
		}
		if ((Rp1->W == Rp2->W) && (Rp1->E == Rp2->E)) {
			flg |= 0x04;
		}
		if (flg == 0) {
			cnt++;
		}
		else {
			cnt1--;
		}
		if ((flg == 3) || (flg >= 7)) {
			if (memcmp(dice[0].Array,dice[1].Array,sizeof(stDicInfo)) == 0) {
				printf("Yes\n");
			}
			else {
				printf("No\n");
			}
			break;
		}
		if ((cnt1 <= 0) || (cnt >= 11)) {
			printf("No\n");
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	ll n, W;
	scanf("%lld %lld", &n, &W);
	vector<ll> w(n), v(n);
	scanf("%lld %lld", &w[0], &v[0]);
	vector<vector<ll> > a(4);
	a[0].push_back(v[0]);
	for(int i = 1; i < n; i++){
		scanf("%lld %lld", &w[i], &v[i]);
		a[w[i] - w[0]].push_back(v[i]);
	}
	for(int i = 0; i < 4; i++){
		sort(a[i].begin(), a[i].end(), greater<ll>());
		for(int j = 0; j < a[i].size(); j++){
			if(j == 0) continue;
			a[i][j] += a[i][j - 1];
		}
	}
	ll ans = 0;
	for(int x0 = 0; x0 <= a[0].size(); x0++){
		for(int x1 = 0; x1 <= a[1].size(); x1++){
			for(int x2 = 0; x2 <= a[2].size(); x2++){
				for(int x3 = 0; x3 <= a[3].size(); x3++){
					if(x0 + x1 + x2 + x3 > n) continue;
					if(w[0] * x0 + (w[0] + 1) * x1 + (w[0] + 2) * x2 + (w[0] + 3) * x3 > W) continue;
					ll ans1 = 0;
					if(a[0].size() && x0) ans1 += a[0][x0 - 1];
					if(a[1].size() && x1) ans1 += a[1][x1 - 1];
					if(a[2].size() && x2) ans1 += a[2][x2 - 1];
					if(a[3].size() && x3) ans1 += a[3][x3 - 1];
					ans = max(ans, ans1);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3696
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	n, m int
	ns   [][]int
)

func dfs(xs []int) {
	if len(xs) == n {
		ns = append(ns, xs)
		return
	}

	for i := xs[len(xs)-1]; i <= m; i++ {
		dfs(append(xs, i))
	}
}

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	n, m = scanInt(), scanInt()
	q := scanInt()
	a := make([]int, q)
	b := make([]int, q)
	c := make([]int, q)
	d := make([]int, q)
	for i := 0; i < q; i++ {
		a[i], b[i], c[i], d[i] = scanInt(), scanInt(), scanInt(), scanInt()
	}

	ns = make([][]int, 0, 100000)
	for i := 1; i <= m; i++ {
		dfs([]int{i})
	}

	ans := 0
	for _, v := range ns {
		sum := 0
		for i := 0; i < q; i++ {
			if v[b[i]-1]-v[a[i]-1] == c[i] {
				sum += d[i]
			}
		}
		ans = max(ans, sum)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 10556
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int n, m, bit[400000], a[400000], c[400000]; vector<int>v[400000];
pair<int, int>l[400000]; vector<int>z1[400000], z2[400000];

void add(int x, int r) { while (x <= n) { bit[x] += r; x += x&-x; } }
int sum(int r) { int s = 0; while (r >= 1) { s += bit[r]; r -= r&-r; } return s; }
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> l[i].first >> l[i].second;
	}
	sort(l + 1, l + n + 1);
	for (int i = 1; i <= n; i++) {
		z1[l[i].first].push_back(i); z2[l[i].second].push_back(i);
	}
	for (int i = 1; i <= m; i++) {
		for (int j = i; j <= m; j += i)v[j].push_back(i);
	}
	int maxn = 0;
	for (int i = 1; i <= m; i++) {
		for (int j : z1[i]) { add(j, 1); maxn = max(maxn, j); }
		for (int j : v[i]) {
			c[j] += sum(maxn) - sum(a[j]);
			a[j] = maxn;
		}
		for (int j : z2[i])add(j, -1);
	}
	for (int i = 1; i <= m; i++)cout << c[i] << endl;
	return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  int ans=1;
  for(int i=0; i<N; i++){
    if(ans<=K) ans*=2;
    else ans+=K;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

class Baseball {
private:
	int out;
	int runner;
	int score;

public:
	//constructor
	Baseball() {
		out = 0; 
		runner = 0;
		score = 0;
	}

	//getter
	int getOut() { return out; }
	int getRunner() { return runner; }
	int getScore() { return score; }

	//input OUT
	void execOut() { ++out; }

	//input HIT
	void execHit() {
		if(runner == 3)++score;
		else ++runner;
	}

	//input HOMERUN
	void execHomerun() {
		score += runner + 1;
		runner = 0;
	}

};

int main(){
	int dataSetNum;
	std::cin >> dataSetNum;

	std::vector< Baseball > baseball;
	baseball.resize(dataSetNum);

	for(int i = 0; i < dataSetNum; ++i){

		while(baseball[i].getOut() != 3){
			
			//input
			std::string tmp;
			std::cin >> tmp;

			if(tmp == "OUT")baseball[i].execOut();
			else if(tmp == "HIT")baseball[i].execHit();
			else if(tmp == "HOMERUN")baseball[i].execHomerun();
		}

	}
	//output
	std::for_each(baseball.begin(), baseball.end(),
    [](Baseball x) { std::cout << x.getScore() << std::endl; } );

	return 0;
}

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


int main() {
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<endl;
    cout<<x<<endl;
    cout<<y<<endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<list>
#include<stack>
#include<queue>
#define ff first
#define ss second 
#define li list<int>
#define vi vector<int>
#define ll long long
#define vvi vector<vector<int> >
#define vii vector<pair<int,int> >
#define forl(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define custom  pair<int,pair<int,int> >
#define mod 1000000007
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    char ip[h][w];
    for(int i=0;i<h;i++){
        forl(j,0,w){
            cin>>ip[i][j];
        }
    }
    int arr[h][w];
    memset(arr,0,sizeof arr);
    for(int j=0;j<w;j++){
        if(ip[0][j]=='#'){
            arr[0][j]=0;
            for(int k=j;k<w;k++){
                arr[0][k]=0;
            }
            break;
            
        }
        else{
            arr[0][j]=1;
        }
    }
    for(int j=0;j<h;j++){
        if(ip[j][0]=='#'){
            arr[j][0]=0;
            for(int k=j;k<h;k++){
                arr[k][0]=0;
            }
            break;
            
        }
        else{
            arr[j][0]=1;
        }
    }
    for(int i=1;i<h;i++){
        for(int j=1;j<w;j++){
            if(ip[i][j]=='#'){
                arr[i][j]=0;
            }
            else{
                arr[i][j]=((arr[i-1][j])%mod+(arr[i][j-1])%mod)%mod;
            }
        }
    }
    cout<<arr[h-1][w-1];
    return 0;
}                   

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

vector<lli> A;
lli N,Q,M;
vector<lli> a,b,c,d;

lli ans;

void calc(lli now,lli maxNum)
{
    LOG2(now,maxNum);
    if(now==N){
        lli score=0;
        REP(i,0,Q){
            if(A[a[i]] + c[i] == A[b[i]])score += d[i];
        }
        chmax(ans,score);
        return;
    }
    REP(i,maxNum,M+1){
        A[now]=i;
        calc(now+1,i);
    }
}

void func(){

    ans = 0;
    A.resize(N);

    calc(0,1);
    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    scanf("%lld",&N);
    scanf("%lld",&M);
    scanf("%lld",&Q);
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        a[i]--,b[i]--;
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
    }
    func();
    return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=1;i<n;i++)
typedef long long ll;


int main(){
    int n; cin >> n;
    int ans=0;
    rep(i, n+1){
        if(to_string(i).length() % 2 == 1) ans++;
    }
    cout << ans;
}

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


long long mypow(int p, int n) {
    if (n == 0) return 1;
    long long t = mypow(p, n / 2);
    return n & 1 ? t * t * p : t * t;
}


long long N;

void read() {
    cin >> N;
}


void work() {
    int len = 1;

    --N;
    while (N >= mypow(26, len)) {
        N -= mypow(26, len);
        ++len;
    }

    string ans;
    for (int i = 0; i < len; ++i) {
        ans += (char)(N % 26 + 'a');
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    
    cout << ans << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
string s;
signed main()
{
	cin>>s;
	if(s[5]=='1'||s[6]=='5'||s[6]=='6'||s[6]=='7'||s[6]=='8'||s[6]=='9'){
		cout<<"TBD"<<endl;
	}else{
		cout<<"Heisei"<<endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/python3

def atoi(c):
    return ord(c) - ord('0')

table = [(), #dummy
        ('.',',','!','?',' '),\
        ('a','b','c'),
        ('d','e','f'),
        ('g','h','i'),
        ('j','k','l'),
        ('m','n','o'),
        ('p','q','r','s'),
        ('t','u','v'),
        ('w','x','y','z')]

n = int(input())
for i in range(n):
    digits = list(input())
    s = ""
    c = ''
    m = 0
    for d in digits:
        if d == '0':
            s += c
            c = ''
            m = 0
        else:
            c = table[atoi(d)][m]
            m = (m + 1) % len(table[atoi(d)])
    print(s)

Measured memory_bytes: 6736
sel='D'

if sel=='A':
    S=input()
    if S[2]==S[3] and S[4]==S[5]:
        print('Yes')
    else:
        print('No')

if sel=='B':
    X=int(input())
    ans=0
    ans+=(X//500)*1000
    ans+=((X%500)//5)*5
    print(ans)

if sel=='C':
    K,N=map(int,input().split())
    A=[int(i) for i in input().split()]
    d=[A[0]+K-A[-1]]
    for i in range(N-1):
        d.append(A[i+1]-A[i])
    d.sort()
    print(K-d[-1])

if sel=='D':
    N,X,Y=map(int,input().split())
    cnt={}
    for k in range(1,N):
        cnt[k]=0
    for i in range(1,N):
        for j in range(i+1,N+1):
            k=j-i # まっすぐ
            k=min(k,abs(i-X)+1+abs(j-Y)) # う回路１
            k=min(k,abs(i-Y)+1+abs(X-j)) # う回路２
            cnt[k]+=1

    for k in range(1,N):
        print(cnt[k])





Measured memory_bytes: 50012
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d",&a, &b, &c, &d);
	int q, w;
	q = a + b;
	w = c + d;
	if(q > w)
	{
		printf("Left\n");
	}
	if(q == w)
	{
		printf("Balanced\n");
	}
	if(q < w)
	{
		printf("Right\n");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
      string s;
      cin>>s;
      ll a=s.size();
      ll cut=0;
          for(ll i=0;i<a/2;i++)
          {
              if(s[i]!=s[a-i-1])
              cut++;
          }
      cout<<cut;
    }
     
     
      
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>

class SumThreeInt{
  private:
    int K, S, count;

  public:
    SumThreeInt (int K_, int S_) : K(K_), S(S_), count(0) {
    }

    void Sol(){
      for(int i=0; i<=K; i++){
        for( int j=0; j<=K; j++){
          if ( S - i - j >= 0 && S - i - j <= K ) count++;
        }
      }

      std::cout << count << std::endl;
    }
};


int main (void) {
  int K, S; std::cin >> K >> S;
  SumThreeInt x(K, S); x.Sol();
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

    while (true) {
      int H = scan.nextInt();
      int W = scan.nextInt();

      if ((H == 0) && (W == 0)) {
        break;
      }

      for (int i = 0; i < H; i++) {
        if (i % 2 == 0) {
          for (int j = 0; j < W; j++) {
            if (j % 2 == 0) {
              System.out.print("#");
            } else {
              System.out.print(".");
            }
          }
        } else {
          for (int j = 0; j < W; j++) {
            if (j % 2 == 0) {
              System.out.print(".");
            } else {
              System.out.print("#");
            }
          }
        }
        System.out.println();
      }

      System.out.println();
    }

  }
}


Measured memory_bytes: 36924
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a >= b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll n;cin >> n;
    vl xx(n),yy(n);
    rep(i,n){
        ll a,b;cin >> a >> b;
        xx[i]=a+b,yy[i]=a-b;
    }
    ll l=*min_element(all(xx)),r=*max_element(all(xx));
    ll d=*min_element(all(yy)),u=*max_element(all(yy));
    cout << max(r-l,u-d) <<endl;
}

Measured memory_bytes: 6388
import Control.Monad
import Control.Applicative
import Data.List

main = do

    n <- getLine
    xs <- map read . words <$> getLine
    
    let costlist = [costs x xs | x <- [-100,-99..100]]
    
    print (minimum costlist)

costs x xs = sum (map (cost x) xs)
cost x y = (x-y) * (x-y)


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

int main(){
  int n;
  cin >> n;
  int x[10],y[10];
  for (int i=0; i<n; i++) cin >> x[i] >> y[i];
  double s=0;
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      int p = x[i]-x[j];
      int q = y[i]-y[j];
      s += sqrt(p*p+q*q);
    }
  }
  printf("%20.20f", s/n);
}


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

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

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

int N;
long long W, weight[110], value[110];

long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++) {
        cin >> weight[i] >> value[i];
    }

    for (int i = 0; i < N; i++) {
        for (int w = 0; w <= W; w++) {
            if (0 <= w - weight[i]) {
                chmax(dp[i+1][w], dp[i][w-weight[i]] + value[i]);
            }
            chmax(dp[i+1][w], dp[i][w]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 79360
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

string S;
deque<char> st;

signed main(){

    in(S);
    for(auto c:S){
        if(c!='B'){
            st.push_back(c);
        }else{
            if(!st.empty()) st.pop_back();
        }

    }
    for(auto e:st) cout<<e;
    cout<<endl;

    return 0;
}


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

int main(void) {
  int c[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }

  for (int i = 1; i < 3; i++) {
    int diff = c[i][0] - c[i-1][0];
    for (int j = 1; j < 3; j++) {
      if (diff != c[i][j] - c[i-1][j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<vector>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <map>


void count(int cur, int prev, std::vector<std::vector<int>> &edges,
           std::vector<long> &result) {
    for (int next: edges[cur]) {
        if (next == prev) {
            continue;
        }
        result[next] += result[cur];
        count(next, cur, edges, result);
    }

}

int main() {
    int N, Q;
    std::cin >> N >> Q;
    std::vector<std::vector<int>> edges(N);

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        std::cin >> a >> b;
        --a;
        --b;
        edges[b].push_back(a);
        edges[a].push_back(b);
    }

    std::vector<long> result(N, 0);
    for (int i = 0; i < Q; i++) {
        int p, x;
        std::cin >> p >> x;
        --p;
        result[p] += x;
    }
    count(0, -1, edges, result);
    for (int i = 0; i < N; i++) {
        std::cout << result[i] << " ";
    }
    std::cout << std::endl;
    return 0;
}




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

#define dump(...) DUMPOUT<<"  ";DUMPOUT<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<std::endl;DUMPOUT<<"    ";dump_func(__VA_ARGS__)
#define PI 3.14159265358979323846
#define EPS 1e-10
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(j) (j).begin(), (j).end()
#define SZ(j) ((int)(j).size())

const int D = 365;

long long eval(vector<int> out, vector<int> c, vector<vector<int>> s) {
    long long sat = 0;
    vector<int> last(26, 0);
    // for d in range(D):
    REP(d, D) {
        //     assert(1 <= out[d] and out[d] <= 26)
        assert(1 <= out[d] and out[d] <= 26);
        //     j = out[d] - 1
        int j = out[d]-1;
        //     last[j] = d + 1
        last[j] = d+1;
        //     for i in range(26):
        REP(i, 26) {
            //         sat -= (d + 1 - last[i]) * c[i]
            sat -= (d+1-last[i]) * c[i];
        }
        //     sat += s[d][j]
        sat += s[d][j];
        cout << sat << endl;
    }
        
    // print("satisfaction: {}".format(sat))
    return sat;
    // print("score: {}".format(max(0, 1000000 + sat)))
}

const int sw = 1;
const int cw =19;

int main() {

    int tempD;
    cin >> tempD;

    vector<int> c(26);
    REP(i, 26) cin >> c[i];

    vector<vector<int>> s(D, vector<int>(26));
    REP(d, D) REP(i, 26) cin >> s[d][i];

    vector<vector<int>> v(D, vector<int>(26));
    REP(d, D) REP(i, 26) {
        v[d][i] = s[d][i]*sw + c[i]*cw; 
    }

    vector<int> res(D);

    REP(d, D) {
        int t = 0;
        REP(i, 26) {
            if (v[d][i] > t) {
                t = v[d][i];
                res[d] = i+1;
            }
        }
    }



    for (int e : res) cout << e << endl;

    return 0;
}

Measured memory_bytes: 3704
import java.util.Scanner;

public class Main{
	static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
    	
    	int a = in.nextInt();
    	int[] ints = new int[a];
    	
    	for (int i=0; i<a; i++) {
            ints[i] = in.nextInt();
        }
    	int MyArray;
    	for (int i=0; i<a; i++) {
    		MyArray = ints[i];
            
            int j = i - 1;
            while (j>=0 && ints[j]>MyArray) {
                ints[j+1] = ints[j];
                j--;
            }
            ints[j+1] = MyArray;
            print(ints);
    	}
    }
            static void print (int num[]) {
                for (int i=0; i<num.length; i++) {
                    System.out.print(num[i]);
                    if (i!=num.length-1) {System.out.print(" ");}
                }
                System.out.println();
            
            
    	       
            }
}



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

int main() {
    int N,max = 0; cin >> N;
    long long sum = 0;

    for(int i = 0; i < N; ++i) {
        int tall; cin >> tall;
        if(max <= tall) max = tall;
        else sum += (max - tall);
    }
    cout << sum << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int a,b;
  cin >> a >> b;
  cout << a*b << endl;

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        sum += s[i];
    }    
    sort(s.begin(),s.end());
    for(int i = 0; i < n; i++){
        if((sum - s[i]) % 10 != 0 && sum % 10 == 0){
            sum -= s[i];
            break;
        }
    }
    cout << (sum % 10 == 0 ? 0 : sum) << endl;
}

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

pair<int,pair<int,int> > pr[150*150];

int main()
{
  int h,w;
  int k=0;
  for(int i=1;i <= 150;i++){ //h
    for(int j=i+1;j <= 150;j++){ //w
      pr[k++] = make_pair(i*i+j*j,make_pair(i,j));
    }
  }   
  sort(pr,pr+k);//pairのsortは第一要素同じだと第二要素で比較

  /*for(int i=0;i < 100;i++){
    cout << pr[i].first << " " << pr[i].second.first << " " << pr[i].second.second << endl;
    }*/
  while(cin >> h >> w, h || w)
    {
      pair<int,pair<int,int> > q = make_pair(h*h+w*w,make_pair(h,w));
      pair<int,pair<int,int> > r = *upper_bound(pr,pr+k,q);
      cout << r.second.first << " " << r.second.second << endl;
    }
  return 0;
}



Measured memory_bytes: 3404
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

void solve(int T, vector<int> N, vector<int> M, vector<int> A, vector<int> B)
{
    for (int i = 0; i < T; i++)
    {
        cout << floor_sum(N.at(i), M.at(i), A.at(i), B.at(i)) << endl;
    }
}

int main()
{
    int T;
    cin >> T;
    vector<int> N(T);
    vector<int> M(T);
    vector<int> A(T);
    vector<int> B(T);
    for (int i = 0; i < T; i++)
    {
        cin >> N.at(i);
        cin >> M.at(i);
        cin >> A.at(i);
        cin >> B.at(i);
    }
    solve(T, move(N), move(M), move(A), move(B));
    return 0;
}


Measured memory_bytes: 4260
#include<iostream>
#define lli long long int
#define LONGMOD 1000000007
using namespace std;

// https://atcoder.jp/contests/abc055/tasks/abc055_b

lli solver(int TRAINING){
    lli result;
    result = 1;
    for(int j=1;j <= TRAINING ;j++){
        result = (result*j) % LONGMOD;
    }
    return result;
}

int main(void){
    lli answer;
    answer = 0;
    int N;
    cin >> N ;
    answer = solver(N);
    cout << answer << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  while((u != NIL) && (k != u->key)){
    if(k < u->key){
      u = u->left;
    }
    else {
      u = u->right;
    }
  }
  
  return u;
}

Node treeSuccessor(Node x){
  Node y;

  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y = x->parent;
  
  while((y != NIL) && (x == y->right)){
    x = y;
    y = y->parent;
  }

  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if((z->left == NIL) || (z->right == NIL)){
    y = z;
  }
  else {
    y = treeSuccessor(z);
  }

  if(y->left != NIL){
    x = y->left;
  }
  else {
    x = y->right;
  }

  if(x != NIL){
    x->parent = y->parent;
  }
  if(y->parent == NIL){
    root = x;
  }
  else if(y == y->parent->left){
    y->parent->left = x;
  }
  else {
    y->parent->right = x;
  }

  if(y != z){
    z->key = y->key;
  }
}

void Insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else {
      x = x->right;
    }
  }
  z->parent = y;
  
  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else {
    y->right = z;
  }
  
}

void Inorder(Node u){
  if(u->left != NIL){
    Inorder(u->left);
  }
  printf(" %d",u->key);
  
  if(u->right != NIL){
    Inorder(u->right);
  }
}

void Preorder(Node u){
  printf(" %d",u->key);
  if(u->left != NIL){
    Preorder(u->left);
  }
  if(u->right != NIL){
    Preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];;
  Node t;

  scanf("%d", &n);

  root = malloc(sizeof(struct node));
  root = NIL;
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      t = treeSearch(root, x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
    } else if (com[0] == 'i'){
      scanf("%d", &x);
      Insert(x);
    } else if (com[0] == 'p'){
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    } else if (com[0] == 'd'){
      scanf("%d", &x);
      treeDelete(treeSearch(root,x));
    }
  }

  return 0;
}

Measured memory_bytes: 9844
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut s: usize = 10_000;
    let a: Vec<usize> = (0..n)
        .map(|_| {
            let number: usize = read();
            s = min(s, number);
            number
        })
        .collect();
    let mut answer: isize = 0;
    let mut b = a.clone();
    let mut v: Vec<bool> = vec![false; n];
    let mut t: Vec<usize> = vec![0; 10_001];

    b.sort();
    for index in 0..n {
        t[b[index]] = index;
    }

    for index in 0..n {
        if v[index] {
            continue;
        }

        let mut cur: usize = index;
        let mut S: isize = 0;
        let mut m: isize = 10_000;
        let mut an: isize = 0;
        loop {
            v[cur] = true;
            an += 1;
            let val = a[cur];
            m = min(m, val as isize);
            S += val as isize;
            cur = t[val];
            if v[cur] {
                break;
            }
        }
        answer += min(S + (an - 2) * m, m + S + (an + 1) * s as isize);
    }

    println!("{}", answer);
}



Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int main(){
	int n=read(),k=read();
	printf("%d\n",n-k+1);
}

Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Mon Sep 23 03:17:40 2019
//
package main

import (
	"container/heap"
	"fmt"
)

type Heap []int

func (h Heap) Len() int {
	return len(h)
}

func (h Heap) Less(i, j int) bool {
	return h[i] > h[j]
}

func (h Heap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *Heap) Push(x interface{}) {
	y, _ := x.(int)
	*h = append(*h, y)
}

func (h *Heap) Pop() interface{} {
	n := len(*h)
	x := (*h)[n-1]
	*h = (*h)[:n-1]
	return x
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	h := make(Heap, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	heap.Init(&h)
	for i := 0; i < m; i++ {
		x := heap.Pop(&h)
		y, _ := x.(int)
		heap.Push(&h, y/2)
	}
	ans := 0
	for h.Len() > 0 {
		x, _ := heap.Pop(&h).(int)
		ans += x
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl
#define SZ(X) ((int)X.size())

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	string s; cin >> s;
	int k; cin >> k;
	vector<string> order;
	for (int i = 0; i < SZ(s); i++)
		for (int j = 0; j < k; j++)
			if (i + j < SZ(s)) order.push_back(s.substr(i, j + 1));
	sort(order.begin(), order.end());
	unique(order.begin(), order.end());
	cout << order[k - 1] << endl;
	return 0;
}


Measured memory_bytes: 1660
n = int(input())
a = list(map(int, input().split()))

num_list = [0 for _ in range(2*10**5)]
for i in range(n):
    num_list[a[i]-1] += 1
    num_list[a[i]] += 1
    num_list[a[i]+1] += 1
print(max(num_list))


Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int x;
  cin>>x;
  if(x>=30){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}


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

int main() {
	int N;
  	cin >>N;
  	vector<int>a(N);
  	rep(i,N){cin >>a[i];}
  	sort(a.begin(),a.end());
  	int count=1;
  	rep(i,N-1){if(a[i]!=a[i+1]){count++;}
    }
  	cout<<count<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define frep(i, m, n) for(int i = m;i < n;i++)
#define frepr(i, m, n) for(int i = m;i >= n;i--)
#define vsort(v) sort(v.begin(),v.end())
#define ll long long
#define inf 999999999
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vst;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int n;
    while(cin >> n && n!=0){
        int sum;
        int ans=0;
        frep(i,2,n){
            sum=i*(i-1)/2;
            // cout << n << " " << sum << " " << i << " " << ans << endl;
            if(sum>=n)break;
            if((n-sum)%i==0)ans++;
        }
        cout << ans << endl;
    }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  if (A + B < C + D){
    cout << "Right" << endl;
  }
  if (A + B > C + D){
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
void main()
{
    string s = rdStr;

    long len = s.length;
    foreach (i; 0 .. len)
    {
        'x'.write;
    }
    writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void ipElems(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ll,ii>
#define endl '\n'

int n;
vector<ii> arr,brr,crr;
bool used[100005];

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	
	cin>>n;
	ll a,b;
	for (int x=0;x<n;x++){
		cin>>a>>b;
		arr.push_back(ii(a,x));
		brr.push_back(ii(b,x));
		crr.push_back(ii(a,x));
		crr.push_back(ii(b,x));
	}
	
	//cout<<ans<<endl;
	
	sort(arr.begin(),arr.end());
	sort(brr.begin(),brr.end());
	sort(crr.begin(),crr.end());
	
	bool can=false;
	ll ans=0;
	for (int x=0;x<n;x++){
		ans+=crr[x].first;
		can=can||used[crr[x].second];
		used[crr[x].second]=true;
	}
	
	if (arr.back().first<=brr[0].first || brr.back().first<=arr[0].first) can=true;
	
	if (!can){
		if (crr[n-1].second!=crr[n].second) ans+=crr[n].first-crr[n-1].first;
		else ans+=min(crr[n+1].first-crr[n-1].first,crr[n].first-crr[n-2].first);
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 8660
import numpy as np
N, M = map(int,input().split())
ansAC = 0
ansWA = 0
zeros = np.zeros(N)
is_solved = set()
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == "WA":
        if p-1 not in is_solved:
            zeros[p-1] += 1
    else:
        is_solved.add(p-1)
ansAC = len(is_solved)
ansWA = int(sum(zeros[list(is_solved)]))
print(ansAC, ansWA)


Measured memory_bytes: 21568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

ll D, c[33], s[444][33], t[444], last[33] = {};
set<ll> s1[33], s2[33];

// vector<ll> score(ll t[]) {
//     ll i, j, sc = 0;
//     vector<ll> v;
//     v.pb(0);
//     for (i = 1; i <= D; i++){
//         sc += s[i][t[i]];
//         last[t[i]] = i;
//         for (j = 1; j <= 26;j++)
//             sc -= c[j] * (i - last[j]);
//         v.pb(sc);
//     }
//     return v;
// }

ll cost(ll k, ll dis){
    return k * dis * (dis - 1) / 2;
}

ll eval(ll d, ll q){
    ll bq = t[d];
    ll b = *s1[bq].upper_bound(d);
    ll a = *s2[bq].upper_bound(-d);
    ll sc = 0;
    sc -= s[d][bq];
    sc += s[d][q];
    ll l = d + a, r = b - d;
    sc += cost(c[bq], l);
    sc += cost(c[bq], r);
    sc -= cost(c[bq], l + r);
    b = *s1[q].upper_bound(d);
    a = *s2[q].upper_bound(-d);
    l = d + a, r = b - d;
    sc -= cost(c[q], l);
    sc -= cost(c[q], r);
    sc += cost(c[q], l + r);
    return sc;
}

int main(){
    ll i, j;
    cin >> D;
    for (i = 1; i <= 26;i++)
        cin >> c[i];
    for (i = 1; i <= D;i++)
        for (j = 1; j <= 26;j++)
            cin >> s[i][j];
    for (i = 1; i <= 26; i++){
        s1[i].insert(D + 1);
        s2[i].insert(0);
    }
    for (i = 1; i <= D;i++){
        ll ma = -1e15, p;
        for (j = 1; j <= 26; j++){
            if(c[j]*(i-last[j])+s[i][j]>ma){
                ma = c[j] * (i - last[j]) + s[i][j];
                p = j;
            }
        }
        t[i] = p;
        last[p] = i;
    }
    for (i = 1; i <= D;i++){
        s1[t[i]].insert(i);
        s2[t[i]].insert(-i);
    }
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> rand365(1, 365);
    ll INF = 1e9;
    double start_temp = 1000, end_temp = 0;
    ll turn = 800000;
    for (i = 0; i < turn; i++){
        ll ma = -1e15, p;
        ll d = rand365(mt);
        for (j = 1; j <= 26; j++){
            if(j!=t[d]){
                ll sc = eval(d, j);
                if(sc > ma){
                    ma = sc;
                    p = j;
                }
            }
        }
        double temp = start_temp + (end_temp - start_temp) * i / turn;
        double prob = exp(ma / temp);
        if (prob > (rand() % INF) / (double)INF){
            s1[t[d]].erase(d);
            s2[t[d]].erase(-d);
            s1[p].insert(d);
            s2[p].insert(-d);
            t[d] = p;
        }
    }
    for (i = 1; i <= D;i++)
        cout << t[i] << endl;
}

Measured memory_bytes: 4476
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std ;
int main(){
    int a, b ;
    cin>>a>>b ;
    int ans=0 ;
    if(a==b){
        ans = a + b;
    }else{
         ans = 2 * max(a, b) -1 ;
    }
    cout<< ans <<endl;
    return 0;

}

Measured memory_bytes: 256
S = str(input())
ans = 'Yes'
for i, letter in enumerate(S):
  if i%2 == 0 and (letter == 'R' or letter == 'U' or letter == 'D'):
    continue
  elif i%2 == 1 and (letter == 'L' or letter == 'U' or letter == 'D'):
    continue
  else:
    ans = 'No'
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int da = b/c;
    int db = b/d;
    int lcm = (c*d)/(__gcd(c,d));
    int dlcm = b/lcm;
    int la = a/c;
    int lb = a/d;
    int llcm = a/lcm;
    int ans = da-la+db-lb-dlcm+llcm;
    if(a%c==0) ans++;
    if(a%d==0) ans++;
    if(a%lcm==0) ans--;
    cout << (b-a+1)-(ans);


}


Measured memory_bytes: 256
def switch_case(str)
  switched = str.chars.map do |chr|
    if chr.is_lower?
      chr.upcase
    elsif chr.is_upper?
      chr.downcase
    else
      chr
    end
  end
  return switched.join("")
end

class String
  def is_upper?
    self == self.upcase
  end

  def is_lower?
    self == self.downcase
  end
end

n = gets.chomp
puts switch_case(n)



Measured memory_bytes: 6868
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100001];
vector<int> v;
int main()
{
	cin>>n;
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for (int i=0;i<n;i++)
	{
		bool b=1;
		vector<int>::iterator k=upper_bound(v.begin(),v.end(),-a[i]);
		if (k==v.end()) v.push_back(-a[i]);
		else *k=-a[i];
	}
	cout<<v.size()<<endl;
	return 0;
}


Measured memory_bytes: 1276
function main(input) {
  const data = input.replace(/\n$/, '').split(' ');
  
  const product = +data[0] * +data[1];
  console.log(product % 2 === 0 ? 'Even' : 'Odd');
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、mainを呼び出します）
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;
vector<ll> A(MAXN, 0);
string S;
signed main(){
    cin >> S;
    vector<ll> dp1(S.size()+1,1), dp2(S.size()+1,0);
    for(int i=1;i<=S.size();i++) {
        if(S[i-1]=='0') {
            dp1[i] = dp1[i-1];
            dp2[i] = 3*dp2[i-1];
            dp2[i] %= 1000000007;
        }
        else {
            dp1[i] = 2*dp1[i-1];
            dp1[i] %= 1000000007;
            dp2[i] = 3*dp2[i-1]+dp1[i-1];
            dp2[i] %= 1000000007;
        }
    }
    //cout << dp1[S.size()] << " " << dp2[S.size()] << endl;
    cout << (dp1[S.size()]+dp2[S.size()])%1000000007 << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = (ll)1e9 + 7;

// print(x, y, z);
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

int main(int argc, char* argv[])
{
  ll H, W, K;
  std::cin >> H >> W >> K;
  K--;

  // dp[h][w] = 横線をh段引いたときに0がwに来る場合の数
  std::vector< std::vector<ll> > dp(H+1, std::vector<ll>(W, 0LL));
  dp[0][0] = 1;

  for (ll h = 0; h < H; h++) {
    for (ll bit = 0; bit < (1 << (W - 1)); bit++) {
      // 2 つの横線がつながっていないか調べる
      bool judge = true;
      for (ll line = 0; line < W - 2; line++) {
	if ((1 << line & bit) && (1 << (line + 1) & bit)) judge = false;
      }
      if (!judge) continue;

      // あみだ処理
      std::vector<ll> amida(W, 0LL);
      for (ll line = 0; line < W; line++) {
	amida[line] = line;
      }
      for (ll line = 0; line < W-1; line++) {
	if ((1 << line) & bit) std::swap(amida[line], amida[line+1]);
      }

      // 動的計画法の処理
      for (ll line = 0; line < W; line++) {
	dp[h + 1][amida[line]] += dp[h][line];
	dp[h + 1][amida[line]] %= MOD;
      }
    }
  }

  print(dp[H][K]);
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, []int) {
	n := scanInt(sc)
	bs := nextIntSlice(sc, n-1)
	return n, bs
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

func resolve(n int, bs []int) int {
	maxSum := 0
	for i := 0; i < len(bs); i++ {
		expA := bs[i]
		if i > 0 {
			if expA > bs[i-1] {
				expA = bs[i-1]
			}
		}
		maxSum += expA
	}
	maxSum += bs[len(bs)-1]
	return maxSum
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788