akhauriyash/Code-Regression huggingface dataset:
input();a=list(map(int,input().split()))
b1,b2,b4=[],[],[];ans=''
for i in a:
  if i%2!=0:
    b1.append(i)
  elif i%4==0:
    b4.append(i)
  elif i%2==0:
    b2.append(i)
if b2:
  if len(b1)<=len(b4):
    ans='Yes'
  else:
    ans='No'
else:
  if len(b1)<=len(b4)+1:
    ans='Yes'
  else:
    ans='No'
print(ans)

Measured memory_bytes: 19748
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
int main() {
	int n;
	cin >> n;
	vi A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	if (n % 2 == 0) {
		vi X(1+ n / 2, 0);
		for (int i = 0; i < n; i++) {
			int x = A[i];
			x = x / 2;
			X[x]++;
		}
		bool can = true;
		for (int i = 0; i < n / 2; i++) {
			if (X[i] != 2) {
				can = false;
				break;
			}
		}
		if (can) {
			ll ans = 1;
			for (int i = 0; i < n / 2; i++) {
				ans = (ans * 2) % MOD;
			}
			cout << ans << endl;
			return 0;
		}
		else {
			cout << 0 << endl;
			return 0;
		}
	}
	else {
		vi X((n+1) / 2, 0);
		for (int i = 0; i < n; i++) {
			X[(A[i] / 2)]++;
		}
		bool can = true;
		if (X[0] != 1) {
			can = false;
		}
		else {
			for (int i = 1; i < (n + 1) / 2; i++) {
				if (X[i] != 2) {
					can = false;
					break;
				}
			}
		}
		if (can) {
			ll ans = 1;
			for (int i = 0; i < n / 2; i++) {
				ans = (ans * 2) % MOD;
			}
			cout << ans << endl;
			return 0;
		}
		else {
			cout << 0 << endl;
			return 0;
		}
	}
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main() {
  ll N;
  cin >> N;
  ll A[N];
  rep(i,0,N) {
    cin >> A[i];
  }
  ll teisu = 0;
  rep(i,0,N-1) {
    if (i%2 == 0) {
      teisu -= A[i];
    }else{
      teisu += A[i];
    }
  }
  ll ans = A[N-1] - teisu;
  cout << ans << " ";
  rep(i,0,N-1) {
    ans = 2*A[i] - ans;
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2048
#include <iostream>

using namespace std;

int main(){
    int n,min=1000000,max=-1000000;
    long long sum=0;
    int box;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>box;
        sum=sum+box;
        if(min>box){
            min=box;
        }
        if(max<box){
            max=box;
        }
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
}


Measured memory_bytes: 3104
# Author: cr4zjh0bp
# Created: Tue Mar 17 19:50:06 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

h, w = na()
m = nsn(h)

dist = [[inf] * (h * w) for _ in range(h * w)]
dx, dy = [0, 1, -1, 0], [1, 0, 0, -1]
for i in range(h):
    for j in range(w):
        for k in range(4):
            ni, nj = i + dy[k], j + dx[k]
            if ni >= 0 and ni < h and nj >= 0 and nj < w and m[ni][nj] != '#' and m[i][j] != '#':
                dist[i * w + j][ni * w + nj] = 1
        dist[i * w + j][i * w + j] = 0

def floyd_warshall(n, dist):
    for i in range(n):
        for j in range(n):
            for k in range(n):
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k])

floyd_warshall(h * w, dist)

ans = 0
for i in range(h * w):
    for j in range(h * w):
        if dist[i][j] != inf:
            ans = max(ans, dist[i][j])

print(ans)

Measured memory_bytes: 42736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,u,v,d,e,maxi1=INT_MIN,mini1=INT_MAX,maxi2=INT_MIN,mini2=INT_MAX;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>u>>v;
        d=(u+v);
        if(mini1>d)
        {
            mini1=d;
            }
        if(maxi1<d)
        {
            maxi1=d;

        }
        e=u-v;
        if(mini2>e)
        {
            mini2=e;

        }
        if(maxi2<e)
        {
            maxi2=e;
        }
    }
    cout<<max(maxi1-mini1,maxi2-mini2)<<endl;
}


