akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
const double PI=3.1415;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    double r;
    cin >> r;
    cout << 2 * r * PI << endl; 
    return 0;
}

Measured memory_bytes: 3788
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
	#define setfile(__a) ('orzyrt')
	#define Compile(__a) system("g++ "__a".cpp -lm -o "__a)
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
	#define setfile(__a) freopen(__a".in","r",stdin);freopen(__a".out","w",stdout)
	#define Compile(__a) ('orzyrt')
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	int n,m;
	int a[555][555];
#define pii pair<int,int>
	vector<pair< pii,pii > >ans;
	void getnext(R int &x,R int &y){
		if(x&1){
			if(y==m)x++;
			else y++;
		}else{
			if(y==1)x++;
			else y--;
		}
	}
	inline void getp(R int x,R int y){
		debug("%d %d\n",x,y);
		R int nx=x,ny=y;getnext(nx,ny);
		if(nx>n)return;
		if(a[x][y]&1){
			a[nx][ny]++;
			a[x][y]--;
			ans.push_back(make_pair(make_pair(x,y),make_pair(nx,ny)));
		}
		getp(nx,ny);
	}
	int main(){
		read(n);read(m);
		for(R int i=1;i<=n;++i){
			for(R int j=1;j<=m;++j){
				read(a[i][j]);
			}
		}
		getp(1,1);
		printf("%d\n",ans.size());
		for(R int i=0;i<ans.size();++i){
			R pii x=ans[i].first,y=ans[i].second;
			printf("%d %d %d %d\n",x.first,x.second,y.first,y.second);
		}
		R int tmp=0;
		for(R int i=1;i<=n;++i){
			for(R int j=1;j<=m;++j){
				if(a[i][j]&1){}
				else tmp++;
			}
		}
		debug("\n\n%d\n",tmp);
		return 0;
	}
}
int main(){
	return Night::main();
}


Measured memory_bytes: 8432
// 秒単位の時間Sが与えられるので、h:m:sの形式へ変換して出力してください。
// ここで、hは時間、mは60未満の分、sは60未満の秒とします。
// 【入力】
// Sが1行に与えられます。
// 【出力】
// h、m、sを :（コロン）区切りで１行に出力してください。
// 数値が１桁の場合、0 を付けて２桁表示をする必要はありません。
// 【制約】
// 0≤S<86400
// 【例】
// 入力：46979、出力：13:2:59
#include<iostream>
using namespace std;

int main( void) {
  int M, S;
  cin >> S;

  int h, m, s;

  s = S % 60;
  M = S / 60;
  m = M % 60;
  h = M / 60;

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

  return 0;
}



Measured memory_bytes: 3068
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
   
class Main{
       
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
   
public static class Edge{
int to;
int cost;
public Edge(int to){
this.to=to; cost=0;
}
public Edge(int to,int cost){
this.to=to; this.cost=cost;
}
}
   
public static class Pair{
int x;
int y;
public Pair(int x,int y){
this.x=x; this.y=y;
}
public static final Comparator<Pair> DISTANCE_ORDER=new Comp();
private static class Comp implements Comparator<Pair>{
public int compare(Pair p1,Pair p2){
return (p1.x>p2.x)?1:(p1.x<p2.x)?-1:0;
}
}
}
   
public static class MyArrayList extends ArrayList<Edge>{}
   
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
st=new StringTokenizer(line);
int n=Integer.parseInt(st.nextToken());
int k=Integer.parseInt(st.nextToken());
int[] c=new int[n];
int[] r=new int[n];
int[] dist=new int[n];
boolean[][] visited=new boolean[n][n];
MyArrayList[] array=new MyArrayList[n];
MyArrayList[] carray=new MyArrayList[n];
for(int i=0;i<n;i++){
st=new StringTokenizer(br.readLine());
c[i]=Integer.parseInt(st.nextToken());
r[i]=Integer.parseInt(st.nextToken());
array[i]=new MyArrayList();
carray[i]=new MyArrayList();
}
for(int i=0;i<k;i++){
st=new StringTokenizer(br.readLine());
int a=Integer.parseInt(st.nextToken())-1;
int b=Integer.parseInt(st.nextToken())-1;
array[a].add(new Edge(b));
array[b].add(new Edge(a));
}
for(int i=0;i<n-1;i++){
bfs(i,r[i],visited,array);
for(int j=0;j<n;j++){
if(i!=j&&visited[i][j]) carray[i].add(new Edge(j,c[i]));
}
}
dijkstra(dist,carray);
out.println(dist[n-1]);
}
out.flush();
}
   
