akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter()
for a in A:
    c[a] += 1
candidate = []
for k, v in c.most_common():
    if v >= 4:
        candidate.append(k)
        candidate.append(k)
    elif v >= 2:
        candidate.append(k)
candidate.sort()

if len(candidate) < 2:
    print(0)
else:
    print(candidate[-1]*candidate[-2])


Measured memory_bytes: 21540
/*
      author : nishi5451
      created: 10.08.2020 23:54:31
*/

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


int main(){
    vector<int> dp(101);
    int a;
    rep(i,3){
        cin >> a;
        dp[a]++;
    }
    int ans = 0;
    for(int i=1; i<=100; i++){
        if(dp[i]!=0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n , t ;
    cin >> n >> t;
    ll cnt = 0 ;
    vl v;
    forn(i , 1 , n ) {
       ll x;
       cin >> x;
       v.pb(x) ;
    }
    sort(all(v)) ;
    forn(i , 0 , n - 1 ) {
       if(i <= n-2){
          ll now = v[i];
          ll next= v[i+1];
          ll diff = next - now ;
          if(diff >= t){
            cnt = cnt + t ;
          }
          else if(diff < t){
            cnt = cnt + diff;
          }
       }
       else if(i == n-1){
        cnt = cnt + t ;
       }
    }
    cout << cnt << el ;
    ro ;
}































Measured memory_bytes: 2420
from sys import stdin
INF = int(1e9+7)


def modadd(a, b):
    # aとbを足した値をmodする(a + b mod p)
    return (a + b) % INF


def main():
    lines = stdin.readlines()
    N = int(lines[0].split()[0])
    M = [True] * (N + 1)
    for i in map(int, lines[1:]):
        M[i] = False
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if M[1] else 0
    for i in range(2, N + 1):
        if M[i]:
            dp[i] = modadd(dp[i - 1], dp[i - 2])
    print(dp[N])
    return


main()


Measured memory_bytes: 11028
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
int main(){
  int a[5];
  int ans=0,x=10;
  for(int i=0;i<5;i++){
    cin>>a[i];
    if(a[i]%10!=0){
    x=min(x,a[i]%10);
    a[i]/=10;
    a[i]=(a[i]+1)*10;
    }
    ans+=a[i];
  }
  if(x!=10)
  cout<<ans-(10-x)<<endl;
  else
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    int[] x = new int[n];
    int[] y = new int[n];
    String[] a = sc.nextLine().split(" ");
    String[] b = sc.nextLine().split(" ");
    for(int i = 0; i < n; i++) {
      x[i] = Integer.parseInt(a[i]);
      y[i] = Integer.parseInt(b[i]);
    }
    double manha = 0;
    double eucli = 0;
    double minko = 0;
    double cheby = 0;
    double sum = 0;
    for(int i = 0; i < n; i++) {
      manha += Math.abs(x[i] - y[i]);
    }
    for(int i = 0; i < n; i++) {
      sum += Math.pow(x[i] - y[i], 2);
    }
    eucli = Math.sqrt(sum);
    sum = 0;
    for(int i = 0; i < n; i++) {
      sum += Math.pow(Math.abs(x[i] - y[i]), 3);
    }
    minko = Math.cbrt(sum);
    double max = 0;
    for(int i = 0; i < n; i++) {
      if(Math.abs(x[i] - y[i]) > max) {
        max = Math.abs(x[i] - y[i]);
      }
    }
    cheby = max;
    System.out.println(manha);
    System.out.println(eucli);
    System.out.println(minko);
    System.out.println(cheby);
  }
}



Measured memory_bytes: 26340
n,m,q = gets.split.map(&:to_i)

g = (n+1).times.map{[0]*n}

lr = m.times.map{gets.split.map(&:to_i)}.sort{|a,b|a[1]<=>b[1]}

lr.each{|(l,r)|
  g[0][r-1]+=1
  g[l][r-1]-=1
}

(n-1).times{|i| g[0][i+1] += g[0][i]}

n.times{|i|
  sum = 0
  n.times{|j|
    sum += g[i+1][j]
    g[i+1][j] = sum
  }
}

n.times{|i|
  n.times{|j|
    g[i+1][j] += g[i][j]
  }
}

q.times{
  pv,qv = gets.split.map(&:to_i)
  p g[pv-1][qv-1]
}


Measured memory_bytes: 22880
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

const int MOD = 1000 * 1000 * 1000 + 7;

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]] += 1;
  }
  if (n % 2 == 1 && cnt[0] != 1) {
    cout << "0\n";
    return;
  }
  for (int i = 1 + n % 2; i <= n; i += 2) {
    if (cnt[i] != 2) {
      cout << "0\n";
      return;
    }
  }
  int ans = 1;
  for (int i = 0; i < n / 2; i++) {
    ans += ans;
    if (ans >= MOD) {
      ans -= MOD;
    }
  }
  cout << ans << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
