akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,n) for(int i=0;i<(int)n;++i)

#define CLEAR(a) memset((a), 0, sizeof(a))

inline int toInt(string s) { int x; istringstream iss(s); iss >> x; return x; }
template<class T> inline string toString(T x) { ostringstream oss; oss <<x ; return oss.str(); }
template<class T> inline T sqr(T x) { return x * x; }

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(int argc, char *argv[]) {
    int rate;
    cin >> rate;

    if (rate >= 2800) cout << "AGC\n";
    else if (rate >= 1200) cout << "ARC\n";
    else cout << "ABC\n";

    return 0;
}


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

static const int UNVISITED = 0;  // 頂点の訪問状態:未訪問
static const int VISITED = 1;    // 頂点の訪問状態:訪問済み

// 頂点s+1から出発する場合の幅優先探索
void bfs(int s, int n, vector<vector<int>>& M, vector<int>& d) {
    static const int INFTY = (1 << 21);

    // 今回は標準ライブラリのキューを使う
    queue<int> q;
    vector<int> status(n);  // status:頂点の訪問状態
    for (int i = 0; i < n; ++i) {
        status[i] = UNVISITED;
    }

    // 各種初期化処理
    // 出発する頂点をpush
    q.push(s);
    status[s] = VISITED;
    // 距離格納配列の初期化
    for (int i = 0; i < n; ++i) {
        d[i] = INFTY;
    }
    // 出発点の距離は0
    d[s] = 0;

    // 探索開始
    while (!q.empty()) {
        // 先頭を取り出してpopする(訪問)
        int u = q.front();
        q.pop();

        // TODO:
        // uに隣接する頂点で訪問済みでない頂点をキューにpushし、
        // 各頂点の距離を記録する
        for (int v = 0; v < n; ++v) {
            if (M[u][v] == 0) {
                continue;
            }
            if (status[v] == VISITED) {
                continue;
            }
            q.push(v);
            status[v] = VISITED;
            d[v] = d[u] + 1;
        }
    }

    // 頂点1から各頂点までの距離を出力
    // INFTYが入っていた場合は到達不可能なので-1を出力
    for (int i = 0; i < n; ++i) {
        cout << i + 1 << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main() {
    static const int N = 110;
    // n : グラフの頂点数
    // M : 隣接行列(グラフを表現)
    // d : 任意の頂点から各頂点への距離格納配列(INFTYで初期化)
    int n, u, k, v;
    vector<int> d(N);
    vector<vector<int>> M(N, vector<int>(N));

    cin >> n;

    // グラフの初期化
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            M[i][j] = 0;
        }
    }

    // TODO:
    // 入力を受け取って、隣接行列に反映する
    // (u->vにつながっている場合には、M[u-1][v-1]=1にする)
    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            M[u - 1][v - 1] = 1;
        }
    }

    bfs(0, n, M, d);

    return 0;
}


Measured memory_bytes: 3212
package main
import "fmt"
var h,w int
func main() {
  fmt.Scan(&h,&w)
  a := make([][]int,h)
  for i:=0;i<h;i++ {
    a[i] = make([]int,w)
    var s string
    fmt.Scan(&s)
    for j:=0;j<w;j++ {
      fmt.Sscanf(s[j:j+1],"%c",&a[i][j])
      a[i][j] -= 97
    }
  }
  if any(a) {
    fmt.Println("YES")
  } else {
    fmt.Println("NO")
  }
}
func any(a [][]int) bool {
  pair := enum_pair(h)
  for _,p := range pair {
    b := make([][]int,h)
    for i:=0;i<h/2;i++ {
      b[i] = a[p[2*i]]
      b[h-1-i] = a[p[2*i+1]]
    }
    if h%2 == 1 { b[h/2] = a[p[h-1]] }
    if check(b) { return true }
  }
  return false
}
func enum_pair(n int) [][]int {
  if n == 1 { return [][]int{{0}} }
  if n%2 == 0 {
    a := make([]int,n)
    for i:=0;i<n;i++ { a[i] = i }
    return enum_rec(a)
  }
  ret := [][]int{}
  for i:=0;i<n;i++ {
    x := []int{}
    for j:=0;j<n;j++ {
      if j != i { x = append(x,j) }
    }
    tmp := enum_rec(x)
    for j:=0;j<len(tmp);j++ {
      tmp[j] = append(tmp[j],i)
    }
    ret = append(ret,tmp...)
  }
  return ret
}
func enum_rec(x []int) [][]int {
  p := x[0]
  a := x[1:]
  n := len(a)
  if n == 1 { return [][]int{{p,a[0]}} }
  ret := [][]int{}
  for i:=0;i<n;i++ {
    b := []int{}
    for j:=0;j<n;j++ {
      if j != i { b = append(b,a[j]) }
    }
    rec := enum_rec(b)
    for _,r := range rec {
      tmp := append([]int{p,a[i]},r...)
      ret = append(ret,tmp)
    }
  }
  return ret
}
func check(a [][]int) bool {
  used := make([]bool,w)
  flag := w%2 == 0
  Outside:
  for i:=0;i<w;i++ {
    if used[i] { continue }
    Middle:
    for j:=i+1;j<w;j++ {
      if used[j] { continue }
      for k:=0;k<h;k++ {
        if a[k][i] != a[h-1-k][j] { continue Middle }
      }
      used[i] = true
      used[j] = true
      continue Outside
    }
    if flag { return false }
    for k:=0;k<h/2;k++ {
      if a[k][i] != a[h-1-k][i] { return false }
    }
    used[i] = true
    flag = true
  }
  return true
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s, t; cin >> s >> t;
    cout << t << s << endl;
}

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

