akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define drrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int MOD = 1'000'000'000 + 7;
const int INF = 1'000'000'000 + 5;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);

	int reward[] = {300000, 200000, 100000};
	int x, y; std::cin >> x >> y;
	int ans = 0;
	if (x == 1 && y == 1) ans += 400000;
	if (x <= 3)
		ans += reward[--x];
	if (y <= 3)
	ans += reward[--y];
	std::cout << ans << "\n";
}


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

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 ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string S;
    cin>>S;
    vector<string> c = {"dream","dreamer","erase","eraser"};
    reverse(S.begin(),S.end());
    rep(i,4) reverse(c[i].begin(),c[i].end());
    bool can = true;
    int p = 0;
    while(p<(int)S.size()&&can){
        string t;
        rep(i,3) t+=S[p+i];
        bool ok = true;
        if(t=="res"){
            rep(i,6){
                if(S[p+i]!=c[3][i]) {
                    can = false;
                    ok = false;
                }
            }
            if(ok) p+=6;
        }
        else if(t=="esa"){
            rep(i,5){
                if(S[p+i]!=c[2][i]) {
                    can = false;
                    ok = false;
                }
            }
            if(ok) p+=5;
        }
        else if(t=="rem"){
            rep(i,7){
                if(S[p+i]!=c[1][i]) {
                    can = false;
                    ok = false;
                }
            }
            if(ok) p+=7;
        }
        else if(t=="mae"){
            rep(i,5){
                if(S[p+i]!=c[0][i]) {
                    can = false;
                    ok = false;
                }
            }
            if(ok) p+=5;
        }
        else {
            can = false;
            ok=false;
        }
    }
    if(can&&p==(int)S.size()) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3744
from sys import stdin
#N, M, C = (int(i) for i in input().split())
#B = [int(x) for x in stdin.readline().rstrip().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
X = int(input())

