akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2700&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int n;
ll solve(){
    ll res = -1;
    vector<string> name(n); for(auto& in:name) cin >> in;
    string aiueo = "aiueo";
    for(int k = 1; k <= 50; k++){
        set<string> s;
        for(int i = 0; i < n;i++){
            string T; T += name[i][0];
            for(int j = 0; j < name[i].length()-1;j++){
                if(T.length() == k) break;
                if(aiueo.find(name[i][j]) != string::npos) T += name[i][j+1];
            }
            s.insert(T);
        }
        if(s.size() == n) return k;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> n,n){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll tc;
	cin >> tc;
	map<string,int>mp;
	while(tc--)
	{
		string str;
		cin >> str;
		++mp[str];
	}
	cout << "AC x " << mp["AC"] <<"\n";
	cout << "WA x " << mp["WA"] <<"\n";
	cout << "TLE x "<< mp["TLE"] <<"\n";
	cout << "RE x " << mp["RE"] <<"\n";
	
	
	
	return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>

using namespace std;

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

    long long sum = 0;
    long long prev_ti = -1;
    for (int i = 0; i < N; i++) {
        long long ti;
        cin >> ti;
        if (prev_ti != -1) {
            sum += min(ti - prev_ti, T);
        }
        prev_ti = ti;
    }
    sum += T;

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A + 1):
    x = 500 * i
    if x == X:
        ans += 1
        break
    elif x > X:
        break
    for j in range(B + 1):
        x = 500 * i + 100 * j
        if x == X:
            ans += 1
            break
        elif x > X:
            break
        for k in range(C + 1):
            x = 500 * i + 100 * j + 50 * k
            if x == X:
                ans += 1
print(ans)



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 999999999
#define MAX_V 100000
#define llong long long

int main()
{
    int n;
    cin >> n;
    cout << 180 * (n - 2) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  vector<ll> b;
  ll ans = a[0];
  for(int i = 1; i < ((n + 1) / 2); i++) {
    ans += a[i];
  }
  for(int i = 1; i < (n / 2); i++) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

/*
 * Constraints:
 * n = 1e10
 */

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

	ll n;
	cin >> n;
	int mn = 1e9;

	for(ll i = 1; i*i <= n; i++)
	{
		if (n%i == 0)
		{
			ll a = i, b = n / i;
			int c1 = 0, c2 = 0;
			while(a)
			{
				a/=10;
				c1++;
			}

			while(b)
			{
				b/=10;
				c2++;
			}
			mn = min(mn, max(c1, c2));
		}
	}

	cout << mn << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int N;
    int k = 0;
    cin >> N;
    while(k * (k + 1) < 2 * N){
        k ++;
    }
    int rm = k * ( k + 1) / 2 - N;
    for(int i = 1; i <= k; i ++){
        if(i != rm){
            cout << i << " ";
        }
    }
    cout << endl;

    return 0;
}


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

int main(){
  int N, n, d;
  int w, h, i;

 
  while(1){
    int k[300][4] = {};
    int wl = 0, wr = 1, hu = 1, hs = 0;

     k[0][0] = 0;
     k[0][1] = 0;
     k[0][2] = 1;
     k[0][3] = 1;

    cin>>N;
    
    if(N == 0) break;
    
    for(i = 1; i < N; i++){
      cin>>n>>d;
      if(d == 0){
	k[i][0] = k[n][0] - 1;
	k[i][1] = k[n][1];
	k[i][3] = k[n][3];
	k[i][2] = k[n][2] - 1;
	if(k[i][0]<= wl) wl = k[i][0];
	
      }else if(d == 2){
	k[i][2] = k[n][2] + 1;
	k[i][0] = k[n][0] + 1;
	k[i][1] = k[n][1];
	k[i][3] = k[n][3];
	if(k[i][2] >= wr) wr = k[i][2];
	
      }else if(d == 1){
	k[i][1] = k[n][1] - 1;
	k[i][3] = k[n][3] - 1;
	k[i][0] = k[n][0];
	k[i][2] = k[n][2];
	if(k[i][1]<= hs) hs = k[i][1];
	
      }else if(d == 3){
	k[i][3] = k[n][3] + 1;
	k[i][1] = k[n][1] + 1;
	k[i][0] = k[n][0];
	k[i][2] = k[n][2];
	if(k[i][3] >= hu) hu = k[i][3];
	
      }
    }

    w = wr - wl;
    h = hu - hs;

    cout<<w<<" "<<h<<endl;;
    
  }

  
  return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
set<int> s;
void dfs(int n,int num,int flag1,int flag2,int flag3)
{
	if(num > 9)
	{
		return;
	}
	if(flag1 && flag2 && flag3)
	{
		s.insert(n);
	}
	dfs(n * 10 + 3,num + 1,1,flag2,flag3);
	dfs(n * 10 + 5,num + 1,flag1,1,flag3);
	dfs(n * 10 + 7,num + 1,flag1,flag2,1);
}
vector<int> v;
int main(int argc, char const *argv[])
{
	dfs(3,1,1,0,0);
	dfs(5,1,0,1,0);
	dfs(7,1,0,0,1);
	int n;
	cin>>n;
	for(auto it = s.begin();it != s.end(); ++it)
	{
		v.push_back(*it);
	}
	int pos = upper_bound(v.begin(),v.end(),n) - v.begin();
	cout<<pos<<endl;
	return 0;
}


Measured memory_bytes: 1664
/*
#include <iostream>
#include <queue>

using namespace std;

int main() {
	int n;
	int h;
	queue<int> cola;

	cin >> n; cin >> h;
	int *a = new int[n];
	int aux = 0;
	int k = n / h;
	int **matriz = new int*[k];
	for (int i = 0; i < k; i++) {
		matriz[i] = new int[h];
	}
	for (int i = 0; i<n; i++)
	{
		cin >> a[i];
	}
	if (n%h==0){
		
		for (int i=0;i<n;i++)
		{
			for (int j=i+1;j<n;j++)
			{
				if(a[i]>a[j])
				{
					aux = a[i];
					a[i] = a[j];
					a[j] = aux;
				}
			}
			cola.push(a[i]);
		}
		int p = 0;
		for (int i = 0; i < n; i++)
		{
			int cont = 1;
			for (int j = i + 1; j < n; j++)
			{
				if (a[i] == a[j])
					{
						cont += 1;
						if (cont > k)
						{
							cout << "impossible" << endl;
							system("pause");
							return 0;
						}
					}
				else { break; }
			}
							
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < k; j++) {
				matriz[j][i] = cola.front();
				cola.pop();
			}
		}
		for (int i = 0; i < k; i++) {
			for (int j = 0; j < h; j++) {
				cout << matriz[i][j] <<" ";
			}
			cout << endl;
		}
		
	}
	else 
	{
		cout << "impossible" << endl;
		system("pause");
		return 0;
	}


	system("pause");
	return 0;
}*/
/*
	#include <cmath>
	#include <cstdio>
	#include <vector>
	#include <iostream>
	#include <algorithm>
	#include <string>
	#include <stack>
	#include <map>
	using namespace std;


	int main() {
		int N;
		int T;
		cin >> N;
		cin >> T;
		vector<int>primero;
		vector<int>segundo;

		for (int i = 0; i < N; i++) {
			int costo, tiempo;
			cin >> costo; cin >> tiempo;
			primero.push_back(costo);
			segundo.push_back(tiempo);
		}
		vector<int>elegido1;
		vector<int>elegido2;
		for (int i = 0; i < N; i++) {
			if (segundo[i] <= T) {
				elegido1.push_back(primero[i]);
				elegido2.push_back(segundo[i]);
			}
		}
		if (elegido1.empty()) {
			cout << "TLE" << endl;
			
			return 0;
		}
		int min = std::min_element(elegido1.begin(), elegido1.end()) - elegido1.begin();
		cout << elegido1[min];
		
		return 0;
	}*/


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <map>
using namespace std;

int main() {
	int N ;
	cin >> N;
	vector<int>T;
	for (int i = 0; i < N; i++) {
		int t;
		cin >> t;
		T.push_back(t);
	}
	int M; cin >> M;
	vector<int>P;
	vector<int>X;

	for (int i = 0; i < M; i++) {
		int p,x;
		cin >> p;
		cin >> x;
		P.push_back(p);
		X.push_back(x);
	}
	
	
	for (int i = 0; i < M; i++) {
		
		vector<int>aux;
		aux = T;
		aux[P[i]-1] = X[i];
		int suma = 0;
		for (int j = 0; j < N; j++) {
			suma += aux[j];
		
		}
		cout << suma << endl;
	}

	return 0;
}

Measured memory_bytes: 256
str = gets
l = str[0, 2].to_i
r = str[2, 2].to_i

def valid_month?(i)
  i >= 1 && i <= 12
end

def valid_year?(i)
  i >= 0 && i <= 100
end

if valid_month?(l) && valid_month?(r)
  puts "AMBIGUOUS"
elsif valid_year?(l) && valid_month?(r)
  puts "YYMM"
elsif valid_month?(l) && valid_year?(r)
  puts "MMYY"
else
  puts "NA"
end

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

int main(){
    string s;
    cin >> s;
    int nagasa = s.size();   //cout << s[0] + nagasa-2 + s[nagasa] << endl;
    cout << s[0];
    cout << nagasa-2;
    cout << s[nagasa-1] << endl;
}

Measured memory_bytes: 256
xkd = gets.chomp.split
x = xkd[0].to_i
k = xkd[1].to_i
d = xkd[2].to_i

if x.abs >= k * d
    if x > 0
        puts x - (k * d)
    else
        puts (x + (k * d)).abs
    end
    
else
    k -= (x / d)
    x -= (x / d) * d
    x -= d if k.odd?
    puts x.abs
end


Measured memory_bytes: 14376
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int sum=0,k,i=0,n;
	cin>>n;
	long long int a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
	{
		if(a[i]>a[i+1] && (i+1)<n)
		{
			sum+=a[i]-a[i+1];
			a[i+1]=a[i];

		}
	}
	
	cout<<sum<<endl;


}


Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=2e5+1;
const ll INF=1e16;
const ll MOD=1e9+7;
void solve()
{
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes\n";
	else cout<<"No\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1;
	//cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : template.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

// int main() {
// 	ios::sync_with_stdio(false);
//  cin.tie(0);
//  int n,x,t; cin >> n >> x >> t;
//  int ans = ((n + x -1) / x) * t;
//  cout << ans << "\n";
// return 0;
// }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	ll sm = 0;
	cin >> s;
	forn(i, s.length()) {
		int c = s[i] - '0';
		sm += c;
	}
	if (sm % 9 == 0) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

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

	int ans=0;
	int prevcount=0;
	int count=1;
	bool flg=0;
	char prevchar=S[0];
	for(int i=1; i<S.length(); i++){
		if(S[i]==prevchar){
			count++;
		}else{
			ans+=(count-(count+1)/3);
			if(flg==1 && count%3==2){
				ans++;
				prevcount=count-1;
			}else if(flg==2 && count%3==2){
				ans++;
				prevcount=count-1;
				flg=0;
			}else{
				prevcount=count;
			}
			if(prevcount%3==2){
				flg=1;
			}else if(flg==1 && prevcount%3==0){
				flg=2;
			}else if(flg==2 && prevcount%3==0){
				flg=2;
			}else{
				flg=0;
			}
			count=1;
		}
		prevchar=S[i];
	}
	ans+=(count-(count+1)/3);
	if(flg==1 && count%3==2){
		ans++;
	}else if(flg==2 && count%3==2){
		ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 1005;

char str[MAXN][MAXN];

void Do1(int l, int r, char c){
	vector<pi> v;
	for(int i=l; i<r; i++) v.emplace_back(l, i);
	for(int i=l; i<r; i++) v.emplace_back(i, r);
	for(int i=r; i>l; i--) v.emplace_back(r, i);
	for(int i=r; i>l; i--) v.emplace_back(i, l);
	for(int i=0; i<sz(v); i+=2){
		str[v[i].first][v[i].second] = c;
		str[v[i+1].first][v[i+1].second] = c;
		c ^= 1;
	}
	str[v[0].first][v[0].second] = c + 2;
	str[v[1].first][v[1].second] = c + 2;
}

int n;
void Do2(int x, int y){
	for(int i=0; i<n; i+=2){
		str[x+i][y+i] = str[x+i+1][y+i] = 'a';
		str[x+i][y+i+1] = str[x+i+1][y+i+1] = 'b';
	}
	for(int i=0; i<n; i+=2){
		str[x+i][y+(i+2)%n] = str[x+i][y+(i+3)%n] = 'c';
		str[x+i+1][y+(i+2)%n] = str[x+i+1][y+(i+3)%n] = 'd';
	}
}

int vis[8][8];
int piv, sx[9], sy[9];

void dfs(int x, int y){
	if(x == n){
		set<int> t;
		for(int i=0; i<7; i++){
			t.insert(sx[i]);
			t.insert(sy[i]);
		}
		if(sz(t) == 1){
			for(int i=0; i<7; i++){
				for(int j=0; j<7; j++){
					printf("%d ", vis[i][j]);
				}
				puts("");
			}
			exit(0);
		}
		return;
	}
	if(y == n){
		if(sx[x]) dfs(x + 1, 0);
		return;
	}
	if(vis[x][y]){
		dfs(x, y + 1);
		return;
	}
	if(x + 1 < n && sx[x] < 3 && sx[x+1] < 3 && sy[y] < 3){
		piv++;
		vis[x][y] = piv; vis[x+1][y] = piv;
		sx[x]++;
		sx[x+1]++;
		sy[y]++;
		dfs(x, y + 1);
		vis[x][y] = vis[x+1][y] = 0;
		sx[x]--;
		sx[x+1]--;
		sy[y]--;
		piv--;
	}
	if(y + 1 < n && sx[x] < 3 && sy[y] < 3 && sy[y+1] < 3){
		piv++;
		vis[x][y] = piv; vis[x][y+1] = piv;
		sx[x]++;
		sy[y]++;
		sy[y+1]++;
		dfs(x, y + 1);
		sx[x]--;
		sy[y]--;
		sy[y+1]--;
		vis[x][y] = vis[x][y+1] = 0;
		piv--;
	}
	dfs(x, y + 1);
}

int main(){
	cin >> n;
	if(n == 2){
		puts("-1");
		return 0;
	}
	if(n == 7){
		puts("abc....");
		puts("abc....");
		puts("def....");
		puts("def....");
		puts("g..hhii");
		puts("g..jjkk");
		puts(".llmmnn");
		return 0;
	}
	if(n == 3){
		puts("xx.");
		puts("..y");
		puts("..y");
		return 0;
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			str[i][j] = '.';
		}
	}
	if(n % 2 == 1){
		string ans[5] = {"ppqqp", "qx..p", "qx..q", "p.yyq", "pqqpp"};
		n -= 5;
		Do2(0, 0);
		for(int i=0; i<5; i++){
			for(int j=0; j<5; j++){
				str[i+n][j+n] = ans[i][j];
			}
		}
		n += 5;
	}
	else{
		Do2(0, 0);
	}
	for(int i=0; i<n; i++) puts(str[i]);
}


Measured memory_bytes: 2176
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<pii> v(n);
	For(i,0,n-1){
		cin>>v[i].F; v[i].S=i;
	}
	set<int> now;
	sort(all(v)); reverse(all(v));
	now.insert(v[0].S);
	For(i,-2,-1) now.insert(i);
	For(i,n,n+1) now.insert(i);
	int ans=0;
	For(i,1,n-1){
		now.insert(v[i].S);
		set<int>::iterator it=now.lower_bound(v[i].S);
		//for(auto &i:now) cout<<i<<" "; cout<<"\n";
		int tmp=0;
		if(*next(it)!=n) tmp+=((*it)-(*(prev(it))))*((*(next(it,2)))-(*next(it)));
		//else tmp+=((*it)-(*(prev(it))))*(n-*it-1);
		//cout<<tmp<<" ";
		if(*prev(it)!=-1) tmp+=((*(next(it)))-(*it))*((*prev(it))-(*(prev(it,2))));
		//cout<<tmp<<"\n";
		ans+=tmp*v[i].F;
	}
	cout<<ans<<"\n";
	return 0;
}





























Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

/*
author: Basel
*/

using namespace std;

string s;

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


Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


# inputs
N = 0
A, B, C = [0], [0], [0]


def set_inputs():
    global N, A, B, C
    N = get_int()
    a, b, c = [], [], []
    for _ in range(N):
        x, y, z = get_list_of_int()
        a.append(x)
        b.append(y)
        c.append(z)
    A, B, C = a, b, c


def main():
    set_inputs()
    happiness = [(A[0], B[0], C[0])]
    for i in range(1, N):
        h = happiness[i-1]
        a = max(h[1], h[2]) + A[i]
        b = max(h[0], h[2]) + B[i]
        c = max(h[0], h[1]) + C[i]
        happiness.append((a, b, c))
    print(max(happiness[N-1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 75224
#include <iostream>
#include <string>

int main(void){
  long H,W;
  long ans;
  std::cin >> H;
  std::cin >> W;
  
  if(H == 1 || W == 1){
    ans = 1;
  }
  else{
  ans = H * W / 2;
  if(H % 2 == 1 && W % 2 == 1){
    ans++;
  }
  }
  std::cout << ans << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
bool check1 (string x) {
    if (x.at(0) == 'A') { 
        return true;
    }
    return false;
}
bool check2 (string x) {
    int cap_count = 0;
    for (int i=0; i< (int)x.size(); i++) {
        if (isupper(x.at(i))) {
            cap_count += 1;
        }
    }
    if (cap_count == 2) {
        return true;
    }
      return false;
}

bool check3 (string x) {
    int c_count = 0;
      for (int i=2; i<= (int)x.size()-2;i++) {
        if (x.at(i) == 'C') {
          c_count += 1;
        }
      }
      if (c_count == 1) {
        return true;
      }
      return false;
    }

int main() {
    string s;
    cin >> s;
       if (check1(s) && check2(s) && check3(s)) {
        cout << "AC" << endl;
    }else {
        cout << "WA" << endl;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.Exception
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val s = sc.nextLine()
    val r = s.count { it == 'R' }
    val w = n - r
    if (r == 0 || w == 0) {
        println(0)
    } else {
        val num = s.substring(0, r).count { it == 'W' }
        println(num)
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int h = sc.nextInt();
		int w = sc.nextInt();

		char[][] s = new char[h][];
		for (int i = 0; i < h; i++) {
			s[i] = sc.next().toCharArray();
		}

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

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '#') {
					continue;
				}

				int cnt = 0;
				for (int k = 0; k < dn; k++) {
					int x = j + dx[k];
					int y = i + dy[k];

					if (x < 0 || x >= w || y < 0 || y >= h) {
						continue;
					}

					if (s[y][x] == '#') {
						cnt++;
					}
				}

				s[i][j] = (char)('0' + cnt);
			}
		}

		for (int i = 0; i < h; i++) {
			pr.println(s[i]);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23252
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2e5+10,mo=1e9+7;
long long f[N];
int las[N];
int main()
{
	int n;
	scanf("%d",&n);
	f[0]=1;
	for (int i=1;i<=n;i++) 
	{
		int x;
		scanf("%d",&x);
		f[i]=f[i-1];
		if (las[x]&&las[x]<i-1) f[i]=(f[i]+f[las[x]])%mo;
		las[x]=i;
	}
	printf("%lld\n",f[n]);
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <vector>
using namespace std;
int main(){
    string s;
    cin>>s;
    int c=0;
    for(int i=1;i<s.size();i++){
        if(s[i]!=s[i-1])c++;
    }
    cout<<c<<endl;
    return 0;
}


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

int main()
{
	int N = 50; //タコ焼きの個数
	int array[50] = { 0 }; //タコ焼きのおいしさの配列
	
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> array[i];
	}
	
	//タコ焼きのおいしさの合計を求める
	int tastesum = 0;
	for (int j = 0; j < N; j++) {
		tastesum += array[j];

	}
	//cout << tastesum << endl;

	//タコ焼きおいしさ二乗
	int tasteselfsquare = 0;
	for (int j = 0; j < N; j++) {
		tasteselfsquare += pow(array[j], 2);

	}
	//cout << tasteselfsquare << endl;

	//体力回復値
	int heal = 0;
	heal = (pow(tastesum, 2) - tasteselfsquare) / 2;

	cout << heal << 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 = sc.nextInt();

        int[] m = new int[n];
        for(int i = 0;i < n;i++){
            m[i] = sc.nextInt();
        }

        int count = 0;
        int ans = 0;
        for(int i = 1;i < n;i++){
            if(m[i-1] >= m[i]){
                count++;
            } else {
                ans = Math.max(ans, count);
                count = 0;
            }
        }

        System.out.println(Math.max(ans, count));
    }
}

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

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

  double ans = 0;
  for (int i = 1; i <= n; i++) {
    double prob = 1.0 / n;

    double num_coin = i;
    while(num_coin < k) {
      num_coin *= 2;
      prob /= 2;
    }

    ans += prob;
  }

  printf("%.12f\n", ans);
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    double R;
    cin >> R;
    cout << 2*R*M_PI << endl;
    return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;

int n, k;
int a[N];
int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++)  scanf("%d", &a[i]);
	printf("%d\n", (n - 1 + k - 2) / (k - 1));
	return 0;
} 

Measured memory_bytes: 4212
#include <vector>
#include <queue>

// Use Dijkstra(ver: priority_queue<>) in most case.
// This has better performance than Dijkstra(ver: set<>).
// Memory: O(V + E)
// NOTE: directed, multi-edge, self-loop, no-negative-weight
class Dijkstra {
    struct edge { int to; long long distance; };
    int N;
    std::vector<std::vector<edge>> adj;

public:
    static const long long inf;
    // O(V)
    Dijkstra(int n = 0) : N(n), adj(n) {
    }
    // O(1)
    int size() {
        return N;
    }
    // O(1)
    void add_edge(int from, int to, long long distance) {
        throw_if_invalid_index(from);
        throw_if_invalid_index(to);
        if (distance < 0) throw;
        adj[from].push_back({ to, distance });
    }
    // O(V logV + E)
    void solve(int s, std::vector<long long>& D, std::vector<int>& P) {
        D.assign(N, inf);
        P.assign(N, -1);

        using pii = std::pair<int,int>;
        std::priority_queue<pii, std::vector<pii>, std::greater<pii>> Q;
        std::vector<bool> used(N, false);

        D[s] = 0;
        Q.push({0, s});

        while (!Q.empty()) {
            int v = Q.top().second; Q.pop();

            if (used[v]) continue;
            used[v] = true;

            for (auto edge : adj[v]) {
                int to = edge.to; long long len = edge.distance;
                if (D[v] + len < D[to]) {
                    D[to] = D[v] + len;
                    P[to] = v;
                    Q.push({D[to], to});
                }
            }
        }
    }

private:
    void throw_if_invalid_index(int index) {
        if (index < 0 || index >= N) throw "index out of range";
    }
};
const long long Dijkstra::inf = 1e18;


#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

using namespace std;

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

    int N, M;
    cin >> N >> M;
    Dijkstra solver(N);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        --A, --B;
        solver.add_edge(A, B, 1);
        solver.add_edge(B, A, 1);
    }

    vector<long long> D;
    vector<int> P;
    solver.solve(0, D, P);

    for (int i = 1; i < N; ++i) {
        if (P[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < N; ++i) {
        cout << P[i]+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 17920
import java.util.*;

public class Main {

  static Scanner scan = new Scanner(System.in);

  public static void main(String[] args) {
    int n = scan.nextInt();

    Set<String> words = new HashSet<>();

    for (int i = 0; i < n; i++) {
      words.add(scan.next());
    }


    System.out.println(words.size());
  }
}


Measured memory_bytes: 66424
s1 = input()
s2 = input()
di1 = {} #s1 → s2 の対応表
di2 = {} #s2 → s1 の対応表

ans = "Yes"
for c1,c2 in zip(s1,s2):
    if c1 not in di1:
        di1[c1] = c2
    else:
        if di1[c1] != c2:
            ans = "No"

    if c2 not in di2:
        di2[c2] = c1
    else:
        if di2[c2] != c1:
            ans = "No"

print(ans)

Measured memory_bytes: 3632
#include<iostream>
#include<queue>

using namespace std;

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

    std::priority_queue<int, std::vector<int>, std::less<int>> que;
    
    long int temp;
    for (int i = 0; i < N; i++)
    {
        cin >> temp;
        que.push(temp);
    }
    for (int i = 0; i < M; i++)
    {
        que.push(que.top() / 2);
        que.pop();
    }
    
    temp = 0;
    while (!que.empty())
    {
        temp += que.top();
        que.pop();
    }
    
    cout << temp;
    
    return 0;
    
}

Measured memory_bytes: 892
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  int a[H][W];
  FOR(i,0,H) FOR(j,0,W) cin >> a[i][j];
  bool start = false;
  int dx = 1, dy = 0;
  vector<string> ans;
  FOR(y,0,H) {
    if(y % 2 == 0) {
      dx = 1;
      dy = 0;
      FOR(x,0,W) {
        if(x == W - 1) {
          dx = 0;
          dy = 1;
        }
        if(a[y][x]%2==1) {
          start ^= 1;
        }
        if(start && y + dy < H) {
          ans.push_back(to_string(y + 1) + " " + to_string(x + 1) + " " + to_string(y + dy + 1) + " " + to_string(x + dx + 1));
        }
      }
    } else {
      dx = -1;
      dy = 0;
      for(int x = W - 1; x >= 0; x--) {
        if(x == 0) {
          dx = 0;
          dy = 1;
        }
        if(a[y][x]%2==1) {
          start ^= 1;
        }
        if(start && y + dy < H) {
          ans.push_back(to_string(y + 1) + " " + to_string(x + 1) + " " + to_string(y + dy + 1) + " " + to_string(x + dx + 1));
        }
      }
    }
  }
  cout << ans.size() << endl;
  FOR(i,0,ans.size()) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 11892
#include <stdio.h>

int main(void)
{
	int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, day, monthi, i;
	
	while (1){
		scanf("%d %d", &monthi ,&day);
		if (monthi == 0) break;
		
		for (i = 0; i < monthi - 1; i++){
			day += month[i];
		}
		day %= 7;
		switch (day){
			case 1:
			printf("Thursday\n");
			break;
			case 2:
			printf("Friday\n");
			break;
			case 3:
			printf("Saturday\n");
			break;
			case 4:
			printf("Sunday\n");
			break;
			case 5:
			printf("Monday\n");
			break;
			case 6:
			printf("Tuesday\n");
			break;
			case 0:
			printf("Wednesday\n");
			break;
		}
	}
	return (0);
}

Measured memory_bytes: 584
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        int size = N.length();
        char[] a = N.toCharArray();
        int result1 = -1;
        int result2 = -1;
        
        for(int i=0;i<size-1;i++){
            char x = a[i];
            if(x == a[i+1]){
                result1 = i+1;
                result2 = i+2;
                break;
            }
            if(i<=size-3&&x == a[i+2]){
                result1 = i+1;
                result2 = i+3;
                break;
            }
        }
        

        System.out.println(result1+" "+result2);
    }
    
    
}


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

int main(){
  int N,K,ans = 0;
  cin >> N >> K;
  vector<int>vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
    ans += min(vec[i]*2,(K-vec[i])*2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n, m, k;
    vector< vector<int> > edg;
    cin >> n;
    m = n/2;
    k = m * (m-1) * 2;
    if(n%2 == 1) k += m * 2;

    cout << k << endl;

    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(i+j != m*2+1){
                cout << i << " " << j << endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/math>
using namespace std;
using namespace atcoder;
const long long INF = 1000000000000000000;
vector<long long> prime(long long N){
  vector<long long> ans;
  for (long long i = 2; i * i <= N; i++){
    if (N % i == 0){
      long long tmp = 1;
      while (N % i == 0){
        tmp *= i;
        N /= i;
      }
      ans.push_back(tmp);
    }
  }
  if (N != 1){
    ans.push_back(N);
  }
  return ans;
}
int main(){
  long long N;
  cin >> N;
  N *= 2;
  vector<long long> pf = prime(N);
  int cnt = pf.size();
  long long ans = INF;
  for (int i = 0; i < (1 << cnt); i++){
    vector<long long> r(cnt, 0);
    for (int j = 0; j < cnt; j++){
      if (i >> j & 1){
        r[j] = pf[j] - 1;
      }
    }
    pair<long long, long long> A = crt(r, pf);
    if (A.second != 0){
      if (A.first == 0){
        ans = min(ans, A.second);
      } else {
        ans = min(ans, A.first);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

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

    vector<ll> A(N), B(M);
    rep (i, N) { cin >> A[i]; }
    rep (i, M) { cin >> B[i]; }

    ll s = 0, ai = 0, bi = 0;
    while (ai < N && s + A[ai] <= K) { s += A[ai]; ++ai; }
    while (bi < M && s + B[bi] <= K) { s += B[bi]; ++bi; }

    ll ans = ai + bi;

    while (ai > 0 && bi < M)
    {
        --ai;

        s -= A[ai];
        while (bi < M && s + B[bi] <= K) { s += B[bi]; ++bi; }

        ans = max(ans, ai + bi);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main (){
    LL d,n;
    cin>>d>>n;
    if (n==100 && d==0) cout <<101 <<endl;
    else
    if (d==0) cout <<n <<endl;
    else if (d==1 && n==100) cout <<10100<<endl;
    else if (d==1) cout <<n*100<<endl;
    else if (d==2 && n==100) cout <<1010000<<endl;
    else cout <<n*10000 <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	int N;
	double s=0;
	vector<double> A;
	cin >> N;

	for(int i=0;i<N;i++){
		double t;
		cin >> t;
		A.push_back(t);
	}

	sort(A.begin(),A.end());

	do{
		s=(A[0]+A[1])/2;
		A.push_back(s);
		A.erase(A.begin());
		A.erase(A.begin());
		sort(A.begin(),A.end());
	}while(A.size()!=1);

	cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    int ans = 15-(int)s.size();
    for (auto &&i : s) {
        if(i == 'o') ans++;
    }
    puts(ans >= 8 ? "YES" : "NO");
    return 0;
}

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

int main(){


	int t = 1;
	//cin >> t;
	while(t--){
		int n;
		cin >> n;
		std::vector<int> v(216001, 0);
		for(int i = 1; i <= 10000; i++){
			for(int j = 1; j <= 10000; j++){
				for(int k = 1; k <= 10000; k++){
					/*int a = i + j, b = j + k, c = k + i;
					a = a*a;
					b = b*b;
					c = c*c;
					ll p = a+b+c;
					if(p >= 20000){
						break;
					}
					if(p%2 == 0){
						p /= 2;
						v[p]++;
					}*/
					ll p = i*i + j*j + k*k + i*j + i *k + j*k;
					if(p>10000){
						break;
					}
					else{
						v[p]++;
					}
				}
			}
		}
		for(int i = 1; i <= n; ++i){
			cout << v[i] << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 3916
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
struct edge{int from,to,cost;};
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
//aが何個使われ、bがb個使われた時点での最善を考えます
int ai[100111];
int n,m;
signed main(){
    cin>>n;
    ai[0]=0;
    int sum=0;
    int kyo[114514];
    rep(i,1,n+1){
        cin>>ai[i];
        kyo[i]=abs(ai[i]-ai[i-1]);
        sum+=abs(ai[i]-ai[i-1]);
    }
    sum+=abs(ai[n]);
    kyo[n+1]=abs(ai[n]);
    rep(i,1,n+1){
        cout<<sum-kyo[i]-kyo[i+1]+abs(ai[i+1]-ai[i-1])<<endl;
    }
    return 0;
}

Measured memory_bytes: 2816
//https://atcoder.jp/contests/abc057/tasks/abc057_c
//2019-08-15()
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int GetDigit(long num){
    long i = 10;
    int dig = 1;
    while(num/i>0){
        i *= 10;
        dig ++;
    }
    return dig;
}

int main()
{
    long num;
    scanf("%ld",&num);
    long ans = 1e10 + 2;
    for(int i=1;i<=sqrt(num);i++){
        if(num%i==0){
            if(GetDigit(num/i)<ans){
                ans = GetDigit(num/i);
            }
        }
    }
    printf("%ld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n,int a[500]) {
    f1(i,n) {
        if(a[i]%2==0) {
            if(a[i]%3!=0 &&a[i]%5!=0) {
                return false;
            }
        }
    }
    return true;
}


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int n;
    cin>>n;
    int a[n];
    f1(i,n) {
        cin>>a[i];
    }
    (check(n,a))?cout<<"APPROVED"<<endl:cout<<"DENIED"<<endl;
    
    return 0;
}

Measured memory_bytes: 3596
l=STDIN.readlines.map(&:chomp)
a_list=l[1].split(' ').map(&:to_i)
b_list=l[2].split(' ').map(&:to_i)
c_list=l[3].split(' ').map(&:to_i)
score=0
a_list.each_with_index do |a,i|
  score+=b_list[a-1]
  if(i>0 && a_list[i-1]+1==a)
    score+=c_list[a_list[i-1]-1]
  end
end
print(score)

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

import math
import sys
import heapq
from operator import itemgetter
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':

cities = dict()
N, M = map(int, input().rstrip().split())
for i in range(M):
	p, y = map(int, input().rstrip().split())
	if p not in cities:
		cities[p] = [[i, y]]
	else:
		cities[p].append([i, y])

heap_q = []	
for i in cities:
	tmp = sorted(cities[i], key=lambda x: x[1])
	for j in range(len(tmp)):
		heapq.heappush(heap_q, (tmp[j][0], i, j+1))

for i in range(M):
	x, y, z = heapq.heappop(heap_q)
	print(str(y).zfill(6) + str(z).zfill(6))

Measured memory_bytes: 46968
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int C = scanner.nextInt();
    int D = scanner.nextInt();
    int E = scanner.nextInt();
    int F = scanner.nextInt();
    boolean[] water = new boolean[F + 1];
    boolean[] sugar = new boolean[F + 1];
    water[0] = true;
    sugar[0] = true;
    for (int i = 1; i <= F; i++) {
      if (i >= 100 * A) water[i] |= water[i - 100 * A];
      if (i >= 100 * B) water[i] |= water[i - 100 * B];
    }
    for (int i = 1; i <= F; i++) {
      if (i >= C) sugar[i] |= sugar[i - C];
      if (i >= D) sugar[i] |= sugar[i - D];
    }

    int maxT = A * 100, maxS = 0;
    for (int i = 1; i <= F; i++) {
      for (int j = 1; j <= F; j++) {
        if (water[i] && sugar[j] && i + j <= F && j <= i / 100 * E) {
          if (maxS * (i + j) < maxT * j) {
            maxT = i + j;
            maxS = j;
          }
        }
      }
    }
    System.out.printf("%d %d\n", maxT, maxS);
  }
}


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

int main(){
	string s; cin >> s;
	string t="";
	int n=s.size();
	for(int i=0;i<n;i++){
		if(s[i]=='A')t+='X';
		else if(s[i]=='B')t+='Y';
		else if(s[i]=='C')t+='Z';
		else t+=(char)(s[i]-3);
	}
	cout << t << endl;
} 


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using s32 = int32_t;
using u32 = uint32_t;
using s64 = int64_t;
using u64 = uint64_t;

bool isMirror(const string S) {
	//cout << S << endl;
	for(u32 i=0; i<S.size()/2; i++) {
		if(S[i] != S[S.size() - 1 - i]) {
			return false;
		}
	}
	
	return true;
}

int main() {

	string S;
	cin >> S;
	
	if(!isMirror(S)) {
		cout << "No";
	} else if(S.size() == 3) {
		cout << "Yes";
	} else {
		string l = S.substr(0, S.size()/2);
		string t = S.substr((S.size() + 3) / 2 - 1, S.size()/2);
		
		if(isMirror(l) && isMirror(t)) {
			cout << "Yes";
		} else {
			cout << "No";
		}
	}		
	
	return 0;
}


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

int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int ans = 0;
	int r = 0;
	while (R * r <= N) {
		int g = 0;
		while (R * r + G * g <= N) {
			if ((N - R * r - G * g) % B==0) ans++;
			g++;
		}
		r++;
	}
	cout << ans << endl;
}

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

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


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

int main()
{
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> xvec(N);
  for (int i = 0; i < N; i++)
  {
    cin >> xvec[i];
  }
  vector<int> yvec(M);
  for (int i = 0; i < M; i++)
  {
    cin >> yvec[i];
  }
  bool ans = true;
  for (int Z = X + 1; Z <= Y; Z++)
  {
    bool war = false;
    for (int i = 0; i < N; i++)
    {
      if (xvec[i] >= Z)
        war = true;
    }
    for (int i = 0; i < M; i++)
    {
      if (yvec[i] < Z)
        war = true;
    }
    if (!war)
    {
      ans = false;
      break;
    }
  }
  if (ans)
    cout << "War" << endl;
  else
    cout << "No War" << endl;
  return 0;
}


Measured memory_bytes: 256
N, M, Q = map(int, input().split())
abcd_list = [list(map(int, input().split())) for _ in range(Q)]
Alist = []
def dfs(array):
    if len(array) == N:
        Alist.append(array)
    else:
        if not array:
            for i in range(1, M+1):
                dfs(array[:] + [i])
        else:
            for i in range(array[-1], M+1):
                dfs(array[:] + [i])
dfs([])
ans = 0
for A in Alist:
    res = 0
    for a, b, c, d in abcd_list:
        if A[b-1] - A[a-1] == c:
            res += d
    ans = max(ans, res)
print(ans)

Measured memory_bytes: 94684
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	long long temp,ans=1;
	for(int i=2; i*i<=n; i++){
		ans=i*i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while(~scanf("%d",&n))
  {
	int a[2*n];
	int i;
	for(i=0;i<=2*n-1;i++)
	  scanf("%d",&a[i]);
	sort(a,a+2*n);
	int sum=0;
	for(i=0;i<=2*n-1;i+=2)
	sum+=a[i];
	printf("%d\n",sum);
  }
	return 0;
} 

Measured memory_bytes: 256
N = int(input())

shops = []
for i in range(N):
  shops.append(list(map(int, input().split())))

profits = []
for i in range(N):
  profits.append(list(map(int, input().split())))

ans = -float('inf')
for i in range(1, 1 << 10):
  profit = 0
  for j in range(N):
    a = i
    count = 0
    for k in range(10):
      count += a & shops[j][k]
      a >>= 1
    profit += profits[j][count]
  ans = max(ans, profit)

print(ans)

Measured memory_bytes: 3188