akhauriyash/Code-Regression huggingface dataset:
//HOW YOU DOI'N........................JT
//Could this code be more bad..........CB
//I know...............................MG
//Hii..................................RG
//Noooooooo............................RG
//I wish I could but I don't want to...PB

//That's what she said.................MS


#include <bits/stdc++.h>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define pb push_back
#define mkpr make_pair
#define fi(i,a,b) for (ll i=a;i<b;i++)
#define vll vector<ll>
#define vch vector<char>
#define vst vector<string>
#define vpll vector<pll>
#define vvl vector<vector<ll>>
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define mxe(v) *max_element(v.begin(),v.end())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define mll map<ll, ll>
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)
#define nl "\n"
#define sp " "
#define sz(x)  (int)x.size()

using namespace std;

double PI = (acos(-1));
ll md = 1000000007;
//ll md = 998244353;

ll pw(ll a, ll b){ll c=1,m=a;while (b){if (b&1)c=(c*m);m=(m*m);b/=2;}return c;}
ll pwmd(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1)c = ((c * m)) % md;m = (m * m) % md;b /= 2;}return c;}
ll modinv(ll n){return pwmd(n, md - 2);}
ll min(ll a,ll b){if(a>=b)return b;return a;}
ll nc2(ll n){return (1ll * n * (n - 1)) / 2;}
ll nsum(ll n){return (1ll * n * (n + 1)) / 2;}
bool prime(ll a){for(int i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}

#define MAX_SIZE 100005
void Sieve(vector<int> &primes){bool IsPrime[MAX_SIZE];memset(IsPrime, true, sizeof(IsPrime));
for (int p = 2; p * p < MAX_SIZE; p++){if (IsPrime[p] == true){
			for (int i = p * p; i < MAX_SIZE; i += p)IsPrime[i] = false;}}
	for (int p = 2; p < MAX_SIZE; p++)if (IsPrime[p])primes.push_back(p);}


vector<char> sml={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char> cap={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};





// Lets start ...


void solve(){
    ll n;
    cin>>n;
    ll l[n],sum=0;
    fi(i,0,n)cin>>l[i],sum+=l[i];
    ll ans=0;
    fi(i,0,n-1){
        sum-=l[i];
        ans=(ans+((l[i]*(sum%md))%md+md)%md+md)%md;
    }
    cout<<ans<<nl;
    
}

int main(){
    //vector<int> primes;
    //Sieve(primes);
    
    fast
    ll tests=1,cnt=0;
    //cin>>tests;
    while(tests--){
        solve();
    }
    

    return 0;
    }

// Done:)




Measured memory_bytes: 5220
#include <bits/stdc++.h>
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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x = c-a, y = d-b;
  for(int i = 0; i < x; i++) cout << 'R';
  for(int i = 0; i < y; i++) cout << 'U';
  for(int i = 0; i < x; i++) cout << 'L';
  for(int i = 0; i < y; i++) cout << 'D';
  cout << 'D';
  for(int i = 0; i < x+1; i++) cout << 'R';
  for(int i = 0; i < y+1; i++) cout << 'U';
  cout << 'L';
  cout << 'U';
  for(int i = 0; i < x+1; i++) cout << 'L';
  for(int i = 0; i < y+1; i++) cout << 'D';
  cout << 'R' << endl;
}

Measured memory_bytes: 256
N=int(input())

ans=dict()

results = ('AC','WA','TLE','RE')
for r in results:
    ans[r]=0

for i in range(N):
    S=input()
    ans[S]+=1

for r in results:
    # print(r,ans[r])
    p = "{0} x {1}".format(r,str(ans[r]))
    print(p)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define mod 1000000007
#define mod 998244353
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
    	int n,m,i,j;
    	cin>>n>>m;
    	int a[n+1];
    	vector<int>g[n+1];
    	for(i=1;i<=n;i++)
    	cin>>a[i];
    	int b[n+1]={0};
    	while(m--)
    	{
    		int u,v;
    		cin>>u>>v;
    		g[u].pb(v);
    		g[v].pb(u);
		}
		for(i=1;i<=n;i++)
		{
			for(j=0;j<(int)g[i].size();j++)
			{
				if(a[i]<=a[g[i][j]])
				{
					b[i]=1;
					break;
				}
			}
		}
		int cnt=0;
		for(i=1;i<n+1;i++)
		{
			if(b[i]==0)
			{
				cnt++;
			}
		}
		cout<<cnt;
	}

}

