akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll w[102];
 ll a[102];
 ll r[103][100005];
 ll n,k;
 ll res()
 {
     ll i,j;

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

         {
             if(i==0||j==0)
                r[i][j]=0;

         else if(w[i]<=j)
         r[i][j]=max(r[i-1][j-w[i]]+a[i],r[i-1][j]);
         else
            r[i][j]=r[i-1][j];
         }
     }
     return r[n][k];
 }
int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll t,i,j,x,y,c=0,m;
     cin>>n>>k;
     memset(r,0,sizeof(r));
     for(i=1;i<=n;i++)
     {
         cin>>w[i]>>a[i];

     }
     ll mi=res();
     cout<<mi<<"\n";

}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> result(n);
    for(int i = 0; i < n - 1; i++){
        cin >> a[i];
        result[a[i] - 1]++;
    }
    for(int i = 0; i < n; i++){
        cout << result[i] << endl;
    }
}

Measured memory_bytes: 4852
#include <iostream>

using namespace std;

#define N 25
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
int n,a,l[N],r[N],par[N],sib[N],deg[N],dep[N],height[N],z[N];
bool used[N];

int dfs(int x,int d){
  dep[x] = d;
  if(l[x] == -1 && r[x] == -1)return 1;
  if(z[x] != 2)z[x] = 1;
  if(l[x] != -1)height[x]=max(height[x],dfs(l[x],d+1));
  if(r[x] != -1)height[x]=max(height[x],dfs(r[x],d+1));
  return height[x]+1;
}


int main(void){
  cin>>n;
  rep(i,n){
    cin>>a;
    cin>>l[a]>>r[a];
    if(l[a]!=-1)deg[a]++,used[l[a]]=true,par[l[a]]=a,sib[l[a]]=r[a];
    if(r[a]!=-1)deg[a]++,used[r[a]]=true,par[r[a]]=a,sib[r[a]]=l[a];
  }
  rep(i,n){
    if(!used[i])par[i]=-1,sib[i]=-1,z[i]=2,dfs(i,0);
  }

  rep(i,n){
    cout<<"node "<<i<<": parent = "<<par[i]<<", sibling = "<<sib[i];
    cout<<", degree = "<<deg[i]<<", depth = "<<dep[i]<<", height = "<<height[i];
    if(!z[i])cout<<", leaf"<<endl;
    if(z[i]==1)cout<<", internal node"<<endl;
    if(z[i]==2)cout<<", root"<<endl;
  }
  
}

Measured memory_bytes: 3068
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int n = Integer.parseInt(sc.nextLine());
            List<Integer> ns = Stream.of(sc.nextLine().split(" "))
                    .map(Integer::parseInt)
                    .collect(Collectors.toList());
            int q = Integer.parseInt(sc.nextLine());
            List<Integer> ms = Stream.of(sc.nextLine().split(" "))
                    .map(Integer::parseInt)
                    .collect(Collectors.toList());
            ms.forEach(m -> {
                if (makeConbination(ns, m, 0, 0)) {
                    System.out.println("yes");
                } else {
                    System.out.println("no");
                }
            });
        } catch (NoSuchElementException | NumberFormatException e) {
            System.out.println(e);
            return;
        }
    }

    private static boolean makeConbination(List<Integer> ns, int target, int i, int t) {
        if (target == t) {
            return true;
        }
        if (i >= ns.size()) {
            return false;
        }
        int n = ns.get(i++);
        return makeConbination(ns, target, i, t + n) ||
                makeConbination(ns, target, i, t);
    }
}



Measured memory_bytes: 32448
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,h;cin>>n>>h;
  vector<int> a;
  vector<int> b;
  for(int i = 0; n > i; i++){
    int A,B;cin>>A>>B;
    a.push_back(A);
    b.push_back(B);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  int ans = 0;
  while(b[b.size()-1] > a[a.size()-1]){
    ans++;
    h -= b[b.size()-1];
    b.pop_back();
    if(h <= 0){
      cout << ans << endl;
      return 0;
    }
  }
  ans += (h-1)/a[a.size()-1]+1;
  cout << ans << endl;
}

