akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
 using namespace std ;
 int main()
 {
   int A, B, c, d, e;
   cin>>A;
   cin>>B;
   c =(A + B);
   d =(A - B);
   e =(A * B);
   if (c >= e&&c >= d)
   {
   cout<<c<<endl;
   }
else   if (e >= d&&e >= c)
   {
     cout<<e<<endl;
   }
  else  if (d >= e&&d >= c) 
   {
     cout<<d<<endl;
   }
   }

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
int n;
#define rep(i,n) for(int i=0; i<n; i++)
int main(){
    cin >> n;
   	int a[n]; rep(i,n) cin >> a[i];
  	double ans = 0;
  	rep(i,n){
      ans += (double)1/a[i];
    }
  	cout << 1/ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char str[100];
  char *start_str = str;
  int len=0;
  scanf("%s",str);
  while(*start_str!='\0'){
    len++;
    start_str++;
  }
  int i;
  //S is palindrome
  for(i=0;i<len/2;i++){
    if(str[i]!=str[len-i-1]){
      printf("No");
      return 0;
    }
  }
  int front = (len-1)/2;
  for(i=0;i<front;i++){
    if(str[i]!=str[front-i-1]){
      printf("No");
      return 0;
    }
  }
  int rear = (len+3)/2;
  for(i=rear;i<len;i++){
    if(str[i-1]!=str[len-(i-rear)-1]){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int ab = scanner.nextInt();
		int bc = scanner.nextInt();
		int ca = scanner.nextInt();
		int area = (ab*bc)/2;
		System.out.println(area);

	}
}

Measured memory_bytes: 22740
#include<iostream>
#include<string>
using namespace std;
int main(){
    //各種宣言
    int n, taro_point=0, hanako_point=0;
    string taro, hanako;
    
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> taro >> hanako;
        if(taro > hanako){
            taro_point += 3;
        }else if(taro < hanako){
            hanako_point += 3;
        }else{
            taro_point++;
            hanako_point++;
        }
    }
    
    cout << taro_point << " " << hanako_point << endl;
    
    
    return 0;
}


Measured memory_bytes: 3144
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
s=0
lt=0
ln=0

if c==1:
    print(n)
    exit()
for i in range(n):

    if i==0:
       lt=i
       ln+=1

    else:
        if t[i]-t[lt]>k:
            s+=1
            lt=i
            ln=0

        ln+=1
        if ln==c:
            s+=1
            lt=i+1
            ln=0

        #print(i, s, lt, ln)


    
if ln>0:
    s+=1

print(s)


Measured memory_bytes: 13228
import java.io.*;

class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			boolean[] cupArray = {true, false, false};
			String line;

			while ((line = br.readLine()) != null) {
				if (line.equals("")) {
					break;
				}
				String[] dataSet = line.split(",");
				int index1 = changeFormat(dataSet[0]);
				int index2 = changeFormat(dataSet[1]);
				cupArray = swap(cupArray, index1, index2);
			}
			System.out.println(find(cupArray));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/*
	 * "A", "B", "C" ??¨?????????????????§??\??????????????????????????°??????????????????
	 * @param String????????\??????????????????????????????
	 * @return int???????????????????????????????????????????????????
	 */
	private static int changeFormat(String index) {
		int result = 0;
		switch (index) {
		case "A":
			result = 0;
			break;
		case "B":
			result = 1;
			break;
		case "C":
			result = 2;
			break;
		default:
			break;
		}
		return result;
	}

	/*
	 * ??????????????\????????????????????????
	 * @param boolean??????????????????????????¶??????????´????????????????
	 * @param int????????\??????????????????????????????
	 * @param int????????\??????????????????????????????
	 * @return boolean?????????????????????????????°??¶????????????????????????
	 *
	 */
	private static boolean[] swap(boolean[] cupArray, int index1, int index2) {
		boolean tmp = cupArray[index1];
		cupArray[index1] = cupArray[index2];
		cupArray[index2] = tmp;
		return cupArray;
	}
	
	/*
	 * ??????????????\??£?????????????????????????????????????????????
	 * @param boolean??????????????????????????¶??????????´????????????????
	 * @return String????????????????????\??£?????????????????????
	 */
	private static String find(boolean[] cupArray) {
		String[] cupName = {"A", "B", "C"};
		for(int i=0; i<cupArray.length; i++){
			if(cupArray[i] == true){
				return cupName[i];
			}
		}
		return "Not Find";
	}
}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi a(n+1); for(auto& e : a) cin >> e;
    vi b(n); for(auto& e : b) cin >> e;

    ll res = 0;
    rep(i, n){
        res += min(a[i], b[i]);
        b[i] -= a[i];
        if(b[i] > 0){
            res += min(a[i+1], b[i]);
            a[i+1] = max(0, a[i+1] - b[i]);
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes printf("Yes\n")
#define no printf("No\n")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

const int INF=1LL<<55;

int a,b,c;
int tempa,tempb,tempc;
int k;

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

    cin>>a>>b>>c>>k;

    int ans=a-b;
    if(k&1){
        cout<<-ans<<endl;
    }else{
        cout<<ans<<endl;
    }

    return 0;
}

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

constexpr int si = 1001 * 1001;
int n, m, k, ar[si], b[si];

int gcd(int a, int b) {
   while (b) {
      auto r = a % b;
      a = b;
      b = r;
   }
   return a;
}

int sol() {
   if (m < k) return 0;
   {sort(ar, ar + n);
   int z = (int)(unique(ar, ar + n) - ar);
   n = z; }
   if (1 == n) return 0;
   if (1 == ar[0]) return 1;
   
   int cn = 0;
   for (int i = 0; i < n - 1; i++) {
      const auto g = gcd(ar[i], ar[i + 1]);
      if (1 == g) return 1;
      b[cn++] = g;
   }
  
   {sort(b, b + cn);
   int z = (int)(unique(b, b + cn) - b);
   cn = z; }
   if (1 == b[0]) return 1;

   for (int i = 0; i < cn - 1; i++) {
      const auto g = gcd(b[i], b[i + 1]);
      if (1 == g) return 1;
      if (g % b[0])
         return 1;
   }

   auto it = upper_bound(ar, ar + n, k);
   const int num = *it,
   diff = num-k,
   rem = diff % b[0];
   return 0 == rem;
}

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

   while (cin >> n >> k)
   {
      m = 0;
      int ha = 0;
      for (int i = 0; i < n; i++) { cin >> ar[i];
         m = max(m, ar[i]); if (k == ar[i]) ha = 1; }
      puts(ha || sol() ? "POSSIBLE" : "IMPOSSIBLE");
   }
   return 0;
}

