akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N;
  cin >> N;
  vector<P> A(N);
  REP(i,N) cin >> A[i].first >> A[i].second;
  vector<P> B(N);
  REP(i,N) cin >> B[i].first >> B[i].second;
  
  sort(ALL(A));
  sort(ALL(B));
  vector<bool> Ab(N,false);
  int ans = 0;
  REP(i,N){
    int MAXAY=-1;
    int MAXA=-1;
    REP(j,N){
      if(B[i].first<=A[j].first) break;
      if(Ab[j]!=false) continue;
      if(MAXAY<A[j].second&&A[j].second<B[i].second){
        MAXAY=A[j].second;
        MAXA=j;
      }
    }
    if(MAXA!=-1){
      ans++;
      Ab[MAXA]=true;
    }
  }

  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    ll A[400000];
    cin >> N;
    for (int i = 1; i < N; i++) {
        cin >> A[i];
    }
    vector<int> list(N);
    for (int i = 1; i < N; i++)
    {
        list[A[i] - 1]++;
    }
    for (auto s : list) {
        cout << s << endl;
    }
}

Measured memory_bytes: 5636
#include <stdio.h>

int main(void){
  int N;
  int max = 0;
  int ans = 1;
  scanf("%d",&N);

  for(int i = 1;i <= N;i++){
    int j = i;
    int counter = 0;
    while(j%2 == 0){
      j /= 2;
      counter++;
    }

    if(max < counter){
      max = counter;
      ans = i;
    }
  }

  printf("%d",ans);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
//#pragma comment(linker, "/stack:200000000")

using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
//#define ipq priority_queue<ll, vector<ll>, greater<ll> >
//#define dpq priority_queue<ll>
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
//#define PQ(type) priority_queue<type>
//#define PQD(type) priority_queue<type,vector<type>,greater<type> >
//#define umap unordered_map<ll,ll> 
//#define vpair vector<pair<ll,ll>>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
ll mod=1e9+7;

int main(){
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a[200005],b[200005],i,j,k;
    cin>>n;
    for(i=0;i<=n;i++){
        cin>>a[i];
        
    }
    for(i=0;i<n;i++){
        cin>>b[i];
    }
    long long sum=0;
    for(i=0;i<n;i++){
        int x=min(b[i],a[i]);
        sum+=x;
        b[i]-=x;
        a[i]-=x;
        x=min(a[i+1],b[i]);
        sum+=x;
        b[i]-=x;
        a[i+1]-=x;
    }
    cout<<sum;
}
    
    
    


Measured memory_bytes: 1024
#include <iostream>
#include "string.h"
using namespace std;
int main(){
string s;
cin>>s;
if((int)s[18]==19);
for(int i=0;i<5;i++){
cout<<s[i];
}
cout<<" ";
for(int i=6;i<13;i++){
cout<<s[i];
}
cout<<" ";
for(int i=14;i<19;i++){
cout<<s[i];
}
cout<<"\n";
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    int abc = d.at(n / 2 - 1), arc = d.at(n / 2);
    cout << arc - abc << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);

int main(){ 
  int n;
  cin >> n;
  vector<P> p;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    p.emplace_back(make_pair(b, a));
  }

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

  bool ok = true;

  ll cnt = 0;

  for (int i = 0; i < n; i++) {
    cnt += p[i].second;
    ok &= (cnt <= p[i].first);
  }

  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
} 

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#define IF_DEBUG 0
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 100050;

int Bit[32], n, K, top, G;
int A[maxn], W[maxn], Cur;
ll Ans;

