akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sqr(x) (x) * (x)

using namespace std;
using namespace __gnu_pbds;

mt19937_64 gen(time(0));

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//const int mod = 1e9 + 7;
const ll inf = 1e18 + 6555;
const int infp = 1e9 + 3422;
const int maxn = 17;

int x[maxn], y[maxn], p[maxn];
ll ans[maxn];
int vert[maxn], gor[maxn];
int uk1 = 0, uk2 = 0;

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif
    int n;
    cin >> n;
    for(int i = 0; i <= n; ++i)
        ans[i] = inf;
    for(int i = 0; i < n; ++i)
        cin >> x[i] >> y[i] >> p[i];

    int gg = 1;
    for(int i = 0; i < n; ++i)
        gg *= 3;

    for(int msk = 0; msk < gg; ++msk)
    {
        uk1 = 0;
        uk2 = 0;
        int m = msk;
        int ind = 0;
        while(m > 0 && uk1 + uk2 <= n)
        {
            if (m % 3 == 1) gor[uk1++] = x[ind];
            if (m % 3 == 2) vert[uk2++] = y[ind];
            m /= 3;
            ++ind;
        }
        int cnt = uk1 + uk2;
        gor[uk1++] = 0;
        vert[uk2++] = 0;
        ll sum = 0;
        for(int i = 0; i < n; ++i)
        {
            int mn = infp;
            for(int j = 0; j < uk1; ++j)
                mn = min(mn, abs(x[i] - gor[j]));
            for(int j = 0; j < uk2; ++j)
                mn = min(mn, abs(y[i] - vert[j]));
            sum += 1ll * mn * p[i];
        }
        ans[cnt] = min(ans[cnt], sum);
    }

    for(int i = 1; i <= n; ++i)
        ans[i] = min(ans[i], ans[i - 1]);
    for(int i = 0; i <= n; ++i)
        cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
	int n,a[100],i; 
	scanf ("%d",&n);
	
	for (i=0;i<n;i++) {
		scanf ("%d",&a[i]);
	}
	
	for (i=n-1;i>=0;i--) {
		printf ("%d",a[i]);
		if(i>0){
		printf (" ");
		}
		if (i==0){
			printf ("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 2684
import bisect
N, M, K = map(int, input().split())
A = [0]+[int(i) for i in input().split()]
B = [int(i) for i in input().split()]

for i in range(1, N+1):
    A[i] = A[i-1]+A[i]

for i in range(1, M):
    B[i] = B[i-1]+B[i]


ans = 0
for i in range(N+1):
    if A[i] <= K:
        ans = max(ans, i+bisect.bisect_right(B, K-A[i]))
print(ans)


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

int shinhou(int n){
  int sum=0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  return sum;
}

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  int total=0;
  for(int i=1;i<=N;i++){
    int sum=shinhou(i);
    if(A<=sum&&sum<=B){
      total+=i;
    }
  }
 cout<<total<<endl;
}
  
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  int h,w;
  cin >> h >> w;
  string s;
  vector<int> bu(128,0);
  REP(i,h) {
    cin >> s;
    REP(j,w) bu[s[j]]++;
  }
  int buf2=0;
  if(h%2) buf2+= w/2;
  if(w%2) buf2+= h/2;
  int buf1=0;
  if(h%2 && w%2) buf1++;
  for(int co: bu){
    if(co%2) buf1--;
    if((co/2)%2) buf2--;
  }
  bool flag = (buf1>=0) && (buf2>=0);
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

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

int main() {
	string s;
	cin >> s;
	deque<char> ans;
	for (char c : s)ans.push_back(c);
	bool rev = false;
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		int t;
		cin >> t;
		if (t == 1) {
			rev = !rev;
		}
		else {
			int f;
			char c;
			cin >> f >> c;
			if (rev) f = 3 - f;
			if (f == 1) {
				ans.push_front(c);
			}
			else {
				ans.push_back(c);
			}
		}
	}

	if (rev)reverse(ans.begin(), ans.end());
	for (char i : ans) {
		cout << i;
	}cout << endl;

	return 0;
}

Measured memory_bytes: 896
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	int pn = 1;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); }
		A = ct - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
	else {
		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }
		A = ct - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
}
void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