Measured memory_bytes: 1276
#include<cstdio>
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
int main(){
	int n; scanf("%d",&n);
	for(int i=1;i<=3500;++i)
		for(int j=1;j<=3500;++j){
			long long up=4ll*i*j-n*i-n*j,down=1ll*n*i*j,gg=gcd(up,down);
			if(up*down<=0) continue;
			up/=gg; down/=gg;
			if(up==1){
				printf("%d %d %lld",i,j,down); return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;
int getans(int& a, int to)
{
	int x = (to - a) / 2;
	a += 2 * x;
	return x;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b, c;
	cin >> a >> b >> c;
	int maxv = max({ a,b,c });
	int ans = getans(a, maxv) + getans(b, maxv) + getans(c, maxv);
	if (a > b) swap(a, b);
	if (b > c) swap(b, c);
	if (a > b) swap(a, b);
	if (a == c) cout << ans << endl;
	else if (a == b) cout << ans + 1 << endl;
	else cout << ans + 2 << endl;
	return 0;
}


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

int c;

int main(){
	std::string str;
	std::cin>>str;
	char in=str[0];
	bool flag=(in=='B');
	for(int i=1;i<str.size();++i){
		in=str[i];
		if(flag!=(in=='B')){
			++c;
			flag=!flag;
		}
	}
	std::cout<<c<<std::endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		while (N != 0) {
			int k = N % 10;
			if (k == 7) {
				System.out.println("Yes");
				break;
			} else {
				N = N / 10;
			}
		}
		if (N == 0) {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26964
var
i,j,c,d,e,b,x,y,z,n:longint;
begin
read(n,c);
for i:=0 to n do
for j:=0 to n do
begin
if i+j<=n then begin
x:=i*10000;
y:=j*5000;
z:=(n-i-j)*1000;
if x+y+z=c then begin writeln(i,' ',j,' ',(n-i-j));exit;end;
end;
end;
writeln('-1 -1 -1');
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x){
	char ch=0; x=0;
	bool sign=false;
	while(ch<'0'||'9'<ch) sign|=ch=='-',ch=getchar();
	while('0'<=ch&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	x=sign?-x:x;
}
int n;
int ary[3003];
long long dp[3003][3003];
int main(){
	read(n);
	for(int i=1;i<=n;++i){
		read(ary[i]);
	}
	for(int i=n;i>=1;--i){
		if(i&1){
			for(int j=1,e;j<=i;++j){
				e=n-i+j;
				dp[j][e]=max(dp[j+1][e]+ary[j],dp[j][e-1]+ary[e]);
			}
		} else {
			for(int j=1,e;j<=i;++j){
				e=n-i+j;
				dp[j][e]=min(dp[j+1][e]-ary[j],dp[j][e-1]-ary[e]);
			}
		}
	}
	cout<<dp[1][n]<<endl;
	return 0;
}

Measured memory_bytes: 70016
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pi pair<int,int>
#define pl pair<long,long>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod ((ll)(1e9+7))
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define vl vector<ll>
#define ml unordered_map<ll,ll> 
#define vpll vector<pair<ll,ll>>
#define INF 0x3f3f3f3f
#define mp make_pair

int main() {
    ll n;
    in(n);
    vpll v(n);
    for(auto &i:v) in2(i.first,i.second);
    sort(v.begin(),v.end());
    double sum=0,c=0;
    do {
        c++;
        double ans=0,a=v[0].first,b=v[0].second;
        for (ll i=1;i<n;i++) {
            ans+=hypot((double)(v[i].first-a),(double)(v[i].second-b));
            a = v[i].first;b=v[i].second;
        }
        // cout<<ans<<endl;
        sum+=ans;
    } while (next_permutation(v.begin(),v.end()));
    // cout<<c<<endl;
    printf("%.10lf\n",sum/(c));
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String output = "No";
		
		for(int C=1; C<=3; C++) {
			if(A*B*C % 2 == 1) {
				output = "Yes";
			}
		}
		
		System.out.println(output);
			
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

vector<vector<int>> g(100010);
vector<int> l(100010, 1e7), r(100010, -1e7);

pair<int, int> dfs(int v, int p) {
    pair<int, int> res = {l[v], r[v]}, tmp;
    for (int u : g[v]) {
        if (u == p) continue;
        if (l[u] == 1e7) {
            l[u] = l[v] - 1;
            r[u] = r[v] + 1;
        } else {
            if (l[u] % 2 == l[v] % 2) {
                l[u] = 3e7;
            }
        }
        tmp = dfs(u, v);
        res.first = max(res.first, tmp.first - 1);
        res.second = min(res.second, tmp.second + 1);
    }
    l[v] = res.first;
    r[v] = res.second;
    return res;
}

void dfs2(int v, int p) {
    for (int u : g[v]) {
        if (u == p) continue;
        if (l[u] % 2 == l[v] % 2) {
            l[u] = 3e7;
        } else {
            l[u] = max(l[u], l[v] - 1);
            r[u] = min(r[u], r[v] + 1);
            dfs2(u, v);
        }
    }
}

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

    int n, k;
    cin >> n;
    rep(i, 0, n - 1) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    cin >> k;
    int root = 0;
    rep(i, 0, k) {
        int a, b;
        cin >> a >> b;
        a--;
        l[a] = r[a] = b;
        if (!i) root = a;
    }
    dfs(root, -1);
    dfs2(root, -1);
    rep(i, 0, n) debug(l[i], r[i]);
    rep(i, 0, n) if (l[i] > r[i]) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    rep(i, 0, n) cout << l[i] << endl;

    return 0;
}

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

int main() {
    int n, x;
    while(cin >> n >> x, n) {
        int ans = 0;
        for(int i = 1; i <= n; ++i) {
            for(int j = i + 1; j <= n; ++j) {
                for(int k = j + 1; k <= n; ++k) {
                    ans += i + j + k == x;
                }
            }
        }
        cout << ans << endl;
    }
}



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

int main() {
  ll n;
  cin>>n;
  vector<ll> a(n);
  for(int i=0; i<n; i++) cin>>a[i];
  sort(a.begin(),a.end());
  for(int i=0; i<n-1; i++){
    if(a[i]==a[i+1]) {
      cout<<"NO";
      return 0;
    }
  }
  cout<<"YES";
}

Measured memory_bytes: 1792
n = int(input())
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))

suma = sum(alist)
sumb = sum(blist)

ac, bc = 0, 0
for a, b in zip(alist, blist):
  if a < b:
    ac += (b - a) // 2 + (1 if (b - a) % 2 == 1 else 0)
  elif a > b:
    bc += a - b
if max(ac, bc) <= sumb - suma:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll D;
    cin >> D;
    vector<ll> c(26);
    rep(i,26){
        cin >> c[i];
    }
    vector<vector<ll>> s(D,vector<ll>(26));
    rep(i,D){
        rep(j,26){
            cin >> s[i][j];
        }
    }
    vector<ll> t(D);
    /*rep(i,D){
        cin >> t[i];
        t[i]--;
    }*/
    
    ll score = 0;
    ll cur = 0;
    rep(i,D){
        t[i] = ((cur%26)+1);
        cur++;
    }
    ll M = 0;
    vector<ll> ans(D);
    rep(j,1000){
        t[j%D]++;
        t[j%D] %= 26;
        score = 0;
        vector<ll> memo(26,-1);
        rep(i,D){
            score += s[i][t[i]];
            memo[t[i]] = i;
            ll M = 0;
            rep(j,26){
                if(M < s[i][j]){
                    t[i] = j+1;
                    M = s[i][j];
                }
            }
        }
        if(M < score){
            rep(k,D){
                ans[k] = t[k];
            }
        }else{
            t[j%D]--;
            t[j%D] %= 26;
        }
    }
    rep(i,D){
        cout << ans[i] << endl;
    }
}


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

int main() {
	string s;
	cin >> s;
	ll ans = 0;
	for (int i = 0; i < 6; i++) {
		if (s.at(i) == '1')ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(q), r(q);
    for (int i = 0; i < q; i++)
    {
        cin >> l[i] >> r[i];
    }
    vector<int> car(s.size(), 0);
    int num = 0;
    for (int i = 1; i < s.size(); i++)
    {
        if (s[i - 1] == 'A' && s[i] == 'C')
        {
            num++;
        }
        car[i] = num;
    }

    for(int i = 0; i<q;i++){
        cout << car[r[i]-1] - car[l[i]-1] << endl;
    }
    return 0;
}

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

using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  int x=S.size();
  int y=0;
     int m=x/2;
  if (x%2 !=0) {
    cout << "No" << endl;
  }
  else if (x%2 ==0) {
    int m=x/2;
    for (int i=0; i<m;i++) {
   if(S.at(i)==S.at(m+i)) {
     y++;
   }
    }
 
    if (y==m) {
      cout <<"Yes" << endl;
    }
    else {
cout << "No" << endl;
    }
  }
  
  
  

  
  
  
  
}

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

int main()
{
    int i, j, n, x, y, p, q;

    cin >> n >> x >> y;

    int ans[n];
    ans[0]=0;
    for(i=1; i<n; i+=1)
        ans[i]=n-i;

    for(i=1; i<=n; i+=1)
    {
        for(j=i+1; j<=n; j+=1)
        {
            p=j-i;
            q=abs(x-i)+1+abs(j-y);

            if(q<p)
            {
                ans[q]+=1;
                ans[p]-=1;
            }
        }
    }

    for(i=1; i<n; i+=1)
        cout << ans[i] << endl;
}

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Stdin io = new Stdin();
            Solve(io);
        }
        static void Solve(Stdin io)
        {
            int n,a,b;
            int[] l = io.Inputs();
            n=l[0];a=l[1];b=l[2];
            WriteLine(Enumerable.Range(1,n).Where(x => (a<=Digits_Sum(x) && Digits_Sum(x)<=b)).Sum());
        }

        static int　Digits_Sum(int n)
        {
            int buf = 0;
            while(n>0)
            {
                buf+=n%10;
                n/=10;
            }
            return buf;
        }
    }
    class Stdin
    {
        public int Input()
        {
            return int.Parse(ReadLine());
        }
        public int[] Inputs()
        {
            string[] buf = ReadLine().Split(' ');
            return buf.Select(x => int.Parse(x)).ToArray();
        }
        public string Raw_Input()
        {
            return ReadLine();
        }
    }
}


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