int main()
{
	sf("%d%d",&n,&K); G = K;
	while(K){Bit[++top]=K&1;K>>=1;}
	fo(i,1,n) sf("%d%d",&A[i],&W[i]);
	ll res = 0;
	Cur = G;
		fo(i,1,n)
			if((Cur | A[i]) == Cur) 
				res += W[i];
	if(res > Ans) Ans = res;
	fd(i,top+1,1) if(Bit[i])
	{
		res = 0;
		Cur = G - (1<<(i-1));
		Cur = Cur | ((1<<(i-1))-1);
		fo(i,1,n)
			if((Cur | A[i]) == Cur) 
				res += W[i];
		if(res > Ans) Ans = res;
	}
	pf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 1024
import sys
 
f_i = sys.stdin
 
n, q = map(int, f_i.readline().split())

class DisjointSets:
    def __init__(self, size):
        # negative values are roots(representatives of each tree)
        # positive values represent the parent element
        self.table = [-1 for _ in range(size)]

    def _find(self, x):
        while self.table[x] >= 0:
            x = self.table[x]
        return x

    def union(self, x, y):
        s1 = self._find(x)
        s2 = self._find(y)
        if s1 != s2:
            if self.table[s1] < self.table[s2]: # the smaller has more elements
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2

    def isSameSet(self, x, y):
        if self._find(x) == self._find(y):
            print(1)
        else:
            print(0)

S = DisjointSets(n)

for l in f_i:
    com, x, y = map(int, l.split())
    if com == 0:
        S.union(x, y)
    else:
        S.isSameSet(x, y)

Measured memory_bytes: 8640
#include <bits/stdc++.h>
    using namespace std;
     
    int a, b, c;
     
    int main(){
    cin >> a >> b >> c;
    if (a == b) {
    cout << c << endl;
    } else if (b == c) {
    cout << a << endl;
    } else {
    cout << b << endl;
    }
    }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, t = 0, x = 0, y = 0;
		boolean f=false;
		n = sc.nextInt();
		for (int i = 0, tt, tx, ty; i < n; i++) {
			tt = sc.nextInt();
			tx = sc.nextInt();
			ty = sc.nextInt();
			if ((Math.abs(tx - x) + Math.abs(ty - y)) % 2 != (tt - t) % 2// 判断奇偶性是否一样
					|| Math.abs(tx - x) + Math.abs(ty - y) > (tt - t)) {// 是否大于最短步数
				
				f=true;
			}
				t = tt;
				x = tx;
				y = ty;
			
		}
		if(f){
			System.out.println("No");
		}else
			System.out.println("Yes");

	}

}


Measured memory_bytes: 87368
#include <iostream>
#include <cmath>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

int main(){
  int a, b;
  cin >> a >> b;
  int _tmp = a * pow(10, to_string(b).length()) + b;
  for(int i=0; i*i<=_tmp; i++){
    if(i*i == _tmp){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;

int vis[101][101];
int main()
{
    string s[101];
    int n , m , i , j , k ;

    cin >> n >> m ;

    for(i=0; i<n; i++)
        cin >> s[i];

    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {


                int l = 0 , r = 0 ;
                for(k=0; k<n; k++)
                    if(s[k][j]=='#')
                        l = 1 ;
                for(k=0; k<m; k++)
                    if(s[i][k]=='#')
                        r = 1 ;
                if(l and r)
                    vis[i][j] = 1 ;

        }
    }

    for(i=0; i<n; i++)
    {
        int f = 0 ;
        for(j=0; j<m; j++)
        {
            if(vis[i][j])
                cout << s[i][j],f=1;
        }
        if(f)cout << '\n';
    }
}


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

// sからn-3桁を消した残りの3桁をaに一致させることができるか
void solve(int a,int n,string s,set<int> &cnt){
  if (cnt.count(a)) return;
  vector<int> digitsub(3);
  digitsub.at(0) = a / 100; //百の位
  digitsub.at(1) = a/10%10; //十の位
  digitsub.at(2) = a % 10;  //一の位
  string digit = to_string(digitsub.at(0))+
    to_string(digitsub.at(1))+to_string(digitsub.at(2));
  int okdigit = 0;
  for (int i=0; i<n; i++){
    if (s.at(i) == digit.at(okdigit)){
      okdigit++;
      if (okdigit == 3) break;
    }
  }
  if (okdigit == 3) cnt.insert(a);
  return;
}

int main() {
  int n; cin >>n;
  string s; cin >>s;
  set<int> cnt;
  for (int i=0; i<1000; i++){
    solve(i,n,s,cnt);
  }
  int ans = cnt.size();
  cout <<ans <<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<char>a[n+1];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            char c;
            cin>>c;
            a[i].push_back(c);
        }
    }
   /* for(int i=0;i<n;i++)
    {
        for(auto itr : a[i])
        cout<<itr<<" ";
        cout<<'\n';
    }*/
    int dp[n][m];
    memset(dp,0,sizeof dp);
    if(a[0][0]=='#')
    dp[0][0]=1;
    for(int i=1;i<n;i++)
    {
        if(a[i][0]=='.')
        dp[i][0]=dp[i-1][0];
        else
        {
            if(a[i-1][0]=='.')
            dp[i][0]=dp[i-1][0]+1;
            else
            dp[i][0]=dp[i-1][0];
        }
    }
    for(int i=1;i<m;i++)
    {
        if(a[0][i]=='.')
        dp[0][i]=dp[0][i-1];
        else
        {
            if(a[0][i-1]=='.')
            dp[0][i]=dp[0][i-1]+1;
            else
            dp[0][i]=dp[0][i-1];
        }
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(a[i][j]=='.')
            dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
            else
            {
                int a1=dp[i-1][j];
                int a2=dp[i][j-1];
                if(a[i-1][j]=='.')
                a1++;
                if(a[i][j-1]=='.')
                a2++;
                dp[i][j]=min(a1,a2);
            }
        }
    }
   /* for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        cout<<dp[i][j]<<" ";
        cout<<'\n';
    }*/
    cout<<dp[n-1][m-1]<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int tax_before, tax_after;
	int price_before, price_after;
	int cost_A, cost_B;
	int max_price;
	int i;

	while(1){
		scanf("%d %d %d", &tax_before, &tax_after, &price_before);
		if(tax_before==0&&tax_after==0&&price_before==0) break;

		i = 1;
		max_price = 0;
		while(1){
			cost_A = i*(100+tax_before)/100;
			if(cost_A*2>price_before) break;
			cost_B = (price_before-cost_A)*100/(100+tax_before);
			while((cost_B+1)*(100+tax_before)/100<=price_before-cost_A) cost_B++;
			if(cost_A+cost_B*(100+tax_before)/100!=price_before){
				i++;
				continue;
			}
			cost_A = i*(100+tax_after)/100;
			cost_B = cost_B*(100+tax_after)/100;
			price_after = cost_A + cost_B;
			if(max_price < price_after) max_price = price_after;
			i++;
		}

		printf("%d\n", max_price);
	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s[0]>='A'&&s[0]<='Z')
    cout<<"A"<<endl;
  else if(s[0]>='a' &&s[0]<='z' )
    cout<<"a"<<endl;
  return 0;
  
}