typedef long long ll;
#define pb push_back

int main(){
    ll x,k,l;
    cin>>x>>k>>l;
    if(l>=abs(x)){
        if(k%2==0) cout<<abs(x);
        else cout<<l-abs(x);
    }else{
        if(k>=abs((x/l))){
            k = k - abs(x/l);
            x = abs(x) - abs(x/l)*l;
            if(k%2==0) cout<<x;
            else cout<<(min(abs(l-x),abs(l+x)));
        }else{
            x = abs(abs(x) - l*k);
            cout<<x;
        }
    }
    return 0;
}


Measured memory_bytes: 3592
[H,W,K] = [int(x) for x in input().split()]
data = [input() for x in range(H)]

result = 0

for y in range(1 << H):
    for x in range(1 << W):
        count = 0
        for i,d1 in enumerate(data):
            if (y >> i) & 1:
                continue
            for j,d2 in enumerate(d1):
                if (x >> j) & 1:
                    continue
                if d2 == '#':
                    count += 1
        if count == K:
            result += 1

print(result)


Measured memory_bytes: 9200
import java.util.Scanner;
public class Main {
	public static void main(String []args) {
		Scanner sc=new Scanner(System.in);
		int a,b;
		while(sc.hasNextInt()) {
		 a=sc.nextInt();
		 b=sc.nextInt();
		if((a<10)&&(a>0)&&(b>0)&&(b<10)) {
			System.out.println(a*b);
		}
		else {
			System.out.println(-1);
		}
		}
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 998244353
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 
const int N=2e5+10;
int fact[N];
int inv[N];
int power(int x, unsigned int y, unsigned int m) 
    { 
        if (y == 0) 
            return 1; 
        int p = power(x, y/2, m) % m; 
        p = (p * p) % m; 
      
        return (y%2 == 0)? p : (x * p) % m; 
    } 

int ncr(int n,int r){
	if(n<r) return 0;
	int z=fact[n];
	z*=inv[r];
	z%=M;
	z*=inv[n-r];
	z%=M;
	return z;
}
int solve(){
	fact[0]=1;
	for(int i=1;i<N;i++) fact[i]=(fact[i-1]*i)%M;
	for(int i=0;i<N;i++) inv[i]=power(fact[i],M-2,M);
	int n,m,k;cin>>n>>m>>k;
	int ans=0;
	for(int i=0;i<=k;i++)
	{
		int h=m*ncr(n-1,i);
		h%=M;
		h*=power(m-1,n-i-1,M);
		h%=M;
		ans+=h;
		ans%=M;
	}
	cout<<ans;



    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 6780
import java.util.*;
 
class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
      	int C = sc.nextInt();
      	int mas = Math.min(B/A,C);
      
      System.out.print(mas);
      
 
    }
}

Measured memory_bytes: 23380
import collections
import sys
n,m,k = map(int,sys.stdin.readline().split())
parent = range(0, n+1)
sizes = [1] * (n + 1)
hd = [1] * (n + 1) 

def f(parent, u):
	if parent[u] != u:  parent[u] = f(parent, parent[u])
	return parent[u]

for a,b in [map(int,sys.stdin.readline().split()) for _ in range(m)]:

	pa,pb = f(parent, a), f(parent, b)
	hd[a] +=1
	hd[b] +=1

	if pa != pb:
		if sizes[pa] >= sizes[pb]:
			parent[pb] = pa
			sizes[pa] += sizes[pb]
		else:
			parent[pa] = pb
			sizes[pb] += sizes[pa]

for c,d in [map(int,sys.stdin.readline().split()) for _ in range(k)]:
	pc,pd = f(parent, c), f(parent, d)
	if (pc == pd):
		hd[c] += 1
		hd[d] += 1

print ' '.join([str(sizes[f(parent,u)] - hd[u])  for u in range(1, n+1)])

Measured memory_bytes: 59164
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>

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

using namespace std;

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