Measured memory_bytes: 9528
n = int(input())
a = list(map(int, input().split()))

count = 0

i = 1
k = 1
index = 0


for j in range(index, n):
    if a[j] == i:
        count += 1
        i += 1
        index = j

if index != 0 or (n == 1 and a[0] == 1) or (index == 0 and count == 1):
    print(n-count)
else:
    print("-1")

Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string t;
	cin >> t;
	int n = t.size();
	for(int i=0;i< n;i++){
		if(t[i]=='?')
			t[i]='D';
	}
	cout << t << endl;
    return 0;
    
}

Measured memory_bytes: 3752
using System;

namespace ALDS1_5_D
{
    class Program
    {
        public long count;

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] list = new int[N];
            for (int i = 0; i < N; i++)
            {
                list[i] = int.Parse(input[i]);
            }

            Program prg = new Program();
            prg.mergeSort(list, 0, list.Length);

            Console.WriteLine(prg.count);

        }


        public void merge(int[] list, int left, int middle, int right)
        {
            int n1 = middle - left;
            int n2 = right - middle;
            int[] L = new int[n1 + 1];
            int[] R = new int[n2 + 1];
            for (int i = 0; i < n1; i++)
            {
                L[i] = list[left + i];
            }
            for (int i = 0; i < n2; i++)
            {
                R[i] = list[middle + i];
            }

            L[n1] = int.MaxValue;
            R[n2] = int.MaxValue;

            int p = 0;
            int q = 0;
            for (int i = left; i < right; i++)
            {
                if (L[p] <= R[q])
                {
                    list[i] = L[p];
                    count += q;
                    p++;
                }
                else
                {
                    list[i] = R[q];
                    q++;
                }
            }
        }

        public void mergeSort(int[] list, int left, int right)
        {
            if (left + 1 < right)
            {
                int mid = (left + right) / 2;
                mergeSort(list, left, mid);
                mergeSort(list, mid, right);
                merge(list, left, mid, right);
            }
        }

    }
}

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

string s ;
typedef long long ll ;
const int mod = 1e9+7 ;
ll dp[100010][101][2];
int d ; 
ll calc(int idx , int sum , bool yes){
	if (idx == s.size()){
//		cout<<sum<<endl;
		if (sum== 0)
			return 1 ; 
		return 0 ;		
	}
	
	ll &ret = dp[idx][sum][yes] ; 
	if (ret != -1)return ret ; 
	
	ret = 0 ; 
	for (int i = 0 ; i<10 ; ++i){
		if (yes && i > s[idx]-'0')break;
		if (idx == 0){
			if (i == s[idx]-'0')
				ret += calc(idx+1 , (sum%d+i%d)%d , 1)%mod;
			else if (i<s[idx]-'0')
				ret += calc(idx+1 , (sum%d+i%d)%d , 0)%mod;
			else 
				break;
		}
		else {
			if (yes){
				if (i == s[idx]-'0')
						ret += calc(idx+1 , (sum%d+i%d)%d , 1)%mod;
				else 
						ret += calc(idx+1 , (sum%d+i%d)%d , 0)%mod;
			}else {
			
					ret += calc(idx+1 , (sum%d+i%d)%d , 0)%mod;
			}
		}
	
	}
	
	return ret%mod ; 
}

int main() {
	 
	cin>>s ; 
	scanf("%d" , &d) ; 
	memset(dp , -1 , sizeof dp) ; 
	int ans = calc(0 , 0 , 0) ; 
	printf("%lld" ,(ans-1+mod)%mod) ; 
	return 0;
}

Measured memory_bytes: 158848
import java.util.*;
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        HashMap<String, Integer> h = new HashMap<String, Integer>();
        String[] s = sc.nextLine().split(" ");String  l= "";
        for (int i = 0; i < s.length; i++) {
            if (l.length() < s[i].length()) l = s[i];
            if (h.containsKey(s[i]))h.put(s[i], h.get(s[i]) + 1);
            else h.put(s[i], 1);
            }
        int mcnt = 0;String mtd = "";
        for (String sd: h.keySet()) {
            if (mcnt< h.get(sd)) {mcnt = h.get(sd);mtd = sd;}
        }
        System.out.println(mtd + " " + l);
    }
 
}

Measured memory_bytes: 17112
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007