Measured memory_bytes: 3592
#include <iostream>
#include <map>
#include <string>
using namespace std;
using ll = unsigned long long int;

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll a_c = (a-1) / c;
  ll a_d = (a-1) / d;
  ll a_cd = (a-1) / lcm(c, d);

  ll b_c = b / c;
  ll b_d = b / d;
  ll b_cd = b / lcm(c, d);

  cout << ((b - a + 1) - ((b_c + b_d - b_cd) - (a_c + a_d - a_cd))) << endl;;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  int count=700;
  for(int i=0;i<S.size();i++){
  if(S.at(i)=='o'){
  count+=100;
  
  }
    if(S.at(i)=='x'){
    count+=0;
    }
  
  }
cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

//最大公約数
ll gcd(ll a, ll b) {
	if(a*b == 0)return max(a, b);
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	if (a%b == 0)return b;
	return gcd(b, a%b);
}

//最小公倍数
//gcd関数を使用
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main(){

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ccd, dcd, bcd, cd = lcm(c, d);
	ccd = b/c - (a-1)/c;
	dcd = b/d - (a-1)/d;
	bcd = b/cd - (a-1)/cd;
	ll ans = b-a+1 - ccd -dcd + bcd;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
int main(){
		int N,X,T;
		cin>>N;
		cin>>X;
		cin>>T;
		if(N%X==0){
			cout<<(T*N/X);
		}
		else{
			cout<<((T)*(N/X+1));
		}
}


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

using namespace std;

int main()
{
    long long int X, Y, A;
    cin >> X >> Y;
    A = X;
    long long int count = 0;

    while (A < Y)
    {
        A *= 2;
        count++;
    }

    if (A == Y)
        count++;

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    char[] expected = sc.next().toCharArray();
    char[] actual = sc.next().toCharArray();
    int cnt = 0;
    
    for (int i = 0; i < 3; i++) {
      cnt = (expected[i] == actual[i]) ? cnt + 1 : cnt;
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 22732
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int A, B; cin >> A >> B;
  int cnt = 0;
  for (int i = A; i <= B; ++i) {
    string s = to_string(i);
    int n = s.size();
    bool ok = true;
    for (int i = 0; i < n/2; ++i) {
      if (s[i] != s[n-i-1]) {
        ok = false;
        break;
      }
    }
    if (ok) ++cnt;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3668
A = set([1, 3, 5, 7, 8, 10, 12])
B = set({4, 6, 9, 11})
C = set({2})
D = set(map(int, raw_input().split()))
if A.issuperset(D) or B.issuperset(D) or C.issuperset(D):
    print "Yes"
else:
    print "No"

Measured memory_bytes: 2568
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

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

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func modInv(a, mod int) int {
	b := mod
	u, v := 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		u -= t * v
		a, b = b, a
		u, v = v, u
	}
	u %= mod
	if u < 0 {
		u += mod
	}
	return u
}

type Bigger []int

func (a Bigger) Len() int      { return len(a) }
func (a Bigger) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a Bigger) Less(i, j int) bool {
	return abs(a[i]) > abs(a[j])
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	const mod = 1000000007

	n, k := nextInt(), nextInt()
	a := Bigger(nextInts(n))
	sort.Sort(a)

	ans := 1
	minus := 0
	for i := range a {
		if a[i] < 0 {
			minus++
		}
	}
	if (minus == n && k%2 == 1) || n == k {
		// 小さいものをかけていく
		for i := n - k; i < n; i++ {
			ans *= (a[i] + mod) % mod
			ans %= mod
		}
		puts(ans)
		return
	}

	ans = 1
	minus = 0
	for i := 0; i < k; i++ {
		if a[i] < 0 {
			minus++
		}
		ans *= (a[i] + mod) % mod
		ans %= mod
	}
	if minus%2 == 0 {
		puts(ans)
		return
	}

	// 取り除く候補
	// 0: 非負，1: 負
	rem := [2]int{}
	exist1 := [2]bool{}
	for i := k - 1; i >= 0; i-- {
		if exist1[0] && exist1[1] {
			break
		}
		if a[i] > 0 && !exist1[0] {
			rem[0] = a[i]
			exist1[0] = true
		} else if a[i] < 0 && !exist1[1] {
			rem[1] = a[i]
			exist1[1] = true
		}
	}
	// 追加する候補
	add := [2]int{}
	exist2 := [2]bool{}
	for i := k; i < n; i++ {
		if exist2[0] && exist2[1] {
			break
		}
		if a[i] > 0 && !exist2[0] {
			add[0] = a[i]
			exist2[0] = true
		} else if a[i] < 0 && !exist2[1] {
			add[1] = a[i]
			exist2[1] = true
		}
	}
	if exist1[0] && exist2[1] && exist1[1] && exist2[0] {
		if abs(add[1]*rem[1]) > abs(add[0]*rem[0]) {
			rem[0], add[1] = (rem[0]+mod)%mod, (add[1]+mod)%mod
			ans = (ans * modInv(rem[0], mod)) % mod
			ans = (ans * add[1]) % mod
		} else {
			rem[1], add[0] = (rem[1]+mod)%mod, (add[0]+mod)%mod
			ans = (ans * modInv(rem[1], mod)) % mod
			ans = (ans * add[0]) % mod
		}
	} else if exist1[0] && exist2[1] {
		rem[0], add[1] = (rem[0]+mod)%mod, (add[1]+mod)%mod
		// 非負の数を取り除き，負の数を加える
		ans = (ans * modInv(rem[0], mod)) % mod
		ans = (ans * add[1]) % mod
	} else if exist1[1] && exist2[0] {
		rem[1], add[0] = (rem[1]+mod)%mod, (add[0]+mod)%mod
		// 負の数を取り除き，非負の数を加える
		ans = (ans * modInv(rem[1], mod)) % mod
		ans = (ans * add[0]) % mod
	} else {
		ans = 0
	}

	puts(ans)
}


Measured memory_bytes: 6016
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
using namespace std;
long long inf=100000000000007;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int to,cost;};
vector<edge> G[22];
vector<int> O[10];
char fi[1005][1005];
P sg[10];
int d[1005][1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
pair<int,double> s[1005];
int c=0;
int n,k;

signed main(){
    int  n;cin>>n;
    int a[100];
    a[0]=2;a[1]=1;
    for(int i=2;i<=n;i++){
        a[i]=a[i-1]+a[i-2];
    }
    cout<<a[n]<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = Integer.parseInt(sc.next());
        if (i % 2 == 0) {
            System.out.println((i / 2) * (i / 2));
        } else {
            System.out.println((i / 2) * (i / 2 + 1));
        }
    }
}

Measured memory_bytes: 21588
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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;}