//なんて工夫のない提出

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


	int N = getint();
	ll K = 0;
	while ((ct = *ci++) >= '0') K = K * 10 + ct - '0';

	int sei[200000], fu[200000];
	int seik = 0, fuk = 0;
	int zero = 0;
	rep(i, N) {
		int a = getint();
		if (a > 0) sei[seik++] = a;
		else if (a < 0) fu[fuk++] = -a;
		else zero++;
	}
	pakuri_sort(seik, sei);
	pakuri_sort(fuk, fu);
	ll k0 = ll(seik) * fuk + ll(zero) * (zero - 1) / 2 + ll(zero) * (N - zero);

	ll L = -1000000000000000001, R = 1000000000000000000;
	while (L + 1 < R) {
		ll M = (L + R) / 2;
		ll k = 0;
		if (M >= 0) {
			k += k0;
			int j = seik - 1;
			rep(i, seik) {
				while (j > i && ll(sei[i]) * sei[j] > M) j--;
				if (i == j) break;
				k += j - i;
			}
			j = fuk - 1;
			rep(i, fuk) {
				while (j > i && ll(fu[i]) * fu[j] > M) j--;
				if (i == j) break;
				k += j - i;
			}
		}
		else {
			int j = 0;
			rep(i, seik) {
				while (j < fuk && ll(sei[i]) * fu[fuk - j - 1] >= -M) j++;
				if (j == fuk) { k += ll(seik - i) * fuk; break; }
				k += j;
			}
		}
		if (k >= K) R = M;
		else L = M;
	}

	printf("%lld\n", R);

	Would you please return 0;
}

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-

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

mod = []
for i in range(max(B,C)):
    res = A * i % B
    if res == C:
        ans = "YES"
        break
    if res in mod:
        ans = "NO"
        break
    mod.append(res)

print(ans)

Measured memory_bytes: 8928
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
typedef long double ld;
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a) for (int i = 0; i < (a).size(); ++i) cin >> (a)[i]
#define out(a) for (auto qwe : a) cout << qwe << " "

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;

const int mxn = 300;

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

    int n, w;
    cin >> n >> w;

    vpii a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].ff >> a[i].ss;
    }

    vii dp(n, vi(100001, INF64));

    dp[0][0] = 0;
    dp[0][a[0].ss] = a[0].ff;

    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= 100001; ++j) {
            if (dp[i - 1][j] != -1)
                dp[i][j] = dp[i - 1][j];

            if (j >= a[i].ss && dp[i - 1][j - a[i].ss] != -1)
                dp[i][j] = min(dp[i][j], dp[i - 1][j - a[i].ss] + a[i].ff);
        }
    }

    for (int k = 100000; k >= 0; --k) {
        if (dp[n - 1][k] <= w) {
            cout << k;
            break;
        }
    }
}

Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	char now=s[0];
	ll bet=0,ha=0;
	ll cnt=0;
	for(ll i=1;i<n;i++){
		if(s[i-1]==s[i]){
			cnt++;
		}
		if(now==s[i]){
			continue;
		}
		now=s[i];
		if(ha==0){
			ha++;
		}
		else{
			ha=0;
			bet++;
		}
	}
	cnt+=min(k*2,bet*2);
	k=max(ll(0),k-bet);
	cnt+=min(k,ha);
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 512
import heapq
N,M=map(int,input().split())
l=[[] for i in range(M+1)]
#print(l)
for i in range(N):
  a,b=map(int,input().split())
  if a<=M:
  #print(a,b)
  #print(l[a])
    l[a].append(b)
#print(l)
ans=0
que=[]
for i in range(1,M+1):
  for j in l[i]:
    heapq.heappush(que,-j)
  if len(que)>0:
    #print(i,que)
    ans-=heapq.heappop(que)
    
    
print(ans)

Measured memory_bytes: 18384
import sys
from collections import Counter as ct
import itertools
fastinput = sys.stdin.readline
N=int(input())
name=[fastinput() for i in range(N)]
MARCH=[sum([n.startswith(k) for n in name]) for k in ("MARCH")]
ans=0
for a,b,c in itertools.combinations([1,2,3,4,0],3):
    ans += MARCH[a]*MARCH[b]*MARCH[c]
print(ans)

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

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

	i64 ans = 0;
	for(int i = 1; i <= n; i++) {
		if(!(i % 3)) continue;
		if(!(i % 5)) continue;
		ans += i;
	}

	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3824
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>
#include<set>

#include <memory>


using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;

ll MOD = 1000000007;


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

	for (ll i = sqrt(N) + 1; i > 0; --i)
	{
		if (N%i == 0)
		{
			cout << i + N / i - 2 << endl;
			return 0;
		}
	}

	return 0;
}

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

using namespace std;

#define N 123456*2
bool tab[N+1];