int a[105], b[105], n;
vector<int> ans;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	for (int i = 1; i <= n; ++i) {
		if (a[i] > i) {
			cout << "-1" << endl;
			return 0;
		}
	}

	for (int i = 0; i < n; ++i) {
		int ind = -1;
		for (int j = n-i; j >= 1; --j)
			if (a[j] == j) {
				ind = j;
				break;
			}
		if (ind == -1) {
			cout << -1 << endl;
			return 0;
		}
		ans.push_back(a[ind]);
		int ct = 0;
		for (int j = 1; j <= n-i; ++j)
			if (j != ind) {
				++ct;
				b[ct] = a[j];
			}
		for (int j = 1; j <= n; ++j)
			a[j] = b[j];
	}
	reverse(ans.begin(), ans.end());
	for (int x : ans)
		cout << x << endl;
}

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

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%NUM;
		a=a*a%NUM;
		b>>=1;
	}
	return res;
}

int main(){
	ll n;
	cin >> n;
	vector<ll> d(n,0);
	priority_queue<ll> q;
	ll t;
	rep(i,n){
		cin >> t;
      if(i==0 && t!=0){
        cout << 0 << endl;
        return 0;
      }
		q.push(t);
		d[t]++;
	}
	if(d[0] != 1){
		cout << 0 << endl;
		return 0;
	}
	ll ans(1);
	ll mx = q.top();
	rep(i,mx){
		ans = (ans * power(d[i],d[i+1])) % NUM;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2168
//g++ main.cpp -I /usr/local/include/ac-library
//#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
//using namespace atcoder;
stack<int> st;
queue<int> qu;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define sz(x) (int)(x).size()
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)

ll dp[51][51][2501];

int main(){
    int n,a;
    cin >> n>> a;
    int x[n+1];
    x[0]=0;
    rep2(i,n){
        cin >> x[i];
    }
    rep(j,n+1){
        rep(k,n+1){
            rep(s,n*50+1){
                if(j==0&&k==0&&s==0){
                    dp[j][k][s]=1;
                }else if(j>=1&&s<x[j]){
                    dp[j][k][s]=dp[j-1][k][s];
                }else if(j>=1&&k>=1&&s>=x[j]){
                    dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j]];
                }else{
                    dp[j][k][s]=0;
                }
            }
        }
    }
    ll ans=0;
    rep2(k,n){
        ans+=dp[n][k][k*a];
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 54364
#include<cstdio>
#include<algorithm>
using namespace std;
int n,t[2],a[5][1000010],to[1000010];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=3;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",a[i]+j);
	for(int i=1;i<=n;i++){
		to[i]=a[2][i]/3+1;
		if(!((a[1][i]-a[2][i]==-1&&a[2][i]-a[3][i]==-1&&a[1][i]%3==1)||(a[1][i]-a[2][i]==1&&a[2][i]-a[3][i]==1&&!(a[1][i]%3)))||(labs(i-to[i])&1)){
			puts("No");
			return 0;
		}
		t[i&1]^=(a[1][i]>a[2][i]);
	}
	for(int i=1;i<=n;i++){
		while(to[i]!=i){
			if(to[to[i]]==to[i]){
				puts("No");
				return 0;
			}
			t[i&1^1]^=1;
			swap(to[i],to[to[i]]);
		}
	}
	puts(t[0]||t[1]?"No":"Yes");
	return 0;
}