const ll mod=1e9+7;

int main(){
    vector<vector<ll>> c(3,vector<ll>(3));
    rep(i,3){
        rep(j,3){
            cin >> c[i][j];
        }
    }
    bool ans=true;
    rep(i,2){
        bool ok=true;
        ll v=0;
        rep(j,3){
            if(j==0){
                v=c[i+1][j]-c[i][j];
            }
            else{
                if(c[i+1][j]-c[i][j]!=v){
                    ok=false;
                }
            }
        }
        if(!ok){
            ans=false;
        }
    }
    rep(i,2){
        bool ok=true;
        ll v=0;
        rep(j,3){
            if(j==0){
                v=c[j][i+1]-c[j][i];
            }
            else{
                if(c[j][i+1]-c[j][i]!=v){
                    ok=false;
                }
            }
        }
        if(!ok){
            ans=false;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
} 

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int ans = 0;
    map<string, int> blue;
    rep(i, N){
        string S; cin >> S;
        blue[S]++;
    }
    vector<string> red;
    int M; cin >> M;
    rep(i, M){
        string S; cin >> S;
        red.push_back(S);
    }
    for(auto op: blue){
        string S = op.first;
        int num = op.second;
        int r = 0;
        rep(i, M) if(S == red[i]) r++;
        ans = max(ans, num-r);
    }
    cout << ans << endl;
    return 0;
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long x, y; scan(x, y);
      puts((x%3==0 or y%3==0 or (x+y)%3==0)? "Possible" : "Impossible");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int S,h,m,s;
	
	scanf ("%d",&S);
	
	h = S / 3600;
	
	m = (S - (h * 3600)) / 60;
	
	s = S - (h * 3600) - (m * 60);
	
	printf ("%d:%d:%d\n",h,m,s);
	
	return 0;
	
}


Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std ;
 
 
 
 
int main(){
	int  a  ,  b , n  ;
	cin >> n ;
	for( int i = 1 ; i < 10 ; i++ ){
		if( n % i == 0 && n/i <= 9 ){
			puts("Yes");
			return 0 ;
		}
	}
	puts("No");
 
 
 
	return 0 ;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
n,k,q=map(int,input().split())
pt=[0 for _ in range(n)]
for _ in range(q):
    a = int(input())
    pt[a-1] += 1
base=q-k
for p in pt:
    print("No" if p <= base else "Yes")

Measured memory_bytes: 4684
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
int dfs(vector<int>&f,int st,int par,vector<vector<int>>&adj){
    for(auto j:adj[st]){
        if(j!=par){
            f[st]++;
            f[st]+=dfs(f,j,st,adj);
        }
    }
    return f[st];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x;
    cin>>x;
    cout<<1-x<<endl;
}
 

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
bool ok = true;
int ans = 0;
while(ok){
    rep(i,n){
        if(a[i]%2==0){
            a[i] = a[i] / 2;
        }
        else{
            ok = false;
        }
    }
    if(ok)ans++;
}
cout << ans << endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1e18
using namespace std;
typedef long long int ll;

int main(){
  string s; cin >> s;
  map<char, int> mp;
  rep(i, 0, s.length()){
    mp[s[i]]++;
    if(mp[s[i]]>=2){
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
cs = n.times.map{gets.chomp.split.map(&:to_i)}
sum = 0
[*0..n-1].permutation.each do |a|
  a.each_cons(2) do |u,v|
    i,j = cs[u]
    x,y = cs[v]
    sum += Math.sqrt((x - i)**2 + (y - j)**2)
  end
end
puts sum / (1..n).inject(:*)

Measured memory_bytes: 1916
n = int(input())
h = list(map(int, input().split()))

c = 0
a = 0   
for i in range(n-1):
  if h[i] >= h[i+1]:
    c += 1
  else:
    a = max(c, a)
    c = 0
    
a = max(c, a)    
print(a)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
	cin >> a[i];
    }
    vector<int> arr;
    sort(ALL(a));
    int s = min(100,n);
    REP(i,s)REP(j,s){
	if(i == j) continue;
	arr.PB( stoi( to_string(a[i]) + to_string(a[j])));
    }
    sort(ALL(arr));
    cout << arr[2] << endl;
    return 0;
}

Measured memory_bytes: 3372
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] inputs = br.readLine().split(" ");
            double hour = Double.parseDouble(inputs[0]);
            double minutes = Double.parseDouble(inputs[1]);
            double hour_jiaodu = Math.toRadians(Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60);
            double minute_jiaodu = Math.toRadians(Double.parseDouble(inputs[3])/60*360);
            double chajiao;
            double result;
            if(hour_jiaodu>minute_jiaodu){
                if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                }
            }
            else {
                if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                }
            }
            System.out.print(result);
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 33304
//If You think you are Bad...I'm your Dad 
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int a,b;
		cin >>a >>b;
		cout<<a*b;

	
	
	}
	return 0;
}

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

