akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ForAtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] str = Console.ReadLine().Split(' ');

            bool approved = true;

            foreach (var _num in str)
            {
                int num = int.Parse(_num);

                if (num % 2 != 0) continue;

                if (num % 3 != 0 && num % 5 != 0)
                {
                    approved = false;
                    break;
                }
            }

            if (approved)
                Console.WriteLine("APPROVED");
            else
                Console.WriteLine("DENIED");
        }
    }
}


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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();

        int t = n % 10;
        switch (t) {
            case 3:
                System.out.println("bon");
                break;
            case 0: case 1: case 6: case 8:
                System.out.println("pon");
                break;
            default:
                System.out.println("hon");
        }
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32768
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

s = S()
tmp = 0
for i in range(len(s)):
    if s[i] != s[-i-1]:
        tmp += 1
print(int(tmp/2))

Measured memory_bytes: 38384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long n; cin >> n;
  cout << n * (n - 1) / 2 << '\n';
  return 0;
}


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

int main()
{
     cout << fixed << setprecision(10);

    int n;
    double x[110], y[110];

    cin >> n;
    for (int i=0; i<n; i++)
    {
        cin >> x[i] ;
    }
    for (int i=0; i<n; i++)
    {
        cin >> y[i] ;
    }

    double d1, d2, d3, d4, sum1 = 0, sum2 = 0, sum3 = 0;
    d4 = abs(x[0] - y[0]);

    for(int i=0; i<n; i++)
    {
        sum1 += abs(x[i] - y[i]);
        sum2 += pow(x[i] - y[i],2);
        sum3 += abs(pow(x[i] - y[i],3));

        if(d4 < abs(x[i] - y[i])) d4 = abs(x[i] - y[i]);
    }

    d1 = sum1;
    d2 = sqrt(sum2);
    d3 = cbrt(sum3);

    cout << d1 << endl;
    cout << d2 << endl;
    cout << d3 << endl;
    cout << d4 << endl;

    return 0;
}