ans = (X//500)*1000+(X-(X//500)*500)//5*5
print(ans)


Measured memory_bytes: 38436
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void solve() {
        string a, b; cin >> a>> b;
        int A, B; cin>> A>> B;
        string t; cin >> t;
        if (t== a) cout << A- 1<< " "<< B;
        else cout << A<< " "<< B- 1;
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 3536
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  am <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
  print $ solve am

solve :: [[Int]] -> Int
solve am = go am [0,0,0]
  where
    go :: [[Int]] -> [Int] -> Int
    go [] table = maximum table
    go ((a:b:c:_):am) (aa:bb:cc:_) = go am [a + max bb cc, b + max cc aa,c + max aa bb ]

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int a,b;

int conv(int n) {
  if (n == 2) return 2;
  else if (n == 4 || n == 6 || n == 9 || n == 11) return 1;
  else return 0;
}
int main(){
  scanf("%d %d",&a,&b);
  a = conv(a);
  b = conv(b);
  if (a == b) printf("Yes\n");
  else printf("No\n");
}


Measured memory_bytes: 256
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    string s;
    cin >> s;
    int cnt = 0,ans = 0;
    rep(i,3) {
        if(s[i] == 'R') cnt++;
        else {
            chmax(ans,cnt);
            cnt = 0;
        }
    }
    cout << max(ans,cnt) << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int ans = 0;

    FOR(i, 0, A+1){
        FOR(j, 0, B+1){
            FOR(k, 0, C+1){
                if(500*i + 100*j + 50*k == X) ans++;
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}

/*****************************************************************************/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	list := make([]int, m)
	broken := make([]bool, n+1)
	for i := 0; i < m; i++ {
		fmt.Scan(&list[i])
		broken[list[i]] = true
	}

	dp := make([]int, n+1)
	dp[0] = 1
	if !broken[1] {
		dp[1] = 1
	}
	for i := 2; i <= n; i++ {
		if !broken[i] {
			dp[i] += dp[i-1]
			dp[i] += dp[i-2]
		}
		dp[i] %= 1000000007
	}
	fmt.Println(dp[n])
}


Measured memory_bytes: 5504
import collections
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
B = []
i = 0
while i < N-1:
    if A[i]==A[i+1]:
        B.append(A[i])
        i += 2
    else:
        i += 1
if len(B)<2:
    print(0)
else:
    print(B[0] * B[1])

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long long LL;
#define REP(i,N) for (int i=0; i<N; i++)

int main() {
  int x, y, xGroup = 0, yGroup = 0;
  vi b(4);
  b[0] = 4;
  b[1] = 6;
  b[2] = 9;
  b[3] = 11;
  cin >> x >> y;
  for (int i = 0; i < 4; i++) {
    if (x == b[i]) xGroup = 1;
    if (y == b[i]) yGroup = 1;
  }
  if (x == 2) xGroup = 2;
  if (y == 2) yGroup = 2;
  
  if(xGroup == yGroup) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

/**
 * http://abc068.contest.atcoder.jp/tasks/arc079_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		Map<Integer, Set<Integer>> m = new HashMap<>();
		for(int i=0; i<M; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			Set<Integer> set = m.get(a);
			if(set==null) set = new HashSet<Integer>();
			set.add(b);
			m.put(a, set);
		}
		sc.close();
		
		boolean ans = false;
		if(m.containsKey(1)){
			for(int next: m.get(1)){
				if( m.containsKey(next) && m.get(next).contains(N)){
					ans = true;
					break;
				}
			}
		}
		
		System.out.println( ans ? "POSSIBLE" : "IMPOSSIBLE");

	}

}

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

int main() {
  string S;
  cin >> S;
  int n = S.size();

  int c = 0;
  for (int i = 0; i < n / 2; i++) {
    if (S.at(i) == S.at(n - 1 - i)) {
      continue;
    }
    c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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


	string s;
	int y, m, d;
	while (cin >> s >> y >> m >> d) {
		if (y>31 || y == 31 && m >= 5) {
			cout << "? ";
			cout << y-30 << ' ' << m << ' ' << d << endl;
		}
		else {
			cout << "HEISEI ";
			cout << y << ' ' << m << ' ' << d << endl;
		}
		
	}



	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD   998244353
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    int N; cin>>N;
    ll A[N];
    ll sum=0;
    rep(i,N){
        cin>>A[i];
        sum+=A[i];
    }
    ll left=0;
    ll ans=sum;
    rep(i,N){
        left+=A[i];
        sum-=A[i];
        mini(ans,abs(sum-left));
    }
    cout<< ans<<"\n";

}

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


Measured memory_bytes: 1792
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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

int main() {
    int H,W,N;cin >> H >> W >> N;swap(H,W);
    vector<vector<bool>> retu(H,vector<bool>(W)); 
    for(int i = 0;i<N;i++){
        int x,y,a;cin >> x >> y >> a;
        if(a == 1){
            for(int j = 0;j<H;j++){
                for(int k = 0;k<x;k++){
                    retu.at(j).at(k) = true;
                }
            }
        }
        else if(a == 2){
            for(int j = 0;j<H;j++){
                for(int k = x;k<W;k++){
                    retu.at(j).at(k) = true;
                }
            }
        }
        else if(a == 3){
            for(int j = 0;j<y;j++){
                for(int k = 0;k<W;k++){
                    retu.at(j).at(k) = true;
                }
            }
        }
        else if(a == 4){
            for(int j = y;j<H;j++){
                for(int k = 0;k<W;k++){
                    retu.at(j).at(k) = true;
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0;i<H;i++)for(int j = 0;j<W;j++) if(!retu.at(i).at(j)) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,x,t = map(int,ipt().split())
    print(math.ceil(n/x)*t)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 68720
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 #define PI acos(-1)
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
 
 
 
 
const int N=2e5+100;
//ll a[200000];
 
 
#define lop(i,n) for(int i=0;i<n;++i)
//ll n,m,mod;
ll mod=1000000007;

ll dp[1000][3];
map<int,int>winme;
map<int,int>winscore;
map<char,int>number;
int main()
{
ll n,k,r,p,s;cin>>n>>k>>r>>s>>p;string t;
string h;cin>>t;

number['r']=0;number['s']=1;number['p']=2;
winme[0]=number['p'];winme[2]=number['s'];winme[1]=number['r'];

winscore[0]=r;winscore[1]=s;winscore[2]=p;
dp[0][winme[number[t[0]]]]=winscore[winme[number[t[0]]]];
ll ans=0;
ll arr[n];
for(int i=0;i<n;i++){
    ll xx=number[t[i]];
    if(i+1>k){
        if(t[i-k]==t[i]){
           /*for(int h=0;h<3;h++){
                if(i+k<n){
                    if(h!=xx&&h!=number[t[i+k]]){}
                }
            }*/
            t[i]='k';
            
        }else{ans+=winscore[winme[xx]];}
    }else{ans+=winscore[winme[xx]];}
    
}
    

cout<<ans;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF INT_MAX/2 //(1<<(4*4-1))
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

  int N;
  vector<int>a(3);
  cin>>N>>a[0]>>a[1]>>a[2];
  vector<int>l(N);
  for(int i=0;i<N;i++)cin>>l[i];

  ll bit=pow(4,N);

  ll Min=INF;
  for(ll i=0;i<bit;i++){
    ll cost=0;
    ll c0=0,c1=0,c2=0;
    vector<ll>co(3,0);
    for(ll j=0;j<N;j++){
      ll k=i;
      //for(int x=0;x<j;x++)k/=4;
      //k%=4;
      k=3&(k>>(2*j));
      //cout<<k<<" ";
      if(k==0){}
      else if(k==1)co[0]+=l[j],c0++;
      else if(k==2)co[1]+=l[j],c1++;
      else if(k==3)co[2]+=l[j],c2++;
    }
    for(ll x=0;x<3;x++){
      cost+=abs(co[x]-a[x]);
    }
    if(c0==0||c1==0||c2==0)continue;
    if(c0!=0)cost+=10*(c0-1);
    if(c1!=0)cost+=10*(c1-1);
    if(c2!=0)cost+=10*(c2-1);
    //cout<<" "<<cost<<endl;
    Min=min(Min,cost);
  }
  cout<<Min<<endl;
  return 0;
}