int main() {
  
  
  string SA, SB, SC;
  cin >> SA >> SB >> SC;
  
  int ind_A = 1, ind_B = 0, ind_C = 0;
  
  char cur = SA[0];
  
  while(true) {
    
    
    // 文字を見る
    if (cur == 'a') {
      
      
      // 終了条件のチェック
      if (ind_A == SA.size()) {
        cout << "A" << endl;
        return 0;
      } else { // 終了しない場合の cur の更新
        cur = SA[ind_A];
        ind_A++;
      }
    } else if (cur ==  'b') {
    
      // Bのカードを見る
      
      // 終了条件のチェック
      if (ind_B == SB.size()) {
        cout << "B" << endl;
        return 0;
      } else { // 終了しない場合の cur の更新
        cur = SB[ind_B];
        ind_B++;
      }
    } else {
      
      // 終了条件のチェック
      if (ind_C == SC.size()) {
        cout << "C" << endl;
        return 0;
      } else { // 終了しない場合の cur の更新
        cur = SC[ind_C];
        ind_C++;
      }
    }
  }
  
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    string S;
    cin >> S;
    map<char, int>d;
    int s_size = S.size();
    for (int i=0; i<s_size; i++) {
        d[S[i]] = 1;
    }

    char s = S[s_size-1];
    if (S == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
    } else if (s_size < 26) {
        char new_moji = '-';
        for (char moji='a'; moji<='z'; moji++) {
            if (d.count(moji) == 0) {
                new_moji = moji;
                break;
            }
        }

        cout << S << new_moji << endl;
    } else {
        int i=25;
        char ikemoji = '-';
        while (i >= 0) {
            for ( char moji=++S[i]; moji<='z'; moji++) {
                bool ikeru = true;
                for (int j=0; j<i; j++) {
                    if (moji == S[j]) {
                        ikeru = false;
                    }
                }

                if (ikeru) {
                    ikemoji = moji;
                    break;
                }
            }

            if (ikemoji != '-') {
                break;
            }

            i--;
        }

        cout << S.substr(0, i) << ikemoji << endl;
    }
    return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>k;

	f(i,0,n-1) cin>>ara[i];

	sort(ara,ara+n,greater<>());

	f(i,0,k-1) count+=ara[i];

	cout<<count<<endl;

}


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

