akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>

using namespace std;

int main(){
    int n=0,R=0,G=0,B=0;
    char S[4010];
    long long ans=0;
    //char s[200];
    //bool flag = false;
    //vector<int> a(N,0);

    cin >> n >> S;

    for(int i=0;i<n;i++){
        if(S[i] == 'R')
            R++;
        else if(S[i] == 'G')
            G++;
        else
            B++;
    }

    for(int i=0;i<n-2;i++){
        int tmp=0;
        for(int j=i+1;2*j-i < n;j++){
            if((S[i]!=S[j]) && (S[j]!=S[2*j-i]) && (S[i]!=S[2*j-i]))
            tmp++;
        }
        
        if(S[i] == 'R'){
            ans+=G*B-tmp;
            R--;
        }else{
            if(S[i] == 'G'){
                ans+=R*B-tmp;
                G--;
            }else{
                ans+=R*G-tmp;
                B--;
            }
        }
    }
    cout << ans << endl;
    //cout << ( (flag) ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

std::string S;

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

  if( S == "A" )
    puts("T");
  else if( S == "T" )
    puts("A");
  else if( S == "G" )
    puts("C");
  else if( S == "C" )
    puts("G");

  return 0;
}

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

int main()
{
	int n,W;
	cin>>n>>W;
	vector<int>wt(n,0),val(n,0);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		wt[i]=x;val[i]=y;
		sum+=val[i];
	}

	vector<vector<ll>>dp(n+1,vector<ll>(sum+1,1e18));
	int ans=INT_MIN;
	dp[0][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=sum;j++)
		{
			if(j==0)
			{
				dp[i][j]=0;
				// cout<<dp[i][j]<<" ";
				continue;
			}
			if(j-val[i-1]>=0)
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-val[i-1]]+wt[i-1]);
			else
				dp[i][j]=dp[i-1][j];
			if(dp[i][j]<=W)
				ans=max(ans,j);
			 // cout<<dp[i][j]<<" ";
		}
		// cout<<endl;
	}
	cout<<ans<<endl;

}


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

#define For(i, j, k) for (int i = j; i <= k; i++)
#define Forr(i, j, k) for (int i = j; i >= k; i--)

using namespace std;

typedef long long LL;

const int N = 3e5 + 10;

int n;

struct Binary_Indexed_Tree {

	int c[N];

	void init() {
		memset(c, 0, sizeof c);
	}

	int lowbit(int x) {
		return x & (-x);
	}

	void add(int x) {
		while (x <= n) {
			c[x]++;
			x += lowbit(x);
		}
	}

	int sum(int x) {
		int ret = 0;
		while (x) {
			ret += c[x];
			x -= lowbit(x);
		}
		return ret;
	}

}T;

LL Inverse(int *A, int m) {
	T.init();
	LL ret = 0;
	Forr(i, m, 1) ret += T.sum(A[i]), T.add(A[i]);
	return ret;
}

int m;
int P[N], A[N];