Measured memory_bytes: 512
import math
N = int(input())
CSF = []
for _ in range(N-1):
    c, s, f = map(int, input().split())
    CSF.append((c, s, f))

ans = []
for i in range(N):
    T = 0
    for j in range(i, N-1):
        T = max(CSF[j][1], math.ceil(T/CSF[j][2])*CSF[j][2])
        T += CSF[j][0]
    ans.append(T)


print(*ans, sep='\n')


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


int main()
{
    string s, ss;
    cin >> s >> ss;
    string a = s;
    string b = ss;
    reverse(s.begin(), s.end());
    reverse(ss.begin(), ss.end());
    if(ss == a && s == b) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n;
    cin>>n;
    set<int> st;
    rep(i,n) {
        int a;
        cin>>a;
        st.insert(a);
    }
    cout<<(sz(st)==n?"YES":"NO")<<endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

int main()
{
int x,y;
cin>>x>>y;
int a=x,b=0,c=0,d=x;
for (int i = 0; i < x; i++)
{

    if (2*a+4*b==y||2*c+4*d==y)
    {
        cout<<"Yes"<<endl;
        goto ai;
    }
    a--;
    b++;
    c++;
    d--;
}
cout<<"No"<<endl;
ai:
    return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final int SEC_FOR_HOUR = 3600;
        final int SEC_FOR_MINUTE = 60;

        Scanner sc = new Scanner(System.in);
        int inputSec = 0;
        try {
            inputSec = sc.nextInt();
        } catch (Exception e) {
            // TODO: handle exception
        } finally {
            sc.close();
        }

        // Hour
        int hour = inputSec / SEC_FOR_HOUR;
        int wkSec = inputSec - hour * SEC_FOR_HOUR;
        // Minutes
        int minute = wkSec / SEC_FOR_MINUTE;
        wkSec = wkSec - minute * SEC_FOR_MINUTE;
        // Second
        int second = wkSec;

        StringBuffer sb = new StringBuffer();
        sb.append(hour + ":" + minute + ":" + second);

        System.out.println(sb);
    }
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;

int main(){
    int N;
    char s[100003][10];
    ll ans;
    cin >> N;

    rep(i,N){
        rep(k,10){
            cin >> s[i][k]; 
        }
    }
    rep(i,N){
        sort(s[i], s[i] + 10);
    }
    string str[100003];
    rep(i,N){
        str[i] = string(s[i],10);
    }
 
    /* rep(i,N){
        cout<<str[i] <<endl;
    }*/

    map<string,ll> dict;

    for (string x; N--; dict[x]++) { // 辞書内の文字列xに対応する出現回数を+1する
        x = str[N]; // 文字列 x 入力
       // cout << "入力文字列: " << x << ", 出現回数: " << dict[x] + 1 << "回" << endl;
        if(dict[x] >= 1){
            ans+=dict[x];
        }
    }


    cout << ans << endl;
    
    return 0;
    

}

Measured memory_bytes: 12928
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
using namespace std;
char s[100009];
int main()
{
	int sum = 0;
	int sg = 0; int sp = 0;
	cin >> s;
	int n = strlen(s);
	for (int i = 0; i < n; i++) {
		if (sg == sp) {
			sg++;
			if (s[i] == 'p') {
				sum--;
			}
		}
		else if (sg > sp) {
			sp++;
			if (s[i] == 'g') {
				sum++;
			}
		}
	}
	printf("%d\n", sum);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    int ans = n;

    if (n > 100) ans = n % 100;
    if (n > 10) ans = n % 10;

    if (ans == 2 || ans == 4 || ans == 5 || ans == 7 || ans == 9) cout << "hon" << endl;
    if (ans == 0 || ans == 1 || ans == 6 || ans == 8) cout << "pon" << endl;
    if (ans == 3) cout << "bon" << endl;

    return 0;
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;


vector<long long int> modKaijou;
vector<long long int> modInv;
vector<long long int> modInvKaijou;


long long int calcModPow(long long int a, long long int n, long long int m) {
	if (n == 0){
		return 1 % m;
	}
    if (n == 1){
        return a % m;
    }

    if (n % 2 == 1){
        return (a * calcModPow(a, n - 1, m)) % m;
    }

    long long int t = calcModPow(a, n / 2, m);
    return (t * t) % m;
}

long long int calcModInvFermat(long long int a, long long int m) {
	return calcModPow(a, m-2, m);
}

long long int calcModConb(long long int n, long long int r, long long int m) {
	long long int a=1, b=1;
	for(int i=0; i<r; i++){
		a = a*(n-i) % m;
		b = b*(i+1) % m;
	}
	return a * calcModInvFermat(b, m) % m;
}

int main()
{
	long long int n, a, b;
	long long int mod = 1000000007;
	long long int res = 0;


	std::cin >> n >> a >> b;


	res = calcModPow(2, n, mod) - 1;


	res = (res - calcModConb(n, a, mod))%mod;
	if(res < 0){
		res+=mod;
	}

	res = (res - calcModConb(n, b, mod))%mod;
	if(res < 0){
		res+=mod;
	}

	cout << res;
	

	return 0;
}

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

#define ll long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define all(v) (v).begin(), (v).end()

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

ll mod(ll a, ll b, ll m)
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a % m;
    if (b & 1)
        return a * mod(a, b - 1, m) % m;
    else
    {
        ll t = mod(a, b / 2, m);
        return t * t % m;
    }
}

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

    int n;
    cin >> n;
    ll z = 0;
    map<pll, pll> m;
    for (int i = 0; i < n; ++i)
    {
        ll a, b;
        cin >> a >> b;
        if (!a && !b)
        {
            z++;
            continue;
        }
        ll g = gcd(a, b);
        a /= g;
        b /= g;
        if (b < 0)
            a = -a, b = -b;
        if (b == 0 && a < 0)
            a = -a;
        if (a > 0)
            m[pll(a, b)].first++;
        else
            m[pll(b, -a)].second++;
    }
    ll md = 1e9 + 7, ans = 1;
    for (auto a : m)
    {
        ans *= (mod(2, a.second.first, md) + mod(2, a.second.second, md) - 1);
        ans %= md;
    }
    cout << (ans + z - 1 + md) % md << '\n';
}