void main_()
{
    ll H, N;
    cin >> H >> N;
    vector<pair<ll, ll>> magic;
    for (ll i = 0; i < N; i++) {
        ll A, B;
        cin >> A >> B;
        magic.emplace_back(A, B);
    }

    vector<ll> dp(H + 1, 1e9);

    dp[0] = 0;

    for (ll i = 0; i < H; ++i) {
        for (auto&& m : magic) {
            ll dam = min(m.first + i, H);
            dp[dam] = min(dp[dam], dp[i] + m.second);
        }
    }

    cout << dp[H] << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 384
import heapq
 
n,m = map(int,input().split())
ab=[[] for _ in range(m)]
for i in range(n):
    a,b=map(int,input().split())
    if a < m+1:
        ab[a-1].append(-b)
 
h=[]
ans=0
for i in range(m):
    for j in ab[i]:
        heapq.heappush(h,j)
    if len(h)==0:
        continue
    ans+=heapq.heappop(h)*(-1)
print(ans)

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

/*
..#.#..
..#.#..
###.###
...@...
###.###
..#.#..
..#.#..
 */

using namespace std;

int W,H;
char c[100][101]; // c[H][W]

bool visited[100][100]; // <----

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

void compute() {

  memset(visited,false,sizeof visited); //memset(???????????????????????????1bit???????????????????????????) ?????????1bit????????§?????????

  queue<int> que;
  int i,j;
  for(i=0;i<H;++i) {
    for(j=0;j<W;++j) {
      if( c[i][j] == '@' ) {
	que.push(j+i*W);
	visited[i][j] = true;
	//break;
	goto Skip;
      }
    }
  }
 Skip:;

  int answer = 1; // <---???????????????
  while( !que.empty() ) { // !0 => 1  !1 => 0
    int cur = que.front(); que.pop(); // que -> [1,2,3,4], front -> 1, pop -> [2,3,4]
    int x = cur % W, y = cur / W; //???????????§?¨?
    
    for(i=0;i<4;++i) {
      int nx = x + dx[i], ny = y + dy[i]; //?¬??????§?¨?????¨?????????§?¨?

      if( !( 0 <= nx && nx < W && 0 <= ny && ny < H ) ) continue; // 0 && 0 => 0, 1 && 0 => 0, 0 && 1 => 0, 1 && 1 => 1
      if( c[ny][nx] == '#' || visited[ny][nx] ) continue;         // 0 || 0 => 0, 1 || 0 => 1, 0 || 1 => 1, 1 || 1 => 1
      
      que.push(nx+ny*W);
      visited[ny][nx] = true;
      ++answer;// <---???????????????

    }
    
  }

  cout << answer << endl;// <---???????????????

}

int main() {
  while( scanf("%d %d",&W,&H), W | H ) {
    //while( scanf("%d %d",&W,&H), W == 0 && H == 0 ) {
    int i;
    for(i=0;i<H;++i) {
      scanf(" %s",&c[i][0]);  // c[y][x]
    }
    compute();
  }
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
struct Point{double x,y;};

int main(void){
    int N;
    bool NA = false;
    cin>>N;
    vector<Point> p(N);
    rep(i,N)cin>>p[i].x>>p[i].y;
    NA = N&1;
    Point G = {(p[0].x+p[N/2].x)/2.0 , (p[0].y+p[N/2].y)/2.0};
    rep1(i,N/2-1) NA |= ((p[i].x+p[i+N/2].x)/2.0!=G.x || (p[i].y+p[i+N/2].y)/2.0!=G.y);
    if(NA)cout<<"NA"<<endl;
    else printf("%.5f %.5f\n",G.x,G.y);

    return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int n,x,y,z;
int dp[64][262144];
int main(){
	cin >> n >> x >> y >> z;
	const int fullmask = 1 << x+y+z+1;
	dp[0][1] = 1;
	for( int i = 0 ; i < n ; ++i )
		for( int mask = 0 ; mask < fullmask ; ++mask )
			for( int u = 1 ; u <= 10 ; ++u ){
				int vmask = (mask << u | 1) & fullmask-1;
				if( (vmask>>z&1) and (vmask>>y+z&1) and (vmask>>x+y+z&1) ) continue;
				dp[i+1][vmask] = (dp[i+1][vmask]+dp[i][mask]) % MOD;
			}
	int all = 1; for( int i = 0 ; i < n ; ++i ) all = all*10LL % MOD;
	cout << (all-accumulate(dp[n],dp[n]+fullmask,0,[]( int x , int y ){ return (x+y)%MOD; })+MOD)%MOD << endl;
	return 0;
}


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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  int n;
  vector<int> a;
  
  long long dfs(int now, long long sum)
  {
    if(now == n) {
      return 0;
    }
    long long score = sum + a[now];
    long long res = 0;
    if(!now && !score) {
      res = min(dfs(now + 1, score + 1), dfs(now + 1, score - 1)) + 1;
    } else if (!now) {
      res = dfs(now + 1, score);
      if(score < 0) {
        res = min(res, 1 - score + dfs(now + 1, 1));
      } else {
        res = min(res, 1 + score + dfs(now + 1, -1));
      }
    } else {
      if(sum < 0) {
        if(score > 0) {
          res = dfs(now + 1, score);
        } else {
          res = 1 - score + dfs(now + 1, 1);
        }
      } else {
        if (score < 0) {
            res = dfs(now + 1, score);
        } else {
            res = score + 1 + dfs(now + 1, -1);
        }
      }
    }
    return res;
  }

  void solve(std::istream& in, std::ostream& out)
  {
    in >> n;
    a.resize(n);
    for (auto&& i : a) {
      in >> i;
    }
    out << dfs(0, 0) << "\n";
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}




Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cctype>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#define maxn 307
#define maxx 20007
#define SDOI2020 RP++ 
using namespace std;
int n,m;
string a,b,flag;
inline int read()
{
	int x=0;
	int flag=0;
	char ch;
	ch=getchar();
	while(!isdigit(ch)) 
	{
		if(ch=='-') flag=1;
	ch=getchar();	
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-48;
		ch=getchar();
		}
		if(flag==1) x=-x;	
		return x;
}


int main()
{
	cin>>a>>b;
	cin>>n>>m;
	cin>>flag;
	if(a == flag) n--;
	else m--;
	cout<<n<<" "<<m<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>

using namespace std;

int N,L;
char S[101][101];
string K[101];
void mysort(char strs[101][101])
{
int i, j;
char s[100];
for(i = 0; i < N; i++) {
for(j = i + 1; j < N; j++) {
if (strcmp(strs[i], strs[j]) > 0) {
strcpy(s, strs[i]);
strcpy(strs[i], strs[j]);
strcpy(strs[j], s);
}
}
}
}

int main(){
	vector<char*> data;
	scanf("%d %d",&N,&L);
	for(int i=0;i<N;i++){
		scanf("%s",S[i]);
	}
	mysort(S);
	K[0]=S[0];
	for(int i=1;i<N;i++){
		K[i]=S[i];
		K[0]+=K[i];
	}
	printf("%s\n",K[0].c_str());
return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i = 0; i<N; i++)
    cin >> h.at(i);
  
  vector<int> dp(N);
  dp.at(0) = 0;
  dp.at(1) = abs(h.at(1) - h.at(0));
  for(int i=2; i<N; i++){
      dp.at(i) = min((dp.at(i-1), dp.at(i-1)+abs(h.at(i)-h.at(i-1))), dp.at(i-2)+abs(h.at(i-2)-h.at(i)));
  }
  
  cout << dp.at(N-1) << endl;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n, k;
	string s;
	cin >> n >> k >> s;

	int res = 0;
	int x = 0;
	int y = 0;
	char now = s[0];
	for (int i = 1; i < n; i++) {
		if (s[i] == now) {
			res++;
		} else {
			if (now == 'R' && s[i] == 'L')
				x++;
			now = s[i];
		}
	}

	if (s[0] == 'R' && s[n - 1] == 'L') {
		x = max(x - 1, 0);
		y++;
	} else if (s[0] == 'L' && s[n - 1] == 'R') {
		y++;
	}

	res += min(x, k) * 2;
	if (k - x > 0)
		res += y;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
//#include <function>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  ll A, B;
  cin >> A >> B;
  ll tmp = 0;

  if ((A == B) || (B < 8)){
    for(ll i = A; i <= B; i++) tmp = ll(tmp ^ i);
    cout << tmp << endl;
    return 0;
  }



  tmp = 0;
  REP(i, 4){
    if ((A + i) % 4 == 0){
      break;
    }else{
      tmp = ll(tmp ^ (A + i));
    }
  }

  REP(i, 4){
    if ((B - i) % 4 == 3){
      break;
    } else{
      tmp = ll(tmp ^ (B - i));
    }
  }

  cout << tmp << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  str s;
  cin >> s;
  int cnt_0 = 0, cnt_1 = 0;
  REP(i,s.length()){
    if(s[i]=='0') cnt_0++; else cnt_1++;
  }
  cout << min(cnt_0,cnt_1)*2 << endl;
  return 0;
}


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

int main(void){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int l = 0;
    ll seg = 0;
    ll res = 0;
    rep(r,n){
        if(seg+a[r] == (seg^a[r])){
        }else{
            while(l<r){
                seg -= a[l];
                l++;
                if(seg+a[r] == (seg^a[r]))break;
            }
        }
        seg += a[r];
        res += r-l+1;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
     
    int main (){
    	int n,k;
      	vector <long long> m;
      	int x;
      	long long sum = 0;
      	cin >> n >> k;

        if (k >= n){
            cout << 0 << endl;
            return 0;
        }
      	for (int i = 0;i< n;i++){
        	cin >> x;
          	m.push_back(x);
        }
        
      	sort(m.begin(), m.end());

      	for (int i = 0;i< k;i++){
        	m.pop_back();
        }
      	for (int i = 0;i< m.size();i++){
        	sum += m[i];
        }
      	cout << sum << endl;
    }

Measured memory_bytes: 2420
#include <stdio.h>

int main(void){
	int h,w,i,j,k,save=0,ari=0;
	scanf("%d %d",&h,&w);
	char a[h][w+1];
	int ans[h][w];
	for(i=0;i<h;i++){
		scanf("%s",a[i]);
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			ans[i][j]=-1;
		}
	}
//
	
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(a[i][j]=='c'){
				ans[i][j]=0;
				save=0;
				ari=1;
			}
			else{
				if(ari==1){
					ans[i][j]=++save;
				}
			}
		}
		save=0;
		ari=0;
	}
	
	for(i=0;i<h;i++){
		for(j=0;j<w-1;j++){
			printf("%d ",ans[i][j]);
		}
		printf("%d\n",ans[i][w-1]);
	}
	return 0;
}	

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  string s;
  cin >> s;

  if (s == "Sunny") cout << "Cloudy" << endl;
  else if (s == "Cloudy") cout << "Rainy" << endl;
  else if (s == "Rainy") cout << "Sunny" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef long long int LLI;

int main()
{
	int n;
	cin >> n;
	
	LLI arr[2][n];
	cin >> arr[0][0];
	
	LLI top = arr[0][0], bottom = 0, max = 0;
	for(int i = 1; i < n; i++)
		cin >> arr[0][i];
	
	for(int i = 0; i < n; i++)
	{
		cin >> arr[1][i];
		bottom += arr[1][i];
	}

	if( bottom + top > max )
		max = bottom + top;
		
	for(int i = 1; i < n; i++)
	{
		top += arr[0][i];
		bottom -= arr[1][i-1];
		if( bottom + top > max )
			max = bottom + top;
	}
	cout << max;
}

Measured memory_bytes: 3588
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,b,n = na()

x = n if b > n else (n//b)*b-1

ans = (a*x)//b - a*(x//b)

print(ans)

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

void Main() {
    // input
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    // translate
    long double angleA = 2 * M_PI / 720 * (60 * H + M);
    long double angleB = 2 * M_PI / 60 * M;
    long double angleAB = angleA - angleB;
    if (angleAB < 0) {
        angleAB *= -1;
    }
    angleAB = min(angleAB, 2 * M_PI - angleAB);

    cout << sqrt(A * A + B * B - 2 * A * B * cos(angleAB)) << endl; 


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4112
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n = ii()
s = input()
left = s[1:].count('W')

dp = [[0,left]]
ans = n-1-left
last = s[0]
for i in s[1:]:
    ri,le = dp[-1]
    if i == 'W':
        le -= 1
    if last == 'E':
        ri += 1
    dp.append([ri,le])
    last = i
    ans = min(ans,n-1-ri-le)
print(ans)

Measured memory_bytes: 45428