akhauriyash/Code-Regression huggingface dataset:
object Main {
  def main(args: Array[String]) {
    val str = scala.io.StdIn.readLine()

    var count         = 0
    var check         = true
    var large_c_count = 0
    var large_check   = false
    str.foreach { c =>
      if(count == 0) {
        if (c != 'A') {
          check = false
        }
      }

      if(1 < count && count < str.length - 1)
      {
        if(c == 'C')
        {
          large_c_count += 1
        }
      }

      count += 1
    }

    if(large_c_count != 1) check = false
    if(str.count{ c => c >= 'A' && c <= 'Z'} != 2) check = false

    if(check) println("AC")
    else      println("WA")
  }
}

Measured memory_bytes: 26900
#!/usr/bin/env python3


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    H, W, K = map(int, input().split())
    field = []
    row = [0] * H
    column = [0] * W
    total = 0
    for _ in range(H):
        field.append(input())
    
    for r in range(H):
        for c in range(W):
            if field[r][c] == "#":
                row[r] += 1
                column[c] += 1
                total += 1

    count = 0
    for r in range(2 ** H):
        for c in range(2 ** W):
            dub = []
            delete = 0
            overdelete = 0
            for i in range(H):
                if r >> i & 1:
                    dub.append(field[i])
                    delete += row[i]
            for i in range(W):
                if c >> i & 1:
                    delete += column[i]
                    for d in dub:
                        if d[i] == "#":
                            overdelete += 1
            
            if total - delete + overdelete == K:
                #print(r, c, total, delete, overdelete)
                count += 1

    print(count)

    return 

if __name__ == '__main__':
    main()


Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG

int main() {
    int s;
    cin >> s;
    vector<int> a;
    a.push_back(s);
    int i = 0;
    int ans = 0;
    while(i < 10000000) {
        if(a[i] == 4 || a[i] == 2 || a[i] == 1){
            ans = i + 4;
            break;
        } 
        if(a[i] % 2 == 0)
            a.push_back(a[i] / 2);
        else
            a.push_back(a[i] * 3 + 1);
        i++;
    }
    cout << ans << endl;
}


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

