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

int main() {
    int H,W;
    cin >> H >> W;
    vector<string> a(H);
    for(int i=0;i<H;i++) {
        cin >> a.at(i);
    }

    for(int i=0;i<W+2;i++) {
        cout << "#";
    }
    cout << endl;

    for(int i=0; i<H;i++) {
        cout << "#";
        cout << a.at(i);
        cout << "#" << endl;
    }

    for(int i=0;i<W+2;i++) {
        cout << "#";
    }
    cout << endl;
}

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

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k, i, j;
    
    cin >> n >> k;
    
    int a[n];
    int stones[k + 1] = {};
    
    for(i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    
    stones[0] = 0;
    int ind, flag;
    for(i = 1; i <= k; ++i)
    {
        for(j = 0; j < n; ++j)
        {
            ind = i - a[j];
            if ((ind >= 0) && (stones[ind] == 0))
            {
                stones[i] = 1;
                
                break;
            }
        }
    }
    
    if (stones[k])
    {
        cout << "First";
    }
    else
    {
        cout << "Second";
    }
    
    
    
    return 0;
}

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

#define VIC ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define sfi(x) scanf("%d", &x)
#define sfi2(x, y) scanf("%d%d", &x,&y)
#define sfl2(x, y) scanf("%I64d%I64d", &x,&y)
#define sfl(x) scanf("%I64d", &x)
#define sfd(x) scanf("%lf", &x)
#define sfd2(x, y) scanf("%lf%lf", &x, &y)
#define sfs(x) scanf("%s", &x)
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;
const int N = 1e2 + 2, K = 1e5 + 5, mod = 1e9 + 7;

inline int add(int x, int y)
{
    x += y;
    if (x >= mod)
        x -= mod;
    return x;
}

inline int sub(int x, int y)
{
    x -= y;
    if (x < 0)
        x += mod;
    return x;
}

int n, k, a[N], dp[N][K], prefix[N][K];

int solve()
{
    for (int i = 0; i <= n; i++)
        prefix[i][0] = dp[i][0] = 1;
    for (int i = 0; i <= k; i++)
        prefix[0][i] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= k; j++)
        {
            int first = (j - a[i] - 1 >= 0? prefix[i - 1][j - a[i] - 1]: 0);
            int last = prefix[i - 1][j];
            dp[i][j] = add(dp[i][j], sub(last, first));
            prefix[i][j] = add(dp[i][j], prefix[i][j - 1]);
        }
    return dp[n][k];
}

int main()
{
    VIC
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    cout << solve();
    return 0;
}


Measured memory_bytes: 79616
s=input()
q=int(input()) 

cnt = [0]*(q+5)
arr=[]
l=0
r=0

for i in range(q):
    t=input().split()
    if t[0]=='1':
        r+=1
        cnt[0]+=1 
        cnt[l]-=1 
    else:
        arr.append([t[2],int(t[1])])
        l+=1 
if r%2==1:
    s=s[::-1]
sm=0
for i in range(len(arr)):
    sm+=cnt[i]
    if sm%2==1:
        if arr[i][1]==1:arr[i][1]=2
        elif arr[i][1]==2:arr[i][1]=1 
ans1=""
ans2=""
for i in range(len(arr)):
    if arr[i][1]==1:
        ans1+=arr[i][0]

    else:ans2+=arr[i][0]
print("%s%s%s"%(ans1[::-1],s,ans2))        
        
    
    
    
    

Measured memory_bytes: 26316
#include <iostream>