int main() {

	scanf("%d", &m);
	n = m;
	For(i, 1, m) {
		scanf("%d", &A[i]);
		if (A[i] % 2 != i % 2) {
			puts("No");
			return 0;
		}
	}
	
	For(i, 1, m) P[i] = A[i];
	LL s = Inverse(P, m);
	For(i, 1, m / 2) P[i] = A[i * 2]; 
	LL a = Inverse(P, m / 2);
	For(i, 1, (m + 1) / 2) P[i] = A[i * 2 - 1];
	LL b = Inverse(P, (m + 1) / 2);

	if (s == (a + b) * 3) puts("Yes");
	else puts("No");

	return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>
int main()
{
    char s[20];
    int x=0;
    int i=0;
    scanf("%s",s);
    for(;i<20;i++) x+=s[i]=='x';
    if(x>7) printf("NO\n");
    else printf("YES\n");
    return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

N = int(input())
graph = [[] for _ in range(N)]
Edges = []
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
    Edges.append((a-1, b-1))

Col = 0
for n in range(N):
    Col = max(Col, len(graph[n]))

Color = dict()
checked = [-1]*N
q = [0]
checked[0] = Col+1
while q:
    qq = []
    for p in q:
        c = checked[p]
        t = 0
        for np in graph[p]:
            if checked[np] == -1:
                if t == c:
                    t += 1
                checked[np] = t
                Color[(p, np)] = t
                Color[(np, p)] = t
                t += 1
                qq.append(np)
    q = qq

print(Col)
for a, b in Edges:
    print(Color[(a, b)]+1)

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

int main()
{
  int n, m;

  cin >> n >> m;

  vector< vector<int> > matrix;
  matrix.resize( n );
  for( int i = 0; i < n; i++ ) {
    matrix[ i ].resize( m );
  }

  for( int i = 0; i < n; i++ ) {
    for( int j = 0; j < m; j++ ) {
      cin >> matrix[ i ][ j ];
    }
  }

  vector <int> ary;
  ary.resize( m );

  for( int j = 0; j < m; j++ ) {
    cin >> ary[ j ];
  }

  int sum;
  for( int i = 0; i < n; i++ ) {
    sum = 0;
    for( int j = 0; j < m; j++ ) {
      sum += matrix[ i ][ j ] * ary[ j ];
    }
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 3120
N, A, B = map(int, input().split())
S = input()
a = 0
b = 0
for char in S:
    if char == 'a' and a+b < A+B:
        print("Yes")
        a += 1
    elif char == 'b' and a+b < A+B and b < B:
        print("Yes")
        b += 1
    else:
        print("No")

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

class Dice{
public:
  int f[6];

  void roll(int i, int j, int k, int l){
    int t; t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  } 
  void roll_x(){ roll(0, 1, 5, 4); } // to N
  void roll_y(){ roll(0, 2, 5, 3); } // to W
  void roll_z(){ roll(1, 2, 4, 3); } // ????¨???????

  void move( char ch){
    if( ch == 'E') for( int i = 0; i < 3; i++ ) roll_y();
    if( ch == 'W') roll_y();
    if( ch == 'N') roll_x();
    if( ch == 'S') for( int i = 0; i < 3; i++ ) roll_x();
  }
};

int main(){
  Dice p1;
  string com;

  for( int i = 0; i < 6; i++ ) cin >> p1.f[i];
  cin >> com;

  for( int i = 0; i < com.size(); i++) p1.move(com[i]);
  
  cout << p1.f[0] << endl;

  return 0;
}

Measured memory_bytes: 3216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		double n = scan.nextDouble();
		double ans =0;
		double count =0;
		for(double i=0;;i++) {
			if(Math.pow(2, i)<=n) {
				count++;
			}else {
				break;
			}

		}
		System.out.println((int)Math.pow(2, count-1));

	}

}


Measured memory_bytes: 24916
def calc(x, y):
    ans = 0
    ans += abs(x[0] - y[0])
    ans += abs(x[1] - y[1])
    return ans
N = int(input())
pts = [[0, 0] for i in range(N)]
d = (10 ** 9) // 2
dist_0 = 0
for i in range(N):
    x, y = list(map(int, input().split()))
    pts[i][0], pts[i][1] = x - d, y -d
    dist_0 = max(dist_0, calc(pts[i], [0, 0]))
s = set()
for pt in pts:
    if calc(pt,[0,0]) == dist_0:
        s.add(tuple(pt))
ans = 0
for pt in pts:
    for can in s:
        ans = max(ans, calc(pt, list(can)))
print(ans)

Measured memory_bytes: 39080
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
KN = min(K,N)
for i in range(1,KN+1):
    for j in range(i+1):
        rec = V[:i-j]+V[N-j:]
        rec.sort(reverse=True)
        away = max(min(i, K-i),0)
        for l in range(away+1):
            recsum = sum(rec[:i-l])
            if recsum > ans:
                ans=recsum
print(ans)

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

int main(){
    int n,k;
    cin>>n>>k;
    int ans=k;
    FOR(i,1,n){
        ans*=k-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> ab(m);
  for(int i=0;i<m;i++) cin >> ab[i].first >> ab[i].second;

  vector<int> med;
  set<int> st;
  for(int i=0;i<m;i++){
    if(ab[i].first == 1){
      med.emplace_back(ab[i].second);
    }
    if(ab[i].second == n){
      st.insert(ab[i].first);
    }
  }

  bool flag = false;
  for(int i=0;i<med.size();i++){
    auto itr = st.find(med[i]);
    if(itr != st.end()){
      flag = true;
      break;
    }
  }

  if(flag) cout << "POSSIBLE\n";
  else cout << "IMPOSSIBLE\n";
}


Measured memory_bytes: 6904
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18

void solve(){
	int n; cin>>n;
	ll b[n-1];
	f(i,n-1) cin>>b[i];
	if(n == 2){
		cout<<2*b[0]<<endl;
		return;
	}
	ll ans = b[0] + b[n-2];
	for(int i=0;i<n-2;i++) ans += min(b[i], b[i+1]);
	cout<<ans<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 256
n=int(input())
dp=[0]*3
for i in range(n):
    val=[int(x) for x in input().split()]
    temp=[0]*3
    for p in range(3):
        for k in range(3):
            if p!=k:
                temp[k]=max(temp[k],dp[p]+val[k])
        #print(temp)
    dp=temp[:]

print(max(dp))

Measured memory_bytes: 46808
N, M = map(int, input().split())
check = [0] * N
check[0] = 1
ab = []
for i in range(M):
    a, b = map(int, input().split())
    ab.append([a, b])
    if a == 1:
        check[b-1] = 1

for a, b in ab:
    if check[a-1] == 1 and b == N:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 40644
#include<stdio.h>
#include<math.h>
int main()
{
    int x;
    scanf("%d", &x);
    int b, p;
    int max = 1;
    for (b = 2; b <= sqrt(x); b++)
    {
        for (p = 1;; p++)
        {
            if (pow(b, p) <= x)
            {
                if (pow(b, p) > max)
                    max = pow(b, p);
            }
            else
                break;
        }
    }
    printf("%d\n", max);
    return 0;
}

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

class activity{
  public:
  int A,B,C;
};

int vacation(vector<activity> a, int n){
  int dp[100005][3];
  dp[1][0]=a[1].A;
  dp[1][1]=a[1].B;
  dp[1][2]=a[1].C;
  for(int i=2;i<=n;i++){
  	dp[i][0] = a[i].A + max(dp[i-1][1],dp[i-1][2]);
    dp[i][1] = a[i].B + max(dp[i-1][0],dp[i-1][2]);
    dp[i][2] = a[i].C + max(dp[i-1][1],dp[i-1][0]);
  }
  return max(dp[n][0],max(dp[n][1],dp[n][2]));
}


int main(){
  int n;	cin>>n;
  vector<activity> a(n+1);
  for(int i=1;i<=n;i++){
  	cin>>a[i].A;
    cin>>a[i].B;
    cin>>a[i].C;
  }
  cout<<vacation(a,n);
  return 0;
}

Measured memory_bytes: 6600
#include <stdio.h>

int main(){
	int i,a,b,c,d,e,average,sum;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	if(a<40){
		a=40;
	}
	if(b<40){
		b=40;
	}
	if(c<40){
		c=40;
	}
	if(d<40){
		d=40;
	}
	if(e<40){
		e=40;
	}
	sum=a+b+c+d+e;
	average=sum/5;
	printf("%d\n",average);
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.util.stream.*;

class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    IntStream repn = IntStream.range(0,n);
    Integer[] a =IntStream.range(0,n)
                          .map(x-> sc.nextInt())
                          .boxed()
                          .toArray((i) -> new Integer[i]);
    Integer[] b =IntStream.range(0,n)
                          .map(x-> sc.nextInt())
                          .boxed()
                          .toArray((i) -> new Integer[i]);
    int value =  repn
                .map(i-> a[i]-b[i])
                .filter(x-> x>0)
                .sum();
    System.out.println(value);
}}

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

using namespace std;

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

	string s;
	cin >> s;

	reverse(s.begin(), s.end());

	int sum = 0;

	map<int, int> mp;
	++mp[0];

	long long ans = 0;
	long long pw = 1;

	for(char c : s) {
		sum = (sum + (c - '0') * pw) % 2019;
		pw = pw * 10 % 2019;
		ans += mp[sum];
		++mp[sum];
	}

	cout << ans << '\n';	

	return 0;
}


Measured memory_bytes: 3692
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def bfs(graph, initial):
    n = len(graph) - 1
    dist = [-1] * (n + 1)
    q = deque([initial])
    visited = [False] * (n + 1)
    visited[initial] = True
    dist[initial] = 0

    while len(q) != 0:
        edge = q.popleft()
        nxt = graph[edge]

        for i, e in enumerate(nxt):
            if visited[e] is False:
                q.append(e)
                dist[e] = dist[edge] + 1
                visited[e] = True

    return dist


def main():
    N = I()
    graph = [[] for i in range(N+1)]

    for i in range(N):
        a = LI()
        edge = a[0]
        if a[1] == 0:
            continue
        for e in a[2:]:
            graph[edge].append(e)
            # graph[e].append(edge)

    # print(graph)
    ret = bfs(graph, 1)
    for i in range(1, N+1):
        print(i, ret[i])


if __name__ == '__main__':
    main()



Measured memory_bytes: 6868
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    REP(i,5){
        int a;
        cin >> a;
        if(a == 0)println(i + 1);
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int w = sc.nextInt();
                int[] a = new int[2];
                for(int i = 0 ; i < 2 ; i++){
                        a[i] = sc.nextInt();
                }
                sc.close();
                Arrays.sort(a);
                if(a[1] - a[0] <= w){
                        System.out.println(0);
                }else{
                        System.out.println(a[1] - a[0] - w);
                }
        }
}//0=48
//鶏になれ

Measured memory_bytes: 35748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353;
char st[maxn];
int main() {
    scanf("%s", st);
    int len = strlen(st);
    for(int i = 0; i < len; ++i)
    {
        if(st[i] == '1')
        {
            st[i] = '9';
        }
        else if(st[i] == '9')
        {
            st[i] = '1';
        }
    }
    printf("%s", st);
    return 0;
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int n;
	cin >> n;

	vector<long long int> input(n);
	rep(i, n){
		cin >> input[i];
	}

	sort(all(input));

	int ans = 0;

	for(int i = 0; i < n - 2; i++){
		for(int j = i + 1; j < n - 1; j++){
			for(int k = j + 1; k < n; k++){
				long long int a = input[i];
				long long int b = input[j];
				long long int c = input[k];

				if(a != b && b != c && c != a && a + b > c && b + c > a && c + a > b){
					// cout << i << " " << j << " " << k << endl;
					// cout << a << " " << b << " " << c << endl;
					ans++;
				}
			}
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
	int n; int map[3][1001];
	int ans=-11111;
	using namespace std;
	void dfs(int x,int y,int sum)
	{
		
		  sum+=map[y][x];
	       if ((x==n)&&(y==2)) 
	           {
			   if (sum>ans)
	              ans=sum;
	          }
	        else
	        {
	        	if (x+1<=n)
				dfs(x+1,y,sum);
			 
			    if (y+1<=2)
			        dfs(x,y+1,sum);			        
			    
			}
	        
	}
	int main()
	{
	    cin>>n;
	    for (int i=1; i<=2; ++i)
	        for (int j=1; j<=n; ++j)
	              cin>>map[i][j];
	    dfs(1,1,0);
	    cout<<ans<<endl;
	}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	unsigned int n, a, b;

	cin >> n >> a >> b;

	string str;

	cin >> str;

	int i;

	int qoute = a+b;
	int overseas = 0;
	for(i = 0; i < n; ++i) {
		
		switch(str[i]) {
			
			case 'a' : 
			{
				if(qoute > 0) {
					cout << "Yes" << endl;
					qoute--;
					break;
				}
			}
			case 'b' : 
			{
				if(qoute > 0 && overseas < b) {
					cout << "Yes" << endl;
					overseas++;
					qoute--;
					break;
				}
			}
			case 'c' :
			{
				;
			}

			default: cout << "No" << endl; 
		}
		
	}
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(x) x.begin(), x.end()
#define lp(i, n) for (int i = 0; i < n; i++)
#define mem(a, v) memset(a, v, sizeof(a))
#define X real()
#define Y imag()
#define angle(a) (atan2(a.Y, a.X))
#define vec(a, b) ((b) - (a))
//#define length(a) (hypot(a.Y , a.X))
#define normalize(a) (a) / length(a)
#define dotP(a, b) ((conj(a) * b).X)
#define crossP(a, b) ((conj(a) * b).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(a) dotP(a, a)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(v, m) conj(v / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll n, ll x) {
  if (!x)
    return 1;
  if (x % 2)
    return n * fastpow(n, x - 1);
  ll p = fastpow(n, x / 2);
  p %= mod;
  p *= p;
  p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll ret = num % mod;
  while (ret < 0)
    ret += mod;
  return ret;
}

ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
long double dist(pair<ll, ll> &a, pair<ll, ll> &b) {
  return sqrt(
      ((a.f - b.f) * (a.f - b.f) * 1.0 + (a.se - b.se) * (a.se - b.se)));
}
/*vector<int> ap;
bool np[MX];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <MX; j+=i) np[j] = 0;
        }
    }
    for(ll i = 2 ; i< MX ; i++) if(np[i]) ap.pb(i);
}*/
const ll MX = 1e5+5;
double dp[305][305][305];
bool v[305][305][305];
int n;
double solve(int one , int two , int three){
	if(!one && !two && !three)
		return 0;
	double &ret = dp[one][two][three];
	if(v[one][two][three]) return ret;
	v[one][two][three] = 1;
	int s = one + two + three;
	ret = 1.0*n/s;
	if(one) ret += 1.0*one/s*solve(one-1,two,three);
	if(two) ret += 1.0*two/s*solve(one+1,two-1,three);
	if(three) ret += 1.0*three/s*solve(one,two+1,three-1);
	return ret;
}
int main()
{
    IO;
    cin>>n;
    vector<int> cnt(4);
    for(int i = 0 ; i< n ;i++){
		int x;
		cin>>x;
		cnt[x]++;
	}
	cout<<fixed<<setprecision(10)<<solve(cnt[1],cnt[2],cnt[3]);
    
    return 0;
}



Measured memory_bytes: 246016
parseInt(x) = parse(Int,x)

function main()
	a,b,c,x,y = readline() |> split |> x->parseInt.(x)
	if (a+b)<2*c
		print(a*x+b*y)
	elseif x >= y
		p = c*2*y
		x -= y
		p += min(a*x, 2*c*x)
		print(p)
	else
		p = c*2*x
		y -= x
		p += min(b*y, 2*c*y)
		print(p)
	end
end

main()

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll cnt = 0, tmp = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'W') {
            cnt += tmp;
        } else {
            tmp++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 720
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, k; readV(n, k);

  auto c(int x)
  {
    auto r = 0;
    for (; x < k; x <<= 1) ++r;
    return r;
  }

  auto p = 0.0;
  foreach (i; 1..n+1) p += 1.0 / 2^^c(i);
  writefln("%.10f", p/n);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

int n, i, x, y, cnt, limit;
vector<int> list[maxN];
int dp[maxN];
bool bad;
vector<int> aux;

bool good(int deny) {
    int p1, p2;

    p1 = 0; p2 = aux.size() - 1;
    while (p1 < p2) {
        if (deny == p1) {
            p1++; continue;
        }
        if (deny == p2) {
            p2--; continue;
        }

        if (aux[p1] + aux[p2] > limit) return false;
        p1++; p2--;
    }

    return true;
}

void dfs(int node, int root) {
    for (auto to : list[node])
        if (to != root && bad == false)
            dfs(to, node);

    if (bad) return;

    aux.clear();

    for (auto to : list[node])
        if (to != root)
            aux.pb(dp[to] + 1);

    if (node != 1 && aux.size() % 2 == 0) aux.pb(0), cnt++;
    sort(aux.begin(), aux.end());
    cnt -= aux.size() / 2;

    if (aux.size() % 2 == 0) {
        if (!good(-1)) bad = true;
        return;
    }

    int ans = -1;
    for (int step = 1 << 20; step > 0; step >>= 1)
        if (ans + step < aux.size())
            if (!good(ans + step))
                ans += step;

    ans++;
    if (ans == aux.size()) {
        bad = true;
        return;
    }

    dp[node] = aux[ans];
    if (dp[node] > limit) bad = true;
}

bool check(int _limit) {
    cnt = 0;
    limit = _limit;
    bad = false;
    dfs(1, 0);
    if (bad) return false;
    return true;
}

int main()
{
    //freopen("test.in","r",stdin);

    cin >> n;
    for (i = 1; i < n; i++) {
        cin >> x >> y;
        list[x].pb(y);
        list[y].pb(x);
    }

    int ans = 0;
    for (int step = 1 << 20; step > 0; step >>= 1)
        if (ans + step < n)
            if (!check(ans + step))
                ans += step;

    //cerr << check(1);

    check(ans + 1);
    cout << cnt << ' ' << ans + 1;


    return 0;
}


Measured memory_bytes: 14080
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
for i in range(dx):
  print("R", end="")
for i in range(dy):
  print("U", end="")
for i in range(dx):
  print("L", end="")
for i in range(dy):
  print("D", end="")
print("D", end="")
for i in range(dx+1):
  print("R", end="")
for i in range(dy+1):
  print("U", end="")
print("L", end="")
print("U", end="")
for i in range(dx+1):
  print("L", end="")
for i in range(dy+1):
  print("D", end="")
print("R")

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

int N, M, K;
vector<int> adj[100005];
vector<int> bloc[100005];
int col[100005];
set<int> grup[100005];
bool vis[100005];
int waktu;

void DFS(int u) {
  vis[u] = 1;
  col[u] = waktu;
  grup[waktu].insert(u);
  for(int v : adj[u]) {
    if(vis[v]) continue;
    DFS(v);
  }
}

int main() {
  scanf("%d %d %d", &N, &M, &K);
  int u, v;
  for(int i = 1; i <= M; i++) {
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for(int i = 1; i <= K; i++) {
    scanf("%d %d", &u, &v);
    bloc[u].push_back(v);
    bloc[v].push_back(u);
  }
  for(int i = 1; i <= N; i++) {
    if(!vis[i]) {
      waktu++;
      DFS(i);
    }
  }
  for(int i = 1; i <= N; i++) {
    int id = col[i];
//    cout << "id " << i << ": " << id << "\n";
    int ans = grup[id].size() - adj[i].size() - 1;
    for(int tdk : bloc[i]) {
      if(grup[id].count(tdk)) ans--;
    }
    cout << ans << " ";
  }
}

Measured memory_bytes: 22528
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5+7;
const ll mod = 1e9+7;
int main()
{
    int n;scanf("%d",&n);
    if(n&1)printf("%d\n",n+n);
    else printf("%d\n",n);
}


Measured memory_bytes: 256
n=int(input())
count=0
a=list(map(int,input().split()))

for i in range(n):
    min=a[i]
    k=i
    for j in range((i+1),n):
        if min > a[j]:
            min=a[j]
            k=j
    if k!=i :
        a[i],a[k]=a[k],a[i]
        count+=1

print(' '.join(map(str,a)))
print(count)


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


int main(){
	
	int n;
	while(cin>>n,n){
		
		vector<int>V1;
		vector<int>V2;
		for(int i=0;i<n;i++){
			int t;
			cin>>t;
			V1.push_back(t);
		}
		
		int cnt=0;
		
		while(1){
			if(cnt>10000){
				cout<<-1<<endl;
				break;
			}
			if(cnt%2){
				int f=1;
				for(int i=0;i<V2.size();i++){
					if(i+1!=V2[i]){
						f=0;
						break;
					}
				}
				if(f){
					cout<<cnt<<endl;
					break;
				}
				cnt++;
				
				V1.clear();
				for(int i=0;i<V2.size();i++){
					if(V2[i]>1){
						V1.push_back(V2[i]-1);
					}
				}
				V1.push_back(V2.size());
			}
			else{
				
				int f=1;
				for(int i=0;i<V1.size();i++){
					if(i+1!=V1[i]){
						f=0;
						break;
					}
				}
				if(f){
					cout<<cnt<<endl;
					break;
				}
				cnt++;
				
				V2.clear();
				for(int i=0;i<V1.size();i++){
					if(V1[i]>1){
						V2.push_back(V1[i]-1);
					}
				}
				V2.push_back(V1.size());
			}
			
			
		}
		
		
	}
	
	return 0;
}


Measured memory_bytes: 1248
#include <vector>
#include <iostream>

#define int long long

signed main() {
  int n, k;
  std::cin >> n >> k;

  std::vector<int> a(n+1, 0);
  for(int i = 1; i <= n; i++) {
    std::cin >> a[i];
  }

  for(int i = 0; i < k; i++) {
    std::vector<int> b(n+1, 0);
    for(int j = 1; j <= n; j++) {
      int l = std::max(1ll, j-a[j]);
      int r = std::min(n, j+a[j]);

      //std::cout << l << " " << r << std::endl;

      b[l]++;
      if(r < n) b[r+1]--;
    }

    for(int j = 1; j <= n; j++)
      b[j] += b[j-1];

    a = b;
    bool done = true;
    for(int j = 1; j <= n; j++)
      if(a[j] < n) done = false;

    if(done) {
      break;
    }
  }
  
  for(int i = 1; i <= n; i++)
    std::cout << a[i] << " ";
  std::cout << std::endl;

  return 0;
}



Measured memory_bytes: 6428
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    double a, b, c, d;
    while(cin >> a >> b >> c >> d){
        double ans = sqrt( (c-a) * (c-a) + (d-b) * (d-b));
        printf("%.6lf",ans);
    }
}

Measured memory_bytes: 1236
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int a,b;cin>>a>>b;cout<<a*b<<endl;
}


Measured memory_bytes: 3592
n,m = map(int,input().split())
s = [list(input().split()) for i in range(m)]

ac,wa = 0,0
cnt_ac = [0]*(n+1)
cnt_wa = [0]*(n+1)

for i in range(m):
    temp_num = int(s[i][0])
    temp_ans = s[i][1]
    if temp_ans == "WA":#不正解の時
        if cnt_ac[temp_num] != 1:#まだ正解していないなら
            cnt_wa[temp_num] += 1
    else:
        if cnt_ac[temp_num] != 1:#初めて正解したとき
            cnt_ac[temp_num] = 1
            ac += 1
            wa += cnt_wa[temp_num]  
        
print(ac,wa)
            

Measured memory_bytes: 27452
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}

ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p&1)    res = (res * x)%m;
        x = (x * x)%m;
        p >>= 1;
    }
    return res;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

