akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
            String line = sc.nextLine();
            String ans = "";
            int length = line.length();
            for(int i=0; i<length; i++){
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch)){
                    ch=Character.toUpperCase(ch);
                }else{
                    ch=Character.toLowerCase(ch);
                }
                ans+=ch;
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 31312
import bisect
n = int(input())
p = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
    p[i].sort()
num = [[0 for _ in range(n)] for _ in range(2)]
ret = 0
for i in range(n):
    s = bisect.bisect_left(p[0], p[1][i])
    b = n - bisect.bisect_right(p[2], p[1][i])
    ret += s*b
print(ret)

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

#define N 100000

int main(void){
    bool prime[N+1];
    for (size_t i = 2; i <= N; i++)
    {
        prime[i]=true;
    }
    for (size_t i = 0; i <= sqrt(N); i++)
    {
        if (prime[i])
        {
            for (size_t j = 2; i*j <= N; j++)
            {
                prime[i*j]=false;
            }
        }
    }
    int likeCnt[N]={};
    for (size_t j = 1; j <= N; j++)
    {
        likeCnt[j]=likeCnt[j-1];
        if (j%2==1&&prime[j]&&prime[(j+1)/2])
        {
            likeCnt[j]++;
        }
    }
    /**************************************/
    int q;
    cin >> q;
    int l[q],r[q];
    for (size_t i = 0; i < q; i++)
    {
        cin >>l[i]>>r[i];
    }
    int ans[q]={};
    for (size_t i = 0; i < q; i++)
    {
        cout << likeCnt[r[i]]-likeCnt[l[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
import sys
n=int(input())
a=(n-n%1000)//1000
b=(n%1000-n%100)//100
c=(n%100-n%10)//10
d=(n%10)
k=[a,b,c,d]
for i in range(8):
  s='{0:03b}'.format(i)
  ans=a
  for j in range(3):
    if s[j]=='1':
      ans+=k[j+1]
    else:
      ans-=k[j+1]
  if ans==7:
    ans=[str(a)]
    for j in range(3):
      if s[j]=='1':
        ans.append('+')
      else:
        ans.append('-')
      ans.append(str(k[j+1]))
    ans.append('=')
    ans.append('7')
    print(''.join(ans))
    sys.exit()

Measured memory_bytes: 61732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    int N,M;
    cin>>N>>M;
    int dp[4096];
    int INF = 1000000000;
    rep(i,1<<N)dp[i] = INF;
    dp[0]=0;
    int a,b,c;
    rep(j,M){
        cin>>a>>b;
        int hoge = 0;
        rep(k,b){
            cin>>c;
            c--;
            hoge = hoge | (1<<c);
        }
        rep(i,1<<N) dp[(i|hoge)] = min(dp[(i|hoge)],dp[i]+a);
        
    }
    int ans = dp[(1<<N)-1];
    // rep(i,1<<N){
    //     rep(j,M+1) cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    if(ans == INF) ans = -1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int main()
{
  string s[3];;
  int cnt[3] = {0};
  int now = 0;

  rep(i, 3) cin >> s[i];

  while( 1 ) {
    if( cnt[now] == s[now].size() ) {
      cout << char('A' + now) << endl;
      break;
    }
    char next = s[now][cnt[now]];
    cnt[now]++;
    now = next - 'a';
  }
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,m,c;
  scanf("%d %d %d",&n,&m,&c);
  int b[m];
  int a[n][m];
  for(int i = 0; i < m; ++i) scanf("%d",&b[i]);
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      scanf("%d",&a[i][j]);
    }
  }
  int count = 0,answer;
  int sum;
  for(int i = 0; i < n; ++i){
    sum = c;
    for(int j = 0; j < m; ++j){
      sum += a[i][j] * b[j];
    }
    if(sum > 0) count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> a(n); 
    vector<int> b(n);
    int m = 0, mm = 0; 
    queue<int> mi;
    for(int i=0; i<n; ++i){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end(), greater<int>());
    int f, s; 
    f = b[0]; s = b[1];
    for(int i=0; i<n; ++i){
        if(a[i]==f){cout << s << endl;}
        else{cout << f << endl;}
    }
    return 0;
}

Measured memory_bytes: 4784
N=int(input())
a=list(map(int,input().split()))

now=1
to_break=0
ans=False

for item in a:
  if item==now:
    now+=1
    ans=True
    #print("OK",item)
  else:
    to_break+=1
    #print("壊す",item)
    
if ans:
  print(to_break)
else:
  print(-1)

Measured memory_bytes: 24744
#include"stdio.h"
#include"iostream"
#include"string"
using namespace std;
int main(void) {
	int a;
	int flg = 0;
	cin >> a;
	string b;
	cin >> b;
	string c = b.substr(a / 2, a / 2);
  if(a%2 == 1){
  	flg = 1;
  }
	if (b.compare(0, a / 2, c) == 0 && flg ==0) {
		flg = 0;
	}
	else {
		flg = 1;
	}
	if (flg == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}


}


Measured memory_bytes: 256
/*                          The four Truths of Life

                                    CKMKB
                                    PKMKB

                                    CKMKC
                                    PKMKC
*/


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;




ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

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

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

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;

	//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;

		cin >> n >> k;
		ll arr[n]; for (i = 0; i < n; i++) {cin >> arr[i];}

		temp = 1;


		for (i = k; i < n; i++)
		{


			if (arr[i] > arr[i - k])
				cout << "Yes\n";
			else
				cout << "No\n";

		}











		//ln
	}
	return 0;
}


Measured memory_bytes: 5208
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
	int ans = 0, tmp = 0;
	string n;
	cin >> n;
	for (int i = 0; i < n.size(); i++) {
		ans += n[i] - '0';
		tmp += n[i] - '0';
		if (i != n.size() - 1) {
			tmp *= 10;
		}
	}
	if (tmp % ans) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict, deque
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def IS(): return input().rstrip()

def main():
    N, M = MI()
    A = LI()
    s = sum(A)
    if s <= N:
        print(N-s)
    else:
        print(-1)
if __name__ == '__main__':
    main()

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

int main() {
    string s; cin >>s;
    int at;
    while (true) {
        s.pop_back();
        if (s.size()%2==1) s.pop_back();
        int h = s.size()/2;
        bool tf = true;
        for (int i = 0; i < h; i++) {
            if (s[i] != s[i+h] ) {tf = false; break;}
        }
        if (tf) break;
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <numeric>
#include <ctime>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <map>

using namespace std;
typedef long long int lint;

class Rect{
public:
	int height;
	int pos;
	Rect(int h, int p){
		height = h; pos = p;
	}
	Rect(){
		height = pos = 0;
	}
};

int area(int W, int* m)
{
	int ret = 0;
	stack<Rect> s;

	for (int i = 0; i <= W; i++){
		if (s.empty()){
			s.push(Rect(m[i], i));
		}
		else{
			if (s.top().height < m[i]){
				s.push(Rect(m[i], i));
			}
			else if (s.top().height > m[i]){
				Rect r;
				while (!s.empty() && s.top().height >= m[i]){
					r = s.top();
					s.pop();
					int buf = r.height * (i - r.pos);
					if (buf > ret) ret = buf;
				}
				r.height = m[i];
				s.push(r);
			}
		}
	}
	return ret;
}

int solve(int H, int W, int** m)
{
	int ret = 0;
	for (int j = 0; j < W; j++){
		int h = 0;
		for (int i = 0; i < H; i++){
			if (m[i][j] != 0){
				h++;
				m[i][j] = h;
			}
			else {
				h = 0;
			}
		}
	}

	for (int i = 0; i < H; i++){
		int buf = area(W, m[i]);
		if (buf > ret) ret = buf;
	}

	return ret;
}

int main()
{
	//clock_t start = clock();

	while (1)
	{
		int H, W;
		cin >> H >> W;
		if (H == 0) break;
		int** m = new int*[H];
		for (int i = 0; i < H; i++) m[i] = new int[W + 1];

		for (int i = 0; i < H; i++){
			string str;
			cin >> str;
			for (int j = 0; j < W; j++) m[i][j] = ((str[j] == '.') ? 1 : 0);
			m[i][W] = 0;
		}

		cout << solve(H, W, m) << endl;

		for (int i = 0; i < H; i++) delete[] m[i];
		delete[] m;
	}
	
	//clock_t end = clock();
	//std::cout << (double)(end - start) / CLOCKS_PER_SEC << "sec.\n";

	return 0;
}

Measured memory_bytes: 2120
N,W=map(int,input().split())
wl=[]
vl=[]
for i in range(N):
  w,v=map(int,input().split())
  wl.append(w)
  vl.append(v)

dp=[[-float("inf") for i in range(W+1)] for j in range(N+1)]
for i in range(W+1):
  dp[0][i]=0

for n in range(1,N+1):
  for w in range(1,W+1):
    if wl[n-1]<=w:
      dp[n][w]=max(dp[n-1][w-wl[n-1]]+vl[n-1],dp[n-1][w])
    else:
      dp[n][w]=dp[n-1][w]

print(str(dp[N][W]))

Measured memory_bytes: 315120
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  char c; cin >> c;
  c+=1;
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
dLst = [0] * N
for i in range(N):
    dLst[i] = int(input())

dLst.sort()
tmp = dLst[0]
ansCnt = 1
for i in range(1, N):
    if tmp < dLst[i]:
        ansCnt += 1
    tmp = dLst[i]

print(ansCnt)

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  ll maxi;
  if (a + b >= c - 1) {
    maxi = b + c;
  } else {
    maxi = (b + c) - (c - (a + b) - 1);
  }

  cout << maxi << endl;
  return 0;
}


Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll q,h,s,d;cin>>q>>h>>s>>d;
    ll n;cin>>n;n*=4;
    ll ans=0;
    vector<pair<ll,ll>>cc(4);
    cc[0]=(mp(q*8,1));
    cc[1]=(mp(h*4,2));
    cc[2]=(mp(s*2,4));
    cc[3]=(mp(d,8));
    sort(all(cc));
    //reverse(all(cc));
    
    for(int i=0;i<4;i++){
        if(n>=cc[i].se){
            cc[i].fi/=8/cc[i].se;
          //cout<<cc[i].fi<<" "<<cc[i].se<<endl;
            ll tmp=n/cc[i].se;
            ans+=tmp*cc[i].fi;
            n=n%cc[i].se;
        }
    }
  
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

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

using namespace std;

int main(){
	int n,a,b; scanf("%d%d%d",&n,&a,&b);

	if(a+b-1>n || 1LL*a*b<n) return puts("-1"),0;

	vector<int> ans(n);
	int idx=0,num=n;
	rep(i,a) ans[idx++]=num+i-a+1;
	num-=a;

	int m=n-(a+b-1);
	for(int i=1;i<b;i++){
		int k=min(a-1,m);
		rep(j,k+1) ans[idx++]=num+j-k;
		num-=k+1;
		m-=k;
	}

	rep(i,n) printf("%d%c",ans[i],i<n-1?' ':'\n');

	return 0;
}


Measured memory_bytes: 3328
#include<iostream>

using namespace std;

int main(){
	int X,Y;
	cin >>X>>Y;
	if((Y%2==0)&&(Y>=2*X)&&(4*X>=Y)){
		cout <<"Yes";
	}else{
		cout <<"No";
	}
	cout <<endl;
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];
ll sum[N];
//ll ans[N];



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

    ll a,b,c;
    cin >>a >>b >>c;
    if(a+b>=c)  cout <<"Yes";
    else    cout <<"No";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pii>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   //cin>>t;
    while(t--){
        int n;
        cin>>n;
        vi a;
        int x;
        Fr(i,0,n-1){
            cin>>x;
            a.pb(x);
        }
        sort(a.begin(),a.end());
        double sum=a[0];
        Fr(i,1,n-1){
            sum=(sum+(double(a[i])))/(double)2;
        }
        cout<<setprecision(8)<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define repr(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) for (ll i = 0; i < n; i++)
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

ll dp[365][26];

int main(){
    ll d;
    cin >> d;
    vector<ll> c(26);
    vector<ll> ans(365);
    rep(i,26) cin >> c[i];
    rep(i,d)rep(j,26) cin >> dp[i][j];
    

    rep(i,d){
        ll now=-1,kazu=0;
        rep(j,26){
            if(now<dp[i][j]){
                now=dp[i][j];
                kazu=j;
            }
        }
        ans[i]=kazu;
    }
    
    rep(i,365) cout << ans[i]+1 << endl;

    return 0;
}












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

int main() {
  string d = "CODEFESTIVAL2016";
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) if (s[i] != d[i]) ans++;
  cout << ans << endl;
  return 0;

}



Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
s = set()
c = 0
for i in a:
  if i//400 >= 8:
    c += 1
  else:
    s.add(i//400)
if len(s) == 0:
  print(1,c)
else:
  print(len(s),len(s)+c)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;


using namespace std;


int main()
{

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

  int n;
  cin >> n;

  for (int i = 9; i >= 1; i--)
  {
    if (n % i == 0)
    {

      if (n / i > 9)
      {
        cout << "No" << endl;
        return 0;

      }
      else
      {
        cout << "Yes" << endl;
        return 0;
      }

    }


  }


}

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

using namespace std;

int main()
{
    int n, buf;
    vector<int> x, hoge; 
    cin >> n;
    x.push_back(0);
    for(int i = 1; i <= n; ++i) {
        cin >> buf;
        x.push_back(buf);
    }
    hoge = x;
    sort(hoge.begin(), hoge.end());
    for(int i = 1; i <= n; ++i) {
        if(x[i] <= hoge[n/2]) cout << hoge[n/2+1] << endl;
        else cout << hoge[n/2] << endl;
    }

    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


//#define int ll

int h,w,n;
int a[10001];
int x=1;
int s[111][111];

signed main(){
    cin>>h>>w>>n;
    repe(i,1,n)cin>>a[i];
    
    rep(i,0,h){
        rep(j,0,w){
            if(a[x]==0)x++;
            if(i%2==0){
               s[i][j]=x;
               a[x]--;
            }else{
                s[i][w-j-1]=x;
                a[x]--;
            }
        }
    }
    
    rep(i,0,h){
        rep(j,0,w){
            cout<<s[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

struct Lowlink{
    vector<set<int>> Graph;
    vector<int> arrived,ord,low;
    int CntBri;

    Lowlink(int N, vector<set<int>> G):Graph(G){
        CntBri=0;
        arrived.assign(N,0);
        ord.assign(N,0);
        low.assign(N,0);

        Dfs(0,0,-1);
    }

    void Dfs(int node,int k,int p){
        arrived.at(node)=1;
        ord.at(node)=k;
        low.at(node)=k;

        for(auto g:Graph.at(node)){
            if(!arrived.at(g)){
                Dfs(g,k+1,node);
                low.at(node)=min(low.at(node),low.at(g));
                if(ord.at(node)<low.at(g)) CntBri++;
            }else if(g!=p){
                low.at(node)=min(low.at(node),ord.at(g));
            }
        }
    }
};

int main(){
    int N,M; cin>>N>>M;
    vector<set<int>> G(N);
    rep(m,0,M){
        int a,b; cin>>a>>b;
        G.at(a-1).insert(b-1);
        G.at(b-1).insert(a-1);
    }

    Lowlink lowlink(N,G);
    cout<<lowlink.CntBri<<endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1LL<<60);

int main() {
  int n, m; cin >> n >> m;
  cout << (n==m?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a, b;
  cin >> a >> b;
  
  if ( a > b){
    cout << ">" << endl;
  }
  else if ( b > a){
    cout << "<" << endl;
  }
  else{
    cout << "=" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, C;
        cin >> N >> C;

        vllvll acc(31, vll(200010));
        rep(i, 0, N) {
                ll s, t, c;
                cin >> s >> t >> c;
                s *= 2;
                s -= 1;
                t *= 2;
                acc[c][s]++;
                acc[c][t]--;
        }

        vll total(200010);

        rep(c, 1, 31) {
                rep(i, 1, len(acc[0])) {
                        acc[c][i] += acc[c][i-1];
                }
        }

        rep(c, 1, 31) {
                rep(i, 0, len(acc[0])) {
                        total[i] += (acc[c][i] >= 1);
                }
        }

        cout << *max_element(all(total)) << endl;
}

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

int main(){
   int n, k;
   cin >> n >> k;
   vector<int> p(n, 0);
   rep(i, n)cin >> p[i];
   sort(p.begin(), p.end());
   int ans = 0;
   rep(i, k)ans+= p[i];
   
   cout << ans << endl;
}

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



int main(){
	ll a,b;
	cin>>a>>b;
	for(int i=1;i<2000;i++){
		if(i*8/100==a&&i/10==b){
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
	return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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




int main(){

    char c;
    cin>>c;

    if('a'<=c && c<='z'){
        cout<<'a'<<endl;
    }
    else{
        cout<<'A'<<endl;
    }

    return 0;
}


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

using namespace std;

int main()
{
  int T;
  cin >> T;
  for (int i = 0; i < T; i++)
  {
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A < B || D < B || C < A % B || C < B - __gcd(B, D))
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,temp;
	cin>>a>>b;
	if(a>0)
		cout<<"Positive"<<endl;
	if(a<=0&&b>=0)
		cout<<"Zero"<<endl;
	if(b<0)
	{
		if((b-a+1)%2==0)
			cout<<"Positive"<<endl;
		else
			cout<<"Negative"<<endl;
	}
	return 0;
}

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

int main()
{
    char s[100+1], p[100+1];
    int s_len, p_len;
    int i, j;
    int flag;
    scanf("%s", s);
    scanf("%s", p);
    s_len = strlen(s);
    p_len = strlen(p);
    flag = 0;
    for(i = 0; i < s_len; i++) {
        for(j = 0; j < p_len; j++) {
            if(s[(i+j)%s_len] != p[j]) {
                break;
            }
        }
        if(j == p_len) {
            flag = 1;
            break;
        }
    }
    if(flag == 1) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2100
'use strict'
 
function Main(input) {
  input = input.split("\n");
  const line1 = input[0].split(" ");
  const line2 = input[1].split("");
  
  const targetNum = parseInt(line1[1], 10) - 1; 
  const text = line2[targetNum].toLowerCase();
  const resultArray = [];
  
  for(let i = 0; i< line2.length; i++){
    if(i === targetNum) {
      resultArray.push(text)
    }
    else{
	  resultArray.push(line2[i]);
    }
  }
  
  const result = resultArray.join("")
  
  console.log(result)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <map>
using namespace std;
int a[100010];
map<int,int> mp;
int main(){
	int i,n;
	cin >> n;
	int x = 0;
	for(i=0;i<n;i++){
		cin >> a[i];
		x ^= a[i];
		mp[a[i]]++;
	}
	if(x!=0 || mp.size()>3){
		cout << "No" << endl;
		return 0;
	}
	if(mp.size()==3){
		i = 0;
		int b[3];
		for(auto x:mp){
			b[i] = x.first;
			i++;
		}
		if(n%3==0 && mp[b[0]]==n/3 && mp[b[1]]==n/3){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
		return 0;
	}
	if(mp.size()==2){
		if(n%2==0 && mp[0]==n/2){
			cout << "Yes" << endl;
			return 0;
		}
		if(n%3==0 && mp[0]==n/3){
			cout << "Yes" << endl;
			return 0;
		}
		cout << "No" << endl;
		return 0;
	}
	if(mp.size()==1){
		if(mp[0]==0){
			cout << "No" << endl;
			return 0;
		}
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 4224
while(True):
    x = input()
    x= int(x)
    if x==0:
        break
    max_p = 0
    min_p= 1000
    total = 0
    for n in range(x):
        point = input()
        point = int(point)
        total += point
        if max_p < point:
            max_p =  point
        if min_p > point:
            min_p = point
    ans = total - max_p -min_p
    ans /= x-2
    ans = int(ans)
    print(ans)
        


Measured memory_bytes: 5592
def main():
  n, p = input_list()
  a = list(input_list())
  # 全て偶数かどうか
  is_even = True
  for v in a:
    if v % 2 != 0:
      is_even = False
      break
  if is_even:
    if p == 0:
      print(2**n)
      exit()
    else:
      print(0)
      exit()
  else:
    print(2**(n-1))
  
  exit()
  if p == 0:
    # 偶数の場合：
    for i in range(n):
      if i % 2 == 0:
        r += combinations_count(n, i)
    if r % 2 != 0:
      r += 1
  else:
    # 奇数の場合：奇数を奇数個かける
    for i in range(n):
      if i % 2 != 0:
        r += combinations_count(n, i)
    if r > 0:
      r += 1
  print(r)  
  exit()
  for i in range(bi+1):
    fi = format(i, '0'+str(n)+'b')
    ans = 0
    for index, v in enumerate(fi):
      if v == '1':
        ans += a[index]
    if ans % 2 == p:
      r += 1
  print(r)
  
def input_list():
  return map(int, input().split())

def input_list():
  return map(int, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import math
import fractions

from functools import reduce
main()

Measured memory_bytes: 64492
import java.util.Scanner;

public class Main {
	public static void main(String[] arg) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int NLast = N;
		int N3;
		int NumberofDigits = 0;

		for(;;) {
			if(N==0) {
				break;
			}else {
				NumberofDigits++;
				N = N/10;
			}
		}

		for(int i=NumberofDigits;i>1;i--) {
			N3  = (int) (NLast/(Math.pow(10, i-1)));
			NLast = (int) (NLast - N3*(Math.pow(10, i-1)));
		}

		switch(NLast) {
		case 0: System.out.println("pon"); break;
		case 1: System.out.println("pon"); break;
		case 2: System.out.println("hon"); break;
		case 3: System.out.println("bon"); break;
		case 4: System.out.println("hon"); break;
		case 5: System.out.println("hon"); break;
		case 6: System.out.println("pon"); break;
		case 7: System.out.println("hon"); break;
		case 8: System.out.println("pon"); break;
		case 9: System.out.println("hon"); break;
		}
	}
}


Measured memory_bytes: 35724
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
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;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int k;
  cin >> k;
  mod = k;
  int cur = 0;
  for (int i = 1; i <= 5e6; i++) {
    cur = mul(cur, 10);
    cur = add(cur, 7);
    // cur %= mod;
    if (cur == 0) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for(int i=0; i<n; ++i)
#define MAX 1000000001

std::vector<int> v;

int main() {
  int a, b, k;
  std::cin >> a >> b >> k;
  int small, big;

  small = big = 1;

  for(int i=a; i<=b; ++i) {
    if(small<=k) {
      v.push_back(i);
      small += 1;
    }else {
      break;
    }
  }

  for(int i=b; i>=a; --i) {
    if(big<=k) {
      v.push_back(i);
      big += 1;
    }else {
      break;
    }
  }

  int size = (int)v.size();

  std::sort(v.begin(), v.end());

  v.erase(std::unique(v.begin(), v.end()), v.end());

  for(int x : v) {
    std::cout << x << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<double> P(N + 1);
  for (ll i = 1; i <= N; i++)
  {
    cin >> P.at(i);
    P.at(i) = (P.at(i) + 1) / 2;
    P.at(i) += P.at(i - 1);
  }

  double ans = 0;
  for (ll i = 0; i <= N - K; i++)
  {
    chmax(ans, P.at(i + K) - P.at(i));
  }

  cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

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

    int n;
    cin >> n;
    int i = 1;
    while (1) {
        if (i*(i + 1) == n*2)break;
        if (i*(i + 1) > n * 2) {
            cout << "No" << endl;
            return 0;
        }
        i++;
    }
    cout << "Yes" << endl << (i + 1) << endl;
    int num = 1;
    int a[1000][1000] = {};
    int l = i;
    for (int j = 0; j < i; j++) {
        for (int k = 0; k < l; k++) {
            a[j][j + k] = num;
            a[j + 1 + k][j] = num;
            num++;
        }
        l--;
    }
    for (int j = 0; j <= i; j++) {
        cout << i << ' ';
        for (int k = 0; k < i; k++)cout << a[j][k] << ' ';
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 5376
#include<iostream>
using namespace std;
long long gcd(long long A,long long B)
{
	if(B==0)  return A;
	else  return gcd(B,A%B);
}
int prime[1000100],t;
int p[1000100],tot,use[1000100];
void init();
int main()
{
	init();
	long long A,B;
	cin>>A>>B;
	long long c=gcd(A,B);
	for(int i=1;i<=tot && c>=p[i];i++)
	{
		int k=p[i];
		if(c%k==0)
		{
			prime[++t]=k;
			while(c%k==0)  c/=k;
		}
	}
	if(c>1)  prime[++t]=c;
	t++;  
	cout<<t<<endl;
	return 0;
}
void init()
{
	int n=1000000;
	for(int i=2;i<=n;i++)
	{
		if(!use[i])  p[++tot]=i;
		for(int j=1;p[j]*i<=n && j<=tot;j++)
		{
			use[p[j]*i]=1;
			if(i%p[j]==0)  break;
		}
	}
}

Measured memory_bytes: 7756
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(){
	int h, w, n;
	cin >> h >> w >> n;
	
	set<pair<int, int> > targ;
	set<pair<int, int> > find;
	
	for(int i = 0;i < n;i++){
		int a, b;
		cin >> a >> b;
		targ.insert(pair<int, int>(a, b));
	}
	
	long long res[10];
	for(int i = 0;i < 10;i++) res[i] = 0;
	res[0] = ((long long)(h-2))*(w-2);
	
	for(set<pair<int, int> >::iterator it = targ.begin(); it != targ.end(); it++){
		pair<int, int> p = *it;
		
		for(int j = -1;j <= 1;j++){
			for(int k = -1;k <= 1;k++){
				if(p.first + j <= 1 || p.first + j >= h || p.second + k <= 1 || p.second + k >= w) continue;
				if(find.find(pair<int, int>(p.first + j, p.second + k)) != find.end()) continue;
				
				find.insert(pair<int, int>(p.first + j, p.second + k));
				
				int sum = 0;
				for(int x = -1;x <= 1;x++){
					for(int y = -1;y <= 1;y++){
						if(targ.find(pair<int, int>(p.first + j + x, p.second + k + y)) != targ.end()) sum++;
					}
				}
				res[sum]++;
				res[0]--;
			}
		}
	}
	
	for(int i = 0;i < 10;i++){
		cout << res[i] << endl;
	}
	
	return 0;
}

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

   int main() {
       
       int n;
       cin >> n;
       long long int arr[n];
       for(int i=0; i<n; i++){
           cin >> arr[i];
           
       if(arr[i]==0){
           cout << 0;
           return 0;
           }
   }
            long long ans = 1LL;
            for(int i=0; i<n; i++){
                if(arr[i]<=1000000000000000000/ans){
                ans*=arr[i];    
            }
                else{
                    ans = -1;
                    break;
                }
       }
       
    cout << ans;   
       return 0;
   }

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

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll MOD = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

ll modpow(ll a, ll n, ll m) {
	if (n == 0) return 1;
	ll half = modpow(a, n/2, m);
	ll res = half * half % m;
	if (n & 1) res = res * a % m;
	return res;
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

ll COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2;i < MAX;i++) {
		fac[i] = fac[i-1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
}

ll modinv(ll a) {
	// ax + MOD*y = 1
	ll x, y;
	extGCD(a, MOD, x, y);
	return mod(x, MOD);
}

ll comb(ll a, ll b) {
	ll ans = 1;
	for (ll i = a - b + 1;i <= a;i++) {
		ans = ans * i % MOD;
	}
	for (ll i = 2; i <= b;i++) {
		ans = ans * modinv(i) % MOD;
	}
	// cout << a << "C" << b << " " << ans << endl;
	return ans;
}

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

	vector<P> primes;
	ll cnt = 0;

	// 素因数分解 M -> primes
	ll r = 0;
	for (ll i = 2;i <= M; i++) {
		if (M % i == 0) {
			r = 0;
			do {
				r++;
				cnt++;
				M /= i;
			} while(M % i == 0);
			primes.push_back(make_pair(i, r));
			// cout << i << " " << r << endl;
		}
	}

	ll ans = 1;
	for (auto pair: primes) {
		ans = ans * comb(pair.second + N - 1, N - 1) % MOD;
	}

	cout << ans << endl;
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  int Q;
  cin >> Q;
  int U=0;
  string BEGIN="", END="";
  for(int i=0; i<Q; i++){
    int T;
    cin >> T;
    if(T==1){
      U=!U;
    }
    if(T==2){
      int F;
      string C;
      cin >> F >> C;
      if(U==1){
        if(F==1){
          F=2;
        }
        else if(F==2){
          F=1;
        }
      }
      if(F==1){
        BEGIN=BEGIN+C;
      }
      else{
        END=END+C;
      }
    }
  }
  reverse(BEGIN.begin(), BEGIN.end());
  S=BEGIN+S+END;
  if(U==1){
    reverse(S.begin(), S.end());
  }
  cout << S << endl;
}

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

const int MAX_N = 1e5;
int N, cnt[MAX_N+5];

int main(){
  cin >> N;
  
  for(int i=0;i<N;i++){
    int a; cin >> a;
    
    cnt[a]++; cnt[a+1]++; cnt[a+2]++;
  }
  
  cout << *max_element(cnt, cnt+MAX_N+5) << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int N,K;
  vi A(300000);
  cin>>N>>K;
  rep(i,N) cin>>A[i];
  rep(j,N-K) {
    if(A[K+j]>A[j]) cout<<"Yes\n";
    else cout<<"No\n";
  }
}


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

struct node{
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node find(Node u,int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key)
      u=u->left;
    else
      u=u->right;
  }
  return u;
}

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }

  z->parent=y;

  if( y == NIL ){
    root=z;
  }
  else{
    if( z->key < y->key ){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(Node u){
  if( u == NIL )
    return;

  inorder(u->left);

  printf(" %d",u->key);

  inorder(u->right);
}

void preorder(Node u){
  if( u == NIL )
    return;

  printf(" %d",u->key);
  
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[20];
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);

    if(com[0]=='f'){
      scanf("%d",&x);
      Node t=find(root,x);
      if(t!=NIL)
	printf("yes\n");
      else
	printf("no\n");
    }

    else if( strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if( strcmp(com,"print")==0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 2; i <= n; i++) {
			int num = i;
			for (int sosuu : map.keySet()) {
				while (num % sosuu == 0) {
					map.put(sosuu, map.get(sosuu) + 1);
					num /= sosuu;
				}
			}
			if (num == i) {
				map.put(num, 1);
			}
		}

		long ans = 1;
		for (int sosuu : map.keySet()) {
			ans = ans * (map.get(sosuu) + 1) % 1000000007;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin >> a[i];
    deque<int> d;
    rep(i,n) {
        int p = lower_bound(all(d), a[i]) - d.begin();
        if (p == 0) {
        d.push_front(a[i]);
        } else d[p-1] = a[i];
    }
    int ans = d.size();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
long long solve(long long, long long);
long long pow2(long long);
long long a[5] = {0, 1, 2, 3, 3};
int main()
{
  long long n, x;
  scanf("%lld%lld", &n, &x);
    long long ans;
  ans = solve(n, x);
  printf("%lld\n",ans);
  return 0;
}
long long solve(long long n, long long x)
{
  if (n==1)
  {
    return a[x-1];
  }
  long long st = pow2(n+1) - 1, ans;//每行面包 肉饼个数和 的一半 包括中间的
  if (n>1)
  {
    if (x > st){
      // printf("st = %lld\n", st);
      // printf("n-1 = %lld x-st = %lld solve(n-1, x-st) = %lld\n", n-1, x-st, solve(n-1, x-st-1));
      // printf("pow2(n) = %lld\n", pow2(n));
      if (x-st < pow2(n+1)-2)
        ans = pow2(n)-1 + 1 + solve(n-1, x-st);//2 13
      else
        ans = pow2(n)-1 + 1 + solve(n-1, x-st-1);//2 13
      // printf("ans = %lld\n", ans);
    }
    else if(x == st)
      ans = pow2(n);
    else{
      ans = solve(n-1, x-1);
    }
  }
  return ans;
}
long long pow2(long long n)
{
  long long x = 1;
  for (int i = 0; i < n; ++i)
    x *= 2;
  return x;
}


Measured memory_bytes: 128