int main(){
	
	for(long i=1;i<N+1;i++) tab[i]=true;
	tab[1]=false;
	for(long i=2;i<N+1;i++){
		if(tab[i]){
			for(long j=2;i*j<N+1;j++)tab[i*j]=false;
		}
	}
	
	while(1){
		
		long num;
		cin >> num ;
		
		if(num==0) break;
		
		int ans=0;
		
		for(long i=num+1;i<=2*num&&i<N+1;i++){
			if(tab[i]) ans++;
		}
		cout << ans << endl;
		
	}	
	return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

string S[410];
//! すでに通ったますか？
bool M[405][405];

int x[4] = {1, 0, -1, 0};
int y[4] = {0, 1, 0, -1};

int main()
{
    int H, W;
    cin >> H >> W;
    REP(i, H)
    {
        cin >> S[i];
    }

    ll sum = 0;
    REP(h, H)
    {
        REP(w, W)
        {
            if (M[h][w])
                continue;

            M[h][w] = true;
            ll wn = 0, bn = 0;
            queue<pll> q;
            q.push(pll(h, w));
            while (!q.empty())
            {
                pll t = q.front();
                q.pop();
                if (S[t.first][t.second] == '.')
                    wn++;
                else
                    bn++;

                REP(i, 4)
                {
                    int nh = t.first + x[i], nw = t.second + y[i];
                    if (nh < 0 || nh >= H || nw < 0 || nw >= W)
                        continue;
                    if (M[nh][nw])
                        continue;
                    if (S[t.first][t.second] == S[nh][nw])
                        continue;
                    q.push(pll(nh, nw));
                    M[nh][nw] = true;
                }
            }

            sum += wn * bn;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<char> c(N);
    bool Rnumber = false, Wnumber = false;
    for (int i = 0; i < N; i++)
    {
        cin >> c[i];
        if (c[i] == 'R')
        {
            Rnumber = true;
        }
        else if (c[i] == 'W')
        {
            Wnumber = true;
        }
    }
    if (Rnumber == false || Wnumber == false)
    {
        cout << 0 << endl;
        return 0;
    }
    int count = 0;
    int k = N - 1;
    for (int i = 0; i < N; i++)
    {
        if (c[i] == 'W')
        {
            for (int j = k; j >= 0; j--)
            {
                if (c[j] == 'R')
                {
                    if (i >= j)
                    {
                        cout << count << endl;
                        return 0;
                    }
                    c[i] = 'R';
                    c[j] = 'W';
                    count++;
                    k--;
                    break;
                }
                k--;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		
        Scanner sc= new Scanner(System.in);
        
        int S=sc.nextInt();
        
        int h=S/3600;
        int m=(S-(h*3600))/60;
        int s=(S-(h*3600))%60;
        
        
        System.out.println(h+":"+m+":"+s);
}

}


Measured memory_bytes: 26348
#include "bits/stdc++.h"
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e5+100;
bool comp[N+7]={1,1};
vector<int>prime;
#define ll long long

void sieve() {
    for(int i=4;i<N;i+=2) comp[i]=1;
    for(int i=3;i<=N/i;i+=2) {
        if(!comp[i]) {
            for(int j=i*i;j<N;j+=2*i) comp[j]=1;
        }
    }
    prime.emplace_back(2);
    for(int i=3;i<N;i+=2) {
        if(!comp[i]) prime.emplace_back(i);
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    sieve();
    int a,b,n,T,cas=0;
    cin>>n;
    for(int i=n;;++i) {
        if(!comp[i]) return cout<<i, 0;
    }
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>

using namespace std;
int T[1000000] = {-1};
int main(void)
{
	int i,j;
	for(i = 1;i<=9;i++)
		for(j = 1;j<=9;j++)
			if( T[i*j] != 1 )
				T[i*j] = 1;
	int N;
	cin >> N;
	if(T[N]==1)
		printf("Yes\n");
	else 
		printf("No\n");		
	return 0;
}

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

int main(){
  int n, k, count, ans;
  cin >> n >> k;
  
  count = 0;
  ans = 1;
  while(count < n){
    if(ans < k){
      ans *= 2;
    }else{
      ans += k;
    }
    count ++;
  }
  
  cout << ans << endl;
}

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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)

//MIN-MAX
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))

//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }



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

        if(n==k){
            ans=0;

        }
        else if(n>k)
        {
            n= n- (n/k)*k;
            set<ll>se;
            ans=n;
            se.insert(n);
            while(1)
            {
                n= abs(n-k);
                ans=min(n,ans);
                if(se.find(n)==se.end())
                    se.insert(n);
                else
                    break;
            }

        }
        else
        {
            set<ll>se;
            ans=n;
            se.insert(n);
            while(1)
            {
                n= abs(n-k);
                ans=min(n,ans);
                if(se.find(n)==se.end())
                    se.insert(n);
                else
                    break;
            }

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













Measured memory_bytes: 256
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s;
	cin>>s;
	int check[s.size()];
	rep(i,s.size()){
		if(s[i]=='A')check[i]=-1;
		else if(s[i]=='Z')check[i]=1;
		else check[i]=0;
	}
	int f=s.size(),l=0;
	rep(i,s.size())if(check[i]==-1){f=i;break;}
	for(int i=s.size()-1;i>=0;i--)if(check[i]==1){l=i;break;}
	cout<<l-f+1<<endl;
	return 0;
}

Measured memory_bytes: 1412
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt (string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin();i!=(c).end();++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS=1e-10;
const double PI=acos(-1.0);


const int UNDEF=INT_MAX;
int main(){
	int p,s;
	int cc=0;
	while(cin>>p,p){
		if(cc){
			cout<<endl<<endl;
		}
		cin>>s;
		vvi cells(p+1,vi(s+1,UNDEF));
		vector<pii> undefs;
		REP(i,p+1){
			REP(j,s+1){
				string s;
				cin>>s;
				if(s=="?"){
					cells[i][j]=UNDEF;
					undefs.push_back(make_pair(i,j));
				}else{
					cells[i][j]=toInt(s);
				}
			}
		}

		vi ans(undefs.size());

		bool flag=true;
		vi used(undefs.size(),0);
		while(flag){
			flag=false;
			REP(kk,undefs.size()){
				if(used[kk])continue;
				pii u=undefs[kk];

				{
				int sum2=0;
				REP(i,s){
					if(cells[u.first][i]==UNDEF){
						if(i!=u.second){
							goto ng_s;
						}
					}else{
						sum2+=cells[u.first][i];
					}
				}
				ans[kk]=(cells[u.first][s]-sum2);
				cells[u.first][u.second]=ans[kk];
				used[kk]=1;
				flag=true;
				goto ng_p;
				}
ng_s:;
	 {
				int sum1=0;
				REP(i,p){
					if(cells[i][u.second]==UNDEF){
						if(i!=u.first){
							goto ng_p;
						}
					}else{
						sum1+=cells[i][u.second];
					}
				}
				ans[kk]=(cells[p][u.second]-sum1);
				cells[u.first][u.second]=ans[kk];
				used[kk]=1;
				flag=true;
	 }
	ng_p:;
			}
		}

		if(find(ALL(used),0)==used.end()){
			REP(i,ans.size()){
				if(i==ans.size()-1){
					cout<<ans[i];
				}else{
					cout<<ans[i]<<endl;
				}
			}
		}else{
			cout<<"NO";
		}
		cc++;
	}
	cout<<endl;

}

Measured memory_bytes: 0
input_arr = input().split()
button_nums = []

for i in input_arr:
    button_nums.append(int(i))

results = []

results.append(button_nums[0] + (button_nums[0] - 1))
results.append(button_nums[1] + (button_nums[1] - 1))
results.append(button_nums[0] + button_nums[1])

print(max(results))


Measured memory_bytes: 3060
#include<bits/stdc++.h> 
using namespace std; 
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = a; i <b; i++)
#define forn(i,a,b) for (int i = a; i >b; i--)
#define mod 1000000007
#define MAX 50
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


long long int fact(long long int n)
{
  if(n==0 || n==1)
  return 1;
  else
  return (n*fact(n-1)%mod)%mod;
}

int prime(long long int n)
{
  for(int i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      return 0;
    }
  }
  return 1;
}

long long int gcd(long long int a,long long int b)
{
  if(a==0)
  return b;
  else
  return gcd(b%a,a);
}

long long int lcm(long long a,long long b)
{
    return (a*b)/gcd(a,b);
}

int check_palin(string s)
{
  string str=s;
  reverse(str.begin(),str.end());
  if(str==s)
  return 1;
  else 
  return 0;
}

int check_divisors(map<int,int> &mp,int key)
{
  
  if(mp[key]>1)
  return 0;
  else
  {
    for(int i=2;i<=sqrt(key);i++)
    {
      if(key%i==0)
      {
       // cout<<i<<" "<<key/i<<" ";
        if(mp[i]>0 || mp[key/i]>0)
        return 0;
      }
    }
  }
return 1;
} 


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
            long long int z=0,n,m,ans=0;
            
              cin>>n;
              vector<int> a;
              map<int,int> mp;
              
              for(int i=0;i<n;i++)
              {
                cin>>m;
                mp[m]++;
                a.push_back(m);
              }
              if(mp[1]==0)
              {
                for(int i=0;i<n;i++)
                {
                  //cout<<a[i]<<" ";
                  ans+=check_divisors(mp,a[i]);
                }
              }
              else if(mp[1]==1)
              ans=1;
              else
              ans=0;

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

Measured memory_bytes: 32816
import sys

MOD = 998244353


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def main():
    input = sys.stdin.buffer.readline
    n, k = map(int, input().split())
    lr = [tuple(map(int, input().split())) for _ in range(k)]
    dp = Bit(n)
    dp.add(1, 1)
    for i in range(2, n + 1):
        for l, r in lr:
            if i - l < 1:
                continue
            if i - r < 2:
                dp.add(i, dp.sum(i - l) % MOD)
            else:
                dp.add(i, (dp.sum(i - l) - dp.sum(i - r - 1)) % MOD)
    print((dp.sum(n) - dp.sum(n - 1)) % MOD)


if __name__ == "__main__":
    main()


Measured memory_bytes: 75596
def set(n):
    #n = int(input())
    #if n == 0:
     #   return False
    lis = []
    for i in range(n):
        lis.append(len(input()))

    return lis

def solve(lis , n):
    ans = 0
    while ans < 5:
        ans += lis[n]
        n +=1
    #    print(n)
    if not(ans == 5):
        return False

    ans = 0
    while ans < 7:
        ans += lis[n]
        n +=1
   #     print(n)
    if not(ans == 7):
        return False


    ans = 0
    while ans < 5:
        ans += lis[n]
        n +=1
  #      print(n)
    if not(ans == 5):
        return False

    ans = 0
    while ans < 7:
        ans += lis[n]
        n +=1
 #       print(n)
    if not(ans == 7):
        return False

    ans = 0
    while ans < 7:
        ans += lis[n]
        n +=1
#        print(n)
    if not(ans == 7):
        return False
    return True

#main
while True:
    n = int(input())
    if not(n ==0):
        lis = set(n)
    for i in range(n):
        if solve(lis,i):
            print(i+1)
            break

        
    else:
        break



Measured memory_bytes: 5612
#include <stdio.h>
#include<string.h>
int main()
{
    int a[5];
    int i;
    for(i=0; i<5; i++)
        scanf("%d",&a[i]);
    int s=10;
    int j;
    for(i=0; i<5; i++)
        if(s>(a[i]%10)&&(a[i]%10)!=0)
        {
            s=a[i]%10;
            j=i;
        }
    int num=0;
    for(i=0; i<5; i++)
    {
        if(i==j)
        {
            num+=a[j];
            continue;
        }
        while(a[i]%10!=0)
            a[i]++;
        num+=a[i];
    }
    printf("%d",num);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  int n,x;
  cin >> n >> x;
  vector <int> a;
  REP(i,n){
    int b;
    cin >> b;
    a.pb(b);
  }
  int sum = n;
  sort(a.begin(),a.end());
  REP(i,n){
    x -= a[i];
  }
  sum += x/a[0];
  cout << sum << endl;
  return 0;
}


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n;
    cin>>n;
    cout<<abs(1000-(n%1000))%1000<<"\n";
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3604
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

R,C,K=map(int,input().split())
V=[[0]*C for _ in range(R)]
for i in range(K):
    r,c,v=map(int,input().split())
    r-=1
    c-=1
    V[r][c]=v
dp=[[0]*4 for _ in range(C)]
prev_dp=[[0]*4 for _ in range(C)]
for y in range(R):
    for x in range(C):
        for i in range(2,-1,-1):
            dp[x][i+1]=max(dp[x][i+1],dp[x][i]+V[y][x])
        if x<C-1:
            for i in range(3,-1,-1):
                dp[x+1][i]=max(dp[x+1][i],dp[x][i])
    if y+1<R:
        prev_dp=dp
        dp=[[0]*4 for _ in range(C)]
        for x in range(C):
            dp[x][0]=max(prev_dp[x])
print(max(dp[-1]))

Measured memory_bytes: 209028
#include<bits/stdc++.h> 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vv = vector<vector<int>>;
using P = pair<int,int>;

double func( double x1,double x2,double y1,double y2 ){
  return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

double kaijo( int n ){
  if( n == 0 ) return 1;
  return n*kaijo(n-1);
}

int main(){
  int n;
  cin >> n;
  vector<pair<double,double>> xy(n);
  rep(i,n) cin >> xy.at(i).first >> xy.at(i).second;
  double sum=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      sum += func(xy.at(i).first,xy.at(j).first,xy.at(i).second,xy.at(j).second);
    }
  }
 
  printf("%.9lf\n",sum*( 2*n - 2)*kaijo(n-2)/kaijo(n) );
  return 0;
}


Measured memory_bytes: 256
import itertools
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    ans=0
    n=INT()
    A=[]
    for i in range(n):
        a=INT()
        A.append([])
        for k in range(a):
            x,y=INTM()
            x-=1
            A[i].append([x,y])

    #print(A)

    for i in itertools.product([0,1], repeat=n):
        #print(str(sum(i))+'aaaa')
        flg=True
        for k in range(n):
            if i[k]==1:
                for j in A[k]:
                    if i[j[0]]!=j[1]:
                        flg=False
                        break
        
        if flg:
            ans=max(ans,sum(i))

    print(ans)


if __name__=='__main__':
    do()

Measured memory_bytes: 9192
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#pragma gcc target ("avx2")
#pragma gcc optimization ("Ofast")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<ll> a(n);
	map<ll, ll> mp;
	rep(i, n) {
		scanf("%lld", &a[i]);
		++mp[a[i]];
	}
	ll sum = accumulate(all(a), 0LL);
	int q;
	scanf("%d", &q);
	while (q--) {
		ll b, c;
		scanf("%lld%lld", &b, &c);
		sum += (c - b) * mp[b];
		mp[c] += mp[b];
		mp[b] = 0;
		printf("%lld\n", sum);
	}

	Please AC;
}

Measured memory_bytes: 10300
N = int(input())
s = input()

def next(p, c, s):
    if p == 'S' and c == 'S':
        return 'S' if s == 'o' else 'W'
    elif p == 'S' and c == 'W':
        return 'W' if s == 'o' else 'S'
    elif p == 'W' and c == 'S':
        return 'W' if s == 'o' else 'S'
    elif p == 'W' and c == 'W':
        return 'S' if s == 'o' else 'W'
    else:
        return None

flag = False
for p, c in [('S', 'S'), ('S', 'W'), ('W', 'S'), ('W', 'W')]:
    r = p + c
    for i in range(1, N-1):
        r += next(r[-2], r[-1], s[i])

    if next(r[-2], r[-1], s[N-1]) == r[0] and next(r[-1], r[0], s[0]) == r[1]:
        flag = True
        print(r)
        break

if not flag:
    print(-1)


Measured memory_bytes: 3444
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
	int N,K;
	cin >> N;
	std::vector<int> d(N);
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	std::sort(d.begin(),d.end());
	//cout << d[N/2-1] << endl;
	//cout << d[N/2] << endl;
	if (N%2==0) {
		K = d[N/2] - d[N/2-1];
	}
	else{
		K = 0;
	}
	cout << K << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int d; cin>>d;
    if(d==22)cout<<"Christmas Eve Eve Eve"<<endl;
    if(d==23)cout<<"Christmas Eve Eve"<<endl;
    if(d==24)cout<<"Christmas Eve"<<endl;
    if(d==25)cout<<"Christmas"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;
    if (S[0] == S[1] && S[1] == S[2])
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}

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