const int N = 1e6 + 5, MX = 1e9;
int cnt(int n){
    int ret = 0;
    while (n % 100 == 0) {
        ++ret;
        n /= 100;
    }
    return ret;
}

int main(){
    int d = D(), n = D(), i = 1;
    while (n) {
        n -= cnt(i) == d;
        ++i;
    }
    printf("%d", i - 1);
    return 0;
}


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

class E
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

		var aM = a.Max();
		if (aM == 1) { Console.WriteLine(n); return; }

		var ps = Enumerable.Range(0, 500).Select(i => 2 * i + 1).TakeWhile(x => x <= aM).ToList();
		ps[0] = 2;
		var cs = ps.ToDictionary(p => p, p => 0);
		var a2 = (int[])a.Clone();

		for (int i = 0; i < n; i++)
		{
			foreach (var p in ps)
			{
				if (a2[i] == 1) break;
				var c = 0;
				for (; a2[i] % p == 0; c++) a2[i] /= p;
				if (c > cs[p]) cs[p] = c;
			}
			if (a2[i] > 1) cs[a2[i]] = 1;
		}

		var lcm = cs.Where(p => p.Value > 0).Select(p => ((MInt)p.Key).Pow(p.Value)).Aggregate((x, y) => x * y);
		Console.WriteLine(a.Select(x => lcm / x).Aggregate((x, y) => x + y).V);
	}
}