    if (N % 500 <= A)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        // 整数の入力
        //int a = int.Parse(Console.ReadLine());
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int b = int.Parse(input[0]);
        int c = int.Parse(input[1]);
        // 文字列の入力
        //string s = Console.ReadLine();

        //積が奇数なら Odd と、 偶数なら Even と出力せよ。
        //出力
        Console.WriteLine(b * c % 2  == 0 ? "Even" : "Odd");
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,x,c[101],a[101][101];
int ans=1e9;
struct level {
	int l[13];
	level() {
		for(int i=1; i<=m; i++)
			l[i]=0;
	}
};
void dfs(int now,int tot,level cur) {
	if(now==n+1) {
		bool tag=1;
		for(int i=1; i<=m; i++)
			if(cur.l[i]<x)
				tag=0;
		if(tag)
			ans=min(ans,tot);
		return;
	}
	if(tot>=ans)
		return;
	level newl=cur;
	for(int i=1; i<=m; i++)
		newl.l[i]+=a[now][i];
	dfs(now+1,tot+c[now],newl);
	dfs(now+1,tot,cur);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n>>m>>x;
	for(int i=1; i<=n; i++) {
		cin>>c[i];
		for(int j=1; j<=m; j++)
			cin>>a[i][j];
	}
	dfs(0,0,level());
	if(ans==1e9) cout<<-1;
	else cout<<ans;
	return 0;
}

Measured memory_bytes: 3600
# ABC075b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

h, w = map(int, input().split())
s = [input() for _ in range(h)]

ans = [[0] * w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if (s[i][j] == '#'):
            for k in range(-1, 2):
                for l in range(-1, 2):
                    if (0 <= i+k < h and 0 <= j+l < w and ans[i+k][j+l] != '#'):
                        ans[i+k][j+l] += 1
            ans[i][j] = '#'

for i in ans:
    print(*i, sep='')

Measured memory_bytes: 3444
#!/usr/bin/ruby
# -*- coding: utf-8 -*-

pass = gets.chomp
if pass.length < 6
  puts "INVALID"
elsif (pass =~ /[0-9]/).nil?
  puts "INVALID"
elsif (pass =~ /[A-Z]/).nil?
  puts "INVALID"
elsif (pass =~ /[a-z]/).nil?
  puts "INVALID"
else
  puts "VALID"
end

Measured memory_bytes: 6096
n = int(input())
s = list(input())
alph = ["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"]
ans = 0
for i in range(1, n):
    x = s[0 : i]
    y = s[i : n]
    c = 0
    for j in alph:
        if j in x and j in y:
            c += 1
    if ans < c:
        ans = c
print(ans)

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

int main(void){
    int k, x;
    cin >> k;
    cin >> x;

    for(int i = x - (k - 1); i <= x + (k - 1); i++) {
        cout << i;
        if(i != x + (k - 1)){
            cout << " ";
        }else {
            cout << endl;
        }
    }
    return 0;
}

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

#define int long long 

const int N = 1e5 + 5;

vector<int> adj[N];

int in_degree[N];

int dist[N];

bool visited[N];

void dfs(int par)
	{
		visited[par] = true;
		for(int b:adj[par])
		{
			dist[b] = max(dist[par] + 1,dist[b]);
			--in_degree[b];
			if(in_degree[b] == 0)
			dfs(b);
		}
	}

signed main()
{
	int n,m;
	cin >> n >> m;
	while(m--)
	{
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		++in_degree[v];
	}
	
	for(int i=1;i<=n;++i)
	{
		if(in_degree[i] == 0 and visited[i] == false)
		dfs(i);
	}
	
	int ans = 0;
	
	for(int i=1;i<=n;++i)
	{
		ans = max(ans,dist[i]);
	}
	
	cout << ans;
}



Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll n, x; cin >> n >> x;
	VI p(n+1); p[0]=1;
	REP(i,n) p[i+1]=p[i]*2+1;
	VI a(n+1); a[0]=1;
	REP(i,n) a[i+1]=a[i]*2+3;
	ll ans=0;
	for(int i=n;i>0;i--){
		if(x>=a[i]){
			ans+=p[i];
			x-=a[i];
			if(x>=1){
				ans++;
				x--;
			}
		}
		x--;
	}
	x=max((ll)0,x);
	cout << ans+min((ll)3,x) << endl;
}

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

int main() {
  string a, b;
  cin >> a >> b;

  int n = stoi(a + b);
  double sf = floor(sqrt(n));
  if (sf * sf == n) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {

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

		int[] A = new int[N];
		for(int i=0; i<N; i++)
			A[i] = sc.nextInt();

		for(int i=0; i<N; i++){ 
			String id = "node "+(i+1)+": ";
			String k = "key = "+A[i]+", ";
			String p = ( (i!=0)? "parent key = "+A[(i+1)/2-1]+", " : "" );
			String lk = ( 2*(i+1)<=N?  "left key = "+A[2*(i+1)-1]+", " : "");
			String rk = ( 2*(i+1)+1<=N? "right key = "+A[2*(i+1)]+", " : "");
			
			System.out.print(id + k + p + lk + rk + "\n");
		}

	}
}

	

Measured memory_bytes: 27644
def main():
    cnt = 0
    for _ in range(m):
        x, y = map(int, input().split())
        unite(x, y)
    for i in range(1, n+1):
        if same(i, p[i-1]):
            cnt += 1
    print(cnt)
        
def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]