Measured memory_bytes: 19200
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
#define MAXN 1000
#define MODD 1000000007
#define ll long long
using namespace std;
ll fact[MAXN+1];
ll factinv[MAXN+1];

ll modpow(ll x, ll y) {
    x%=MODD;
    ll xs = x;
    ll answer = 1;
    while(y) {
        if (y&1) {
            answer = (answer * xs) % MODD;
        }
        y >>= 1;
        xs = (xs * xs) % MODD;
    }
    return answer;
}

ll binomial[MAXN+2][MAXN+2];
ll dp[MAXN+10][MAXN+10];

ll Solve(int left,int pos,int A,int B,int C,int D) {
    if (pos == B+1) {
        return (left == 0);
    }
    
    if (dp[left][pos]!=-1)
        return dp[left][pos];
    
    
    // either sz=0;
    ll answer = Solve(left,pos+1,A,B,C,D);
    for(int y=C;y<=D;y++) {
        if (left-y*pos < 0)
            break;
        ll curr = fact[y*pos]*modpow(factinv[pos],y)%MODD;
        curr = (curr * factinv[y])%MODD;
        curr = (curr * binomial[left][y*pos])%MODD;
        answer +=   curr*Solve(left-y*pos,pos+1,A,B,C,D)%MODD;
        if (answer > MODD)
            answer -= MODD;
    }
    return dp[left][pos]=answer;
    
    
}