Measured memory_bytes: 3416
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
string str;
int w[50][30];
int word[30];
int main(){
    cin.sync_with_stdio(false);
    int n;
    while(cin>>n){
        memset(w,0,sizeof(w));
        for(int i=0;i<n;i++){
            cin>>str;
            for(int j=0;j<str.length();j++){
                w[i][str[j]-'a']++;
            }
        }
        memset(word,0x3f,sizeof(word));
        for(int i=0;i<26;i++){
            for(int j=0;j<n;j++){
                word[i]=min(word[i],w[j][i]);
            }
        }
        string ans="";
        for(int i=0;i<26;i++){
            while(word[i]){
                ans+=char('a'+i);
                word[i]--;
            }
        }
        cout<<ans<<endl;
    }
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int a=0;
  int b=0;
  for(int i=0;i<n;i++){
    a+=i;
  }
  for(int j=0;j<m;j++){
    b+=j;
  }
  cout<<a+b<<endl;
}


  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
   string s, t;
   cin>>s>>t;
   if(s.length()!=t.length()-1){
       cout<<"No\n";
       return 0;
   }
   if(t.substr(0, s.length()) == s){
       cout<<"Yes\n";
   }
   else cout<<"No\n";
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	ll l, r;
	cin >> l >> r;

	if (r - l >= 3000) ANS(0);
	else
	{
		ll res = INF;

		for (ll i = l; i < r; i++) {
			for (ll j = i + 1; j <= r; j++) {
				//cout << i << " : " << j << endl;
				res = min(res, (i * j) % 2019);
			}
		}
		ANS(res);
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<string.h>
#include<cstdio>
#include<cstdlib>
#include<stack>

using namespace std;
int n;


int solve(int i, int m, int a[]){
  if(m == 0) return 1;
  else if(m < 0) return 0;
  else if(i >= n) return 0;
  else return solve(i + 1, m, a) || solve(i + 1, m - a[i], a);
}

int main(){

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

  int q;
  cin >> q;
  for(int i = 0; i < q; i++){
    int t;
    cin >> t;
    if(solve(0, t, a)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;

}


Measured memory_bytes: 3092
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 yy
#define y1 Yy
#define yn YY
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;

int gcd(int x,int y){
    if(x<y)return gcd(y,x);
    if(y==0)return x;
    return gcd(y,x%y);
}

int n,k,a[100005];

int main(){
    int a0;
    scanf("%d %d %d",&n,&k,a);
    a0=a[0];
    for(int i=1;i<n;i++){
        scanf("%d",a+i);
        a0=gcd(a0,a[i]);
    }
    sort(a,a+n);
    for(int i=n-1;i>=0;i--){
        if(a[i]<k)break;
        if((a[i]-k)%a0==0){
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
vector<int> lengths;
int main()
{
	int N;
	cin>>N;
	for(int i=0;i<2*N;i++)
	{
		int x;
		cin>>x;
		lengths.push_back(x);
	}
	sort(lengths.begin(),lengths.end());
	int sum=0;
	for(int i=0;i<lengths.size();i+=2)
		sum+=lengths[i];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
using vc = vector<char>; using vvc = vector<vc>;
using vp = vector<pair<int,int>>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main(){
  int n;cin >> n;
  vl an(n);
  rep(i,n) cin >> an[i];
  ll ans = 0;
  ll st = 0;
  rep(i,n) {
    st = max(st,an[i]);
    ans += st - an[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4772
#include <iostream>
#include <vector>
using i64 = long long;

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<int> h(n);
    for (auto &e : h) std::cin >> e;
    std::vector<int> v(n, 1);
    while (m--) {
        int a, b;
        std::cin >> a >> b;
        --a; --b;
        if (h[a] >= h[b]) v[b] = 0;
        if (h[b] >= h[a]) v[a] = 0;
    }

    int ret = 0;
    for (auto e : v) if (e) ret++;
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 4020
#include <iostream>
using namespace std;
unsigned long long gcd(unsigned long long a,unsigned long long b)
{
    if (!b) return a;
    return gcd(b,a%b);
}
int N;
void solve()
{
    unsigned long long ans=1;
    while(N--)
    {
        unsigned long long T;
        cin>>T;
        ans=ans/gcd(ans,T)*T;
    }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>N)
        solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  string S ; cin >> S;
  ll a = S.size();

  rmsame(S);
  ll b = S.size();
  if(a == b) cout << "yes" << endl;
  else cout << "no" << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void read(int &x){
	char c=getchar();
	int f=1;
	x=0;
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	x*=f;
}
int main(){
	int i,j,k,m,n;
	read(n);read(m);
	if(n>=1 && n<=9 && m>=1 && m<=9)cout<<n*m<<endl;
	else cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int c[999999],q[999999];
int main() {
	int a,b,w=0,i;
	cin>>a;
	for (i=1;i<=a;++i){
		cin>>c[i];
		q[c[i]]++;
	}
	sort(c+1,c+a+1);
	for (i=1;i<=a;++i){
		w=max(w,q[ c[i] ] + q[ c[i] -1] + q[ c[i]+1]);
	}
	cout <<w;
}

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

const ll mod = 1e9+7;

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

  vector<int> a(n+1);
  for (int i = 2; i <= n; i++) {
    int tmp = i;
    for (int j = 2; j <= tmp; j++) {
      while (tmp > 0 && tmp % j == 0) {
        a[j]++;
        tmp/=j;
      }
    }
  }
  ll ans = 1;
  for (int i = 0; i <= n; i++) {
    if (a[i] != 0) {
      ans *= (a[i] + 1);
      ans %= mod;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int LIMIT = 1e18;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    for (auto &&i : a) {
        if (i == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    int ans = 1;
    for (auto &&i : a) {
        if (ans * i > LIMIT || ans > LIMIT / i) {
            cout << -1 << endl;
            return 0;
        }
        ans *= i;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3976
n=int(input())
l=[int(i) for i in input().split()]
from collections import Counter
lst=list(Counter(l).items())
lst.sort(reverse=True)
num=0
for i in range(n):
    if lst[i][1]>3:
        if num==0:
            ans=lst[i][0]**2
            num+=2
            break
        elif num==1:
            ans*=lst[i][0]
            num+=1
            break
    elif 1<lst[i][1]<=3:
        if num==0:
            ans=lst[i][0]
            num+=1
        elif num==1:
            ans*=lst[i][0]
            num+=1
            break
    else:
        continue
if num==2:
    print(ans)
else:
    print(0)


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

long long int day(int y,int m,int d){
  long long int year = 0;
  for(int i = 0 ; i < y ; i ++){
    if(i%3){
      year += 195;
    }else{
      year += 200;
    }
  }
  m--;
  if(y%3==0)return year + m * 20  + d;
  return year + (m/2 + m%2) * 20 + m/2 * 19 + d;
}

int main(void){
  int n;
  cin>>n;
  long long int mire = day(1000,1,1);
  while(n--){
    int y,m,d;
    cin>>y>>m>>d;
    cout<<mire-day(y,m,d)<<endl;
  }
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

void solve() {
    int n, k;
    cin >> n >> k;

    vector<int> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];

    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < n - k; i++)
        ans += v[i];
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std; //头文件和命名空间
int arrCount[200005] = { 0 }; //定义存放每个数字出现次数的数组并初始化为0
bool cmp(int iNum1, int iNum2){ //降序排序判断函数
    return iNum1 > iNum2;
}
int main(){
    ios::sync_with_stdio(false); //输入输出加速
    int nCount, nDiff, i, iTemp, iSum=0; //nCount-球的个数；nDiff-不同的数的个数；i-循环计数器；iTemp-输入暂存；iSum-累加器
    cin >> nCount >> nDiff; //读入球的个数和不同的数的个数
    for (i = 1; i <= nCount; ++i){ //读入数字并计数
        cin >> iTemp; //读入数字
        ++arrCount[iTemp]; //计数
    }
    sort(arrCount, arrCount + 200005,cmp); //降序排序(使用STL提供的快速排序函数)
    for (i = nDiff; arrCount[i] != 0; ++i){ //对第K+1项到最后一项求和，控制遇到值为0的项结束缩短时间
        iSum += arrCount[i]; //累加
    }
    cout << iSum << endl; //输出
    return 0; //结束
}

Measured memory_bytes: 1024
N, M = map(int, input().split())

e = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    e[a-1].append(b-1)
    e[b-1].append(a-1)
visited = [0]*N
visited[0] = 1
que = [0]
while que:
    x = que.pop(0)
    for i in e[x]:
        if visited[i] == 0:
            visited[i] = x+1
            que.append(i)

print("Yes")


print(*visited[1:], sep="\n")


Measured memory_bytes: 38040
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 1e5 + 5;
 
int32_t main()
{
	IOS;
	string s;
	cin >> s;
	if(s.find("7") != string::npos)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()
#define PI 3.141592653589793

int main() {
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    vector<int> A(N, 0);
    rep(i, N - 1) {
        if (s[i] == 'A' && s[i + 1] == 'C')
            A[i + 1] = A[i] + 1;
        else
            A[i + 1] = A[i];
    }

    rep(i, Q) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        cout << A[b] - A[a] << endl;
    }
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {

	Scanner std = new Scanner(System.in);


	//List<Integer> listx = new ArrayList<>();
	int X = std.nextInt();
	int A = std.nextInt();

	if(X < A) {
		System.out.println(0);
	}
	else {
		System.out.println(10);
	}

	}














	}



Measured memory_bytes: 21716
n = int(input())
l = []
for i in range(n):
    sp = input().split()
    l.append((sp[0], int(sp[1]), i+1))

a = sorted(l, key=lambda i: i[1], reverse=True)
a = sorted(a, key=lambda i: i[0])

for i in range(n):
    print(a[i][2])

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define ll long long
using namespace std;
int a[55];
int main() {
	int n,ans=0;
	cin>>n;
	rep(i,1,n) cin>>a[i];
	rep(i,1,n) if(a[i]!=i)ans++;
	if(ans==2||ans==0)cout<<"YES";
	else cout<<"NO";
	return 0;
}


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

using namespace std;
/** whole range */
#define whole(xs) (xs).begin(), (xs).end()
typedef long long ll;

namespace {
    int N;
    vector<ll> A;
    void input() {
        cin >> N;
        A.resize(N);
        for (int i = 0; i < N; i++) cin >> A[i];
    }

    void solve() {
        map<ll, int> M;
        for (auto a : A) {
            M[a]++;
        }
        vector<ll> cs{0, 0};
        for (auto m : M) {
            auto key = m.first;
            auto count = m.second;
            if (count >= 4) {
                cs.push_back(key);
                cs.push_back(key);
            } else if (count >= 2) {
                cs.push_back(key);
            }
        }
        sort(whole(cs));
        reverse(whole(cs));
        cout << cs[0] * cs[1] << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}



Measured memory_bytes: 7296
n = int(input())
v = list(map(int, input().split()))
v1 = [v[2 * i] for i in range(0, n // 2)]
v2 = [v[2 * i + 1] for i in range(0, n // 2)]

import collections
c1 = collections.Counter(v1)
c2 = collections.Counter(v2)

mc1 = c1.most_common()
mc2 = c2.most_common()
if mc1[0][0] != mc2[0][0]:
    print(n - (mc1[0][1] + mc2[0][1]))
else:
    if len(mc1) == 1 and len(mc2) == 1:
        print(n // 2)
    elif len(mc1) == 1 or len(mc2) == 1:
        print(n // 2 - mc2[1][1] if len(mc1) == 1 else n // 2 - mc1[1][1])
    else:
        if (mc1[0][1] + mc2[1][1]) >= (mc1[1][1] + mc2[0][1]):
            print(n - (mc1[0][1] + mc2[1][1]))
        else:
            print(n - (mc1[1][1] + mc2[0][1]))

Measured memory_bytes: 21760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  int i = 0;
  while (i < N) { 
    cin >> mochi.at(i); i++; }
  sort(mochi.begin() , mochi.end());
  int j = 1;
  int dup =0;
  while (j < N) { if (mochi.at(j - 1) == mochi.at(j)) { dup+=1; j++;} 
                 else {j++;} }
  
  
  cout << mochi.size() - dup;

                }

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

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    int a[1010];
    for(;;) {
        cin >> n;
        if(n == 0) break;
        rep(i, n) cin >> a[i];
        int ans = abs(a[1] - a[0]);
        rep(i, n) {
            rep(j, n) {
                if(i == j) continue;
                ans = min(ans, abs(a[i] - a[j]));
            }
        }
        cout << ans << endl;
    }
	return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int n,m;
ll s[maxn],len[maxn],dp[maxn],t[maxn];
class segTree{
    int a[maxn],s[maxn*4],lazy_tag[maxn*4];
public:
    segTree(){
        memset(a,0,sizeof(a));
    }
    void build(int node,int begin,int end){
        lazy_tag[node]=0;
        if(begin==end){
            s[node]=a[begin];
        }else{
            build(2*node,begin,(begin+end)/2);
            build(2*node+1,(begin+end)/2+1,end);
            s[node]=s[2*node]+s[2*node+1];
        }
    }
    int query(int k){
        return a[k];
    }
    void PushDown(int node,int begin,int end){
        if(begin==end){
            s[node]+=lazy_tag[node];
            a[begin]=s[node];
        }else{
            lazy_tag[2*node]+=lazy_tag[node];
            lazy_tag[2*node+1]+=lazy_tag[node];
        }
        s[node]+=lazy_tag[node]*(end-begin+1);
        lazy_tag[node]=0;
    }
    void Change(int node,int begin,int end,int left,int right,int num){
        if(begin>=left&&end<=right){
            lazy_tag[node]+=num;
        }else{
            PushDown(node,begin,end);
            int m=(begin+end)/2;
            if(!(left>m||right<begin))
                Change(2*node,begin,m,left,right,num);
            if(!(left>end||right<m+1))
                Change(2*node+1,m+1,end,left,right,num);
        }
    }
    void PushDown_all(int node,int begin,int end){
        PushDown(node,begin,end);
        if(begin!=end){
            PushDown_all(2*node,begin,(begin+end)/2);
            PushDown_all(2*node+1,(begin+end)/2+1,end);
        }
    }
}contain;
int main(){
    //freopen("e:\\in.txt","r",stdin);
    memset(s,0,sizeof(s));
    memset(t,0,sizeof(t));
    memset(dp,0,sizeof(dp));
    memset(len,0,sizeof(len));
    int a,b;
    scanf("%d%d",&n,&m);
    contain.build(1,1,m);
    scanf("%d",&a);
    for(int i=1;i<n;i++){
        s[a]++;
        scanf("%d",&b);
        t[b]++;
        len[b]+=(b-a+m)%m;
        if(b>a){
            contain.Change(1,1,m,a,b,1);
        }else{
            contain.Change(1,1,m,1,b,1);
            contain.Change(1,1,m,a,m,1);
        }
        dp[1]+=min((b-a+m)%m,1+(b-1+m)%m);
        a=b;
    }
    contain.PushDown_all(1,1,m);
    for(int i=1;i<m;i++){
        dp[i+1]=dp[i]+len[i]-t[i]+s[i]-contain.query(i+1)+s[i+1];
    }
    ll ans=dp[1];
    for(int i=2;i<=m;i++)
        ans=min(ans,dp[i]);
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    long double ans = 0;
    cout.precision(10);
    for (int i = 0; i < n; ++i) {
        long double a;
        cin >> a;
        ans += ((long double)1 / a);
    }
    cout << ((long double)1 / ans);
}


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

int main() {
  int num_query; cin >> num_query;
  map<string, int> dic;
  
  while (num_query--) {
    int command; scanf("%d", &command);
    char key[20]; scanf("%s", key);
    
    switch (command) {
      case 0:
        int value; scanf("%d", &value);
        if (dic.count(key)) dic.at(key) = value;
        else dic.insert(make_pair(key, value));
        break;
        
      case 1:
        if (dic.count(key)) printf("%d\n", dic.at(key));
        else printf("%d\n", 0);
        break;
        
      case 2:
        dic.erase(key);
        break;
        
      case 3:
        char key2[20]; scanf("%s", key2);
        map<string, int>::iterator it = dic.lower_bound(key);
        map<string, int>::iterator last = dic.upper_bound(key2);
        while(it != last) {
          printf("%s %d\n", ((*it).first).c_str(), (*it).second);
          it++;
        }
        break;
    }
  }
}


Measured memory_bytes: 26036
#include<bits/stdc++.h>
using namespace std;
int main()
{
int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
  cin>>k;
  cout<<arr[k-1];


}


Measured memory_bytes: 256
import atexit
import io
import sys

buff = io.BytesIO()
sys.stdout = buff


@atexit.register
def write():
    sys.__stdout__.write(buff.getvalue())

l = []
for i in xrange(5):
	l.append(input())
k = input()
ans = 'Yay!'
for i in xrange(5):
	for j in xrange(5):
		if abs(l[i]-l[j]) > k:
			ans = ':('
print ans

Measured memory_bytes: 28012
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if (k <= a) {
        ans = k;
    } else if (k <= a + b) {
        ans = a;
    } else {
        ans = a - (k - a - b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  vector<short> A;

  for (int ii=0; ii<3; ++ii) {
    short a;
    cin >> a;
    A.push_back(a);
  }

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

  cout << A[2]*10+A[1]+A[0] << endl;
    
  return 0;
}

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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 998244353;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll num_): num((num_ + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return num; }

    template <typename T>
    void check_type(const T &num_) const {
        assert(num_ >= 0 && num_ < MOD);
        static_assert(is_integral<T>() || is_same<T,modint>(), "T is not integral");
    }

    template <typename T>
    modint operator+(const T &r) const { check_type(r); return modint(num + r); }
    template <typename T>
    modint operator-(const T &r) const { check_type(r); return modint(num - r); }
    template <typename T>
    modint operator*(const T &r) const { check_type(r); return modint(num * r); }
    template <typename T>
    modint operator/(const T &r) const { check_type(r); return num * pow(r, MOD-2); }

    template <typename T>
    modint operator+=(const T &r) { return *this = *this + r; }
    template <typename T>
    modint operator-=(const T &r) { return *this = *this - r; }
    template <typename T>
    modint operator*=(const T &r) { return *this = *this * r; }
    template <typename T>
    modint operator/=(const T &r) { return *this = *this / r; }

    static modint pow(const modint &x, const ll &r) {
        if(r == 0) return 1;
        return pow(x*x, r/2) * modint(r&1 ? x : modint(1));
    }

    static modint fact(int n){
        if((int)factorial.size() <= n) {
            int size = factorial.size();
            factorial.resize(n+1);
            for (int k = size; k <= n; k++) {
                factorial[k] = factorial[k-1] * k;
            }
        }
        return factorial[n];
    }

    static modint C(int n, int r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }

    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
};
vector<modint> modint::factorial = {1};
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)


int main(void){
    int n;
    cin >> n;
    modint sum = 0;
    for (int i = n/2+1; i <= n; i++) {
        sum += C(n,i) * modint::pow(2,n-i) * 2;
    }
    cout << modint::pow(3,n) - sum << endl;
    return 0;
}


Measured memory_bytes: 117376
#include <cstdio>

int main(int argc, char const *argv[])
{
	int n,m;
	int A[100][100];
	int b[100];
	int c ;
	scanf("%d %d \n",&n,&m);
	for(int i = 0;i <n;i++)
		for(int j = 0; j <m;j++)
			scanf("%d",&A[i][j]);
	for(int i = 0; i < m;i++)
		scanf("%d",&b[i]);

	for(int i = 0;i<n;i++){
		c = 0;
		for(int j = 0;j<m;j++)
			c += A[i][j] * b[j];
		printf("%d\n",c);
	}

	return 0;
}


Measured memory_bytes: 2756
#!/usr/bin/env python
# coding: utf-8

def readInt():
    return int(input())

def readList():
    return list(input().split())

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

def main():
    s = input()
    win = sum(1 for c in s if c == 'o')
    if win+15-len(s) >= 8:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}
	queue<P<int>> que;
	VV dist(h, V(w, upper));
	rep(i, h) rep(j, w) {
		if (s[i][j] == '#') {
			que.push(make_pair(i, j));
			dist[i][j] = 0;
		}
	}
	while (!que.empty()) {
		P<int> p = que.front();
		que.pop();
		int y = p.first;
		int x = p.second;
		rep(dir, 4) {
			int ny = y + dy[dir];
			int nx = x + dx[dir];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
			if (dist[ny][nx] != upper) continue;
			dist[ny][nx] = dist[y][x] + 1;
			que.push(make_pair(ny, nx));
		}
	}
	int ans = 0;
	rep(i, h) rep(j, w) {
		chmax(ans, dist[i][j]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13456
from itertools import product
n = int(input())
a = [[] for i in range(n)]

for i in range(n):
    c = int(input())
    for j in range(c):
        x, y = map(int, input().split())
        x-=1
        a[i].append([x, y])

ans = 0
for c in product([1, 0], repeat=n):
    f = True
    for i, p in enumerate(c):
        if p == 1:
            for x, y in a[i]:
                if c[x] != y:
                    f = False
                    break
        if not f:
            break
    if f:
        ans = max(ans, sum(c))
print(ans)


Measured memory_bytes: 3064
/*
* @Author: _dp95
* @Date:   2020-01-30 10:21:41
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 3*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

ll n, ar[MAX], sum, dp[MAX][MAX][2] ;

ll sol( ll l, ll r, ll flag ){
	if( l == r ){
		return flag?0:ar[l] ;
	}
	if( l > r )
		return 0 ;
	ll &ans = dp[l][r][flag] ;
	if( ans != -1 )
		return ans ;
	if( flag == 0 ){
		ans = ar[l] + sol( l+1, r, flag^1 ) ;
		ans = max( ans, ar[r] + sol( l, r-1, flag^1 ) ) ;
	}
	else{
		ans = sol( l+1, r, flag^1 ) ;
		ans = min( ans, sol( l, r-1, flag^1 ) ) ;
	}
	return ans ;
}

int main( ){
  timesaver ;
  cin >> n ;
  for( ll i = 0 ; i < n; i++ ){
  	cin >> ar[i] ;
  	sum += ar[i] ;
  }
  mem( dp, -1 ) ;
  cout << 2*sol( 0 , n-1, 0 )-sum << nl ;
}

Measured memory_bytes: 141952
n = int(input())
l_s = [input() for i in range(n)]
set_char = set(l_s[0])
for s in l_s:
    set_char &= set(s)
ans = ''
for c in sorted(set_char):
    num = 50
    for s in l_s:
        num = min(num, s.count(c))
    ans += c * num
print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long x;
long long b[100000];
long long l[100000];
long long u[100000];
long long s[100001];

long long get(int p, long long r) {
    if (r <= 0) return 0;
    if ((x - b[p]) * u[p] + b[p] * l[p] < r) return 1e18;
    if (b[p] * l[p] >= r) return (r + l[p] - 1) / l[p];
    return b[p] + (r - b[p] * l[p] + u[p] - 1) / u[p];
}

int main() {
    int n, p = -1, i;
    long long ans = 1e18, sum = 0;
    vector <pair<long long, int>> v;
    
    scanf("%d %lld", &n, &x);
    
    for (i = 0; i < n; i++) {
        scanf("%lld %lld %lld", &b[i], &l[i], &u[i]);
        
        sum += b[i] * l[i];
        v.push_back(make_pair((x - b[i]) * u[i] + b[i] * l[i], i));
    }
    
    if (sum == 0) {
        puts("0");
        
        return 0;
    }
    
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    
    for (i = 0; i < n; i++) s[i + 1] = s[i] + v[i].first;
    
    for (i = 1; i <= n; i++) {
        if (s[i] >= sum) break;
        p++;
    }
    
    for (i = 0; i < n; i++) {
        if (i <= p) {
            int q = lower_bound(s, s + n + 1, sum + v[i].first) - s - 1;
            long long c = (q - 1) * x;
            long long r = sum + v[i].first - s[q];
            
            ans = min(ans, c + get(v[i].second, r));
        } else {
            long long c = (p + 1) * x;
            long long r = sum - s[p + 1];
            
            ans = min(ans, c + get(v[i].second, r));
        }
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    string s; cin>>s;
    deque<char> que;
    int Bcount=0;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='B')Bcount++;
        else{
            if(Bcount>0){
                Bcount--;
                continue;
            }
            que.push_front(s[i]);
        }
    }
    /*
    for(auto itr=que.begin();itr<=que.end();itr++){
        cout<<*itr;
    }
    */
    for(auto itr:que){
        cout<<itr;
    }
    
    cout<<endl;
    return 0;
}

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

int main(){
 string S; int num = 0;
 cin >> S;
 vector <string> s(S.size());
 int i = 0,k = 0;
 while(i < S.size()){
 s.at(k) = S.at(i); if(i == 0) {i++;k++; num++;continue;}
 int j = 1;
 while( s.at(k-1) == s.at(k) && i + j < S.size() ){s.at(k) = s.at(k) + S.at(i+j); j++;}
 if(s.at(k-1) != s.at(k) )num++;
 i += j; k++;
 }
 cout << num << endl;
 return 0;
}

Measured memory_bytes: 11012
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
typedef long long ll;
using namespace std;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=1e6+5;

char s[maxn];
int f1[maxn],f2[maxn];
vector<int>vec;
bool vis[maxn];
int n;
int fun1(int x){return x;}
int fun2(int x){return n-x+1;}
void solve(int c,int k,int v(int ))
{
    memset(f1,0,sizeof(f1));
    memset(f2,0,sizeof(f2));
    vec.clear();
    for(int i=1;i<=n;i++)
    {
        f1[i]=f1[i-1];
        if(s[i]=='x')continue;
        vec.push_back(i);
        if(i<=c)f1[i]=1;
        else f1[i]=f1[i-c-1]+1;
    }
    for(int i=n;i>=1;i--)
    {
        f2[i]=f2[i+1];
        if(s[i]=='x')continue;
        if(i+c>=n)f2[i]=1;
        else f2[i]=f2[i+c+1]+1;
    }
    int cnt=0;
    for(int i=0,t;i<vec.size();i++)
    {
        if(i==0&&f2[vec[i]+1]>=k)vis[v(vec[0])]=1;
        t=lower_bound(vec.begin(),vec.end(),vec[i]+c+1)-vec.begin();
        if(t==vec.size())
        {
            if(f1[vec[i]]==k&&i==cnt)cnt++;
            while(f1[vec[i]]>=k&&cnt<vec.size())
            {
                vis[v(vec[cnt])]=1;cnt++;
            }
        }
        else
        {
            if(f1[vec[i]]+f2[vec[t]]==k&&cnt==i)cnt++;
            if(f1[vec[i]]+f2[vec[t]]>=k)
            {
                while(cnt<t)
                {
                    vis[v(vec[cnt])]=1;
                    cnt++;
                }
            }
        }
    }
}
int main()
{
    int k,c;
    scanf("%d%d%d",&n,&k,&c);
    scanf("%s",s+1);
    solve(c,k,fun1);
    for(int i=1;i<=n/2;i++)swap(s[i],s[n-i+1]);
    solve(c,k,fun2);
    for(int i=vec.size()-1;i>=0;i--)
    {
        if(!vis[fun2(vec[i])])printf("%d\n",fun2(vec[i]));
    }
}

Measured memory_bytes: 10484
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<long double> V(N,0.0L);
    for(auto &idx: V)
        cin >> idx;

    long double current = 0.0L;

    do {
        sort(V.begin(), V.end(), greater<int>());

        current = (V[V.size()-2]+V[V.size()-1])/2;

        V.pop_back();
        V.pop_back();

        V.push_back(current);
    } while(V.size() > 1);

    cout << V[0] << endl;

    return 0;
}


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

using namespace std;

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

int main(){
    int N;
    double T, A;
    double opt = 1001;
    int ans = 0;
    cin >> N >> T >> A;

    rep(i, N){
        double h;
        cin >> h;
        double t = T * 1.0 - h * 0.006;
        double tmp = abs(t - A);
        if(tmp < opt){
            opt = tmp;
            ans = i;
        }
    }
    cout << ans + 1 << endl;
}


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

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

    long long m;

    if (n == 0)
        m = 2;
    else if (n == 1)
        m = 1;
    else {
        long long a = 2, b = 1;
        for (int i = 2; i <= n; i++) {
            m = a + b;
            a = b;
            b = m;
        }
    }

    cout << m << endl;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
int main(){
    int dice[100][6];
    int pos[6][6] = {{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};
    int a,b,n;
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<6;j++) cin>>dice[i][j];
    bool flg=false;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int p=0;p<6;p++){
                if(dice[i][0]==dice[j][p]){
                    a=p;
                    for(int k=0;k<6;k++){
                        if(dice[i][1]==dice[j][k] && k!=a && pos[a][k]!=0){
                            b=k;
                            if(dice[i][2]==dice[j][pos[a][b]-1] && dice[i][3]==dice[j][5-(pos[5-a][5-b]-1)] && dice[i][4]==dice[j][5-b] && dice[i][5]==dice[j][5-a]) flg=true;
                        }
                        if(flg) break;
                    }
                }
                if(flg) break;
            }
            if(flg) break;
        }
        if(flg) break;
    }
    if(flg) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
ll n, a, b, k;
string s;

int main(){
    cin  >> a >> b >> k;
    for(ll i = a; i < a+k; i++){
        if(i > b)  break;
        cout << i << '\n';
    }
    for(ll i = b-k+1; i <= b; i++){
        if(i >= a+k) cout << i << '\n';
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 5000000

int H,A[N];

void buildMaxHeap(int *);
void maxHeapify(int *,int);

int left(int);
int right(int);

main(){
  int i;
  
  scanf("%d",&H);
  
  for( i=1 ; i<=H ; i++ ){
    scanf("%d",&A[i]);
  }

  buildMaxHeap(A);

  for( i=1 ; i<=H ; i++ ){
    printf(" %d",A[i]);
  }
  
  printf("\n");
  return 0;
}

void buildMaxHeap(int *A){
  int i;
  for( i=H/2 ; i>=1 ; i-- )
    maxHeapify(A,i);
}


void maxHeapify(int *A, int i){
  int l,r,largest,ex;

  l = left(i);
  r = right(i);

  if( l <= H && A[l]>A[i] ) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest])largest = r;

  if(largest != i){
    ex = A[i];
    A[i] = A[largest];
    A[largest] = ex;
    maxHeapify(A,largest);
  }
}

int left(int i){
  return 2*i;
}
int right(int i){
  return (2*i+1);
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
#define ppb pop_back
#define len(v) int(v.size())
#define all(v) (v).begin(),(v).end()
#define ri(x) scanf("%d",&(x))
#define rii(x,y) scanf("%d %d",&(x),&(y))
#define riii(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rl(x) scanf("%lld",&(x))
#define rll(x,y) scanf("%lld %lld",&(x),&(y))
#define rlll(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
void fastio(){ios_base::sync_with_stdio(false); cin.tie(0);}

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;
const int maxn = 1024;

int n;
string s;

int main() {
	fastio();
	cin >> n >> s;
	forn(i, s.size()){
		s[i]-='A';
		s[i]+=n;
		s[i]%=26;
		s[i]+='A';
	}
	cout << s;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int nmin, nmax, m;
	while (cin >> m >> nmin >> nmax, m) {
		int p[210];
		for (int i = 1; i <= m; i++)cin >> p[i];
		int ans = nmin, v = p[nmin] - p[nmin + 1];
		for (int i = nmin + 1; i <= nmax; i++) {
			if (v <= p[i] - p[i + 1]) {
				ans = i;
				v = p[i] - p[i + 1];
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

#define MAX 100005
#define INF 12345678910
#define ll long long
ll arr[MAX], cost[MAX];

int main()
{
    ll n, k;
    scanf("%lld %lld", &n, &k);
    for(ll i=1; i<=n; i++) scanf("%lld", &arr[i]);
    cost[1] = 0;
    for(ll i=2; i<=n; i++){
		ll mins = INF;
        for(ll j=1; j<=k; j++){
            ll pos = max(i-j, 1LL);
            mins = min(mins, cost[pos]+abs(arr[i]-arr[pos]));
        }
        cost[i] = mins;
    }
    printf("%lld\n", cost[n]);
}


Measured memory_bytes: 1792