const int N = 5005;
int n, k;
char s[N];

int main() {
	cin >> n >> k >> s + 1;
	char a = *min_element(s + 1, s + 1 + n);
	int L = 0;
	for (int i = 1, j; i <= n; )
		if (s[i] == a) {
			for (j = i; j <= n && s[j] == a; ++j);
			L = max(L, j - i);
			i = j;
		} else ++i;
	if (L << min(15, k - 1) >= n) {
		for (int i = 1; i <= n; ++i) cout << a;
		cout << endl;
		return 0;
	}
	string ans;
	for (int i = 1, j; i <= n; )
		if (s[i] == a) {
			for (j = i; j <= n && s[j] == a; ++j);
			if (j - i == L) {
				string now;
				for (int x = 1; x <= L << k - 1; ++x) now += a;
				for (int x = j; now.size() < n; ++x) now += s[x <= n ? x : 2 * n + 1 - x];
				if (ans.empty() || now < ans) ans = now;
			}
			i = j;
		} else ++i;
	if (s[n] == a) {
		string now;
		int i = n;
		while (i && s[i] == a) --i;
		for (int x = 1; x <= n - i << k; ++x) now += a;
		for (int x = i; now.size() < n; --x) now += s[x];
		if (ans.empty() || now < ans) ans = now;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

ll N, A, B;
ll H[100005];
ll H1[100005];

int C(ll x){
  for(int i=0;i<N;i++) H1[i] = H[i] - x*B;
  ll s = 0;
  for(int i=0;i<N;i++) if(H1[i] > 0) s += (H1[i]+(A-B)-1) / (A-B);
  return s <= x;
}

int main()
{
  cin >> N >> A >> B;
  rep(i, N) cin >> H[i];
  ll lb = 0, ub = 1000000000LL;
  ll mid = lb + (ub-lb) / 2;
  for(int i=0;i<100;i++){
    if(C(mid)) ub = mid;
    else lb = mid;
    mid = lb + (ub-lb) / 2;
  }
  cout << ub << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0)
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  IO;
  int n; cin>>n;
  vector<vector<int>> dp(n+1, vector<int>(3));
  for (int d = 1; d <= n; d++) {
    int x,y,z; cin>>x>>y>>z;
    vector<int> acts = {x,y,z};
    // dp[day][act] = best happiness

    for (int a = 0; a < 3; a++) {
      // pair with prev day
      for (int p = 0; p < 3; p++) {
        if (p != a) {
          // valid move
          dp[d][a] = max(dp[d][a], dp[d - 1][p] + acts[a]);
        }
      }
    }
  }

  int ans = 0;
  for (int a = 0; a < 3; a++) ans = max(ans, dp[n][a]);
  cout<<ans<<"\n";
}

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

int main() {
    int X, A, B;
    cin >> X >> A >> B;

    int days = -A + B;

    if (days <= 0) {
        cout << "delicious" << endl;
    } else if (days <= X) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }

    return 0;
}

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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}