// 12,34
// 13,24
// 14,23

int main() {
    fact[0]=factinv[0]=1;
    for(int i=1;i<=MAXN;i++) {
        fact[i]=(fact[i-1]*i)%MODD;
        factinv[i]=modpow(fact[i], MODD-2);
    }
    
    for(int i=0;i<=MAXN;i++)
        for(int j=0;j<=i;j++) {
            binomial[i][j]=(j==0?1:(binomial[i-1][j]+binomial[i-1][j-1])%MODD);
        }
    
    
    int N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;

    for(int i=0;i<=N+1;i++)
        for(int j=0;j<=N+1;j++)
            dp[i][j]=-1;
    
    cout << Solve(N,A,A,B,C,D)%MODD << endl;
    
    
    
}

Measured memory_bytes: 15232
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;

int dp[4000][4000];
// int find(int arr[], int i, int j) {
// 	if (dp[i][j] != -1)
// 		return dp[i][j];
// 	if (i == j)
// 		return arr[i];
// 	int taro = INT_MIN, jiro = INT_MAX;
// 	taro = max(arr[i] + find(arr, i + 1, j) - jiro, arr[j] + find(arr, i, j - 1) - jiro);
// 	jiro = min(taro - arr[i] + find(arr, i + 1, j), taro - arr[j] + find(arr, i, j - 1));
// 	return dp[i][j] = taro - jiro;
// }


int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int n;
	cin >> n;
	int arr[n + 5];
	// memset(dp, 0, sizeof dp);
	for (int i = 1; i <= n; i++)
		cin >> arr[i];
	// cout << find(arr, 0, n - 1);
	for (int i = n; i >= 0; i--) {
		for (int j = i; j <= n; j++) {
			dp[i][j] = max(arr[i] - dp[i + 1][j], arr[j] - dp[i][j - 1]);
		}
	}
	cout << dp[1][n];
	return 0;
}