public static void bfs(int s,int t,boolean[][] visited,MyArrayList[] array){
Arrays.fill(visited[s],false);
Deque<Pair> que=new ArrayDeque<Pair>();
que.offerLast(new Pair(s,0));
while(!que.isEmpty()){
Pair p=que.pollFirst();
int ns=p.x;
visited[s][ns]=true;
ArrayList<Edge> list=array[ns];
if(p.y==t) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(!visited[s][e.to]) que.offerLast(new Pair(e.to,p.y+1));
}
}
}
   
public static void dijkstra(int[] dist,MyArrayList[] array){
PriorityQueue<Pair> pque=new PriorityQueue<Pair>(1,Pair.DISTANCE_ORDER);
Arrays.fill(dist,INF);
dist[0]=0;
pque.offer(new Pair(0,0));
while(!pque.isEmpty()){
Pair p=pque.poll();
int v=p.y;
ArrayList<Edge> list=array[v];
if(dist[v]<p.x||list.size()==0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(dist[e.to]>dist[v]+e.cost){
dist[e.to]=dist[v]+e.cost;
pque.offer(new Pair(dist[e.to],e.to));
}
}
}
}
}

Measured memory_bytes: 871792
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int N, ans =0, l,r;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    var K = Array(N + 1) { true }
    repeat(M) { K[nextInt()] = false }
    var dp = Array(N + 2) { 0 }
    dp[N] = 1
    val MOD = 1000000007
    for (n in N - 1 downTo 0) {
        if (K[n]) dp[n] = (dp[n + 1] + dp[n + 2]) % MOD
    }
    println(dp[0])
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int64_t n, m;
  cin >> n >> m;
  if (n%m != 0) {
    cout << n << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  string a;
  cin >> a;
  string b;
  cin >> b;
  std::string c(n * 2, 'a');
  for (int i = 0; i < n * 2; i++) {
    if (i % 2 == 0) {
      c.at(i) = a.at(i / 2);
    }
    else {
      c.at(i) = b.at((i - 1) / 2);
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 3556
def lcs(X, Y):
    global c
    m, n = len(X), len(Y)
    c = [[0 for i in range(n+1)] for j in range(m+1)]
    for i in range(1, m+1):
        for j in range(1, n+1):
            if X[i-1] == Y[j-1]:
                c[i][j] = c[i-1][j-1] + 1
            else:
                c[i][j] = max(c[i-1][j], c[i][j-1])
    return c[m][n]

def lcs_improved(X, Y):
    hist = [0] # yの文字cまでを見た時に, hist[i]以降の文字列において, 共通文字のうち, 一番小さいindexのもの
    for c in Y:
        for i in range(len(hist)-1, -1, -1):
            next_match_i = X.find(c, hist[i])+1
            if next_match_i:
                if i+1 < len(hist):
                    hist[i+1] = min(hist[i+1], next_match_i)
                else:
                    hist.append(next_match_i)
    return len(hist)-1

q = int(input())
for i in range(q):
    X = input()
    Y = input()
    print(lcs_improved(X, Y))


Measured memory_bytes: 5624
r, c = (int(x) for x in input().split())


A = [[int(x) for x in input().split()] for l in range(r)]
newA = [[0]*(c+1) for i in range(r+1)]

for i in range(r):
    for j in range(c):
        newA[i][j] = A[i][j]
        newA[i][c] += A[i][j]
        newA[r][j] += A[i][j]
        newA[r][c] += A[i][j]

for i in range(r+1):
    for j in range(c):
        print(str(newA[i][j])+" ",end = "")
    print(str(newA[i][c]))



Measured memory_bytes: 6256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll x;
    cin >> x;

    ll now = 100;
    ll ans = 0;
    while(now < x) {
        ll y = 1.01*(double)now;
        now = y;
        ans++;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 3640
n = int(input())
P = list(map(int, input().split()))

#%%
ans = 0
for i in range(n-1):
    if P[i] == i+1:
        P[i], P[i+1] = P[i+1], P[i]
        ans += 1

if P[-1] == n:
    ans += 1

print(ans)


Measured memory_bytes: 53804
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

struct datas{
  ll sumd;
  set<int> ts;
};
ll max(ll a,ll b){
  if(a<b){
    return b;
    
  }else{
    return a;
  }
}
ll gcd(int a,int b){//最大公約数
  if (a%b==0){
		return(b);
    }
	else{
		return(gcd(b,a%b));
    }
}
int main(void){
  int a,b;
  cin>>a>>b;
  ll a1=a/gcd(a,b);
  ll b1=b/gcd(a,b);
  cout<<a1*b1*gcd(a,b)<<endl;
  return 0;
}


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

int main () {
  int A , B, C, D ; 
  int T1 , T2 ; 
  cin >> A >> B >> C >> D ; 
  
  T1 = 0 ;
  T2 = 0 ; 
  
  while (A > 0 ){
    A = A - D ; 
    T2++ ; 
  }
  
    
  while (C > 0 ){
    C = C - B ; 
    T1++ ; //takahashi turn 
  }
  
  if( T2 >= T1){
    cout << "Yes" << endl ;  
  }
  else{
    cout << "No" << endl ;  
  }
  
  return 0 ; 
  
}

Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

const int maxn = 3e3 + 5;
LL pre[maxn * maxn];

struct X{
	LL x,y;
}node[maxn * maxn];

int main(){
	int n,m,d,q,pos;
	cin >> n >> m >> d;
	for(LL i = 1;i <= n;i++){
		for(LL j = 1;j <= m;j++){
			scanf("%d",&pos);
			node[pos].x = i;
			node[pos].y = j;
		}
	}
	for(int i = 2;i <= n * m;i++){
		pre[i] = pre[i - 1] + abs(node[i].x - node[i - 1].x) + abs(node[i].y - node[i - 1].y); 
	}
	cin >> q;
	while(q--){
		int l,r;
		LL sum = 0;
		cin >> l >> r;
		if(d == 1) cout << pre[r] - pre[l] << endl;
		else{
			for(int i = l + d;i <= r;i += d){
				sum += abs(node[i].x - node[i - d].x) + abs(node[i].y - node[i - d].y);
			}
			cout << sum << endl;
		}
	}
}

Measured memory_bytes: 6656
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		if(a==1)a=14;
		if(b==1)b=14;
		System.out.println((a<b)?"Bob":(a>b)?"Alice":"Draw");
		sc.close();
	}
}

Measured memory_bytes: 22868
def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    A, B, C = get_next_ints()
    parity = (A % 2 + B % 2 + C % 2)
    ans = 0
    if parity == 1:
        A += 1 if A % 2 == 0 else 0
        B += 1 if B % 2 == 0 else 0
        C += 1 if C % 2 == 0 else 0
        ans += 1
    if parity == 2:
        A += 1 if A % 2 != 0 else 0
        B += 1 if B % 2 != 0 else 0
        C += 1 if C % 2 != 0 else 0
        ans += 1
    max_val = max(A, B, C)
    ans += int((max_val - A) / 2 + (max_val - B) / 2 + (max_val - C) / 2)
    print(ans)

solve()

Measured memory_bytes: 3064
def luca(n):
    if lucas[n] != 0:
        return lucas[n]
    else:
        lucas[n] = luca(n-1) + luca(n-2)
        return lucas[n]

n = int(input())

lucas = [0 for x in range(n+1)]
lucas[0] = 2
lucas[1] = 1

if n >= 2:
    print(luca(n))
else:
    print(luca(n))

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

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 21, maxm = (1 << 20) | 10;

int n, m;
char s[maxn][maxm];
int dp[maxn][maxm], pd[maxn][maxm];

void transfer(int n, int S) {
	for (int i = 0; i <= n; ++i) {
		memcpy(pd[i], dp[i], sizeof(dp[i][0]) * S);
		memset(dp[i], 0, sizeof(dp[i][0]) * S);
	}
	int s1 = 0, s2 = S - 1;
	for (int i = n, s = S >> 1; i; --i, s >>= 1) {
		s2 ^= s;
		for (int j = 0, t; j < S; ++j) {
			if(t = pd[i][j]) {
				pd[i - 1][j] += t;
				if(i == n || ((j >> i) & 1) != ((j >> i - 1) & 1)) {
					dp[i - 1][((j & s1) >> 1) | (j & s2)] += t;
				}
			}
		}
		s1 ^= s;
	}
	return;
}

int main(int argc, char *argv[]) {
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= n; ++i) {
		scanf("%s", s[i]);
	}
	for (int i = n; i; --i) {
		int S = 1 << i;
		for (int j = 0; j < S; ++j) {
			if(s[i][j] == '1') {
				++dp[i][j];
			}
			int cnt = 0;
			for (int k = 0; k <= i; ++k) {
				cnt += dp[k][j];
			}
			if(cnt >= m) {
				for (int k = i - 1; ~k; --k) {
					printf("%d", (j >> k) & 1);
				}
				putchar('\n');
				return 0;
			}
		}
		if(i > 1) {
			transfer(i, S);
		}
	}
	puts("");
	return 0;
}



Measured memory_bytes: 193792
using System;
using System.Linq;
 
namespace AtCoder
{
    class HappyBirthday
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
            int a = input.First();
	        int b = input.Last();
            if (a <= 8 && b <= 8)
              Console.WriteLine("Yay!");
          	else
              Console.WriteLine(":(");
        }
    }
}