int main(){
    string s;
     cin >> s;
     if (s[0]== 'S'){
         cout << "Cloudy";
     }else if (s[0]== 'C'){
         cout << "Rainy";
     }else{
         cout << "Sunny";
     }
    return 0;
}

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

cnt = {}
for a in A:
    if a not in cnt:
        cnt[a] = 1
    else:
        cnt[a] += 1

A = [[k, v] for k, v in cnt.items()]
A.sort(reverse=True)

h = 0
w = 0
for k, v in A:
    if v >= 4 and h == 0:
        h = k
        w = k
        break
    elif v >= 2 and h > 0:
        w = k
        break
    elif v >= 2 and h == 0:
        h = k

print(h * w)


Measured memory_bytes: 77848
N=int(input())
A=input()
B=input()
C=input()
iC = 0
for i in range(N):
    a = A[i]
    b = B[i]
    c = C[i]
    if a != b and b != c and c != a :
        iC += 2
    elif a != b or b != c or c != a :
        iC += 1
print(iC)


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<iomanip>
#include<map>
#include<fstream>
//#include"big_integers.h"

using namespace std;

int main()
{
	int k, s;
	int c = 0;
	cin >> k >> s;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (0 <= z && z <= k)
				c++;
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lf double
#define ll long long
#define cc pair<char,char>
#define ull unsigned ll
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define iiii2 pair<int,iii>
#define lii pair<ll,ii>
#define lolo pair<ll,ll>
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 1000000000
#define inf 1000000000
#define N 200005
#define LOG 20
#define magic 100
#define KOK 250
#define EPS 0.0025
#define pw(x) (1<<(x))
#define PI 3.1415926535
using namespace std;

ll ans;
int a[N],bit[N][LOG+2];
int no,n,tot[LOG+2],ok[LOG+2];

int main() {

	#if 0
	freopen("input.txt","r",stdin);
	#endif
		
	scanf("%d",&n);

	for(int i=1;i<=n;i++) {

		scanf("%d",&a[i]);

		for(int j=0;j<=LOG;j++) {

			if(a[i]&pw(j)) {

				bit[i][j]=1;

			}

		}

	}

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

		bit[n+1][i]=2;

	}

	int last=0;

	for(int i=1;i<=n;i++) {

		while(last+1<=n+1 && !no) {

			last++;

			for(int j=0;j<=LOG;j++) {

				tot[j]+=bit[last][j];

				if(tot[j]>1 && !ok[j]) {

					no++;

					ok[j]=1;

				}

			}

			if(no) break ;

		}

		ans+=last-i;

		for(int j=0;j<=LOG;j++) {

			tot[j]-=bit[i][j];

			if(tot[j]==1 && ok[j]) no--,ok[j]=0;

		}

	}

	printf("%lld",ans);

}

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