Measured memory_bytes: 51032
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int A, B, C, D, E, F;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    double cnt = -1.0;
    int ans_w = 0, ans_v = 0;
    cin >> A >> B >> C >> D >> E >> F;
    rep(a, 0, 31) {
        rep(b, 0, 31) {
            int w = 100*a*A + 100*b*B;
            if (w == 0) continue;
            rep(c, 0, 101) {
                rep(d, 0, 101) {
                    int z = C * c + D * d;
                    if (w + z <= F) {
                        if (100*z <= E*w) {
                            if ((double)z*100.0/((double)z+(double)w) > cnt) {
                                cnt = (double)z*100.0/((double)z+(double)w);
                                ans_w = w;
                                ans_v = z;
                            }
                        }
                    }
                }
            }
        }
    }
    printf("%d %d\n", ans_w+ans_v, ans_v);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)
	cin>>h[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++)
	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	string S;
	cin >> S;
	if (S == "Sunny") {
		cout << "Cloudy";
	}
	else if (S == "Cloudy") {
		cout << "Rainy";
	}
	else {
		cout << "Sunny";
	}

	return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 2; i < s.size(); i += 2) {
    if (s.substr(0, i / 2) == s.substr(i - i / 2, i / 2)) {
      ans = i;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3556
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    c = [int(s) for s in line.split()]
    cards = [i for i in range(1, 11) if i not in c]

    c1c2 = c[0] + c[1]
    e = sum(int(i + c1c2 <= 20) for i in cards)
    print('YES' if e > 3 else 'NO')

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    n %= 1000;
    if(n==0)
        cout << 0 << endl;
    else
        cout << 1000 - n << endl;
    return 0;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
int k;
cin>>k;
set<string> us;
int n=s.size();
rep(i,n){
    reps(j,n-i+1,1){
        if(j>k)break;
        us.insert(s.substr(i,j));
    }
}
vector<string> dict(us.begin(),us.end());
sort(dict.begin(),dict.end());
cout<<dict[k-1]<<endl;
return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,K;
  cin >> N >> K;
  int i;
  int sum =1;
 for ( i=0 ; i<N ; i++ ){
    if ( sum+K <= sum*2) sum+=K;
    else sum*=2;
      }
  cout << sum << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M;
	int k[MAX] = {}, p[MAX] = {};
	static int s[MAX][MAX];
	int ans = 0;
	// int k;
	
	cin>>N>>M;
	
	for(int i = 0; i < M; i++){
		cin>>k[i];
		
		for(int j = 0; j < k[i]; j++){
			cin>>s[i][j];
			s[i][j]--;
		}
	}
	
	for(int i = 0; i < M; i++){
		cin>>p[i];
	}
	for(int i = 0; i < (1<<N); i++){
		int con = 0;
		for(int j = 0; j < M; j++){
			int sum = 0;
			for(int l = 0; l < k[j]; l++){
				if((i>>s[j][l])&1) sum++;
			}
			if(p[j] == sum%2) con++;
		}
		if(con == M) ans++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
// A Dynamic Programming based 
// C# program to find minimum 
// number operations to 
// convert str1 to str2 
using System;
using System.Collections.Generic;
using System.Linq;
class GFG
{

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var t = Console.ReadLine();
        CutCount(t, n);
    }

    static void CutCount(string s, int n)
    {

        var ss = s;
        int max = 0;
        for (int i = 1; i < ss.Count(); i++)
        {
            var sub1 = ss.Substring(0, i);
            var sub2 = ss.Substring(i);
            var c1 = sub1.Intersect(sub2).Count();
            max = Math.Max(max,c1);

        }
        Console.Write(max);

    }



}



Measured memory_bytes: 13152
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int i, p, j,pg=20000,pj=20000;
	for (i = 0; i < 3; i++)
	{
		cin >> p;
		pg = min(p, pg);
	}
	for (i = 0; i < 2; i++)
	{
		cin >> j;
		pj = min(j, pj);
	}
	cout << pj + pg - 50 << endl;
	return 0;
}

Measured memory_bytes: 3012
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a-*(int*)b;
}

