akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (l) < (x) && (x) < (r)

int main() {
    int X, Y;
    cin >> X >> Y;
    rep(i,0,101) rep(j,0,101) {
        if (i+j == X && 2*i + 4*j == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;

int main()
{
    int N,K;
    string S;
    cin>>N>>S>>K;

    for(int i=0;i<N;++i)
        if(S[i]!=S[K-1])
            cout<<"*";
        else
            cout<<S[i];
    cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m;
  cin >> n >> m;
  set<ll> a;
  rep(i, m) {
      int x; cin >> x;
      a.insert(x);
  }
  ll dp[100100];
  dp[0] = 1;
  dp[1] = (a.find(1) == a.end() ? 1 : 0);
  for(ll i = 2; i <= n ; i++) {
      if(a.find(i) != a.end()) {
          dp[i] = 0; continue;
      }
      dp[i] = dp[i - 1] + dp[i - 2];
      dp[i] %= mod;
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
int main(void){
        int w,h,x,y,r;
        scanf("%d",&w);
        scanf("%d",&h);
        scanf("%d",&x);
        scanf("%d",&y);
        scanf("%d",&r);
        if(x < r || y < r || w-x < r || h-y < r)
                puts("No");
        else
                puts("Yes");
        return 0;
}


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

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;
static const bool DEBUG = false;

int f(int b, int n) {
	if (n < b)return n;
	else return f(b, n / b) + n%b;
}

//約数を求める 未ソート
vector<int> divisor(int x) {
	vector<int> ret;
	int i;
	for (i = 1; i*i < x; i++) {
		if (x%i)continue;
		ret.emplace_back(i);
		ret.emplace_back(x / i);
	}
	if (i*i == x)ret.emplace_back(i);
	return ret;
}

signed main() {
	int n, s;
	cin >> n >> s;
	if (n == s) { cout << n + 1 << endl; return 0; }
	dump(1);
	rep(b, 2, (int)sqrt(n) + 2) {
		if (f(b, n) == s) {
			cout << b << endl;
			return 0;
		}
	}
	dump(2);
	vector<int> d = divisor(n - s);
	sort(all(d));
	dumpc(d);
	rep(i, 0, d.size()) {
		int b = d[i] + 1;
		if (b <= sqrt(n) + 1)continue;
		dump(b);
		dump(f(b, n));
		if (f(b, n) == s) {
			cout << b << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string a,b;
    cin>>a>>b;
    int tmp=stoi(a+b);
    if (ceil(sqrt(tmp))==float(sqrt(tmp))) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}


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

int N;
pair<long long, long long> tasks[200000];


int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        long long A, B;
        cin >> A >> B;
        tasks[i] = make_pair(B, A);
    }
    sort(tasks, tasks + N);

    long long time_taken = 0;
    bool possible = true;
    for(int i = 0; i < N; i++){
        time_taken += tasks[i].second;
        if(time_taken > tasks[i].first){
            possible = false;
        }
    }
    if(possible){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3328
#include<stdio.h>
int x[100010][2];
int ans[100010];
int n, a[3];
void f(int i,int p,int q){
	ans[i] = p;
	a[p]++;
	a[q]--;
}
int main(){
	scanf("%d%d%d%d",&n,a,a+1,a+2);
	for(int i = 0; i < n; i++){
		char s[3];
		scanf("%s",s);
		x[i][0] = s[0] - 'A';
		x[i][1] = s[1] - 'A';
	}
	for(int i = 0; i < n; i++){
		int p = x[i][0], q = x[i][1];
		if(!a[p]&&!a[q]){
			puts("No");
			return 0;
		}
		else if(!a[p])
            f(i,p,q);
		else if(!a[q])
            f(i,q,p);
		else{
			if(i != n - 1 && p == 3 - x[i + 1][0] - x[i + 1][1])
                f(i,q,p);
			else f(i,p,q);
		}
	}
	puts("Yes");
	for(int i = 0; i < n; i++)
        printf("%c\n",ans[i]+'A');
    return 0;
}


Measured memory_bytes: 2880
import bisect
s = input()
n = len(s)
dp = [[0 for i in range(26)] for j in range(n+1)]
flg = [0]*26
prt = []
for i in range(n-1,-1,-1):
  x = ord(s[i])-97
  for j in range(26):
    if j == x:
      dp[i][j] = n-i
      flg[x] = 1
    else:
      dp[i][j] = dp[i+1][j]
  if flg.count(1) == 26:
    prt.append(i)
    flg = [0]*26
ind = 0
ans = []
if not prt:
  for i in range(26):
    if dp[0][i] == 0:
      print(chr(i+97))
      exit()
prt = prt[::-1]
for i in range(26):
  if dp[prt[0]][i] == dp[0][i]:
    ans.append(i)
    break
else:
  ans.append(0)

pnt = prt[0]
flg = 0
while True:
  c = ans[-1]
  if not flg:
    pnt = n-dp[pnt][c]
  flg = 0
  prtp = bisect.bisect_right(prt,pnt)
  if prtp == len(prt):
    for i in range(26):
      if dp[pnt+1][i] == dp[-1][i]:
        ans.append(i)
        break
    else:
      ans.append(0)
    for od in ans:
      print(chr(od+97),end="")
    break
  npnt = prt[prtp]
  for i in range(26):
    if dp[pnt+1][i] == dp[npnt][i]:
      ans.append(i)
      break
  else:
    ans.append(0)
    flg = 1
  pnt = npnt


Measured memory_bytes: 125644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
ll n;
vl g[100100];
mint dp[100100][2];
void dfs(ll now,ll last=-1){
    dp[now][0]=dp[now][1]=1;
    for(auto next: g[now]){
        if(next==last)continue;
        dfs(next,now);
        dp[now][0]=dp[now][0]*(dp[next][0]+dp[next][1]);
        dp[now][1]=dp[now][1]*dp[next][0];
    }
    return;
}
int main(){
    cin>>n;
    rep(i,n-1){
        ll u,v;cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1);
    mint ans=dp[1][0]+dp[1][1];
    cout<<ans.x<<endl;
    return 0;
}

Measured memory_bytes: 17460
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    int n;
    cin >> n;
    set<VI> s;
    VI p(3);
    FOR(i, n) {
        cin >> p[0] >> p[1] >> p[2];
        SORT(p);
        s.insert(p);
    }
    cout << n - s.size() << endl;
}


Measured memory_bytes: 3260
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef pair<int, int> pi;
typedef vector<pair<int,int> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
int cnt[N]={};
bool f;
int main()
{
    int n,mac,a;
    cin>>n;
    cin>>mac;
    for(int i=1;i<n&&cin>>a;i++)
    {
        if(a-mac>0)
        {
            mac=a-1;
        }else if(a-mac==0)
        {
            mac=a;
        }else
        {
            puts("No");
            go;
        }
    }
   puts("Yes");
go;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <map>
using namespace std;

map<long long int, int> m;
vector<int> road[200005];
vector<int> adj[2][200005];
int clus[2][200005];
bool visited[2][200005];
int clusIdx;

void dfs(int type, int here){
	visited[type][here] = true;
	clus[type][here] = clusIdx;
	for(int i=0; i<adj[type][here].size(); ++i){
		int next = adj[type][here][i];
		if(!visited[type][next])
			dfs(type, next);
	}
}
int main(){
	int N, K, L, p, q;
	scanf("%d %d %d", &N, &K, &L);
	while(K--){
		scanf("%d %d", &p, &q);
		adj[0][p].push_back(q);
		adj[0][q].push_back(p);
	}
	while(L--){
		scanf("%d %d", &p, &q);
		adj[1][p].push_back(q);
		adj[1][q].push_back(p);
	}
	for(int j=0; j<2; ++j){
		clusIdx = 0;
		for(int i=1; i<=N; ++i){
			if(!visited[j][i]){
				++clusIdx;
				dfs(j, i);
			}
		}
	}
	for(int i=1; i<=N; ++i){
		long long int key = 1ll * clus[0][i] * 200005 + clus[1][i];
		if(m.find(key) == m.end())
			m[key] = 1;
		else
			++m[key];
	}
	for(int i=1; i<=N; ++i){
		long long int key = 1ll * clus[0][i] * 200005 + clus[1][i];
		printf("%d ", m[key]);
	}
}


Measured memory_bytes: 33152
def Print(str, d)
    a, b = d[1].to_i, d[2].to_i
    puts "#{str[a..b]}"
end

def Reverse(str, d)
    a, b = d[1].to_i, d[2].to_i
    str[a..b] = str[a..b].reverse
    #puts "rev : #{str}"
    str
end

def Replace(str, d)
    a, b = d[1].to_i, d[2].to_i
    str[a..b] = d[3]
    #puts "rep : #{str}"
    str
end

str = gets.chomp
gets.to_i.times {
    d = gets.chomp.split(" ")
    
    case d[0]
    when "print"
        Print(str, d)
    when "replace"
        str = Replace(str, d)
    when "reverse"
        str = Reverse(str, d)
    end
}

Measured memory_bytes: 8732
program main
integer :: k,n,ans
integer,allocatable :: a(:),dis(:)
read(*,*)k,n
allocate(a(n),dis(n))
read(*,*)a(1:n)
dis(n) = k + a(1) - a(n)
do i = 1,n-1
dis(i) = a(i+1) - a(i)
end do
ans = sum(dis) - maxval(dis)
write(*,*)ans
end program main

Measured memory_bytes: 2304
N, K = map(int, input().split())
P, C = [list(map(int, input().split())) for _ in range(2)]
ans = max(C)
for i in range(N):
    m = [0] * (N+1)
    k = i
    for j in range(N):
        m[j+1] = m[j] + C[k]
        k = P[k]-1
        if k == i:
            break
    if m[j+1] > 0:
        ans = max(ans, m[j+1] * (K//(j+1)-1) + max(m + [m[j+1] + m[k+1] for k in range(K%(j+1))]))
    else:
        ans = max(ans, max(m[1:min(j+1,K)+1]))
print(ans)


Measured memory_bytes: 95900
import math
n, d = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(n)]
count = 0
def dist(X0, X1):
    l = 0
    for x0, x1 in zip(X0, X1):
        l += (x0 - x1) ** 2
    return math.sqrt(l)
for i in range(n - 1):
    for j in range(i + 1, n):
        l = dist(X[i], X[j])
        if l.is_integer():
            count += 1
print(count)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        String s;
        if (n < 10) {
            switch (n) {
                case 3:
                    s = "bon";
                    break;
                case 0:
                case 1:
                case 6:
                case 8:
                    s ="pon";
                    break;
                default:
                    s = "hon";
                    break;
            }
        } else if (n >= 10 && n < 100) {
            switch (n % 10) {
                case 3:
                    s = "bon";
                    break;
                case 0:
                case 1:
                case 6:
                case 8:
                    s ="pon";
                    break;
                default:
                    s = "hon";
                    break;
            }
        } else {
            switch ((n % 100) % 10) {
                case 3:
                    s = "bon";
                    break;
                case 0:
                case 1:
                case 6:
                case 8:
                    s ="pon";
                    break;
                default:
                    s = "hon";
                    break;
            }
        }
        
        System.out.println(s);
    }
}

Measured memory_bytes: 35896
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //定番のn回繰り返しを省略
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int MAX_N = 300;


//ここから書き始める
int main(int argc, char const *argv[])
{
	int N,T;
	int c[MAX_N],t[MAX_N];


	cin >> N >> T;

	pair<int, int> kouho[N];
	rep(i,N)
	{
		cin >> c[i];
		cin >> t[i];
		kouho[i].first = c[i];
		kouho[i].second = t[i];

	}

	sort(kouho, kouho + N);
	rep(i, N)
	{
		if(kouho[i].second <= T)
		{
			cout << kouho[i].first << endl;
			break;
		}

		if(i == N - 1) cout << "TLE" << endl;
	}



    return 0;
}


Measured memory_bytes: 256
def f(n):
	out = 0
	i = 1
	while 2**i <= n*4:
		if i == 1:
			mod = n % 4
			if mod in [1,2]:
				out += 1
		else:
			mod = n % (2**i)
			if ((2**i) // 2 <= mod) and (mod % 2 == 0):
				out += (2**(i-1))
		i += 1

	return out

A, B = map(int, input().split())

untilB = f(B)
untilA_1 = f(A-1)

print(untilB ^ untilA_1)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.HCPCvirtual6
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Read();
            int[] cnts = new int[3];
            for(int i =0; i < 3; i++)
            {
                cnts[s[i] - 'a']++;
            }
            if (cnts[0] == 1 && cnts[1] == 1 && cnts[2] == 1)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    int n = Integer.parseInt(data[0]);
    int k = Integer.parseInt(data[1]);
    int result = 1;
    
    for(int i=0; i<n; i++){
      if (i == 0){
        result *= k;
      } else {
        result *= k-1;
      }
    }
    System.out.println(result);
  }
}


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

int main() {
  string v="aiueo";
  char c; cin >> c;
  for(char i:v) {
    if(c==i) {
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;
  return 0;
}


Measured memory_bytes: 256
#include"stdio.h"
#include"stdlib.h"
struct num
{
  int n;
  struct num *next;
};
int main()
{
  int n;
  int q;
  struct num *S;
  struct num *T;
  struct num *p;
  struct num *o;
  int i;
  int m;
  int C=0;
  S=(struct num*)malloc(sizeof(struct num));
  S->next=NULL;
  T=(struct num*)malloc(sizeof(struct num));
  T->next=NULL;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&m);
      for(p=S;p->next!=NULL;p=p->next)
        {
          if(p->next->n==m)break;
        }
      if(p->next==NULL)
        {
          p->next=(struct num*)malloc(sizeof(struct num));
          p->next->n=m;
          p->next->next=NULL;
        }
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&m);
      for(p=T;p->next!=NULL;p=p->next)
        {
          if(p->next->n==m)break;
        }
      if(p->next==NULL)
        {
          p->next=(struct num*)malloc(sizeof(struct num));
          p->next->n=m;
          p->next->next=NULL;
        }
    }
  for(p=S->next;p!=NULL;p=p->next)
    {
      for(o=T->next;o!=NULL;o=o->next)
        {
          if(p->n==o->n)
            {
              C++;
              break;
            }
        }
    }
  printf("%d\n",C);
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n;
int a[10] = {1,2,3,4,5,6,7,8,9,10};
int p[10],q[10];
bool check1(){
	for(int i = 0;i < n;i++) if(a[i] != p[i]) return 0;
	return 1;
}
bool check2(){
	for(int i = 0;i < n;i++) if(a[i] != q[i]) return 0;
	return 1;
}
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 0;i < n;i++) cin >> p[i];
	for(int i = 0;i < n;i++) cin >> q[i];
	int k1 = 0,k2 = 0;
	do{
		k1++;
		if(check1()){
			break;
		}
	}while(next_permutation(a,a+n));
	sort(a,a+n);
	do{
		k2++;
		if(check2()) break;
	}while(next_permutation(a,a+n));
	cout << abs(k1-k2) << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

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

int main()
{
    int N, A, B;

    cin >> N >> A >> B;

    if (N * A >= B)
    {
        cout << B << endl;
    }
    else if (N * A < B)
    {
        cout << N * A << endl;
    }
}

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

int main() {
	int k,n;
	cin>>k>>n;
	int a[n];
	int mx=0;
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	    if(i)
	    {
	        mx=max(mx,a[i]-a[i-1]);
	    }
	}
	mx=max(mx,k-a[n-1]+a[0]);
	int ans=k;
	cout<<ans-mx<<endl;
	return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
N = int(input())
edge = [[] for i in range(N)]
color = [-1 for i in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    u -= 1
    v -= 1
    w %= 2
    edge[u].append((v,w))
    edge[v].append((u,w))
search = [(e, 0) for e in edge[0]]
color[0] = 0
while len(search) > 0:
    e,c = search.pop()
    n,w = e[0],e[1]
    if color[n] >= 0:
        continue
    color[n] = (c + w) % 2
    search += [(e,color[n]) for e in edge[n]]

for i in range(N):
    print(color[i])

Measured memory_bytes: 35628
#5個のうち1番目の入力が0なら処理を終わる。
while True:
    line = []
    line.append(int(input()))
    if line[0] == 0:break

    #標準入力をしリストをセットにしたものを作る。
    for _ in range(4):line.append(int(input()))
    se = set(line)
    
    #全員が同じ数を出すか3種類の手が出たら5こ"3"を出力する。
    if len(se) == 1 or len(se) == 3:
        for _ in range(5):print("3")
        ""
    #じゃんけんの勝敗に基づき勝ちだったら"1"負けだったら"2"を出力する
    else:
        if sum(se) == 3:
            for i in line:
                if i == 1:print("1")
                else:print("2")
        if sum(se) == 4:
            for i in line:
                if i == 3:print("1")
                else:print("2")
        if sum(se) == 5:
            for i in line:
                if i == 2:print("1")
                else:print("2")


Measured memory_bytes: 5592
#include <iostream>
#include<stdio.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long int ll;
using namespace std;

ll rec(ll x) {
	if (x == 1) {
		return 1;
	}
	if (x == 0) {
		return 0;
	}
	else {
		return 1 + 2 * rec(x / 2);
	}
}

int main(void) {
	ll x;
	cin >> x;
	cout << rec(x) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3];
  for(int i=0;i<3;i++) cin>>a[i];
  sort(a,a+3);
  int sum=a[2]-a[1]+a[2]-a[0];
  if(sum%2==0) cout<<sum/2;
  else cout<<sum/2+2;

}


Measured memory_bytes: 256
N,K=map(int, input().split())
A=list(map(int, input().split()))

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
D=make_divisors(sum(A))
ans=1
for i in D:
  E=[]
  for j in A:
    d=j%i
    if d!=0:
      E.append(d)
  if len(E)==0:
    ans=i
  E=sorted(E)
  cn=0
  e=sum(E)
  left,right=e,0
  #print(i,E)
  for k in range(len(E)):
    left-=E[-1-k]
    right+=(i-E[-1-k])
    if left==right:
      if left<=K:
        ans=i
      break
print(ans)

Measured memory_bytes: 9220
#成績の差が最も小さい 2 人を選ぶプログラム

#1 行目には学生の人数 n (2 ≤ n ≤ 1000)
#2 行目には　 ai（1 ≤ i ≤ n）が i 番目の学生の成績
while True:
 #1行目nを読み込む
  n =int(input())
  #もしn==0ならbreak
  if n==0:
    break
  else :
     #配列a[i]を読み込む(1<=i<=n)
    a = sorted(list(map(int, input().strip().split())))
    
    a_sub = 1000000
    for i in range(n-1):
      if abs(a[i]-a[i+1]) < a_sub :
        a_sub =  abs(a[i]-a[i+1])
    print(a_sub)


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vl2;
const bool multiple_queries = false;
#define rep(i, n) for(ll i = 0; i < (n) ; ++i)
#define For(i, a, b) for(ll i = (a); i < (b) ; ++i)
#define revrep(i, n) for(ll i = (n) - 1; i >= 0 ; --i)
#define revFor(i, b, a) for(ll i = (b) - 1; i >= (a) ; --i)
#define all(v) v.begin(), v.end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(i) __builtin_popcountl((i))
#define substring(s, start, end) s.substr((start), (end) - (start) + 1)

void print(){cout;}
void println(){cout << endl;}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

template <class Head, class... Tail>
void println(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  println(forward<Tail>(tail)...);
}

template<typename T>
void read_vector(ll n, vector<T>& v, ll offset = 0){
  v.resize(n);
  rep(i, n){
    cin >> v[i];
    if (offset) v[i] += offset;
  }
}

void solve(){
  ll n, m, k;
  cin >> n >> m >> k;
  vl ca(n + 1, 0), cb(m + 1, 0);
  rep(i, n){
    ll a; cin >> a;
    ca[i + 1] = ca[i] + a;
  }
  rep(i, m){
    ll b; cin >> b;
    cb[i + 1] = cb[i] + b;
  }

  ll ans = 0;
  rep(i, n + 1){
    ll t = ca[i];
    if (t > k) break;
    // ub - 1 <= k < ub
    ll ub = upper_bound(all(cb), k - t) - cb.begin();
    ans = max(ans, i + ub - 1);
  }
  println(ans);
}

void test(ll num = 0, bool verbose = false){
  rep(i, max(1LL, num)){
    ll t = clock();
    if (verbose) cout << "\n#####" << " " << i + 1 << " " << "#####" << " " << "\n## Answer ##\n";
    solve();
    if (verbose) {cout << "\nElapsed Time:" << " " << 1000.0 * (clock() - t) / CLOCKS_PER_SEC << " " << "[ms]" << endl;}
  }
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  #ifdef _LOCAL
    test(6, true);
  #else
    ll t = 0;
    if (multiple_queries) cin >> t;
    test(t, false);
  #endif
  return 0;
}

Measured memory_bytes: 6340
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<long long int> s(n);
  for(long long int i=0; i<n; i++){
    cin>>s.at(i);
  }
  int q;
  cin>>q;
  vector<long long int> t(q);
  for(long long int i=0; i<q; i++){
    cin>>t.at(i);
  }

  sort(s.begin(),s.end());
  long long int ans=0;
  for(int i=0; i<q; i++){
    int key=t.at(i);
    int high=n-1;
    int low=0;
    bool found=false;
    while(high>=low){
      int mid=(high+low)/2;
      if(s.at(mid)==key){
        found=true;
        break;
      }else if(s.at(mid)>key){
        high=mid-1;
      }else if(s.at(mid)<key){
        low=mid+1;
      }
    }
    if(found){
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

int main()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> v(N);
  for(int i=0; i<N; i++){
    scanf("%lld",&v[i]);
  }
  sort(v.begin(),v.end());
  double ans = 1.0*(v[0]+v[1])/2;
  for (int i=2; i<N; i++) {
    ans = (ans+v[i])/2;
  }
  printf("%.10f\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7

using namespace std;

ll n;
string stn;

string tostr(ll x)
{
    string res="";
    string tmp = "0";

    while(x)
    {
        tmp[0] = x%10;
        x/=10;
        res+=x;
    }

    return res;
}

ll query(ll x)
{
    cout << "? " << x << "\n";
    cout.flush();

    char c='N';
    cin >> c;

    return (c=='Y');
}

ll EX(ll v,ll e)
{
    ll p = 1;

    rep(i,0,e)
        p*=v;
        return p;
}

int main()
{
    ios_base::sync_with_stdio(false);

    if(query(1000000000000))
    {
        ll low = 1;
        ll high = 11;
        ll digits = 12;

        while(low <= high)
        {
            ll mid = (low+high)/2;

            bool q = query(EX(10,mid)-1);

            if(q)
            {
                high=mid-1;
                digits=min(digits,mid);
            }
            else
            {
                low=mid+1;
            }
        }

        cout << "! "<<EX(10,digits-1) << "\n";
        cout.flush();
        return 0;
    }

    ll low = 1;
    ll high = 9;
    ll digits = 1;

    while(low <= high)
    {
        ll mid = (low+high)/2;

        bool q = query(EX(10,mid));

        if(q)
        {
            low = mid+1;
            digits = max(digits,mid+1);
        }
        else
        {
            high=mid-1;
        }
    }

    ll answer = 0;

    rep(i,0,digits-1)
    {
        low = 0;
        high = 9;
        ll d = 0;

        while(low <= high)
        {
            ll mid = (low+high)/2;

            bool q = query(answer*10+mid);

            if(q)
            {
                low=mid+1;
                d=max(d,mid);
            }
            else
            {
                high=mid-1;
            }
        }

        answer = answer*10+d;
    }

    low = 0;
    high = 9;
    ll d = 9;

    while(low <= high)
    {
        ll mid = (low+high)/2;

        bool q = query(answer*100+10*mid+0);

        if(q)
        {
            high=mid-1;
            d=min(d,mid);
        }
        else
        {
            low=mid+1;
        }
    }

    answer = answer*10+d;

    cout << "! " <<answer << "\n";
    cout.flush();

    return 0;
}



Measured memory_bytes: 596
from collections import defaultdict

n, x, y = map(int, input().split())
x -= 1
y -= 1

d = defaultdict(int)
for i in range(n-1):
    for j in range(i+1, n):
        path = min([j-i, abs(x-i)+abs(y-j)+1, abs(x-j)+abs(y-i)+1])
        d[path] += 1

for i in range(1, n):
    print(d[i])


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

int a,b,c;
char op;

int main(){
	cin>>a>>op>>b;
	c=(int)op;
	if(c==43){
	    cout<<a+b<<endl;
	}
	else if(c==45){
	    cout<<a-b<<endl;
	}
}


Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};


int main(){
    ll N,a;
    ll cnt[100005];
    llrep(i,100005){
        cnt[i]=0;
    }
    cin >> N;
    vector<ll> A;
    llrep(i,N){
        cin >> a;
        A.push_back(a);
        cnt[a]++;
    }
    sort(A.begin(), A.end());
    ll max=0;
    llrep(i,A.size()){
        ll max_candi=0;
        max_candi = cnt[A[i]] + cnt[A[i]+1] + cnt[A[i]+2];
        if (max_candi > max){
            max = max_candi;
            // cout << "i = " << i << " overwrite with " << max << endl;
        }
    }
    cout << max << endl;

    return 0;
}


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

int main(){
  int n,cnt=0;
  string s;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    if(s=="A")cnt++;
    else if(s=="Un")cnt--;
    if(cnt<0){
      break;
    }
  }
  if(cnt==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 3160
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long 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;}

int n,m;

int main(){
    cin >> n >> m;
    vector<vector<int>> e(n,vector<int>(n,1e6));//infで初期化
    vector<vector<int>> inv(n,vector<int>(n,1e6));
    vector<int> a(m);
    vector<int> b(m);
    vector<int> c(m);
    REP(i,m){
        cin >> a[i] >> b[i] >> c[i];
        --a[i];
        --b[i];
        e[a[i]][b[i]] = c[i];
        e[b[i]][a[i]] = c[i];//無向グラフ
        inv[a[i]][b[i]]=i;
        inv[b[i]][a[i]]=i;
        
    }
    REP(i,n){
        e[i][i]=0;
    }
    
    vector<vector<int>> next(n,vector<int>(n,0));
    vector<int> used(m,0);
    REP(i,n){
        REP(j,n){
            next[i][j] = j;
        }
    }
    //ワーシャルフロイド法
    REP(k,n){
        REP(i,n){
            REP(j,n){
                if(chmin(e[i][j],e[i][k]+e[k][j])){
                    //e[i][j]=e[i][k]+e[k][j];
                    next[i][j]=next[i][k];
                }
            }
        }
    }
    //経路復元
    REP(i,n){
        REP(j,n){
            int pre=-1;
            for(int cur=i;cur!=j;cur=next[cur][j]){
                if(pre>=0){
                    used[inv[pre][cur]]=1;
                }
                pre = cur;
            }
            if(pre>=0){
                used[inv[pre][j]]=1;
            }
        }
    }
    int res = 0;
    REP(i,m){
        if(!used[i])res++;
    }
    put(res);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
 
int main(){
  int n,m;
  cin>>n>>m;
  int mn=n,mx=1;
  rep(i,m){
    int l,r;
    cin>>l>>r;
    mn=min(mn,r);
    mx=max(mx,l);
  }
  int ans=mn-mx+1;
  if(ans<=0)ans=0;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int n;
bool vis[310][310];
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  vv<vii> a(n, vii(n));
  rep(i, 0, n) rep(j, 0, n) cin >> a[i][j];
  bool flag = false;
  rep(i, 0, n) rep(j, 0, n) rep(k, 0, n) {
    if (a[i][j] > a[i][k] + a[k][j]) {
      cout << -1 << endl;
      return 0;
    }
    if (a[i][j] == a[i][k] + a[k][j] && !(k == j || k == i)) {
      vis[i][j] = true;
      a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
    }
  }
  int ans = 0;
  rep(i, 0, n) {
    rep(j, i+1, n) {
      if (!vis[i][j]) ans += a[i][j];
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        String[] words = new String[N];
        for(int i=0; i<N; i++){
            words[i] = scan.next();
        }
        scan.close();

        int ac_cnt=0;
        int wa_cnt=0;
        int tle_cnt=0;
        int re_cnt=0;

        for(int i=0; i<N; i++){
            switch(words[i]){
                case "AC":
                    ac_cnt++;
                    break;
                case "WA":
                    wa_cnt++;
                    break;
                case "TLE":
                    tle_cnt++;
                    break;
                case "RE":
                    re_cnt++;
                    break;
            }
        }
        System.out.println("AC x " + ac_cnt);
        System.out.println("WA x " + wa_cnt);
        System.out.println("TLE x " + tle_cnt);
        System.out.println("RE x " + re_cnt);
    }
}

Measured memory_bytes: 65180
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main implements Runnable
{
    static int dx[]={-1,0,1,0};
    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        if(n<10) {
        	ret(n);
        }
        
        int d[][]=new int[10][10];
        
        for (int i = 1,t,s; i <= n ; i++) {
        	t=i;s=i%10;
        	while(t>=10)t/=10;
        	d[t][s]++;
//        	db(i,s,t);
		}
        long r=0;
        for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
//				db(i,j,d[i][j]);
				r+=(long)d[i][j]*d[j][i];
			}
		}

        out.println(r);
     	out.flush();
    }
        
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}


class P implements Comparable<P>{
    int x,y;
    P(int x,int y) {
    	this.x=x;
    	this.y=y;
    }

    public int compareTo(P p){
        return y-p.y;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 23632
#define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<algorithm>

#define N_MAX 30

int main(){
	while (1){
		int n, dp[N_MAX + 1];
		scanf("%d", &n);
		if (n == 0)
			break;
		std::fill(dp, dp + n + 1, 0);
		dp[0] = 1;
		dp[1] = 1;
		dp[2] = 2;
		for (int i = 3; i <= n; ++i){
			for (int j = 1; j <= 3; ++j){
				if (j <= i){
					dp[i] += dp[i - j];
				}
			}
		}
		int day = (dp[n] % 3650 == 0) ? dp[n] / 3650 : dp[n] / 3650 + 1;
		printf("%d\n", day);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}

int main(){
	int n;
	cin >> n;
	hei(int) a(n);
	rep(i, 0, n)cin >> a[i];
	int m;
	cin >> m;
	hei(int)b(m);
	rep(i, 0, m)cin >> b[i];
	sort(a.begin(), a.end());
	int x = 0;
	sort(b.begin(), b.end());
	rep(i, 0, n) {
		if (x == m)break;
		if (a[i] == b[x])x++;
	}
	YES(x==m)
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int dp[202020][4];

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

	string s;
	cin >> s;
	int N = s.size();
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= 3; j++) {
			if (i - j < 0)continue;
			for (int k = 0; k <= 3; k++) {
				if (k != j)dp[i][j] = max(dp[i-j][k]+1,dp[i][j]);
				else if (i - 2 * j < 0)continue;
				else if (s.substr(i-2*j,j) != s.substr(i-j,j))dp[i][j] = max(dp[i - j][k]+1, dp[i][j]);
			}
		}
	}
	puts(max(dp[N][1],max(dp[N][2],dp[N][3])));

	return 0;
}



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

int main(){
    int N, R=0;
    string s, ans = "No";	
    cin >> N;
    cin >> s;

    for(int i = 0; s[i] != '\0'; i++) {
	if(s[i] == 'R')
	    R++;
	else
	    R--;
    }
    if(R>0)
	ans = "Yes";
    
    cout << ans << endl; 
	      
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
  string str;
  int a[4],e,f;
  cin >> str;
  int num=atoi(str.c_str());
  a[3]=num%10;
  a[2]=(num%100-a[0])/10;
  a[1]=(num%1000-a[0]-a[1])/100;
  a[0]=(num-a[0]-a[1]-a[2])/1000;
  e=a[0]+a[1]+a[2]+a[3];
  f=(e-7)/2;
  if(f==a[1]){
    cout << a[0] << "-" << a[1] << "+" << a[2] << "+" << a[3] << "=7" << endl;
  }
  else if(f==a[2]){
    cout << a[0] << "+" << a[1] << "-" << a[2] << "+" << a[3] << "=7" << endl;
  }
  else if(f==a[3]){
    cout << a[0] << "+" << a[1] << "+" << a[2] << "-" << a[3] << "=7" << endl;
  }
  else if(f==a[1]+a[2]){
    cout << a[0] << "-" << a[1] << "-" << a[2] << "+" << a[3] << "=7" << endl;
  }
  else if(f==a[1]+a[3]){
    cout << a[0] << "-" << a[1] << "+" << a[2] << "-" << a[3] << "=7" << endl;
  }
  else if(f==a[2]+a[3]){
    cout << a[0] << "+" << a[1] << "-" << a[2] << "-" << a[3] << "=7" << endl;
  }
  else if(f==a[1]+a[2]+a[3]){
    cout << a[0] << "-" << a[1] << "-" << a[2] << "-" << a[3] << "=7" << endl;
  }
  else{
    cout << a[0] << "+" << a[1] << "+" << a[2] << "+" << a[3] << "=7" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        //入力を保持する
        var S = Console.ReadLine();
        
        if (S.Equals("ABC"))
        {
            Console.WriteLine("ARC");
            return;
        }
        if (S.Equals("ARC"))
        {
            Console.WriteLine("ABC");
            return;
        }
    }
}



Measured memory_bytes: 25748