Measured memory_bytes: 11348
# coding: utf-8
A, B, C, D = map(int, input().split())

if A <= C < B <= D:
    print(B-C)
elif A <= C < D <= B :
    print(D-C)
elif A < B <= C < D or C < D <= A < B:
    print(0)
elif C <= A < D <= B:
    print(D-A)
elif C <= A < B <= D:
    print(B-A)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define arr(var, n) vec var(n); rep(i,n){cin >> var[i];}
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl

//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arr(w,n);

  vecll sum(n+1);
  sum[0]=0;
  rep(i,n){
    sum[i+1]+=w[i]+sum[i];
  }

  ll ans=LONG_MAX;
  rep(i,n-1){
    ll tmp = abs(sum[n] - 2 * sum[i+1]);
    if(ans>tmp){
      ans = tmp;
    }
  }

  prt(ans);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(1e5)+10;
int n,k,K,cnt,ans;
char s[maxn],t[maxn];
int l[maxn],r[maxn];
int solve(char ch) {
	int res=0; k=K;
	for (int i=1;i<=n;i++) s[i]=t[i];
	for (int i=1;i<=cnt;i++) {
		if (s[l[i]]==ch) continue;
		if (k==0) break;
		k--;
		//printf("OK\n");
		for (int j=l[i];j<=r[i];j++) {
		//	printf("%d\n",j);
			s[j]=ch;
		}
	}
	for (int i=1;i<=n;i++) {
		if (s[i]=='L'&&(i==1||s[i-1]=='R')) res++;
		if (s[i]=='R'&&(i==n||s[i+1]=='L')) res++;
	}
	return res;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(k); K=k;
	scanf("%s",s+1);
	for (int i=1;i<=n;i++) t[i]=s[i];
	int lst=1;
	for (int i=2;i<=n+1;i++)
		if (s[i]!=s[i-1]) {
			cnt++; l[cnt]=lst;
			r[cnt]=i-1; lst=i;
		}
	printf("%d\n",n-min(solve('L'),solve('R')));
	return 0;
}

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