//  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    
    int plan1, plan2;
    plan1 = n * a;
    plan2 = b;
    
    if (plan1 > plan2) {
        cout << plan2 << endl;
    }
    else {
        cout << plan1 << endl;
    }
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

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

 
int main() {
  int N, D, ans=0;
  cin >> N >> D;
  VVI X;
  REP(i,N) {
    VI A(D);
    REP(j,D) {
      cin >> A.at(j);
    }
    X.PB(A);
  }
  REP(i,N-1) {
    FOR(j,i+1,N) {
      int d=0;
      REP(k,D) {
        d+= pow(X.at(i).at(k) - X.at(j).at(k),2);
      }
      double g=sqrt(d);
      if(ceil(g)== g) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
# define int long long
using namespace std;
 
int32_t main()
{
 ios_base::sync_with_stdio(0);  cout.tie(0); cin.tie(0);
 int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a>=k){cout<<k;}
  else if(a<=k && a+b>=k){cout<<a;}
  else{cout<<2*a+b-k;}
 
 
 
 
 
 
}

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

ll dp[55][55][2555];

signed main(){
    //cout << setprecision(12) ;
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    ll n,t;
    cin>>n>>t;
    ll mod = 1e9+7;

    
    dp[0][0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n*n;k++){
                if(k-2*j>=0){
                    dp[i][j][k] += dp[i-1][j][k-2*j]*(2*j+1) % mod;
                    dp[i][j][k]%=mod;
                    if(j) dp[i][j][k] += dp[i-1][j-1][k-2*j] % mod;
                    dp[i][j][k]%=mod;
                    if(j+1<=n) dp[i][j][k] += dp[i-1][j+1][k-2*j]*(j+1)*(j+1) % mod;
                }
                dp[i][j][k]%=mod;
            }
        }
    }
    
    ll ans = dp[n][0][t];
    cout<<ans<<endl;
}