int main(){
unsigned int K, S;

std::cin >> K >> S;

unsigned int count = 0;

for (unsigned int X = 0; X <= K && X <= S; ++X){
for (unsigned int Y = 0; Y <= K && Y <= S; ++Y){

if (X+Y <= S && S-X-Y <= K){
++count;
}

}
}

std::cout << count << std::endl;

return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(12);
    ll a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    if(a1+a2+a3 >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int i, s_len, t_len;
	char s[128], t[256];
	scanf("%s", s);
	scanf("%s", t);
	s_len = strlen(s);
	t_len = strlen(t);
	strncpy(t+t_len, t, t_len-1);
	if (strstr(t, s) != NULL) {
		printf("Yes");
	} else {
		printf("No");
	}
	return 0;
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	vector<int> s;
	for (int i = 0; i < 3; i++) {
		int a;
		cin >> a;
		s.push_back(a);
	}
	sort(s.begin(), s.end());
	cout << s[0] + s[1];
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char* argv[])
{
	//ABC158 C
	//in A B
	//8%時の消費税・10%時の消費税
	int a, b;
	int price = -1;
	int tmp_price;
	int tmp_a, tmp_b;

	scanf("%d %d", &a, &b);

	// 10%から予測
	tmp_price = b * 10;
	do {
		tmp_a = (int)(tmp_price * 0.08);
		tmp_b = (int)(tmp_price * 0.1);
		if ((tmp_a == a) && (tmp_b == b)) {
			price = tmp_price;
			break;
		}
	} while (tmp_price++ / 10 <= b);

	printf("%d", price);
	return 0;
}



Measured memory_bytes: 128
x=int(input())


if x>=1800:
    print(1)
elif x>=1600:
    print(2)
elif x>=1400:
    print(3)
elif x>=1200:
    print(4)
elif x>=1000:
    print(5)
elif x>=800:
    print(6)
elif x>=600:
    print(7)
elif x>=400:
    print(8)


Measured memory_bytes: 9168
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    int ans[10001] = {};
    for (int x = 1; x < 100; x++) {
        for (int y = 1; y < 100; y++) {
            for (int z = 1; z < 100; z++) {
                int num = x*x+y*y+z*z+x*y+y*z+z*x;
                if (num <= n) ans[num]++;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3584
A,B,C = map(int, input().split())

max_num = max(A,B,C)

flg = 0
if (max_num*3%2 == (A+B+C)%2):
    target = max_num
else:
    target = max_num+1
    flg += 1

ans = (3*target-(A+B+C)) // 2
print(ans)

Measured memory_bytes: 3060
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

const int INF = 1e9;


// code
// ------------------------------------------------
int main() {
  int n,k;
  cin >> n >> k;

  vector<int> l(n);

  rep(i,n) cin >> l[i];

  sort(l.rbegin(),l.rend());
  int max =0;
  rep(i,k) max += l[i];

  cout << max;





  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 2.80 + c[j] * 12.5;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

Measured memory_bytes: 3724
#include<iostream>
#include<cmath>
int main()
{
	long long a,b;
	scanf("%lld%lld",&a,&b);
	if(a<=b)
	{
		if((a>=0&&b>=0)||(a<0&&b<0))
		printf("%lld",b-a);
		if(a<0&&b>=0)
		{
			if(b==0)
			printf("%d",b-a);
			else
			{
				if(-a<b)
		        printf("%lld",1+a+b);
		        else
		        printf("%lld",1-a-b);
			}
		}
	}
	else
	{
		if(a>=0&&b<0)
		{
			if(a>=-b)
			printf("%lld",1+a+b);
			else
			printf("%lld",1-a-b);
		}
		if((a<0&&b<0)||(a>=0&&b>=0))
		{
			if(b!=0)
		    printf("%lld",2+a-b);
			else
			printf("%lld",1+a-b);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define NUM 60

using namespace std;

int main(){
	int n, r, from[NUM], to[NUM], tmp[NUM]; 
	while(cin>>n>>r, n, r){
		for(int i=0; i<n; i++) from[i] = to[i] = n-i;
		for(int k=0; k<r; k++){
			int p, c, j=0; cin>>p>>c;
			for(int i=0; i<p-1; i++)tmp[i] = from[i];
			for(int i=p-1; i<p+c-1; i++) to[j++] = from[i];
			for(int i=0; i<p-1; i++) to[j++] =tmp[i];
			for(int i=0; i<n; i++) from[i] = to[i];
		}
		cout << from[0] << endl;
	}
	return 0;
}


Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int H, W; cin >> H >> W;
	string S[H]; REP(i, H) cin >> S[i]; 

	V2(ans, H, W);
	REP(i, H){
		REP(j, W){
			if(S[i][j] == '#'){
				ans[i][j] = INT_MIN;
				for(int k = -1; k < 2; ++k){
					for(int l = -1; l < 2; ++l){
						if(i-k < 0  or i-k == H or j-l < 0 or j-l == W) continue; 
						else ++ans[i-k][j-l];
					}
				}
			}
		}
	}

	REP(i, H){
		REP(j, W){
			if(ans[i][j] < 0) cout << '#';
			else cout << ans[i][j];
		}cout << endl;
	}
}


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

int gcd(int m, int n){
    if(n==0) return m;
    else return gcd(n,m%n);
}

int main(){
    int k;
    cin >> k;
    ll ans=0;
    for(int a=1; a<=k; a++){
        for(int b=1; b<=k; b++){
            for(int c=1; c<=k; c++){
                int abgcd, abcgcd;
                abgcd = gcd(a,b);
                abcgcd = gcd(abgcd,c);
                ans += abcgcd;
            }
        }
    }
    cout << ans << endl;

   

}

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

int main(){
  int n, fibn[1000];
  fibn[0] = fibn[1] = 1;
  cin >> n;
  for(int i = 2; i <= n;i++)
    fibn[i] = fibn[i-1] + fibn[i-2];
  cout << fibn[n] << endl;
  return 0;
}


Measured memory_bytes: 3124
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846264338327950L

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, Q, i, j, k, l, tmp, ans;

int main(){
    ll a;
    cin >> a;
    cout << (a + pow(a, 2) + pow(a, 3)) << endl;
    return 0;
}

Measured memory_bytes: 4016
import java.util.Scanner;

class Main{

  static boolean isIncluded(int[] a, int x){
    for(int i = 0; i < a.length; i++)
      if(a[i] == x)
        return true;

    return false;
  }

  public static void main(String[] arsg){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int[] a = new int[n];

    for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt();

    int q = stdIn.nextInt();
    int count = 0;
    for(int i = 0; i < q; i++){
      int x = stdIn.nextInt();
      if(isIncluded(a, x))
        count++;
    }

    System.out.println(count);
  }
}

Measured memory_bytes: 39968
import random

D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]

res=0
last=[0]*26
for i in range(D):
    t=int(input())
    res+=s[i][t-1]
    last[t-1]=i+1
    minus=sum(c[j]*(i+1-last[j]) for j in range(26))
    res-=minus
    print(res)

Measured memory_bytes: 78676
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "DENIED" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    rep(i,N){
        if(A[i]%2==0 and !(A[i]%3==0 or A[i]%5==0)) dame;
    }
    cout<< "APPROVED" <<"\n";

}

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


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int m = n;
    int s = 0;
    while(m > 0){
      s += m % 10;
      m /= 10;
    }
 
    if(n % s == 0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int h, w;cin >> h >> w;
    for(int i=0;i<h;i++){
        string s;cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
def CountingSort(A, B, k):
    C = [0] * (k + 1)
    for j in range(n):
        C[A[j]] += 1
    C[0] -= 1
    for i in range(1, k + 1):
        C[i] += C[i - 1]
    for j in A[::-1]:
        B[C[j]] = j
        C[j] -= 1
A = list(map(int, input().split()))
B = [0] * n
CountingSort(A, B, max(A))
print(" ".join(map(str,B)))



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

using namespace std;

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

  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  bool cant = false;
  for (int i = 0; i < h - 1; i++) {
    for (int j = 0; j < w - 1; j++) {
      cant |= (s[i + 1][j] == '#' && s[i][j + 1] == '#');
    }
  }
  cout << (cant ? "Impossible" : "Possible") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
  char data[10000];
  int i;

  while(fgets(data,10000,stdin)){
    for(i=0;;i++){
      if(data[i]=='\0') break;
      if(data[i]>='A' && data[i]<='Z'){
	data[i]= data[i]-'A'+'a';
      }
      else if(data[i]>='a' && data[i]<='z'){
	data[i]= data[i]-'a'+'A';
      }
      printf("%c", data[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <queue>
#define ll long long int
#define inf 3e18+1
#define all(v) (v).begin(),(v).end() 
#define N 200005
#define F first
#define S second
using namespace std;
ll mod=1e9+7;
ll dp[200001];
ll solve(ll n){
    if(n==3) return 1;
    if(n<3) return 0;
    if(dp[n]!=-1) return dp[n];
    ll ans=1;
    for(int i=3;i<=n;i++) {
        ans=(ans+solve(n-i))%mod;
    }
    return dp[n]=ans;
}
int main()
{
    // added the two lines below 
    ios_base::sync_with_stdio (false); 
    cin.tie(NULL);
    cout.tie(0);    
    ll test=1;//cin>>test;
    while(test--){
        memset(dp,-1,sizeof(dp));
        ll n;
        cin>>n;
        cout<<solve(n);
    }
    return 0;
}




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

int main(){
	string c;

	cin >>c;

	if(c == "a")
		cout <<"vowel" <<endl;
	else if(c == "i")
		cout <<"vowel" <<endl;
	else if(c == "u")
		cout <<"vowel" <<endl;
	else if(c == "e")
		cout <<"vowel" <<endl;
	else if(c == "o")
		cout <<"vowel" <<endl;
	else
		cout <<"consonant" <<endl;



	return 0;
}

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

int main()
{
	int n;
	int h[200000];
	int ans,ans_tmp;
	int iti;
	int j = 0;

	cin >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> h[i];
	}
	ans = 0;
	ans_tmp = 0;
	for (iti = 0;iti < n;)
	{
		for (j = iti;j+1<n;)
		{
			if (h[j] >= h[j+1])
			{
				ans_tmp++;
			}
			else
			{
				iti = j;
				break;
			}
			j++;
		}
		iti = j;
		if (ans < ans_tmp)
			ans = ans_tmp;
		ans_tmp = 0;
		iti++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
//A
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();

		int ans = 0;

		for(int i=0;i<2;i++) {

			if(A>B) {

				ans += A;

				A--;

			}else {

				ans += B;

				B--;
			}
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

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

	    int N=gi();
	    int K=gi();
	    int[] D=new int[K];
	    
	    for (int i=0; i<K;i++) {
            D[i]=gi();
	    }
	    int a=N;
	    while(true) {
	    	boolean flg=true;
	    	String s=String.valueOf(N);
	    	for (int i=0; i<K;i++) {
	    		if (s.contains(String.valueOf(D[i]))) flg=false;
	    	}
	    	if(flg) break;
	    	N++;
	    }
	    System.out.println(N);
	}

	public static double f(double r, double n, double m, double i) {
		double a = 0;
		double b=0;
		if(0<i&&i<n) {
			a=Math.abs(r-((2*r/n)*i));
			a= Math.sqrt(Math.pow(r, 2) - Math.pow(a, 2));
		}
		if(0<i-m&&i-m<n) {
			b=Math.abs(r-(2*r*(i-m)/n));
			b=Math.sqrt(Math.pow(r, 2) - Math.pow(b, 2));
		}
		return 2* Math.max(a, b);
	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 53960
import Control.Monad
import Text.Printf
import Control.Applicative
import Data.List as L

primes :: Integral a => [a]
primes = map fromIntegral primes'
  where
    primes' :: Integral a => [a]
    primes' = [2,3,5] ++ f 5 7 (drop 2 primes')

    f :: Integral a => a -> a -> [a] -> [a]
    f m s (p:ps) = [n | n <- ns, gcd m n == 1]
                   ++ f (m*p) (p^2) ps
      where -- Primes are either 6n+1 or 6n+5 form.
        ns = [x + y | x <- [s, s +6 .. p^2 -2], y <- [0, 4]]

primeList :: [Integer]
primeList = filter (\x -> x `mod` 5 == 1) $ takeWhile (< 55555) primes

main :: IO()
main = do
  [n] <- map read . words <$> getLine
  printf "%s" $ slv n

slv :: Int -> String
slv n = unwords $ map show ansPrimList
  where ansPrimList = take n primeList

isPrime :: Integer -> Bool
isPrime 2 = True
isPrime n
    | n < 2 = False
    | n `mod` 2 == 0 = False
    | otherwise = try n 3
    where
        try :: Integer -> Integer -> Bool
        try m i
            | m `mod` i == 0 = False
            | i^2 > m = True
            | otherwise =  try m (i+2)

comb :: Integer -> [a] -> [[a]]
comb 0 xs = [[]]
comb _ [] = []
comb n (x:xs) = [x:y | y <- comb (n-1) xs] ++ comb n xs

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <istream>
#include <sstream>
using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	if (B%A == 0)
	{
		cout << A + B << endl;
	}
	else
	{
		cout << B - A << endl;
	}

}

Measured memory_bytes: 256
package main

import (
    "fmt"
    "os"
)

func main() {

    var N, E, S, W = 0, 0, 0, 0

    var buf [1]byte
    var count = 0
    for {
        n, err := os.Stdin.Read(buf[:])
        if n <= 0 && err != nil {
            break
        }
        switch buf[0] {
        case 'N':
            N++
        case 'W':
            W++
        case 'S':
            S++
        case 'E':
            E++
        }
        count++
    }

    switch {
    case N+S > 0 && N*S == 0:
        fmt.Printf("No\n")
    case E+W > 0 && E*W == 0:
        fmt.Printf("No\n")
          default:
        fmt.Printf("Yes\n")
    }
}

Measured memory_bytes: 512
#ビット全探索の例

H, W, K = map(int, input().split())
C = []
for _ in range(H): C.append([c for c in input()])
ans = 0
for i in range(1<<H):
   for j in range(1<<W):
       cnt = 0
       for m in range(H):
           for n in range(W):
               if i>>m&1: continue
               if j>>n&1: continue
               if C[m][n] == '#': cnt += 1
       if cnt == K: ans += 1
print(ans)

Measured memory_bytes: 9208
import java.io.FileNotFoundException;
import java.util.Scanner;

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

		//    	File file = new File("src/in.txt");

		//コード
		//    	Scanner sc = new Scanner(file);
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = Integer.parseInt(sc.next());
		}
		int[] cnt = new int[1000005];
		for(int i=0;i<N;i++) {
			if(cnt[A[i]] != 0) {
				cnt[A[i]]=2;
				continue;
			}
			int x = A[i];
			for(int j=x;j<1000005;j+=x) {
				cnt[j]+=1;
			}
		}
		int ans = 0;
		for(int i=0;i<N;i++) {
			if(cnt[A[i]]==1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 50236
#include <stdio.h>
int main(void)
{
   int i,j,k,l,n;
   int dice[24][6];

	int label[24][6]={
			{1,2,3,4,5,6},{1,3,5,2,4,6},{1,4,2,5,3,6},
			{1,5,4,3,2,6},{2,1,4,3,6,5},{2,3,1,6,4,5},
			{2,4,6,1,3,5},{2,6,3,4,1,5},{3,1,2,5,6,4},
			{3,2,6,1,5,4},{3,5,1,6,2,4},{3,6,5,2,1,4},
			{4,1,5,2,6,3},{4,2,1,6,5,3},{4,5,6,1,2,3},
			{4,6,2,5,1,3},{5,1,3,4,6,2},{5,3,6,1,4,2},
			{5,4,1,6,3,2},{5,6,4,3,1,2},{6,2,4,3,5,1},
			{6,3,2,5,4,1},{6,4,5,2,3,1},{6,5,3,4,2,1}
			};

   scanf("%d",&n);
   int dices[n][6];
    
   for(i=0;i<n;i++){
       for(j=0;j<6;j++) scanf("%d",&dices[i][j]);
   }
    
   for(i=0;i<n-1;i++){
       for(j=i+1;j<n;j++){
            
           for(k=0;k<24;k++){
               for(l=0;l<6;l++) dice[k][l]=dices[j][label[k][l]-1];
           }
            
           for(k=0;k<24;k++){
               for(l=0;l<6;l++) {
                   if(dice[k][l]!=dices[i][l]) {
                       break;
                   }
               }
               if(l==6){
                    printf("No\n");
                    return 0;
               }
           }
       }
   }
    
   printf("Yes\n");
   return 0;
}


Measured memory_bytes: 2112
import java.awt.geom.Point2D;
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        new Main(); 
    }
 
    public Main() {
    	new aoj0059().doIt();
    }
    class aoj0059{
    	void doIt(){
    		ArrayList<Point2D> p = new ArrayList<Point2D>();
    		while(sc.hasNext()){
    			String[] str = sc.next().split(",");
    			p.add(new Point2D.Double(Double.parseDouble(str[0]),Double.parseDouble(str[1])));
    		}
    		System.out.println(area(p));
    	}
    	double area(ArrayList<Point2D> polygon) {
    		double res = 0.0;
    		int n = polygon.size();
    		for(int i = 0; i < n; i++){
    			Point2D from = polygon.get(i), to = polygon.get((i+1) % n); 
    	        res += cross(from, to);
    	    }
    	    return Math.abs(res) / 2.0;
    	}
    	double cross(Point2D p1, Point2D p2){
    		double res = p1.getX() * p2.getY() - p1.getY() * p2.getX();
    		return res;
    	}
    }
}

Measured memory_bytes: 26332
#include <bits/stdc++.h>
#define N 366
using namespace std;
int n,A[N][4][4];
int mem[N][3][3][7][7][7][7];
int dx[]={0,0,0,1,-1};
int dy[]={0,1,-1,0,0};

int check(int d,int x,int y){
  if(x<0||y<0||x>=3||y>=3)return 0;
  for(int i=0;i<2;i++)
    for(int j=0;j<2;j++)if(A[d][y+i][x+j]) return 0;
  return 1;
}

void getABCD(int x,int y,int &A,int &B,int &C,int &D){
  A++,B++,C++,D++;
  if(x==0&&y==0) A = 0;
  if(x==2&&y==0) B = 0;
  if(x==0&&y==2) C = 0;
  if(x==2&&y==2) D = 0;
}

int dfs(int num=0,int x=1,int y=1,int A=1,int B=1,int C=1,int D=1){
  if(num==n-1) return 1;
  if(mem[num][x][y][A][B][C][D]++) return 0;
  
  for(int i=0;i<5;i++)
    for(int j=0,nx=x,ny=y;j<2;j++){
      nx+=dx[i],ny+=dy[i];
      int nA=A,nB=B,nC=C,nD=D;
      getABCD(nx,ny,nA,nB,nC,nD);
      if(nA==7||nB==7||nC==7||nD==7)continue;
      if(check(num+1,nx,ny)&&dfs(num+1,nx,ny,nA,nB,nC,nD))return 1;
    }
  return 0;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      for(int j=0;j<16;j++) cin>>A[i][j/4][j%4];

    memset(mem,0,sizeof(mem));
    cout<<check(0,1,1)*dfs()<<endl; 
  }
  return 0;
}

Measured memory_bytes: 33968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static List<Edge>[] g;
    static void Main()
    {
        SetOut(new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        var N = int.Parse(ReadLine());
        var graph = new List<Edge>[N];
        for (int i = 0; i < N; i++)
        {
            graph[i] = new List<Edge>();
        }
        var d = new int[N];
        for (int i = 0; i < N - 1; i++)
        {
            var ab = ReadLine().Split();
            var a = int.Parse(ab[0]) - 1;
            var b = int.Parse(ab[1]) - 1;
            graph[a].Add(new Edge(b, i));
            graph[b].Add(new Edge(a, i));
            d[a]++;
            d[b]++;
        }

        var m = 0;
        var max = 0;
        for (int i = 0; i < N; i++)
        {
            if (max < d[i])
            {
                max = d[i];
                m = i;
            }
        }
        aa = max;

        g = graph;
        ans = new int[N - 1];
        for (int i = 0; i < ans.Length; i++)
        {
            ans[i] = -1;
        }
        DFS(m, -1, -1);
        var aaa = ans.Max();
        WriteLine(aaa + 1);

        for (int i = 0; i < N - 1; i++)
        {
            if (aaa + 1 != max) throw new Exception();
            WriteLine(ans[i] + 1);
        }


        Out.Flush();
    }
    static int aa;
    static int[] ans;
    static void DFS(int v, int p, int c)
    {
        var k = 0;
        foreach (var u in g[v])
        {
            if (k == c) k++;
            //if(k==)
            if (u.to != p)
            {

                ans[u.id] = k;
                DFS(u.to, v, k);
                k++;
            }
            
        }
    }
}

public struct Edge
{
    public int to;
    public int id;

    public Edge(int t, int i)
    {
        to = t;
        id = i;
    }
}


Measured memory_bytes: 27532
#include <bits/stdc++.h>
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( a )        (a).begin(), (a).end()             

int main(void){
    int e, y; cin >> y >> e; 
    
    if( y == 0 ){
        if( e <= 1911 ) cout << 'M' << e - 1867 << endl;
        else if( e <= 1925 ) cout << 'T' << e - 1911 << endl;
        else if( e <= 1988 ) cout << "S" << e - 1925 << endl;
        else                 cout << 'H' << e - 1988 << endl;
    }else{
        if( y == 1 ){
            cout << 1867 + e << endl;
        }
        if( y == 2 ){
            cout << 1911 +e <<endl;
        }
        if( y == 3 ){
            cout << 1925+e << endl;
        }
        if( y == 4 ){
            cout << 1988+e <<endl;
        }
    }
}


Measured memory_bytes: 3104
Imports System

Public Class Program

    Public Shared Sub Main(args As String())

        Select Case Console.ReadLine
            Case "SUN"
                Console.WriteLine(7)
            Case "MON"
                Console.WriteLine(6)
            Case "TUE"
                Console.WriteLine(5)

            Case "WED"
                Console.WriteLine(4)
            Case "THU"
                Console.WriteLine(3)
            Case "FRI"
                Console.WriteLine(2)
            Case "SAT"
                Console.WriteLine(1)
        End Select

    End Sub
End Class


Measured memory_bytes: 20432
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void){


	int n;
	cin>>n;
	for(int i=0;i<n;i++){
        double xa,ya,ra,xb,yb,rb;
        cin>>xa>>ya>>ra>>xb>>yb>>rb;
        double d;
        d = sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
        int ans;
        d<ra-rb ? ans=2 : d<rb-ra ? ans=-2 : d<=ra+rb ? ans=1 : ans=0;

        cout<<ans<<endl;


	}


	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    for(int j = 0; j < h; j++) {
        for(int i = 0; i < w; i++) {
            if((i<a && j<b)||(i>=a && j>=b)) cout << "1";
            else cout << "0";
        }
        cout << "\n";
    }

    return 0;
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


ll X;

void input() {
	cin>>X;
}

void solve() {
	cout<<X/500*1000+X%500/5*5<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	bool takawin = true;
	while (true) {
		C -= B;
		if (C <= 0){
			takawin = true;
			break;
		}
		A -= D;
		if (A <= 0){
			takawin = false;
			break;
		}
	}


	if (takawin){
	cout << "Yes" << "\n";
	} else {
	cout << "No" << "\n";

	}


	return 0;
}


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

long long int N, M, a;

int main(){
    scanf("%lld%lld", &N, &M);
    a = min(N, M / 2);
    if(M - a * 2 >= 0)a += (M - a * 2) / 4;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		String[] dataStr = sc.nextLine().split(" ");

		int[] data = new int[dataStr.length];
		for (int i = 0; i < data.length; i++) {
			data[i] = Integer.parseInt( dataStr[i] );
		}

		int W = data[0], H = data[1], x = data[2], y = data[3], r = data[4];

		if ( 0<=x-r && x+r<=W  && 0<=y-r && y+r<=H )
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

Measured memory_bytes: 26256
#include<stdio.h>

int main(){
  int x,y;
  scanf("%d%d",&x,&y);
  while(x*x+y*y){
    if(x<y){
      printf("%d %d\n",x,y);}
    else{
      printf("%d %d\n",y,x);}
    scanf("%d%d",&x,&y);}
  return 0;}

Measured memory_bytes: 600
import scala.io.{StdIn => in}

object Main extends App {
  val s = in.readLine
  val k = in.readInt

  val res =
    for {
      i <- 0 until s.size
      end = s.size min i+k
      j <- i+1 to end
    } yield s.substring(i,j)

  val ans = res.distinct.sorted.take(k).last
  println(ans)
}

Measured memory_bytes: 33036
#include <bits/stdc++.h>
using namespace std;
#define _                             \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define mod 998244353
typedef long long int ll;

int main()
{
    string a, b;
    cin >> a >> b;

    int n = a.length();
    int m = b.length();

    int dp[n + 1][m + 1];

    memset(dp, 0, sizeof(dp));

    //dp[length of a][length of b];

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (a[i - 1] == b[j - 1])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
            }
        }
    }
    deb(dp[n][m]);
    string ans;
    int i = n, j = m;

    while (i >= 1 && j >= 0)
    {
        int x = i;
        int y = j;

        while (j - 1 >= 0 && dp[i][y] == dp[i][j - 1])
        {
            j--;
        }

        while (i - 1 >= 0 && dp[x][j] == dp[i - 1][j])
        {
            i--;
        }

        if (i > 0)
            ans.push_back(a[i - 1]);

        i--;
        j--;
    }
    reverse(ans.begin(), ans.end());

    cout << ans;
}


Measured memory_bytes: 35456
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <stack>
#include <climits>
#include <utility>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,n,m) for(int  i=n;i<=m;i++)
#define per(i,n,m) for(int i=n;i>=m;i--)
inline void scan(int&x){scanf("%d", &x);};inline void scan(ll&x){scanf("%lld",&x);};inline void scan(double&x){scanf("%lf",&x);};inline void scan(string&x){const char *str;scanf("%s",str);x = string(str);};inline void scan(char&ch){scanf("%c",&ch);};
inline void print(const int&x){printf("%d ",x);};inline void print(const ll&x) {printf("%lld ",x);};inline void print(const double&x) {printf("%lf ",x);};inline void print(const string&x){ const char *str=x.c_str();printf("%s ",str);};inline void print(const char&x) {printf("%c ",x);};
inline void println(const int&x){printf("%d\n",x);};inline void println(const ll&x) {printf("%lld\n",x);};inline void println(const double&x) {printf("%lf\n",x);};inline void println(const string&x){const char *str=x.c_str();printf("%s\n",str);};inline void println(const char&x) {printf("%c\n",x);};
inline void scanarray(int*a,int n){rep(i,0,n-1)scan(a[i]);};inline void scanarray(double*a, int n){rep(i,0,n-1)scan(a[i]);};
inline void printarray(int*a,int n){rep(i,0,n-2){print(a[i]);}println(a[n-1]);}inline void printarray(double*a, int n){rep(i,0,n-2){print(a[i]);} println(a[n-1]);};
inline void copyarray(int*a,int n,int*b){rep(i,0,n-1)b[i]=a[i];};inline void copyarray(double*a, int n, double*b){rep(i,0,n-1)b[i]=a[i];};
/*
scan, print, println    : int, ll, double, string, char
scanarray, printarray   : int, double
copyarray               : int to int, double to double
(*)scanarrayはすべての入力の型が同一でないとバグるので注意。 2 5.3 9 8　とかはダメ
stringについては入出力の際はchar*で行い、コード中で便利のためにstringを使えるようにしている
*/
const ll MaxN = 2000000;
ll A[MaxN];
int n;

int partition(int *A, int p, int r) {
	int x = A[r];
	int i = p-1;
	rep(j,p,r-1) {
		if(A[j] <= x) {
			i++;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[r]);
	
	return i+1;
}

int main() {
    //template
    
    scan(n);
    int a[n];
    int b[n];
    scanarray(a,n);
    
    int idx = partition(a,0,n-1);
	rep(i,0,n-2) {
		if(i == idx) printf("[%d] ", a[i]);
		else print(a[i]);
	}
	println(a[n-1]);
    

    return 0;
}




Measured memory_bytes: 3532
#include <bits/stdc++.h>
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll I2 = 500000004;
int main()
{
    int N, Q;
    std::cin >> N >> Q;
    std::vector<int> A(N);
    for (int i = 0; i < N; i++) { std::cin >> A[i]; }
    std::vector<int> x(Q), y(Q);
    for (int i = 0; i < Q; i++) { std::cin >> x[i] >> y[i], x[i]--, y[i]--; }
    std::vector<std::vector<ll>> dp(N, std::vector<ll>(N, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) { dp[i][j] = A[i] > A[j]; }
    }
    for (int i = 0; i < Q; i++) {
        dp[x[i]][y[i]] = dp[y[i]][x[i]] = (dp[x[i]][y[i]] + dp[y[i]][x[i]]) * I2 % MOD;
        for (int Y = 0; Y < N; Y++) {
            if (Y == y[i] or Y == x[i]) { continue; }
            dp[x[i]][Y] = dp[y[i]][Y] = (dp[x[i]][Y] + dp[y[i]][Y]) * I2 % MOD;
        }
        for (int X = 0; X < N; X++) {
            if (X == y[i] or X == x[i]) { continue; }
            dp[X][x[i]] = dp[X][y[i]] = (dp[X][x[i]] + dp[X][y[i]]) * I2 % MOD;
        }
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) { (ans += dp[i][j]) %= MOD; }
    }
    for (int i = 0; i < Q; i++) { (ans *= 2) %= MOD; }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 72576
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

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

void Main(){
    ll N;
    cin >> N;
    vec<ll> A(N);
    map<ll, bool> mp;
    ll cnt = 0;
    REP(i, N){
        cin >> A[i];
        if(!mp[A[i]]){
            cnt++;
        }else{
            cnt--;
        }
        mp[A[i]]^=true;
    }
    cout << cnt << el;
}



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

int main(){
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = w*h/2;
    int num;
    if (w == x * 2 && h == y * 2) num = 1;
    else num = 0;
    cout << ans << setprecision(10) << " " << num << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    double L;
    cin >> L;
    double v=L*L*L;
    double ans=v/27;
    cout << fixed << setprecision(30);
    cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

// https://beta.atcoder.jp/contests/abc055/tasks/abc055_b

int main() {

    int n; cin >> n;

    ll p = 1;
    REP(i, n) {
        p = (p * (i+1)) % 1000000007;
    }

    cout << p << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] a = new int[m];
    int[] b = new int[m];
    int[] num = new int[n];
    for(int i=0;i<m;i++){
      a[i] = sc.nextInt();
      num[a[i]-1]++;
      b[i] = sc.nextInt();
      num[b[i]-1]++;
    }
    for(int i=0;i<n;i++) System.out.println(num[i]);
  }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=50010;

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

    ll n;
    cin>>n;
    map<ll,ll> m;
    for(ll i=0;i<(1<<n);++i)
    {
        ll x;
        cin>>x;
        m[x]+=1;
    }
    vector<ll> ar;
    int f=1;
    auto it=m.end();
    advance(it,-1);
    ar.pb(it->first);
    it->second-=1;
    if(it->second==0){m.erase(it);}
    while(f==1&&!m.empty())
    {
        ll size=ar.size();
        for(ll i=0;i<size;++i)
        {
            auto it=m.find(ar[i]);
            if(it==m.end()){it=m.lower_bound(ar[i]);}
            if(it==m.begin()){f=0;break;}
            advance(it,-1);
            ar.pb(it->first);
            it->second-=1;
            if(it->second==0){m.erase(it);}
        }
    }
    if(f){cout<<"Yes";}
    else{cout<<"No";}

    return (0);
}


Measured memory_bytes: 18808