long mod_pow(long x, long n, long p=MOD){
  if(x==0) return 0;
  long res=1;
  x %= p;
  while(n>0){
    if(n&1) res=res*x%p;
    x=x*x%p;
    n>>=1;
  }
  return res;
}

int main(){
  long n,k;
  cin>>n>>k;

  vector<int> divs;
  for(long x = 1; x *x <= n; x++) if(n%x==0){
    divs.pb(x);
    divs.pb(n/x);
  }
  uniq(divs);

  map<long,long> cnt;
  rep(i,divs.size()){
    long d = divs[i];
    long tmp = mod_pow(k, (d+1)/2);
    rep(j,i) if(d%divs[j]==0){
      tmp = (tmp - cnt[divs[j]] + MOD) %MOD;
    }
    cnt[d] = tmp;
  }

  long ans = 0;
  for(auto &p : cnt){
    if(p.fi%2 == 0) ans += p.fi/2 * p.se;
    else ans += p.fi * p.se;
    ans %= MOD;
  }

  cout << ans %MOD << endl;


  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<math.h>
#include    <iomanip>
#include    <map>
#include    <set>
using namespace std;

int main(){
    int n1,n2,n3;
    while(cin>>n1>>n2>>n3&&n1!=0){
        int nn;
        cin>>nn;
        int chk[1000];
        for (int i=0; i<1000; i++) {
            chk[i]=2;
        }
        int a[1000],b[1000],c[1000],d[1000];
        for (int i=0; i<nn; i++) {
            cin>>a[i]>>b[i]>>c[i]>>d[i];
            if(d[i]==1){
                chk[a[i]]=1;
                chk[b[i]]=1;
                chk[c[i]]=1;
            }
        }
        for (int i=0; i<nn; i++) {
            if (chk[a[i]]==1&&chk[b[i]]==1&&chk[c[i]]==2&&d[i]==0) {
                chk[c[i]]=0;
            }
            if (chk[a[i]]==1&&chk[b[i]]==2&&chk[c[i]]==1&&d[i]==0) {
                chk[b[i]]=0;
            }
            if (chk[a[i]]==2&&chk[b[i]]==1&&chk[c[i]]==1&&d[i]==0) {
                chk[a[i]]=0;
            }
        }
        for (int i=0; i<n1+n2+n3; i++) {
            cout<<chk[i+1]<<"\n";
        }
    }
    return 0;
}

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

int main(void)
{
    string s;
    cin >> s;
    if (stoi(s) < 111)
        cout << "111" << endl;
    else if (s[0] == s[1] && s[1] == s[2])
        cout << s << endl;
    else
    {
        int x = s[0] - '0';
        x = 100 * x + 10 * x + x;
        if (x > stoi(s))
            cout << x << endl;
        else
            cout << x + 111 << endl;
    }
}


Measured memory_bytes: 3608
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
l = 0
r = 100001
for lr in LR:
  l = max(lr[0], l)
  r = min(r, lr[1])
  
print(r - l + 1 if r - l >= 0 else 0)

Measured memory_bytes: 27332
x, n = map(int, input().split())
p = list(map(int, input().split()))
y = None
if x in p:
    for i in range(102):
        if i in p:
            continue
        if y is None or abs(x - i) < y:
            y = abs(x - i)
            ans = i
else:
    ans = x
print(ans)


Measured memory_bytes: 9180
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


//const int mod=1000000007;
const int mod=998244353;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    cin >> n >> m;
    vpll v(n+1);
    for(int i=1; i<=n; i++){
        cin >> v[i].fi >> v[i].se;
    }
    ll dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=1; i<=n; i++){
        for(int j=0; j<=m; j++){
            if(j>=v[i].fi){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-v[i].fi]+v[i].se);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout << dp[n][m] << el;
    
    return 0;
}


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

#define N 200010
#define INF 0x3f3f3f3f
int n;
char s[N];
int f[N][2];

int main() {
	while (scanf("%d", &n) != EOF) {
		scanf("%s", s + 1);
		f[0][0] = 0; 
		f[1][0] = 0;
		f[1][1] = 1;
		for (int i = 2; i <= n; ++i) {
			//white
			if (s[i] == '.') {
				if (s[i - 1] == '.') {
					f[i][0] = f[i - 1][0];
				} else {
					f[i][0] = f[i - 1][1];  
				}
				f[i][1] = min(f[i - 1][0], f[i - 1][1]) + 1;
			} else {
				f[i][0] = min(f[i - 1][0], f[i - 1][1]);
				if (s[i - 1] == '.') {
					f[i][1] = f[i - 1][0] + 1;
				} else {
					f[i][1] = f[i - 1][1] + 1; 
				}
			}
		}
		printf("%d\n", min(f[n][0], f[n][1]));
	}
	return 0;
}