int main(){
    int H,W;cin>>H>>W;
    vector<vector<char>> lst(H);
    vector<vector<int>> hist(H);
    int ans = 0;
    rep(i,H){
        rep(j,W){
            char s;cin>>s;
            lst[i].push_back(s);
            hist[i].push_back(-1);
        }
    }
    auto conv=[&](int x){
        //数字を座標に変換する.
        return make_pair(x%H,x/H);
    };
    for(int i=0;i<H*W;i++){
        for(int j=0;j<H*W;j++){
            if(i==j)continue;
            if(lst[conv(i).first][conv(i).second]=='#')continue;
            if(lst[conv(j).first][conv(j).second]=='#')continue;
            //start:i,goal:j
            rep(a,H)rep(b,W)hist[a][b]=-1;//初期化.
            //幅優先探索をする.
            queue<P> Q;
            Q.push(conv(i));
            hist[conv(i).first][conv(i).second]=0;
            while(!Q.empty()){
                P now=Q.front();Q.pop();
                if(now == conv(j)){
                    ans = max(ans,hist[now.first][now.second]);
                    break;
                }
                vector<P> anlst={make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)};
                for(P x: anlst){
                    P nnow = make_pair(now.first+x.first,now.second+x.second);
                    if(nnow.first>=H || nnow.first<0 || nnow.second>=W || nnow.second<0)continue;
                    if(lst[nnow.first][nnow.second]=='#')continue;
                    if(hist[nnow.first][nnow.second]>0)continue;
                    hist[nnow.first][nnow.second]=hist[now.first][now.second]+1;
                    Q.push(nnow);
                }
                //ここまででしてはイケナイところは取り除いた.
                
            }
        }
    }
    cout<<ans<<endl;
    // rep(i,H){
    //     rep(j,W){
    //         cout<<lst[i][j]<<' ';
    //     }
    //     cout<<endl;
    // }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