Measured memory_bytes: 4608
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            var Source = Console.ReadLine().ToList();

            Console.WriteLine(new List<char> { 'a', 'b', 'c' }.Select(s => Source.Contains(s)).Aggregate((b, b1) => b && b1) ? "Yes" : "No");

        }

        public static int countWordInArray(IEnumerable<string> sourcelist, string TargetWord)
        {
            return sourcelist.Count(s => s == TargetWord);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#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<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; }

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

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};

struct tt {
    int a, b, c;
    bool operator<(const tt &x) const {
        if(a == x.a) return b < x.b;
        else return a < x.a;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<tt> a(m);
    for(int i = 0; i < m; i++) {
        cin >> a[i].a >> a[i].b;
        a[i].c = i;
    }
    sort(a.begin(), a.end());
    vector<P> ans(m);
    int now = 1, cnt = 0;
    for(int i = 0; i < m; i++) {
        if(a[i].a == now) cnt++;
        else while(now != a[i].a) now++, cnt = 1;
        ans[a[i].c] = P(a[i].a, cnt);
    }
    for(int i = 0; i < m; i++) {
        cout << setw(6) << setfill('0') << ans[i].first << setw(6) << setfill('0') << ans[i].second << endl;
    }
}

Measured memory_bytes: 3456
package main

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

func main() {
	sc := NewScanner()
	A, B, C := sc.NextInt(), sc.NextInt(), sc.NextInt()

	if A == B && B == C {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <bitset>
#include <random>


int main() {
	int k; std::cin >> k;
	std::vector<int> nums{ 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 };
	std::cout << nums[k - 1] << '\n';
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std ;
#define pb push_back
#define ll long long
vector<ll>vec ;
ll len ;
ll dp[200][5][2] ;
ll k ;
void gen(string s ) {
    vec.clear() ;

    for(ll i=0;i<s.size();i++) vec.pb( (int) s[i]-'0') ;
    len = vec.size() ;
}

ll digit_dp(ll pos , ll not_zero , ll is_big ) {
    if (not_zero>k) return 0LL ;
    if (pos>=len) return 1LL ;
    if (dp[pos][not_zero][is_big]!=-1) return dp[pos][not_zero][is_big] ;
    ll lim , ans = 0 , i , nxt_big , nxt_zero ;
    if (is_big) lim = vec[pos] ;
    else lim = 9 ;

    for(i=0;i<=lim;i++) {
        if (is_big and (lim==i) ) nxt_big = 1 ;
        else nxt_big = 0 ;

        if (i) nxt_zero = not_zero+1 ;
        else nxt_zero = not_zero ;

        ans+= digit_dp(pos+1 , nxt_zero,nxt_big ) ;


    }

    return dp[pos][not_zero][is_big] = ans ;

}




int main() {
    string s ;
    cin >> s >>  k ;
    gen(s) ;

    memset(dp,-1,sizeof(dp)) ;
    ll left =  digit_dp(0,0,1) ;
    k-- ;
    memset(dp,-1,sizeof(dp)) ;
    ll right = digit_dp(0,0,1) ;
    cout << left -right ;


    return 0 ;
}


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

using namespace std;

int n,m;
string a[105],b[105];

map <string,int> ma;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    cin >> m;
    for (int i = 1; i <= m; i++)
        cin >> b[i];
    for (int i = 1; i <= n; i++)
        ma[a[i]]++;
    for (int i = 1; i <= m; i++)
        ma[b[i]]--;
    int x=0;
    for (int i = 1; i <= n; i++)
        x=max(x,ma[a[i]]);
    cout << x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<ll, ll> mp;
    mp[0] = 1000;
    for (int i = 0; i < n; i++) {
        map<ll, ll> np = mp;
        ll k = mp[0];
        for (auto p : mp) {
            if (p.first) {
                np[0] = max(np[0], p.second + p.first * a[i]);
            } else {
                np[k / a[i]] = max(np[k / a[i]], k % a[i]);
            }
        }
        swap(mp, np);
    }
    cout << mp[0] << '\n';
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
using namespace std;

long long a[300000];
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < 3 * N; i++){
        cin >> a[i];
    }
    sort(a, a + 3 * N);
    long long ans = 0;
    for(int i = 0; i < N; i++){
        ans += a[N + i * 2];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
n = int(input())
a = list(int(input()) for i in range(n))
l = a[:]
l.sort(reverse=True)
x = l[0]
y = l[1]
ans = 0
for i in range(n):
    if a[i] == x:
        ans = y
    else:
        ans = x
    print(ans)

Measured memory_bytes: 14072
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <limits>
using namespace std;
typedef long long ll;

enum Face {
	TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM, FACE_SIZE
};

template<class T>
struct Dice {
	T face[FACE_SIZE];

	Dice(){}
	Dice(T top, T front, T right, T left, T back, T bottom){
		face[TOP] = top;
		face[FRONT] = front;
		face[RIGHT] = right;
		face[LEFT] = left;
		face[BACK] = back;
		face[BOTTOM] = bottom;
	}

	void roll_y(){
		roll(FRONT, RIGHT, BACK, LEFT);
	}

	void roll_x(){
		roll(FRONT, BOTTOM, BACK, TOP);
	}

	void roll_z(){
		roll(TOP, RIGHT, BOTTOM, LEFT);
	}

	void roll(Face a, Face b, Face c, Face d){
		char tmp = face[d];
		face[d] = face[c];
		face[c] = face[b];
		face[b] = face[a];
		face[a] = tmp;
	}

	T at(Face a) const {
		return face[a];
	}

	static std::vector< Dice<T> > all_rolls(Dice<T> dice){
		std::vector< Dice<T> > res;
		for(int k=0;k<6;(k&1?dice.roll_y():dice.roll_x()),k++){
			for(int j=0;j<4;dice.roll_z(),j++){
				res.push_back(dice);
			}
		}
		return res;
	}
};


int dz[] =  {0, 0,  0,  0, 1, -1};
int dy[] =  {1, -1, 0,  0, 0, 0};
int dx[] =  {0, 0,  1, -1, 0, 0};
Face from[] = {BOTTOM, TOP, RIGHT, LEFT, BACK, FRONT};
Face to[] =   {TOP, BOTTOM, LEFT, RIGHT, FRONT, BACK};


bool valid[300][300];


Dice<char> rolls[8][24];

bool used[2][2][2];
Dice<char> cube[2][2][2];

bool dfs(int n, int mask){
	if(n >= 8)return true;

	int m = n;
	int x = m % 2; m /= 2;
	int y = m % 2; m /= 2;
	int z = m;

	for(int i=0;i<8;i++){
		if((mask >> i) & 1)continue;

		for(int r=0;r<24;r++){
			Dice<char> dice = rolls[i][r];
			bool ok = true;

			for(int k=0;k<6;k++){
				int nz = z + dz[k];
				int ny = y + dy[k];
				int nx = x + dx[k];

				if(nz < 0 || nz >= 2 || ny < 0 || ny >= 2 || nx < 0 || nx >= 2)continue;
				if(!used[nz][ny][nx])continue;

				if(!valid[ dice.at(from[k]) ][ cube[nz][ny][nx].at(to[k]) ]){
					ok = false;
					break;
				}
			}

			if(!ok)continue;

			used[z][y][x] = true;
			cube[z][y][x] = dice;


			if(dfs(n + 1, mask | (1 << i)))return true;

			used[z][y][x] = false;

		}
	}

	return false;
}

inline string solve(const vector< Dice<char> > &dice_vec){
	for(int i=0;i<dice_vec.size();i++){
		vector< Dice<char> > all_rolls = Dice<char>::all_rolls(dice_vec[i]);
		for(int j=0;j<all_rolls.size();j++){
			rolls[i][j] = all_rolls[j];
		}
	}

	memset(used, false, sizeof(used));
	return dfs(0, 0) ? "YES" : "NO";
}


Dice<char> toDice(const string& init){
	return Dice<char>(init[0], init[1], init[2], init[3], init[4], init[5]);
}

int main(){
	memset(valid, false, sizeof(valid));
	for(int i=0;i<26;i++){
		char a = 'a' + i;
		char b = 'A' + i;
		valid[a][b] = true;
		valid[b][a] = true;
	}

	string init;
	while(cin >> init){
		if(init == "0")break;

		vector< Dice<char> > dices;
		dices.push_back(toDice(init));

		for(int t=0;t<7;t++){
			cin >> init;
			dices.push_back(toDice(init));
		}

		cout << solve(dices) << endl;
	}

	return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
#define AC ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
int main()
{
    AC
    int a[200000],b[200000],n;
    cin>>n;
    for(int i=0; i<n-1; i++)
    {    
        cin>>b[i];
        a[b[i]-1]++;
    }
    for(int i=0; i<n; i++) cout<<a[i]<<'\n';
}

Measured memory_bytes: 5172
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
if a > b:
    t = a
    a = b
    b = t
if b > c:
    t = b
    b = c
    c = t
if a > b:
    t = a
    a = b
    b = t
print(str(a) + " " + str(b) + " " + str(c))


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

struct Edge {
    int to, id;
    Edge(int _to, int _id) : to(_to), id(_id) {}
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<Edge>> G(N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
    }
    auto dfs = [&](auto &&dfs, int cur, int ng, int64_t bit) -> int64_t {
        int64_t res = 1LL << cur;
        for(auto &e : G[cur]) {
            if(e.id == ng) continue;
            if(bit & (1LL << e.to)) continue;
            res |= dfs(dfs, e.to, ng, bit | (1LL << e.to));
        }
        return res;
    };
    int ans = 0;
    rep(i, N) for(auto &e : G[i]) {
        int64_t mask = dfs(dfs, i, e.id, 0LL);
        ans += (mask == (1LL << N) - 1);
    }
    cout << M - ans / 2 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t="keyence";
  cin>>s;
  if(s.substr(s.size()-7,7)==t||s.substr(0,7)==t)cout<<"YES";
  else{
    int a=0,b=0;
    while(a<7&&s[a]==t[a])a++;
    while(b<7&&s[s.size()-1-b]==t[6-b])b++;
    if(a+b>=7)cout<<"YES";
    else cout<<"NO";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
double dp[22][22][15000];
int n;
double r, theta;
double x[22], y[22];
bool can[22][22][22];

double dist(int i, int j) {
    return pow(pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2), 0.5);
}

int ans = 0;
void chmin(double &a, double b) {
    a = min(a, b);
}
int main() {
    //cout.precision(10);
    cin >> n;
    cin >> r >> theta;
    for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            if(j == i) continue;
            for(int k = 1; k <= n; k++) {
                if(j == k) continue;
                double X = (x[k] - x[j]) * (x[j] - x[i]);
                double Y = (y[k] - y[j]) * (y[j] - y[i]);
                //cerr << i << " " << j << " " << k << " " << " " << X << " " << Y << " " << acos((X + Y) / (dist(i, j ) * dist(j, k))) << endl;
                if(acos((X + Y) / (dist(i, j) * dist(j, k))) - EPS <= (theta / 180.0 * PI)) {
                    //cerr << i << " " << j << " " << k << endl;
                    can[i][j][k] = true;
                }
            }
        }
    }
    for(int i = 0; i <= 20; i++) {
        for(int j = 0; j <= 20; j++) {
            for(int k = 0; k <= 1e4 + 2; k++) dp[i][j][k] = 1e9;
        }
    }
    for(int i = 2; i <= n; i++) {
        dp[1][i][1] = dist(1, i);
        if(dp[1][i][1] - EPS <= r) {
            ans = 1;
        }
    }
    if(ans == 0) {
        cout << 0 << endl;
        return 0;
    }
    for(int num = 2; num <= 2e5; num++) {
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                if(i == j) continue;
                for(int k = 1; k <= n; k++) {
                    if(!can[i][j][k]) continue;
                    chmin(dp[j][k][num], dp[i][j][num-1] + dist(j, k));
                    //cerr << num << " " << j << " " << k << " " << dp[j][k][num] << endl;
                    if(dp[j][k][num] - EPS <= r) ans = num;
                }
            }
        }
        if(ans != num) break;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 39788
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
vector<int> fri[100000];
vector<int> blo[100000];
int frindex[100000];
int frindexcounter[100000];
int blocounter, fricounter[100000];
int main() {
	
	//B
	int a[3][3];
	int i, j, k;
	for (i = 0; i < 3; i++) {
		for (j = 0;j< 3; j++) {
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	int b;
	for (i = 0; i < n; i++) {
		cin >> b;
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 3; k++) {
				if (a[j][k] == b) {
					a[j][k] = -1;
				}
			}
		}
	}
	for (i = 0; i < 3; i++) {
		if (a[i][0] * a[i][1] * a[i][2] == -1) {
			cout << "Yes" << endl;
			return 0;
		}
		if (a[0][i] * a[1][i] * a[2][i] == -1) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	if (a[0][0] * a[1][1] * a[2][2] == -1) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a[0][2] * a[1][1] * a[2][0] == -1) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
	return 0;
	//C
	/*int n, m;
	int s[3] = { -1,-1,-1 };
	int a, b;
	int i;
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		if (s[a - 1] == -1) {
			s[a - 1] = b;
		}
		else {
			if (s[a - 1] != b) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	if (n == 3) {
		if (s[0] == 0) {
			cout << -1 << endl;
			return 0;
		}
		else if (s[0] == -1) {
			a = 100;
		}
		else {
			a = s[0] * 100;
		}
		if (s[1] == -1) {
			
		}
		else {
			a = a + s[1] * 10;
		}
		if (s[2] == -1) {

		}
		else {
			a = a + s[2];
		}
	}
	else if (n == 2) {
		if (s[0] == 0) {
			cout << -1 << endl;
			return 0;

		}
		else if (s[0] == -1) {
			a = 10;
		}
		else {
			a = s[0] * 10;
		}
		if (s[1] == -1) {

		}
		else {
			a = a + s[1] * 1;
		}
	}
	else {
		if (s[0] == -1) {
			a = 0;
		}
		else {
			a = s[0];
		}
	}
	cout << a << endl;
	return 0;*/
	//D
	/*int n, m, k;
	cin >> n >> m >> k;

	int i, j, a, b;
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		fri[a - 1].push_back(b - 1);
		fri[b - 1].push_back(a - 1);
	}
	for (i = 0; i < k; i++) {
		cin >> a >> b;
		blo[a - 1].push_back(b - 1);
		blo[b - 1].push_back(a - 1);
	}

	for (i = 0; i < n; i++) {
		frindex[i] = -1;
		frindexcounter[i] = 0;
	}
	queue<int> que;
	int index = 0;
	for (i = 0; i < n; i++) {
		if (frindex[i] == -1) {
			frindex[i] = index;
			que.push(i);
			while (que.size()) {
				j = que.front(); que.pop();
				for (a = 0; a < fri[j].size(); a++) {
					if (frindex[fri[j][a]] == -1) {
						que.push(fri[j][a]);
						frindexcounter[index]++;
						frindex[fri[j][a]] = index;
					}
				}
			}
			index++;
		}
	}

	for (i = 0; i < n; i++) {
		blocounter = 0;
		for (j = 0; j < blo[i].size(); j++) {
			if (frindex[blo[i][j]] ==frindex[i]) {
				blocounter++;
			}
		}
		fricounter[i] = frindexcounter[frindex[i]] - fri[i].size() - blocounter;
		
	}
	for (i = 0; i < n; i++) {
		cout << fricounter[i] << ' ';
	}
	return 0;*/

}

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

int main() {
  int n;cin>>n;
  vector<int> a(55);
  vector<string> s(55);
  rep(i,n)cin>>s[i]>>a[i];
  string x;cin>>x;
    int cnt=0;
    for(int i=n-1;i>=0;i--){
      if(x==s[i])break;
      cnt+=a[i];
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3620
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 310000
ll MOD=998244353;

int a[1100][1100];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
main(){
    int h=in(),w=in();
    queue<pii> q;
    rep2(i,1,h)rep2(j,1,w){
        char c;cin>>c;
        if(c=='.'){a[i][j]=1;}
        else q.push({i,j});
    }
    int count=-1;
    while(!q.empty()){
        queue<pii> qq;
        while(!q.empty()){
        pii p=q.front();
        q.pop();
        rep(i,4){
            if(a[p.first+dx[i]][p.second+dy[i]]){
                a[p.first+dx[i]][p.second+dy[i]]=0;
                qq.push({p.first+dx[i],p.second+dy[i]});
            }
        }
        }
        count++;q=qq;
    }
    cout<<count;
}



Measured memory_bytes: 12800
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> v(n+1, INF);
    for(int i = n-1; i >= 0; --i){
        auto p = lower_bound(v.begin(), v.end(), a[i]+1);
        *p = a[i];
    }
    int ans = 0;
    rep(i,n){
        if(v[i] < INF) ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

template<i64 M>
struct modint {
    i64 x;

    constexpr modint(const i64 y = 0) noexcept : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}

    constexpr modint operator-() const noexcept { return modint(-x); }
    constexpr modint operator+(const modint &rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const noexcept { return modint(*this) /= rhs; }

    constexpr modint &operator+=(const modint &rhs) noexcept {
        x += rhs.x;
        if (x >= M) x -= M;
        return *this;
    }

    constexpr modint &operator-=(const modint &rhs) noexcept {
        if (x < rhs.x) x += M;
        x -= rhs.x;
        return *this;
    }

    constexpr modint &operator*=(const modint &rhs) noexcept {
        x = x * rhs.x % M;
        return *this;
    }

    constexpr modint &operator/=(const modint &rhs) noexcept {
        i64 a = rhs.x, b = M, u = 1, v = 0;
        while (b > 0) {
            i64 t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        *this *= u;
        return *this;
    }

    friend ostream &operator<<(ostream &os, const modint &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, modint &a) {
        i64 t;
        is >> t;
        a = modint(t);
        return is;
    }
};

constexpr i64 MOD = 1 ? 1'000'000'007 : 998'244'353;
using m64 = modint<MOD>;
constexpr m64 operator"" _m(unsigned long long n) { return m64(n); }

void solve() {
    string s;
    cin >> s;
    i64 d;
    cin >> d;
    i64 n = s.size();

    vector<vector<vector<m64>>> dp(n + 1, vector<vector<m64>>(2, vector<m64>(d)));
    dp[0][1][0] = 1;
    for (i64 i = 0; i < n; i++) {
        for (i64 j = 0; j < d; j++) {
            i64 x = s[i] - '0';
            dp[i + 1][1][(j + x) % d] += dp[i][1][j];
            for (i64 k = 0; k < x; k++) dp[i + 1][0][(j + k) % d] += dp[i][1][j];
            for (i64 k = 0; k < 10; k++) dp[i + 1][0][(j + k) % d] += dp[i][0][j];
        }
    }
    cout << dp[n][0][0] + dp[n][1][0] - 1 << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 20068
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  string s = input<string>();

  int count = 0;
  for(int i=0;i < s.length()/2;i++){
    if(s[i] != s[s.length() - i - 1]){
      count++;
    }
  }
  output(count);

  return 0;
}

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

int main(int argc, char const *argv[]){
	ld a,b,x;
	cin>>a>>b>>x;
	if(2*x > a*a*b){
		cout<<fixed<<setprecision(10)<<(45/atan(1))*atan(2*(a*a*b - x)/a/a/a);
	}
	else{
		ld val = 2*x/a/b/b;
		val = 90 - (45/atan(1))*atan(val);
		cout<<fixed<<setprecision(10)<<val;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    vector<int> L(N);
    rep(i,N) cin >> L.at(i);
    sort(L.begin(), L.end());
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (L[i] == L[j]) continue;
            for (int k = j + 1; k < N; k++) {
                if (L[j] == L[k]) continue;
                if (L[k] < L[i] + L[j]) cnt++;
            }
        }
    }
    cout << cnt << endl;
}


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

#define REP(i,n)    for(int i = 0; i < (int)n; i++)
#define MAX_N   100000
#define MAX_M   100000


void solve(){
    long long n, a, b;
    cin >> n >> a >> b;
    long long ans = n;
    if(n >= a + b){
        long long tmp = n / (a + b);
        ans -= b * tmp;
        if(n % (a + b) > a){
            ans -= ((n % (a + b)) - a);
        }
    }
    else if(n > a){
        ans = a;
    }
    else{
        ans = n;
    }
    cout << ans << endl;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        ks: [usize; 2]
    }
    println!("{}", solve(ks[0], ks[1]));
}

fn solve(k:usize, s:usize) -> usize {
    let mut answer = 0;
    for x in 0..k+1 {
        for y in 0..k+1 {
            if s >= x + y && s <= k + x + y {
                answer += 1;
            }
        }
    }
    answer
}

#[test]
fn solve_test() {
    assert_eq!(solve(2,2), 6);
    assert_eq!(solve(5,15), 1);
    assert_eq!(solve(2500, 7500), 1);
    assert_eq!(solve(2499, 7500), 0);
    assert_eq!(solve(2500, 2), 6);
}


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


	/* constants */
	#define inf (int)1e+9
	#define VIS 1
	#define UNVIS 0
	#define null NULL
	#define MAX (int)1e+6
	#define MIN -(int)1e+6
	
// ------------------------------------------------------------------------

int n;
vector<vector<int>> v;

int memo[(int)1e5+5][3];

int maxPoints(int day, int notodo) {

	if (memo[day][notodo]!=-1)
		return memo[day][notodo];

	if (day==n)
		return 0;

	int answer=-inf;
	for (int i=0; i<3; i++) {
		if (i!=notodo) {
			answer=max(answer, v[day][i] + maxPoints(day+1,i));
		}	
	}

	memo[day][notodo]=answer;
	return answer;
}

int main()
{
	
	cin.tie(NULL);
	cout.tie(NULL);

	/*Start*/
	
	scanf("%d",&n);

	v.resize(n);

	for (int i=0; i<n; i++)
		v[i].resize(3);

	for (int i=0; i<n; i++) {
		scanf("%d%d%d",&v[i][0],&v[i][1],&v[i][2]);
	}

	memset(memo,-1,sizeof(memo));	
	cout<<maxPoints(0,3)<<endl;

    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    long long A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    long long bit = 0;
    int n = 0;
    long long ans = 0;
    for (int i = 0; i < N; i++)
    {
        while (i + n < N && (bit == 0 || (bit & A[i + n]) == 0))
        {
            bit += A[i + n];
            n++;
        }
        ans += n;
        n--;
        bit -= A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll N; cin >> N;
    int altar[3][N + 1];
    rep(i, 3) {
        rep(j, N) {
            cin >> altar[i][j];
        }
        sort(altar[i], altar[i] + N);
        altar[i][N] = INF;
    }
    ll numBfillcondition[N];
    rep(i, N) {
        numBfillcondition[i] = N - (upper_bound(altar[2], altar[2] + N, altar[1][i]) - altar[2]);
    }
    ll sum[N + 1];
    sum[N] = 0;
    for(int i = N - 1; i >= 0; --i) {
        sum[i] = sum[i + 1] + numBfillcondition[i];
    }

    ll ans = 0;
    rep(i, N) {
        int keyB = upper_bound(altar[1], altar[1] + N, altar[0][i]) - altar[1];
        ans += sum[keyB];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2944
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main() {
	string a,b,t;
	int ta=0,tb=0;
	cin>>a>>b;
	t=a+b;
	for(int i=0;i<a.size()+b.size();i++){
		ta=ta*10+t[i]-'0';
	}
	t=b+a;
	for(int i=0;i<a.size()+b.size();i++){
		tb=tb*10+t[i]-'0';
	}
//	printf("%d %d\n",ta,tb);
	int sa=sqrt(ta),sb=sqrt(tb);
	if(sa*sa==ta || sb*sb==tb) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	if (s[0] == 'R') {
		if (s[1] != 'R') {
			cout << 1 << endl;
		} else if (s[2] != 'R') {
			cout << 2 << endl;
		} else {
			cout << 3 << endl;
		}
	} else if (s[1] != 'R') {
		if (s[2] != 'R') {
			cout << 0 << endl;
		} else {
			cout << 1 << endl;
		}
	} else {
		if (s[2] != 'R') {
			cout << 1 << endl;
		} else {
			cout << 2 << endl;
		}
	}
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n,i,j,all=0;
    scanf("%d",&n);
    int s[n];
    for(i=0;i<n;i++){
    scanf("%d",&s[i]);
    }
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            all+=s[i]*s[j];
        }
    }
    printf("%d",all);
}


Measured memory_bytes: 128
n = int(input())
A = list(map(int, input().split()))

mod = 10**9+7

A = [a+1 for a in A]
C = [0]*(n+1)
C[0] = 3
ans = 1
for a in A:
    if C[a-1] < C[a]:
        print(0)
        exit()
    else:
        ans *= C[a-1]-C[a]
        ans %= mod
        C[a] += 1
print(ans)

Measured memory_bytes: 90988
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,m,x,l=0,r=0; cin>>m>>m>>x;
  for(int i=0; i<m; i++){
    cin>>a;
    if(a<x) l++;
    else r++;
  }
  cout<<min(l,r);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for(int i=0; i<t; i++){
            long a = sc.nextLong();
            long b = sc.nextLong();
            long c = sc.nextLong();
            long d = sc.nextLong();
            if(a < b){
                System.out.println("No");
                continue;
            }
            if(b > d){
                System.out.println("No");
                continue;
            }
            if(c >= b){
                System.out.println("Yes");
                continue;
            }

            long tmp;
            long tb = b;
            long td = d;
            while((tmp=tb % td) != 0){
                tb = td;
                td = tmp;
            }

            tmp = (a-c) % td;

            if(tmp == 0) tmp = td;
            if(tmp < b-c){
                System.out.println("No");
            }else{
                System.out.println("Yes");
            }
        }
    }
}

Measured memory_bytes: 22600
while(True):
	T,D,L = map(int, input().split())
	if (T+D+L) == 0:break
	x = [int(input()) for i in range(T)]
	count = 0
	lag = 0
	for i in range(T):
		if lag > 0 :
			count += 1
		if x[i] >= L:
			lag = D
		else:
			lag -= 1
	print(count)


Measured memory_bytes: 14188
def main():
  S = list(input())
  T = input()

  t = ''.join(S)
  if t == T:
    print('Yes')
    return

  for _ in range(len(S)-1):
    last = S[-1]
    S.pop(-1)
    S.insert(0, last)
    t = ''.join(S)
    # print(t, T, t == T)

    if t == T:
      print('Yes')
      return
      
  print('No')
  return

main()

Measured memory_bytes: 3060
def dot(c1, c2):
    return c1.real * c2.real + c1.imag * c2.imag

def cross(c1, c2):
    return c1.real * c2.imag - c1.imag * c2.real

def project(p1, p2, p3):
    # p1 and p2 is are points on the line.
    # return the projection point x of p3 onto the line.
    base = p2 - p1
    return p1 + base * dot(p3 - p1, base) / (abs(base) ** 2)

def print_cross_point(c, r, p1, p2):
    # c is the center of the circle and r is the radius of the circle.
    # p1 and p2 are are points on the line.
    pr = project(p1, p2, c)
    l = p2 - p1
    e = l / abs(l)
    base = (r ** 2 - abs(pr - c) ** 2) ** 0.5
    c_p1 = pr - e * base
    c_p2 = pr + e * base
    print("{0:.10f} {1:.10f} {2:.10f} {3:.10f}".format(c_p1.real, c_p1.imag,
                                                       c_p2.real, c_p2.imag))


import sys

file_input = sys.stdin

cx, cy, r = map(int, file_input.readline().split())
c = cx + cy * 1j

q = file_input.readline()

for line in file_input:
    x1, y1, x2, y2 = map(int, line.split())
    p1 = x1 + y1 * 1j
    p2 = x2 + y2 * 1j
    if x1 < x2:
        print_cross_point(c, r, p1, p2)
    elif x1 > x2 or y1 > y2:
        print_cross_point(c, r, p2, p1)
    else:
        print_cross_point(c, r, p1, p2)

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

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

  int x = N%10;//7
  int y = N%100;
  if(x == 7){
    cout << "Yes" << endl;
  }else if((y-x)/10 == 7){
    cout << "Yes" << endl;
  }else if((N-y)/100 == 7){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 3620
#include <stdio.h>
int binarySearch(int,int,int);

int num[100000];
int main()
{
  int n,q,x,i,j;
  int cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&num[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&x);
    if(binarySearch(0,n,x)) cnt++;
  }
  printf("%d\n",cnt);

  return 0;
}

int binarySearch(int l,int r,int q){
  int m=(l+r)/2;
  if(num[m]==q) return 1;
  else if(l==m || r==m) return 0;
  else if(num[m] < q) return binarySearch(m,r,q);
  else return binarySearch(l,m,q);
}



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

typedef long long LL;  
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = 1000000007;

int main()
{
ios_base::sync_with_stdio(0); 
cout.precision(15);
cout.setf(ios::fixed);

LL a,b,c;
cin>>a>>b>>c;

if(b%2 == 0) swap(b,a);
if(c%2 == 0) swap(c,a);

if(a%2 == 0) 
	{cout<<0<<endl; return 0;}

LL ans = min(b*c,a*c);
ans = min(ans,a*b);

cout<<ans<<endl;


}


Measured memory_bytes: 256
N, a, b, c, *S = open(0).read().split()
N, a, b, c = map(int, (N, a, b, c))

flg = a*b*c == 0 and a+b+c == 2

ans = []
for i, s in enumerate(S):
    if s == 'AB':
        if flg and a*b == 1 and i < N-1:
            s_ = S[i+1]
            if s_ == 'AC':
                ans.append('A')
                a += 1
                b -= 1
                continue
            elif s_ == 'BC':
                ans.append('B')
                a -= 1
                b += 1
                continue

        ans.append('B' if a > b else 'A')
        if a > b:
            a -= 1
            b += 1
        else:
            a += 1
            b -= 1

    elif s == 'AC':
        if flg and a*c == 1 and i < N-1:
            s_ = S[i+1]
            if s_ == 'AB':
                ans.append('A')
                a += 1
                c -= 1
                continue
            elif s_ == 'BC':
                ans.append('C')
                a -= 1
                c += 1
                continue

        ans.append('C' if a > c else 'A')
        if a > c:
            a -= 1
            c += 1
        else:
            a += 1
            c -= 1

    elif s == 'BC':
        if flg and b*c == 1 and i < N-1:
            s_ = S[i+1]
            if s_ == 'AB':
                ans.append('B')
                b += 1
                c -= 1
                continue
            elif s_ == 'AC':
                ans.append('C')
                b -= 1
                c += 1
                continue

        ans.append('C' if b > c else 'B')
        if b > c:
            b -= 1
            c += 1
        else:
            b += 1
            c -= 1

    if a < 0 or b < 0 or c < 0:
        print('No')
        exit()


print('Yes')
[print(r) for r in ans]


Measured memory_bytes: 17908
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int count0 = 0;
    int count1 = 0;
    for (size_t i = 0; i < s.size(); i++) {
        if (s[i] == '0') {
            count0 += 1;
        }
        else if (s[i] == '1') {
            count1 += 1;
        }
    }

    cout << min(count0, count1) * 2 << endl;
}


Measured memory_bytes: 512