int main(){
  int K,A,B;
  cin >> K >> A >> B;
  
  int cnt = 0;
 
  for(int i=A; i<=B; i++){
    cnt += (i%K==0);
  }
  
  if(cnt==0) cout << "NG" << endl;
  else cout << "OK" << endl;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=1000005;
char ch1[MAXN],ch2[MAXN];
int n;
queue<int> li;
int main()
{
	n=read();
	scanf("%s",ch1+1);scanf("%s",ch2+1);
	bool flag=true;for(int i=1;i<=n;i++)if(ch1[i]!=ch2[i])flag=false;
	if(flag)return puts("0"),0;
	int ans=0;
	for(int up=n+1,down=n;down>=1;--down)
	{
		while(down-1&&ch2[down-1]==ch2[down])--down;
		--up;while(up&&(ch1[up]!=ch2[down]||up>down))--up;
		if(!up)return puts("-1"),0;
		while(li.size()&&li.front()-li.size()>=down)li.pop();
		if(up!=down)li.push(up);
		ans=max(ans,(int)li.size()+1);
	}pr2(ans);
	return 0;
}


Measured memory_bytes: 6272
# -*- coding: utf-8 -*-
import numpy as np

def main():
    # # 整数の入力
    # a = int(input())
    # # スペース区切りの整数の入力
    # b, c = map(int, input().split())
    # # 文字列の入力
    # s = input()
    # # 出力
    # print("{} {}".format(a+b+c, s))
    A, B, C = map(int, input().split())
    print(max(C - (A-B), 0))


if __name__=='__main__':
    main()


Measured memory_bytes: 12420
#include<bits/stdc++.h>
using namespace std;
int main(){int N,M;cin>>N>>M;int h[N],v[M],w[M],x=N;vector<int>c(N,1);for(int i=0;i<N;i++)cin>>h[i];
           for(int i=0;i<M;i++){cin>>v[i]>>w[i];if(h[v[i]-1]>=h[w[i]-1]&&c.at(w[i]-1)){c.at(w[i]-1)=0;x--;}
                               if(h[v[i]-1]<=h[w[i]-1]&&c.at(v[i]-1)){c.at(v[i]-1)=0;x--;}}cout<<x<<endl;}
           


Measured memory_bytes: 4800
#include<stdio.h>

int main(void){
    int N[100];
    int x;
    int a,t;
    
    scanf("%d",&x);
    for(int i=0;i<x;i++){
        scanf("%d",&N[i]);
    }
	
	printf("%d",N[0]);
    for(int i=1;i<x;i++){
        printf(" %d",N[i]);
    }
	printf("\n");
    
    for(int s=1;s<x;s++){
        a=N[s];
        t=s-1;
        while(t>=0 && N[t]>a){
            N[t+1]=N[t];
            t--;
        }
        N[t+1]=a;
        printf("%d",N[0]);
		for(int i=1;i<x;i++){
    		printf(" %d",N[i]);
    	}
		printf("\n");
    }
    
    return 0;
}


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

int main(){
    //FILE *inp = freopen("dic.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    int n;
    string item, cmd;
    set<string>dictionary;
    cin>>n;
    while(n--){
        cin>>cmd>>item;
        if(cmd=="insert") dictionary.insert(item);
        else if(cmd=="find"){
            set<string>::iterator itr = dictionary.find(item);
            if(itr==dictionary.end()) cout << "no" << endl;
            else cout << "yes" << endl;
        }
    }
    //fclose(inp);
    return 0;
}



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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ma = max(a, b);
  ma = max(ma, c);
  int n = 3*ma - a - b - c;
  int ans = n / 2;
  if(n%2==1) ans += 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,x;
	cin>>n>>x;
	int s[n+1];
	for(int i=1;i<=n;i++) cin>>s[i];
	sort(s+1,s+n+1);
	int ans=0;
	for(int i=1;i<=x;i++) {
		ans+=s[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.*;
import java.io.*;
import java.math.*;

public class Main{
  public static OutputStream out=new BufferedOutputStream(System.out);
  static Scanner sc=new Scanner(System.in);
  static long mod=1000000007l;

  //nl-->neew line; //l-->line;  //arp-->array print;  //arpnl-->array print new line
  public static void nl(Object o) throws IOException{out.write((o+"\n").getBytes());}
  public static void l(Object o) throws IOException{out.write((o+"").getBytes());}
  public static void arp(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+" ").getBytes()); out.write(("\n").getBytes());}
  public static void arpnl(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+"\n").getBytes());}
  public static void scanl(long[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextLong();}
  public static void scani(int[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextInt();}
  public static void scan2D(int[][] a,int n,int m) {for(int i=0;i<n;i++) for(int j=0;j<m;j++) a[i][j]=sc.nextInt();}
  //
  static long cnt;
  static TreeSet<Integer> ans;
  static int n,m;
  static boolean[][] dp,vis;
  static HashMap<Pair,Boolean> arrl;


  public static void main(String[] args) throws IOException{
    long sttm=System.currentTimeMillis();
    long mod=1000000007l;

    int n=sc.nextInt();
    int[] a=new int[n+1];
    for(int x=1;x*x<=n;x++){
        for(int y=1;y*y<=n;y++){
            for(int z=1;z*z<=n;z++){
                int val=x*x+y*y+z*z+x*y+y*z+z*x;
                if(val<=n) a[val]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        nl(a[i]);
    }

    out.flush();
  }
}

class Pair{
  int st,nd;
  Pair(int st,int nd){
    this.st=st;
    this.nd=nd;
  }
}


Measured memory_bytes: 40792
#include <stdio.h>
#include <string.h>

int main(void){
	int n, m, i, j, k, sum, keta[100], w[100], s[100][8], p[8];
	char c;
	while(1){
		scanf("%d%d%*c",&n,&m);
		if(n == 0 && m == 0) break;
		memset(keta,-1,sizeof(keta));
		memset(s,-1,sizeof(s));
		for(i = 0;i < n;i++){
			j = 0;
			for(j = 0;j < 8;j++){
				c = getchar();
				if(c != '*'){
					if(keta[i] == -1)
						keta[i] = 8 - j;
					s[i][j] = c - '0';
				}
			}
			scanf("%d%*c",&w[i]);
		}
		sum = 0;
		for(i = 0;i < m;i++){
			j = 0;
			while(j < 8){
				c = getchar();
				p[j++] = c - '0';
			}
			getchar();
			for(j = 0;j < n;j++){
				for(k = 0;k < keta[j];k++){
					if(p[7 - k] != s[j][7 - k]) break;
				}
				if(k == keta[j])
					sum += w[j];
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1036
N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]

a.sort(key = lambda x: x[1])

now = 0
flag = 1
for i in range(N):
    now += a[i][0]
    if now > a[i][1]:
        flag = 0
        break

if flag == 1:
    print("Yes")
else:
    print("No")


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

int main(void)
{
	char S[11], T[11], U[11];
	int s, t;
	scanf("%s %s",S,T);
	scanf("%d %d", &s, &t);
	scanf("%s", U);
	if (strcmp(S, U) == 0) {
		s--;
	}
	else {
		t--;
	}
	printf("%d %d\n", s, t);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 1000000007;
/*
2000000011 is prime
2000000033 is prime
*/

ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];

char s[500005];


int main(){
    cin >> n >> k >> q;
    for(int i=0;i<q;i++){
        cin >> x[i];
    }
    for(int i=0;i<n;i++){
        y[i+1] = k - q;
    }
    for(int i=0;i<q;i++){
        y[x[i]] ++;
    }
    for(int i=1;i<=n;i++){
       // p(y[i]);
        Yes(y[i] >= 1);
    }
   // cout << ans << endl;
    return 0;

}


















Measured memory_bytes: 19584
import itertools, math

n = int(input())
xy = []
kai = 1
for i in range(n):
    xy.append(list(map(int, input().split())))
    kai *= (i + 1)
    
cost = 0
for lst in itertools.permutations(range(n), n):
    x = xy[lst[0]][0]
    y = xy[lst[0]][1]
    for num in lst:
        dx = xy[num][0] - x
        dy = xy[num][1] - y
        cost += math.sqrt(dx ** 2 + dy ** 2)
        x = xy[num][0]
        y = xy[num][1]
print(cost / kai)

Measured memory_bytes: 3064
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char
import Data.List
import Data.Monoid
import Data.Bits
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM

-- let k = search v f i j
-- => (k < j || f k) && (k == i || not (f (k-1)))
search :: (U.Unbox a) => U.Vector a -> (a -> Bool) -> Int -> Int -> Int
search !v !f !i !j
  | i >= j = error "bad input"
  | f (v U.! i) = i
  | otherwise = loop i j
  where loop !i !j | j == i + 1 = j
                   | f (v U.! k) = loop i k
                   | otherwise = loop k j
          where k = (i + j) `quot` 2

query :: Int -> Int -> U.Vector Int -> Int
query !i !depth vec = minimum [vec U.! (2^k - 1 + (i `shiftR` (depth - k))) | k <- [0..depth]]

fill :: Int -> Int -> Int -> Int -> UM.MVector s Int -> ST s ()
fill !i !j !x !depth vec | i < j = doFill 0 depth i j
                         | otherwise = return ()
  where
    -- Invariant: 0 <= k*2^l <= i < j <= (k+1)*2^l <= 2^depth
    doFill !k 0 !i !j | i == k, j == k+1 = UM.write vec (2^depth - 1 + k) x
                      | otherwise = error "fill"
    doFill !k l !i !j | i == (k `shiftL` l) && j == ((k+1) `shiftL` l) = UM.write vec (2^(depth-l) - 1 + k) x
                      | m <= i = doFill (2*k+1) (l-1) i j
                      | j <= m = doFill (2*k) (l-1) i j
                      | otherwise = doFill (2*k) (l-1) i m >> doFill (2*k+1) (l-1) m j
      where m = (2*k+1) `shiftL` (l-1)

main = do
  [n,q] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- 1 <= n <= 2*10^5, 1 <= q <= 2*10^5
  works <- replicateM n $ do
    [s,t,x] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (s,t,x)
  let works' = sortBy (\(s,t,x) (s',t',x') -> compare x' x <> compare s s' <> compare t t') works
  ds <- U.replicateM q $ do
    Just (d, _) <- BS.readInt <$> BS.getLine
    return d
  -- q <= 2^depth
  let depth = ceiling (logBase 2 (fromIntegral q) :: Double) :: Int
  let result = U.create $ do
        vec <- UM.replicate (2^(depth+1)-1) (10^9+1)
        forM_ works' $ \(s,t,x) -> do
          let !s' = s - x
              !t' = t - x
              i0 = search ds (\d -> s' <= d) 0 q
              i1 | i0 == q = q
                 | otherwise = search ds (\d -> t' <= d) i0 q
          fill i0 i1 x depth vec
        return vec
  forM_ [0..q-1] $ \i -> do
    let v = query i depth result
    if v == 10^9+1
      then putStrLn "-1"
      else print v


Measured memory_bytes: 82300
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b,int c);
int main()
{
    int k;
    scanf("%d",&k);
    int sum=0;
    for(int i=1;i<=k;i++)
        for(int j=1;j<=k;j++)
           for(int n=1;n<=k;n++)
               sum+=gcd(i,j,n);
    printf("%d\n",sum);
    return 0;
}
int gcd(int a,int b,int c)
{
    while(b>0)
    {
        int d = a % b;
        a = b;
        b = d;
    }
    while(a>0)
    {
        int m=c%a;
        c=a;
        a=m;
    }
    return c;
}


Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
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; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string m; cin >> m;
    if(m=="SUN") {
        cout << 7 << endl;
        return 0;
    }
    if(m=="MON") {
        cout << 6 << endl;
        return 0;
    }
    if(m=="TUE") {
        cout << 5 << endl;
        return 0;
    }
    if(m=="WED") {
        cout << 4 << endl;
        return 0;
    }
    if(m=="THU") {
        cout << 3 << endl;
        return 0;
    }
    if(m=="FRI") {
        cout << 2 << endl;
        return 0;
    }
    if(m=="SAT") {
        cout << 1 << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i < n; i++) cin >> v[i];
    vector<int> pos(n);
    for (int i=0; i < n; i++) pos[v[i] - 1] = i;
    int ans = 1;
    int L = 0, R = 0;
    while (L < n){
        while (R < n-1 && pos[R+1] > pos[R]) R++;
        ans = max(ans, R-L+1);
        L++;
        if (R<L) R=L;
    }
    cout << n-ans;

}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  bool s=true;
  string a[100];
  set<string> b;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a[i];
    b.insert(a[i]);
  }
  for(i=0;i<n-1;i++){
    if(a[i].at(a[i].size()-1)!=a[i+1].at(0)){
      s=false;
    }
  }
  cout<<(b.size()/n&&s?"Yes":"No");
}

Measured memory_bytes: 256
MAX = 60000
lst = [i for i in range(MAX)]
lst[0] = lst[1] = 0
for i in range(MAX):
  if lst[i] != 0:
    for j in range(i * 2, MAX, i):
      lst[j] = 0
while 0 == 0:
  try:
    n = int(input())
    i = n - 1
    j = n + 1
    while lst[i] == 0:
      i -= 1
    while lst[j] == 0:
      j += 1
    print(str(lst[i]) + " " + str(lst[j]))
  except EOFError:
    break


Measured memory_bytes: 7924
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

bool getBit(long long num, int i){
	return ((num & (1LL << i)) != 0);
}

vector<int> atk, sum;
vector<long long> bit;
int maxi;

void input(int n){
	vector<string> name(n);
	vector<vector<string>> near(n);

	map<string, int> id;
	rep(i,n){
		int d;
		cin >> name[i] >> atk[i] >> d;
		id[name[i]] = i;
		while(d--){
			string s;
			cin >> s;
			near[i].emplace_back(s);
		}
	}

	rep(i,n){
		sum[i + 1] = sum[i] + atk[i];
	}

	rep(i,n){
		bit[i] |= 1LL << i;
		for(auto s : near[i]){
			bit[i] |= 1LL << id[s];
		}
		//cout << bitset<10>(bit[i]) << endl;
	}
}

void dfs(int& n, int i, long long enemy, int total){
	maxi = max(maxi, total);
	if(i == n) return;
	if(total + sum[n] - sum[i] < maxi) return;
	
	if(not getBit(enemy,i)){
		dfs(n, i + 1, enemy bitor bit[i], total + atk[i]);
	}
	dfs(n, i + 1, enemy, total);
}

//map<pair<long long, long long>, int> memo1, memo2;
vector<int> dp; // dp[s] := 集合sから任意の数, 仲間を選べるときの最大値

int main(){
	int n;
	while(cin >> n,n){
		atk = vector<int>(n);
		sum = vector<int>(n + 1, 0);
		bit = vector<long long>(n,0);
		input(n);

		maxi = 0;
		dfs(n, 0, bit[0], atk[0]);
		cout << maxi << endl;
	}
}



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

#define N 300005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

#define Mo 1000000007

using namespace std;

int power(int x,int y)
{
		int sum=1;
		for (;y;y>>=1)
		{
				if (y&1) sum=1ll*sum*x%Mo;
				x=1ll*x*x%Mo;
		}
		return sum;
}

int i,j,m,n,p,k;

char c[2][N];

int main()
{
		scanf("%d",&n); int ans=1;
		scanf("%s",c[0]+1); scanf("%s",c[1]+1);
		for (i=1;i<=n;++i)
			if (c[0][i]==c[1][i])
			{
				 if (i==1) ans=1ll*ans*3%Mo;
				 else if (c[0][i-1]==c[1][i-1]) ans=1ll*ans*2%Mo;
			}
			else 
			{
				 for (j=i;j<=n&&c[1][j]!=c[0][j];++j);
				 int len=(j-i)/2;
				 if (i==1) ans=1ll*ans*6%Mo*power(3,len-1)%Mo;
				 else ans=1ll*ans*2*power(3,len-1)%Mo;
				 i=j-1;
			}
		printf("%d\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue

#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>


#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORd(i,a,b) for(int i=(a);i>=(b);i--)
#define FORl(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORN(i,n) for(int i=(0);i<(n);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................



int main()
{
    fast
    
    int n;
    cin>>n;
    set<string>st;
    st.clear();
    while(n--)
    {
        string s;
        cin>>s;
       
        st.insert(s);
        
    }
    cout<<st.size()<<"\n";
    return 0;
}

Measured memory_bytes: 19184
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x;
		for(int i=3; i<=n; i++){
			x = i;
			if(x%3==0){
				System.out.print(" " + i);
				continue;
			}
			while(x!=0){
				if(x%10==3){
					System.out.print(" " + i);
					break;
				}
				x /= 10;
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 24464
import sys
from math import floor
input = sys.stdin.readline

def main():
    N, C, K = map(int, input().split())
    t = sorted([int(input()) for i in range(N)])

    i = 0
    ans = 0
    while i < N:
        lim = t[i] + K
        tmp = 0
        for j in range(i, N):
            if t[j] <= lim:
                tmp += 1
            else:
                i = j
                break
            if tmp == C or j == N-1:
                i = j+1
                break
        ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 8276
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
int gcd(int one, int two) {
	while (one != 0 && two != 0) {
		if (one > two) {
			one = one % two;

		}
		else {
			two = two % one;
		}

	}

	return std::max(one, two);

}
int main()
{
	using namespace std;
	int a = 0, b = 0, c = 0, d = 0, e = 0, min = 0, ma = 0, ans = 0, count = 0, nagax = 0, nagay = 0, size = 0;
	int sa[10000] = {};
	int yoko = 0, tate = 0;
	std::string output,output2,output3,output4;
	char changer;
	char changer2;

	cin >> a>>b>>c;
	cout << std::max(a, std::max(b, c))*10+a+b+c-std::max(a, std::max(b, c))<<endl;
}






Measured memory_bytes: 256
array = gets.chomp.split(" ")
hash = {}
array.each do |str|
    if hash.has_key?(str)
        hash[str] += 1
        else
        hash[str] = 1
    end
end
ml_w = ""
ml_l = 0
mc_w = ""
mc_c = 0
hash.each do |key, val|
    if key.length > ml_l
        ml_l = key.length
        ml_w = key
    end
    if val > mc_c
        mc_c = val
        mc_w = key
    end
end
puts mc_w + " " + ml_w

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

int main(void) {
  int N;
  string S;
  cin >> N >> S;
  vector<int> black_sum(N + 1, 0);
  for (int i = 0; i < N; i++) {
    black_sum[i + 1] = black_sum[i] + (S[i] == '#');
  }
  int ans = 10000000;
  for (int i = 0; i <= N; i++) {
    int white = N - i - (black_sum[N] - black_sum[i]);
    ans = min(ans, black_sum[i] + white);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
	unordered_map<int, int>a;
	for (int i = 0; i < n; i++) {
		int ai;
		cin >> ai;
		if(a[ai]) { cout << "NO" << endl; return 0;}
		a[ai]++;
	}
	cout << "YES" << endl;
	return 0;
}


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

int main() {
  char b;
  cin >> b;
  char answer;
  if (b == 'A') {
    answer = 'T';
  }
  else if (b == 'C') {
    answer = 'G';
  }
  else if (b == 'G') {
    answer = 'C';
  }
  else {
    answer = 'A';
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int n;
int p[200010];
int a[200010],b[200010];
int main()
{
  cin >> n;
  rep(i,n) cin >> p[i];

  rep(i,n){
    int index = p[i] - 1;
    a[index] = index * n + (i+1);
    b[index] = (n-index-1) * n + (i+1); 
  }

  rep(i,n) cout << a[i] << " ";
  cout  << "\n";
  rep(i,n) cout << b[i] << " ";
  cout  << "\n";
  
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    
    rep(i, 9){
        rep(j, 9){
            if((i+1)*(j+1)==n){
                cout << "Yes" << endl; return 0;
            }
        }
    }


    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
from heapq import*
I=lambda:list(map(int,input().split()))[::-1]
k,n=I()
q=[]
v=i=T=A=0
l=[0]*-~n
for b,a in sorted(I()for _ in[0]*n)[::-1]:
 if i<k:
  if l[a]:heappush(q,b)
  else:T+=v*2+1;v+=1
  T+=b
 elif l[a]^1and q:T+=b+v*2+1-heappop(q);v+=1
 A=max(A,T);i+=1;l[a]=1
print(A)

Measured memory_bytes: 21664
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    int i;

    ll ans0=1, ans1=1;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        ans0 *= 3;
        ans1 *= (tmp%2? 1: 2);
    }
    printf("%lld\n", ans0-ans1);

    return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var r = bufio.NewReaderSize(os.Stdin, 100000)
var tokens []string
var nextToken int

func nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := r.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func next() string {
	for nextToken >= len(tokens) {
		line := nextLine()
		tokens = strings.Fields(line)
		nextToken = 0
	}
	r := tokens[nextToken]
	nextToken++
	return r
}

func nextInt() int {
	i, e := strconv.Atoi(next())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n, q := nextInt(), nextInt()
	s := next()

	a := make([]int, n)
	for i := 0; i < n-1; i++ {
		if s[i] == 'A' && s[i+1] == 'C' {
			a[i+1] = 1
			i++
		}
	}

	sums := make([]int, n+1)
	for i := 0; i < n; i++ {
		sums[i+1] = sums[i] + a[i]
	}

	w := bufio.NewWriter(os.Stdout)
	for i := 0; i < q; i++ {
		l, r := nextInt(), nextInt()
		_, _ = fmt.Fprintln(w, sums[r] - sums[l])
	}

	_ = w.Flush()
}


Measured memory_bytes: 6144
#include <stdio.h>

int main() {
  int A, B, ans;
  scanf("%d", &A);
  scanf("%d", &B);
  if (A+B==3) ans = 3;
  else if (A+B==4) ans = 2;
  else ans = 1;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int in;
	priority_queue<int> pq;
	string s;
	while(1) {
		cin >> s;
		if (s == "end") {
			break;
		}
		else if (s == "insert") {
			cin >> in;
			pq.push(in);
		}
		else {
			cout << pq.top() << endl;
			pq.pop();
		}
	}
}


Measured memory_bytes: 7032
//Bismillahir Rahmanir Raheem
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<queue>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<deque>
#include<set>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long LL;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef pair<int, int> pii;
#define FF first
#define SS second
#define MP make_pair
#define mxN (int)2e5 + 2
#define sz(n) (int)(n).size()
#define fasterIO ios::sync_with_stdio(0); cin.tie(0);
LL gcd(LL a, LL b)
{
    if(b == 0LL) return a;
    return gcd(b, a % b);
}
LL bigmod(LL a, LL b, LL mod)
{
    if(b == 0LL) return 1LL;
    LL sq = bigmod(a, b/2LL, mod);
    sq = (sq * sq) % mod;
    if(b&1LL) return (sq * (a%mod)) % mod;
    return sq;
}


int main()
{
    fasterIO
    string s;
    cin >> s;
    LL sum = 0;
    for(int i = 0; i < sz(s); i++)
    {
        sum += s[i] - '0';
    }
    cout << ((sum % 9 == 0) ? "Yes" : "No") << endl;
    return 0;
}





Measured memory_bytes: 3312
use std::collections::BTreeMap;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n: usize = sc.read();
    let mut p: usize = sc.read();
    let mut map = BTreeMap::new();
    for prime in 2.. {
        if prime * prime > p {
            break;
        }
        if p % prime == 0 {
            let mut count = 0;
            while p % prime == 0 {
                p /= prime;
                count += 1;
            }
            map.insert(prime, count);
        }
    }
    if p > 1 {
        map.insert(p, 1);
    }

    let mut ans = 1;
    for (&prime, &count) in map.iter() {
        let mut count = count;
        while count >= n {
            count -= n;
            ans *= prime;
        }
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define all(A) A.begin(),A.end()
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
typedef std::vector<int> vi;
typedef std::pair<int,int> pi;
typedef std::vector<pi> vp;
typedef long long ll;
#define popcnt(x) __builtin_popcount(x)
#define LSOne(x) ((x) & (-(x)))
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
#define what_is(x) cerr << #x << " is " << x << endl
#define bit_lg(x) (assert(x > 0),__builtin_ffsll(x) - 1)
const double PI = acos(-1);
template<class A,class B>
std::ostream& operator << (std::ostream& st,const std::pair<A,B> p) {
	st << "(" << p.first << ", " << p.second << ")";
	return st;
}
#define tc() int T; scanf("%d",&T); for(int t = 1;t <= T;t++)
using namespace std;




int main(){
#ifdef HOME
	freopen("in.in", "r", stdin);
#endif
	int ctr[2] = {0};
	int n; scanf("%d",&n);
	loop(i,n){
		int x; scanf("%d",&x);
		ctr[x&1]++;
	}
	ctr[0] += ctr[1] >> 1;
	ctr[1] &= 1;
	int res = ctr[1] + (ctr[0] > 0);
	puts((res == 1) ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 256
// Dice02.cc
#include<iostream>
using namespace std;

// Dice面番号；Diceの各面固有の数値；0-5
// Dice整数値：Diceの各面に表示される整数値
class Dice {
public:
  // Diceオブジェクトが生成された時に
  // そのDiceの各面の整数値を設定する。
  // また、上面の番号と前面の番号を添字とし、右面の番号を値に持つ二次元配列変数の値をセットする。
  Dice() {
    number = new int[6];
    setDiceRight();
  }

  ~Dice() {
    delete[] number;
  }

  // Dice面番号とDice整数値を受け取り、number配列にセットする。
  void setlabel( int index, int num) {
    number[ index] = num;
  }

  // Dice上面のDice整数値と前面のDice整数値を受け取り、右側の面のDice整数値を返す。
  int getRight( int top, int front) {
    int index_top, index_front;
    index_top = getindex( top);
    index_front = getindex( front);
    return number[ dice_right[ index_top][ index_front]];
  }

private:
  int *number;
  int dice_right[6][6];

  void setDiceRight() {
    dice_right[0][1]=2;
    dice_right[0][2]=4;
    dice_right[0][4]=3;
    dice_right[0][3]=1;

    dice_right[1][5]=2;
    dice_right[1][2]=0;
    dice_right[1][0]=3;
    dice_right[1][3]=5;

    dice_right[2][5]=4;
    dice_right[2][4]=0;
    dice_right[2][0]=1;
    dice_right[2][1]=5;

    dice_right[3][5]=1;
    dice_right[3][1]=0;
    dice_right[3][0]=4;
    dice_right[3][4]=5;

    dice_right[4][5]=3;
    dice_right[4][3]=0;
    dice_right[4][0]=2;
    dice_right[4][2]=5;

    dice_right[5][4]=2;
    dice_right[5][2]=1;
    dice_right[5][1]=3;
    dice_right[5][3]=4;
  }

  int getindex( int num) {
    for ( int i = 0; i < 6; i++) {
      if ( number[ i] == num) return i;
    }

    return -1;
  }
};

int main( void) {
  Dice dice;
  int label;
  int top, front;
  int num;

  for ( int i = 0; i < 6; i++) {
    cin >> label;
    dice.setlabel( i, label);
  }
  cin >> num;
  for ( int i = 0; i < num; i++) {
    cin >> top >> front;
    cout << dice.getRight( top, front) << endl;
  }
}



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

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N, T, S;
  while(cin>>N>>T>>S && N){
    vector<int> pleasure(N);
    vector<int> time(N);
    static int dp[3001][3001];
    memset(dp, 0, sizeof(dp));
    REP(i, N){
      cin>>pleasure[i]>>time[i];
    }
    REP(i, N){
      REP(t, T+1){
        dp[i+1][t] = max(dp[i][t], dp[i+1][t]);
        if(t + time[i] <= T && !(t < S && S < t + time[i])){
          dp[i+1][t + time[i]] = max(dp[i+1][t + time[i]], dp[i][t] + pleasure[i]);
        }
        //cout<<dp[i+1][t]<<" ";
      }
      //cout<<endl;
    }
    int ans = 0;
    REP(t, T+1) ans = max(ans, dp[N][t]);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 35000
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,k;
	while(cin >> n >> k , n){
		int d[100001] = {0};
		for(int i=1;i<=n;i++){
			int t;cin >> t;
			d[i] = d[i-1] + t;
		}
		int ans = 0;
		for(int i=1;i+k-1<=n;i++){
			ans = max(ans,d[i+k-1]-d[i-1]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);



int main(){
  string s;
  cin >> s;
  int n=s.size();
  rep(i,n){
    for(int j=i;j<n;j++){
      string t=s.substr(0,i);
      string u=s.substr(j);
      string k=t;
      k+=u;
      if(k=="keyence"){
        cout <<"YES"<<endl;
        return 0;
      }
    }
  }
  cout <<"NO"<<endl;
  
    
}


Measured memory_bytes: 256
<?php
list($n,$m,$c)=explode(" ",trim(fgets(STDIN)));
$b=explode(" ",trim(fgets(STDIN)));
$ans=0;
$i=0;
while($i<$n){
  $a=explode(" ",trim(fgets(STDIN)));
  $sum=$c;
  $j=0;
  while($j<$m){
    $sum+=$a[$j]*$b[$j];
    ++$j;
  }
  if($sum>0){
    ++$ans;
  }
  ++$i;
}
echo $ans;

Measured memory_bytes: 4728
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;



int main() {
    int x;
    cin >> x;
    bool judge = false;
    
    for(ll i=-2000; i<=2000; i++){
        for(ll j=-2000; j<=2000; j++){
            if(i*i*i*i*i-j*j*j*j*j == x){
                cout << i << " " << j << endl;
                judge = true;
            }
            if(judge) break;
        }
        if(judge) break;
    }
    
    return 0;
}



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

int main() {
	int N;
	cin >> N;
	char c;
	
	for (int i = 0; i < N; i++) {
		cin >> c;
		if (c == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}

	cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  cin>>a>>b>>c;
  if(a!=b && a!=c && b!=c)
  {
      cout<<"No";
      
  }
  else
  {
      if(a==b && b==c){
      cout<<"No";
      }
      else{
          cout<<"Yes";
      }
  }
  return 0;
}

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

int main() {
  int A,B,C,D,L,R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if ( L > R ) {
    cout << "Left" << endl;
  }else if ( L < R ){
    cout << "Right" << endl;
  }else if ( L == R ){
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

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

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        int ni = i;
        int sum = 0;
        while(ni) {
            sum += ni % 10;
            ni /= 10;
        }
        if(a <= sum && sum <= b) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <list>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  int n,m;
  cin >> n >> m;
  int q;
  cin >> q;
  int arr[q];
  for(int i=0;i<q;i++)
    cin >> arr[i];
  int arr1[n][m];
  int index=0;
  for(int i=0;i<m;i++)
  {
    if(i%2==0){
      for(int j=0;j<n;j++)
      {
        if(arr[index]>0){
          arr1[j][i]=index+1;
          arr[index]-=1;
        }
        else{
          while(true){
            if(arr[index]>0)
              break;
            index++;
          }
          arr1[j][i]=index+1;
          arr[index]-=1;
        }
      }
    }
    else{
      for(int j=n-1;j>=0;j--)
      {
        if(arr[index]>0){
          arr1[j][i]=index+1;
          arr[index]-=1;
        }
        else{
          while(true){
            if(arr[index]>0)
              break;
            index++;
          }
          arr1[j][i]=index+1;
          arr[index]-=1;
        }
      }
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
      cout << arr1[i][j] << ' ';
    cout << endl;
  }
  return 0;
}


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


char getThird(char a, char b) {
    return ('R' + 'G' + 'B' - (a + b));
}

long long rgb(string inp) {
    const int len = inp.length();
  	if (len <= 3) return 0;
    int* r_count = new int[len + 1];
    int* g_count = new int[len + 1];
    int* b_count = new int[len + 1];
    int* arrToUse = NULL;

    r_count[len] = 0;
    g_count[len] = 0;
    b_count[len] = 0;

    for (int i = inp.length() - 1; i >= 0; i--) {
        r_count[i] = r_count[i + 1];
        g_count[i] = g_count[i + 1];
        b_count[i] = b_count[i + 1];

        if (inp[i] == 'R') r_count[i]++;
        if (inp[i] == 'G') g_count[i]++;
        if (inp[i] == 'B') b_count[i]++;
    }
    long long ret = 0;
    
    for (int i = 0; i < inp.length() - 2; i++) {
        for (int j = i + 1; j < inp.length() - 1; j++) {
            if (inp[j] != inp[i]) {
                char third = getThird(inp[i], inp[j]);
                if (third == 'R') arrToUse = r_count;
                else if (third == 'G') arrToUse = g_count;
                else arrToUse = b_count;
                
                int val = arrToUse[j + 1];
                if (val > 0 && (j + (j - i) < inp.length()) && inp[j + (j - i)] == third) {
                    val--;
                }
                ret += val;
            }
        }
    }

    arrToUse = NULL;

    delete[] r_count;
    delete[] g_count;
    delete[] b_count;

    return ret;
}

int main() {
  int n;
  string inp;
  cin >> n;
  cin >> inp;
  cout << rgb(inp) << endl;
}


Measured memory_bytes: 3204
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	string s;
	cin >> s;
	//cout << a*a-b << endl;
	printf((s[0]==s[1]&&s[1]==s[2]||s[1]==s[2]&&s[2]==s[3]) ? "Yes\n" :"No\n");
}

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

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int mod = 998244353;
#define ll long long
#define int ll
const int N = 1e6 + 10;

ll power(ll a, ll b, ll m = mod){ll r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}

int f[N], inv[N], n, a, b, k;
void pre(){
	f[0] = 1, f[1] = 1;
	for (int i = 2; i < N; ++i)
		f[i] = (i*f[i-1])%mod;
	inv[N-1] = power(f[N-1], mod-2);

	for (int i = N-2; i >= 0; --i)
		inv[i] = ((i+1)*inv[i+1])%mod;
}

int C(int n, int r){
	if(r > n)return 0;
	ll t = (f[n]*inv[r])%mod;
	t = (t*inv[n-r])%mod;
	return t;
}

int32_t main(){_

	cin>>n>>a>>b>>k;

	pre();

	int ans = 0;
	for (int i = 0; i <= n; ++i)
	{
		int x = i;
		int y = (k-i*a);
		if(y%b)continue;
		int j = y/b;
		if(j < 0 or j > n)continue;
		ans += (C(n,i)*C(n,j))%mod;
		ans %= mod;
	}
	cout<<ans;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<string> s(N);
	for (int i = 0; i < N; i++) cin >> s.at(i);

	int M;
	cin >> M;

	vector<string> t(M);
	for (int i = 0; i < M; i++) cin >> t.at(i);

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int n = count(s.begin(), s.end(), s.at(i));
		int m= count(t.begin(), t.end(), s.at(i));
		ans = max(ans, n - m);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<set>
using namespace std;
int main()
{
    long long n,k=0,i,t=0,j,m,b,x=0,y=0;
    cin>>n;
    string s[n];
    int a[n][26],c[26];
    for(i=0;i<n;i++)
      for(j=0;j<26;j++)
         a[i][j]=0;
    for(i=0;i<n;i++)
       cin>>s[i];
    for(i=0;i<n;i++)
       for(j=0;j<s[i].size();j++)
          {
              a[i][s[i][j]-97]++;
          }
    for(i=0;i<26;i++)
       {
           c[i]=a[0][i];
       }
    for(i=1;i<n;i++)
       for(j=0;j<26;j++)
          {
              if(c[j]>a[i][j])
                {
                    c[j]=a[i][j];
                }    
          }
    for(i=0;i<26;i++)
       {
           if(c[i]>0)
             {
                 for(j=0;j<c[i];j++)
                    cout<<char(i+97);
                 k++;    
             }
       }
    if(k==0)
      cout<<" ";
    return 0;
}

Measured memory_bytes: 256