int main() {
  int N, M, C;

  cin >> N >> M >> C;
  int B[M], A[N][M], count=0;

  for (int i=0; i<M; i++) cin >> B[i];
  for (int i=0; i<N; i++) {
    for (int j=0; j<M; j++) {
      cin >> A[i][j];
    }
  }

  for (int i=0; i<N; i++) {
    int tmp=0;
    for (int j=0; j<M; j++) {
      tmp += A[i][j]*B[j];
    }
    tmp += C;
    if(tmp>0) count++;
  }

  cout << count << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    vector<int> v;
    rep(i, 0, n) {
        if (s1[i] == s2[i]) v.push_back(1);
        else {
            v.push_back(2);
            i++;
        }
    }
    ll ans = 1;
    rep(i, 0, (int)v.size()) {
        if (i == 0) {
            if (v[i] == 1) ans *= 3;
            else ans *= 6;
            continue;
        }
        if (v[i] == 1) {
            if (v[i - 1] == 1) ans *= 2;
            ans %= MOD;
        } else {
            if (v[i - 1] == 1) ans *= 2;
            else ans *= 3;
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;


struct SegTree {
  vector<ll> st;
  int n;
  ll neutro = 0;

  SegTree(int _n){
    n = _n;
    st.assign(n << 2, neutro);
  }

  ll query(int i, int j) { return query(1, 0, n-1, i, j); }

  ll query(int p, int L, int R, int i, int j){
    if(i > R || j < L)return neutro;
    if(i <= L && j >= R)return st[p];
    int m = (L+R)/2, l = p*2, r = l+1;
    ll a = query(l, L, m, i, j);
    ll b = query(r, m+1, R, i, j);
    return max(a, b);
  }

  void update(int i, ll val) { update(1, 0, n-1, i, val); }

  void update(int p, int L, int R, int i, ll val){
    if(i > R || i < L)return;
    if(L == R)st[p] = val;
    else{
      int m = (L+R)/2, l = p*2, r = l+1;
      update(l, L, m, i, val);
      update(r, m+1, R, i, val);
      st[p] = max(st[l], st[r]);
    }
  }

};


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

  int n;
  cin >> n;
  vector<int> h(n), a(n);
  int mx = 0;
  forn(i, 0, n){
    cin >> h[i];
    mx = max(mx, h[i]);
  }
  forn(i, 0, n)cin >> a[i];

  SegTree st(mx+1);

  ll ans = 0;
  forn(i, 0, n){
    ll x = st.query(0, h[i]-1);
    ll y = st.query(h[i], h[i]);
    if(y < x+a[i]){
      st.update(h[i], x+a[i]);
      ans = max(ans, x+a[i]);
    }
  }

  cout << ans << endl;



}





Measured memory_bytes: 11128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e5 + 5;
unordered_set<string>Q;
int main()
{
    ios::sync_with_stdio(false);
    int n ; cin >> n;
    string v;
    for (int i = 1 ; i <= n ; i++){
        cin >> v;
        Q.insert(v);
    }
    cout << Q.size() << endl;
    return 0;
}


Measured memory_bytes: 17704
#入力とか変数宣言とか
N, M = gets.split.map(&:to_i)
as = Array.new(M,Array.new(2,0))
ans = Array.new(M,0)
M.times do |i|
  as[i] = gets.split.map(&:to_i)
end

#木, $par[i]=iならば根
$par = (0..(N-1)).to_a

#ユニオンのサイズを保持する。初期値は1
$size = Array.new(N,1)

#ここからUnion-find#
#根を求める関数
def get_root(x)
  if $par[x] == x then
    return x
  else
    #経路圧縮, 根にたどり着くまで再帰
    get_root($par[x])
  end
end

#xとyが同じ集合に属するか否か
def is_same?(x, y)
  get_root(x)==get_root(y)
end

#xとyの属する集合を併合して、不便さの変化deltaを返す
def unite(x,y)
  delta = 0
  x = get_root(x)
  y = get_root(y)

  if !(x==y) then
    delta = $size[y]*$size[x]
    x,y = y,x if $size[x]>$size[y]
    #yが新たな親になる
    $par[x]=y
    #サイズを更新
    $size[y] += $size[x]
    $size[x] = 0
  end
  return delta
end
#ここまでUnion-find#

#エントリーポイント#
#入力の後ろから繋ぎたいので、入力を逆順にする
as = as.reverse
  
#数列ans[i]の最終項はN*(N-1)/2
ans[M-1] = N*(N-1)/2
  
#一つずつ繋ぎつつ答えをansに格納
(M-1).times do |i|
  #つないで答えをもらってくる
  ans[M-2-i] = ans[M-1-i] - unite(as[i][0]-1,as[i][1]-1)
end

puts ans


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,k;
  cin>>n>>k;
  vll a(n);
  REP(i,n)cin>>a[i];

  ll cnt=1;
  ll base=1;
  while(base<n){
    base*=2;
    cnt++;
  }


  vll ans(n);
  copy(ALL(a),ans.begin());
  while(k>0){
    vll imos(n+1);
    REP(j,n){
      ll l=max(0LL,j-ans[j]);
      ll r=min(j+ans[j]+1,n);
      imos[l]++;
      imos[r]--;
    }

    REP(j,n)imos[j+1]+=imos[j];
    imos.pop_back();
    if(ans==imos)
      break;
    else
      ans=imos;
    k--;
  }

  cout<<ans[0];
  REP(i,n-1)cout<<" "<<ans[i+1];
  cout<<endl;
}



Measured memory_bytes: 7948
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    int g1,g2;
    switch(a){
        case 2:
        g1=1;
        break;
        case 4:
        case 6:
        case 9:
        case 11:
        g1=2;
        break;
        default:
        g1=3;
    }
    switch(b){
        case 2:
        g2=1;
        break;
        case 4:
        case 6:
        case 9:
        case 11:
        g2=2;
        break;
        default:
        g2=3;
    }
    if(g1==g2){
        cout<<"Yes";
    }else cout<<"No";
}


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