Measured memory_bytes: 56448
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>]
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(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; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

//////////////////////////////////////////////////////////////

int main() {

	int R;
	cin >> R;

	double ans = 3.14 * R * 2.0f;

	cout << ans << endl;

}


Measured memory_bytes: 3236
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define fo(x,a,b) for(register int x=a;x<=b;x++)
#define dfo(x,a,b) for(register int x=a;x>b;x--)
#define inf 2147483647
using namespace std;
int n,q,x,y,ans,lm,a[105];
int main ()
{
	

	while (true) 
	{
		scanf("%d%d",&n,&q);
		if (n==0&&q==0) break;
		fo(i,1,100)
		a[i]=0;
		fo(i,1,n)
		{
			scanf("%d",&x);
			fo(j,1,x)
			{
				scanf("%d",&y);
				a[y]++;
				lm=max(lm,y);
			}
		}
		ans=0;
		int ke=0;
		fo(j,1,lm)
		{
			if (a[j]>ke&&a[j]>=q) {ke=a[j];ans=j;};
		}			
		printf("%d\n",ans);
	}
	return 0;
}





Measured memory_bytes: 3096
from collections import Counter
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
v=[[] for i in range(m)]
for i in x:v[i%m].append(i)
a=0
for i in range(1,m//2+1*(m%2==1)):
  d=len(v[i])-len(v[m-i])
  if d<0:
    d=-d
    v[i],v[m-i]=v[m-i],v[i]
  c=sorted(Counter(v[i]).items(),key=lambda x:x[1])
  p=0
  for t in c:
    p+=(t[1]//2)
  a+=len(v[m-i])+min(p,(d//2))
a+=len(v[0])//2+(len(v[m//2])//2 if m%2==0 else 0)
print(a)

Measured memory_bytes: 82028
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int find(int x)
{
	if(x==0)return 0;
	int low=1,high=Min(sqrt(sqrt(x)),3e3),mid,ans=1;
	while(low<=high)
	{
		mid=(low+high)/2; //db1(mid);
		if(mid*mid*mid*mid*mid>1e18)high=mid-1;
		else if(mid*mid*mid*mid*mid<=x)
		{
			ans=mid;
			low=mid+1;
		}
		else high=mid-1;
	}
	return ans;
}
int32_t main() {
    IOS;
    	int x; cin>>x;
        rep(i,0,3e3)
        {
        	if(x+(i*i*i*i*i)>1e20)break;
        	int y=x+(i*i*i*i*i),ans=find(y);
        	if(ans*ans*ans*ans*ans>1e20)break;
        	else if(ans*ans*ans*ans*ans==y)
        	{
        		cout<<ans<<" "<<i; return 0;
        	}
        }
        rep(i,0,3e3)
        {
        	if(abs(x-(i*i*i*i*i))>1e20)break;
        	int y=x-(i*i*i*i*i),ans=find(abs(y));
        	if(ans*ans*ans*ans*ans>1e20)break;
        	else if(ans*ans*ans*ans*ans==abs(y))
        	{
        		if(y<0)ans*=-1;
        		cout<<ans<<" "<<-i; return 0;
        	}	
        }
        



        cout<<'\n';
    return 0;
}

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

int main() {
    int N, Y;
    cin >> N >> Y;
    for (int i = 0; 10000 * i <= Y; i++) {
        for (int j = 0; 10000 * i + 5000 * j <= Y; j++) {
            int rest = Y - (10000 * i + 5000 * j);
            int k = rest / 1000;
            if (rest % 1000 == 0 && i + j + k == N) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 380
NN, MM = list(map(int,input().split()))
ARR = [list(map(int,input().split())) for l in range(MM)]
PMAP = list(map(int,input().split()))
#print(NN,MM,ARR)
switch = [[0 for j in range(NN)] for i in range(MM)]
for i in range(MM):
    for j in range(ARR[i][0]):
        switch[i][ARR[i][j+1]-1] = 1
#print(switch)

number_of_switch_on = 0
for j in range(2**NN):
#   print("bit-full-search step ", j)
    switch_on = 1
    for l in range(MM):
        checksum = 0
#        print("Checking Bulb", l+1)
        for k in range(NN):
            if (j>>k) & 1:
#               print("Switch ", k+1, " is on!")
                checksum += switch[l][k]
#        print("Checksum of switch ",l," is", checksum)
        if (checksum % 2) != PMAP[l]:
            switch_on = 0
    number_of_switch_on = number_of_switch_on + switch_on
#    print(" ")
#    print()
print(number_of_switch_on)

Measured memory_bytes: 67796
n = int(input())
dd = list(map(int,input().split()))
dd.sort()
# print(dd)
fir = dd[len(dd)//2-1]
sec = dd[len(dd)//2]
cou = 0
i = fir + 1
# print(fir,sec)
# while i <= sec:
#     cou += 1
#     i += 1
print(sec-i +1)


Measured memory_bytes: 14396
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        int A, B;

        A = sc.nextInt();
        B = sc.nextInt();

        if(A == 1) {
            A += 13;
        }
        if (B == 1) {
            B += 13;
        }

        if (A > B) {
            out.println("Alice");
        } else if (B > A) {
            out.println("Bob");
        } else if (A == B) {
            out.println("Draw");
        }
        

        sc.close();
    }
}

Measured memory_bytes: 21716
#include <stdio.h>

int main() {

  int a, b, c, i, x;
  x = 0;
  scanf("%d %d %d", &a, &b, &c);
  for ( i = a; i <= b; i++) {
    if ((c % i) == 0)
      x++;
  }
  printf("%d\n", x);

  return 0;

}

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

int main(){
    bool yellowFlag = false;
    int N;
    cin >> N;
    
    for(int i = 0; i < N ; i++){
        string color;
        string yellow = "Y";
        cin >> color;
        if(color == yellow)yellowFlag =true;    
    }

    if(yellowFlag){
        cout << "Four" << endl;
    }else{
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    int n;
    cin >> n;
    int ans = 0;
    if (n % 2 == 0) {
        ans = n / 2 - 1;
    } else {
        ans = n / 2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main(){
  unsigned short *A,*B;
  int C[VMAX+1];
  int n,i,j;
  scanf("%d",&n);
  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);
  for(i=0;i<=VMAX;i++)C[i]=0;
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];
  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}



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

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

    ll count = 0;

    if(N * 2 <= M)
    {
        M -= N * 2;
        count += N;
        count += M / 4;
    }
    else
    {
        count = M / 2;
    }

    cout << count << endl;
    
    return 0;
}

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

int main() {
  int A, B, S;
  cin >> A >> B;
  S = A * B;
  if (S%2 == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll=long long;

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,x,y,z,max1=0,ans;
    string s,t,u;
    cin>>a>>b>>k;
    for (ll i=max(a,b); i>0; i--) {
        if (a%i==0&&b%i==0) {
            k--;
        }
        if (k==0) {
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    vector<int> dem(4);
    for (int i = 0; i < 3; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        dem[a]++;
        dem[b]++;
    } // end i
    int odd = 0;
    for (int i = 0; i < 4; ++i) {
        if(dem[i] % 2) odd++;
    } // end i
    cout << (odd == 0 || odd == 2 ? "YES" : "NO") << endl;

}

int main(int argc, char *argv[]) {
    string FileName("B"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    // /home/USER/.../MEPH_X -> MEPH_X
    if (sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size() - ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        solve(cin);
    } else {
        cerr << sub << " test" << endl;
        string inFile = FileName + ".txt";
        auto fs = fstream(inFile, fstream::in);
        while (fs) { solve(fs); }
    }
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	string s = to_string(n);
	if (s[0] == s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repS(n) for(int (s) = 0; (s) < 1 << (n); ++(s))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define divceil(n,d) ((n)/(d) + ((n)%(d) > 0))
#define parity(a,b) (((a) & 1LL)^((b) & 1LL)^1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}


bool is_prime[100001];

void solve(){
	
	fill(all(is_prime),1);
	repU(i,2,50000) is_prime[i * 2] = 0;
	is_prime[1] = 0;
	int p = 3;

	while((ll)p * p < 100000){
		for(int t = p * 2; t < 100000; t += p) is_prime[t] = 0;
		p += 2;
		while(!is_prime[p]) p += 2;
	}
	
	int f[100001];
	f[1] = 0;
	
	for(int i = 3; i < 100000; i += 2){
		f[i] = f[i-2];
		if(is_prime[i] && is_prime[(i+1)/2]) ++f[i];
	}
	
	int q,l,r,a;
	cin>>q;
	
	rep(i,q){
		cin>>l>>r;
		a = f[r];
		if(l > 1) a -= f[l-2];
		cout<<a<<endl;
	}
	
	return;
}

void input(){
	
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	input();
	solve();
	
	return 0;
}





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

int main() {
    int n,m;
    string s,t;
    map<string, int> reword;

    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> s;
        reword[s]++;
    }
    cin >> m;
    for (int i=0;i<m;i++) {
        cin >> t;
        reword[t]--;
    }
    int ans = 0;
    for (auto&& it : reword) {
        ans = max(ans, it.second);
    }
    cout << ans << endl;
}

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

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    COMinit();
    int N, K; cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    ll ans = 0;
    for (int i = 0; N - i - 1 >= K-1; i++){
        ans += ((COM(N-1-i, K-1) * (A[N-1-i] - A[i]))) % MOD;
        ans += MOD;
        ans %= MOD;
        //cout << ans << endl;
    }
    cout << ans << endl;
}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  int h, w;
  cin >> h >> w;
  int a[h][w];
  rep(i, h) rep(j, w) cin >> a[i][j];
  vector<P> x, y;
  rep(i, h) rep(j, w-1) {
    if (a[i][j] % 2 == 0) continue;
    a[i][j+1]++;
    x.emplace_back(i+1, j+1);
    y.emplace_back(i+1, j+2);
  }
  rep(i, h-1) {
    if (a[i][w-1] % 2 == 0) continue;
    a[i+1][w-1]++;
    x.emplace_back(i+1, w);
    y.emplace_back(i+2, w);
  }
  int n = x.size();
  cout << n << endl;
  rep(i, n) {
    cout << x[i].first << " " << x[i].second << " " << y[i].first << " " << y[i].second << endl;
  }
}

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


Measured memory_bytes: 5228
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    scan(N);
    auto L = new int[](N);
    auto R = new int[](N);
    foreach (i ; 0 .. N) {
        scan(L[i], R[i]);
        R[i]++;
    }

    sort(zip(L, R));

    auto rf = new int[](N + 1);
    rf[0] = inf;
    foreach (i ; 1 .. N + 1) {
        rf[i] = min(rf[i - 1], R[i - 1]);
    }
    auto rr = new int[](N + 1);
    rr[N] = inf;
    foreach_reverse (i ; 0 .. N) {
        rr[i] = min(rr[i + 1], R[i]);
    }

    long ans;
    foreach (i ; 0 .. N - 1) {
        int Lz = L[N - 1], Rz = rr[i + 1];
        chmax(ans, R[i] - L[i] + max(0, min(Rz, rf[i]) - Lz));
        chmax(ans, max(0, rf[i + 1] - L[i]) + max(0, Rz - Lz));
    }
    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 4860
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	ll a,b;
	cin>>a>>b;
	if(max(a,b)<10)
	{
		cout<<a*b;
	}
	else
	cout<<-1;
}

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

bool dp[85][85][13000];  // マス(y,x)までに差をaにできるか?

int main() {
  int h, w;
  cin >> h >> w;

  // 2次元配列2つに突っ込む
  int ga[h + 1][w + 1], gb[h + 1][w + 1];  // 少し大きめにもたせた
  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++)
      cin >> ga[y][x];
  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++)
      cin >> gb[y][x];

  // DPをします
  dp[0][0][abs(ga[0][0] - gb[0][0])] = true;
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      int shita = abs(ga[y + 1][x] - gb[y + 1][x]);  // 下側で作れる差
      int migi = abs(ga[y][x + 1] - gb[y][x + 1]);   // 右側で作れる差
      for (int d = 0; d < 13000; d++) {
        if (abs(shita + d) < 13000) dp[y + 1][x][abs(shita + d)] |= dp[y][x][d];
        if (abs(shita - d) < 13000) dp[y + 1][x][abs(shita - d)] |= dp[y][x][d];
        if (abs(migi + d) < 13000) dp[y][x + 1][abs(migi + d)] |= dp[y][x][d];
        if (abs(migi - d) < 13000) dp[y][x + 1][abs(migi - d)] |= dp[y][x][d];
      }
    }
  }

  // 一番小さいのを出力
  for (int i = 0; i < 13000; i++)
    if (dp[h - 1][w - 1][i]) {
      cout << i << endl;
      return 0;
    }
}


Measured memory_bytes: 88320
#include<stdio.h>
int main()
{
    char a[11], b[11], c[11];
    scanf("%s %s %s",a,b,c);
    a[0]=a[0]-32;
    b[0]=b[0]-32;
    c[0]=c[0]-32;
    printf("%c%c%c\n",a[0],b[0],c[0]);
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<char> S(N);
    int count_r = 0;
    int count_g = 0;
    int count_b = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
        if(S.at(i) == 'R') {count_r++;}
        if(S.at(i) == 'G') {count_g++;}
        if(S.at(i) == 'B') {count_b++;}
    }

    int64_t sum = count_r * count_g * count_b;

    
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j + (j - i) < N; j++)
        {
            //jはiの一つ隣から探索
            int k = j + (j - i); //j+(j-i) = i+1+(i+1-i) = i+2 kはiの二つ隣から探索
            if(S.at(i) != S.at(j) && S.at(j) != S.at(k) && S.at(k) != S.at(i))
            {
                sum--;
            }
        }
        
    }

    cout << sum << endl;
}
*/

#include <iostream>
#include <string>
using namespace std;

int main() {
	int N;
	string S;
	cin >> N >> S;
	int count_r = 0;
	int count_g = 0;
	int count_b = 0;
	for(int i = 0; i < N; i++) {
		if(S[i] == 'R') { count_r++; }
		if(S[i] == 'G') { count_g++; }
		if(S[i] == 'B') { count_b++; }
	}
int64_t sum = count_r * count_g * count_b;
	for(int i = 0; i < N; i++) {
		for(int j = i + 1; j + (j - i) < N; j++) {
			int k = j + (j - i);
			if(S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) {
				sum--;
			}
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 3196
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(long long i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
ll n,y;
cin>>n>>y;
y/=1000;
rep(i,0,n)
{
	rep(j,0,n)
	{
		ll k=n-i-j;
		if(k<0)continue;
		ll kk=i+5*j+10*k;
		if(kk==y)
		{
			o2(k,j);os;ol(i);
			return 0;
		}
	}
}

ol("-1 -1 -1");

return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	
	int h,w,f=0;
	char c[120][120];
	int  re[120][120];
	
	cin>>h>>w;
	
	for(int i=0;i<h;i++){
		f=0;
		for(int j=0;j<w;j++){
			cin>>c[i][j];
			if(c[i][j]=='c'){
				f=1;
			re[i][j]=0;
			}
			else{
				if(f!=1)
					re[i][j]=-1;
				else
					re[i][j]=re[i][j-1]+1;
					
			}
		}
	}
	
	for(int i=0;i<h;i++){
		cout<<re[i][0];
	for(int j=1;j<w;j++)
		cout<<" "<<re[i][j];
		cout<<endl;
	}
}

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

#define int long long

int memo[20][(1 << 12)];

int m, w;
int bm[20];
int bw[20];

#define POW(X) ((X)*(X))

int dp(int i, int bit){
	if(i == m) return 0;
	if(memo[i][bit] != -1) return memo[i][bit];

	int ans = dp(i+1, bit);

	for(int j = 0;j < w;j++){
		if((bit & (1 << j)) == 0){
			int tmp = abs(bm[i] - bw[j]) * POW(abs(bm[i] - bw[j]) - 30);
			ans = max(ans, dp(i+1, bit | (1 << j)) + tmp);
		}
	}

	return memo[i][bit] = ans;
}

signed main(){
	while(cin >> m >> w, m != 0){
		for(int i = 0;i < m;i++) cin >> bm[i];
		for(int i = 0;i < w;i++) cin >> bw[i];
		memset(memo, -1, sizeof(memo));
		cout << dp(0, 0) << endl;
	}
	return 0;
}


Measured memory_bytes: 3720
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <regex>

using ull = unsigned long long;
using ll = long long;

using namespace std;




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

	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		h.emplace_back(t, true);
	}

	int a, b;
	for (int i = 0; i < m; i++)
	{
		
		cin >> a >> b;
		a--; b--;
		
		if (h[a].first > h[b].first) {
			/*h[a].second = true;*/ h[b].second = false;
		}
		else if (h[b].first > h[a].first) {
			/*h[b].second = true; */h[a].second = false;
		}
		else {
			h[b].second = false; h[a].second = false;
		}

		
	}

	int count = 0;
	for(auto v : h)
	{
		if (v.second == true)
			count++;
	}
	
	cout << count;
	
	return 0;
	
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
 #define len length
// what if
using namespace std;
typedef long long ll;

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

int n;
cin >> n;
if(n %10 == 1 || n %10 == 0 || n %10 == 6 || n %10 == 8)
    cout << "pon";
else if ( n %10 == 3)
    cout << "bon";
else if(n %10 == 2 || n %10 == 4 ||n %10 == 5 || n %10 == 7 || n %10 == 9)
    cout<<"hon";

 return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

vector<int> divisor(int n) {
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }

    sort(ret.begin(), ret.end());
    return ret;
}

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i += 2) {
        vector<int> div = divisor(i);
        if (div.size() == 8) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

num = n-2
ans = 0

for i in range(num):

    if l[i] < l[i+1] and l[i+1] < l[i+2] or l[i] > l[i+1] and l[i+1] > l[i+2]:
        ans += 1
print(ans)
    

Measured memory_bytes: 3060
/*
 * Created by Dipta Das on 29-06-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;
const int size = 1e5 + 100;
vector<int> adj[size];
int dp[size];
int n, m, mn;

int dfs (int node) {
    if (dp[node] != -1) return dp[node];
    dp[node] = 0;
    for (int i = 0; i < (int) adj[node].size(); ++i) {
        dp[node] = max (dp[node], dfs(adj[node][i]) + 1);
    }

    return dp[node];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    memset(dp, -1, sizeof(dp));

    cin >> n >> m;
    for (int i = 0, x, y; i < m; ++i) {
        cin >> x >> y;
        adj[x].push_back(y);
    }

    mn = 0;
    for (int i = 1; i <= n; ++i) {
        mn = max (mn, dfs (i));
    }

    cout << mn << endl;
    


    return 0;
}



Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<int,P>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b;
	string s;
	cin>>a>>s>>b;
	f(i,a){
		if(s[i]!=s[b-1]) cout<<'*';
		else cout<<s[i];
	}
	puts("");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner; 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w;
        int t;
        for(int c=1;c<=h;c++){
            t = c;
            w = c%3;
            if(w==0){
                System.out.print(" "+c);
            }else{
                while(t!=0){
                    if(t%10==3){
                        System.out.print(" "+c);break;
                    }else{
                        t/= 10;
                    }
                    
                }
            }
        }
      System.out.println();  
    }
}


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

int main() {
long long h,w,k;
cin>>h>>w>>k;
char c[h][w];
for(long long i=0;i<h;i++){
    for(long long j=0;j<w;j++){
        cin>>c[i][j];
    }
}
long long ans=0;
long long sum=0;
for(long long i=0;i<1<<h;i++){
    for(long long j=0;j<1<<w;j++){
        for(long long m=0;m<h;m++){
            for(long long n=0;n<w;n++){
                if(!(i>>m&1)&&!(j>>n&1)){
                    if(c[m][n]=='#'){
                        sum++;
                    }
                }
            }
        if(m==h-1){
            if(sum==k){
                ans++;
            }
            sum=0;
        }
        }
    }
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3628
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


def main():
    N, P = MAP()

    li = factorization(P)

    ans = 1
    for p, e in li:
        ans *= pow(p, e//N)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5584
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int K;
int V[100];
int arr[100];
int sz;
int main(){
  int i, j, k, r, res=0, tmp, x, y;
  rd(N);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(V[Lj4PdHRW]);
    }
  }
  for(x=0;x<K+1;x++){
    for(y=0;y<K+1;y++){
      if(x+y <= N && x+y<=K){
        sz = 0;
        for(i=0;i<x;i++){
          arr[sz++] = V[i];
        }
        for(i=0;i<y;i++){
          arr[sz++] = V[N-1-i];
        }
        sort(arr, arr+sz);
        r =min_L(K - x - y, sz);
        {
          int Q5VJL1cS, e98WHCEY;
          if(sz==0){
            e98WHCEY = 0;
          }
          else{
            e98WHCEY = arr[0];
            for(Q5VJL1cS=1;Q5VJL1cS<sz;Q5VJL1cS++){
              e98WHCEY += arr[Q5VJL1cS];
            }
          }
          tmp =e98WHCEY;
        }
        for(i=0;i<r;i++){
          if(arr[i] < 0){
            tmp -= arr[i];
          }
        }
        chmax(res, tmp);
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190526-1

// --- original code ---
// int N, K, V[100];
// 
// int arr[100], sz;
// 
// {
//   int i, j, k, r;
//   int x, y;
//   int res = 0, tmp;
// 
//   rd(N,K,V(N));
// 
//   rep(x,K+1) rep(y,K+1) if(x+y <= N && x+y<=K){
//     sz = 0;
//     rep(i,x) arr[sz++] = V[i];
//     rep(i,y) arr[sz++] = V[N-1-i];
//     sort(arr, arr+sz);
// 
//     r = min(K - x - y, sz);
//     tmp = sum(arr(sz));
//     rep(i,r) if(arr[i] < 0) tmp -= arr[i];
// 
//     res >?= tmp;
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 256
#include<iostream>

int n,m;
int DP[100][20];
int book[100];

int solve(){
	for(int i=1; i<n; i++){
		for(int j=1; j<m; j++){
			if(DP[i-1][j-1] <= book[i])
				DP[i][j] = book[i];
			else{
				int tmp = book[i];
				DP[i][j] = DP[i-1][j-1];
				for(int k=1; k<i; k++){
					tmp += book[i-k];
					if(DP[i-k-1][j-1]<=tmp){
						if(tmp < DP[i][j])
							DP[i][j] = tmp;
						break;
					}else{
						if(DP[i-k-1][j-1] < DP[i][j])
							DP[i][j] = DP[i-k-1][j-1];
					}
				}
			}
		}
	}
	return DP[n-1][m-1];
}

int main(){
	while(true){
		std::cin >> m >> n;
		if(!m && !n)
			return 0;
		for(int i=0; i<n; i++){
			std::cin >> book[i];
			if(i>0){
				DP[i][0] = book[i];
				DP[i][0] += DP[i-1][0];
			}else{
				for(int k=0; k<m; k++)
					DP[i][k] = book[i];
			}
		}

		std::cout << solve() << std::endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;
  
void sort(int ar[]){
for(int i = 0; i < 2; i++)
for(int j = i + 1; j < 3; j++)
if(ar[i] > ar[j]){
swap(ar[i], ar[j]);
}
}
  
int main(){
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a);
for(int i = 0 ; i < 3; i++){
char c = ' ';
if(i == 2) c = '\n';
cout << a[i] << c ;
}
  
return 0;
}


Measured memory_bytes: 3104
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	switch n % 10 {
	case 2, 4, 5, 7, 9:
		fmt.Println("hon")
	case 0, 1, 6, 8:
		fmt.Println("pon")
	case 3:
		fmt.Println("bon")
	}
}


Measured memory_bytes: 1816
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, H, i, j, k, stx, sty, sth = 0;
    cin >> N;
    int x[N], y[N], h[N];

    for (i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i])
        {
            sth = h[i];
            stx = x[i];
            sty = y[i];
        }
    }

    for (i = 0; i < 101; i++)
    {
        for (j = 0; j < 101; j++)
        {
            for (k = 0, H = sth + abs(stx - i) + abs(sty - j); k < N; k++)
            {
                if (h[k] != max(H - abs(x[k] - i) - abs(y[k] - j), 0))
                {
                    break;
                }
            }
            if (k == N)
            {
                cout << i << " " << j << " " << H << "\n";
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

int b[3][4009];
ll ss[3][4009];
ll ans;
signed main(){
    ll n;
    string s;
    cin>>n>>s;
    ll tr=0,tg=0,tb=0;
    ll sum=0;
    rep(i,n){
        if(s[i]=='R') b[0][i]=1;
        if(s[i]=='G') b[1][i]=1;
        if(s[i]=='B') b[2][i]=1;
    }
    rep(i,n){
        if(s[n-1-i]=='R') tr++;
        if(s[n-1-i]=='G') tg++;
        if(s[n-1-i]=='B') tb++;
        ss[0][n-1-i]= tr;
        ss[1][n-1-i]= tg;
        ss[2][n-1-i]= tb;
    }
    
    rep(i,n-2){
        if(b[0][i]==1) {
            rep(j,n-1-i){
                if(b[1][i+1+j]==1){
                    ans += ss[2][i+j+2];
                    if(i+2*(j+1)<n && b[2][i+2*(j+1)]==1) ans--;
                    // cout<<" "<<i<<" "<<j<<" "<<endl;
                }else if(b[2][i+1+j]==1){
                    ans += ss[1][i+j+2];
                    if(i+2*(j+1)<n && b[1][i+2*(j+1)]==1) ans--;
                    // cout<<" "<<i<<" "<<j<<" "<<endl;
                }
            }
        }else if(b[1][i]==1) {
            rep(j,n-1-i){
                if(b[0][i+1+j]==1){
                    ans += ss[2][i+j+2];
                    if(i+2*(j+1)<n && b[2][i+2*(j+1)]==1) ans--;
                    // cout<<" "<<i<<" "<<j<<" "<<endl;
                }else if(b[2][i+1+j]==1){
                    ans += ss[0][i+j+2];
                    if(i+2*(j+1)<n && b[0][i+2*(j+1)]==1) ans--;
                    // cout<<" "<<i<<" "<<j<<" "<<endl;
                }
            }
        }else if(b[2][i]==1) {
            rep(j,n-1-i){
                if(b[1][i+1+j]==1){
                    ans += ss[0][i+j+2];
                    if(i+2*(j+1)<n && b[0][i+2*(j+1)]==1) ans--;
                    // cout<<" "<<i<<" "<<j<<" "<<endl;
                }else if(b[0][i+1+j]==1){
                    ans += ss[1][i+j+2];
                    if(i+2*(j+1)<n && b[1][i+2*(j+1)]==1) ans--;
                    // cout<<" "<<i<<" "<<j<<" "<<endl;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3788