struct MInt
{
	const int M = 1000000007;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }

	public static implicit operator MInt(long v) => new MInt(v);
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator -(MInt x, MInt y) => x.V - y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;
	public static MInt operator /(MInt x, MInt y) => x * y.Inv();

	public MInt Pow(int i) => MPow(V, i);
	public MInt Inv() => MPow(V, M - 2);

	static long MPow(long b, int i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
}


Measured memory_bytes: 14688
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
constexpr int  INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	ll a, b;
	string s;
	cin >> a >> s >> b;
	if (s[0] == '+') {
		cout << a + b << endl;
	}
	else {
		cout << a - b << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int n; string s;
  	cin >> n >> s;
  	
  	vi W(n+2);
  	vi E(n+2);
  	W[0] = W[n+1] = E[0] = E[n+1] = 0;

	rep3(i,1,n){
      	W[i] = W[i-1];
    	if(s[i-1] =='W') W[i]++;
    }
  	rep3rev(i,n,1){
        E[i] = E[i+1];
    	if(s[i-1] =='E') E[i]++;
    }
  	/*
  	rep(i,n+2){
    	cout << W[i] << " ";
    }
  	cout << endl;
    rep(i,n+2){
    	cout << E[i] << " ";
    }
	*/
  	int mn = INT_MAX;
  	rep(i,n+1){
    	mn = min(mn, W[i] + E[i+1]);
    }
  	cout << mn << endl;
	return;
}

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