Measured memory_bytes: 3532
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
k = 1
cnt = 1
while GCD > 1:
  k += 1
  if k ** 2 > GCD:
    cnt += 1
    break
  if GCD % k:
    continue
  cnt += 1
  while GCD % k == 0:
    GCD //= k
print(cnt)


Measured memory_bytes: 5048
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
static const int MAX = 100000;

int a[MAX];

int main(void){
  int n;
  cin >> n;
  for(int i=0;i<n;i++)
    cin >> a[i];

  map<int ,int> mp;
  for(int i=0;i<n;i++){
    mp[a[i]]++;
  }
  int ans = 0;
  for(auto p: mp){
    int x = p.first;
    int n = p.second;
    if(n < x) ans += n;
    else ans += n-x;
  }

  cout << ans << endl;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

string S, T;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> S >> T;

	rep(i, 0, S.size()) {
		char tmp = S[S.size() - 1];
		for(int j = S.size() - 1; j >= 1; j--) {
			S[j] = S[j - 1];
		}
		S[0] = tmp;
		if(S == T) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string s, t;
    cin >> s >> t;
    s += s;
    for (int i = 0; i < s.size(); i++) {
        // cout << s.substr(i, t.size()) << '\n';
        if (s.substr(i, t.size()) == t) {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
}


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

int main() {
	string s, t;
	cin >> s >> t;
	bool check = true;

	for(int i=0;i<s.size();i++) {
		char r = s.at(0);
		s.erase(s.begin());
		s += r;

		if(s==t) {
			cout << "Yes" << endl;
			check = false;
			break;
		}
	}
	if(check) cout << "No" << endl;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int ans;
    if((A + B + C) % 2 == 0){
        if(A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
            vector<int> vec{A, B, C};
            sort(vec.begin(), vec.end());
            ans = (vec.at(2) - vec.at(0)) / 2 + (vec.at(2) - vec.at(1)) / 2;
        }else{
        if(A % 2 == 1) A++;
        if(B % 2 == 1) B++;
        if(C % 2 == 1) C++;
        vector<int> vec{A, B, C};
        sort(vec.begin(), vec.end());
        ans = (vec.at(2) - vec.at(0)) / 2 + (vec.at(2) - vec.at(1)) / 2 + 1;
        }
    }
    else{
        if(A % 2 == 1 && B % 2 == 1 && C % 2 == 1){
            vector<int> vec{A, B, C};
            sort(vec.begin(), vec.end());
            ans = (vec.at(2) - vec.at(0)) / 2 + (vec.at(2) - vec.at(1)) / 2;
        }else{
        if(A % 2 == 0) A++;
        if(B % 2 == 0) B++;
        if(C % 2 == 0) C++;
        vector<int> vec{A, B, C};
        sort(vec.begin(), vec.end());
        ans = (vec.at(2) - vec.at(0)) / 2 + (vec.at(2) - vec.at(1)) / 2 + 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    vector<int> cnt(n); rep(i,n){
        cnt[a[i]]++;
        if(cnt[a[i]] >= 3){
            cout << 0 << endl;
            return 0;
        }
    }
    if(cnt[0] >= 2){
        cout << 0 << endl;
        return 0;
    }

    const ll MOD = 1e9+7;
    ll ans = 1LL;
    rep(i,n/2){
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

int main()
{
  long long N, P;
  cin >> N >> P;
  
  long long ans = 1;
  if (N == 1) ans = P;
  else
  {
    for (long long i = 2; i * i <= P; i++)
    {
      long long p = P;
      long long j = 0;
      while (p % i == 0 && j < N)
      {
        p /= i;
        j++;
      }
      if (j >= N) ans = i;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100];
ll dp[100000+1]={0};

ll f(ll k,ll n)
{
    ll t=a[0];
    
    for(ll i=0;i<n;i++)
    {
        if(a[i]<t)
        t=a[i];
    }

    dp[t]=1;
    
    for(ll i=t+1;i<=k;i++)
    {
        for(ll j=0;j<n;j++)
        {
            if(((i-a[j])>=0)&&(dp[i-a[j]]==0))
            {
                dp[i]=1;
                break;
            }
            
        }
    }
    
    return dp[k];
    
}
int main()
{
    ll n,k;
    cin>>n>>k;
    
    for(ll i=0;i<n;i++)
    cin>>a[i];
    
    ll x=f(k,n);

    
    if(x)
    cout<<"First"<<endl;
    
    else
    cout<<"Second"<<endl;
    
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
        var n, l int
        fmt.Scan(&n, &l)

        max := l + n
        min := l

        var sum int
        for i := min; i < max; i++ {
                sum += i
        }

        if max <= 0 {
                fmt.Println(sum - (max - 1))
                return
        }
        if min > 0 {
                fmt.Println(sum - min)
                return
        }
        fmt.Println(sum)
}

Measured memory_bytes: 512
from operator import itemgetter
from bisect import bisect
n = int(input())
a = [tuple(map(int,input().split())) for i in range(n)]
b = [tuple(map(int,input().split())) for i in range(n)]
a.sort(key=itemgetter(1))
a.sort(key=itemgetter(0))
b.sort(key=itemgetter(1))
b.sort(key=itemgetter(0))

ans = 0
for l,r in b:
  ind = bisect(a,(l-1,r-1))
  chk = 0
  d = -1
  for i in range(min(len(a),ind)):
    if a[i][1] < r:
      chk = max(chk,a[i][1])
      if chk == a[i][1]:
        d = i
  if d >= 0:
    ans += 1
    k = a[d]
    a.remove(k)
    
print(ans)

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

using namespace std;
#define int long long
int32_t main()
{
    int a, b ;
    cin >> a >> b ;
    int gcd = __gcd(a, b) ;
    int ans = (a * b)/ gcd ;
    cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
#define ll long long
int n;
int arr[3][100005];
ll dp[3][100005];

int main()
{
  	cin>>n;
	for(int j=0; j<n;j++)
	{
		for(int i=0; i<3; i++)
		{
			cin>>arr[i][j];
		}
	}

	ll sol=0;
	dp[0][0]=arr[0][0];
	dp[1][0]=arr[1][0];
	dp[2][0]=arr[2][0];
	for(int j=1;j<n; j++)
	{
		for(int i=0;i<3;i++)
		{
			dp[i][j]=arr[i][j]+max(dp[(i+1)%3][j-1],dp[(i+2)%3][j-1]);
		}
	}	
	sol=max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
	cout<<sol;

	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

ll d = 1e9 + 7;

ll gyaku(ll a){
    ll ans = 1;
    ll bai = d - 2;
    ll kake = a;
    while(bai > 0){
        if (bai % 2 == 1){
            ans *= kake;
            ans %= d;
        }
        kake = kake*kake;
        kake %= d;
        bai /= 2;
    }
    return ans;
}


int main(void){
    ll x; cin >> x;
    ll y; cin >> y;
    if ((x+y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    ll hiku = (x+y)/3;
    x -= hiku;
    y -= hiku;
    if ((x < 0) or (y < 0)){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    REP(i, x+y){
        ans *= (i+1);
        ans %= d;
    }
    REP(i, x){
        ans *= gyaku(i+1);
        ans %= d;
    }
    REP(i, y){
        ans*= gyaku(i+1);
        ans %= d;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n;
int x,y,z;

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int a;
        scanf("%d",&a);
        if(a % 4 == 0)
            x++;
        else{
            if(a % 2 == 0)
                y++;
            else
                z++;
        }
    }
    if(z - x > 1 || y > 0 && z - x == 1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//以下雛形を記す
long long INF =  -10000000000000000;
struct edge{
    int from;
    int to;
    long long cost;
};

int main(){
    int N, M;//Vは頂点、Kは辺の数
    cin >> N >> M;
    vector<edge> es(M);
    for(int i = 0; i < M; i++){
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].from--;
        es[i].to--;
       // es[i].cost *= -1;
    }
    vector<long long> d(N);//各頂点までの距離
    for(int i = 0; i < N; i++) d[i] = INF;
    d[0] = 0;
    int n = 0;
    while(true){
        bool flag = false;
        bool flag2 = true;
        for(int i = 0; i < M; i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] < d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                if(n >=N && e.to == N - 1) flag2 = false;
                flag = true;
            }
        }
        n++;
        if(!flag){
            cout << d[N - 1] << endl;
            break;
        }
        if(n >= N && flag2 == false){//閉路があり、閉路から抜け出して目標点までの距離が更新される場合
            cout << "inf" << endl;
            break;
        }
        else if(n >= 2*N && flag2 == true){
            cout << d[N - 1] << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void get_int2(char *line, int size, int *a1, int *a2) {
  if(!fgets(line, size, stdin)) return;
  sscanf(line, "%d %d", a1, a2);
}

#define BUF_SIZE 53
#define ROW_MAX 52
#define COL_MAX 52

enum {
  FREE = '.',
  WALL = '#'
};

struct point {
  int x;
  int y;
  int dist;
};


#define DIR_CNT 4
int next_dir4[DIR_CNT][2] = {
  {-1, 0},
  {0, -1},
  {0, 1},
  {1, 0},
};

static struct point stack[2500];
static int start = 0;
static int end = 0;

void enqueue(struct point p) {
  stack[start++] = p;
}

int is_empty(void) {
  return start == end;
}

struct point dequeue(void) {
  return stack[end++];
}

int main(void) {
  int row, col;
  char line[BUF_SIZE];
  char map[ROW_MAX][COL_MAX];
  int i, j;
  for(i = 0; i < ROW_MAX; i++) {
    for(j = 0; j < COL_MAX; j++) {
      map[i][j] = WALL;
    }
  }
  get_int2(line, BUF_SIZE, &row, &col);

  int cnt = 0;
  for(i = 1; i <= row; i++) {
    if(!fgets(line, BUF_SIZE, stdin)) return 0;
    for(j = 1; j <= col; j++) {
      map[i][j] = line[j-1];
      cnt += (map[i][j] == FREE);
    }
  }

  struct point st = {1, 1, 1};
  struct point en = {row, col, -1};
  enqueue(st);
  map[st.x][st.y] = WALL;
  while(!is_empty()) {
    struct point p = dequeue();
    if(p.x == en.x && p.y == en.y) {
      en.dist = p.dist;
      break;
    }
    for(i = 0; i < DIR_CNT; i++) {
      int next_x = p.x + next_dir4[i][0];
      int next_y = p.y + next_dir4[i][1];
      if(map[next_x][next_y] == WALL) continue;
      struct point np = {next_x, next_y, p.dist+1};
      enqueue(np);
      map[next_x][next_y] = WALL;
    }
  }
  if(en.dist == -1) {
    printf("-1\n");
  } else {
    printf("%d\n", cnt - en.dist);
  }
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
string s,t;
ll dp[3050][3050];
ll fx(ll i, ll j)
{
	if(i == s.length() || j == t.length())
	{
		return dp[i][j]=0;
	}
	if(dp[i][j]!=-10	)
		return dp[i][j];
	if(s[i] == t[j])
	{
		return dp[i][j] = 1 + fx(i+1, j+1);
	}
	else
	{
		return dp[i][j] = max(fx(i+1, j), fx(i, j+1));
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>s>>t;
	ll i,j;
	for(i=0;i<s.length()+10;i++)
	{
		for(j=0;j<t.length()+10;j++)
		{
			dp[i][j]=-10;
		}
	}
	fx(0,0);
	i=0, j=0;
	string ans = "";
	while(i<s.length() && j<t.length())
	{
		if(s[i]==t[j])
			ans += s[i], i++, j++;
		else if(dp[i+1][j] > dp[i][j+1])
			i++;
		else 
			j++;
	}
	cout<<ans<<nl;
	return 0;
}

Measured memory_bytes: 75528
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author acesine
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            Map<Integer, Integer> m = new HashMap<Integer, Integer>();
            int A = in.nextInt(), B = in.nextInt(), C = in.nextInt();
            m.put(A, m.getOrDefault(A, 0) + 1);
            m.put(B, m.getOrDefault(B, 0) + 1);
            m.put(C, m.getOrDefault(C, 0) + 1);
            if (m.getOrDefault(5, 0) == 2 && m.getOrDefault(7, 0) == 1) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }
}



Measured memory_bytes: 21204
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n = int(input().strip())
    v = list(map(int, input().strip().split()))
    ans = INF
    for i in range(1, 101):
        t = 0
        for j in range(n):
            t += (i - v[j]) ** 2
        ans = min(ans, t)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int left =0;
    int right =0;
    left = a+b;
    right = c+d;
    if(left>right){
        cout<<"Left"<<endl;
    }else if(left<right){
        cout<<"Right"<<endl;
    }else{
        cout<<"Balanced"<<endl;
    }
}



Measured memory_bytes: 256
n=int(input())
hlist = list(map(int, input().split()))
hlist[0]-=1
ng=len(hlist)

ok=1

for i in range(ng-2):
    if hlist[i]<=hlist[i+1] and hlist[i+1]<=hlist[i+2]:
        if hlist[i+1]==hlist[i+2] and hlist[i]<hlist[i+1]:
            hlist[i+1]-=1
    elif hlist[i]<=hlist[i+1] and hlist[i+1]>=hlist[i+2]:
        if hlist[i+1]-hlist[i+2]==1 and hlist[i]!=hlist[i+1]:
            hlist[i+1]-=1
        else:
            ok=0
    else:
        ok=0

if ng==1:
    ok=1
elif ng==2:
    if hlist[0]<=hlist[1]:
        ok=1
    else:
        ok=0

#print(ok)
#print(hlist)
if ok==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')
#import numpy as np

def main():
	n=II()
	A=LI()
	B=[0]*(n+1)
	for i in A:
		B[i]+=1

	ans=0
	for i in B:
		ans+=i*(i-1)//2
	#print(ans)
	for i in A:
		print(ans-B[i]+1)









if __name__ == "__main__":
	main()

Measured memory_bytes: 20396
n = int(input())
s = input()

done_1 = set()
done_2 = set()
done_3 = set()
for i in range(n):
    if s[i] in done_1:
        continue
    for j in range(i+1, n):
        if s[i] + s[j] in done_2:
            continue
        for k in range(j+1, n):
            pin = s[i] + s[j] + s[k]
            done_3.add(pin)
        done_2.add(pin[:2])
    done_1.add(pin[0])
print(len(done_3))


Measured memory_bytes: 41324
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

using namespace std;

int main() {
    nl // youtu.be/QosiU0JR_h8  
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int &x : v) cin >> x;
    sort(all(v));
    int sum = 0;
    for(int i=0; i<k; ++i)
        sum += v[i];
    cout << sum;
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
p_list = list(map(int,input().split()))
p_list_sorted = sorted(p_list)
cnt = 0
for i in range(N):
    if p_list[i] != p_list_sorted[i]:
        cnt += 1

if cnt == 2 or cnt == 0:
    print("YES")
else:
    print("NO")

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


using namespace std;

int main()
{
    int a,b,A,B,boxa[20000],boxb[20000],c=0,ans;
    string op,boxc[20000];
    while(1){
        cin >> a >> op >> b;
        if(op=="?"){
            break;
        }
        boxa[c]=a;
        boxb[c]=b;
        boxc[c]=op;
        c++;
    }
    for(int i=0;i<c;i++){
        A=boxa[i];
        B=boxb[i];
        op=boxc[i];
        if(op=="+")ans=A+B;
        else if(op=="-")ans=A-B;
        else if(op=="/")ans=A/B;
        else if(op=="*")ans=A*B;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3308
S = input()

if S[0]==S[1] and S[2]==S[3] and S[1]!=S[2]:
    print('Yes')
    exit()
if S[0]==S[2] and S[1]==S[3] and S[1]!=S[2]:
    print('Yes')
    exit()
if S[0]==S[3] and S[2]==S[1] and S[0]!=S[2]:
    print('Yes')
    exit()
print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;
  int x[n], y[n], h[n];
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i] >> h[i];
  }

  int nz = -1;
  for(int i = 0; i < n; i++){
    if(h[i] != 0){
      nz = i;
      break;
    }
  }

  int cx = -1, cy = -1, height = -1;
  if(nz != -1){
    for(cx = 0; cx <= 100; cx++){
      bool all = false;
      for(cy = 0; cy <= 100; cy++){
        height = h[nz] + abs(x[nz] - cx) + abs(y[nz] - cy);
        all = true;
        for(int i = 0; i < n; i++){
          if(h[i] != max(0, height - abs(x[i] - cx) - abs(y[i] - cy))){
            all = false;
            break;
          }
        }
        if(all) break;
      }
      if(all) break;
    }
  }
  else{
    cx = 0; cy = 0; height = INF_INT;
    for(int i = 0; i < n; i++){
      height = min(height, x[i] + y[i]);
    }
  }

  cout << cx << " " << cy << " " << height << endl;

  return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n:usize
    }
    let mut sum = 0;
    for i in 1..=n {
        let y = n / i;
        let g = y * (y+1) / 2;
        sum += g * i;
    }

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


Measured memory_bytes: 2180
#include <stdio.h>
int main() {
  int W, H, x, y, r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
  if (W >= x + r && H >= y + r && 0 <= x - r && 0 <= y - r) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1820
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define pushb push_back()
#define popb pop_back()
#define makep make_pair
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
ll solve(ll x){
    ll ans=0;
    ll x2=x;
    if(x==2){
        return 3;
    }else if(x==3){
        return 0;
    }
    ll s=1;
    while(s<=x){
        s<<=1;
    }
    s>>=1;
    while(s>1){
        if(x>=s){
            x%=s;
            ans+=s*(((x%s)+1)%2);
        }
        if(x2==7){
            // cout<<x<<' '<<s<<' '<<ans<<endl;
        }
        s>>=1;
    }
    if(((x2/2)%2+x2%2)%2){
        ans++;
    }
    return ans;
}
int main(){
    ll a,b;cin>>a>>b;
    ll ans=solve(b)^solve(a)^a;
    // cout<<solve(a)<<endl;
    // cout<<solve(b) <<endl;
    // printf("%x\n",a);
    // printf("%x\n",b);
    
    cout<<ans <<endl;

    // solve(7);

    return 0;
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
   cin>>n;
   vector<ll>  v(n);
   rep(i,n) cin>>v[i];
   rep(i,n-1){
       if(v[i]==i+1){
           swap(v[i],v[i+1]);
           sum++;
       }
   }
   if(v[n-1]==n) sum++;

    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3924
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

#define swap(a,b)(t=a,a=b,b=t)

int main(){
	ll a,b,c,t;
	scanf("%lld%lld%lld",&a,&b,&c);
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	ll ans=0;
	while(c-a>=2){
		ans++;
		a+=2;
		if(a>b)swap(a,b);
		if(b>c)swap(b,c);
	}
	printf("%lld",ans+(a==c?0:a==b?1:2));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
signed main(){
	int K;
	cin >> K;
	int n_seq = 1;
	int rep7 = 7;
	while(1){
		rep7 %= K;
		if(rep7 == 0){
			break;
		}
		rep7 = 10*rep7+7;
		++n_seq;
		if(1e8 < n_seq){
			n_seq = -1;
			break;
		}
	}
	cout << n_seq << endl;
 
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    int a, b; cin >> a >> b;
    if (a == b) {
        cout << "a == b" << '\n';
    }
    else if (a > b){
        cout << "a > b" << '\n';
    }
    else {
        cout << "a < b"<< '\n';
    }

}



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

int main()
{
    int n;
    double ans = 0.0;
    cin >> n;
    double x[n];
    string u[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> u[i];
        if (u[i] == "JPY")  ans += x[i];
        else    ans += x[i] * 380000.0;
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

ll gcd(ll a,ll b){
    ll M=max(a,b);
    ll m=min(a,b);
    if(m==0){
        return M;
    }
    return gcd(m,M%m);
}

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    vector<bool> done(1001001,false);
    vector<ll> D(1001001);
    for(ll i=0;i<1001001;i++){
        D[i]=i;
    }

    for(ll i=2;i<1001001;i++){
        ll now=i;
        while(now<1001001){
            if(!done[now]){
                done[now]=true;
                D[now]=i;
            }
            now+=i;
        }
    }

    vector<bool> f(1001001,false);
    bool flag=false;

    for(ll i=0;i<n;i++){
        ll x=a[i];
        while(x>1){
            ll d=D[x];
            //cout<<"x="<<x<<" d="<<d<<"   ";
            if(!f[d]){
                f[d]=true;
                while(x%d==0 && x>1){
                    x/=d;
                }
            }else{
                flag=true;
                break;
            }
        }
        if(flag) break;
    }

    if(!flag){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }

    ll g=a[0];
    for(ll i=1;i<n;i++){
        g=gcd(g,a[i]);
    }

    if(g==1){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
}

Measured memory_bytes: 19016
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	
	string s;
	cin>>s;
	int a=0,b=0,n = s.size();
	string zo,oz;
	for0(i,n){
		if(i%2){
			zo += '0';
			oz += '1';
			}
			
		else{
			zo += '1';
			oz += '0';
			}
		}
	for0(i,n){
		if(s[i]!=zo[i]) a++;
		if(s[i]!=oz[i]) b++;
		}
	int ans = min(a,b);
	cout<<ans<<nw;
	return 0;
}

Measured memory_bytes: 768
$A[0]=<>;$A[1]=<>;$A[4]=<>;
chomp@A;
$A[6]=$A[0]+$A[1]-$A[4];
$A[8]=$A[1]+$A[4]-$A[6];
$A[3]=$A[4]+$A[8]-$A[6];
$A[7]=$A[0]+$A[3]-$A[8];
$A[2]=$A[3]+$A[6]-$A[1];
$A[5]=$A[0]+$A[6]-$A[4];
$i=0;
print"$A[$i++] $A[$i++] $A[$i++]\n"for(1..3)

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int a, b, k;
	vector<int> nums;

	cin >> a >> b >> k;

	for (int i = 1; i < max(a, b) + 1; i++) {
		if (a % i == 0 and b % i == 0) {
			nums.push_back(i);
		}
	}
	reverse(nums.begin(), nums.end());

	cout << nums[k-1] << endl;

	return 0;

}

Measured memory_bytes: 888
#include <stdio.h>

int main(void){   

    int i, j, cou=1, flag=0, flag2=0;
    char a, rm, rm2;

    for(i=0; i<6; i++){
       scanf("%c", &a);
    
       if(cou == 3){
           rm = a;
       }else if(cou == 5){
           rm2 = a;
       }

       if(rm == a && cou == 4){
           flag =1;
       }
       if(rm2 == a && cou==6){
           flag2 =1;
       }
       

       
       cou++;

    }
    if(flag){
        if(flag2){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else{
        printf("No\n");
        }
    
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
    int p,n1,n2,n3,n4;
    scanf("%d",&p);
    n4=p%10;
    p=p/10;
    n3=p%10;
    p=p/10;
    n2=p%10;
    n1=p/10;
    if(n1==n2&&n2==n3||n2==n3&&n3==n4||n1==n2&&n2==n3&&n3==n4)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;

int main(){
    int n; cin >> n;
    vl v(n);
    map<int, int> odd;
    map<int, int> even;
    int omax=0, emax=0, osecond=0, esecond=0;
    rep(i,n){
        cin >> v[i];
        if((i+1)%2 == 1){
            if(odd.find(v[i])==odd.end()) odd[v[i]] = 1;
            else odd[v[i]]++;
        }else{
            if(even.find(v[i])==even.end()) even[v[i]] = 1;
            else even[v[i]]++;
        }
    }
    vector<pair<int, int>> o,e;

    for(auto it = odd.begin(); it != odd.end(); it++){
        o.push_back(make_pair(it->second, it->first));
    }
    
    for(auto it = even.begin(); it != even.end(); it++){
        e.push_back(make_pair(it->second, it->first));
    }
    sort(o.rbegin(), o.rend());
    sort(e.rbegin(), e.rend());
    if(o.size()==1) o.emplace_back(0,0);
    if(e.size()==1) e.emplace_back(0,0);
    if(o[0].second == e[0].second){
        cout << n - max(o[0].first + e[1].first, o[1].first + e[0].first) << endl;
    }else{
        cout << n - o[0].first - e[0].first;
    }
}

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

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

    int out = s+1;
    if(s==1000000000) out=1;

    if(k==0) {
        for(int i=0; i<n-1; i++) {
            cout<<out<<' ';
        }
        cout<<out<<endl;
        return 0;
    }
    else {
        for(int i=0; i<k-1; i++) {
            cout<<s<<' ';
        }
    }
    

    if(k==n) cout<<s<<endl;

    else {
        cout<<s<<' ';
        int time = n-k;
        if(time==1) cout<<out<<endl;
        else {
            for(int i=0; i<time-1; i++) {
                cout<<out<<' ';
            }
            cout<<out<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
// #define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
// ll power(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 modInverse(ll a){return power(a,mod-2);}
const int N=1000001;
// vector<pair<ll, ll> > adj[N];
// bool vis[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;
vector <int> adj[N];


void solve() 
{
    ll n, x, t;
    cin>>n>>x>>t;

    ll ans = 0;

    ll p;

    if(n%x == 0)
    {
        p = n/x;
    }
    else
    {
        p = n/x + 1;
    }

    cout<<p*t<<endl;


}

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)

    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 27236
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int flg = S.Length;
          
          if(K - flg >= 0)
          {
            Console.Write(S);
          }
          else
          {
            for(int i = 0; i < K; i++)
            {
              Console.Write(S[i]);
            }
            Console.Write("...");
          }
       }
    }
}


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

int main(){
    string s;cin>>s;
    int c1=0,c2=0;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]!='0'){
                c1++;
            }else{
                c2++;
            }
        }else{
            if(s[i]!='1'){
                c1++;
            }else{
                c2++;
            }
        }
    }
    int ans=c1;
    if(c2<c1)
        ans=c2;
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;

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

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

    int n;
    string s;
    cin >> n >> s;
    int alpha_cnt[26] = {};

    for( int i = 0; i < s.size(); ++i ) {
        ++alpha_cnt[s[i] - 'a'];

    }

    LL ans = 1;
    for( int i = 0; i < 26; ++i ) {
        ans = ans * ( alpha_cnt[i] + 1 ) % MOD;

    }

    cout << ans - 1 << endl;

    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned 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 (a > b) { a = b; return 1; } return 0; }
 
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }
 
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vi a(n);
  vector<vector<pii>> b(n);
  rep(i,n){
    cin>>a[i];
    rep(j,a[i]){
      int x,y; cin>>x>>y;
      x--; y;
      b[i].emplace_back(x,y);
    }
  }
  int ans=0;
  for(int bit=0; bit<(1<<n); bit++){
    bool ok=true;
    rep(i,n){
      if(bit&(1<<i)){
        rep(j,a[i]){
          int x=b[i][j].first;
          int y=b[i][j].second;
          if((bit & (1<<x))){
            if(y==0) ok=false;
          }else{
            if(y==1) ok=false;
          }
        }
      }
    }
    if(ok){
      int cnt=0;
      rep(i,n){
        if(bit&(1<<i)) cnt++;
        chmax(ans,cnt);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (???test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// ??\??????push_back(d)???array[d]???????????????1?????§?????????
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN(){T d;cin>>d;return d;}
// ?????§??¬?´???°???Greatest Common Divisor???
LL gcd(LL a, LL b){ return (b > 0) ? gcd(b, a%b) : a; }
// ????°???¬?????°???Least Common Multiple???
LL lcm(LL a, LL b){ return a / gcd(a, b) * b; }

// ------------------- include, typedef, define END. -------------------

int main(){
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//??????????????????????????????.
	LL a,b;
	while(cin >> a >> b)
		cout << gcd(a,b) << " " << lcm(a,b) << endl;	

	return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
using namespace std;
using pii = pair<int,int>;

inline bool isPrime(int x)
{
    if (x == 2) return true;
    if ((x&1) == 0) return false;

    for (int i=3; i*i <= x; i += 2)
        if (x % i == 0) return false;

    return (true);
}

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

   int n;
   int x;
   int cnt = 0;
   cin >> n;
   while (n--) {
       cin >> x;
       if (isPrime(x)) ++cnt;
   }
   outl(cnt);
}




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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)

#define BR "\n"
#define SP " "

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

  set<string> s;

  rep0(i, N) {
    string op, str;
    cin >> op >> str;
    if (op == "insert") s.insert(str);
    else if (s.find(str) == s.end()) cout << "no" << BR;
    else cout << "yes" << BR;
  }
  return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	long long t;
	cin>>t;
  	if(t>=30)
      	cout<<"Yes\n";
  	else
      	cout<<"No\n";
	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
int asc(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int a[100005];
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    qsort(a, n, sizeof(int), asc);
    unsigned long long int x, y;
    x = y = 0;
    for (i = 0; i < n - 1; i++)
        if (a[i] == a[i + 1])
        {
            x = a[i];
            break;
        }
    i += 2;
    for(;i<n-1;i++)
        if (a[i] == a[i + 1])
        {
            y = a[i];
            break;
        }
    printf("%lld\n", x*y);
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int x[5];
    rep(i, 5){
        cin >> x[i];
    }
    rep(i, 5){
        if(x[i]==0){
            cout << i+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3468