Measured memory_bytes: 2048
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N; cin >> N;
	while (N--) {
		int x, y, b, p; cin >> x >> y >> b >> p;
		int ans = x*b + y*p;
		ans = min(ans, (x*max(5, b) + y*(max(2, p))) / 5 * 4);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int x,y,z;
int k;
ll a[1005],b[1005],c[1005];

int main(){
  cin >> x >> y >> z >> k;
  rep(i,0,x) cin >> a[i];
  rep(i,0,y) cin >> b[i];
  rep(i,0,z) cin >> c[i];

  sort(a,a+x,greater<>());
  sort(b,b+y,greater<>());
  sort(c,c+z,greater<>());

  vector<ll> d,e;
  rep(i,0,x) rep(j,0,y) d.push_back(a[i]+b[j]);

  sort(d.begin(),d.end(),greater<ll>());

  rep(i,0,z) rep(j,0,min(k,(int)d.size())) e.push_back(c[i]+d[j]);

  sort(e.begin(),e.end(),greater<ll>());

  rep(i,0,k) cout << e[i] << endl;

  return 0;
}


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

int main(){
	ll N; cin>>N;
	vector<ll> A(N);
	for(ll i=0;i<N;i++)cin>>A[i];
	ll ans=0;
	for(ll i=0;i<N;i++){
		if(i==0)continue;
		else if(A[i-1]<=A[i])continue;
		else{
			ans+=A[i-1]-A[i];
			A[i]=A[i-1];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4844
int_n = int(input())

ar_int_s = list()

for i in range(int_n):
    ar_int_s.append(int(input()))


if sum(ar_int_s) % 10 != 0:
    print(sum(ar_int_s))
else:
    li_minus = list(filter(lambda x: x % 10 != 0, ar_int_s))
    if len(li_minus) == 0:
        print(0)
    else:
        print(sum(ar_int_s) - min(li_minus))



Measured memory_bytes: 2940
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

typedef long long LL;
const int N = 2020;
struct node {
	LL p, v;
}a[N];

LL f[N][N]; //dp[i][j] i表示移左边数量 j表示移右边数量

bool cmp(node x, node y) {
	return x.v > y.v;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].v;
		a[i].p = i;
	}
	sort(a, a + n, cmp);

	for (int i = 0; i < n; i++) {
		for (int j = 0; i + j < n; j++) {
			int t = i + j;
			f[i + 1][j] = max(f[i + 1][j], f[i][j] + abs(a[t].p - i) * a[t].v);
			f[i][j + 1] = max(f[i][j + 1], f[i][j] + abs(a[t].p - (n - 1 - j)) * a[t].v);
		}
	}

	LL res = 0;
	for (int i = 0; i <= n; i++) res = max(res, f[i][n - i]);
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 26352
/**
 *    author:  tourist
 *    created: 14.07.2018 15:15:06       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a < b || d < b) {
      cout << "No" << '\n';
      continue;
    }
    if (b <= c + 1) {
      cout << "Yes" << '\n';
      continue;
    }
    a -= b;
    if (a <= c) {
      a += d;
    }
    long long have = a - c - 1;
    assert(have >= 0);
    long long z = __gcd(b, d);
    if (b <= c + have % z + 1) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }
  }
  return 0;
}


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

int main() {
  int h,n;
  cin >> h >> n;
  vector<int> a(n),b(n);
  vector<int> dp(h+1,INF);
  dp[0]=0;
  for(int i=0; i<n; i++){
    cin >> a[i] >> b[i];
    for(int j=0; j<h; j++){
      int nj=min(h,j+a[i]);
      dp[nj]=min(dp[nj],dp[j]+b[i]);
    }
  }
  cout << dp[h] << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    string S; cin >> S;
    string p1 = "KIH", p2 = "B", p3 = "R";
    REP(i, 16){
        string cand = "";
        if(i >> 0 & 1) cand += "A"; cand += p1;
        if(i >> 1 & 1) cand += "A"; cand += p2;
        if(i >> 2 & 1) cand += "A"; cand += p3;
        if(i >> 3 & 1) cand += "A";
        if(cand == S){
            cout << "YES" << endl; return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
ll ans[maxn];
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll fastpow(ll a, ll b){
    ll calc=1;
    for(;b>=1LL;b/=2LL){
        if((b&1LL))calc=mult(calc,a);
        a=mult(a,a);
    }
    return calc;
}
ll soma(ll a,ll b){
    if(a+b>MOD)return a+b-MOD;
    else return a+b;
}
ll subt(ll a,ll b){
    if(a-b<0)return a-b+MOD;
    else return a-b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    per(i,k+1,1){
        ans[i]=fastpow((k/i),n);
        for(int j=2*i;j<=k;j+=i){
            ans[i]=subt(ans[i],ans[j]);
        }
    }
    ll res=0;
    rep(i,1,k+1)res=soma(res,mult(ans[i],i));
    cout<<res<<'\n';
    return 0;   
}   

Measured memory_bytes: 4396
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    ll set = n / (a + b);
    cout << set * a + min(a,(n - set * (a + b))) << "\n";

    return 0;
}

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

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

int main(){
    string s;
    cin>>s;
    if(s[0]==s[2]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second

using namespace std;

int nums[55];

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

  REP(i,0,M){
    int a, b;
    cin>>a>>b;
    nums[a-1]++;
    nums[b-1]++;
  }

  REP(i,0,N){
    cout<<nums[i]<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    ll N, X;
    cin >> N >> X;
    ll b[N], l[N], u[N];
    rep(i, N) cin >> b[i] >> l[i] >> u[i];
    ll S = 0;
    rep(i, N) S += b[i]*l[i];
    pli p[N];
    rep(i, N) p[i] = pli(b[i]*l[i]+(X-b[i])*u[i], i);
    sort(p, p+N, greater<pli>());
    ll ans = INF;
    ll sum[N+1];
    sum[0] = 0;
    rep(i, N) sum[i+1] = sum[i] + p[i].first;
    rep(i, N){
        ll s = p[i].first;
        int j = p[i].second;
        if(sum[i] < S){
            ll k = lower_bound(sum, sum+N+1, S)-sum;
            ll rem = S-(sum[k]-s);
            ll n;
            if(rem <= b[j]*l[j]) n = (rem+l[j]-1)/l[j];
            else n = b[j]+(rem-b[j]*l[j]+u[j]-1)/u[j];
            ans = min(ans, (k-1)*X+n);
        }
        else{
            ll k = lower_bound(sum, sum+N+1, S-s)-sum;
            ll rem = S-sum[k];
            ll n;
            if(rem < 0) n = 0;
            elif(rem <= b[j]*l[j]) n = (rem+l[j]-1)/l[j];
            else n = b[j]+(rem-b[j]*l[j]+u[j]-1)/u[j];
            ans = min(ans, k*X+n);
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;

using namespace std;

int c(int i, int k) {

	if (i == k || k == 0) 
		return 1;
	
	return c(i - 1, k - 1) + c(i - 1, k);
}

int main() {

	int n, m;
	cin >> n >> m;

	int ans = 0;

	if (n >= 2) {
		ans += c(n,  2);
	}
	
	if (m >= 2)
		ans += c(m,  2);

	cout << ans << endl;

}

Measured memory_bytes: 256
N = int(input())
F = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]

import itertools

ans = -10**10
for I in itertools.product([0,1],repeat=10):
    if sum(list(I))==0:
        continue
    
    TMP = 0
    for i in range(N):
        tmp = 0
        for j in range(10):
            if F[i][j]==1 and I[j]==1:
                tmp+=1
        TMP += P[i][tmp]
    
    ans = max(ans,TMP)

print(ans)
         


Measured memory_bytes: 68756
S = input()

halfLength = len(S) // 2
mae = S[:halfLength] 
ushiro = ''.join(list(reversed(S[halfLength+ 1:])))
answer = 'No'
if mae == ushiro:
    mae_halflen =  len(mae) // 2
    mae_mae = mae[mae_halflen:] 
    mae_ushiro = ''.join(list(reversed(mae[:mae_halflen + len(mae) % 2])))
    if (mae_mae == mae_ushiro):
         answer = 'Yes'
print(answer)

Measured memory_bytes: 3064
//#pragma GCC optimize("Ofast")
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define lli long long int
#define ld long double
#define vec vector
#define forn(a) for(lli a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main(){
  IOS;

  int A, B;

  char a, b; cin>>a>>b;
  A = (a-'0')*10 + (b-'0');

  cin>>a>>b;
  B = (a-'0')*10 + (b-'0');

  bool r1 = 1<=A && A<=12;
  bool r2 = 1<=B && B<=12;

  if(!r1 && !r2) cout<<"NA"<<endl;
  elif( r1 && r2 ) cout<<"AMBIGUOUS"<<endl;
  elif( r2 ) cout<<"YYMM"<<endl;
  else cout<<"MMYY"<<endl;

  return 0;
}

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

size_t N;

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

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

  size_t A[N];
  for (i = 0; i < N; i++) {
    cin >> A[i];
  }

  size_t L[N + 1], R[N + 1];
  L[0] = 0;
  R[N] = 0;

  for (i = 1; i < N + 1; i++) {
    L[i] = gcd(L[i - 1], A[i - 1]);
  }

  for (i = N - 1; i >= 0; i--)
    R[i] = gcd(R[i + 1], A[i]);

  // for (i = 0; i < N; i++) {
  //   cout << "L = " << L[i];
  //   cout << " R = " << R[i];
  //   cout << " GCD = " << gcd(L[i], R[i + 1]) << "\n";
  // }
  size_t ans = 0;
  for (i = 0; i < N; i++)
    ans = max(gcd(L[i], R[i + 1]), ans);

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 2560
#!/usr/bin/env python3
import sys
from itertools import chain

# form bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter
# import numpy as np


def solve(N: int, K: int, p: "List[int]"):
    p = sorted(p)
    return sum(p[:K])


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, K, p = map(int, line.split())
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, K, p)
    print(answer)


if __name__ == "__main__":
    main()


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

#define LL long long
#define ULL unsigned long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 53;

int n;
int a[MAXN], b[MAXN];
AR ( ULL ) dp[MAXN][MAXN];

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d", &n );
	lpi ( i, 1, n ) scanf ( "%d", &a[i] );
	lpi ( i, 1, n ) scanf ( "%d", &b[i] );
}

void work ()
{
	// main work

	lp ( i, 0, MAXN ) {
		dp[i][i].push_back ( 0 );
		lp ( j, 0, i ) {
			lpi ( k, 1, i ) {
				int t = i % k;
				for ( auto x : dp[t][j] ) dp[i][j].push_back ( x | ( 1ULL << k ) );
			}
			sort ( dp[i][j].begin (), dp[i][j].end () );
			dp[i][j].erase ( unique ( dp[i][j].begin (), dp[i][j].end () ), dp[i][j].end () );
		}
	}

	lpi ( i, 1, n ) {
		if ( dp[a[i]][b[i]].empty () ) {
			cout << -1 << endl;
			return;
		}
	}

	LL ans = 0;
	bool flag, f;
	lpdi ( j, MAXN-1, 0 ) {
		flag = true;
		lpi ( i, 1, n ) {
			AR ( ULL ) &ar = dp[a[i]][b[i]];
			f = false;
			for ( auto x : ar ) {
				if ( ! ( ( x & ( ~ans ) ) & ( ~( ( 1ULL << j ) - 1 ) ) ) ) {
					f = true;
					break;
				}
			}
			if ( !f ) {
				flag = false;
				break;
			}
		}

		if ( !flag ) ans |= 1ULL << j;
	}

	cout << ans << endl;
}

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

int main() {
  vector<int> v(5);
  for (int i=0; i<5; i++) { 
    cin >> v[i];
    if (v[i] == 0) {
      cout << i+1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

int bubbleSort(vector<int> &A)
{
    bool state = true;
    int cnt = 0;
    while (state)
    {
        state = false;
        repi(i, A.size(), 1)
        {
            if (A[i] < A[i - 1])
            {
                swap(A[i], A[i - 1]);
                state = true;
                cnt++;
            }
        }
    }
    return cnt;
}

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    repi(i, n, 0)
    {
        cin >> A[i];
    }
    int t = bubbleSort(A);
    repi(i, n, 0)
    {
        cout << A[i] << ((i + 1) % n ? " " : "");
    }
    cout << endl
         << t << endl;
    return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

pair<ll, ll> enumDivisor(long long n) {
    pair<ll, ll> res;
    for (long long i = 1; i*i <= n; i++) {
        if (n%i) continue; 
        res = pair<ll, ll>(i, n/i);
    }
    return res;
}

int f(ll a, ll b) {
    ll x = max(a, b);
    int res = 0;
    while (x > 0) {
        x /= 10;
        res++;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin >> n;
    pair<ll, ll> p = enumDivisor(n);
    int ans = f(p.fi, p.se);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
int main()
{
	int i, j , n;
	int a, b, c;
	char s[1005];
	int aa[1005];
	scanf("%d %d %d", &a, &b, &c);
	if(a > c || a + b < c)
	{
		printf("NO\n");
	}
	else
	{
		printf("YES\n");
	}
	return 0;
}

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

using namespace std;

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

  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if ((a & 1) == 1) {
      cout << "first\n";
      return 0;
    }
  }
  cout << "second\n";
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int N=2e5+11,INF=~0u>>2;
struct Edge{int nxt,to;}edge[N<<1];
int n,head[N],num_edge,tot1,tot2,tag,col[N],tmp1,tmp2,p[N],tot;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
void add_edge(int from,int to){
	edge[++num_edge].nxt=head[from];
	edge[num_edge].to=to;
	head[from]=num_edge;
}
void dfs1(int u,int fa,int cnt){
	if(u==n){
		cnt--;
		tot1=(cnt+1)/2;tot2=cnt-tot1;
		tmp1=tot1;tmp2=tot2;
		tag=1;
		return;
	}
	for(int i=head[u];i&&tag==0;i=edge[i].nxt){
		int v=edge[i].to;
		if(v!=fa){
			if(tag==0) dfs1(v,u,cnt+1);
			if(tag){
				if(tmp2) tmp2--,col[u]=2;
				else col[u]=1;
				p[++tot]=u;
			}
		}
	}
}
void dfs2(int u){
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(col[v]==0){
			col[v]=col[u];
			if(col[u]==1) tot1++;
			else tot2++;
			dfs2(v);
		}
	}
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();
	for(int i=1;i<n;++i){
		int x=read(),y=read();
		add_edge(x,y);add_edge(y,x);
	}
	tot1=tot2=1;
	col[1]=1;col[n]=2;
	dfs1(1,0,0);
	for(int i=1;i<=tot;++i) dfs2(p[i]);dfs2(1);dfs2(n);
	if(tot1>tot2) puts("Fennec");
	else puts("Snuke");
	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n; std::cin >> n;
    vi l(n); rep(i, n) std::cin >> l[i];
    sort(rng(l));
    int ans = 0;
    rep(i, n) srep(j, i+1, n) srep(k, j+1, n) {
        if (l[i] == l[j] || l[j] == l[k] || l[i] == l[k]) continue;
        if (l[i] + l[j] > l[k]) {
          ans++;
        }
    }
    std::cout << ans << "\n";
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

long long gcd(long long m, long long n) {
    return n != 0 ? gcd(n, m % n) : m;
}

int main() {
    int n, k;
    cin >> n >> k;
    int a;
    int g;
    int m = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (n == 0) {
            g = a;
        } else {
            g = gcd(g, a);
        }
        m = max(m, a);
    }

    if (k % g == 0 && k <= m) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
S = list(map(int, input().split()))

for i in range(N):
    if i==N-1:
        print(S[i])
    else:
        print(S[i],end=' ')

for i in range(1,N):
    key = S[i]
    if key < max(S[0:i]):
        S.pop(i)
        x = 0
        for k in range(i):
            if x==1:
                continue
            if key < S[k]:
                S.insert(k,key)
                x += 1
    
    for k in range(N):
        if k==N-1:
            print(S[k])
        else:
            print(S[k],end=' ')


Measured memory_bytes: 5980
n,m=map(int,input().split())
e=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    e[a].append(b)
    e[b].append(a)

fp=set()
def rec(cur):
    ret = 0
    fp.add(cur)
    if len(fp) == n:
        fp.remove(cur)
        return 1
    for nex in e[cur]:
        if nex not in fp:
            ret += rec(nex)
    fp.remove(cur)
    return ret
print(rec(0))

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
	char o[100],e[100];
	scanf("%s %s",o,e);
 
	int i=0;
	while(1==1){
		printf("%c",o[i]);
		if(e[i]=='\0'){
			break;
		}
		printf("%c",e[i]);
		i++;
		if(o[i]=='\0'){
			break;
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		
		if( X == 7 || X == 5 || X== 3 ) {
			System.out.println("YES\n");
		}else {
			System.out.println("NO\n");
		}
		
		sc.close();
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main() 
{
    fast();
    ll n;
    cin>>n;
    vi a(n);
    cin>>a;
    sort(all(a));
    ll ans=a.back();
    ll index=n-2;
    for(ll i=0;i<n-2;i++)
    {
        ll in = index-i/2;
        ans+=a[in];
    }
    cout<<ans<<nl;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int h, w, a, b; 
    cin >> h >> w >> a >> b;
    vvint ans(h,vint(w,0));
    for (int i = 0; i < b; i++) {
        for (int j = a; j < w; j++) {
            ans[i][j] = 1;
        }
    }
    for (int i = b; i < h; i++) {
        for (int j = 0; j < a; j++) {
            ans[i][j] = 1;
        }
    }
    rep(i,h) {
        rep(j,w) cout << ans[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 7540
import sys
from math import ceil

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = S()
    sum_ = 0
    for i in n:
        sum_ += int(i)
    # print(sum_ // 9)
    if (sum_ % 9) == 0:
        print('Yes')
    else:
        print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 11900
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def aaa(num):
    return 1/num

def main():
    n = int(input())
    a = Input()
    ans = 1 / sum(aaa(i) for i in a)
    print(ans)
main()

Measured memory_bytes: 8988
import java.util.*;

import static java.lang.System.*;

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

        boolean[] exists = new boolean['z' - 'a' + 1];
        for (int i = 0; i < S.length(); i++) {
            exists[S.charAt(i) - 'a'] = true;
        }

        if (S.length() < 26) {
            out.print(S);
            for (int i = 0; i <= 'z' - 'a'; i++) {
                if (!exists[i]) {
                    out.println((char) ('a' + i));
                    return;
                }
            }
        } else {
            PriorityQueue<String> cand = new PriorityQueue<>();
            for (int i = S.length() - 1; i > 0; i--) {
                char changeChar = S.charAt(i);

                loop:
                for (int k = i - 1; k >= 0; k--) {
                    if (S.charAt(k) < changeChar) {
                        StringBuilder str = new StringBuilder();
                        for (int j = 0; j < S.length(); j++) {
                            if (j == k) {
                                str.append(changeChar);
                                cand.add(str.toString());
                                break loop;
                            } else {
                                str.append(S.charAt(j));
                            }
                        }
                    }
                }
            }

            if(cand.isEmpty()) {
                out.println(-1);
            } else {
                out.print(cand.poll());
            }
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    int a,b;
    int d,r;
    double f;
    cin>>a>>b;
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n",d,r,f);
    
}



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

int n, tmp, mn=1e9, i;
int_fast64_t cnt;
bool minus, zero;

int main(){
        scanf("%d", &n);
        for(i=0; i<n; i++){
                scanf("%d", &tmp);
                minus ^= (tmp<0);
                zero |= (tmp==0);
                if(mn>abs(tmp)) mn = abs(tmp);
                cnt += abs(tmp);
        }
        if(!minus|zero) printf("%ld\n", cnt);
        else printf("%ld\n", cnt-mn*2);
        return 0;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
b = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
kazu = 0
c_a = 0
c_b = 0
time = 0

a = [0]+a
b = [0]+b

for i in range(1,n+1):
    a[i]= a[i-1]+a[i]
for i in range(1,m+1):
    b[i]= b[i-1]+b[i]

for i in range(0,n+1):
    for j in range(max(0,kazu-i+1),m+1):
        time = a[i] + b[j]
        if time > k:
            break
        kazu = i + j

print(kazu)


Measured memory_bytes: 40756
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

ll mod = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll a[26];
  for (int i = 0; i < 26; i++)
  {
    a[i] = 0;
  }
  for (int i = 0; i < s.size(); i++)
  {
    a[s[i] - 'a']++;
  }
  ll ans = 1;
  for (int i = 0; i < 26; i++)
  {
    ans *= a[i] + 1;
    ans %= mod;
  }
  cout << ans - 1 << "\n";
}

Measured memory_bytes: 512
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    map<ll,ll> res;
    REP(i,N) {
        int a;
        cin >> a;
        if(res.count(a)) res[a]++;
        else res[a] = 1;
    }
    ll ans = 0;
    for(auto x: res) {
        if(x.first > x.second) ans += x.second;
        else ans += x.second-x.first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6272