int main(void)
{
    int N, i;
    int d[200000];

    scanf("%d",&N);
    for(i-0; i<N; i++) scanf("%d",&d[i]);

    qsort(d,N,sizeof(int),compare_int);

    N = N/2;

    printf("%d\n",d[N]-d[N-1]);
    
    return 0;
}

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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+10
#define small -big
#define pb push_back
#define endl "\n"


template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}


ll pow(ll a, ll n, ll m){
    
    ll res = 1;
    
    while(n){
        
        if(n % 2) res = res * a % m;
        a = a * a % m;
        n /= 2;
            
    }
    
    return res;
}


ll Fact[1000005];
ll invFact[1000005];

void cal(){
    
    Fact[0] = 1;
    Fact[1] = 1;
    
    for(ll i = 2; i <= 1000000; i++){
        
        Fact[i] = i * Fact[i - 1] % mod;
    }
    
    invFact[0] = 1;
    
    
    for(ll i = 1; i <= 1000000; i++){
        
        invFact[i] = pow(Fact[i], mod - 2, mod);
    }
}

ll comb(ll n, ll r){
    
    ll res = 1;
    
    res = Fact[n];
    res = res * invFact[n - r] % mod;
    res = res * invFact[r] % mod;
    
    return res;
}

void addse(ll & a, ll b) {
        a %= mod;
        b %= mod;
        a += b;
        a %= mod;
}

void subse(ll & a, ll b) {
        a %= mod;
        b %= mod;
        a -= b;
        if(a < 0) {
                a += mod;
        }
        
        a %= mod;
}

void mulse(ll & a, ll b) {
        a %= mod;
        b %= mod;
        a *= b;
        a %= mod;
}


void solve() {
    
            ll N, M;
            cin >> N >> M;
            
           
            ll tot = 0;
            
            for(ll i = 0; i <= N; i++) {
                    ll now = comb(N, i);
                    mulse(now, comb(M, i));
                    mulse(now, Fact[i]);
                    mulse(now, comb(M - i, N - i));
                    mulse(now, Fact[N - i]);
                    mulse(now, comb(M - i, N - i));
                    mulse(now, Fact[N - i]);
                   
                    if(i % 2) {
                            subse(tot, now);
                    } else {
                            addse(tot, now);
                    }
            }
            
            
            cout << tot << endl;
}


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

    int t = 1;
   // cin >> t;
    for(int i = 1; i <= t; i++) {
            solve();
    }


    return 0;
        
}


