akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n,m;cin >> n >> m;
    vector<int> a(n),b(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(RALL(a));
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    sort(RALL(b));
    LL h=0,w=0;
    LL ans = 1, res = 0;
    for (int i = n*m; i >= 1; i--) {
        if(h < n && i == a[h] && w < m && i == b[w]){
            h++;
            w++;
            res += h + w - 2;
        }
        else if(h < n && i == a[h]){
            if(w==0) ans = 0;
            h++;
            res += w - 1;
            ans = ans * w % mod;
        }
        else if(w < m && i == b[w]){
            if(h==0) ans = 0;
            w++;
            res += h - 1;
            ans = ans * h % mod;
        }
        else{
            if(res <= 0) ans = 0;
            ans = ans * res % mod;
            res--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int i, j, k, n, A[100];

void pr(){
	for(j = 0; printf("%d", A[j]), j < n-1; j++) printf(" ");
	printf("\n");
}

int main(){
	scanf("%d", &n);
	while(i < n) scanf("%d", &A[i++]);
	for(i = 0; i < n; i++){
		for(j = i, k = A[i]; j > 0 && k < A[j-1]; j--) A[j] = A[j-1];
		A[j] = k;
		pr();
	}
	return 0;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int N;
  string S,T;
  cin >> N >> S;
  int M = SZ(S);
  REP(i,M) {
    T += (char)('A' + (S.at(i) - 'A' + N)%26);
  }
  cout << T << endl;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, raw_input().split(" "))

max_l = -1
min_r = 999999
for i in range(0, m):
    l, r = map(int, raw_input().split(" "))
    max_l = max(max_l, l)
    min_r = min(min_r, r)

ans = min_r - max_l + 1

if ans <= 0:
    print(0)

else:
    print(ans)



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

string con = "w kstnhmyrw";

char getVowel(char ch){
  if(ch == 'T') return 'a';
  if(ch == 'L') return 'i';
  if(ch == 'U') return 'u';
  if(ch == 'R') return 'e';
  if(ch == 'D') return 'o';
}

int main(){
  string s;

  while(cin >> s){

    for(int i = 0; i < s.length(); i += 2){
      int button = s[i] - '0';
      char vowel = getVowel(s[i + 1]);

      if(button == 1){
	cout << vowel;
      }
      else if(button == 0 && vowel == 'u'){
	cout << "nn";
      }
      else{
	cout << con[button] << vowel;
      }
    }

    cout << endl;
  }
}

Measured memory_bytes: 1188
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LS() for _ in range(n)]
    r = 0
    for x,u in a:
        if u == 'JPY':
            r += int(x)
        else:
            r += float(x) * 380000.0

    return '{:0.9f}'.format(r)



print(main())




Measured memory_bytes: 5576
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	long long n;
	cin >> n;
	int count = 1;
	long long m = 3;
	while(n>m){
		count++;
		m *= 3;
	}
	cout << count << endl;
}

Measured memory_bytes: 3096
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#define mod1 998244353
#define base1 19260817
#define mod2 998244853
#define base2 666623333
#define M 1000005
typedef long long ll;
int n,G[M];
std::pair <int,int> F[M];
std::map <std::pair <int,int>,int> Map;
ll ans;
int read(){
	char c=getchar();int ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar();
	return ans;
}
int read_opt(){
	char c=getchar();
	while (c!='<'&&c!='>'&&c!='+'&&c!='-') c=getchar();
	return c=='<'?1:(c=='>'?2:(c=='+'?3:4));
}
void Write(ll x){
	if (x<10) putchar(x^48);
	else Write(x/10),putchar((x%10)^48);
	return;
}
int power(ll x,int y,int mod){
	ll ans=1;if (y<0) y+=mod-1;
	for (;y;y>>=1,x=x*x%mod)
		if (y&1) ans=ans*x%mod;
	return ans;
}
int add(int x,int y,int mod){return (x+=y)>=mod?x-mod:x;}
int sub(int x,int y,int mod){return (x-=y)<0?x+mod:x;}
int main(){
	n=read();
	for (register int i=1;i<=n;i++)
		switch (read_opt()){
			case 1:F[i]=F[i-1],G[i]=G[i-1]-1;break;
			case 2:F[i]=F[i-1],G[i]=G[i-1]+1;break;
			case 3:G[i]=G[i-1],F[i]=std::make_pair(add(F[i-1].first,power(base1,G[i],mod1),mod1),add(F[i-1].second,power(base2,G[i],mod2),mod2));break;
			case 4:G[i]=G[i-1],F[i]=std::make_pair(sub(F[i-1].first,power(base1,G[i],mod1),mod1),sub(F[i-1].second,power(base2,G[i],mod2),mod2));break;
		}
	for (register int i=n,X,Y;i>=0;++Map[F[i--]])
		X=((F[n].first+0ll)*power(base1,G[i],mod1)+F[i].first)%mod1,
		Y=((F[n].second+0ll)*power(base2,G[i],mod2)+F[i].second)%mod2,
		ans+=Map[std::make_pair(X,Y)];
	Write(ans);
	return 0;
}


Measured memory_bytes: 37740
(* O(n) *)
let solve n a_s = List.fold_left max 0 a_s - List.fold_left min max_int a_s

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  let n = read_int () in
  read_ints () |> solve n |> string_of_int |> print_endline

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;
const int MOD = (int)1e9 + 7;

int main()
{
  int N, M;
  scanf("%d %d", &N, &M);

  vector<ll> modfact(N + 5, 1);
  for (int i = 2; i <= N + 1; ++i) {
    modfact[i] = (modfact[i - 1] * i) % MOD;
  }
  ll ans = 0;
  if (N == M) {
    ans = (modfact[N] * modfact[M]) % MOD;
    ans = (ans * 2) % MOD;
  }
  else if (abs(N - M) == 1) {
    ans = (modfact[N] * modfact[M]) % MOD;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define piii pair<ll, pii>
#define MOD 1000000007
#define M 100005
#define inf 1000000005
using namespace std;
ll dp[105][M];
int main(){
    //ll t; cin>> t; while(t--){
        ll n, w;
        cin>> n >> w;
        ll W[n+1], v[n+1];
        for(ll i =1;i<=n;i++){
            cin>> W[i] >> v[i];

        }
        for(ll i =0;i<=n;i++){ // no of item
            for(ll j =0;j<=w;j++){ // weight
                if(i==0 || j==0) dp[i][j] = 0;
                else{
                    if(j>=W[i]){
                        dp[i][j] =  max(dp[i-1][j], dp[i-1][j- W[i]] + v[i]);
                    }
                    else  dp[i][j] = dp[i-1][j];
                }
            }
        }
        cout << dp[n][w] << endl;

}


Measured memory_bytes: 80128
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include <iomanip>
#include<algorithm>
#include<vector>
#include <map>
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a, p;
  cin >> a >> p;

  cout << (a*3 + p)/2 << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main(void) {
	int n,k;
	cin >> n >> k;
	cout << (n-1+(k-2))/(k-1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main()
{
    char a, b;
    cin>>a>>b;
    if(a<b) cout<<'<'<<endl;
    else if(a>b) cout<<'>'<<endl;
    else cout<<'='<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <cstdio> 
#include <math.h>
using namespace std;
int main()
{ int a, b; char op; while (cin >> a >> op >> b, op != '?')
{ if (op == '+') cout << (a+b) << endl; 
if (op == '-') cout << (a-b) << endl;
if (op == '*') cout << (a*b) << endl
; if (op == '/') cout << (a/b) << endl; } } 







Measured memory_bytes: 3112
N, M = list(map(int, input().split()))

p = [0]*M
s = [0]*M
b = [0]*N
pena = 0
corr = 0

for i in range(M):
    p[i], s[i] = input().split()
    p[i] = int(p[i])
    if b[p[i]-1] != -1:
        if s[i] == "AC":
            pena += b[p[i]-1]
            corr += 1
            b[p[i]-1] = -1
        else:
            b[p[i]-1] += 1

print(corr, pena)

Measured memory_bytes: 20688
n=int(input())
l=[]
r=[]
p=[]
for x in range(n):
    L,R=map(int,input().split())
    l.append(L)
    r.append(R)

def hito(x):
    return r[x]-l[x]+1
for x in range(n):
    p.append(hito(x))
print(sum(p))

Measured memory_bytes: 3064
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { N: number, d: number[] } => {
  const N = +lines[0]
  const d = lines[1].split(' ').map(line => +line)
  const obj = { N, d }
  debug(obj)
  return obj
}

// solver
export const solve = (lines: string[]): string => {
  const { N, d } = parseLines(lines)
  d.sort((a, b) => a - b)
  const mid1 = N / 2 - 1
  const mid2 = N / 2
  if (d[mid1] < d[mid2]) {
    return `${d[mid2] - d[mid1]}`
  } else {
    return '0'
  }
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 18748
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,m;
  cin>>n>>m;
  ll count=0;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll sum=0;
  rep(i,n)sum+=a[i];
  rep(i,n){
    if(4*m*a[i]>=sum)count++;
  }
  if(count>=m)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    int n ; cin >> n;
    vector<int> vec;
    for(int i = 0;i < n;i++){
        int x; cin >> x; vec.push_back(x);
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            ans += vec[i] * vec[j];
        }
    }
    cout << ans;
}


Measured memory_bytes: 3604
S = input()
T = input()
x,y = len(S),len(T)
A = [0] * (x-y+1)
for i in range(0, x-y+1):
  count = 0
  j = 0
  for k in range(i, i+y):
    if S[k] != T[j]:
      count += 1
    j += 1
  A[i] = count
print(min(A))

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

int main() {
  int a, i1, i2, i3, i4;
  cin >> a;
  i1 = a/1000;
  i2 = a%1000/100;
  i3 = a%100/10;
  i4 = a%10;
  if((i1 == i2 && i2 == i3) || (i2 == i3 && i3 == i4)) cout << "Yes";
  else cout << "No";
  cout << endl;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sortBy)
import Data.Function (on)

main :: IO ()
main = do
  (x : y : a : b : c : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  ps <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  qs <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  rs <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    ss = sortBy (flip compare `on` fst) $ map (flip (,) T) rs ++ map (flip (,) R) ps ++ map (flip (,) G) qs :: [(Int, RGT)]
    f :: [(Int, RGT)] -> (Int, Int, Int, Int)
    f = foldl step (x + y, x, y, 0)
      where
        step acc@(0, _, _, t) _ = acc
        step acc@(l, 0, g, t) (_, R) = acc
        step acc@(l, r, 0, t) (_, G) = acc
        step (l, r, g, t) (s, color) | color == T = (pred l, r, g, t + s)
                                     | color == R = (pred l, pred r, g, t + s)
                                     | otherwise  = (pred l, r, pred g, t + s)
    (_, _, _, total) = f ss
  print total

data RGT = R | G | T deriving Eq

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 72060
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cfloat>
#include <queue>
using namespace std;

#define INF DBL_MAX

struct Circle {
  double x, y, r;
  Circle(int _x, int _y, int _r) {
    x = _x; y = _y; r = _r;
  }
  Circle() : x(0), y(0), r(INF) {}
};
typedef pair<double, int> P;

Circle T[1010];
int xs, ys, xt, yt;
int N;
double D[1010];

double dist(Circle a, Circle b) {
  double l = sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
  return max(l - (a.r + b.r), .0);
}

int main() {
  scanf("%d %d %d %d %d", &xs, &ys, &xt, &yt, &N);
  T[0] = Circle(xs, ys, 0);
  T[1] = Circle(xt, yt, 0);
  for (int i=0; i<N; i++) {
    int x, y, r;
    scanf("%d %d %d", &x, &y, &r);
    T[i+2] = Circle(x, y, r);
  }

  for (int i=0; i<=N+1; i++) D[i] = INF;

  priority_queue< P, vector<P>, greater<P> > q;
  q.push(P(0, 0));
  D[0] = 0;

  while (!q.empty()) {
    double l = q.top().first;
    int s = q.top().second;
    q.pop();
    if (D[s] < l) continue;

    for (int t=0; t<=N+1; t++) {
      if (s == t) continue;
      double x = dist(T[s], T[t]);
      if (D[t] > D[s] + x) {
        D[t] = D[s] + x;
        q.push(P(D[t], t));
      }
    }
  }
  printf("%.10f\n", D[1]);
  return 0;
}


Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

signed main() {
    int n, m;
    while (cin >> n >> m) {
        int ans = 1;
        for (int i = 1; i <= m; ++i) {
            if (i * i > m) break;
            if (m % i == 0) {
                int j = m / i;
                if (m / i >= n && ans < i) ans = i;
                if (m / j >= n && ans < j) ans = j;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int n,x,l[123],d[123],c=1;
	cin>>n>>x;
	for(int i=0;i<n;i++){
		cin>>l[i];
	}
	d[0]=0;
	for(int i=1;i<=n;i++){
		d[i]=d[i-1]+l[i-1];
		if(d[i]<=x){
			c++;
		}
		else break;
	}
	cout<<c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e14
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, 0));
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < N - i; j++) {
            ll tmp = INF;
            ll sum = 0;
            for (int k = j; k < j + i; k++) {
                tmp = min(tmp, dp[j][k] + dp[k + 1][j + i]);
                sum += a[k];
            }
            sum += a[j + i];
            dp[j][j + i] = tmp + sum;
        }
    }
    cout << dp[0][N - 1] << endl;
}

Measured memory_bytes: 1664
import math
def nCr(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r) )
N,P = map(int,input().split())
A = list(map(int,input().split()))
E = 0
O = 0
for i in A:
    if i % 2 == 0:
        E += 1
    else:
        O += 1
ans = 1
ans *= 2**E
if P == 0:
    ans2 = 1
    for i in range(O // 2):
        i += 1
        i *= 2
        ans2 += nCr(O,i)
else:
    ans2 = 0
    for i in range((O+1) // 2):
        i *= 2
        i += 1
        ans2 += nCr(O,i)
print (ans * ans2)


Measured memory_bytes: 3064
n = int(input())
h = list(map(int,input().split()))
dp = [float('inf')]*n
dp[0],dp[1]=0,abs(h[1]-h[0])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 20412
n=int(input())
w=[input() for _ in range(n)]
yn=0
for i in range(1,n):
    if w.count(w[i])!=1:
        yn=1
        break
if yn==1:
    print("No")
else:
    for i in range(n-1):
        if w[i][len(w[i])-1]!=w[i+1][0]:
            yn=1
            break
    if yn==1:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 3060
n, q = map(int, input().split())
S = list(input())
num = [0 for _ in range(len(S))]
tmp = 0
for i in range(len(S) - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        tmp += 1
    num[i + 1] = tmp
ans = [0 for _ in range(q)]
for i in range(q):
    l, r = map(int, input().split())
    ans[i] = str(num[r - 1] - num[l - 1])
print('\n'.join(ans))


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

int main() {
    string s, t;
    cin >> s >> t;

    int ans = 0;
    rep(i, 3) {
        if (s[i] == t[i]) ans++;
    }

    cout << ans << endl;
    return 0;
}


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

int main(){

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

    long long int ans=0;
    for(int i=0;i<N;i++){
        if(A[i]<B[i]){
            ans+=min(A[i+1],B[i]-A[i]);
            A[i+1] = max(0,(A[i+1]-(B[i]-A[i])));
            ans+=A[i];
            A[i]=max(0,A[i]-B[i]);
        }else{
            ans+=min(A[i],B[i]);
            A[i]-=B[i];
        }
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  if ((n + 1) / 2 >= k) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
ll GCD(ll a,ll b){
    ll tmp,r;
if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
int main(){
   int a,b;
   cin>>a>>b;
   ll ans=(ll)a*b;
   ans/=GCD(a,b);
   OUT(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <vector>
 
 
int main(int argc, char *argv[])
{
	int n;
	int m1=0,m2=0;
	cin >> n;
	vector<int> v(n);

	for (int i=0; i<n; i++)
	{
		cin >> v[i];
		if (v[i]>m1)
		{
			m2=m1;
			m1=v[i];
		}
		else if (v[i]>m2)
		{
			m2=v[i];
		}
	}
	for (int i=0; i<n; i++)
	{

		if (v[i]==m1)
		{
			cout<<m2<<endl;
		}
		else
		{
			cout<<m1<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
long long n, a[200005], ans;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i=0; i<n; i++)
	cin >> a[i];
sort(a, a+n); reverse(a, a+n);
for (int i=1; i<n; i++)
	ans+=a[i/2];
cout << ans;
return 0;
}


Measured memory_bytes: 5208
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
string color(int x) {
	switch (x) {
	case 0:return "black";
	case 1:return "blue";
	case 2:return "lime";
	case 3:return "aqua";
	case 4:return "red";
	case 5:return "fuchsia";
	case 6:return "yellow";
	case 7:return "white";
	default:return "gray";
	}
}

int h(char c) {
	if (isalpha(c))return (c - 'a')+10;
	else return (c - '0');
}

int main() {

	map<int, vector<double> >m;
	m[0].push_back(0x00);
	m[0].push_back(0x00);
	m[0].push_back(0x00);
	m[1].push_back(0x00);
	m[1].push_back(0x00);
	m[1].push_back(0xff);
	m[2].push_back(0x00);
	m[2].push_back(0xff);
	m[2].push_back(0x00);
	m[3].push_back(0x00);
	m[3].push_back(0xff);
	m[3].push_back(0xff);
	m[4].push_back(0xff);
	m[4].push_back(0x00);
	m[4].push_back(0x00);
	m[5].push_back(0xff);
	m[5].push_back(0x00);
	m[5].push_back(0xff);
	m[6].push_back(0xff);
	m[6].push_back(0xff);
	m[6].push_back(0x00);
	m[7].push_back(0xff);
	m[7].push_back(0xff);
	m[7].push_back(0xff);

	vector<double>d(8);

	string s;

	while (cin >> s, s != "0") {

		double r, g, b;

		r = h(s[1]) * 16 + h(s[2]); //cout << "red is " << r << endl;
		g = h(s[3]) * 16 + h(s[4]); //cout << "green is " << g << endl;
		b = h(s[5]) * 16 + h(s[6]); //cout << "blue is " << b << endl;

		for (int i = 0; i < 8; i++) {

			d[i] = pow(pow(r - m[i][0], 2) + pow(g - m[i][1], 2) + pow(b - m[i][2], 2), 0.5);
		//	cout << d[i] << " ";
		}//cout << endl;
		cout << color(distance(d.begin(),min_element(d.begin(), d.end()))) << endl;


	}



	return 0;
}

Measured memory_bytes: 3148
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

import heapq
n,m,s,t = inm()
dst = [{} for i in range(n)]
for i in range(m):
    u,v,a,b = inm()
    dst[u-1][v-1] = (a,b)
    dst[v-1][u-1] = (a,b)

costa = [BIG]*n
costb = [BIG]*n
q = [(0,s-1)]
while len(q)>0:
    d,p = heapq.heappop(q)
    if costa[p]<=d:
        continue
    costa[p] = d
    for v in dst[p]:
        heapq.heappush(q,(d+dst[p][v][0], v))

q = [(0,t-1)]
while len(q)>0:
    d,p = heapq.heappop(q)
    if costb[p]<=d:
        continue
    costb[p] = d
    for v in dst[p]:
        heapq.heappush(q,(d+dst[p][v][1], v))

#ddprint(costa)
#ddprint(costb)

mn = BIG
ans = []
for i in range(n-1,-1,-1):
    mn = min(mn, costa[i]+costb[i])
    ans.append(mn)
for i in range(n-1,-1,-1):
    print(10**15-ans[i])


Measured memory_bytes: 124504
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
    const int MOD=1e9+7;
    ll mod(ll x){
        return (x%MOD + MOD)%MOD;
    }
    ll mul(ll a , ll b){
        return mod(mod(a)*mod(b));
    }
 
    void solve(){
        int n,k;
        cin>>n>>k;
        vector<ll>pos;
        vector<ll>neg;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            if(x>0)
                pos.push_back(x);
            else
                neg.push_back(x);
        }
        ll ans=1;
        if((int)pos.size()){
            if(k%2){
                sort(pos.begin(),pos.end());
                ans=mul(ans,pos.back());
                pos.pop_back();
                --k;
            }
            vector<ll>ok;
            sort(pos.begin(),pos.end(),greater<>());
            sort(neg.begin(),neg.end());
            for(int i=0;i+1<(int)pos.size();i+=2)
                ok.push_back(pos[i]*pos[i+1]);
            for(int i=0;i+1<(int)neg.size();i+=2)
                ok.push_back(neg[i]*neg[i+1]);
            if((int)pos.size()%2 && (int)neg.size()%2)
                ok.push_back(pos.back()*neg.back());
            sort(ok.begin(),ok.end(),greater<>());
            for(int i=0;i<(k/2);i++)
                ans=mul(ans,ok[i]);
            cout<<ans;
        }
        else{
            sort(neg.begin(),neg.end());
            if(k%2)
                reverse(neg.begin(),neg.end());
            for(int i=0;i<k;i++)
                ans=mul(ans,neg[i]);
            cout<<ans;
        }
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);

    for(int i = 0; i < m; i++) {
        int k;
        cin >> k;
        for(int j = 0; j < k; j++) {
            int s;
            cin >> s;
            s--;
            a[s] |= 1 << i;
        }
    }

    int p = 0;
    for(int i = 0; i < m; i++) {
        int x;
        cin >> x;
        p |= x << i;
    }
    int ans =0;
    for(int s = 0; s < (1 << n); s++) {
        int t = 0;
        for(int i = 0; i < n; i++) {
            if(s >> i & 1){
                t ^= a[i];
            }
        }
        if(t == p){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll> x(n+1);
    FOR(i,1,n+1){
        cin>>x[i];
    }
    ll ans=0;
    FOR(i,1,n){
        if(a*(x[i+1]-x[i])<b){
            ans+=a*(x[i+1]-x[i]);
        }else{
            ans+=b;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
N, K=map(int, input().split())
#s = [input().split() for i in range(Q)]

peo=[]

for i in range(K):
    A=int(input())
    su=input().split()
    for k in range(A):
        peo.append(str(su[k]))

peo
print(N-len(set(peo)))
    

Measured memory_bytes: 9460
import java.util.*;

public class Main{
	public static void main(String arga[]){
		
		Scanner sc = new Scanner(System.in);
		
		int X =sc.nextInt();
		int Y =sc.nextInt();
		int Z =sc.nextInt();
		int N =sc.nextInt();
		int count=0;
		
		
		for(int i=0;i<=X;i++){
			
			for(int j=0; j<=Y;j++){
				
				for(int k=0; k<=Z;k++){
					
				if(N==500*i+100*j+50*k){
					count++;
				}
			}
		}
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 22356
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int MAXN = 305;

int dp[MAXN][MAXN][MAXN];
char s[MAXN];
int k;

int solve(int l, int r, int k) {
  if (l == r) { return 0;}
  if (l == r - 1) { return 1;};
  int &ans = dp[l][r][k];
  if (ans != -1) return ans;
  ans = max(ans, solve(l + 1, r, k));
  ans = max(ans, solve(l, r - 1, k));
  if (k) {
    ans = max(ans, solve(l + 1, r - 1, k - 1) + 2);
  }
  if (s[l] == s[r - 1]) {
    ans = max(ans, solve(l + 1, r - 1, k) + 2);
  }
//  eprintf("dp[%d][%d][%d] = %d\n", l, r, k, ans);
  return ans;
}

int main() {
#ifdef LOCAL
  freopen("d.in", "r", stdin);
  freopen("d.out", "w", stdout);
#endif

  while (scanf("%s%d", s, &k) == 2) {
    memset(dp, -1, sizeof(dp));
    printf("%d\n", solve(0, strlen(s), k));
  }

  return 0;
}


Measured memory_bytes: 111104
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
    int a[3];
    int n;

    scanf("%d", &n);
    while(n>0) {
        scanf("%d %d %d", &a[0], &a[1], &a[2]);
        sort(a, a+3);
        if(a[0]*a[0] + a[1]*a[1] == a[2] * a[2]) {
            printf("YES\n");
        }else{
            printf("NO\n");
        }
        n--;
    }
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

static const ll INF = std::numeric_limits<ll>::max() / 3;
static const ll MAX_E = 2000; // TODO
static const ll MAX_V = 1000; // TODO

struct Edge {
  ll from;
  ll to;
  ll cost; // TODO
};

Edge es[MAX_E];

ll d[MAX_V];
ll V; // TODO
ll E; // TODO

// s番目の頂点から各頂点への最短距離を求める
// s番目の頂点からのパスに負の閉路が存在する場合、falseを返す
bool bellman_ford(ll s) {
  for (ll i = 0; i < V; i++) {
    d[i] = INF;
  }
  d[s] = 0;
  for (int i = 0; i < V; i++) {
    bool update = false;
    for (ll j = 0; j < E; j++) {
      Edge e = es[j];
      if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        if (i == V - 1) {
          return false;
        }
        update = true;
      }
    }
    if (!update) {
      break;
    }
  }
  return true;
}

// trueなら負の閉路が存在する
bool find_negative_loop() {
  memset(d, 0, sizeof(d));

  for (int i = 0; i < V; i++) {
    for (int j = 0; j < E; j++) {
      Edge e = es[j];
      if (d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;

        if (i == V - 1) {
          return true;
        }
      }
    }
  }
  return false;
}

void solve(long long N, long long M, ll r, std::vector<long long> a,
           std::vector<long long> b, std::vector<long long> c) {
  V = N;
  E = M;
  REP(i, E) { es[i] = {a[i], b[i], c[i]}; }
  if (!bellman_ford(r)) {
    std::cout << "NEGATIVE CYCLE" << std::endl;
  } else {
    REP(i, V) {
      if (d[i] == INF) {
        std::cout << "INF" << std::endl;
      } else {
        std::cout << d[i] << std::endl;
      }
    }
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  long long r;
  scanf("%lld", &r);
  std::vector<long long> a(M);
  std::vector<long long> b(M);
  std::vector<long long> c(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
    scanf("%lld", &c[i]);
  }
  solve(N, M, r, std::move(a), std::move(b), std::move(c));
  return 0;
}



Measured memory_bytes: 3220
#include<stdio.h>
#include<math.h>
int main()
{
    unsigned long long int n;
    scanf("%lld", &n);
    long long int x;
    x = ceil(sqrt(n));
    while (n%x > 0)
        x--;
    int ans = 0;
    x = n / x;
    while (x > 0)
    {
        ans++;
        x /= 10;
    }
    printf("%d\n", ans);
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

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

    double dice = (double)1 / n;
    double ans = 0;
    REP2(i, 1, n){
        int point = i;
        int ex = 0;
        while(point < k){
            point *= 2;
            ex++;
        }
        ans += dice * pow(0.5, ex);
    }
    cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 512
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

// int32_t A[2][200000];

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

  int32_t N, K;
  cin >> N >> K;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int32_t> A(N + 2);
  for (int32_t i = 1; i <= N; ++i) {
    cin >> A[i];
  }
  for (int32_t k = 0; k < min(K, 1000); ++k) {
    vector<int32_t> S(N + 2, 0);
    for (int32_t i = 1; i <= N; ++i) {
      ++S[max(i - A[i], 0)];
      --S[min(i + A[i] + 1, N + 1)];
    }
    int32_t sum_value = 0;
    for (int32_t i = 0; i <= N + 1; ++i) {
      sum_value += S[i];
      A[i] = sum_value;
    }
  }
  for (int32_t i = 1; i <= N; ++i) {
    if (i != 1) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;
  return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int N, Q, query[300010];
vector< int > card;

int main() {
	cin >> N >> Q;
	
	for_(i,0,N) {
		int c; cin >> c;
		card.push_back(c);
	}
	
	sort(card.begin(), card.end());
	
	memset(query, 0, sizeof(query));
	
	for_(q,2,300001) {
		int qq = q;
		
		while (1) {
			int lw = lower_bound(card.begin(), card.end(), qq) - card.begin() - 1;
			if (lw >= 0) query[q] = max(query[q], card[lw] % q);
			if (lw == N-1) break;
			qq += q;
		}
	}
	
	for_(i,0,Q) {
		int q; cin >> q;
		cout << query[q] << endl;
	}
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    int ans=1e9;
    int tmp;
    for(int i=0;i<n;i++){
        cin >> a[i];
        tmp=0;
        while(a[i]%2==0){
            a[i]/=2;
            tmp++;
        }
        ans=min(ans,tmp);
    }
    cout << ans;
}

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

#define LL long long

int F(int f[], int x) {return (f[x] == x ? x : f[x] = F(f, f[x]));}

void unite(int f[], int x, int y) {
    if(F(f, x) == F(f, y)) return;
    f[F(f, x)] = F(f, y);
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n, k, l, x, y; cin >> n >> k >> l;
    int rd[n+1], rw[n+1];

    for(int i = 1; i <= n; i++) rd[i] = rw[i] = i;

    while(k--) {
        cin >> x >> y;
        unite(rd, x, y);
    }

    while(l--) {
        cin >> x >> y;
        unite(rw, x, y);
    }

    pair<int,int> q[n+1];
    map<pair<int,int>, int> ans;

    for(int i = 1; i <= n; i++) {
        q[i] = {F(rd, i), F(rw, i)};
        ans[q[i]]++;
    }

    for(int i = 1; i <= n; i++) cout << ans[q[i]] << " ";
}

Measured memory_bytes: 18024
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//dp
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll inf = 1LL << 60;
const int max_n = 110;
const int max_v = 100100;
int N,W,w[max_n],v[max_v];
ll dp[max_n][max_v];
//dp
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    cin >> N >> W;
    rep(i,max_n)cin >> w[i] >> v[i];
    rep(i,max_n)rep(j,max_v) dp[i][j] = inf;
    dp[0][0] = 0;
    rep(i,N){
        for(int j = 0;j < max_v;j++){
            if (j - v[i] >= 0){
                chmin(dp[i+1][j] ,dp[i][j-v[i]] + w[i]);
            }
            chmin(dp[i+1][j] ,dp[i][j]);
        }
    }
    ll ans;
    rep(i,max_v){
        if(dp[N][i] <= W)ans = i;
    }
    cout << ans;
}

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

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string a;
    cin >> a;
    sort(a.begin(), a.end());
    int min_a = stoi(a);
    reverse(a.begin(), a.end());
    int max_a = stoi(a);
    cout << max_a - min_a << endl;
  }
}


Measured memory_bytes: 3004
// clang-format off
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using G = vector<vector<ll>>;
#define G(i, j) i, vector<ll>(j)
#define Gv(i, j, k) i, vector<ll>(j, k)
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
#define END(ans) ANS(ans); return
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
const string YES = "Yes";
const string NO = "No";
// clang-format on

void solve(long long X, long long Y) {
  if (Y % 2 == 0 && X * 2 <= Y && Y <= X * 4) {
    END(YES);
  }
  END(NO);
}

// clang-format off
int main() {
  long long X;
  scanf("%lld",&X);
  long long Y;
  scanf("%lld",&Y);
  solve(X, Y);
  return 0;
}


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


int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i,n) cin >> vec[i];
  int ans = 0;
  rep(i,n){
    rep(j,n){
      if(i==j) continue;
      ans += vec[i] * vec[j];
    }
  }
  cout << ans/2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    vector<map<char, int> > s(n);
    rep(i, 0, n) {
        string t;
        cin >> t;
        rep(j, 0, t.size()) {
            s[i][t[j]]++;
        }
    }
    vii cnt(26, 100);
    rep(i, 0, n) {
        rep(j, 0, 26) {
            if (s[i][(char)('a'+j)]) {
                cnt[j] = min(cnt[j], s[i][(char)('a'+j)]);
            } else {
                cnt[j] = 0;
                continue;
            }
        }
    }
    rep(i, 0, 26) {
        if (cnt[i]) {
            rep(j, 0, cnt[i]) cout << (char)('a' + i);
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
#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, y;
    cin >> x >> y;
    if(x==1&&y==1){
        cout << 1000000 << endl;
    }else{
        int ans=0;
        if(x<=3){
            ans += 1e5 * (4-x);
        }
        if(y<=3){
            ans += 1e5 * (4-y);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
import bisect
import sys
import math
input = sys.stdin.readline
import functools

from collections import defaultdict

############ ---- Input Functions ---- ############

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

############ ---- Solution ---- ############

def dfs(i, edges, visited):
    s = []
    if not visited[i]:
        s.append(i)
        visited[i] = True
    res = 0
    while len(s) > 0:
        v = s.pop()
        res += 1
        for i in edges[v]:
            if not visited[i]:
                s.append(i)
                visited[i] = True

    return res

def solve():
    [N, M] = inlt()
    edges = defaultdict(set)
    visited = [False for i in range(N)]

    for i in range(M):
        [a, b] = inlt()
        edges[a - 1].add(b - 1)
        edges[b - 1].add(a - 1)

    res = 0
    for i in range(N):
        res = max(res, dfs(i, edges, visited))
    
    return res

    

if len(sys.argv) > 1 and sys.argv[1].startswith("input"):
    f = open("./" + sys.argv[1], 'r')
    input = f.readline

res = solve()
print(str(res))


Measured memory_bytes: 177180
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    li=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K=int(readline())

    print(li[K-1])
if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<list>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int i,j,n,ans=0;cin>>n;
	int A[100];
	for(i=0;i<n;i++){cin>>A[i];}
	for(i=0;i<n;i++){
		int minj=i;
		for(j=i+1;j<n;j++){if(A[j]<A[minj]){minj=j;}}
		if(minj!=i){ans++;}
		swap(A[i],A[minj]);
	}
	for(i=0;i<n;i++){cout<<A[i]<<(i+1<n?" ":"\n");}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	ll mn = b;
	ll mx = a;
	rep(i,n-1) mn += a;
	rep(i,n-1) mx += b;
	ll ans = mx - mn + 1;
	cout << max(ans, ll(0)) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
const int N = 1e5 + 7;
vi G[N];
int n , m , u , v , dp[N] , visit[N] , ans;

void dfs(int s){
    
    visit[s] = 1;
    for(auto it : G[s]){
        if(visit[it] == 0)
            dfs(it);
        
        dp[s] = max(dp[s] , 1 + dp[it]);
    }
    
    ans = max(ans , dp[s]);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    cin >>n >> m;
    for(int i = 0 ;i < m; i++){
        cin >> u >> v;
        G[u].pb(v);
    }
    for(int i = 1 ;i <= n ; i++)
        if(visit[i] == 0)
            dfs(i);
    cout << ans << endl;
        
    return 0;
}

Measured memory_bytes: 8576