akhauriyash/Code-Regression huggingface dataset:
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	int n, j = 0, k = 0;
	string s, s1;
	re(n,s,s1);
	for(int i = 0; i < 2*n; i++)
	{
		if(i%2==0) cout<<s[j++];
		else cout<<s1[k++];
	}
	cout<<"\n";
	
}


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

//c

int main() {
  
  int K; cin >> K;
  int ans = 0;
  
  vector<int> data(K, 0);
  for(int i=K; i>0; i--){
    data.at(i-1) += (K/i)*(K/i)*(K/i);
    int j = i*2;
    while(j <= K){
      data.at(i-1) -= data.at(j-1);
      j += i;
    }
  }
  
  
  for(int i=0; i<K; i++){
    ans += data.at(i)*(i+1);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long 
#define max(a,b) a>b?a:b
inline void read(int &x)
{
    x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
}
int n,m;
int main()
{
    read(n);read(m);
    for(int a=0;a<=n;a++)
        for(int b=0;b<=n-a;b++)
            {
                int c=n-a-b;
                if(a*10000+b*5000+c*1000==m){cout<<a<<" "<<b<<" "<<" "<<c<<"\n";return 0;}
            }
    cout<<"-1 -1 -1\n";
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    
    double A,B;
    cin >> A >> B;
    double K;
    K = (A + B) / 2;
    if(K == floor(K)) cout << setprecision(9) << K << endl;
    else cout << setprecision(9) << "IMPOSSIBLE" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,t,sj[102];
long long jz[102],f[102][100001];
int main()
{
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;i++) scanf("%d%lld",&sj[i],&jz[i]);
	for(int i=1;i<=n;i++)
		for(int j=0;j<=t;j++)
			if(sj[i]<=j) f[i][j]=max(f[i-1][j-sj[i]]+jz[i],f[i-1][j]);
			else f[i][j]=f[i-1][j];
	printf("%lld",f[n][t]);
	return 0; 
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
#define MAX 200005
#define INF (1<<26)
 
int segN=1000000;
struct data{
  int value;
  data* ch[2];
  
  void init(){
    value=INF;
    ch[0]=(data*)malloc(sizeof(data));
    ch[1]=(data*)malloc(sizeof(data));
    ch[0]->ch[0]=NULL;
    ch[1]->ch[0]=NULL;
  }
   
  void set(int i,int x,int l,int r){
    int m=(l+r)/2;
    if(ch[0]==NULL)init();
    if(i<l || r<=i)return;
    if(x<value)value=x;
    if(r-l==1)return;
    ch[0]->set(i,x,l,m);
    ch[1]->set(i,x,m,r);
  }
    
  void set(int i,int x){
    set(i,x,0,segN);
  }
    
  int min(int a,int b,int l,int r){
    int m=(l+r)/2;
    if(ch[0]==NULL)init();
    if(b<=l || r<=a)return INF;
    if(a<=l && r<=b)return value;
    int lc=ch[0]->min(a,b,l,m);
    int rc=ch[1]->min(a,b,m,r);
    return (lc<rc?lc:rc);
  }
  
  int min(int a,int b){
    if(0<=a&&a<b)return min(a,b,0,segN);         
    else return INF;
  }
};
  
  
    
  
  
  
  
  
 
 
int rak[MAX+1];
int tmp[MAX+1];
int n,k;
 
bool compare_sa(int i,int j){
  if(rak[i]!=rak[j])return (rak[i]<rak[j]);
  else{
    int ri=(i+k<=n?rak[i+k]:-1);
    int rj=(j+k<=n?rak[j+k]:-1);
    return ri < rj;
  }
}
 
void construct_sa(string s,int *sa){
  n=s.size();
  for(int i=0;i<=n;i++){
    sa[i]=i;
    rak[i]=(i<n?s[i]:-1);
  }
  for(k=1;k<=n;k*=2){
    sort(sa,sa+n+1, compare_sa );
    tmp[sa[0]]=0;
    for(int i=1;i<=n;i++){
      tmp[sa[i]]=tmp[sa[i-1]]+
        (compare_sa(sa[i-1],sa[i])?1:0);
    }
    for(int i=0;i<=n;i++)rak[i]=tmp[i];
  }
}
 
 
int search(string &target,int *sa,string s){
  int l=0,r=n,m;
  int size=target.size(),res;
  while(l<r){
    m=(l+r)/2;
    res=s.compare(sa[m],size,target);
    if(res>=0)r=m;
    else l=m+1;
  }
  if(s.compare(sa[l],size,target)<0)return n+1;
  return l;
}
 
int search2(string &target,int *sa,string s){
  int l=0,r=n,m;
  int size=target.size(),res;
  while(l<r){
    m=(l+r)/2;
    res=s.compare(sa[m],size,target);
    if(res>0)r=m;
    else l=m+1;
  }
  if(s.compare(sa[l],size,target)<=0)return n+1;
  return l;
}
 
data T,T2;
string s,s2;
string x,y;
int m;
int sa[MAX+1];
int sa2[MAX+1];
 
int main(){
  ios::sync_with_stdio(false);
    
  T.init();
  T2.init();

  cin>>s;
  s2=s;
  reverse(s2.begin(),s2.end());
   
  construct_sa(s2,sa2);
  construct_sa(s,sa);
 
  for(int i=0;i<=n;i++){
    //cout<<i<<' '<<sa[i]<<' '<<s.substr(sa[i])<<endl;
  }
  for(int i=0;i<=n;i++){
    //cout<<i<<' '<<sa2[i]<<' '<<s2.substr(sa2[i])<<endl;
  }
   
  for(int i=0;i<=n;i++){
    T.set(i,sa[i]);
    T2.set(i,sa2[i]);
  }
   
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>x>>y;
    reverse(y.begin(),y.end());
    int xl=search(x,sa,s),xr=search2(x,sa,s);
    int yl=search(y,sa2,s2),yr=search2(y,sa2,s2);
    int xs=x.size();
    int X=T.min(xl,xr);
    int Y=T2.min(yl,yr);
    if(Y!=INF)Y=n-Y;
     
    //cout<<xl<<' '<<xr<<' '<<X<<endl;
    //cout<<yl<<' '<<yr<<' '<<Y<<endl;
 
    if(Y<X+xs)cout<<0<<'\n';
    else if(X==INF||Y==INF)cout<<0<<'\n';
    else cout<<Y-X<<'\n';
     
  }
     
  return 0;
}

Measured memory_bytes: 55260
#include <iostream>
using namespace std;
using ll = long long;

int main(){
        ll n,i,c,bn=1e15+1;
        cin >> n;
        for(i=0;i<5;++i){
                cin >> c;
                bn = min(bn,c);
        }
        if(n%bn==0) cout << n/bn+4 << endl;
        else cout << n/bn+5 << endl;
        return 0;
}

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

int main()
{
    queue<int> a;
    queue<string> b;
    int n, q, timer = 0;
    scanf("%d %d", &n, &q);
    for (int i = 0; i < n; i++)
    {
        int j;
        char k[10];
        cin >> k >> j;
        a.push(j);
        b.push(k);
    }
    for (; !a.empty(); )
    {
        if(a.front() > q)
        {
            timer += q;
            a.push(a.front() - q);
            a.pop();
            b.push(b.front());
            b.pop();
        }
        else
        {
            timer += a.front();
            cout << b.front() << " " << timer << "\n";
            a.pop();
            b.pop();
        }
    }
}


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

int main() {
  int N, K,C;
  cin >> N;
  C=30;
  
  for(int i=0;i<N;i++){
    cin >> K;
    int A;
    for(int j=0;j<30;j++){
      if(K%2==0){
        K/=2;
      }else{
        A=j;
        break;
      }
    }
    C=min(C,A);
  }
  
  cout << C << endl;
}


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

int main()
{
    string S;
    cin >> S;
    if (S.at(0) == 'S' && S.at(1) == 'U')
    {
        cout << 7 << endl;
    }
    else if (S.at(0) == 'M')
    {
        cout << 6 << endl;
    }
    else if (S.at(0) == 'T' && S.at(1) == 'U')
    {
        cout << 5 << endl;
    }
    else if (S.at(0) == 'W')
    {
        cout << 4 << endl;
    }
    else if (S.at(0) == 'T' && S.at(1) == 'H')
    {
        cout << 3 << endl;
    }
    else if (S.at(0) == 'F')
    {
        cout << 2 << endl;
    }
    else if (S.at(0) == 'S' && S.at(1) == 'A')
    {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
S=input()
length=len(S)

change_a=0
for i in range(length):
    if i%2==0 and S[i]=='1':
        change_a+=1
    if i%2==1 and S[i]=='0':
        change_a+=1

change_b=0
for i in range(length):
    if i%2==0 and S[i]=='0':
        change_b+=1
    if i%2==1 and S[i]=='1':
        change_b+=1

print(min(change_a, change_b))

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <ctime>
#include <cstdlib>
#include <iterator>
using namespace std;

//#define TEST
int main()
{
#ifdef TEST
	freopen("data.in", "r", stdin);
	freopen("data.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	string str;
	while(cin >> str) {
		int a[128] = {0};
		for (int i= 0; i < str.length(); ++i)
			a[str[i]] = 1;
		bool fg = false;
		for (char i = 'a'; i <= 'z'; ++i) {
			if(a[i] == 0) {
				cout << i << endl; fg = true; break;
			}
		}
		if(fg == false) cout << "None" << endl;
	}

	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    int t;
    int x=3;
    set<int> S;
    while(x--){
        cin >> t;
        S.insert(t);
    }
    cout << S.size();
 
    return 0;
}


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

count = 0

for i in range(N-2):
    letter1 = S[i]
    letter2 = S[i+1]
    letter3 = S[i+2]

    if (letter1 == 'A') and (letter2 == 'B') and (letter3 == 'C'):
        count += 1

print(count)
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n,s,u,md,f[N];
char c[N];
vector<int> e[N];
int dfs(int x,int fa)
{
	int ret = (c[x] == 'W');int deg = fa > 0;
	for(int i = 0;i < e[x].size();i ++)
	{
		int y = e[x][i];
		if(y != fa && dfs(y,x))
			ret = 1,s += 2,deg ++;
	}
	if(ret)
	{
		f[x] = (deg&1) != (c[x] == 'W');
		s += f[x];f[x] *= 2;
	}
	else
		f[x] = -1;
	return ret;
}
void dfs2(int x,int fa,int d)
{
	d += f[x];if(d >= md) md = d,u = x;
	for(int i = 0;i < e[x].size();i ++)
	{
		if(e[x][i] != fa && f[e[x][i]] != -1)
			dfs2(e[x][i],x,d);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i = 1;i < n;i ++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	scanf("%s",c+1);
	for(int i = 1;i <= n;i ++)
		if(c[i] == 'W')
		{
			dfs(i,0);md = -N;
			dfs2(i,0,0);md = -N;
			dfs2(u,0,0);
			printf("%d\n",s > 1?s-md:1);
			return 0;
		}
	printf("0\n");
	return 0;
}

Measured memory_bytes: 13952
#include <iostream>
using namespace std;
int attacks(int h, int a){
    if(h<a)
    return 1;
    
    int p = h/a;
    if(h%a==0)
    return p;
    else
    return p+1;
}
int main() {
	int h,a;
	cin>>h>>a;
	cout<<attacks(h, a);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

#define REP(i,n) for(LL i=0, i##_len=(n); i<i##_len; ++i)

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

template <LL MOD=1000000007> class MODLL {
public:
  LL x;
  MODLL(const LL _x) : x(_x % MOD) {};
  MODLL operator+(const MODLL rhs) const { return MODLL(*this) += rhs; }
  MODLL operator-(const MODLL rhs) const { return MODLL(*this) -= rhs; }
  MODLL operator*(const MODLL rhs) const { return MODLL(*this) *= rhs; }
  MODLL operator/(const MODLL rhs) const { return MODLL(*this) /= rhs; }
  MODLL& operator+=(const MODLL rhs) { x += rhs.x; x %= MOD; return *this; }
  MODLL& operator-=(const MODLL rhs) { x -= rhs.x; x %= MOD; if(x<0) x += MOD; return *this; }
  MODLL& operator*=(const MODLL rhs) { x *= rhs.x; x %= MOD; return *this; }
  MODLL inv() const {
    if(x == 0) { throw "does not have inverse"; }
    LL a = x, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return MODLL(u);
  }
  MODLL& operator/=(const MODLL rhs) { (*this) *= rhs.inv(); return *this; }
  MODLL pow(ULL n) const {
    MODLL res = 1;
    MODLL a = x;
    while (n > 0) {
      if (n & 1) res *= a;
      a = a * a;
      n >>= 1;
    }
    return res;
  }
};

typedef MODLL<> ML;

int main() {
  int H, W;
  std::cin >> H >> W;
  std::vector<std::string> S(H);
  REP(i, H) {
    cin >> S[i];
  }

  std::vector< std::vector<int> > cnt(H, std::vector<int>(W, -1));
  REP(i, H) {
    int num_l = 0;
    int left = -1;
    REP(j, W+1) {
      if( j == W || S[i][j] == '#' ) {
        if( left < 0 ) continue;
        for( int k = left; k < j; k++) {
          cnt[i][k] += num_l;
        }
        num_l = 0;
        left = -1;
      }
      else {
        if( left < 0 ) { left = j; }
        num_l++;
      }
    }
  }
  REP(j, W) {
    int num_l = 0;
    int left = -1;
    REP(i, H+1) {
      if( i == H || S[i][j] == '#') {
        if( left < 0 ) continue;
        for( int k = left; k < i; k++) {
          cnt[k][j] += num_l;
        }
        num_l = 0;
        left = -1;
      }
      else {
        if( left < 0 ) { left = i; }
        num_l++;
      }
    }
  }

  int ans = 0;
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      ans = std::max(ans, cnt[i][j]);
    }
  }
  std::cout << ans << std::endl;

  return 0;
}



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

/// Info.
///****************************************************************************************************************************************///
/// author                : BAHAA El_DEEN OSAMA
/// Date                  : 11/9/2020
///****************************************************************************************************************************************///


int main()
{

    int a,b;cin>>a>>b;
    cout<< (a+b)%24<<endl;
    return 0;
}



Measured memory_bytes: 3628
import java.util.*;

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

    int n = sc.nextInt();

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

    int count = 0;
    for (int i = 0; i < n - 2; i++) {
      int a = list[i];
      int b = list[i+1];
      int c = list[i+2];

      if((b > a && b < c) || (b < a && b > c)) {
        count++;
      }
    }

    System.out.println(count);
  }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
int A[2000];
int main() {
	ll N, K, Q;
	cin >> N >> K >> Q;
	for (int i = 0; i < N; i++) cin >> A[i];
	int ans = 1 << 30;
	for (int i = 0; i < N; i++) {
		vector<vector<int>> vec;
		vector<int> v;
		vector<int> m;
		for (int j = 0; j < N; j++) {
			if (A[i] <= A[j]) {
				v.push_back(A[j]);
			}
			else {
				if (!v.empty()) vec.push_back(v);
				v.clear();
			}
		}
		if (!v.empty()) vec.push_back(v);
		for (int j = 0; j < vec.size(); j++) {
			if (vec[j].size() < K) continue;
			sort(vec[j].begin(), vec[j].end());
			for (int k = 0; k + K <= vec[j].size(); k++) m.push_back(vec[j][k]);
		}
		sort(m.begin(), m.end());
		if (m.size() >= Q) ans = min(ans, m[Q - 1] - A[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long n = sc.nextLong();
		long cap = 1001001001001001001L;
		for(int i = 0; i < 5; i++){
		    cap = min(cap, sc.nextLong());
		}
		
		// 計算
		long result = 0;
		result = (n + cap - 1)/cap + 4;
		
		// 出力
		System.out.println(result);
        
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
using pii = pair<int,int>;

int main(){
    int N, K, S; cin >> N >> K >> S;
    if(S == (int)1e9){
        rep(i, 0, N){
            if(i != 0) cout << " ";
            if(i < K) cout << S;
            else cout << 1;
        }
        cout << endl;
        return 0;
    }
    rep(i, 0, N){
        if(i != 0) cout << " ";
        if(i < K) cout << S;
        else cout << S + 1;
    }
    cout << endl;
    
}

Measured memory_bytes: 1280
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int N;
    cin >> N;
    int v[N];
    for (int i = 0; i < N; i++){
      cin >> v[i];
    }
    sort(v, v+N);

    double ans = 0;
    double w = 1.0;
    for(int i=N-1;i>=1;i--){
      w /= 2;
      ans += w*v[i];
    }
    ans += w*v[0];

    cout << ans <<endl;

    
  	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
	public class Main
		{ public static void main(String[] args)
			{   
			    Scanner scanner = new Scanner(System.in);
				int N = scanner.nextInt();
				int[] a = new int[N];
				
				int min = 1000;
				int max = 0;
				
				for (int i = 0; i < N; i++) {
				    a[i] = scanner.nextInt();
				    
				    if (min > a[i]) {
				        min = a[i];
				    }
				    
				    if (max < a[i]) {
				        max = a[i];
				    }
				}
				
				System.out.println(max - min);
		}
		}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
#define check(n) reverse(all(n));rep(z,0,n.size())cout<<n[z];co("");reverse(all(n));
using namespace std;
using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  bint c=1,a=1000000000000000000,b;
  int n;
  cin>>n;
  vector<ull> x(n);
  bool f=true;
  rep(i,0,n) cin>>x[i];
  rep(i,0,n){
    if(x[i]==0){f=true; c=0; break;}
    if(f==false) continue;
    if(c*x[i]>a){f=false; c*=x[i]; continue;}
    c*=x[i];
  }
  if(f==true) co(c);
  else co(-1);
  return 0;
}


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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int32_t main()
{
    int a,b,k;
    cin>>a>>b>>k;
    vi v;
    for(int i=1;i*i<=a;i++)
    {
        if(a%i==0)
        {
            v.pb(i);
            if(i*i!=a)
            {
                v.pb(a/i);
            }
        }
    }
    sort(v.begin(),v.end());
    //cout<<v.size()<<"\n";
    int res;
    int cnt=0;
    for(int i=v.size()-1;i>=0;i--)
    {
        if(b%v[i]==0)
         cnt++;
         if(cnt==k)
         {
             res=v[i];
             break;
         }
    }
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){
    int X;
    cin >> X;
    for(int i = X;;i++){
        if(IsPrime(i)){cout << i;return 0;}
    }
}


Measured memory_bytes: 256
s = input()
before = int(s[:2])
after = int(s[2:])
if 1 <= before <= 12:
  if 1 <= after <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= after <= 12:
    print('YYMM')
  else:
    print('NA')

Measured memory_bytes: 9164
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            int tax8 = (int) (i * 0.08);
            int tax10 = (int) (i * 0.1);
            if (a == tax8 && b == tax10) {
                System.out.println(i);
                return;
            }
            if (a < tax8 || b < tax10) {
                System.out.println("-1");
                return;
            }
        }
    }
}


Measured memory_bytes: 23892
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<long long int> H(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	int sum = 0;
	int rec = 0;
	H[N] = 1001000000;
	for (int i = 0; i < N ; i++) {
		if (H[i] >= H[i + 1]) {
			sum++;
		}
		else {
			rec = max(rec, sum);
			sum = 0;
		}
	}
	cout << rec << endl;
	return 0;
}

Measured memory_bytes: 1152
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

def main():
    N = gete(int)
    cur = [0]*3 
    for _ in range(N):
        a = geta(int)
        cur = [max(cur[j-1], cur[j-2]) + a[j] for j in range(3)] 

    print(max(cur))

if __name__ == "__main__":
    main()

Measured memory_bytes: 47576
#include<bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	string s;
	cin>>s;
	ll sum=0;
	ll n=s.length();
	for(int i=0;i<n;i++)
	sum+=s[i]-'0';
	if(sum%9)
	cout<<"No";
	else
	 cout<<"Yes";
}

Measured memory_bytes: 3748
#include <vector>
#include <algorithm>
#include <cstdio>
int main(){
	int n,d,i,r;
	for(;~scanf("%d%d",&n,&d);printf("%d\n",r)){
		std::vector<int>v;
		v.push_back(2),v.push_back(3);
		for(i=2;i<n;i++)v.push_back((v[i-2]+v[i-1])%1001);
		std::sort(v.begin(),v.end());
		for(i=r=1;i<n;i++)if(v[i]-v[i-1]>=d)r++;
	}
}

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

int main(){
  int n;
  cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  int color[8] = {0};
  int cnt = 0;
  rep(i,n){
    if(a[i]<=399) color[0]++;
    else if(a[i]>=400 && a[i]<=799) color[1]++;
    else if(a[i]>=800 && a[i]<=1199) color[2]++;
    else if(a[i]>=1200 && a[i]<=1599) color[3]++;
    else if(a[i]>=1600 && a[i]<=1999) color[4]++;
    else if(a[i]>=2000 && a[i]<=2399) color[5]++;
    else if(a[i]>=2400 && a[i]<=2799) color[6]++;
    else if(a[i]>=2800 && a[i]<=3199) color[7]++;
    else if(a[i]>=3200) {
      cnt++;
    }
  }
  int ans = 0;
  rep(i,8){
    if(color[i]>0) ans++;
  }
  if(ans==0) cout << 1 << " " << ans+cnt << endl;
  else cout << ans << " " << ans+cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

string s, t;

int main(void){
    cin >> s >> t;
    lli m = 0;
    rep(i, s.size()){
        if(i+t.size()-1 < s.size()){
            lli c = 0;
            rep(j, t.size()){
                if(t[j] == s[i+j]) c++;
            }
            m = max(m, c);
        }
    }
    cout << t.size()-m << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define f(i,l,h) for(ll i=l;i<h;i++)
#define fr(i,h,l) for(ll i=h;i>=l;i--)

using namespace std;

typedef pair<ll,ll> pll;
const ll INF=(ll)(1e9+7);
typedef vector<ll> vll;

int main()
{
    //cout << "Hello world!" << endl;

    ll n;
    cin>>n;
    ll a[n];
    ll b[n];

    f(i,0,n){
        cin>>a[i]>>b[i];
    }

    sort(a,a+n);
    sort(b,b+n);

    if(n&1){
        ll mn=a[n/2];
        ll mx=b[n/2];
        cout<<mx-mn+1<<endl;
    }else{
        ll mn=a[n/2-1] + a[n/2];
        ll mx=b[n/2-1] + b[n/2];
        cout<<mx-mn+1<<endl;
    }

    return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	for(int i=0; i<ty - sy; i++){
		printf("U");
	}
	for(int i=0; i<tx - sx; i++){
		printf("R");
	}
	for(int i=0; i<ty - sy; i++){
		printf("D");
	}
	for(int i=0; i<tx - sx; i++){
		printf("L");
	}

	printf("L");

	for(int i=0; i<ty - sy; i++){
		printf("U");
	}
	printf("U");

	for(int i=0; i<tx - sx; i++){
		printf("R");
	}
	printf("R");
	printf("D");
	printf("R");
	for(int i=0; i<ty - sy; i++){
		printf("D");
	}
	printf("D");
	for(int i=0; i<tx - sx; i++){
		printf("L");
	}
	printf("L");
	printf("U");
	puts("");
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
res = [0]*n

for x in range(n-1):
  c,s,f = map(int,input().split())
  for y in range(x+1):
    if res[y] < s:
      res[y] = s + c
    else:
      res[y] = ((res[y]-1)//f +1)*f + c
  
for asldijfgherab in range(n):
  print(res[asldijfgherab])

Measured memory_bytes: 3060
#include<stdio.h>
#define N 500000
#define M 1000000000
void merge(int [],int ,int ,int );
void mergesort(int [],int ,int );
int arr[N/2+2],fg[N/2+2],count=0; 

int main(){
  int i,k,r[N];
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d",&r[i]);
  }
  mergesort(r,0,k);
  for(i=0;i<k-1;i++){
    printf("%d ",r[i]);
  }
  printf("%d\n",r[k-1]);
  printf("%d",count);
  printf("\n");
  return 0;
}
void merge(int A[],int l,int m,int r){
  int i,j,k;
  int a;
  int b;
  a=m-l;
  b=r-m;
  for(i=0;i<a;i++){
    arr[i] = A[l+i];
  }
  for(i=0;i<b;i++){
    fg[i]=A[m+i];
  }
  arr[a]=fg[b]=M;
  i = j = 0;
  for(k=l;k<r;k++){
    count++;
    if(arr[i] <= fg[j]){
      A[k] = arr[i];
      i++;
    }
      else {
    A[k] = fg[j];
    j++;
      }
  }
}
void mergesort(int A[],int l,int r){
  int m;
  if(l+1<r){
    m = (l+r)/2;
    mergesort(A,l,m);
    mergesort(A,m,r);
    merge(A,l,m,r);
  }
}
 

Measured memory_bytes: 4508
s=input()
sum=0
temps=list(s)
l=len(temps)-1
for i in range(0,2**l):
  temp=s[0]
  for j in range(0,l):
    if (i>>j)&1:
      temp += '+'
    temp += s[j+1]
  sum=sum+eval(temp)
print(sum)

Measured memory_bytes: 3060
w,h,n=map(int,input().split())
b=c=0
for _ in [0]*n:
    x,y,a=map(int,input().split())
    if a==1:b=max(b,x)
    if a==2:w=min(w,x)
    if a==3:c=max(c,y)
    if a==4:h=min(h,y)
print([(w-b)*(h-c),0][(w<b)|(h<c)])

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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a ,t ,count(0) ,maxi = INT_MAX;
  cin >> t;
  for(int i=0;i<t;++i){
    cin >> a;
    if(a < maxi){
      count++;
      maxi = a;
    }
  }
  cout << count;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
  int n,m,ans;
  cin >> n >> m;
  vector<int> x(m);
  rep(i,m){
    cin >> x.at(i);
  }

  if(n>=m){
    puts("0");
    return 0;
  }

  sort(all(x));

  vector<int> section(m-1);
  int section_sum=0;
  rep(i,m-1){
    section.at(i)=x.at(i+1)-x.at(i);
  }
  sort(all(section));
  reverse(all(section));
  for(int i = 0;i<n-1;i++){
    section_sum+=section.at(i);
  }


  cout << (x.at(m-1)-x.at(0))-section_sum << endl;
}

Measured memory_bytes: 1024
n = int(input())
s=[]
for i in range(n):
  s.append(int(input()))
s.sort()

m = -1
for i in s:
  if i % 10 != 0:
    m = i
    break

if sum(s) % 10 == 0:
  if m == -1:
    print(0)
  else:
    print(sum(s) - m)
else:
  print(sum(s))

Measured memory_bytes: 9076
#include<bits/stdc++.h>
using namespace std;
#define N 1666666
int arr[N];
signed main(){
    
    string str;
    cin>>str;
    int m;scanf("%d",&m);
    int sum=0;
    while(m--){
        int op;
        scanf("%d",&op);
        if(op==1){
            sum++;
        }else{
            int k;
            char ch;
            scanf("%d",&k);
            cin>>ch;
            if(sum%2==0){
                if(k==1){
                    str.insert(str.begin(),ch);
                }else{
                    str.insert(str.end(),ch);
                }  
            }else{
                if(k==1){
                    str.insert(str.end(),ch);
                }else{
                    str.insert(str.begin(),ch);
                }  
            }
            
        }
    }
    if(sum%2==0)
        cout<<str;
    else 
        {
            reverse(str.begin(),str.end());
            cout<<str;
        }
    return 0;
}

/*
))((())(

*/

Measured memory_bytes: 1028
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int MAX = 100005;
const int NIL = -1;


struct Node {
	int p, l, r;
};
Node Tree[MAX];
int n, Depth[MAX];


void print(int u) {
	printf("node %d: ", u);
	printf("parent = %d, ", Tree[u].p);
	printf("depth = %d, ", Depth[u]);

	if (Tree[u].p == NIL)
		printf("root, ");
	else if (Tree[u].l == NIL)
		printf("leaf, ");
	else
		printf("internal node, ");

	printf("[");
	// ????????????????????????????§???????
	int c = Tree[u].l;
	while (c != NIL) {
		printf("%d", c);
		if (Tree[c].r != NIL)
			printf(", ");
		// ?????°?????§?´§??????????????????
		c = Tree[c].r;
	}
	printf("]\n");
}

// ??????????±???±???
void rec(int u, int depth) {
	Depth[u] = depth;
	if (Tree[u].r != NIL)  // ?????§???????????????????????±???
		rec(Tree[u].r, depth);
	if (Tree[u].l != NIL)  // ????????§??????????????±?????????????????±?????±??? + 1
		rec(Tree[u].l, depth + 1);
}
int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		Tree[i].p = Tree[i].l = Tree[i].r = NIL;
	}
	int v, num, c, l, root;
	for (int i = 0; i < n; i++) {
		// v?????????????????? ???num???v????????????????????° 
		scanf("%d %d", &v, &num);
		for (int j = 0; j < num; j++) {
			scanf("%d", &c);

			//??????????????§?????? ??? ?´§????????§????????????
			// l??°????????????????????????????°?????????????????????????l????´§????????§??????
			if (j == 0)
				Tree[v].l = c;
			else
				Tree[l].r = c;
			l = c;
			// ????????¶??????
			Tree[c].p = v;
		}
	}
	// ???????????????
	for (int i = 0; i < n; i++) {
		if (Tree[i].p == NIL)
			root = i;
	}

	rec(root, 0);
	for (int i = 0; i < n; i++)
		print(i);
	return 0;
}

Measured memory_bytes: 7804
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut bars: [usize; n],
    }

    let mut result = 0;
    for i in 0..n {
        for j in i + 1..n {
            for k in j + 1..n {
                let mut triangle = Vec::new();
                triangle.push(bars[i]);
                triangle.push(bars[j]);
                triangle.push(bars[k]);

                // 長さの異なる 3 本の棒のみを選ぶ
                triangle.sort();
                triangle.dedup_by(|a, b| a.eq(&b));
                if triangle.len() < 3 {
                    continue;
                }

                // 三角形を成立させられる場合、成功
                let len: usize = triangle.iter().map(|t| t).sum();
                let max = triangle.iter().map(|t| t).max().unwrap();
                let rest = len - max;
                if max < &rest {
                    result += 1;
                }
            }
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 2308
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define print(x) cout<<(x)<<'\n'
using ll=long long;
using pl=pair<ll,ll>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vs=vector<string>;

void solve() {
    ll a,b,h;
    cin >> a >> b >> h;
    print((a+b)*h/2);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


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

int main() {
  int N, ans=0, t=0;
  cin >> N;
  vector<int> s(N);
  for (int i=0; i<N; i++) {
    cin >> s[i];
    ans+=s[i];
  }
  if (ans%10==0) {
    sort(s.begin(),s.end());
    for (int i=0; i<N; i++) {
      if (s[i]%10!=0) {
        ans-=s[i];
        break;
      }
      t++;
    }
  }
  if (t==N) {
    ans=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
// syakutori
#include <algorithm>
#include <iostream>
using namespace std;

int ans, tmp;

int main(void)
{
    int n, k;
    while(1) {
        cin >> n >> k;
        if(n==0 && k==0) break;

        int a[n];
        for(int i=0; i<n; i++) cin >> a[i];
        ans = 0;
        for(int i=0; i<k; i++) ans += a[i];
        tmp = ans;
        for(int i=0; i<n-k; i++) {
            tmp = tmp + a[k + i] - a[i];
            ans = max(ans, tmp);
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1548
#include <stdio.h>
#define Alen 2000000

void SwapElement(int *A,int i, int j){
  int tmp = A[i];
  A[i] = A[j];
  A[j] = tmp;
}

int Partition(int *A, int p, int r){
  int x = A[r];
  int i = p-1;
  int j;
  for(j=p; j<r; j++){
    if(A[j] <= x){
      i++;
      SwapElement(A,i,j);
    }
  }
  SwapElement(A,i+1,r);
  return i+1;
}

int main(){
  int n,i,q;
  int A[Alen];
  
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  
    q = Partition(A,0,n-1);
    
    for(i=0; i<n; i++){
      if(i==q)printf("[");
      printf("%d",A[i]);
      if(i==q)printf("]");
      if(i!=n-1)printf(" ");
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
char a[1002][1002];
long long f[1002][1002];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if((i==1)&&(j==1)){
				f[i][j]=1;
				continue;
			}
			if(a[i][j]=='.'){
				f[i][j]=(f[i][j-1]+f[i-1][j])%1000000007;
			}
			else
				f[i][j]=0;
		}
	}
	cout<<f[n][m];
}

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

void solve1()
{
    int n; cin >> n;
    map<ll, ll> d; 
    set<ll> dm;
    rep(i, n) {
        int a; cin >> a;
        d[a]++;
        dm.insert(a);
    }

    int m; cin >> m;
    map<ll, ll> t; 
    rep(i, m) {
        int a; cin >> a;
        t[a]++;
        dm.insert(a);
    }

    bool f = true;
    for(auto itr = dm.begin(); itr != dm.end(); itr++) {
        if(t[*itr] > d[*itr]) {
            f = false;
        }
    }

    string ans;
    if(f) {
        ans = "YES";
    } else {
        ans = "NO";
    }

    cout << ans << endl;
    
}

int main()
{
    solve1();
}


Measured memory_bytes: 37916
#include<stdio.h>

int main(void){
    int x[100];
    int n;
    int i;
    
    scanf("%d", &n);
    for(i = 1; i <= n; i++){
        scanf("%d", &x[n - i]);
    }
    for(i = 0; i < n; i++){
        printf("%d",x[i]);
        if(i != n -1)
            printf(" ");
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2060
#include <iostream>

int main()
{
	int a, b, count;
	std::cin >> a;
	for(int i = 1; i <= a; i++)
	{
		for(int j = i+1; j <= a; j++)
		{
			b = (i + j) %2;
			if(b == 1)
			{
				count++;
			}
		}
	}
	std::cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(ll, h, w);
    ll ans = 1e6;

    for(int i = 1; i < h; i ++){
        ll a = w*i, b, c;
        if((h-i) % 2 == 0 || w % 2 == 0) b = c = w*(h-i)/2;
        else{
            if(h-i < w) b = (w/2)*(h-i), c = (w/2+1)*(h-i);
            else b = ((h-i)/2)*w, c = ((h-i)/2+1)*w;
        }
        ans = min(ans, max(max(abs(a-b), abs(b-c)), abs(c-a)));
    }
    
    swap(w, h);
    
    for(int i = 1; i < h; i ++){
        ll a = w*i, b, c;
        if((h-i) % 2 == 0 || w % 2 == 0) b = c = w*(h-i)/2;
        else{
            if(h-i < w) b = (w/2)*(h-i), c = (w/2+1)*(h-i);
            else b = ((h-i)/2)*w, c = ((h-i)/2+1)*w;
        }
        ans = min(ans, max(max(abs(a-b), abs(b-c)), abs(c-a)));
    }
    
    Cout(ans);
}

Measured memory_bytes: 256
def resolve():
    N, M, X, Y = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))
    ans = 0
    for z in range(X+1, Y+1):
        if max(x)<z and z<=min(y):
            ans += 1
    print("No War" if ans != 0 else "War")
resolve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << '\n';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;

  ui N{}, K{}; cin >> N >> K;
  vector<ll> V(N);
  rep(0, N) cin >> V[i];

  ll ans{0};
  for (ui numA = 0; numA < K + 1; ++numA)
  {
    if (numA > N) break;
    for (ui numB = 0; numA + numB < K + 1; ++numB)
    {
      if (numB > N) break;
      if (!numA && !numB) continue;
      if (numA + numB > N) break;

      vector<ll> has{};
      has.reserve(N);
      rep(0, numA) has.push_back(V[i]);
      rep(0, numB) has.push_back(V[(V.size() - 1) - i]);

      std::priority_queue<ll, vector<ll>, std::greater<ll>> res(std::greater<ll>(), has);

      ll sum = boost::accumulate(has, (ll)0LL);
      ui inf = K - (numA + numB);
      while (inf != 0
        && !res.empty()
        && res.top() < 0)
      {
        sum -= res.top();
        res.pop();
        --inf;
      }
      ans = std::max(sum, ans);
    }
  }

  using std::cout;
  cout << ans << '\n';
  
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/ruby
n,*a=`dd`.split.map &:to_i
s,idx=[0,1].map{|x|
	idx=[]
	s=0
	x.step(n-1,2){|i|
		if a[i]>0
			idx<<i
			s+=a[i]
		end
	}
	[s,idx]
}.max

if s<1
	i=(0...n).max_by{|i|a[i]}
	p a[i]
	r=n.downto(i+2).to_a+[1]*i
	p r.size
	p *r
else
	p s
	j=idx[-1]
	r=n.downto(j+2).to_a
	idx[0..-2].reverse.each{|i|
		r+=((i+j)/2+1).downto(i+2).to_a
		j=i
	}
	r+=[1]*idx[0]
	p r.size
	p *r
end


Measured memory_bytes: 2820
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, ans;
	cin >> n;
	cout << n / 3 << "\n";

	return 0;
}


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

"""
参考：http://drken1215.hatenablog.com/entry/2018/08/05/224100_1
・文字列DP
・こういう、ちょっと状況込み入ったDPがまだ自分でうまく書けない。
・もっと数こなして経験積まなきゃなー。
"""

MOD = 10 ** 9 + 7
S = input()

# 文字列Sのi文字目まで考えたときにABCのj文字目まで照合させた個数
dp = [[0] * 4 for i in range(len(S)+1)]
dp[0][0] = 1

for i in range(len(S)):
    # i文字目でABCカウントを進めない場合(真下に送る分)
    for j in range(4):
        if S[i] == '?':
            dp[i+1][j] = (dp[i+1][j] + dp[i][j] * 3) % MOD
        else:
            dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD
    # i文字目でABCカウントを進める場合(右下に送る分)
    if S[i] == '?' or S[i] == 'A':
        dp[i+1][1] = (dp[i+1][1] + dp[i][0]) % MOD
    if S[i] == '?' or S[i] == 'B':
        dp[i+1][2] = (dp[i+1][2] + dp[i][1]) % MOD
    if S[i] == '?' or S[i] == 'C':
        dp[i+1][3] = (dp[i+1][3] + dp[i][2]) % MOD

print(dp[len(S)][3])


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

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

int main(){
    int n, k; cin >> n >> k;
    vector<long long int> h(n); rep(i, n) cin >> h[i];
    if(n <= k) cout << 0 << endl;
    else if(k == 0) cout << accumulate(h.begin(), h.end(), 0LL) << endl;
    else{
        sort(h.begin(), h.end(), greater<int>());
        h.erase(h.begin(), h.begin()+k);
        cout << accumulate(h.begin(), h.end(), 0LL) << endl;
    }
}

Measured memory_bytes: 1792