def same(x, y):
    return root(x) == root(y)

def unite(x, y):
    x = root(x)
    y = root(y)
    if x != y:
        par[x] = y

if __name__ == "__main__":
    n, m = map(int, input().split())
    p = list(map(int, input().split()))
    par = [0] + [i for i in range(1, n+1)]
    main()


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

using namespace std;

typedef long long ll;

int main()
{
    int N,D;
    while(cin>>N>>D)
    {
        int p,k;
        k=2*D+1;
        p=N/k;
        if(N%k)
            cout<<p+1<<endl;
        else
            cout<<p<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

n=int(input())
*a,=map(int,input().split())

cnt=sorted(list(Counter(a).items()),key=lambda x:x[0])

if len(cnt)==1 and cnt[0][0]==0:
    print('Yes')
elif n%3==0 and len(cnt)==2 and cnt[0][0]==0 and cnt[0][1]==n//3:
    print('Yes')
elif n%3==0 and len(cnt)==3 and cnt[0][0]^cnt[1][0]^cnt[2][0]==0 and cnt[0][1]==n//3 and cnt[1][1]==n//3 and cnt[2][1]==n//3:
    print('Yes')
else:
    print('No')


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

int main(){
    // input
    int N, tmp;
    cin >> N;
    vector<int> A(N);
    for( int i=0; i<N; i++ ){
        cin >> tmp;
        A[tmp-1] = i+1;
    }

    // output
    for( int i=0; i<N; i++ ){
        cout << A[i] << endl;
    }
} 

Measured memory_bytes: 1152
#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;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    map<char, int> mp;
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            mp[s[j]]++;
        }
    }
    int cnt4 = 0;
    int cnt2 = 0;
    int cnt1 = 0;
    for (auto&& p : mp) {
        cnt4 += p.se/4;
        p.se -= (p.se/4) * 4;
        cnt2 += p.se/2;
        p.se -= (p.se/2) * 2;
        cnt1 += p.se;
    }
    if (h % 2 == 0 && w % 2 == 0) {
        if (h * w == 4 * cnt4) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (h % 2 == 0) {
        if (h * w == 4 * cnt4 + 2 * cnt2 && cnt2 <= h/2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (w % 2 == 0) {
        if (h * w == 4 * cnt4 + 2 * cnt2 && cnt2 <= w/2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if (cnt1 == 1 && cnt2 <= (h+w-2)/2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

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

using namespace std;

const int N = 310;
const int M = 110;

double dp[N][N][N];
bool f[N][N][N];
int n, cnt[4];

double solve(int x, int y, int z) {
  if (x == 0 && y == 0 && z == 0) return 0;
  if (f[x][y][z]) return dp[x][y][z];
  dp[x][y][z] = 1.0;
  if (x > 0) dp[x][y][z] += (1.0 * x / n) * solve(x - 1, y, z);
  if (y > 0) dp[x][y][z] += (1.0 * y / n) * solve(x + 1, y - 1, z);
  if (z > 0) dp[x][y][z] += (1.0 * z / n) * solve(x, y + 1, z - 1);
  dp[x][y][z] *= (1.0 * n / (x + y + z));
  f[x][y][z] = true;
  return dp[x][y][z];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x; 
    cin >> x;
    cnt[x]++;
  }
  memset(f, false, sizeof f);
  cout << fixed << setprecision(10) << solve(cnt[1], cnt[2], cnt[3]) << "\n";
  return 0;
}


Measured memory_bytes: 256256
x = [int(input()) for i in range(3)]

if x[0] >= x[1]:
  print(x[2]//x[0]+1 if x[2]%x[0]!=0 else x[2]//x[0])
else:
  print(x[2]//x[1]+1 if x[2]%x[1]!=0 else x[2]//x[1])

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

using namespace std;

int a[3010];
long long dp[3010][3010];
int n;

int main(){
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = n - 1; i >= 0; i--){
        for(int j = i + 1; j <= n; j++){
            dp[i][j] = max(a[i] - dp[i + 1][j], a[j - 1] - dp[i][j - 1]);
        }
    }
    cout << dp[0][n] << '\n';
}

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

int main(){

	int n, v[26];
	int w[7] = {31, 26, 21, 16, 11, 6, 1};
	
	while(cin >> n){
		if(n == 0) break;
		for(int i=0; i<n; i++){
			cin >> v[i];
		}
		
		cout << 31 << endl;
		for(int i=0; i<6; i++){
			cout << w[i] - v[i%n] << endl;
			cout << w[i+1] << endl;
		}
		cout << 0 << endl;
	}

	return 0;

}

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

using namespace std;

//#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

int main() {
    ll N; cin >> N;
    if(N%10 == 7 || N/10%10 == 7 || N/100%10 ==7){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int ans = 0;

    if (A + B <= 2 * C) ans = A * X + B * Y;
    else {
        if (X < Y) ans = min(C * 2 * X + B * (Y - X), C * 2 * Y);
        else ans = min(C * 2 * Y + A * (X - Y), C * 2 * X);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
import sys
input = sys.stdin.readline

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

n=I()
eva=[]
for i in range(n):
    eva.append(input().rstrip().split(" "))
for i in range(n):
    eva[i][1]=int(eva[i][1])
#print(eva)
ass=sorted(eva,key=lambda x:(x[0],-x[1]))
#print(ass)
for i in range(n):
    for j in range(n):
        if ass[i]==eva[j]:
            print(j+1)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  auto solve = [](string &s) {
    switch (s[0]) {
      case 'M':
        return 6;
      case 'T': {
        if (s == "TUE") {
          return 5;
        } else {
          return 3;
        }
      }
      case 'W':
        return 4;
      case 'F':
        return 2;
      case 'S':
        if (s == "SAT") {
          return 1;
        } else {
          return 7;
        }
    }
  };
  cout << solve(s) << endl;
}


Measured memory_bytes: 256
fn read_line() -> String {
    use std::io;
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

fn main() {
    let line = read_line();
    let mut iter = line.split_whitespace();
    let N = iter.next().unwrap().parse::<i32>().unwrap();
    let mut H = iter.next().unwrap().parse::<i32>().unwrap();

    let mut vec = Vec::new();

    for _ in 0..N {
        let line = read_line();
        let mut iter = line.split_whitespace();
        let a = iter.next().unwrap().parse::<i32>().unwrap();
        let b = iter.next().unwrap().parse::<i32>().unwrap();
        vec.push((a, 1));
        vec.push((b, 0));
    }

    vec.sort_by(|a, b| b.cmp(a));

    let mut res = 0;

    for (n, is_a) in vec {
        if is_a == 1 {
            res += ((H-1) / n) + 1;
            break;
        } else {
            H -= n;
            res += 1;
            if H <= 0 {
                break;
            }
        }
    }

    println!("{}", res);
}


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

int main() {
  string s;
  vector<string> week = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  cin >> s;

  for(int i = 0; i < 7; i++){
    if(s == week[i]) cout << 7 - i;
  }
}
  



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B;
    cin >> A >> B;
    cout << A * B / __gcd(A, B) << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int N; cin >> N;
    vector<int> H(N, 0);
    for (int i = 0; i < N; ++i)
     cin >> H[i];
    
    int ans = 0;
    int wall = 0;
    for (int i = 0; i < N; ++i)
    {
        if (H[i] >= wall)
        {
        ans++;
        wall = H[i];
        }
    }

    cout << ans << endl;
}

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


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

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



template <class T> inline T biton(T n, T pos)
{
    return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
    return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
    return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
    while (b)
    {
        a = a % b;
        swap(a, b);
    }
    return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
};

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

long long com[200005];

void solve()
{
    int n;
    cin>>n;

    for(int i=1; i<=n; i++)
    {
        cin>>com[i];
        com[i]+=com[i-1];
    }

    long long mn=LONG_MAX;

    for(int i=1;i<=n;i++){
        mn=min(abs(com[i]-(com[n]-com[i])),mn);
    }
    cout<<mn<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);


    int t = 1;


    while (t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 1792
use std::cmp::{max, min};

fn main() {
    let t: Vec<i64> = reads();
    let (a, b, c, x, y) = (t[0], t[1], t[2], t[3], t[4]);

    let mut ans = a * x + b * y;

    for z in 0..max(x, y) + 1 {
        let t = c * (z * 2) + a * max(0, x - z) + b * max(0, y - z);
        ans = min(ans, t)
    }

    println!("{}", ans);
}

//------

#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_owned()
}

#[allow(dead_code)]
fn reads<T>() -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    read_line()
        .split_whitespace()
        .map(|w| w.parse().unwrap())
        .collect()
}


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

int main()
{
  unordered_set<int> set;
  int N;
  int temp;

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> temp;
    set.insert(temp);
  }
  cout << set.size() << endl;
}

Measured memory_bytes: 256
/* AOJ 0083
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0083
 *
 */

#include <stdio.h>

typedef struct TEra Era;

struct TEra {
    char* fName;
    int fYear;
    int fMonth;
    int fDay;
};

Era era[4] = {
    {"heisei", 1989, 1, 8},
    {"showa", 1926, 12, 25},
    {"taisho", 1912, 7, 30},
    {"meiji", 1868, 9, 8},
};

int main(){
    int y, m, d;
    int dy, dm, dd;
    int i;

    while(scanf("%d %d %d", &y, &m, &d)==3){
        for(i=0;i<4;i++){
             dy = y - era[i].fYear;
             dm = m - era[i].fMonth;
             dd = d - era[i].fDay;
             if((dy > 0) || (dy==0 && dm >0)|| (dy==0 && dm==00 && dd>=0)){
                 printf("%s %d %d %d\n",era[i].fName, dy+1, m, d);
                 break;
             }
        }
        if(i==4){
            printf("pre-meiji\n");
        }
    }

    return 0;
}

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

int main(){
	int a,b,sa;
	cin>>a>>b;
	sa=b-a;
	int a_hight=0;
	for(int i=0;i<sa;i++)
		a_hight=a_hight+i;
	cout<<a_hight-a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{   int a,b,flag=0,i;
    char s[12];
    scanf("%d%d%s",&a,&b,s);
    for(i=0;i<a+b+1;i++){
        if(i==a){
            if(s[i]!='-'){
                flag=1;
            }
        }else{
            if(s[i]<'0'||s[i]>'9'){
                flag=1;
            }
        }
    }
    if(flag==1)
    printf("No");else printf("Yes");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){

int N=0;
int K=0;
int M[50];

int i=0;
int c=0;

int ans=0;

int hozon=0;

cin>>N>>K;

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

for(i=0;i<N;i++){
	for(c=0;c<N-1;c++){
		if(M[c]<M[c+1]){
			hozon=M[c];
			M[c]=M[c+1];
			M[c+1]=hozon;
		}
	}
}

for(i=0;i<K;i++){
	ans=ans+M[i];
}

cout<<ans;












}

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

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

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

	int N,X; cin >> N >> X;
	int m[200];
	int sum = 0;
	int MIN = INT_MAX;

	for (int i = 0;i < N;i++){
		cin >> m[i];
		sum += m[i];
		MIN = min(MIN,m[i]);
	}

	cout << N+(X-sum)/MIN << endl;



	return 0;

}


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

#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

#define debug(x) cout << "> " << #x << " = " << x << endl;
#define debug_at(arr, at) cout << "> " << #arr << "[" << at << "] = " << arr[at] << endl;
#define debug_pair(p) cout << "> " << #p << " = (" << p.first << ", " << p.second << ")" << endl;

using namespace std;

typedef pair<int, int> ii;

const int N = 60;

bool M[N][N];
bool vis[N];
set<ii> edges;

int n, m;

void dfs(int u) {
    vis[u] = true;
    fori(v, 1, n + 1) {
        if(M[u][v] and !vis[v]) {
            dfs(v);
        }
    }
}

inline bool can() {
    memset(vis, 0, sizeof vis);
    dfs(1);
    fori(i, 1, n + 1) {
        if(!vis[i]) {
            return false;
        }
    }
    return true;
}

inline int solve() {
    int res = 0;
    for(auto p : edges) {
        int u, v;
        tie(u, v) = p;
        M[u][v] = M[v][u] = 0;
        if(!can()) {
            ++res;
        }
        M[u][v] = M[v][u] = 1;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);

    cin >> n >> m;
    fori(i, 0, m) {
        int u, v;
        cin >> u >> v;
        M[u][v] = M[v][u] = true;

        if(u > v) swap(u, v);
        edges.insert({u, v});
    }

    int ans = solve();
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
INF = 1<<60
# A：想定する最短距離と計算(WF)で算出した最短距離が合っているか判定
# A[i][j] > A[i][k] + A[k][j] : -1
# AとWFが合っていたら最短距離の和を出力
def resolve():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]
    B = [[True]*(N) for _ in range(N)]

    for k in range(N):
        for i in range(N):
            for j in range(N):
                if A[i][j] > A[i][k] + A[k][j]:
                    print(-1)
                    return
                # 1~Nまでの最短距離を求める為、不要な道を削除
                # (sample1:1->3=3, 1->2->3=1+2) よって1->3は削除
                elif A[i][j] == A[i][k] + A[k][j] and k!=i and k!= j:
                    B[i][j] = False

    ans = [sum([A[i][j] for j in range(N) if B[i][j]]) for i in range(N)]
    print(sum(ans)//2)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 43612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




int main() {
	string s, t;
	int n;
	cin >> n;
	rep(i, n) {
		cin >> s;
		vi v(26, 0);
		t = "";
		//cout << s.size() << endl;
		for (int i = 0; i < s.size(); i += 3) {
			if (i == 0) {
				t += s[0];
				v[s[0] - 'a'] = 1;
			}
			else {
				if (v[s[i] - 'a'] == 0) {
					if (s[i - 1] == '>') {
						t += s[i];
						//cout << " " << t << endl;
					}
					if (s[i - 1] == '-') {
						t = s[i] + t;
						//cout << " " << t << endl;
					}
					v[s[i] - 'a'] = 1;
				}
			}
		}
		cout << t << endl;
	}
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  long double a,b,x;
  cin >> a >> b >> x;

  x /= a;

  long double ans;
  long double pi = acos(-1);

  if(a*b - 2*x >= 0){
    ans = pi / 2 - atan(2 * x / ( b * b));
    ans = ans * 180 / pi;
  }else{
    ans = atan(2 * (a*b - x) / (a * a));
    ans = ans * 180 / pi;
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  double a,b,x;
  cin>>a>>b>>x;

  if(2*x>=a*a*b){
    cout<<setprecision(8)<<atan(2*(a*a*b-x)/a/a/a)*180/M_PI<<endl;
  }else{
    cout<<setprecision(8)<<atan(a*b*b/2/x)*180/M_PI<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N, L, Q;
long long x[100005];
long long a[100005];
long long b[100005];
//              pos  , hotel idx   
vector<pair<long long, long long> >vec;

long long dob[100005][50];

void prepare(){
	for(int i = 0; i < N; i++){
		long long lim = x[i] + L;
		//cout << "i = " << i << " lim = " << lim << endl;
		vector<pair<long long, long long> >::iterator it = upper_bound(vec.begin(), vec.end(), make_pair(lim, (long long)LONG_MAX));
		it--;
		dob[i][0] = (*it).second;
	}

	for(int i = 1; i < 30; i++){
		for(int j = 0; j < N; j++){
			dob[j][i] = dob[dob[j][i-1]][i-1];
		}
	}
}

bool check(int start, int goal, int mid){

	//cout << "start = " << start << " goal =" << goal << " mid = " << mid << endl;

	long long now = start;
	for(int idx = 30; idx >= 0; idx--){
		if((mid>>idx)&1){
			//cout << "idx = " << idx << endl;
			//cout << "move from " << now << " to " << dob[now][idx] << endl;
			now = dob[now][idx];
		}
	}

	//while(mid){
	//	if(mid&1){
	//		now = dob[



	//	}
	//	mid = (mid >> 1);
	//}
	if(x[goal] <= x[now]){
		return true;
	}else{
		return false;
	}
}


long long cal(int start, int goal){
	if(x[start] > x[goal]){
		swap(start, goal);
	}

	//cout << "start = " << start << " goal = " << goal << endl;

	long long s = 0;
	long long e = 100005;
	while(s+1 < e){
		long long mid = (s+e)/2;
		if(check(start, goal, mid)){
			e = mid;
		}else{
			s = mid;
		}
	}
	cout << e << endl;
	return e;
}


int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> x[i];
		vec.push_back(make_pair(x[i], i));
	}
	cin >> L >> Q;

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


	//for(int i = 0; i < vec.size(); i++){
	//	cout <<"vec" << vec[i].first << "," << vec[i].second << endl;
	//}


	prepare();

	//for(int i = 0; i < N; i++){
	//	cout << "start = " << i << endl;
	//	for(int j = 0; j < 10; j++){
	//		cout << "2 ** " << j << " day " << dob[i][j] << endl;
	//	}
	//}




	//for(int i = 0; i < vec.size(); i++){
	//	cout << vec[i] << endl;
	//}

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

	////cout << "cal" << endl;
	for(int i = 0; i < Q; i++){
		cal(a[i] - 1, b[i] - 1);
	}
}

Measured memory_bytes: 43888
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

ll n, ans = 0;
ll s[5];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		string c;
		cin >> c;
		
		if (c[0] == 'M')s[0]++;
		if (c[0] == 'A')s[1]++;
		if (c[0] == 'R')s[2]++;
		if (c[0] == 'C')s[3]++;
		if (c[0] == 'H')s[4]++;
	}

	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				if (s[i] > 0 && s[j] > 0 && s[k] > 0) {
					ans += s[i] * s[j] * s[k];
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

a,b = map(int, input().split())
if (b >= a):
    print(a)
else:
    print(a-1)


Measured memory_bytes: 8992
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string s, t;
    cin >> s >> t;
    ll cnt = 0;
    rep(i, s.size())if(s[i] == t[i])cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll v[65],a[maxn],n,cnt[65],ans;

inline void ins(ll x)
{
	for(ll i=60;i>=0;i--)
	{
		if(x&(1ll<<i))
		{
			if(v[i]) x^=v[i];
			else {v[i]=x; break;}
		}
	}
}

inline ll qm()
{
	ll tmp=0;
	for(int i=60;i>=0;i--) if((tmp^v[i])>tmp) tmp^=v[i];
	return tmp;
}

int main()
{
	n=read(); rep(i,1,n) a[i]=read();
	rep(x,0,60) rep(j,1,n) if(a[j]&(1ll<<x)) cnt[x]++;
	per(i,60,0)
	{
		if(cnt[i]&1)
		{
			ans+=(1ll<<i);
			rep(j,1,n) if(a[j]&(1ll<<i)) a[j]^=(1ll<<i);
		}
	}
	rep(i,1,n) ins(a[i]); printf("%lld\n",ans+2*qm());
	return 0;
}

Measured memory_bytes: 4484
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(){
    string a;
    getline(cin, a);
    vector<ll> x(500, 0);
    for (int i = 0; i < a.size(); i++)
        x[a[i]]++;
    
    ll res = a.size()*(a.size() + 1)/2 + 1;
    for (int i = 0; i < 500; i++)
        res -= x[i]*(x[i] + 1)/2;
    
    cout << res << endl;
    return 0;
}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	string S, T = "AKIHABARA";
	bool ans = true;
	int index = 0;

	cin >> S;

	rep(i, 9) {
		if (S[index] == T[i]) index++;
		else if (T[i] == 'A') {}
		else ans = false;
	}

	if (index != S.length()) ans = false;

	cout << (ans ? "YES" : "NO") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a,b,c[100000];
  long long ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a >> b;
    ans+=a;
    c[i]=a+b;
  }
  sort(c,c+n,greater<int>());
  for(int i=1; i<n; i+=2) {
    ans-=c[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = sum(B);
for i in range(n-1):
  if A[i] + 1 == A[i+1]:
    ans = ans + C[A[i]-1]
print(ans)

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	a*=100;
	b*=10;
	c=a+b+c;
	if(c%4) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 924844033LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int dy[4] = {0, 1, 0, -1};
int dx[4] = {1, 0, -1, 0};
int main() {
    string s;
    cin >> s;
    int n = s.length();
    int a = 0, b = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == '0') {
            if(i % 2) {
                a++;
            } else {
                b++;
            }
        } else {
            if(i % 2) {
                b++;
            } else {
                a++;
            }
        }
    }
    cout << min(a, b) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main(){
	fio; cout<<fixed<<setprecision(25);	
	string s; cin >> s;
	for(int i = 0; i < s.size()-1 ; ++i){
		if(s[i] == s[i+1]){
			cout << i+1 << ' ' << i+2 << endl;
			return 0;
		}
	}
	for(int i = 0;i < s.size()-2 ; ++i){
		if(s[i] == s[i+2]){
			cout << i+1 << ' ' << i+3 << endl;
			return 0;
		}
	}
	cout << -1 << ' ' << -1 << endl;








	return 0;
}


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

using namespace std;

static const int INF = 1 << 28;

#define D(x) cout << x << endl;
#define d(x) cout << x;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;

long long n;
string S;
vll A;
bool found = false;

bool solve(int p, int q) {
  
  A[0] = p, A[1] = q;

  for (int i = 2; i < n; i++) {
    if (S[i - 1] == 'o') {
      A[i] = A[i - 2] * A[i - 1];
    } else {
      A[i] = A[i - 2] * A[i - 1] * -1;
    }
  }
  if ((S[n - 1] == 'o' && A[n - 2] * A[n - 1] == A[0]) || (S[n - 1] == 'x' && A[n - 2] * A[n - 1] * -1 == A[0])) {
    if ((S[0] == 'o' && A[n - 1] * A[0] == A[1]) || (S[0] == 'x' && A[n - 1] * A[0] * -1 == A[1])) {
      for (int i = 0; i < n; i++) {
        if (A[i] == 1) {
          d('S');
        } else {
          d('W');
        }
      }
      D("");
      return true;
    }
  }
  return false;
}

int main() {
  cin >> n >> S;
  A.resize(n);

  if (solve(1, 1)) {
    return 0;
  } else if (solve(1, -1)) {
    return 0;
  } else if (solve(-1, 1)) {
    return 0;
  } else if (solve(-1, -1)) {
    return 0;
  } else {
    D(-1);
    return 0;
  }
}


Measured memory_bytes: 1408