// 連長圧縮（ランレングス圧縮）：sの連長部分を{文字,個数}の配列で返す。
vector<pair<char, long long>> RunLengthEncoding(string s){
    vector<pair<char, long long>> ret;
    long long i = 0, n = s.size();
    while(i<n){
        char tmp = s[i];
        long long cnt = 1;
        while(i<n){
            i++;
            if(tmp == s[i]) cnt++;
            else break;
        }
        ret.push_back(make_pair(tmp, cnt));
    }
    return ret;
}

int main(){
    Init();
    string s; cin >> s; s += ";";
    auto rle = RunLengthEncoding(s);
    ll ans = 0, n = rle.size(), pre = 0;
    for(ll i=0; i<n; i++){
        if(rle[i].first == '>'){
            // >
            ans += (ll)(rle[i].second * (rle[i].second+1.0)/2.0);
            if(rle[i].second < pre){
                ans = ans + pre - rle[i].second;
            }
        }
        else if(rle[i].first == '<'){
            // <
            ans += (ll)((rle[i].second-1.0) * rle[i].second/2.0);
            pre = rle[i].second;
        }
        else{
            // ;
            if(rle[i-1].first == '<') ans += pre;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8484
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#define REP(i,a,b) for (int i = (a); i < (b); i++)
#define rep(i,a) REP(i,0,a)

using namespace std;

int n,m,k;

int main(void){
    while (cin >> n >> m >> k && n) {
        int dp[n][n * m + 1];
        memset(dp,0,sizeof(dp));
        rep(i, m) dp[0][i + 1] = 1;
        REP(i, 1, n) rep(j, m * n + 1) REP(k, max(0, j - m), j) dp[i][j] += dp[i - 1][k];

        long long s = 0;
        rep(i, m * n + 1) s += dp[n - 1][i];

        double ans = 0.0;
        rep(i, m * n + 1) ans += 1.0 * dp[n - 1][i] / s * max(1, i - k);
        printf("%.10f\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1236
from collections import Counter
n = int(input())
s = Counter(list(map(int, input().split())))

if s[0] == n:
    print("Yes")
elif len(s) == 2 and s[0] == n // 3:
    print("Yes")
elif len(s) == 3:
    res = 0
    num = set()
    for k, v in s.items():
        res ^= k
        num.add(v)
    if not res and len(num) == 1:
        print("Yes")
    else:
        print("No")
else:
    print("No")


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const int mod = 1e9+7;
const int N = 53;

string s[2];

void solve() {
	int n; cin >> n;
	long long ans = 1;
	cin >> s[0] >> s[1];
	int c = 3;
	for (int i = 0; i < n; ++i) {
		if (s[0][i] == s[1][i]) {
			(ans *= c) %= mod;
			c = 2;
		} else {
			if (c != 1) {
				(ans *= c*(c-1)) %= mod;
			} else {
				(ans *= 3) %= mod;
			}
			c = 1;
			++i;
		}
	}
	cout << ans;
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256