Measured memory_bytes: 2964
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
using namespace std;

int main() {
	long long A, B;
	char p;
	cin >> A >> p >> B;
	if (p == 43) {
		cout << A + B << endl;
	}
	else {
		cout << A - B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

int main(void){
    int n;
    cin >> n;
    
    int longs = 0;
    int sum = 0;
    for(int i = 0; i < n; i++){
        int l;        
        cin >> l;
        if(longs <= l){
            sum += longs;
            longs = l;
        } else {
            sum += l;
        }
    }

    if(longs < sum){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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


int main() {
	int r;
	std::cin >> r;
	if (r < 1200) std::cout << "ABC" << std::endl;
	else if (r < 2800) std::cout << "ARC" << std::endl;
	else std::cout << "AGC" << std::endl;

}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#define MAXA 100000
#define MAX 20000000000
#define s(i) scanf("%d", &(i))
#define p(i) printf("%d", (i))
#define ps() printf(" ") 
#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))
using namespace std;
int main(){
	int i, n, j, Count = 0;
	char str[10001] = {0}, str1[10001] = {0};
	cin >> n;
	getchar();
	cin >> str;
	rer(i,0,strlen(str)){
		if(str[i]+n <= 'Z'){
			str1[i] = str[i]+n;
		}else{
			char t = str[i]+n-26;
			while(t > 'Z'){
				t = t-26;
			}
			str1[i] = t;
		}
	}
	cout << str1 << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int d;
    cin >> d;
    switch (d) {
        case 22 : cout << "Christmas Eve Eve Eve" << endl;  break;
        case 23 : cout << "Christmas Eve Eve" << endl;      break;
        case 24 : cout << "Christmas Eve" << endl;          break;
        case 25 : cout << "Christmas" << endl;
    }
    return 0;
}

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

signed main() {
	int N,K;
	cin>>N>>K;
	int c;
	int ans=5000000000000000000;
	std::vector<int> x(N),y(N);
	for(int i=0;i<N;i++)cin>>x[i]>>y[i];
	for(int xi=0;xi<N;xi++){
		for(int xj=xi+1;xj<N;xj++){
			for(int yi=0;yi<N;yi++){
				for(int yj=yi+1;yj<N;yj++){
					c=0;
					for(int i=0;i<N;i++){
						if(min(x[xi],x[xj])<=x[i]&&max(x[xi],x[xj])>=x[i]&&min(y[yi],y[yj])<=y[i]&&max(y[yi],y[yj])>=y[i]){
							c++;
						}
					}
					if(c>=K)ans=min(ans,(max(x[xi],x[xj])-min(x[xi],x[xj]))*(max(y[yi],y[yj])-min(y[yi],y[yj])));
				}
			}
		}
	}
	cout<<ans<<endl;
}


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

bool pal(string s) {
	string t = s;
	reverse(t.begin(), t.end());
	return s == t;
}

signed main() {
	int a, b; cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; i++) {
		string s = to_string(i);
		ans += pal(s);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");	

  var a = parseInt(input[0], 10);
  var s = input[1]
  
  if(a<3200){
    console.log("red");
  }else{
    console.log(s)
  }	
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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 ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




int main()
{
    int N;
    string S;
    cin >> N >> S;

    int ans = 0;
    rep(i,10){
        rep(j,10){
            rep(k,10){
                int one = N;
                int two = N;
                int three = N;
                rep(l,N){
                    if(one == N && S[l] == '0'+ i) one = l;
                    if(two == N && l > one && S[l] == '0' + j) two = l;
                    if(three == N && l > two && S[l] == '0' + k){
                        //cout << i << j << k << endl;
                        ans++;
                        break;
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 256
import std.stdio;

void main(){
	int n;
	ulong ans;
	while(readf("%d\n", &n), n){
		int[] t;
		t.length = n;
		ans = 0;
		for (int i = 0; i < n; i++) {
			readf("%d\n", &t[i]);
		}
		t.sort;
		for (int i = 0; i < n-1; i++) {
			ans += t[i] * (n-1-i);
		}
		writeln(ans);
	}
}

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

int main()
{
    char a;
    cin>>a;
    if(a=='C')cout<<"G"<<endl;
    else if(a=='G')cout<<"C"<<endl;
    else if(a=='A')cout<<"T"<<endl;
    else if(a=='T')cout<<"A"<<endl;
}


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

using namespace std;

typedef long long ll;

ll dp[51][2500];

int main() {

	ll n, a; scanf("%lld %lld", &n, &a);

	dp[0][0] = 1;

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

		ll x; scanf("%lld", &x);

		for (int j = n - 1; j >= 0; j--)
			for (int w = 0; w + x <= 2500; w++)
				dp[j + 1][w + x] += dp[j][w];

	}

	ll ans = 0;

	for (int i = 1; i <= n; i++) ans += dp[i][i * a];

	printf("%lld", ans);

	return 0;

}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	getline(cin,s);
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		{
			for(int j=i+1;j<s.size();j++)
			{
				if(s[j]=='F')
				{
					puts("Yes");
					return 0;
				}
			}
		}
	}
	puts("No");
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  string tmp_s = "";
  for (int i = s.size() - 1; i >= 0; i--){
    tmp_s += s[i];
    if(tmp_s == "maerd") tmp_s = "";
    else if(tmp_s == "remaerd") tmp_s = "";
    else if(tmp_s == "esare") tmp_s = "";
    else if(tmp_s == "resare") tmp_s = "";
  }
  if(tmp_s == "") cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
from itertools import*
import math
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

k,A,B,C = map(int,input().split())
Max = max(2*k+10,101)
#二項係数とその逆元テーブルを作る前処理
fac = [0]*(Max)
finv = [0]*(Max)
inv = [0]*(Max)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,Max):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
#O(1)でmod計算した組合せ数を計算
def Comb(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod
def pow_mod(x,n):
    if n==0: return 1
    if n%2:return x*pow_mod(x,n-1)%mod
    a = pow_mod(x,n//2)
    return a*a%mod

M = A+B
a = A*inv[M]%mod
b = B*inv[M]%mod
E = 0
for n in range(k,2*k):
    E += (((n)*pow_mod(a,k)%mod)*pow_mod(b,n-k)%mod)*Comb(n-1,k-1)%mod
    E += (((n)*pow_mod(b,k)%mod)*pow_mod(a,n-k)%mod)*Comb(n-1,k-1)%mod
    E %= mod
E = E*100*inv[100-C]%mod
print(E)

Measured memory_bytes: 133084
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    priority_queue<P> pq;
    rep(i, n){
        pq.emplace(b[i], i);
    }

    int ans = 0;
    while(not pq.empty()){
        int x = pq.top().first;
        int id = pq.top().second;
        pq.pop();

        if(x <= a[id]){
            continue;
        }

        int sum = b[(id+n-1)%n] + b[(id+1)%n];
        int cnt = (x - a[id]) / sum;
        ans += cnt;
        b[id] -= sum * cnt;

        if(b[id] > a[id] && x != b[id]){
            pq.emplace(b[id], id);
        }
    }

    rep(i, n){
        if(a[i] != b[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9456
s=input()
l=len(s)

ans=0

if s[0]=="0":
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "1":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "0":
                ans+=1

else:
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "0":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "1":
                ans+=1

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n;

	cin >> n;
	int a[n*3];
	for(int i = 0; i < n*3; i++){
		cin >> a[i];
	}
	sort(a,a+n*3);
	long long ans = 0;

	for(int i = 0; i < n; i++){
		int p = (n*3-2) - i*2;
		ans += a[p];
		//cout << p << endl;
	}
	cout << ans << endl;
	return 0;
}
/*


*/


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;
    if (a + b >= 10)
        cout << "error" << endl;
    else
        cout << a + b << endl;

    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
using namespace std;
int main() {
  int a;
  int i,j;
  cin >> a;

  string mozi[a];

  for(i=0;i<a;i++){
  cin >> mozi[i];
  }

  for(i=0;i<a;i++){
     for(j=i+1;j<a;j++){
       if(mozi[i] == mozi[j]){
        cout << "No" << endl;
          return 0;
       }
    };
  };

  for(i=0;i<a-1;i++){
    if(mozi[i][mozi[i].size()-1]!=mozi[i+1][0]){
        cout << "No" << endl;
                  return 0;
    }
  }

        cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
    char a[10], mozi[100];
    int n, x, y;
    scanf("%s %d", &a, &n);
    y=0;
    for(x=0; x<n; x++)
    {
        scanf("%s", mozi);
        strncat(mozi,mozi,10);
        if((strstr(mozi,a))!=NULL)
        {
            y++;
        }
    }
    printf("%d\n", y);
     
    return 0;
}


Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll cnt = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] <= 0)
        {
            cnt++;
        }
    }
    // cout<<cnt<<endl;
    ll res = 0;
    for (ll i = 0; i < n; i++)
    {
        a[i] = llabs(a[i]);
    }
    sort(ALL(a));
    // for(auto d:a){
    //     cout<<d<<' ';
    // }
    // cout<<endl;
    for (ll i = 0; i < n; i++)
    {
        res += a[i];
    }
    if (cnt % 2 == 1)
    {
        res -= 2 * a[0];
    }
    cout << res << endl;
}

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

int main(){
    int h,w;
    while(cin >> h >> w && !(h==0 && w==0)){
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

int main() {
int H, W;
while (true) {
cin >> H >> W;
if (H == 0 && W == 0) break;
for (int u = 0; u < H; u++) {
for (int i = 0; i < W; i++) {
cout << "#";
}
cout << endl;
}
cout << "\n";
}
return 0;
}


Measured memory_bytes: 3040