using namespace std;

void solve(int r, int t)
{
    vector<int> x;
    if (r%100 == 0) {
        x.push_back(r/100);
    } else {
        x.push_back(r/100);
        x.push_back(r/100+1);
    }

    vector<int> y;
    if (t%30 == 0) {
        y.push_back(t/30);
    } else {
        y.push_back(t/30);
        y.push_back(t/30+1);
    }

    vector<int> result;
    for (int i = 0; i < x.size(); i += 1){
        for (int j = 0; j < y.size(); j += 1) {
            result.push_back(x[i]+5*y[j]);
        }
    }

    sort(result.begin(), result.end());
    for (int i = 0; i < result.size(); i += 1){
        if (i+1 == result.size()) {
            cout << result[i] << endl;
        } else {
            cout << result[i] << " ";
        }
    }

    return;
}

int main()
{
    int N;
    int r, t;
    cin >> N;
    for(int i = 0; i < N; i += 1) {
        cin >> r >> t;
        solve(r, t);
    }
    return 0;
}

Measured memory_bytes: 3136
import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;

void main() {
	enum long Mod = 10 ^^ 9 + 7;

	ulong s;
	readf("%s\n", &s);

	auto dp = new long[s + 1];
	dp[0] = 1;

	foreach (i;3..s + 1) {
		dp[i] = (dp[i - 1] + dp[i - 3]) % Mod;
	}

	writeln(dp[s]);
}


