akhauriyash/Code-Regression huggingface dataset:
import math


def main():
    N, K = map(int, input().split())
    print((max(0, N - K + 1) + sum(
        max(0, N - (math.ceil(K * (1 / 2) ** i)) + 1) * (1 / 2) ** i
        - max(0, N - (math.ceil(K * (1 / 2) ** (i - 1))) + 1) * (1 / 2) ** i
        for i in range(1, len(bin(K)) - 2 + 1 + 1))) / N)
    return


main()


Measured memory_bytes: 3060
#include<string>
#include<iostream>
using namespace std;
int main(void)
{
  string str;
  cin >> str;
  int status = 0;
  for(int i=0; i < (int)str.size(); i++){
    switch(status){
      case 0:
        if(str[i] == 'h') status = 1;
        else status = 3;
        break;
      case 1:
        if(str[i] == 'i') status = 2;
        else status = 3;
        break;
      case 2:
        if(str[i] == 'h') status = 1;
        else status = 3;
        break;
      default:
        status = 3;
        break;
    }
  }
  if(status == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

typedef pair<ll, ll> P;
vector<int> bu(100010, 0);
vector<bool> fl(100010, false);

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<P> v;
    REP(i,m) {
        int a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }
    sort(v.begin(), v.end(), [](const P& x, const P& y){return x.second < y.second;});
    ll ans = 1;
    int r = v[0].second;
    for (int i = 1; i < m; ++i) {
        if (r <= v[i].first) {
            ans++;
            r = v[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2808
#include<iostream>
#include<string>
using namespace std;
#define MAX 105
#define ERROR "ERROR"
char G[MAX][MAX];
int px, py;

void init(){
    for ( int y = 0; y < MAX; y++ )
	for ( int x = 0; x < MAX; x++ ) G[y][x] = ' ';
    for ( int x = 0; x < MAX; x++ ) G[0][x] = 'X';
}

bool F(){
    if ( G[py][px] == ' ' ) return false;
    px++;
    return true;
}

bool B(){
    if ( G[py][px-1] == ' ' ) return false;
    px--;
    return true;
}

bool P(){
    if ( G[py+1][px] == ' '){
	char l = G[py+1][px-1];
	if ( l == ' ' ) return false;
    }
    py++;
    return true;
}

bool N(){
    if ( py == 1 ) return false;
    if ( G[py-1][px] == ' ' ){
	char l = G[py-1][px-1];
	if ( l == ' ' ) return false;
    }
    py--;
    return true;
}

bool D(){
    if ( G[py][px] == ' ' ) return false;
    G[py][px] = ' ';
    int ry = py;
    int rx = px;
    while( G[ry][rx+1] != ' '){
	G[ry][rx] = G[ry][rx+1];
	G[ry][rx+1] = ' ';
	rx++;
    }
    if ( G[py][px] == ' ' && G[py][px-1] == ' '){
	py--;
	if ( py == 0 ) return false;
	if ( G[py][px] == ' ' && G[py][px-1] == ' '){
	    return false;
	}
    }
    return true;
}

bool C(){
    if ( G[py][px] == ' ') return false;
    if ( G[py+1][px] != ' ' ) return false;
    G[py+1][px] = G[py][px];
    py++; px++;
    return true;
}

void insert(char ch){
    int wx = px;
    while(G[py][wx] != ' ') wx++;
    for ( int x = wx; x >= px+1; x--) G[py][x] = G[py][x-1];
    G[py][px++] = ch;
}

bool fall(){
    for ( int y = 2; y < MAX; y++ ){
	for ( int x = 1; x < MAX; x++ ){
	    if ( G[y][x] == ' ') continue;
	    int sx = x;
	    int ex = x;
	    while( G[y][ex+1] != ' ') ex++;
	    int ty = y;
	    bool hasc = false;
	    for ( int i = sx; i <= ex; i++ ) if ( py == y && (px == i || px == i+1)) hasc = true;
	    while(1){
		bool empty = true;
		for ( int i = sx; i <= ex; i++ ) if ( G[ty-1][i] != ' ' ) empty = false;
		if ( empty ) ty--;
		else break;
	    }
	    if ( ty < y ){
		for ( int i = sx; i <= ex; i++ ){
		    G[ty][i] = G[y][i]; G[y][i] = ' ';
		}
		if ( hasc ) py = ty;
		return true;
	    }
	    x = ex;
	}
    }
    return false;
}

string simulate(){
    string str; cin >> str;
    init();
    py = px = 1;
    G[py][px++] = str[0];
    for ( int i = 1; i < str.size(); i++ ){
	char ch = str[i];
	if ( ch == 'F' ) {
	    if ( !F() ) return ERROR;
	} else if ( ch == 'B' ){
	    if ( !B() ) return ERROR;
	} else if ( ch == 'P' ){
	    if ( !P() ) return ERROR;
	} else if ( ch == 'N' ){
	    if ( !N() ) return ERROR;
	} else if ( ch == 'D' ){
	    if ( !D() ) return ERROR;
	    while(fall());
	} else if ( ch == 'C' ){
	    if ( !C() ) return ERROR;
	} else {
	    insert(ch);
	}
    }
    string ans = "";
    int p = px-1;
    while( G[py][p] != ' '){ ans = G[py][p] + ans; p--; }
    p = px;
    while( G[py][p] != ' '){ ans = ans + G[py][p]; p++; }

    return ans;
}

main(){
    int n; cin >> n;
    for ( int i = 0; i < n; i++ ) cout << simulate() << endl;
}

Measured memory_bytes: 1220
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
using namespace std;

int main()
{
    int n, i, j;
    cin>>n;
    vector<int> first(n);
    vector<int> second(n);
    for(i=0;i<n;i+=1)
    {
        cin>>first[i]>>second[i];
    }
    int flag =  0;
    for(i=0;i<=n-3;i+=1)
    {
        if(first[i]==second[i] and first[i+1]==second[i+1] and first[i+2]==second[i+2])
        {
            flag = 1;
            break;
        }
    }
    if(flag==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


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

int main() {
  ll X;
  cin >> X;
  ll money = 100;
  int ans = 0;
  while(1) {
    ans++;
    ll risi = money / 100;
    money += risi;
    if (money >= X) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>

int main(void) {
 double PI = acos(-1);
 int R ;
 scanf("%d",&R);

 double res = 2 * R * PI;
 printf("%lf",res);




 return EXIT_SUCCESS;
}



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

int main(){
	long long int n,a,b;
	cin>>n>>a>>b;
	int x[n]={0};
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	long long int ans=0;
	for(int i=1;i<n;i++){
		long long int w=a*(x[i]-x[i-1]);
		ans+=min(w,b);
	}
	
	cout<<ans<<endl;
}		

Measured memory_bytes: 640
from math import cos, sin, radians
from cmath import exp

a, b, h, m = map(int, input().split())

# 時針は一時間あたり360/12 = 30度
# 時針は一分あたり30/60 = 0.5度
# 分針は一分あたり360/60 = 6度
hdeg = radians(h * 30 + m * 0.5)
mdeg = radians(m * 6)

# オイラーの公式
hz = a * exp(complex(0, hdeg))
mz = b * exp(complex(0, mdeg))

# 複素数平面における二点間の距離
dist = abs(hz - mz)

print(dist)

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

int main(){
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  double P=acos(-1)*(60*H+M)/360;
  double Q=acos(-1)*M/30;
  cout << fixed << setprecision(10) << sqrt(A*A+B*B-2*A*B*cos(P-Q)) << endl;
}
  

Measured memory_bytes: 4188
import java.util.*;

class Main {

    static void solve (int [] data) {
        int [][] triangle = new int[10][10];
        triangle[0] = data;

        for(int i = 1; i < 10; i++) {
            for(int j = 0; j < 10 - i; j++) {
                triangle[i][j] = ( triangle[i-1][j] + triangle[i-1][j+1] ) % 10;
            }
        }

        System.out.println(triangle[9][0]);
    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        int[] data = new int[10];
        
        while(sc.hasNext()) {
            char[] line = sc.nextLine().toCharArray();
            for(int i = 0; i < 10; i++ ){
                data[i] = Integer.parseInt( "" + line[i]);
            }
            solve(data);
        }

    }
}

Measured memory_bytes: 12000
n = int(input())
p = []
n2 = n
for i in range(2,int(n2**0.5//1 + 1)):
  index = 0
  while n2%i == 0:
    index+=1
    n2 = n2//i
  if index != 0:
    p.append(index)
  else:
    continue
count = 0
t = 1

if n2 == 1:
  next
else:
  count+=1

if n == 1:
  print(0)
elif not p:
  print(1)
else:
  for i in range(len(p)):
    while p[i] - t >= 0:
      p[i]-=t
      count+=1
      t+=1
    t = 1
  print(count)

Measured memory_bytes: 9464
#include<bits/stdc++.h>
using namespace std;
const int offset=100010;
#define lowb(x) x&-x
int n,a[offset],s[offset*10],bit[offset*10];
void add(int x)
{
	while(x<=2*offset)
	{
		bit[x]++;
		x+=lowb(x);
	}
}
long long cal(int x)
{
    long long sum=0;
    while(x>=1)
    {
    	sum+=bit[x];
    	x-=lowb(x);
	}
    return sum;
}
bool check(int x)
{
    for(int i=1;i<=2*offset;i++)
		bit[i]=0;
    s[0]=0;
    for(int i=1;i<=n;i++)
    	if(a[i]>=x)
        	s[i]=s[i-1]+1;
        else
        	s[i]=s[i-1]-1;
    long long sum=0;
    for(int i=0;i<=n;i++)
	{
        sum+=cal(s[i]+offset);
        add(s[i]+offset);
    }
    return sum>=1ll*n*(n+1)/4;
}
int main()
{
    cin>>n;
    int l=0,r=0;
    for(int i=1;i<=n;i++)
	{
        cin>>a[i];
        r=max(r,a[i]);
    }
    while(l<=r)
	{
        int mid=(l+r)/2;
        if(check(mid))
			l=mid+1;
        else
			r=mid-1;
    }
    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 7168
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int a,p;
    scanf("%d%d",&a,&p);
    int ha=a*3+p;
    int ans=ha/2;
    printf("%d\n",ans);
    return 0;
}

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

int main() {
	int N,cnt=0;
	string S,T;
	char ans[N];
	cin >> N >> S >> T;
	for(int i=0;i<N;i++){
		ans[cnt]=S.at(i);
		cnt++;
		ans[cnt]=T.at(i);
		cnt++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll a,p; cin >> a >> p;
  cout << (3*a+p)/2;
  return 0;
}

Measured memory_bytes: 256
round = int(input(""))
for i in range (0,round):
    arr = []
    temp = input("")
    a,b,c = temp.split(" ")
    arr.append(int(a))
    arr.append(int(b))
    arr.append(int(c))
    arr.sort()
    if(pow(arr[0],2)+pow(arr[1],2)==pow(arr[2],2)):
        print("YES")
    else:
        print("NO")



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

using namespace std;

int main()
{
	int n;

	while(cin >> n && n)
	{
		int data[100000]={};
		int count=0;

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

		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n-i-1;j++)
			{
				if(data[j]>data[j+1])
				{
					swap(data[j],data[j+1]);
					count++;
				}
			}
		}
		cout << count << endl;
	}

    return 0;
}

Measured memory_bytes: 1556
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
typedef pair < pii , pii > p4i;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n;
p4i a[1000005],data[20][1000005];
void upd(p4i &A,p4i B){
	if(B.first>A.first){
		A.second=A.first;
		A.first=B.first;
	}
	else if(B.first>A.second && B.first!=A.first){
		A.second=B.first;
	}
	if(B.second>A.second) A.second=B.second;
}
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
    int i,j,k;
	scanf("%d",&n);
	for(i=0;i<(1<<n);++i){
		scanf("%d",&a[i].first.first);
		a[i].first.second=i;
		a[i].second.first=a[i].second.second=-1;
	}
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
	for(i=1;i<(1<<n);++i){
		for(j=0;j<n;++j){
			if(i&(1<<j)){
				upd(a[i],a[i^(1<<j)]);
			}
		}
	}
    for(i=0;i<(1<<n);++i){
		int tmp=i;
		for(j=0;j<n;++j){
			if(!(i&(1<<j)))
				upd(data[j][tmp],a[i]);
			else
				tmp-=(1<<j);
		}
	}
	for(i=1;i<(1<<n);++i){
		int tmp=i,res=a[i].first.first+a[i].second.first;
		for(j=0;j<n;++j){
			if(!(i&(1<<j))) continue;
			tmp-=(1<<j);
		//	printf("i=%d (%d %d): (%d,%d)+(%d,%d)\n",i,j,tmp,data[j][tmp].first.first,data[j][tmp].first.second,data[j][tmp].second.first,data[j][tmp].second.second);
			UMAX(res,data[j][tmp].first.first+data[j][tmp].second.first);
		}
		printf("%d\n",res);
	}
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

Measured memory_bytes: 111616
#include<stdio.h>

int main(void){
  int a,l,r;
  scanf("%d",&a);
  l = a/100;
  r = a%100;
  if(0<l && l<=12){
    if(0<r && r<=12)printf("AMBIGUOUS\n");
    else printf("MMYY\n");
  }else{
    if(0<r && r<=12)printf("YYMM\n");
    else printf("NA\n");
  }
}

Measured memory_bytes: 128
def resolve():
    '''
    code here
    '''
    N, D = [int(item) for item in input().split()]
    points = [[int(item) for item in input().split()] for _ in range(N)]

    cnt = 0
    for x, y in points:
        if x**2 + y**2 <= D**2:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 42392
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());

        int res = 0;

        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) {
                    res++;
                }
            }
        }

        System.out.println(res);
    }
}


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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

constexpr int mod = 998244353;
int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> in(n);
	for (int i : range(n))in[i] = s[i] - 'a';
	set<vector<int>> all;
	queue<vector<int>> que;
	que.push(in);
	all.insert(in);
	while (que.empty() == false) {
		if (all.size() > 30)break;
		auto now = que.front();
		que.pop();
		for (int i : range(n - 1)) {
			if (all.size() > 30)break;
			if (now[i] == now[i + 1])continue;
			auto nxt = now;
			nxt[i] = nxt[i + 1] = 3 - now[i] - now[i + 1];
			if (all.count(nxt) == 0) {
				all.insert(nxt);
				que.push(nxt);
			}
		}
	}
	if (que.size() == 0) {
		cout << all.size() << endl;
	}
	else {
		int M = 0;
		for (int i : range(n)) {
			M = (M + in[i]) % 3;
		}
		LL ret = 1;
		for (int i : range(n-1)) {
			if (in[i] == in[i + 1])ret = 0;
		}
		using V = vector<LL>;
		using VV = vector<V>;
		using VVV = vector<VV>;

		VVV dp(2, VV(3, V(3,0)));
		for (int i : range(3))dp[0][i][i] = 1;
		for (int _ : range(n - 1)) {
			VVV nxt(2, VV(3, V(3, 0)));
			for (int i : range(2)) {
				for (int j : range(3)) {
					for (int k : range(3)) {
						for (int l : range(3)) {
							if (k == l) {
								nxt[i|1][(j + l) % 3][l] += dp[i][j][k];
							}
							else {
								nxt[i][(j + l) % 3][l] += dp[i][j][k];
							}
						}
					}
				}
			}
			for (auto &a : nxt)for (auto &b : a)for (auto &c : b)c %= mod;
			swap(dp, nxt);
		}
		cout << (ret + dp[1][M][0]+ dp[1][M][1]+dp[1][M][2]) % mod << endl;
	}

	return 0;
}


Measured memory_bytes: 50436
w,h,n=map(int,input().split())
xa=0
xb=w
ya=0
yb=h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        xa=max(x,xa)
    if a==2:
        xb=min(x,xb)
    if a==3:
        ya=max(y,ya)
    if a==4:
        yb=min(y,yb)
print(max((xb-xa)*max((yb-ya),0),0))

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	ds := make([]int, n)
	for i := 0; i < len(ds); i++ {
		ds[i] = eGetInt(scanner)
	}
	sort.Ints(ds)
	sum := 1
	for i := 1; i < len(ds); i++ {
		if ds[i] != ds[i-1] {
			sum++
		}
	}
	fmt.Println(sum)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
A = []
bingo = []
for i in range(3):
    A.append(list(map(int, input().split())))
    bingo.append([False] * 3)

N = int(input())

for i in range(N):
    b = int(input())
    for j in range(3):
        if b in A[j]:
            idx = A[j].index(b)
            bingo[j][idx] = True

# check
migiue = True
migisita = True
okFlg = False
for i in range(3):
    tate = True
    yoko = True
    for j in range(3):
        if bingo[i][j] == False:
            yoko = False
        if bingo[j][i] == False:
            tate = False
    if tate or yoko:
        okFlg = True
        break
    if bingo[i][i] == False:
        migisita = False
    if bingo[i][-i - 1] == False:
        migiue = False

if migiue or migisita:
    if okFlg == False:
        okFlg = True
print('YNeos'[not okFlg::2])


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

int main(){
  
  int n, m, ans = -100;
  string s, t;
  map<string, int> mp;
  
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> s;
    mp[s]++;
  }
  
  cin >> m;
  for(int i = 0;i < m;i++){
    cin >> t;
    mp[t]--;
  }
  
  map<string, int>::iterator it;
  for(it = mp.begin();it != mp.end();it++) ans = max(ans, it->second);
  
  cout << max(0, ans) << endl;
  
  return 0;
}

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

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

	if (N % 2 == 0)
	{
		cout << 1.0 / 2;
	}
	else
	{
		int s = N / 2;
		s = N - s;

		cout << s * 1.0 / N;
	}
	
}


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

int main() {
	int		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	s;
	
	cin >> n;
	cin >> s;
	
	for(i=0;i < n-2 ; i++) {
		if ((s[i] == 'A') && (s[i+1] == 'B') && (s[i+2] == 'C')) {
			ans++;
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
// 問題の URL を書いておく
// https://atcoder.jp/contests/abc167/tasks/abc167_c

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

int main(int argc, const char* argv[])
{
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> costs(n);
    vector<vector<int>> skills(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> costs[i];
        vector<int> skill(m);
        for(int j = 0; j < m; ++j)
        {
            cin >> skill[j];
        }
        skills[i] = skill;
    }

    int minCost = numeric_limits<int>::max();
    for(int i = 0; i < (1 << n); ++i)
    {
        int cost = 0;
        vector<int> mySkill(m);
        for(int j = 0; j < n; ++j)
        {
            if(((i >> j) & 1) == 1)
            {
                cost += costs[j];
                for(int k = 0; k < m; ++k)
                {
                    mySkill[k] += skills[j][k];
                }
            }
        }
        bool success = true;
        for(int j = 0; j < m; ++j)
        {
            if(mySkill[j] < x)
            {
                success = false;
                break;
            }
        }
        if(success)
        {
            minCost = min(minCost, cost);
        }
    }
    if(minCost == numeric_limits<int>::max())
    {
        cout << -1 << endl;
    }
    else
    {
        cout << minCost << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
//#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "")
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = __int128;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
istream& operator >>(istream &is, __int128 &a) { int64_t i; is >> i; a = (__int128)i; return is; }
ostream& operator <<(ostream &os, const __int128 &a) { os << (int64_t)a; return os; }
string to_string(__int128 i) { return to_string((int64_t)i); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

const ll INF = 5e15;

int main() {
    ll N;
    cin >> N;
    ll sum = 0;
    ll me = INF;
    for(ll i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        sum += a;
        if(a > b) chmin(me, b);
    }
    if(me == INF) cout << 0 << endl;
    else cout << sum - me << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<int> T(N);
    int sum = 0;
    rep(i, 0, N)
    {
        cin >> T[i];
        sum += T[i];
    }
    int M;
    cin >> M;
    int P, X;
    rep(i, 0, M)
    {
        cin >> P >> X;
        cout << sum - T[P - 1] + X << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace _20190316
{
    class Program
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var str = Console.ReadLine().Trim();
            var d = new Dictionary<char, int>();
            for (int i = 0; i < n; i++)
            {
                if (d.ContainsKey(str[i])) { d[str[i]]++; }
                else { d[str[i]] = 1; }
            }
            var result = 1L;
            foreach (var item in d)
            {
                result *= item.Value + 1;
                result %= mod;
            }
            Console.WriteLine(result - 1);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
int min(int a, int b)
{
	if(a<b) return a;
	else return b;
}
int main()
{
	int n,x,m,a[101], i, c1,c2, st;
	while(~scanf("%d %d %d", &n, &m, &x))
	{
		c1=c2=0;
		for(i=0; i<m; i++)
		{
			scanf("%d", &st);
			if(st<x) c1++;
			else if(st>x) c2++;
		}
		printf("%d\n", min(c2,c1));
	}
	return 0;
}

Measured memory_bytes: 256
/*
* Created by: WeirdBugsButOkay
*/

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

void solve()
{
    int n, N = 1e4 + 1;
    cin >> n;
    int ans[N] = {0};
    for(int i = 1; i < 105; i++)
        for(int j = 1; j < 105; j++)
            for(int k = 1; k < 105; k++)
            {
                int val = i * i + j * j + k * k + i * j + j * k + k * i;
                if(val < N)
                    ans[val]++;
            }
    for(int i = 1; i <= n; i++)
        cout << ans[i] << endl;
}

int main()
{
    int q = 1;
    //scanf("%d", &q);
    for(int i = 1; i <= q; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int gcd(int a, int b){return b?gcd(b,a%b):a;}

signed main(){
   ll a,b;
   cin>>a>>b;
   // cout<<gcd(a,b)<<endl;
   vector<int>v;
   int x=gcd(a,b);
   if(x==1){
       cout<<1<<endl;
       return 0;
   }
  /*  for (int i = 1; i*i <=x; i++)
    {
        if(x%i==0){
            v.push_back(i);
            if(i*i!=x)v.push_back(x/i);
        }
    }*/
    int i=2;
    vector<int>w;
    set<int>st;
    while(i*i<=x){
        if(x%i==0){
            //w.push_back(i);
            st.insert(i);
            x/=i;
        }
        else{
            i++;
        }
    }
    //w.push_back(x);
    st.insert(x);
    //show(w);
    cout<<st.size()+1<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
m,a,r,c,h=0,0,0,0,0
for i in range(n):
  s=input()
  if s[0]=='M':
    m+=1
  elif s[0]=='A':
    a+=1
  elif s[0]=='R':
    r+=1
  elif s[0]=='C':
    c+=1
  elif s[0]=='H':
    h+=1
print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

struct SegTree {
	ll sz;
	vector<ll> dat;
	SegTree(ll n) {
		sz = 1;
		while (sz < n)sz *= 2;
		dat.resize(2 * sz - 1, (1ll << 31) - 1);
	}
	void update(ll a, ll x) {
		a += sz - 1;
		dat[a] = x;
		while (a > 0) {
			a = (a - 1) / 2;
			dat[a] = min(dat[a * 2 + 1], dat[a * 2 + 2]);
		}
	}
	ll query(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
		if (r < 0) r = sz;
		if (r <= a or b <= l)return INF;
		if (a <= l and r <= b)return dat[k];
		ll q1, q2;
		q1 = query(a, b, k * 2 + 1, l, (l + r) / 2);
		q2 = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(q1, q2);
	}
};
SegTree s(210000);
int main() {
	ll n, m;
	cin >> n >> m;
	REP(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		if (a == 0) s.update(b, c);
		else cout << s.query(b, c + 1) << endl;
	}
}



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

int main() {
  int N,i,s=0,x=0,S1=0,j;
  cin >> N;
  vector<int> W(N);
  
  for(i=0; i<N; i++) {
    cin >> W.at(i);
    s+= W.at(i);
  }
  
  i=0;
  do {
    x += W.at(i);
    i++;
  } while(x<s/2);
  
  for(j=0; j<i; j++)
    S1 += W.at(j);
  
  cout << min(abs(2*S1-s),abs(2*(S1-W.at(j-1))-s)) << endl;
}

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

int main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    int top = y + r, bottom = y - r, right = x + r, left = x - r;
    if(top <= h && bottom >= 0 && right <= w && left >= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3096
from math import ceil
from itertools import permutations

#S=input()
#D=list(map(int,input().split()))
from heapq import *
"""
import sys
input=sys.stdin.readline
"""
from collections import defaultdict
from fractions import gcd
#S=
from math import sqrt
import sys
sys.setrecursionlimit(100100)

from collections import deque
import bisect
import sys
input=sys.stdin.readline

n=int(input())
s=int(input())
if s>n:
    print(-1)
    quit()
if s==n :
    print(n+1)
    quit()
def func(b,n):
    res=0
    while(n):
        res+=n%b
        n//=b
    return res
j=1
i=n
ans=10**30
for i in range(2,int(sqrt(n))+1):
    if func(i,n)==s:
        ans=min(ans,i)
l=defaultdict()
for i in range(1,ceil(sqrt(n))):
    b=(n-s)//i+1
    if sqrt(n)<b and n//b+(n%b)==s:
        ans=min(ans,b)
if ans==10**30:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 66408
#include<bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

int main(){
    int n;
    cin >> n;
    vector<P> r(n), b(n);
    for(int i=0;i<n;i++) cin >> r[i].first >> r[i].second;
    for(int i=0;i<n;i++) cin >> b[i].first >> b[i].second;
    sort(r.begin(), r.end(), [](const P x, const P y){
        return x.second < y.second;
    });
    sort(b.begin(), b.end(), [](const P x, const P y){
        return x.first < y.first;
    });
    int ans = 0;
    vector<bool> used(n,false);
    for(auto eb: b){
        int elem = -1, mxy = -1;
        for(int i = 0; i < n; i++){
            if(r[i].second >= eb.second) break;
            if(used[i]) continue;
            if(r[i].first < eb.first){
                mxy = r[i].second;
                elem = i;
            }
        }
        if(elem != -1) {
            used[elem] = true;
            ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N, K = map(int, input().split())
j = 0
i = 3
A = 1000000000000000001
B = 1000000000000000002
C = 1000000000000000003
if N<K:
    M = N-K
    M = abs(M)
    
    if M<N:
        print(M)
    else:
        print(N)
elif N==K:
    print(0)
elif N%K==0:
    print(0)
else:
    N = N%K
    while j==0:
        #print(N)
        #print("aaa")
        N = N-K
        N = abs(N)
        if i%3==0:
            A = N
        elif i%3==1:
            B = N
        elif i%3==2:
            C = N
        
        if A==C:
            if A<=B:
                print(A)
            else:
                print(B)
            j+=1
        elif B==A:
            if A<=C:
                print(B)
            else:
                print(C)
            j+=1
        elif B==C:
            if B<=A:
                print(C)
            else:
                print(A)
            j+=1
        i+=1
            
            

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <iomanip>
#include <map>
#include <string.h>
#include <cstring>
#include <queue>
#include <limits>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <cmath>
#include <stdio.h>
#include <set>
#include <cstdio>
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define FOR(i, a) for(int i = 0; i < (a); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int N = 1e5 + 10;
double esp = 1e-10;
string s;
int main() {
    while (cin >> s) {
        s[3] = '8';
        cout << s << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int flag=0;
        for(int i=0;i<=n/4;i++)
        {
            for(int j=0;j<=n/7&&4*i+7*j<=n;j++)
            {
                if(4*i+7*j==n)
                {
                    flag=1;
                    break;
                }
            }
        }
        if(flag==1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define s second

using namespace std;

const int N = (int) 770 + 10;
const int K = (int) N * N;
const int mod = (int) 1e9 + 7;

int n, m, comp;
bool g[N][N], u[N];
int c[N];
int comp_id[N];
bool dp[N], gdp[N];
int cnt[2];

void dfs(int x, int clr = 0) {
	//cout << x << ' ' << clr << ' ' << comp << endl;
	u[x] = 1;
	c[x] = clr;
	cnt[clr]++;
	comp_id[x] = comp;
	for (int i = 1; i <= n; i++) {
		if (g[x][i] || i == x) 
			continue;
		if (!u[i]) {
			dfs(i, clr ^ 1);
		} else if ((clr ^ 1) != c[i]) {
			cout << -1;
			exit(0);
		}
	}
}

ll f(ll x) {
	return x * (x - 1) / 2;
}

int main() {
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n >> m;
	for (int i = 1, x, y; i <= m; i++) {
		cin >> x >> y;
		g[x][y] = g[y][x] = 1;
	}
	vector<pii> v;
	for (int i = 1; i <= n; i++) {
		if (!u[i]) {
			++comp;
			dfs(i);
			v.pb(mp(cnt[0], cnt[1]));
			cnt[0] = cnt[1] = 0;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (comp_id[i] != comp_id[j] && g[i][j] == 0) {
				while (1) {

				}
			}
		}
	}
	dp[0] = 1;
	for (auto it : v) {
		memset(gdp, 0, sizeof(gdp));
		for (int i = n; i >= 0; i--) {
			if (i + it.f <= n) {
				gdp[i + it.f] |= dp[i];
			}
			if (i + it.s <= n) {
				gdp[i + it.s] |= dp[i];
			}
		}	
		for (int i = n; i >= 0; i--) {
			dp[i] = gdp[i];
		}
	}
	ll ans = LLONG_MAX;
	for (int i = n; i >= 0; i--) {
		if (dp[i]) {
			ans = min(ans, f(i) + f(n - i));
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 768
#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

class Modinv:
    def __init__(self, n, mod):
        self.mod = mod
        self.fact = [1]*n
        self.finv = [1]*n
        self.inv  = [1]*n
        for i in range(2,n):
            self.fact[i] = (self.fact[i-1]*i) % self.mod
            self.inv[i]  = self.mod - self.inv[self.mod%i] * (self.mod//i)%self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod

    def nPr(self, n, r):
        if n<r:
            return 0
        else:
            return self.fact[n] * self.finv[n-r] % self.mod

    def nCr(self, n, r):
        if n<r:
            return 0
        else:
            return self.fact[n] * (self.finv[r] * self.finv[n-r] % self.mod) % self.mod

    def nHr(self, n, r):
        return self.nCr(n-1+r, n-1)

def main():
    X,Y = map(int,input().split())

    if (X+Y)%3 != 0:
        print(0)
    else:
        # 操作回数
        n = (X+Y)//3
        # 移動を簡略化, (1,2) => (0,1), (2,1) => (1,0) に
        X -= n
        Y -= n
        # 負の領域には移動不可能
        if X < 0 or Y < 0:
            print(0)
        else:
            modinv = Modinv(10**6+10, 10**9+7)
            print(modinv.nCr(X+Y,X))


if __name__ == "__main__":
    main()

Measured memory_bytes: 127536
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;
template <typename T = vii> 
using vec = vector<T>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    
    int n;
    cin >> n;
    vll v(n), dp[2];
    for (auto &e : v) {
        cin >> e;
    }
    dp[0].assign(n, 0);
    dp[1].assign(n, 0);
    dp[0][0] = v[0];
    dp[1][0] = -1e10;
    for (int i = 1; i < n; i++) {
        dp[0][i] = max(dp[0][i - 1], dp[1][i - 1]) + v[i];
        dp[1][i] = max(dp[0][i - 1] - 2 * v[i - 1], dp[1][i - 1] + 2 * v[i - 1]) - v[i];
    }
    cout << max(dp[0].back(), dp[1].back())<< '\n';
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>

int main(void) {
  int x, y, z;
  std::cin >> x >> y >> z;
  std::swap(x, y);
  std::swap(x, z);
  std::cout << x << " " << y << " " << z << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1 << 30
using namespace std;
 
int num, g;
 
int Search(vector<int> &p, vector<int> &c, int cmp, int sum, int score, int id) {
	if (id == num) {
		if (score >= g)
			return sum;
		for (int i = num - 1; i >= 0; i--) {
			if ((cmp & (1 << i)) == 0) {
				if ((p[i] - 1) * (i + 1) * 100 + score >= g) {
					sum += (g - score) / ((i + 1) * 100);
					if ((g - score) % ((i + 1) * 100) > 0)
						sum++;
					return sum;
				}
				break;
			}
		}
		return INF;
	}
	int ans = Search(p, c, cmp, sum, score, id + 1);
	cmp = cmp | (1 << id);
	score += p[id] * (id + 1) * 100 + c[id];
	ans = min(ans, Search(p, c, cmp, sum + p[id], score, id + 1));
	return ans;
}
 
int main(void) {
	int i = 0, cmp = 0;
	cin >> num >> g;
	vector<int> p(num), c(num);
	for (; i < num; i++)
		scanf("%d%d", &p[i], &c[i]);
	int ans = Search(p, c, cmp, 0, 0, 0);
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  string w;
  cin >> w;
  vector<char> vec(w.size());
  for(int i = 0;i < w.size();i ++){
    vec.at(i) = w[i];
  }
  
  if((w.size() + 2) % 2 != 0){
    cout << "No" << endl;
  }
  
  else {
    
    bool hantei = true;
    
    //count(vec.begin(),vec.end(),'a');
    vector<char> yousosu = vec;
    sort(yousosu.begin(),yousosu.end());
    yousosu.erase(unique(yousosu.begin(), yousosu.end()), yousosu.end());
    for(int i = 0;i < yousosu.size();i ++){
      if((count(vec.begin(),vec.end(),yousosu[i]) + 2) % 2 != 0){
        hantei = false;
      }
    }
      if(hantei)cout << "Yes" << endl;
      else cout << "No" << endl;
  }
    
}

Measured memory_bytes: 3600
class Dice():
    def __init__(self, a, b, c, d, e, f):
        """面の数字とindexを一致させるために0を挿入"""
        self.s = [0, a, b, c, d, e, f]

    def rotate(self, dir):
        if dir == "N":
            self.s[0] = self.s[1] #s[0]に一時的にs[1]を保持
            self.s[1] = self.s[2] 
            self.s[2] = self.s[6]
            self.s[6] = self.s[5]
            self.s[5] = self.s[0]
            return

        elif dir == "W":
            self.s[0] = self.s[1]
            self.s[1] = self.s[3] 
            self.s[3] = self.s[6]
            self.s[6] = self.s[4]
            self.s[4] = self.s[0]
            return

        elif dir == "S":
            self.s[0] = self.s[1]
            self.s[1] = self.s[5] 
            self.s[5] = self.s[6]
            self.s[6] = self.s[2]
            self.s[2] = self.s[0]
            return

        elif dir == "E":
            self.s[0] = self.s[1]
            self.s[1] = self.s[4] 
            self.s[4] = self.s[6]
            self.s[6] = self.s[3]
            self.s[3] = self.s[0]
            return
        
        elif dir == "R":
            self.s[0] = self.s[2]
            self.s[2] = self.s[3] 
            self.s[3] = self.s[5]
            self.s[5] = self.s[4]
            self.s[4] = self.s[0]
            return

        else:
            return


dice1 = Dice(*list(map(int, input().split())))
dice2 = Dice(*list(map(int, input().split())))
FLG = False

if set(dice1.s[1:]) != set(dice2.s[1:]):
    """片方にない数字がもう片方に含まれる場合"""
    pass 

elif dice1.s[1:] != dice2.s[1:]:
    for i in range(3):
        if dice1.s[1:] != dice2.s[1:]:
            for j in range(4):
                if dice1.s[1:] != dice2.s[1:]:
                    dice2.rotate("R")
                else:
                    FLG = True
                    break
            if FLG:
                break

            dice2.rotate("S")
            for j in range(4):
                if dice1.s[1:] != dice2.s[1:]:
                    dice2.rotate("R")
                else:
                    FLG = True
                    break
            if FLG:
                break
            dice2.rotate("E")
        else:
            FLG = True 
        if FLG:
            break
else:
    FLG = True

if FLG:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    cout << min(B, A * N) << endl;
}

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

int main(){
  int N;
  long long ans = 1;
  string str;
  int sums[26] = {0};
  cin >> N;
  cin >> str;
  for(int s=0; s<N; s++){
    sums[str[s] - 'a']++;
  }
  for(int a=0; a<26; a++){
    ans *= (sums[a]+1);
    ans %= (1000000007);
  }
  ans--;

  cout << ans;
  return 0;
}


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

int main()
{
	unsigned long n = 0;

	cin >> n;

	cout << n << ":";

	for (unsigned long i = 2; i <= sqrt(n); i++) {
		while (n % i == 0) {
			cout << " " << i;
			n /= i;
		}
	}

	if(n > 1)
		cout << " " << n;

	cout << endl;

	return 0;
}

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

#define pi 3.14159265358979323846
#define ll long long
#define N 200001


int main()
{
    ll n;
    cin>>n;
    ll ara[n-1];
    for(int i=0;i<n-1;i++)
        cin>>ara[i];
    ll x;
    ll p[N]={0};

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

        x=ara[i];
        p[x]++;
    }
    for(int i=1;i<=n;i++)
        cout<<p[i]<<endl;


}





Measured memory_bytes: 6748
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String input;
		Scanner sc=new Scanner(System.in);
		input=sc.next();
		String output=null;
		if(input.equals("A")) {
			output="T";
		}else if(input.equals("C")) {
			output="G";
		}else if(input.equals("G")) {
			output="C";
		}else if(input.equals("T")) {
			output="A";
		}
		System.out.println(output);
	}

}


Measured memory_bytes: 20948
from heapq import heapify, heappop, heappush

N, M = map(int, input().split())
A = [-1*int(i) for i in input().split()]
heapify(A)

for i in range(M):
    n = -1 * heappop(A)
    heappush(A, -1*(n//2))

print(-1*sum(A))

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

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

using namespace std;

vector<vector<int>> seg;

int query(int l,int r){
	int res=0;
	for(int a=l+seg.size()/2,b=r+seg.size()/2;a<b;a>>=1,b>>=1){
		if(a&1) res+=lower_bound(seg[a].begin(),seg[a].end(),l)-seg[a].begin(), a++;
		if(b&1) b--, res+=lower_bound(seg[b].begin(),seg[b].end(),l)-seg[b].begin();
	}
	return res;
}

int main(){
	int n,q; scanf("%d%d",&n,&q);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]), a[i]--;

	vector<int> pre(n,-1);
	rep(i,n){
		int x=a[i];
		a[i]=pre[x];
		pre[x]=i;
	}

	int N;
	for(N=1;N<n;N<<=1);
	seg.resize(2*N);
	rep(i,n) seg[N+i].emplace_back(a[i]);
	for(int i=N-1;i>0;i--){
		merge(seg[2*i  ].begin(),seg[2*i  ].end(),
			  seg[2*i+1].begin(),seg[2*i+1].end(),
			  back_inserter(seg[i]));
	}

	rep(_,q){
		int l,r; scanf("%d%d",&l,&r); l--;
		printf("%d\n",query(l,r));
	}

	return 0;
}


Measured memory_bytes: 95160