akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

while True:
    N = inp()
    if N == 0:
        break
    ans = []
    for i in range(N):
        L,P,A,B,C,D,E,F,S,M = input().split()
        P,A,B,C,D,E,F,S,M = map(int,[P,A,B,C,D,E,F,S,M])
        T1 = A+B+C
        T2 = D+E
        T = T1 + T2*M
        B = F*S*M - P
        x = B/T
        ans.append([-x,L])
    ans.sort()
    for azu,nyan in ans:
        print(nyan)
    print('#')



Measured memory_bytes: 7164
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    string s; cin>>s;
    for(int i=0; i<s.size()-1; i++){
        if(s[i] == s[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define repd(i,n) for ((i)=(n);(i)>=1;(i)--)
using namespace std;

int n,m;
int i,j;
int a[200005],d[200005],lim[25];
int tor[200005][25],tol[200005][25];
int dppre[1<<19],dpsuf[1<<19];

void calc(int x){
	int i;
	rep(i,n){
		tor[i][x]=tor[i-1][x];
		if(tor[i][x]<i){
			tor[i][x]=i;
			while(tor[i][x]<n&&d[tor[i][x]]<=lim[x]){
				tor[i][x]++;
			}
		}
	}
	tol[n+1][x]=n+1;
	repd(i,n){
		tol[i][x]=tol[i+1][x];
		if(tol[i][x]>i){
			tol[i][x]=i;
			while(tol[i][x]>1&&d[tol[i][x]-1]<=lim[x]){
				tol[i][x]--;
			}
		}
	}
}

int main(){
	cin>>n>>lim[m=1];
	rep(i,n) cin>>a[i];
	rep(i,n-1) d[i]=a[i+1]-a[i];
	while(lim[m]>0){
		m++;
		lim[m]=lim[m-1]/2;
	}
	rep(i,m){
		calc(i);
	}
	int c=0;
	for(i=1;i<=n;i=tor[i][1]+1)c++;
	if(c>m+1){
		rep(i,n){
			puts("Impossible");
			return 0;
		}
	}
	for(i=0;i<(1<<(m-1));i++){
		dppre[i]=0;dpsuf[i]=n+1;
		for(j=0;j<(m-1);j++)if((i>>j)&1){
			dppre[i]=max(dppre[i],tor[dppre[i^(1<<j)]+1][j+2]);
			dpsuf[i]=min(dpsuf[i],tol[dpsuf[i^(1<<j)]-1][j+2]);
		}
	}
	
	for(i=1;i<=n;i=tor[i][1]+1){
		int f=0;
		for(j=0;j<(1<<(m-1));j++){
			f|=(dppre[j]>=i-1&&dpsuf[((1<<m-1)-1)^j]<=tor[i][1]+1);
		}
		if(f){
			rep(j,tor[i][1]-i+1) puts("Possible");
		}
		else{
			rep(j,tor[i][1]-i+1) puts("Impossible");
		}
	}
	return 0;
}

Measured memory_bytes: 46080
S = input()
left = int(S[0:2])
right = int(S[2:])
if 1 <= left <= 12 and 1 <= right <= 12:
  print('AMBIGUOUS')
elif 0 <= left <= 99 and 1 <= right <= 12:
  print('YYMM')
elif 1 <= left <= 12 and 0 <= right <= 99:
  print('MMYY')
else:
  print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vii vector<int,int>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define all(a) a.begin(),a.end()
const int mod=1e9+7;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main(){
    fast;
    string s1,s2;
    cin>>s1;
    cin>>s2;
    int y=s1.length();
    int z=s2.length();
    int dp[y+1][z+1];
    for(int i=0;i<=y;i++){
        for(int j=0;j<=z;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else{
                if(s1[i-1]!=s2[j-1]){
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
                else{
                    dp[i][j]=dp[i-1][j-1]+1;
                }
            }
        }
    }
    int req=dp[y][z];
    int p=req;
    int l=y,r=z;
    string res[req];
    while(req>0){
        if(s1[l-1]==s2[r-1]){
            req--;
            res[req]=s1[l-1];
            l--;
            r--;
        }
        else{
            if(dp[l-1][r]<=dp[l][r-1]){
                r--;
            }
            else{
                l--;
            }
        }
    }
    for(int i=0;i<p;i++){
        cout<<res[i];
    }
}

Measured memory_bytes: 35584
s=list(input())
n=len(s)
p=[]
q=[]
cnt_p=0
cnt_q=0

if n%2!=0:
  m=(n-1)//2
  p.extend(['0','1']*m)
  p.append('0')
  q.extend(['1','0']*m)
  q.append('1')
else:
  m=n//2
  p.extend(['0','1']*m)
  q.extend(['1','0']*m)
for i in range(n):
  if s[i]==p[i]:
    cnt_p+=1
  else:
    cnt_q+=1
print(min(cnt_p,cnt_q))


  
  

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

struct item { ll weight, value; };

const ll INF = 1LL << 50;

vector<ll> travel_time(vector<ll> X, vector<ll> Y, ll N) {
  vector<vector<ll>> dp(1 << N, vector<ll>(N, INF));
  REP(i, 0, N) dp[1 << i][i] = abs(X[i]) + abs(Y[i]);
  REP(s, 0, 1 << N) REP(i, 0, N) if(s & (1 << i)) {
    REP(j, 0, N) if(!(s & (1 << j))) {
      dp[s | (1 << j)][j] = min(dp[s | (1 << j)][j], dp[s][i] + abs(X[i] - X[j]) + abs(Y[i] - Y[j]));
    }
  }

  vector<ll> t(1 << N, INF);
  REP(s, 0, 1 << N) REP(i, 0, N) t[s] = min(t[s], dp[s][i] + abs(X[i]) + abs(Y[i]));
  return t;
}

vector<ll> profit(vector<vector<ll>> weight, vector<vector<ll>> value, vector<ll> L, ll N, ll W) {
  vector<ll> ret(1 << N, 0);
  REP(s, 0, 1 << N) {
    vector<ll> dp(W + 1, 0);
    dp[0] = 0;
    REP(i, 0, N) if(s & (1 << i)) REP(j, 0, L[i]) {
      REP(w, 0, W + 1) if(w + weight[i][j] <= W) {
        dp[w + weight[i][j]] = max(dp[w + weight[i][j]], dp[w] + value[i][j]);
      }
    }
    REP(i, 0, W + 1) ret[s] = max(ret[s], dp[i]);
  }
  return ret;
}

int main(void) {
  ll N, M, W, T;
  cin >> N >> M >> W >> T;
  map<string, item> items;
  REP(i, 0, M) {
    string S;
    cin >> S;
    cin >> items[S].weight >> items[S].value;
  }
  vector<ll> L(N), X(N), Y(N);
  vector<vector<ll>> weight(N), value(N);
  REP(i, 0, N) {
    cin >> L[i] >> X[i] >> Y[i];
    weight[i].resize(L[i]);
    value[i].resize(L[i]);
    REP(j, 0, L[i]) {
      string S;
      ll x;
      cin >> S >> x;
      weight[i][j] = items[S].weight;
      value[i][j] = items[S].value - x;
    }
  }

  vector<ll> t = travel_time(X, Y, N);
  vector<ll> p = profit(weight, value, L, N, W);

  vector<ll> dp(T + 1, 0);
  dp[0] = 0;
  REP(i, 0, 1 << N) {
    REP(j, 0, T + 1) if(j + t[i] <= T) {
      dp[j + t[i]] = max(dp[j + t[i]], dp[j] + p[i]);
    }
  }

  ll ans = 0;
  REP(i, 0, T + 1) ans = max(ans, dp[i]);
  cout << ans << endl;
}


Measured memory_bytes: 3296
<?php
/**
 * ABC129
 * A - Airplane
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d %d", $p, $q, $r);

echo min($p + $q, $q + $r, $r + $p), PHP_EOL;


Measured memory_bytes: 4728
#-*- coding: utf-8 -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_b -d test-b
oj test -d test-c -c "python abc116c.py"
oj test -d test-b -c "python abc116b.py" test-b/sample-3.in
"""

from collections import defaultdict
import sys
import math
import time

def deco(func):
    def wrapper(*args, **kwargs):
        s = time.time()
        #print('--start--')
        ret = func(*args, **kwargs)
        logging.debug('--end in %f --' % (time.time() - s) )
        return ret
    return wrapper


#@deco
def sol(S, n):
    cnt = 0
    ttl = sum(S)
    while ttl > 0:
        mark = False
        for i, s in enumerate(S):
            if s > 0:
                mark = True
                S[i]-=1
            elif mark and s == 0:
                break
        logging.debug("ttl:%s, cnt:%s, S:%s" % (ttl, cnt, S))
        cnt += 1
        ttl = sum(S)
    return cnt



import logging
#logging.basicConfig(level=logging.DEBUG, format="%(message)s")
logging.basicConfig(level=logging.ERROR, format="%(message)s")
do_submit = True
#do_submit = False
def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(int, line.split())) for line in lines]
    n = parsed_lines[0][0]
    S = parsed_lines[1]
    return (n, S)


if not do_submit:
    # n, S= input_parse("""
    # 4
    # 1 2 2 1
    # """)
    n, S= input_parse("""
    5
    3 1 2 3 1
    """)
    print(sol(S, n))
else:
    # a, b, c = list(map(int, input().split()))
    # print(sol(a, b, c))
    n = int(input())
    S = list(map(int, input().split()))
    print(sol(S, n))




Measured memory_bytes: 4576
#include <iostream>
#include <string>
using namespace std;
#define MAX 100000

int main()
{
	int N, H[MAX];
	string judge = "Yes";
	cin >> N;
	for (int i = 0; i < N; i++)cin >> H[i];
	for (int i = N-1; i > 0; i--) {
		if (H[i] == (H[i - 1] - 1)) {
			H[i - 1]--;
		}
		else if ((H[i - 1] - H[i]) > 1)judge = "No";
	}
	cout << judge << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int c[3];
	c[0]=a+b;
	c[1]=a-b;
    c[2]=a*b;
    sort(c,c+3);
    cout<<c[2]<<endl;
    return 0;
}

Measured memory_bytes: 256
//Diljit Dosanjh is the best.
#include<bits/stdc++.h>
using namespace std;
#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef long double ld;
const ld pi=3.1415926535897932384626433;
const int mod = 1000000007;
const ll inf = 1e18;
void solve()
{
   string s;
   cin>>s;
   ll k=0;
   ll ans=0;
   for (ll i=0;i<3;i++)
   {
      if (s[i]=='R')
      k++;
      else
      {
         ans=max(ans,k);
         k=0;
      }
   }
   ans=max(ans,k);
   cout<<ans<<endl;
}
int main()
{
   #ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin); 
   freopen("output.txt", "w", stdout); 
   #endif
   bolt;
   ll t;
   t=1;
   while(t--)
   {
      solve();
   }
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>
#include<bitset>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const double EPS = 0.000000000001;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================


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

	int four = 0;
	int odd = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] % 4 == 0) {
			four++;
		}
		else if (A[i] % 2 == 1) {
			odd++;
		}
	}

	if (N % 2 == 0) {
		if (four >= odd) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}
	else {
		if (four >= odd - 1) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}






}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<string.h>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;


int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int abmax = 2 * max(x, y);
    const int inf = 10000000000;
    int res = inf;
    rep(i, abmax + 1)
    {
        int cost = c * i + a * max(0, (x - i / 2)) + b * max(0, (y - i / 2));
        res = min(res, cost);
    }
    cout << res << endl;
}


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

using namespace std;

int main()
{
    long long n,k;
    cin>>n>>k;
    vector<long long> v(n);
    for(int i = 0;i<n;i++)
    {
        cin>>v[i];
    }

    sort(v.begin(),v.end());
    long long answer = 0;
    if(k >= n)
    {
        answer = 0;
    }
    else
    {
        for(int i = 0;i<n-k;i++)
        {
            answer += v[i];
        }
    }

    cout<<answer;

    return 0;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e5 + 5, inf = 1e9;
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define sz(x) (int)x.size()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll n;
	cin >> n;
	ll ans = 0;
	if(n == 2){
		cout << "1\n";
		return 0;
	}
	for(int i = 2; (ll)i * i <= n - 1; i++){
		if((n - 1) % i == 0){
			ans++;
			if((n - 1) / i != i){
				ans++;
			}
		}
	}
	for(int i = 2; (ll)i * i <= n; i++){
		if(n % i == 0){
			ll tmp = n;
			while(tmp % i == 0)tmp /= i;
			ans += ((tmp % i) == 1);
			if(n / i != i){
				tmp = n;
				while(tmp % (n / i) == 0)tmp /= (n / i);
				ans += ((tmp % (n / i)) == 1);
			}
		}
	}
	cout << ans + 2 << '\n';
	return 0;
}



Measured memory_bytes: 256
s=input()
t=input()

ns = len(s)
nt = len(t)
ans = nt

for i in range(ns-nt+1):
    m=nt
    for j in range(nt):
        if s[i+j]==t[j]:
            m-=1
    ans = min(ans,m)
print(ans)

Measured memory_bytes: 67572
public class Main {
  private static void solve() {
    int a = ni();
    int p = ni();
    
    System.out.println((a * 3 + p) / 2);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 21332
#include<stdio.h>
int main()
{
    int A,B,K;
//    int r,tmp;
    int count = 0;

    scanf("%d %d %d", &A,&B,&K);

    int c;


    for(int i = A;count<K;i--){
        if(A%i==0 && B%i==0){
            count++;
            c = i;
        }
    }
    printf("%d\n",c);
    return 0;

}

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

int main() {
  int N;
  cin >> N;
  vector<double> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  vector<vector<double>> dp(N + 1, vector<double> (N + 1));
  dp.at(0).at(0) = 1.0;
  for (int i = 1; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if (j != 0) {
        dp.at(i).at(j) += dp.at(i - 1).at(j - 1) * p.at(i - 1);
      }
      dp.at(i).at(j) += dp.at(i - 1).at(j) * (1.0 - p.at(i - 1));
    }
  }
  double result = 0.0;
  for (int i = ((N + 1) / 2); i <= N; i++) {
    result += dp.at(N).at(i);
  }
  cout << fixed << setprecision(10);
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 73808
import bisect
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A.sort()
B.sort()
C.sort()
count = 0
for Bi in B:
    idx_A = bisect.bisect_left(A, Bi)
    idx_C = bisect.bisect_right(C, Bi)
    count += (idx_A) * (len(C) - idx_C)
print(count)

Measured memory_bytes: 23232
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		System.out.println(solve(n));
		in.close();
	}

	static int[][][][] h = new int[4][4][4][100];
	static int[] hi = new int[256];

	private static int solve(int n) {
		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 4; j++)
				for (int k = 0; k < 4; k++)
					for (int l = 0; l < 100; l++)
						h[i][j][k][l] = -1;
		hi['A'] = 0;
		hi['G'] = 1;
		hi['C'] = 2;
		hi['T'] = 3;
		char[] s = new char[n];
		return fnc(s, 0);
	}

	private static int fnc(char[] s, int i) {
		if (!chk(s, i - 1))
			return 0;
		if (i == s.length)
			return 1;
		if (hist(s, i) >= 0)
			return hist(s, i);
		int c = 0;
		s[i] = 'A';
		c += fnc(s, i + 1);
		c %= 1000000007;
		s[i] = 'G';
		c += fnc(s, i + 1);
		c %= 1000000007;
		s[i] = 'T';
		c += fnc(s, i + 1);
		c %= 1000000007;
		s[i] = 'C';
		c += fnc(s, i + 1);
		c %= 1000000007;
		histSave(s, i, c);
		return c;
	}

	private static void histSave(char[] s, int m, int c) {
		if (m > 3)
			h[hi[s[m - 3]]][hi[s[m - 2]]][hi[s[m - 1]]][m] = c;
	}

	private static int hist(char[] s, int m) {
		if (m < 4)
			return -1;
		return h[hi[s[m - 3]]][hi[s[m - 2]]][hi[s[m - 1]]][m];
	}

	private static boolean chk(char[] s, int r) {
		if (r < 2)
			return true;
		if (s[r - 2] == 'A' && s[r - 1] == 'G' && s[r] == 'C')
			return false;
		if (s[r - 2] == 'A' && s[r - 1] == 'C' && s[r] == 'G')
			return false;
		if (s[r - 2] == 'G' && s[r - 1] == 'A' && s[r] == 'C')
			return false;
		if (r < 3)
			return true;
		if (s[r - 3] == 'A' && s[r - 1] == 'G' && s[r] == 'C')
			return false;
		if (s[r - 3] == 'A' && s[r - 2] == 'G' && s[r] == 'C')
			return false;
		return true;
	}
}

Measured memory_bytes: 23764
#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 a, b, c, d, e, f, g;
int main(){
	cin >> a >> b >> c >> d >> e >> f >> g;
	long long num = 0;
	num += 2 * (a/2);
	num += 1 * (b);
	num += 2 * (d/2);
	num += 2 * (e/2);
	long long NUM = 0;
	if(a>0 && d>0 && e>0){
		NUM += 3;
		a--;
		d--;
		e--;
	}
	NUM += 2 * (a/2);
	NUM += 1 * (b);
	NUM += 2 * (d/2);
	NUM += 2 * (e/2);

	cout << max(num, NUM) << endl;
}

Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 int main()
 {
   int num;
   double w,h;
   map<int,double> mm;
   map<int,double>::iterator iter;
   char temp1,temp2;
   while(cin>>num>>temp1>>w>>temp2>>h) mm[num]=w/(pow(h,2));                       
   for(iter=mm.begin();iter!=mm.end();++iter)
   {
     if(iter->second>=25) cout<<iter->first<<endl;                                          
   }
   //while(1);
   return 0; 
 }

 

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll a,b; cin>>a>>b;
	if(a==1 && b==1) cout<<1;
	else if(a==1 || b==1) cout<<1;
	else if(a*b%2) cout<<a*b/2+1;
	else cout<<a*b/2;
		
	
	return 0;
}

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

int main() {
 int n;
  cin >> n ;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin >>a.at(i);
    b.at(i) = a.at(i);
   }
  sort(b.begin(),b.end()) ;
 for(int i=0;i<n;i++){
     if (a.at(i) == b.at(b.size()-1)){
       cout << b.at(b.size()-2)<<endl;
     }
     else{
       cout <<b.at(b.size()-1)<<endl;
     }
   }
}


Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int main()
{
	int n,m,q,k;
	cin>>n;
	n%=1000;
	cout<<(1000-n)%1000;
}



Measured memory_bytes: 3632
from collections import defaultdict

def solve():
    N = input()
    d = defaultdict(str)
    d['a'] = 'b'
    d['b'] = 'c'
    d['c'] = 'd'
    d['d'] = 'e'
    d['e'] = 'f'
    d['f'] = 'g'
    d['g'] = 'h'
    d['h'] = 'i'
    d['i'] = 'j'
    d['j'] = 'k'
    d['k'] = 'l'
    d['l'] = 'm'
    d['m'] = 'n'
    d['n'] = 'o'
    d['o'] = 'p'
    d['p'] = 'q'
    d['q'] = 'r'
    d['r'] = 's'
    d['s'] = 't'
    d['t'] = 'u'
    d['u'] = 'v'
    d['v'] = 'w'
    d['w'] = 'x'
    d['x'] = 'y'
    d['y'] = 'z'
    return d[N]

print(solve())

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,d,a,ba=0;
	set<int> mon;
	cin>>n>>k;
	for(int t=0;t<k;t++)
	{
		cin>>d;
		for(int i=0;i<d;i++)
		{
			cin>>a;
			mon.insert (a);
		}
	}
	cout<<n-mon.size();
	return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner
import kotlin.system.exitProcess

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val s = scn.next().toCharArray()
	if (s.size%2!=0) {
		print("No")
		exitProcess(0)
	}
	for (i in s.indices){
		if (s[i] != when(i%2){0 -> {'h'} else -> {'i'}}){
			print("No")
			exitProcess(0)
		}
	}
	print("Yes")

}

Measured memory_bytes: 34248
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
  ll m,d; cin>>m>>d;
  ll ans=0;
  for(int i=1;i<=d;i++){
      ll a=i/10,b=i%10;
      if(a>=2&&b>=2&&a*b<=m)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<list>
#include<string>
using namespace std;
int main(){
	list<char> left={'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
	list<char> right={'y','u','i','o','p','h','j','k','l','n','m'};
	bool flag;
	while(1){
		string str;
		int cnt=0;
		cin >> str;
		if(str=="#")	break;
		if(find(right.begin(),right.end(),str[0])!=right.end())	flag = false;
		else flag = true;
		for(int i=1;i<str.size();i++){
			if(find(right.begin(),right.end(),str[i])!=right.end()){
				if(flag)	cnt++;
				flag = false;
			}
			else{
				if(!flag)	cnt++;
				flag =true;
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(abs(x-a)<abs(x-b))
        cout<<"A"<<endl;
    else
        cout<<"B"<<endl;
}

Measured memory_bytes: 256
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	int a,b;
	cin>>a>>b;
	for(int i=0;i<1000000000;i++)
	{
		if(abs(a-i)==abs(b-i))
		{
			cout<<i;
			return;
		}
	}
	cout<<"IMPOSSIBLE";
}
int main()
{
//code

fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 256
#一つの数式が一行に与えられます
#連続するシンボルは一つの空白で区切られて与えられます
#計算結果を一行に出力してください
require "pp"


input = gets.chomp.split(" ")
stack = %w[]
input.each do |str|
  if str =~ /^[0-9]/
    stack.push str
  else
    if str == "+"
      second = stack.pop.to_i
      first = stack.pop.to_i
      stack.push(first+second)
    elsif str == "-"
      second = stack.pop.to_i
      first = stack.pop.to_i
      stack.push(first-second)
    elsif str == "*"
      second = stack.pop.to_i
      first = stack.pop.to_i
      stack.push(second*first)
    end
  end
end
puts stack[0]



Measured memory_bytes: 7028
def main():
    N = int(input())
    S = input()
    
    ans = S.count('R') * S.count('G') * S.count('B')

    for i in range(N-2):
        for j in range(i+1, i+1+(N-1-i)//2):
            k = j + (j - i)
            if S[i] != S[j] != S[k] != S[i]:
                ans -= 1
            
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << "\n"; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


VV G;
V a, dp, ans;

void dfs(int u, int p=-1) {
  int i = lower_bound(all(dp), a[u]) - dp.begin();
  int tmp = dp[i];
  dp[i] = a[u];
  ans[u] = lower_bound(all(dp), INF) - dp.begin() - 1;
  for (auto &v : G[u]) if (v != p) dfs(v, u);
  dp[i] = tmp;
}


int main() {
  ll n; cin >> n;
  G.assign(n, V());
  a.assign(n, 0);
  dp.assign(n+1, INF);
  ans.assign(n, INF);
  dp[0] = -INF;
  cin >> a;

  rep(i, n-1) {
    int u, v; cin >> u >> v;
    --u, --v;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  dfs(0);

  cout << ans;
  return 0;
}


Measured memory_bytes: 27960
#include "bits/stdc++.h"
 
using namespace std;
 
#define int long long
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FORR(i, a, b) for (int i = (a); i >= (b); i--)
 
#define pb push_back
#define VDEL(v, n) v.erase(v.begin() + (n))
#define ALL(v) v.begin(), v.end()
 
#define INT_INF 200000000
 
#define TINT(str) atoi(str.c_str())
#define TSTR(num) to_string(num)
 
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<vector<int>> VII;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
 
//the end of library zone

int N, Q, S, T;
int H[200010];

int calc(int val){
    if(val > 0){
        return -S * val;
    }
    else if(val < 0){
        return -T * val;
    }
    else return 0;
}

signed main() {
    cin >> N >> Q >> S >> T;

    int A = 0;

    cin >> H[0];

    int past = 0;

    REP(h, N){
        int now;
        cin >> now;
        H[h + 1] = now - past;
        A += calc(H[h + 1]);

        past = now;
    }

    REP(q, Q){
        int R, L, X;
        cin >> L >> R >> X;
        int pastv = calc(H[L]);
        int newv = calc(H[L] + X);
        A += (newv - pastv);
        H[L] += X;

        if(R + 1 <= N){
            pastv = calc(H[R + 1]);
            newv = calc(H[R + 1] - X);
            A += (newv - pastv);
            H[R + 1] -= X;
        }

        cout << A << endl;
    }

    return 0;
}


Measured memory_bytes: 4672
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename key>
using ordered_set = tree<key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
#define F first
#define S second
#define T second.first
//#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(v) v.begin(),v.end()
#define OO 0x3f3f3f3fLL
#define INF 0x3f3f3f3f3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll,pair<ll,ll>> piii;
const int N = 2e5+5, M= 20, mod = 1000000000;
const double EPS = 1e-10;


int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ll a;
    cin>>a;
    cout<<a+(a*a)+a*a*a;
}


Measured memory_bytes: 3628
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
string t,s;
cin>>s>>t;
cout<<t<<s<<endl;
}

Measured memory_bytes: 256
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>k;
		// n=s.length();
		ll dp[k];
		for(i=k;i>0;i--)
		{
			m=(k/i);
			j=power(m,n);
			for(ll p=2*i;p<=k;p+=i)
				j=(j-dp[p]+mod)%mod;
			dp[i]=j;
			c=(c+(j*i)%mod)%mod;
		}
		c=(c)%mod;
		cout<<c;

		
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 4292
#include<bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (int)(n); i++)
#define all(a) a.begin(), a.end()
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

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

    vector<ll> ans;

    ans.push_back(a*c);
    ans.push_back(a*d);
    ans.push_back(b*c);
    ans.push_back(b*d);
    put(*max_element(all(ans)));
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int n = stdIn.nextInt();
		int count = 1;

		char[] a = stdIn.next().toCharArray();
	

		for(int i = 0; i < n-1; i++) {
			if(a[i] != a[i+1]) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 27244
#include <cstdio>

#define N 100050
#define INF 1000000007
#define Min(a,b) (a<b?a:b)

int eg[N*2],nxt[N*2],wi[N*2],head[N],egtot;
void addEdge(int p1,int p2,int w)
{
	eg[++egtot]=p2;
	nxt[egtot]=head[p1];
	wi[egtot]=w;
	head[p1]=egtot;
}

int len[N],sz[N];
int n;
long long ans;
void dfs(int p,int fa)
{
	sz[p]=1;
	for(int i=head[p];i;i=nxt[i])
		if(eg[i]!=fa)
		{
			len[eg[i]]=wi[i];
			dfs(eg[i],p);
			sz[p]+=sz[eg[i]];
		}
//	printf("ans+ %d*%d\n",Min(sz[p],n-sz[p]),len[p]);
	ans+=(long long)Min(sz[p],n-sz[p])*len[p]*2;
}

int findCenter(int p,int fa)
{
	for(int i=head[p];i;i=nxt[i])
		if(eg[i]!=fa && sz[eg[i]]*2>=n)
			return findCenter(eg[i],p);
	return p;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++)
	{
		int p1,p2,w;scanf("%d%d%d",&p1,&p2,&w);
		addEdge(p1,p2,w);
		addEdge(p2,p1,w);
	}
	dfs(1,0);
	int ctr=findCenter(1,0);
	if(sz[ctr]*2==n)
		ans-=len[ctr];
	else
	{
		int minl=INF;
		for(int i=head[ctr];i;i=nxt[i])
			minl=Min(minl,wi[i]);
		ans-=minl;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 7680
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n,m;cin>>n>>m;
  for(int i = 0; m > i; i++){
    int t;cin>>t;
    n-=t;
  }
  if(n < 0){
    cout << -1 << endl;
  }else{
    cout << n << endl;
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    
    for(int i=0; i<n; i++)
        cin >> v[i];
    int tot=0;
    for(int i=0; i<n; i++){
        int lim=(int)(sqrt(v[i]));
        int cnt=0;
        for(int j=2; j<=lim; j++){
            if(v[i]%j==0)
                cnt++;
        }
        if(cnt==0) tot++;
    }
    cout << tot << endl;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
int p,flag,ans=-1;
string s;
map<int,char>cc;
int bnf1();
int get_A(){
  int res=0;
  if(s[p]=='(')p++,res=bnf1(),p++;
  else if(isdigit(s[p])){
    while(isdigit(s[p]))res=res*2+(s[p++]-'0');
  }
  else flag++;
  if(res>=1024)flag++;
  if(res<0)flag++;
  return res;
}
int bnf2(){
  int res=get_A();
  while(s[p]=='*'){
    int t=p++;
    if(s[t]=='*')res*=get_A();
    if(res>=1024)flag++;
    if(res<0)flag++;
  }
  if(res>=1024)flag++;
  if(res<0)flag++;
  return res;
}
int bnf1(){
  int res=bnf2();
  while(s[p]=='+'||s[p]=='-'){
    int t=p++;
    if(s[t]=='+')res+=bnf2();
    if(s[t]=='-')res-=bnf2();
    if(res>=1024)flag++;
    if(res<0)flag++;
  }
  if(res>=1024)flag++;
  if(res<0)flag++;
  return res;
}
bool ch(){
  int t=0;
  stack<int>st;
  r(i,s.size()){
    if(s[i]=='(')t++;
    if(s[i]==')'){
      int tt=0;
      if(!st.empty()&&st.top()!=t)return 0;
      while(!st.empty()&&st.top()==t)st.pop(),tt++;
      if(!tt)return 0;
      t--;
    }
    if(s[i]=='+'||s[i]=='-'||s[i]=='*')st.push(t);
  }
  if(t)return 0;
  return 1;
}
void dfs(int d){
  if(d==s.size()){
    p=0;
    if(ch()){
      p=flag=0;
      int res=bnf1();
      if(!flag&&p==s.size())ans=max(ans,res);
    }
  }
  else if(s[d]=='.'){
    r(i,7){
      s[d]=cc[i];
      dfs(d+1);
    }
    s[d]='.';
  }
  else dfs(d+1);
}
main(){
  cin>>s;
  cc[0]='0';
  cc[1]='1';
  cc[2]='+';
  cc[3]='-';
  cc[4]='*';
  cc[5]='(';
  cc[6]=')';
  dfs(0);
  cout<<ans<<endl;
}

Measured memory_bytes: 3208
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

string S,T;

int main(){
    cin>>S>>T;

    rep(i,S.size()){
        if(S[i]!=T[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3624
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if A.__contains__(0):
        print(0)
        return

    ans = A[0]
    for v in range(1, N):
        if ans > 10 ** 18:
            print(-1)
            return
        else:
            ans *= A[v]
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21664
///**Bismillahir Rahmanir Rahim.**
//Accepted

#include <bits/stdc++.h>
#define clr(a, v)             memset(a, v, sizeof a)
#define all(v)                v.begin(), v.end()
#define ast(v)                sort(v.begin(),v.end())
#define dst(v)                sort(v.begin(),v.end(), greater <int> ())
#define fast ios_base::       sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ass(tmp, v)           tmp.assign(v.begin(), v.end())
#define mid(b, e)             (b+e)/2
#define left(node)            node*2
#define right(node)           node*2+1
#define rep(i, l, r)          for (int i = l; i < r; i++)
#define rep2(i, l, r)         for (int i = l-1; i >= r; i--)
#define sf(n)                 scanf("%d", &n)
#define sff(n, m)             scanf("%d %d",&n,&m)
#define sfl(n)                scanf("%lld", &n)
#define sffl(n, m)            scanf("%lld %lld",&n,&m)
#define sfff(n, m, o)         scanf("%d %d %d",&n,&m, &o)
#define pf(n)                 printf("%d", n)
#define sp                    printf(" ")
#define nl                    printf("\n")
#define prln(n)               printf("%d\n", n)
#define pfl(n)                printf("%lld", n)
#define pb                    push_back
#define pii                   pair<int,int>
#define mp                    make_pair
#define S                     second
#define F                     first
#define PI                    3.1415926

struct greaters
{
    bool operator()(const long& a, const long& b) const
    {
        return a > b;
    }
};

//-----------------------------------***********************----------------------------------------------//

typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int N = 200050;
const int mod = 1e9+7;

void reset(){

}

int main(){
    //freopen("test.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    int tc = 1, cas = 0;
    while(tc--){
      //reset();
      ll n; cin >> n;
      ll a[n+5]; cin >> a[0];
      ll ans = 0, start_idx = 0;
      
      rep(i, 1, n){
      	cin >> a[i];
      	if(a[i] > a[i-1]) start_idx = i;
	  	ans = max(ans, i - start_idx);
	  }
	  cout << ans << '\n';
      ///printf("Case %d: %lld\n", ++cas, ans);
    }
    return 0;

}

//-----------------------------------***********************----------------------------------------------//



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, i, j, k;
	cin >> n;
	ll ans = 0;
	foe(i, 1, n) {
		foe(j, 1, n) {
			foe(k, 1, n) 
			ans += __gcd(i, __gcd(j, k));
		}
	}
	cout << ans;
}


Measured memory_bytes: 3656
use std::io::{stdin, Read};


fn main() {
    let mut buffer = String::new();
    let mut stdin = stdin();

    stdin.read_to_string(&mut buffer).unwrap();
    let rows: Vec<&str> = buffer.split('\n').collect();
    let row1: Vec<&str> = rows[0].split(' ').collect();
    let row2: Vec<&str> = rows[1].split(' ').collect();
    let n: u64 = row1[0].parse().unwrap();
    let mut res: u64 = 1;

    for i in 0..n {
        let num: u64 = row2[i as usize].parse().unwrap(); 
        if num == 0 {
            println!("0");
            return;
        }
    }

    for i in 0..n {
        let num: u64 = row2[i as usize].parse().unwrap(); 
        if res > 10u64.pow(18) / num {
            println!("-1");
            return;
        }
        res *= num;
        if res > 10u64.pow(18) {
            println!("-1");
            return;
        }
    }

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


Measured memory_bytes: 5532
from collections import defaultdict
import sys

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
a = read_int()
a.sort()

def solve():
    counts = defaultdict(lambda: int())
    keys = []
    for i in range(N):
        if counts[a[i]] == 0:
            keys.append(a[i])
        counts[a[i]] += 1
    if len(counts) == 1 and keys[0] == 0:
        return 'Yes'
    if len(counts) == 2:
        if counts[keys[0]] * 2 == counts[keys[1]] and check_xor(keys[1], keys[0], keys[1]):
            return "Yes"
        elif counts[keys[1]] * 2 == counts[keys[0]] and check_xor(keys[0], keys[1], keys[0]):
            return "Yes"
    if len(counts) == 3:
        if counts[keys[0]] == counts[keys[1]] == counts[keys[2]] and check_xor(*keys):
            return "Yes"
    return "No"

def check_xor(a, b, c):
    return a^c == b

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 14460
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(n + 1, vector<ll>(2501)));
    dp[0][0][0] = 1;
    dp[0][1][x[0]] = 1;
    ll ans = 0;
    for (int i = 1; i < n; ++i) {
        dp[i][0][0] = 1;
        for (int j = 1; j <= i + 1; ++j) {
            for (int k = 0; k <= 2500; ++k) {
                if (j <= i) {
                    dp[i][j][k] += dp[i - 1][j][k];
                }
                if (k - x[i] >= 0) {
                    dp[i][j][k] += dp[i - 1][j - 1][k - x[i]];
                }
            }
        }
    }
    for (int j = 1; j <= n; ++j) {
        ans += dp.back()[j][a * j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 51200
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

char s[15];
int pos[15];
long long num(int l,int r)
{
    long long ans=0;
    for(int i=l;i<=r;i++)
    {
        ans=ans*10+s[i]-'0';
    }
    return ans;
}
long long solve(int n)
{
    int l=-1,r=0;
    long long ans=0;
    pos[n]=1;
    for(int i=0;i<=n;i++)
    {
        if(pos[i]==0)
            r++;
        else
        {
            ans+=num(l+1,i);
            l=i;
        }
    }
    return ans;
}
int main()
{
    scanf("%s",s);
    int n=strlen(s);
    long long ans=0;
    int R= (1<<(n-1))-1 ;
    for(int i=0;i<=R;i++)
    {
        memset(pos,0,sizeof(pos));
        int tot=0;
        int temp=i;
        while(temp)
        {
            pos[tot++]=temp%2;
            temp=temp/2;
        }
        ans+=solve(n-1);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256