Measured memory_bytes: 2812
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }

// int answer(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }






int main(){
  int N,K;
  cin >> N >> K;
  int v[N];
  rep(i,N) cin >> v[i];
  int ans = 0;
  for(int i = 0; i <= N; i++){
    for(int j = 0; j+i <= min(N,K); j++){
      vector<int> a;
      rep(o,i) a.push_back(v[o]);
      rep(o,j) a.push_back(v[N-o-1]);
      int rest = K - (i+j);
      sort(a.begin(),a.end(),greater<int>());
      int sum = 0;
      while (rest && !a.empty() && a.back() < 0) a.pop_back(), rest--;
      for(auto& x:a) sum+=x;

     

      ans = max(ans,sum);
    }
  }
  cout << ans << endl;


  return 0;
}







Measured memory_bytes: 256
# import math
# import numpy as np
# import itertools
# import heapq
import sys
a,b,c,d=map(int,input().split())
cnt=1
for i in range(1000):
    if cnt==1:
        c-=b  
        if c<=0:
            print('Yes')  
            sys.exit()
        cnt*=-1
    if cnt==-1:
        a-=d
        if a<=0:
            print('No')
            sys.exit()
        cnt*=-1






Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace  std;
int n;
string s;
int main () {
	cin >> n >> s;
	if(n % 2 == 1) {
		cout << "No";
		return 0;
	}
	for(int i = 0; i < n / 2; i++) {
		if(s[i] == s[i + n / 2]) {
		}
		else {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
x=[]
y=[]
W=0
K=0

for i in range(10):
    n=int(input())
    x.append(n)
#print(x)
for j in range(10):
    n=int(input())
    y.append(n)
#print(y)


for k in range(7):
    x.remove(min(x))
#print(x)
for l in range(7):
    y.remove(min(y))
#print(y)


for m in range(3):
    W+=x[m]
print(W,end=' ')
for n in range(3):
    K+=y[n]
print(K)


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


void solve() {
    int n;
    cin >> n;
    cout << fixed << setprecision(6) << 1.0 / 27 * n * n * n << endl;
}

int main() {
	header();
	solve();
	return 0;
}


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

typedef long long ll;
const int MOD = 1e9 + 7;
int dp[3001];
int fact[200001];
int tcaf[200001];
int pow1(int n, int p){
  ll cur, res;
  cur = n;
  res = 1;
  while(p){
    if(p & 1){
      res *= cur;
      res %= MOD;
    }
    p /= 2;
    cur *= cur;
    cur %= MOD;
  }
  return res;
}
void init(){
  fact[0] = tcaf[0] = 1;
  for(int i = 1;i < 200001;i++){
    fact[i] = 1LL * fact[i - 1] * i % MOD;
    tcaf[i] = pow1(fact[i], MOD - 2);
  }
}
int ways(pair<int, int> p1, pair<int, int> p2){
  int n, m;
  n = p2.first - p1.first;
  m = p2.second - p1.second;
  if(n < 0 || m < 0)
    return 0;
  return 1LL * fact[n + m] * tcaf[n] % MOD * tcaf[m] % MOD;
}
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  init();
  int h, w, n;
  cin >> h >> w >> n;
  dp[0] = 1;
  vector<pair<int, int>> points(n + 2);
  points[n + 1] = {h - 1, w - 1};
  for(int i = 1;i <= n;i++){
    cin >> points[i].first >> points[i].second;
    points[i].first--;
    points[i].second--;
  }

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

  for(int i = 1;i <= n + 1;i++){
    dp[i] = ways(points[0], points[i]);
    for(int j = 1;j < i;j++){
      dp[i] -= 1LL * dp[j] * ways(points[j], points[i]) % MOD;
      dp[i] %= MOD;
    }
    dp[i] = (dp[i] + MOD) % MOD;
  }
  cout << dp[n + 1];
  return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/perl

use strict;
use warnings;
use Math::Trig qw/atan pi/;

my ($a, $b, $x);
{
    my $in = <STDIN>;
    ($a, $b, $x) = split(" ", $in);
}
my $ans = 0.0;
if ($a*$a*$b/2>$x)
{
    $ans = 90-atan($x*2/$b/$a/$b)*180/pi;
}
elsif ($a*$a*$b/2==$x)
{
    $ans = atan($a/$b)*180/pi;
}
else
{
    $ans = atan(($a*$a*$b-$x)/$a/$a/$a*2)*180/pi;
}
print "$ans\n";

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n, d, c = 0, x, y;
    double dis;
    cin >> n >> d;
    for(int i = 0;i < n;i++)
    {
        cin >> x >> y;
        dis = x*x + y*y;
        dis = sqrt(dis);
        if(dis <= d)
            c++;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 3676
/*Author: Gautam*/
 
 
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}
 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
int memo[100005];
void init()
{
    int n=100005;
    forn(i,n)memo[i]=-1;
}
bool go(int n)
{
    if(n==0)return true;
    if(n<0)return false;
    if(memo[n]!=-1)return memo[n];
    bool ans=0;
    for(int i=100;i<=105;i++)
    {
        ans|=go(n-i);
    }
    return memo[n]=ans;
}
void solve()
{
    init();
    int n;
    cin>>n;
    cout<<go(n);
}
 
int main()
{
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

const double TAU = atan2(0, -1) * 2.0;
const double  PI = atan2(0, -1);

int n;
vector<array<double, 3>> v;

int main() {
	cin >> n;
	inc(i, n) {
		int x, y;
		cin >> x >> y;
		if(x == 0 && y == 0) { continue; }
		
		v.PB({ atan2(x, y), 1.0 * x, 1.0 * y });
	}
	sort(ALL(v));
	n = SI(v);
	inc(i, n) {
		auto a = v[i];
		a[0] += TAU;
		v.PB(a);
	}
	
	double ans = 0;
	inc(i, n) {
		double x = 0, y = 0;
		incID(j, i, i + n) {
			x += v[j][1];
			y += v[j][2];
			setmax(ans, hypot(x, y));
		}
	}
	
	printf("%.12f\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 12 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int to[200001], ne[200001], he[100001];
int kotae[100001], C;
char d[100001];
void sagasu(int P, int D) {
	if (!kotae[P]) kotae[P] = C;
	if (d[P] < D) {
		d[P] = D;
		for (int p = he[P]; p; p = ne[p]) {
			sagasu(to[p], D - 1);
		}
	}
}

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


	int N, M, Q;
	N = getint();
	M = getint();
	int k = 1;
	rep(i, M) {
		int a = getint(), b = getint();
		to[k] = a;
		ne[k] = he[b];
		he[b] = k++;
		to[k] = b;
		ne[k] = he[a];
		he[a] = k++;
	}
	Q = getint();
	int v[100000], d[100000], c[100000];
	rep(i, Q) {
		v[i] = getint();
		d[i] = getint();
		c[i] = getint();
	}
	for (int i = Q - 1; i >= 0; i--) {
		C = c[i];
		sagasu(v[i], d[i]);
	}
	rep1(i, N) putint(kotae[i]);

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <string>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  int a = 0, b = 0, c = 0, d = 0;
  rep(i, n){
    string s;
    cin >> s;
    if (s == "AC") a++;
    else if (s == "WA") b++;
    else if (s == "TLE") c++;
    else if (s == "RE") d++;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  string s;
  cin >> s;
  cout << count(ALL(s), '1') << LF;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

int main(){
  double R;
  cin>>R;
  cout<<setprecision(4)<<2*R*PI<<endl;
}

Measured memory_bytes: 3784
#include<stdio.h>
int main(){
int a,b,c,d;
scanf("%d %d %d",&a,&b,&c);
while(a>b || b>c){
if(a>b){
d=a;
a=b;
b=d;
}
if(b>c){
d=b;
b=c;
c=d;
}
}
printf("%d %d %d\n",a,b,c);
return 0;
}


Measured memory_bytes: 2148
#include <stdio.h>
#include <stdbool.h>
#define true 1
#define false 0
#define MAX 1000
#define VMAX 10000

int n,A[MAX],s;
int B[MAX],T[VMAX+1];

void sort(int C[]){
	int flag=1;
	int tmp;
	while(flag==1){
		flag=0;
		for(int j=n-1;j>=1;j--){
			if(C[j]<C[j-1]){
				tmp=C[j];
				C[j]=C[j-1];
				C[j-1]=tmp;
				flag=1;
			}
		}
	}
}

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

int solve(){
	int ans=0;
	bool V[MAX];
	for(int i=0;i<n;i++){
		B[i]=A[i];
		V[i]=false;
	}
	sort(B);
	for(int i=0;i<n;i++)T[B[i]]=i;
	for(int i=0;i<n;i++){
		if(V[i])continue;
		int cur=i;
		int S=0;
		int m=VMAX;
		int an=0;
		while(1){
			V[cur]=true;
			an++;
			int v=A[cur];
			m=min(m,v);
			S+=v;
			cur=T[v];
			if(V[cur])break;
		}
		ans+=min(S+(an-2)*m,m+S+(an+1)*s);
	}
	return ans;
}

int main(void){

	scanf("%d",&n);
	s=VMAX;
	for(int i=0;i<n;i++){
		scanf("%d",&A[i]);
		s=min(s,A[i]);
	}
	int ans=solve();
	printf("%d\n",ans);

    return 0;
}




Measured memory_bytes: 2144
n = int(input())
d = dict()
d["AC"] = 0
d["WA"] = 0
d["RE"] = 0
d["TLE"] = 0

for _ in range(n):
    s = str(input())
    d[s] += 1

print("AC x "+str(d["AC"]))
print("WA x "+str(d["WA"]))
print("TLE x "+str(d["TLE"]))
print("RE x "+str(d["RE"]))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  map<int,int> cnt;
  rep(i,N){
    int a;
    cin >> a;
    cnt[a]++;
  }

  if(N%3 == 0){
    if(cnt.size() == 1){
      if(cnt[0] == N) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
    else if(cnt.size() == 2){
      vector<pair<int,int>> v;
      FOR(it,cnt) v.emplace_back(*it);

      if(v[0].first == 0 && v[0].second == N/3) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
    else if(cnt.size() == 3){
      vector<pair<int,int>> v;
      FOR(it,cnt) v.emplace_back(*it);

      if(v[0].second == v[1].second && v[1].second == v[2].second){
        int x = v[0].first;
        int y = v[1].first;
        int z = v[2].first;

        if(((x^y) == z && (x^z) == y) ||
           ((x^z) == y && (x^y) == z) ||
           ((y^z) == x && (y^x) == z)) cout << "Yes" << endl;
        else cout << "No" << endl;
      }else{
        cout << "No" << endl;
      }
    }
    else cout << "No" << endl;

  }else{
    if(cnt[0] == N) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3840
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INF 10000000000
#define mod 1000000007
#define X 100000
#define N 20
#define M 46
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
void Iswap(int *a,int *b){
  int t=*a;
  *a=*b;
  *b=t;
}
void Fswap(double *a,double *b){
  double t=*a;
  *a=*b;
  *b=t;
}
void Lswap(ll *a,ll *b){
  ll t=*a;
  *a=*b;
  *b=t;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}

int main(void){
  int n;
  scanf("%d",&n);
  while(n){
    if(n%10==7){
      PRS("Yes");
      return 0;
    }
    n/=10;
  }
  PRS("No");
  return 0;
}

Measured memory_bytes: 1628
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);


void solve()
{
	int n;
	cin >> n;
	cout << (n - 1) / 2;	
}
 
int main()
{
    Red;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
	vector<int>a;
	int n,x;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		a.push_back(x);
	}
	for(int i=n-1;i>=0;i--){
		
		cout<<a[i];
		if(i!=0){
			cout<<" ";
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		
		int a = N / 15;
		
		int b = (N * 800) - (a * 200);

		System.out.println(b);
	}

}


Measured memory_bytes: 25812
def Base_10_to_n(x,n):
  tmp=x
  out=''
  while tmp>0:
    out=str(tmp%n)+out
    tmp=int(tmp/n)
  return out
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]
ans=10**18
for i in range(4**n):
  cost=0
  d=[[] for j in range(4)]
  s=Base_10_to_n(i,4).zfill(n)
  for j in range(n):
    k=int(s[j])
    d[k].append(l[j])
  if len(d[1])*len(d[2])*len(d[3])==0:
    continue
  for j in range(1,4):
    cost+=(len(d[j])-1)*10
  d1=sum(d[1])
  d2=sum(d[2])
  d3=sum(d[3])
  L=[abs(d1-a)+abs(d2-b)+abs(d3-c),abs(d1-a)+abs(d2-c)+abs(d3-b),abs(d1-b)+abs(d2-a)+abs(d3-c),abs(d1-b)+abs(d2-c)+abs(d3-a),abs(d1-c)+abs(d2-a)+abs(d3-b),abs(d1-c)+abs(d2-b)+abs(d3-a)]
  cost+=min(L)
  ans=min(ans,cost)
print(ans)

Measured memory_bytes: 3064