Measured memory_bytes: 19236
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,A[10];
	scan(N);
	int ans=1;
	int nozoku=1;
	rep(i,N){
		scan(A[i]);
		ans*=3;
		if(A[i]%2==0) nozoku*=2;
	}
	prin(ans-nozoku);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  string s;
  cin >> s;

  vector<int> L(N+2, 0);
  REP(i, N) L[i+1] += L[i]+((s[i] == 'W')? 1: 0);

  vector<int> R(N+1, 0);
  RREP(i, N) R[i] += R[i+1]+((s[i] == 'E')? 1: 0);

  int ans = INF;
  REP(i, N){
    chmin(ans, L[i]+R[i+1]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5380
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 300100;

vector<pair<int, vector<int>>> g;
pair<int, vector<int>> v[MAX];
int dad[MAX], id[MAX];
int idx[MAX];
bool dead[MAX];

int findset(int x) {
  return x == dad[x] ? x : dad[x] = findset(dad[x]);
}

int pos;
void dfs(int x) {
  if (g[x].second.size() == 1) {
    idx[pos++] = g[x].first;
    return;
  }
  for (int y: g[x].second) dfs(y);
}

int main(void) {
  int n, m, q;
  while (scanf("%d %d %d", &n, &m, &q) == 3) {
    if (n == 0) break;

    REP(i, m) {
      scanf("%d", &v[i].first);
      int k; scanf("%d", &k);
      v[i].second.resize(k);
      REP(j, k) {
        scanf("%d", &v[i].second[j]);
        --v[i].second[j];
      }
    }

    sort(v, v + m);
    g.clear();
    REP(i, n) {
      g.push_back({i, {i}});
      id[i] = i;
      dad[i] = i;
      dead[i] = false;
    }

    for (int j = m-1; j >= 0; --j) {
      vector<int> w;
      for (int x: v[j].second) w.push_back(id[findset(x)]);
      sort(w.begin(), w.end(), [&] (const int& a, const int& b) {
          return g[a].first < g[b].first;
        }
      );
      
      int par = findset(v[j].second[0]);
      for (int x: v[j].second) dad[findset(x)] = par;
      id[par] = g.size();
      dead[g.size()] = false;
      for (int x: w) dead[x] = true;
      g.push_back({g[w[0]].first, w});
    }
    
    vector<int> w;
    REP(i, (int)g.size())
      if (!dead[i]) w.push_back(i);
    sort(w.begin(), w.end(), [&] (const int& a, const int& b) {
        return g[a].first < g[b].first;
      }
    );
    
    pos = 0;
    for (int x: w) dfs(x);

    REP(i, q) {
      int x;
      scanf("%d", &x); --x;
      printf("%d\n", idx[x]+1);
    }
    putchar('\n');
  }
  
  return 0;
}

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



ll mod = 1000000007;
ll modpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll com(ll a, ll b){
	ll res = 1;
	b = min(b, a-b);
	ll n = b;
	for(int i=0; i<n; i++){
    	res *= a;
    	if(res >= mod) res %= mod;
    	res *= modpow(b, mod-2);
    	if(res >= mod) res %= mod;
    	a--;
    	b--;
    }
	return res;
}

int main(){
    int a, b;
    cin >> a >> b;
    ll ans = 0;
    if(a >= 2){
        ans += com(a,2);
    }
    if(b >= 2){
        ans += com(b,2);
    }
    cout << ans << endl;
    return 0;
}


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.next());

      int[] L = new int[n];
      for(int i=0;i<n;i++){
        L[i] = Integer.parseInt(sc.next());
      }
      Arrays.sort(L);
      /*
      System.out.println("");
      for(int i=0;i<n;i++){
        System.out.print(L[i]+" ");
      }
      System.out.println("");
      */

      int ans = 0;

      for(int i=n-1;i>=0;i--){
        for(int j=i-1;j>=0;j--){
//////////////////////////////////////////////////////

int start = 0;
int end = j;
int sa = L[i]-L[j];
int cnt = -1;
while(true){
  int a = start+end;
  int mid = a/2;
  if(L[mid]>sa){ //L[mid以降]は使える。
    end = mid;
  }
  else if(L[mid]<=sa){ //L[mid以前]は使えない
    start = mid;
  }

  if(a==(start+end) && L[mid]>sa){
    cnt = mid;  //L[mid以降]は使えることの記録。
    //System.out.println(L[i]+","+L[j]+"のとき"+L[cnt]+"が最小の棒。"+"saは"+sa);
    break;
  }
  if(a==(start+end) && L[mid+1]>sa){
    cnt = mid+1;  //L[mid+1以降]は使えることの記録。
    //System.out.println(L[i]+","+L[j]+"のとき"+L[cnt]+"が最小の棒。"+"saは"+sa);
    break;
  }
  if(a==(start+end) && L[mid]<=sa){
    break;
  }
}
//使えるのはL[j]の次に小さいやつまでなので、
/*
int aaa = 0;
if(cnt!=-1){
  for(int k=j;k>0;k--){
    if(L[k]!=L[k-1]){ //L[k-1]から使える。
      aaa = (k-1)-(cnt)+1;
      ans += aaa;
      break;
    }
  }
  System.out.println(aaa+"個加算。");
}
*/
if(cnt!=-1 && j>=1){ //i=2,j=1,k=0が最小の組み合わせ
  ans += (j-1)-(cnt)+1;
  //System.out.println(((j-1)-(cnt)+1)+"個加算。");
}

//////////////////////////////////////////////////////
        }
      }


      System.out.println(ans);

    }
}


Measured memory_bytes: 27060