Measured memory_bytes: 8704
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = 0
for i in range(N):
    if A[i] >= B[i]:
        a += B[i]
    else:
        a += A[i]
        if (B[i] - A[i]) <= A[i + 1]:
            A[i + 1] -= B[i] - A[i]
            a += (B[i] - A[i])
        else:
            a += A[i + 1]
            A[i + 1] = 0
print(a)

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

typedef long long int lint;

int main(){
    lint n, l;
    cin >> n >> l;
    vector<lint> a(n);
    for(lint i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    lint j = 0;
    while(j < n - 1){
        if(a[j] + a[j+1] >= l){
            break;
        }
        j++;
    }
    if(j == n - 1){
        cout << "Impossible" << endl;
    }else{
        cout << "Possible" << endl;
        for(lint i = 1 ; i <= j ; i++){
            cout << i << endl;
        }
        for(lint i = n - 1 ; i > j ; i--){
            cout << i << endl;
        }
    }
    return 0;
}

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

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

using namespace std;
using lint=long long;

lint solve(){
	lint a,b; cin>>a>>b;
	if(a<b) swap(a,b);
	if(a==b) return (a-1)+(b-1);
	if(a==b+1) return (a-2)+(b-1);

	lint m=sqrt(a*b)+1;
	while(m*m>a*b) m--;

	lint l=m,r=m;
	while((l+1)*r<a*b) l++;
	lint res=0;
	res+=b-1;
	res+=r-b;
	res+=l-1;
	if(m*m==a*b) res--;

	return res;
}

int main(){
	int q; cin>>q;
	rep(_,q) cout<<solve()<<endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


rotate_candidate = fetch_one_line()
half_len = int(len(rotate_candidate) / 2)

hug_num = 0
for i in range(half_len):
    if rotate_candidate[i] != rotate_candidate[-(i+1)]:
        hug_num += 1

print(hug_num)




Measured memory_bytes: 38384
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXV = 4000;
const int MAXE = 20000;
const int INF = (1<<30);
const ll LINF = (1LL<<60);
struct FlowGraph{
	struct edge{
		int to, cap, flow; ll dis;
		edge *nxt, *rev;
	}edges[MAXE + 5], *adj[MAXV + 5], *cur[MAXV + 5], *ecnt;
	FlowGraph() {ecnt = &edges[0];}
	int s, t;
	void addedge(int u, int v, int c, ll w) {
		edge *p = (++ecnt), *q = (++ecnt);
		p->to = v, p->cap = c, p->flow = 0, p->dis = -w;
		p->nxt = adj[u], adj[u] = p;
		q->to = u, q->cap = 0, q->flow = 0, q->dis = w;
		q->nxt = adj[v], adj[v] = q;
		p->rev = q, q->rev = p;
//		printf("%d %d %d %lld\n", u, v, c, w);
	}
	ll h[MAXV + 5], d[MAXV + 5], f[MAXV + 5];
	int hp[MAXV + 5];
	void update(int x, ll k) {
		f[x] = k;
		while( x ) {
			hp[x] = x;
			if( (x<<1) <= t && f[hp[x]] > f[hp[x<<1]] )
				hp[x] = hp[x<<1];
			if( (x<<1|1) <= t && f[hp[x]] > f[hp[x<<1|1]] )
				hp[x] = hp[x<<1|1];
			x >>= 1;
		}
	}
	bool relabel() {
		for(int i=s;i<=t;i++)
			h[i] += d[i], d[i] = f[i] = LINF, hp[i] = i, cur[i] = adj[i];
		update(s, d[s] = 0);
		while( f[hp[1]] != LINF ) {
			int x = hp[1]; update(x, LINF);
			for(edge *p=adj[x];p;p=p->nxt) {
				if( p->cap > p->flow ) {
					ll w = p->dis + h[x] - h[p->to];
					if( d[x] + w < d[p->to] )
						update(p->to, d[p->to] = d[x] + w);
				}
			}
		}
		return !(d[t] == LINF);
	}
	bool vis[MAXV + 5];
	int aug(int x, int tot) {
		if( x == t ) return tot;
		int sum = 0; vis[x] = true;
		for(edge *&p=cur[x];p;p=p->nxt) {
			ll w = p->dis + h[x] - h[p->to];
			if( !vis[p->to] && p->cap > p->flow && d[x] + w == d[p->to] ) {
				int del = aug(p->to, min(tot - sum, p->cap - p->flow));
				p->flow += del, p->rev->flow -= del, sum += del;
				if( sum == tot ) break;
			}
		}
		vis[x] = false;
		return sum;
	}
	ll min_cost_max_flow(int _s, int _t) {
		s = _s, t = _t; ll cost = 0;
		while( relabel() ) {
			int del = aug(s, INF);
			cost += (d[t] + h[t]) * del;
		}
		return -cost;
	}
}G;
int N, s, t;
int main() {
	scanf("%d", &N), s = 1, t = 2*N+6;
	for(int i=1;i<=N;i++) {
		int x, y, c; scanf("%d%d%d", &x, &y, &c);
		G.addedge(s, i+1, c, 0);
		G.addedge(i+1, 2*N+2, INF, + x + y);
		G.addedge(i+1, 2*N+3, INF, + x - y);
		G.addedge(i+1, 2*N+4, INF, - x + y);
		G.addedge(i+1, 2*N+5, INF, - x - y);
	}
	for(int i=1;i<=N;i++) {
		int x, y, c; scanf("%d%d%d", &x, &y, &c);
		G.addedge(i+N+1, t, c, 0);
		G.addedge(2*N+5, i+N+1, INF, + x + y);
		G.addedge(2*N+4, i+N+1, INF, + x - y);
		G.addedge(2*N+3, i+N+1, INF, - x + y);
		G.addedge(2*N+2, i+N+1, INF, - x - y);
	}
	printf("%lld\n", G.min_cost_max_flow(s, t));
}
/*
(+ rx + ry) + (- bx - by)
(+ rx - ry) + (- bx + by)
(- rx + ry) + (+ bx - by)
(- rx - ry) + (+ bx + by)
*/

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

int a[100][100];
int N,u,k,col;
int main() {
	cin >> N;
	for(int i=0; i<N; ++i) {
		cin >> u >> k;
		for(int l=0; l<k; ++l) {
			cin >> col;
			a[u-1][col-1] = 1;
		}
		cout << a[i][0];
		for(int l=1; l<N; ++l) {
			cout << " " << a[i][l];
		}
		cout << endl;
	}
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int x, y;
    cin >> s >> x >> y;
    vector<int> fx(16010);
    vector<int> fy(16010);
    vector<int> dx;
    vector<int> dy;    
    int i;
    int sc = 0;
    for(i = 0; i < s.size(); i++)
    {
        while(s[i] != 'T' && i < s.size())
        {
            sc++;
            i++;
        }
        break;
    }
    fx[8000+sc] = 1;
    fy[8000] = 1;

    int tc = 0;
    for(int j = i; j < s.size();)
    {
        int fc = 0;
        while(s[j] == 'T' && j < s.size())
        {
            tc++;
            j++;
        }
        while(s[j] == 'F' && j < s.size())
        {
            fc++;
            j++;
        }
        if(tc % 2 == 1)
        {
            dy.push_back(fc);
        }
        else
        {
            dx.push_back(fc);
        }
    } 
 
    // x
    for(int i = 0; i < dx.size(); i++)
    {
        for(int j = 0; j < 16010; j++)
        {
            if(fx[j] == i+1)
            {
                fx[j] = 0;
                int k = j;
                while(fx[k-dx[i]] == i+1)
                {
                    fx[k-dx[i]] = i+2;
                    k -= dx[i];
                }
                fx[k-dx[i]] = i+2;
                while(fx[k+dx[i]] == i+1)
                {
                    fx[k+dx[i]] = i+2;
                    k += dx[i];
                }
                fx[k+dx[i]] = i+2;
            }
        }
    }
    // y
    for(int i = 0; i < dy.size(); i++)
    {
        for(int j = 0; j < 16010; j++)
        {
            if(fy[j] == i+1)
            {
                fy[j] = 0;
                int k = j;
                while(fy[k-dy[i]] == i+1)
                {
                    fy[k-dy[i]] = i+2;
                    k -= dy[i];
                }
                fy[k-dy[i]] = i+2;
                while(fy[k+dy[i]] == i+1)
                {
                    fy[k+dy[i]] = i+2;
                    k += dy[i];
                }
                fy[k+dy[i]] = i+2;
            }
        }
    }
    if(fx[8000+x] == dx.size() + 1 && fy[8000+y] == dy.size() + 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

namespace ConsoleApp2
{
    class Program
    {
        static readonly int[] Matches = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

        static void ReadInt2(out int first, out int second)
        {
            var array = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            first = array[0];
            second = array[1];
        }

        static string Max(string left, string right)
        {
            if (left == null || left.Contains("/"))
                return right;
            if (right == null || right.Contains("/"))
                return left;

            if (left.Length > right.Length)
                return left;
            else if (left.Length < right.Length)
                return right;
            else
                return left.CompareTo(right) >= 0 ? left : right;
        }

        static string Solve(int digit, int remain, string[,] memo, int[] usable)
        {
            if (memo[digit, remain] != null)
                return memo[digit, remain];
            if (digit <= 0)
                return remain == 0 ? "" : "/";

            if (Array.Exists(usable, x => x == digit) && remain >= Matches[digit])
            {
                return memo[digit, remain] =
                    Max(Solve(digit - 1, remain, memo, usable),
                        digit.ToString() + Solve(digit, remain - Matches[digit], memo, usable));
            }
            else
            {
                return memo[digit, remain] = Solve(digit - 1, remain, memo, usable);
            }
        }

        static void Main(string[] args)
        {
            int n, m;
            ReadInt2(out n, out m);
            int[] A = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();

            string[,] memo = new string[10, n + 1];
            string ans = Solve(9, n, memo, A);
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 234412
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

/*
1. only 'A', 'C', 'G', 'T'
2. not include 'AGC', 'GAC', 'ACG'
3. not include 'ATGC', 'AGGC', 'AGTC' 
*/

ll memo[100][64];
ll AGC_idx = 0 + 4 * 2 + 16 * 1;

bool ok(ll last4[]){
    ll _last4[4];

    rep(i, 4){
        rep(j, 4) _last4[j] = last4[j];
        if (i >= 1){
            _last4[i - 1] = last4[i];
            _last4[i] = last4[i - 1];
        }
        ll last4_idx1 = _last4[0] + 4 * _last4[1] + 16 * _last4[2];
        ll last4_idx2 = _last4[1] + 4 * _last4[2] + 16 * _last4[3];
        if (AGC_idx == last4_idx1 || AGC_idx == last4_idx2) return false;
    }    
    return true;
}

ll dfs(ll cnt, ll last3[], ll N){
    ll last3_idx = last3[0] + 4 * last3[1] + 16 * last3[2];

    if (cnt == N) return 1;
    if (memo[cnt][last3_idx] != 0) return memo[cnt][last3_idx];

    ll ret = 0;
    ll last4[4];
    rep(i, 3) last4[i] = last3[i];
    
    rep(c, 4){
        last4[3] = c;
        if (ok(last4)){
            ll nxt_last3[3];
            rep(j, 3) nxt_last3[j] = last4[j + 1];
            ret = (ret + dfs(cnt + 1, nxt_last3, N)) % mod;
        }
    }

    memo[cnt][last3_idx] = ret;

    return ret;

}

int main(void){
    ll N;
    ll answer;
    rep(i, 100) rep(j, 64) memo[i][j] = 0;

    cin >> N;
    
    ll last3[3] = {3, 3, 3};
    answer = dfs(0, last3, N);

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
/*
[abc166] F - Three Variables Game
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 1e5;

int N, A, B, C;
int s[MAX_N];
int ans[MAX_N];

int to_i(string &si) {
    if (si == "AB") return 0;
    if (si == "BC") return 1;
    return 2;
}

bool solve() {
    int n[3] = {A, B, C};
    for (int i = 0; i < N; i++) {
        int p = s[i], q = (p + 1) % 3;
        if (n[p] + n[q] == 0) {
            return false;
        }
        if (n[p] == 0 || n[q] == 0) {
            if (n[p] == 0) swap(p, q);
        } else if (/*n[p] == 1 && n[q] == 1 &&*/ i + 1 < N &&
                   s[i + 1] != s[i]) {
            if (q == (s[i + 1] + 2) % 3) swap(p, q);
        }
        n[p]--, n[q]++;
        assert(n[p] >= 0 && n[q] >= 0);
        ans[i] = q;
    }
    return true;
}

int main() {
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++) {
        string str;
        cin >> str;
        s[i] = to_i(str);
    }

    if (solve()) {
        cout << "Yes" << endl;
        for (int i = 0; i < N; i++) {
            cout << char('A' + ans[i]) << endl;
        }
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

class Program
{
  static void Main(string[] args)
  {
    int[] inputs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    int N = inputs[0];
    int X = inputs[1];
    int T = inputs[2];
    int times = (N + X - 1) / X;
    int ans = times * T;
    Console.WriteLine(ans);
  }
}


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


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


def main():
    N = readint()
    print(N + N ** 2 + N ** 3)


if __name__ == "__main__":
    main()


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

bool isPalindrome(string s) {
  int l = 0, r = s.size() - 1;
  while (l < r) {
	if (s[l++] != s[r--]) return false;
  }

  return true;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	string s;
	cin >> s;
	if (isPalindrome(s) && isPalindrome(s.substr(0, s.size() / 2)) && isPalindrome(s.substr((s.size() + 1) / 2))) cout << "Yes" << endl;
	else cout << "No" << endl;
    
    return 0;
}



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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 1e5+5;

ll n , k , mod=1e9+7 , fac[N] , inv[N] , ans=1;

vector<int> adj[N];

ll fp(ll b , ll p)
{
    if (!p) return 1;
    ll ans = fp(b , p/2);
    ans = (ans*ans)%mod;
    if (p%2) ans = (ans*b)%mod;
    return ans;
}

void pre()
{
    fac[0]=1 , inv[0]=1;
    for(ll i=1; i<N; i++)
    {
        fac[i] = (i*fac[i-1])%mod;
        inv[i] = fp(fac[i] , mod-2);
    }
}

ll nCr(ll nn , ll r)
{
    if (r > nn) return 0;
    return (((fac[nn] * inv[r])%mod)*inv[nn-r])%mod;
}

void imp()
{
    cout << "0\n";
    exit(0);
}

void dfs(int node , int p)
{
    if (node == 1) ans = (ans*k)%mod;

    ll cnt=0 , rem = k-1;
    for(auto ch : adj[node])
    {
        if (ch != p) cnt++;
    }
    if (cnt == 1)
    {
        if (node != p) rem--;
       // cout << rem << ' ' << cnt << " how\n";
        if (rem <= 0) imp();
        ans = (ans*rem)%mod;
    }
    else if (cnt > 1)
    {
        if (node != p) rem--;
     //   cout << rem << ' ' << cnt << " how\n";
        if (cnt > rem) imp();
        ll tmp = (nCr(rem , cnt)*fac[cnt])%mod;
        ans = (ans*tmp)%mod;
    }

    for(auto ch : adj[node])
    {
        if (ch != p)
        {
            dfs(ch , node);
        }
    }
}

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

    cin >> n >> k;

    for(int i=1; i<n; i++)
    {
        int x,y;
        cin >> x >> y;
        adj[x].push_back(y) , adj[y].push_back(x);
    }

    pre();
    dfs(1,1);

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
long long GCD(long long A, long long B) {
    if (B == 0) return A;
    else return GCD(B, A % B);
}
int main() {
    int N;
    cin >> N;
    vector<long long>A(N);
    for (long long i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    long long sum = 1;
    for (long long i = 0; i < N; i++) {
        sum *= A.at(i);
    }
    for (long long i = 1; i < N; i++) {
        A.at(i) = (A.at(i) * A.at(i - 1)) / GCD(A.at(i), A.at(i - 1));
    }
    cout << A.at(N - 1) << endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define dump(x)  cerr << #x << " => " << (x) << endl
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define EQ(a,b) (abs(a - b) < 1e-10)
using namespace std;
typedef long long LL;
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {1,0,-1,0};
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
// LONG_MAX,LLONG_MAX
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 Key,class Value> ostream& operator << (ostream &s, map<Key,Value> M)
{ for ( auto itr = begin(M); itr != end(M); ++itr) { s << itr->first << ":" << itr->second; } return s;}


constexpr int n[9] = {2,5,5,4,5,6,3,7,6};

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vector<int> A(M);
    REP(i,M) cin >> A[i];
    vector<string> dp(N+1,"");
    REP(i,M) {
        FOR(j,i+1,M) {
            if (n[A[i]-1] == n[A[j]-1]) {
                int m = max(A[i],A[j]);
                A[i] = m;A[j] = m;
            }
        }
    }
    UNIQ(A);
    for (int num : A) {
        if (n[num-1] <= N) dp[n[num-1]] = max(dp[n[num-1]],to_string(num));
    }
    FOR(i,1,N+1) {
        for (int num : A) {
            if (i >= n[num-1]) {
                string a;
                if (dp[i-n[num-1]] != "")
                    a = max(dp[i-n[num-1]]+to_string(num),to_string(num)+dp[i-n[num-1]]);
                else
                    a = "";
                dp[i] = max(dp[i],a,[] (string l,string r){
                    return (l.size() < r.size() || ( l.size() == r.size() && l < r ));
                });
            }
        }
    }
    cout << dp[N] << endl;
}

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


int main() {
     int n, a;
     cin >> n >> a;
     vector<int> l(n);
     for( int i = 0; i < n; i++ ){
        cin >> l[i];
     }
     
     vector<int> v(n+1);
     int aux = 0;
     int cnt  =1;
     for(int i =0; i < n; i++){
            if(l[i]+aux <= a){
                   cnt++;
                   aux += l[i];
            }
            else break;
     }
     
     cout << cnt;

     
return 0;

}









  

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);

    if( (a+b)%3==0 || a%3==0 || b%3==0 )
    {
        printf("Possible");
    }

    else
    {
        printf("Impossible");
    }
    return 0;
}


Measured memory_bytes: 1700
from sys import stdin
from collections import deque

N, Q = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
lr_list = [list(map(int, stdin.readline().rstrip().split())) for _ in range(Q)]

#result_list = []
count = 0

result_list = deque([])

for i in range(N):
    result_list.append(count)
    if S[i] != "A":
        continue
    try:
        if S[i+1] == "C":
            count += 1
    except:
       pass

for l, r in lr_list:
    print(result_list[r-1] - result_list[l-1])

Measured memory_bytes: 64988
taro = hanako = 0
for i in range(int(input())):
    lst = list(map(str, input().split()))
    while 1:
        if lst[0] == lst[1]:
            taro = taro + 1
            hanako = hanako + 1
            break
        else:
            length = min(len(lst[0]),len(lst[1]))
            for j in range(length):
                first = ord(lst[0][j:j+1])
                second = ord(lst[1][j:j+1])
                if first > second:
                    taro = taro + 3
                    break
                elif first < second:
                    hanako = hanako + 3
                    break
                elif j == length - 1:
                    if len(lst[0]) > len(lst[1]):
                        taro = taro + 3
                    elif len(lst[0]) < len(lst[1]):
                        hanako = hanako + 3
                    break
            break
print(str(taro) + " " + str(hanako))


Measured memory_bytes: 5604
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

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

    vector<int> L(N, 0);
    for (auto &x: L) cin >> x;
    int cnt = 0;

    for (size_t i=0; i<L.size(); ++i) {
        for (size_t j=i+1; j<L.size(); ++j) {
            if (L[i] == L[j]) continue;

            for (size_t k=j+1; k<L.size(); ++k) {
                if (L[i] == L[k]) continue;
                else if (L[j] == L[k]) continue;

                vector<int> M(3);
                M[0] = L[i];
                M[1] = L[j];
                M[2] = L[k];
                sort(M.begin(), M.end(), greater<int>());
                if (M[0] < M[1] + M[2]) {
                    ++cnt;
                }
            }
        }
    }
    cout << cnt << endl;

}


Measured memory_bytes: 3632
#include <stdio.h>

int     main(void)
{
    int x, y;
    int i;
    
    i = 0;
    while (i < 10000)
    {
        scanf("%d%d", &x, &y);
        
        if (x == 0 && y == 0)
            break;
        else if (x < y)
            printf("%d %d\n", x, y);
        else if (y < x)
            printf("%d %d\n", y, x);
        else
            printf("%d %d\n", x, y);
            
        i++;
    }
}


Measured memory_bytes: 2032
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d  long double
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (int)1e18
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;

 
 
 
 
signed main()
{
    haha
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n,greater<int>());
    if(k>=n)
    {
        cout<<0;
        return 0;
    }
    for(int  i=0;i<k;i++)
    arr[i]=0;
    int s=0;
    for(int i=0;i<n;i++)
    s+=arr[i];
    cout<<s;
    
    
    
    
}

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

int main(){
    string s, t;
    cin >> s >> t;
    set<int> a[26], b[26];
    for(int i = 0; i < s.size(); i++){
        a[s[i] - 'a'].insert(t[i] - 'a');
        b[t[i] - 'a'].insert(s[i] - 'a');
    }
    bool f = true;
    for(int i = 0; i < 26; i++){
        if(a[i].size() > 1) f = false;
        if(b[i].size() > 1) f = false;
    }
    cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int,int>pi;
typedef     pair<long long,long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define     FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
map<int,int>m;

int main()
{
   int n,i,k,x,c=0,q;
   cin>>n>>k>>q;
   vector<int>v(n+2,(k-q));
      while(q--)
   {
    cin>>x;
    v[x]++;
   }   
   for(i=1;i<=n;i++)
   {
   // v[i]+=m[v[i]];
  //  cout<<v[i]<<" ";
    if(v[i]<=0)

    {
      cout<<"No"<<endl;
    }else
    {
      cout<<"Yes"<<endl;
    }
   }
   }

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

int main(){
  string s,t;
  int a,b;
  string u;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(s == u) cout << a-1 << ' ' << b << endl;
  else cout << a << ' ' << b-1 << endl;
  
  return 0;
}


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

int main() {
    int n,a,b,c;
    cin >> n >> a >> b >> c;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l.at(i);
    }
    int quat;
    int minMp = 10000;
    int sum;
    vector<int> matu(4);
    for (int i = 0; i < pow(4, n); i++) {
        
        matu.at(0) = 0;
        matu.at(1) = 0;
        matu.at(2) = 0;
        matu.at(3) = 0;
        sum = 0;

        for (int j = 0; j < n; j++) {
            quat = 0;
            if (i & (1<<(j * 2))) {
                quat++;
            }
            if (i & (1<<((j * 2) + 1))) {
                quat += 2;
            }

            if ((matu.at(quat) != 0) && (quat != 3)) {
                sum += 10;
            }
            matu.at(quat) += l.at(j);
        }
        if ((matu.at(0) == 0) || (matu.at(1) == 0) || (matu.at(2) == 0)) {
            continue;
        }
        sum += abs(a - matu.at(0)) + abs(b - matu.at(1)) + abs(c - matu.at(2));
        
        if (minMp > sum) {
            minMp = sum;
        }
    }

    cout << minMp << endl;
}

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

using namespace std;

int main(){

	int n;
	map<int,int> m;
	while(cin>>n){
		m[n]++;
	}

	int maxCnt=0;
	int maxVal=0;

	vector<int> maxValList;
	for(map<int,int>::iterator it = m.begin(); it != m.end(); it++){
		if(maxCnt<it->second){
			maxCnt=it->second;
			maxVal=it->first;
			maxValList.clear();
			maxValList.push_back(it->first);
		}
		else if(maxCnt==it->second){
			maxValList.push_back(it->first);
		}
	}
	sort(maxValList.begin(),maxValList.end());
	for(int i = 0; i < maxValList.size(); i++){
		cout<<maxValList[i]<<endl;
	}


	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void){
  int W,H;
  int x,y,r;
  
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);

  //x is out of range "W"
  if(x - r < 0 || W < x + r)
    printf("No\n");
  //y is out of range "H"
  else if(y - r < 0 || H < y + r)
    printf("No\n");
  else
    printf("Yes\n");
  
  return 0;
}

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

constexpr int MAX_N = 8;

bool graph[MAX_N+1][MAX_N+1];
bool visited[MAX_N+1];
int N, M;

int dfs(int v) {
  bool all{true};
  for (int i{1}; i <= N; ++i) {
    if (!visited[i]) {
      all = false;
      break;
    }
  }
  if (all) return 1;

  int count{};
  for (int i{1}; i <= N; ++i) {
    if (!graph[v][i] || visited[i]) continue;

    visited[i] = true;
    count += dfs(i);
    visited[i] = false;
  }

  return count;
}

int main() {
  scanf("%d%d", &N, &M);
  for (int i{}; i < M; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    graph[a][b] = graph[b][a] = true;
  }

  visited[1] = true;
  printf("%d\n", dfs(1));
}


Measured memory_bytes: 256