akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <math.h>

int main()
{
    int a, b;
    std::cin >> a >> b;
    int r;
    r = b * pow(100, a);
    if (r >= pow(100, a+1)) r = r + 1 * pow(100, a);
    std::cout << r << std::endl;
}


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

int main(void){
    int i,j,k=0,l;
    int len;
    char data[1000];

    fgets(data,sizeof(data),stdin);

    len=strlen(data);

    for(i=0;i<len-1;i++){
        if('a'<=data[i]&&data[i]<='z')data[i]-=0x20;
    }
    printf("%s",data);
    return(0);
}

Measured memory_bytes: 524
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace ConsoleAppAtCoderABC172
{
    class Program
    {
        static void Main(string[] args)
        {
            var nmk = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var (n, m, k) = (nmk[0], nmk[1], nmk[2]);

            var a = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var b = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            // 累積値
            var aTotal = new List<int>();
            var bTotal = new List<int>();

            aTotal.Add(0);
            if (a[0] <= k)
            {
                aTotal.Add(a[0]);
                for (int i = 1; i < n; i++)
                {
                    var total = aTotal[i] + a[i];
                    if(total <= k)
                    {
                        aTotal.Add(total);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            bTotal.Add(0);
            if (b[0] <= k)
            {
                bTotal.Add(b[0]);
                for (int i = 1; i < m; i++)
                {
                    var total = bTotal[i] + b[i];
                    if (total <= k)
                    {
                        bTotal.Add(total);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            var maxCount = 0;
            var bCount = bTotal.Count - 1;
            for (int aCount = 0; aCount < aTotal.Count; aCount++)
            {
                var aValue = aTotal[aCount];
                
                while(true)
                {
                    var bValue = bTotal[bCount];
                    if(aValue + bValue > k)
                    {
                        bCount--;
                    }
                    else
                    {
                        break;
                    }
                }

                maxCount = Math.Max(maxCount, aCount + bCount);
            }

            WriteLine(maxCount);
        }
    }
}


Measured memory_bytes: 68476
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;

class Main{
public static void main(String[] args) throws IOException{
final int[] alphas={1,3,5,7,9,11,15,17,19,21,23,25};
final int[] beta={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25};
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> array=new ArrayList<String>();
HashMap<Character,Character> dic=new HashMap<Character,Character>();
int ga;
int gb;
String line;
int n=Integer.parseInt(br.readLine());
while(n-->0){
ga=0;
gb=0;
line=br.readLine();
char[] chararray=line.toCharArray();
for(String s : line.split(" ")){
if(s.length()==4){
array.add(s);
}
}
outside: for(int p=0;p<array.size();p++){
         char[] uc=array.get(p).toCharArray();
         for(int a=0;a<alphas.length;a++){
         for(int b=0;b<beta.length;b++){
         char ct=(char)((alphas[a]*('t'-97)+beta[b])%26+97);
         char ch=(char)((alphas[a]*('h'-97)+beta[b])%26+97);
         char ci=(char)((alphas[a]*('i'-97)+beta[b])%26+97);
         char cs=(char)((alphas[a]*('s'-97)+beta[b])%26+97);
         char ca=(char)((alphas[a]*('a'-97)+beta[b])%26+97);
         if(uc[0]==ct&&uc[1]==ch){
         if((uc[2]==ci&&uc[3]==cs)||(uc[2]==ca&&uc[3]==ct)){
         ga=alphas[a];
         gb=beta[b];
         break outside;
         }
         }
         }
         }
         }
for(int i=0;i<26;i++){
char nc=(char)((ga*i+gb)%26+97);
char c=(char)(i+97);
dic.put(nc,c);
}
for(int i=0;i<chararray.length;i++){
if(chararray[i]>='a'&&chararray[i]<='z'){
chararray[i]=dic.get(chararray[i]);
}
}
System.out.println(chararray);
array.clear();
dic.clear();
}
}
}

Measured memory_bytes: 17824
#include <bits/stdc++.h>
using namespace std;
const int inf=100000000;
int n,m;
int a[1100],b[1100],c[1100],dist[110][110];
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;
        b[i]--;
    }
    for(int i=0;i<n;i++)
    {
        for (int j=0;j<n ;j++ )
        {
            if(i==j)
            {
                dist[i][j]=0;
            }
            else
            {
                dist[i][j]=inf;
            }
        }
    }

    for(int i=0;i<m;i++)
    {
        dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
        dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
    }

    for (int k=0;k<n ;k++ )
    {
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }

    }
    int ans=m;
    for(int i=0;i<m;i++)
    {
        bool shortest=false;
        for(int j=0;j<n;j++)
        {
            if(dist[j][a[i]]+c[i]==dist[j][b[i]])
            {
                shortest =true;
            }
        }
        if(shortest==true)
        {
            ans--;
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 384
/* A Binary Search Tree I */

#include<stdio.h>
#include<stdlib.h>

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

struct Node *nil;
struct Node *root;
void init(){
  nil->key=-1;
  nil->parent=nil;
  nil->left=nil;
  nil->right=nil;
}

void Preorder(struct Node *u);
void Inorder(struct Node *u);

void TreeInsert(struct Node *T, struct Node *z);

int main(){
  int n; /* command number */
  int k; 
  char com[6];
  int i;
  struct Node *T;
  struct Node *z;
  nil=malloc(sizeof(struct Node));
  init();
  /*scan*/
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&k);
      z=malloc(sizeof(struct Node));
      z->key=k;
      z->left=nil;
      z->right=nil;
      if(i==0)root=z;
      TreeInsert(T,z);
      T=z;
    }else{
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  free(z);
  return 0;
}

void TreeInsert(struct Node *T, struct Node *z){
  struct Node *y;
  struct Node *x;
  y=nil;
  x=root;

  while(x!=nil){
    if(z==x)break;
    y=x;
    if(z->key<x->key){
      x=(x->left);
    }else{
      x=(x->right);
    }
  }
  z->parent=y;     
  if(y==nil){
    root=z; /* if T is empty */
  }else if(z->key<=y->key){
    y->left=z;
  }else{
    y->right=z;
  }
}

void Preorder(struct Node *u){
  if(u!=nil){
    printf(" %d",u->key);
    Preorder(u->left);
    Preorder(u->right);
  }
}

void Inorder(struct Node *u){
  if(u!=nil){
    Inorder(u->left);
    printf(" %d",u->key);
    Inorder(u->right);
  }
}

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
ll inf = 1e9+7;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n,m; 
    ll x; cin >> n >> m >> x;
    ll c[n];
    ll a[n][m];
    ll ans = inf;
    rep(i,0,n){
        cin >> c[i];
        rep(j,0,m){
            cin >> a[i][j];
        }
    }
    rep(bit,0,(1<<n)){
        ll us[m] = {};
        ll cost = 0;
        rep(shift,0,n){
            if(bit & (1<<shift)){
                cost += c[shift];
                rep(i,0,m){
                    us[i] += a[shift][i];
                }
            }
        }
        ll ok = true;
        rep(i,0,m){
            if(us[i]<x) ok = false;
        }
        if(ok){
            ans = min(cost,ans);
        }
    }
    if(ans==1e9+7) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3660
n=int(input())
NMAX=55555
is_prime = [True]*NMAX
for i in range(2, NMAX):
    if is_prime[i]:
        for j in range(2*i, NMAX, i):
            is_prime[j] = False

prime=[]
for i in range(len(is_prime)):
  if is_prime[i] == True:
    prime.append(i)
    is_prime[i]=False
prime=[i for i in prime if i%5==1]
prime=prime[1:]
ans=prime[:n]
print(*ans)


Measured memory_bytes: 3700
N = int(input())
As = list(map(int, input().split()))

aveA = sum(As) / N

ans = 0
minDiff = abs(As[0] - aveA)
for i, A in enumerate(As[1:], 1):
    diff = abs(A - aveA)
    if diff < minDiff:
        ans = i
        minDiff = diff
print(ans)


Measured memory_bytes: 3060
n=int(input())
h=[int(i) for i in input().split()]



dp=[float('inf')]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])


Measured memory_bytes: 13980
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int N;
int x,y;
int n;
int Vert[16][16];
int Horiz[16][16];
int T[16][16];
int r,s,t,u;
int main()
{
    cin>>N;
    for(int i=0;i<N;i++)
    {
        cin>>x>>y>>n;
        for(int a=0;a<16;a++)
            for(int b=0;b<16;b++)
            {
                Vert[a][b]=1;
                Horiz[a][b]=1;
            }
        for(int a=0;a<16;a++)
        {
            Vert[a][0]=0;
            Horiz[0][a]=0;
        }
        for(int a=0;a<n;a++)
        {
            cin>>r>>s>>t>>u;
            if(r==t)
                Vert[r][max(s,u)]=0;
            if(s==u)
                Horiz[max(r,t)][s]=0;
        }
        for(int p=0;p<16;p++)
        {
            for(int q=0;q<16;q++)
            {
                if(p==0&&q==0)
                    T[p][q]=1;
                else if(p>x||q>y)
                    T[p][q]=0;
                else if(Vert[p][q]==0&&Horiz[p][q]==0)
                    T[p][q]=0;
                else if(Vert[p][q]!=0&&Horiz[p][q]==0)
                    T[p][q]=T[p][q-1];
                else if(Vert[p][q]==0&&Horiz[p][q]!=0)
                    T[p][q]=T[p-1][q];
                else if(Vert[p][q]!=0&&Horiz[p][q]!=0)
                    T[p][q]=T[p-1][q]+T[p][q-1];
            }
        }
        if(T[x][y]==0)
            cout<<"Miserable Hokusai!"<<endl;
        else
            cout<<T[x][y]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3012
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    a,b,c=L()
    c=c-(a-b) if c>=a-b else 0
    print(c)

if __name__=='__main__':
    main()

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

int main() {
  int N;
  string S;
  cin>>N>>S;
  
  int ans=1;
  for(int i=0; i<N-1; i++){
    if(S.at(i)!=S.at(i+1)){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}
 
/* brownsands :Arpit */			

void solve()
{ 
  int x,y,z;cin >> x >>y>>z;
  cout << z <<" " <<x <<" "<<y;
}
signed main()
{ 
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int test=0,t;
  //cin>>t;
    t=1;
   while(test++ <t){         
   	//cout<<"Case# "<<test<<": ";
        solve();}
  //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
} 
               
			
 

				
		
		




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

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll x[5];
    
    rep(i, 5){
        cin >> x[i];
    }
    
    rep(i, 5){
        if(x[i] != i + 1) cout << i+1 << endl;
    }

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

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

  cout << max(0, min(b,d) - max(a,c)) << endl;

  return 0;
}



Measured memory_bytes: 256
//0番の動物(2パターン)×1・N-1番の動物(2パターン)を全て試す.
#include <iostream>
#include <string>
using namespace std;

int n;
string s;
int type[100000];	//type[i] = 羊なら0, オオカミなら1

//両隣が同じ動物であってほしいならtrueを返す
bool same(int i) {
	int x = (s[i] == 'o');
	if (type[i] == 0) return x;
	return !x;
}

bool check() {
	for (int i = 0; i < n; i++) {
		int a = (i - 1 + n) % n;
		int b = (i + 1 + n) % n;
		
		if (i == 0 || i == n - 2 || i == n - 1) {	//矛盾判定
			if (same(i) != (type[a] == type[b])) return false;
		}
		else {	//定める
			if (same(i)) type[b] = type[a];
			else type[b] = !type[a];
		}
	}
	return true;
}

void answer() {
	for (int i = 0; i < n; i++) {
		if (type[i] == 0) cout << "S";
		else cout << "W";
	}
	cout << endl;
}

signed main() {
	cin >> n >> s;
	
	for (type[0] = 0; type[0] < 2; type[0]++) {
		for (type[1] = 0; type[1] < 2; type[1]++) {
			for (type[n - 1] = 0; type[n - 1] < 2; type[n - 1]++) {
				if (check()) {
					answer();
					return 0;
				}
			}
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
using ll = long long;
const int AMAX = (int)1e5;
ll cnt[AMAX + 1];

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

    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        cnt[a] += b;
    }

    for (int ans = 1; ans <= AMAX; ++ans) {
        if (K <= cnt[ans]) {
            cout << ans << endl;
            return 0;
        }
        K -= cnt[ans];
    }
}

Measured memory_bytes: 1024
import numpy as np


def getInput():
    """

    :return: list of list of str. 1st dim: row, 2nd dim: column.
    """
    separator = ' '
    ret_array = []
    while True:
        try:
            row = input().split(sep=separator)
            ret_array.append(row)
        except EOFError:
            break
    return ret_array


g = getInput()

# number
N = int(g[0][0])
C = np.zeros(N-1, dtype=int)
S = np.zeros(N-1, dtype=int)
F = np.zeros(N-1, dtype=int)


for i in range(0, N-1):
    C[i], S[i], F[i] = list(map(int, g[i+1]))


for i in range(0, N):
    if i == N-1:
        print(0)
        exit()
    current_time = 0
    for j in range(i, N-1):
        if S[j] > current_time:
            current_time = S[j]
        else:
            current_time = np.ceil(current_time/F[j])*F[j]
        current_time += C[j]
    print(int(current_time))


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

int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    cout << h2*60+m2-h1*60-m1 - k << endl;

    return 0;
}

Measured memory_bytes: 3624
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(100<=n && n<=111){
      System.out.println(111);
    }else if(111<n && n<=222){
      System.out.println(222);
    }else if(222<n && n<=333){
      System.out.println(333);
    }else if(333<n && n<=444){
      System.out.println(444);
    }else if(444<n && n<=555){
      System.out.println(555);
    }else if(555<n && n<=666){
      System.out.println(666);
    }else if(666<n && n<=777){
      System.out.println(777);
    }else if(777<n && n<=888){
      System.out.println(888);
    }else{
      System.out.println(999);
    }
  }
}


Measured memory_bytes: 22996
#include<iostream>
#include<utility>
#include<queue>
#include<vector>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e7
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int h,w;
bool inner(int x,int y){
  if(x<0||x>=w)return false;
  if(y<0||y>=h)return false;
  return true;
}

int main(){
  cin>>h>>w;
  bool m[h][w],visit[h][w];
  string s;
  int black=0;
  rep(i,h){
    cin>>s;
    rep(j,w){
      m[i][j]=(s[j]=='.'?true:false);
      if(!m[i][j])black++;
      visit[i][j]=false;
    }
  }
  queue<piii> node;
  node.push(piii(pii(0,0),1));
  int ans=-1;
  while(!node.empty()){
    piii now=node.front();
    node.pop();
    int nowx=now.first.first,nowy=now.first.second;
    if(visit[nowy][nowx])continue;
    visit[nowy][nowx]=true;
    if(nowx==w-1 && nowy==h-1){
      ans=now.second;
      break;
    }
    rep(i,4){
      int nx=nowx+dx[i],ny=nowy+dy[i];
      if(visit[ny][nx])continue;
      if(!inner(nx,ny))continue;
      if(m[ny][nx])node.push(piii(pii(nx,ny),now.second+1));
    } 
  }
  cout<<(ans!=-1?h*w-ans-black:-1)<<endl;
  return 0;
}


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

ans = 0
for i in range(1000):
    n = "{:03}".format(i)
    index = 0
    c = 0
    for k in n:
        for j in range(index, N):
            if S[j] == k:
                index = j+1
                c+=1
                break
    if c == 3:
        ans += 1
print(ans)


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

using namespace std;

typedef long long ll;
const int mod=1e9+7;

ll a[100500][100];

ll comb(int x,int y){
	if(a[x][y]) 
		return a[x][y];
	if(y==0||y==x ) 
		return a[x][y]=1;
	return a[x][y]=(comb(x-1,y)+comb(x-1,y-1))%mod;
}

int main(){
	ll m,n;
	cin>>n>>m;
	ll x=m,p=2,ans=1;
	while(p*p<=m){
		int cnt=0;
		while(x%p==0){
			x/=p;
			cnt++;
		}
		if(cnt){
			ans=(ans*comb(n+cnt-1,cnt)) % mod;
		}
		p++;
	}
	if(x!=1)
		ans=(ans*n)%mod;
	cout<<ans<<endl;
}


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

using namespace std;

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

int main()
{
  IO;
  set <int> st;
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    int k; cin >> k;
    if (st.count(k)) st.erase(k);
    else st.insert(k);
  }
  cout << st.size() << endl;

  return 0;
}

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

int main(){
  double N;cin>>N;
  vector<double> v(N);
  rep(i,N) cin>>v[i];
  sort(v.begin(),v.end());
  double ans=(v[0]+v[1])/2;
  if(N>2){
    for(int i=2;i<N;i++){
      ans=(ans+v[i])/2;
    }
  }
  cout<<fixed<<setprecision(7)<<ans<<endl;
}

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

int main () {

  string S,T,U;
  cin >> S >>T;
  
  int A,B;
  cin >> A >> B;
  cin >> U;
  if(U == S){
    cout << A-1 << " " << B <<endl;
  }
  if(U == T){
    cout << A << " " << B-1 <<endl;
  }


}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, k) = readIntegerList()
    val vList = readLongList()

    val lQueue = PriorityQueue<Long>()
    var ans = 0L
    for (l in 0..min(k, n)) {
        if (l != 0) lQueue.add(vList[l - 1])

        val rQueue = PriorityQueue<Long>()
        for (r in 0..min(k - l, n - l)) {
            if (r != 0) rQueue.add(vList[n - r])

            val remain = k - l - r
            val queue = PriorityQueue(lQueue)
            queue.addAll(rQueue)
            for (i in 0 until remain) {
                if (queue.isNotEmpty() && queue.peek() < 0) queue.remove() else break
            }

            ans = max(ans, queue.sum())
        }
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

int main(){
    int h,w;
    cin >> h >>w;
    char maze[h][w];
    rep(i,h){
        rep(j,w){
            cin >> maze[i][j];
        }
    }
    int l[h][w],r[h][w],t[h][w],u[h][w];
    rep(i,h){
        rep(j,w){
            if(maze[i][j]=='#') l[i][j]=0;
            else if(j==0) l[i][j]=1;
            else l[i][j]=l[i][j-1]+1;

            if(maze[i][w-1-j]=='#') r[i][w-1-j]=0;
            else if(j==0) r[i][w-1-j]=1;
            else  r[i][w-1-j]=r[i][w-j]+1;

            if(maze[i][j]=='#') t[i][j]=0;
            else if(i==0) t[i][j]=1;
            else t[i][j]=t[i-1][j]+1;

            if(maze[h-1-i][j]=='#') u[h-1-i][j]=0;
            else if(i==0) u[h-1-i][j]=1;
            else u[h-1-i][j]=u[h-i][j]+1;  
        }
    }
    int ans=0;
    rep(i,h){
        rep(j,w){
            int count=0;
            count = r[i][j]+l[i][j]+t[i][j]+u[i][j]-3;
            ans=max(count,ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 66688
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,w;
  cin>>n>>w;
  long int wt[n],v[n];
  for(int i=0;i<n;i++)cin>>wt[i]>>v[i];
  vector< vector<long int> > dp(n,vector<long int>(w,0));
  for(int i=0;i<w;i++){
    if(wt[0]>i+1)dp[0][i] = 0;
    else dp[0][i] = v[0];
  }
 
  for(int i=1;i<n;i++){
    for(int j=0;j<w;j++){
      if(wt[i]>j+1){
        dp[i][j] = dp[i-1][j];
      }
      else{
        long int remain = (j+1) - wt[i];
        long int res = 0;
        if(remain > 0){
          res = v[i] + dp[i-1][remain-1];
        }
        else {
          res = v[i];
        }
        dp[i][j] = max(dp[i-1][j],res);
      }
    }
  }
  cout<<dp[n-1][w-1];
  return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	vector<string> S(N);
	int ac_cnt = 0, wa_cnt = 0, tle_cnt = 0, re_cnt = 0;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	for (auto x : S) {
		if (x == "AC") ac_cnt++;
		else if (x == "WA") wa_cnt++;
		else if (x == "TLE") tle_cnt++;
		else if (x == "RE") re_cnt++;
	}
	cout << "AC x " << ac_cnt << '\n';
	cout << "WA x " << wa_cnt << '\n';
	cout << "TLE x " << tle_cnt << '\n';
	cout << "RE x " << re_cnt << '\n';
	return 0;
}

Measured memory_bytes: 6340
using System;

namespace Atcoder0128_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int x = int.Parse(input);
            input = Console.ReadLine();
            int a = int.Parse(input);
            input = Console.ReadLine();
            int b = int.Parse(input);

            int tmp = x - a;
            int tmp2 = tmp / b;
            Console.WriteLine(tmp - b * tmp2);
        }
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var bodystr = Console.ReadLine();
        var bodyArray = bodystr.ToCharArray();
        var countNum = int.Parse(Console.ReadLine());
        var endList = new List<string>();
        var firstList = new List<string>();
        var firstPlace = 0;
        var endPlace = 0;
        var gyaku = false;

        for (var i = 0; i < countNum; i++)
        {
            var allShiji = Console.ReadLine();
            var shijiList = allShiji.Split(' ');
            if (shijiList[0] == "1")
            {
                gyaku = !gyaku;
            }
            else
            {
                if (shijiList[1] == "1")
                {
                    if (gyaku)
                    {
                        endList.Add(shijiList[2]);
                    }
                    else
                    {
                        firstList.Add(shijiList[2]);
                    }
                }
                else
                {
                    if (!gyaku)
                    {
                        endList.Add(shijiList[2]);
                    }
                    else
                    {
                        firstList.Add(shijiList[2]);
                        firstPlace++;
                    }
                }

            }
        }

        var str = "";
        firstList.Reverse();
        var first = string.Join("", firstList);
        var end = string.Join("", endList);

        if (gyaku)
        {
            str = string.Join("", (first + bodystr + end).Reverse());
        }
        else
        {
            str = string.Join("", first + bodystr + end);
        }
        Console.WriteLine(str);
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll H; cin >> H;

    ll t = 1;
    ll ans = 0;

    while(H){
        ans += t;
        t *= 2;
        H /= 2;
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;
int main(){
    int a,b;scanf("%d%d",&a,&b);
    double ret=0;
    for(int i=1;i<=a;i++){
        double tmp=1.0/a;
        int now=i;
        while(now<b){
            now*=2;
            tmp/=2;
        }
        ret+=tmp;
    }   
    printf("%.12f\n",ret);
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author palayutm
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);
            Arrays.sort(a);
            int sum = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 > 0) sum += a[i];
                else sum -= a[i];
            }
            out.println(Math.abs(sum));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 22740
from collections import deque

h, w = map(int, input().split())

board = []
for row in range(h):
    board.append(list(input()))

def bfs(row, col):
    if board[row][col] == "#":
        return 0
    max_path = 0
    queue = deque([(row, col)])
    visited[row][col] = 0
    while queue:
        next = queue.popleft()
        if next[0] < h-1 and visited[next[0]+1][next[1]] == -1 and board[next[0]+1][next[1]] == ".":
            visited[next[0]+1][next[1]] = visited[next[0]][next[1]] + 1
            if visited[next[0]][next[1]] + 1 > max_path:
                max_path = visited[next[0]][next[1]] + 1
            queue.append((next[0]+1, next[1]))
        if next[0] > 0 and visited[next[0]-1][next[1]] == -1 and board[next[0]-1][next[1]] == ".":
            visited[next[0]-1][next[1]] = visited[next[0]][next[1]] + 1
            if visited[next[0]][next[1]] + 1 > max_path:
                max_path = visited[next[0]][next[1]] + 1
            queue.append((next[0]-1, next[1]))
        if next[1] < w-1 and visited[next[0]][next[1]+1] == -1 and board[next[0]][next[1]+1] == ".":
            visited[next[0]][next[1]+1] = visited[next[0]][next[1]] + 1
            if visited[next[0]][next[1]] + 1 > max_path:
                max_path = visited[next[0]][next[1]] + 1
            queue.append((next[0], next[1]+1))
        if next[1] > 0 and visited[next[0]][next[1]-1] == -1 and board[next[0]][next[1]-1] == ".":
            visited[next[0]][next[1]-1] = visited[next[0]][next[1]] + 1
            if visited[next[0]][next[1]] + 1 > max_path:
                max_path = visited[next[0]][next[1]] + 1
            queue.append((next[0], next[1]-1))
    return max_path

result = 0
for i in range(h):
    for j in range(w):
        visited = [[-1]*w for _ in range(h)]
        max_path = bfs(i, j)
        if result < max_path:
            result = max_path

print(result)


Measured memory_bytes: 3308
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let mut s = 1;
    for _ in 0..n {
        if s * 2 < s +k {
            s *= 2;
        } else {
            s +=k;
        }
    }
    println!("{}", s);
}

Measured memory_bytes: 4352
#include "stdio.h"
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    while(1)
    {
        vector<pair<int,int> > ten[100];
        int n,k;
        scanf("%d %d",&n,&k);
        if(n == 0 && k == 0)
        {
            break;
        }
        for(int i = 0; i < k; i++)
        {
            int w;
            scanf("%d",&w);
            if(w == 0)
            {
                int a,b;
                scanf("%d %d",&a,&b);
                a--;
                b--;
                int e[100];
                for(int i = 0; i < n; i++)
                {
                    e[i] = (2e9);
                }
                priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
                q.push(make_pair(0,a));
                while(q.size() > 0)
                {
                    if(e[q.top().second] > q.top().first)
                    {
                        e[q.top().second] = q.top().first;
                        if(q.top().second == b)
                        {
                            break;
                        }
                        for(int ii = 0; ii < ten[q.top().second].size(); ii++)
                        {
                            q.push(make_pair(q.top().first + ten[q.top().second][ii].second,ten[q.top().second][ii].first));
                        }
                    }
                    q.pop();
                }
                if(e[b] == (2e9))
                {
                    printf("-1\n");
                }
                else
                {
                    printf("%d\n",e[b]);
                }
            }
            else
            {
                int a,b,c;
                scanf("%d %d %d",&a,&b,&c);
                a--;
                b--;
                ten[a].push_back(make_pair(b,c));
                ten[b].push_back(make_pair(a,c));
            }
        }
    }
}

Measured memory_bytes: 1256
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int a[11],b[11],i,s,z;
	for(i=1;i<=10;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+11,greater<int>());
	for(i=1;i<=10;i++){
		scanf("%d",&b[i]);
	}
	sort(b+1,b+11,greater<int>());
	s=a[1]+a[2]+a[3];
	z=b[1]+b[2]+b[3];
	printf("%d %d\n",s,z);
	return 0;
}

Measured memory_bytes: 1036
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <deque>
#define ll long long

using namespace std;

struct pour {
	int stt;
	int end;
	int sz;
};

int main() {
	string s; cin >> s;
	vector<pour> parts;
	deque<int> st;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '/') {
			if (st.size() == 0) {
				continue;
			}
			else {
				int prev = st.back(); st.pop_back();
				pour tmp;
				tmp.stt = prev;
				tmp.end = i;
				tmp.sz = i - prev;
				parts.push_back(tmp);
			}
		}
		else if (s[i] == '\\') {
			st.push_back(i);
		}
	}
	if (parts.size() == 0) {
		cout << 0 << endl << 0 << endl;
		return 0;
	}

	int sum = 0;
	deque<int> out;
	int stt = parts.back().stt;
	int ed = parts.back().end;
	for (int i = parts.size() - 1; i >= 0; i--) {
		pour cur = parts[i];
		sum += cur.sz;
		if (cur.stt > stt && cur.end < ed) {
			int pick = out.back(); out.pop_back();
			out.push_back(pick + cur.sz);
		}
		else {
			stt = cur.stt;
			ed = cur.end;
			out.push_back(cur.sz);
		}
	}

	cout << sum << endl;
	cout << out.size();
	for (int i = out.size() - 1; i >= 0; i--) {
		cout << " " << out[i];
	}
	cout << endl;




	return 0;

}





Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> Pi;
typedef unsigned long long ULL;
int gcd(int a,int b){if (b == 0) return a; return gcd(b , a%b);}
int lcm(int a, int b){ return a/gcd(a,b)*b;}
inline int read(){
    int f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e5 + 10;
LL cntA[maxn], cntB[maxn] , ans[maxn];
LL fac[maxn];
int main(){
    //freopen("/Users/chutong/data.txt", "r", stdin);
    LL A,B;
    scanf("%lld%lld",&A,&B);A--;
    int len1 = log2(A) + 1,len2 = log2(B) + 1;
    fac[0] = 1;
    for (int i=1; i<=40; i++) {
        fac[i] = fac[i-1]*2;
    }
    for (int i=1; i<=len1; i++) {
        LL left =  (A+1) % fac[i];
        cntA[i] = (A+1)/fac[i];
        cntA[i] *= fac[i-1];
        if (left > fac[i]/2){
            cntA[i] += left - fac[i]/2;
        }
    }
    for (int i=1; i<=len2; i++) {
        LL left =  (B+1) % fac[i];
        cntB[i] = (B+1)/fac[i];
        cntB[i] *= fac[i-1];
        if (left > fac[i]/2){
            cntB[i] += left - fac[i]/2;
        }
    }
    LL res = 0;
    for (LL i=1; i<=max(len1,len2); i++) {
        if ((cntB[i] & 1) ^ (cntA[i] & 1)){
            ans[i] = 1;
            res += pow(2, i-1);
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;cin>>s;
	int n = s.size(), cnt = 0;
	for(int i = 0; i < n; i += 2){
		if(s[i]=='h' && s[i+1]=='i') cnt++;
	}
	if(cnt*2==n){
		cout<<"Yes";
	} else{
		cout<<"No";
	}
	return 0;
}



Measured memory_bytes: 256
#include <array>
#include <cstddef>
#include <functional>
#include <type_traits>
#include <utility>

template <class Key, class T, Key Empty, std::size_t N,
	class Hash = std::hash<Key>>
	struct mu_hashmap {

	std::array<std::pair<Key, T>, N> table;
	Hash hash;

	explicit mu_hashmap(Hash hash = Hash()) : table(), hash(hash) {
		for (auto itr = table.begin(), end = table.end(); itr != end; ++itr) {
			itr->first = Empty;
		}
	}

	T& operator[](const Key key) {
		typename std::array<std::pair<Key, T>, N>::iterator itr =
			table.begin() + hash(key) % N;
		while (itr->first != key) {
			if (itr->first == Empty) {
				itr->first = key;
				break;
			}
			++itr;
			if (itr == table.end()) {
				itr = table.begin();
			}
		}
		return itr->second;
	}
};

#include<cstddef>
#include<cstdint>
#include<iostream>

int main() {
	using usize = std::size_t;
	using u32 = std::uint_fast32_t;
	using i64 = std::int_fast64_t;

	usize n;
	std::cin >> n;

	u32 ans = 0;
	i64 acc = 0;
	mu_hashmap<i64, u32, 200000ULL * 1000000000 + 1, (1ULL<<20)-5> count;
	++count[acc];

	for (usize i = 0; i != n; ++i) {
		i64 a;
		std::cin >> a;

		acc += a;
		ans += count[acc];
		++count[acc];
	}

	std::cout << ans << std::endl;

	return 0;
}



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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int K;
ll calcDP( string s )
{
    vector<vector<vector<ll> > > dp(s.size()+1, vector<vector<ll> > (2, vector<ll>(12,0)));
    
    dp[0][0][0] = 1;

    rep(i,s.size())
    {
        int key = s[i]-'0';
        rep(smaller, 2)
        {
            rep(zero_cnt, 10)
            {
                rep(n, (smaller? 10 : key+1))
                {
                    if( n != 0 ) dp[i+1][smaller || n < key][zero_cnt+1] += dp[i][smaller][zero_cnt];
                    else dp[i+1][smaller || n < key][zero_cnt] += dp[i][smaller][zero_cnt];
                }
            }
        }
    }
    return dp[s.size()][0][K] + dp[s.size()][1][K];
}

int main()
{
    string N;
    cin >> N >> K;
    cout << calcDP(N) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    string S;
    cin >> S;
    int N = sz(S);
    int dp[N+1], next[N+1][26];
    fill(dp, dp+N+1, inf);
    dp[N] = 0;
    fill(next[N], next[N]+26, -1);
    rep3(i, N-1, 0){
        rep(j, 26) next[i][j] = next[i+1][j];
        next[i][S[i]-'a'] = i+1;
    }
    rep3(i, N-1, 0){
        rep(j, 26){
            if(next[i][j] == -1) chmin(dp[i], 0);
            else chmin(dp[i], dp[next[i][j]]+1);
        }
    }
    int n = dp[0], now = 0;
    string ans;
    rep(i, n){
        rep(j, 26){
            if(dp[next[now][j]] == n-i-1){
                ans += 'a'+j;
                now = next[now][j];
                break;
            }
        }
    }
    rep(j, 26){
        if(next[now][j] == -1){
            ans += 'a'+j;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 24832
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define fi first
#define se second
 
const ll MOD = 1000000007;

int main() {
   int n, k; scanf("%d%d", &n, &k);
   if (k > (n - 1) * (n - 2) / 2) {
      puts("-1");
   } else {
      int c = 0;
      while (c < k) {
         if ((c + 1) * c / 2 > k)
            break;
         ++c;
      }
      vector<pi> e;
      for (int i = 1; i < n - c; ++i) {
         for (int j = i + 1; j < n; ++j)
            e.pb({i, j});
      }
      for (int i = 1; i < n - k + c * (c - 1) / 2; ++i)
         e.pb({i, n});
      printf("%d\n", e.size());
      for (auto i : e)
         printf("%d %d\n", i.fi, i.se);
   }
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2){
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}

// g++ -std=c++11 prac.cpp
ll Max=-1,Min=1e9+1;

int main(){
    ll x=0,y=0,n,m,k,l,r,w,sum1=0,sum2=0,ans=0;
    string s,t;
    bool f=true;
    map <int,int> a;
    cin >> n;
    rep(i,n){
        cin >> x;
        if(a.empty()==1){
            a.insert(make_pair(x,1));
        }
        else if (a.find(x) != a.end()){
            a.find(x)->second++;
        }
        else{
            a.insert(make_pair(x,1));
        }
    }
    for(auto i=a.begin();i!=a.end();i++){
        if(i->first > i->second){
            ans += i->second;
        }
        else{
            ans += i->second - i->first;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
 
const int INF = 1145141919;
const long long INFL = 1LL<<60;
 
template<class T>
inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
 
template<class T>
inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
 
int H, W;
int a[1100][1100];
long long int memo[1100][1100];
 
int rec(int x, int y)
{
	if(x == 0 || x > W || y == 0 || y > H || a[y][x])
	{
		return 0;
	}
	if(memo[y][x] != 0)
	{
		return memo[y][x];
	}
	// cout << x << " " << y << endl;
	if(x == W && y == H)
	{
		return 1;
	}
	int ans = 0;
	ans = rec(x+1, y) + rec(x, y+1);
	return memo[y][x] = ans % 1000000007;
}
 
int main()
{
	cin >> H >> W;
	char in;
	for (int i = 1; i <= H; ++i)
	{
		for (int j = 1; j <= W; ++j)
		{
			cin >> in;
			a[i][j] = (in == '.' ? 0 : 1);
		}
	}
	memo[H][W] = 1;
	for (int i = H; i > 0; --i)
	{
		for (int j = W; j > 0; --j)
		{
			if(!a[i][j])
			{
				memo[i][j] += memo[i+1][j] + memo[i][j+1];
				memo[i][j] %= 1000000007;
			}
		}
	}
	cout << memo[1][1] << endl;
	return 0;
}

Measured memory_bytes: 13952
S = input()
T = input()
if len(S)==1:
    Flag = (S==T)
else:
    Flag = False
    for X in range(0,len(S)):
        S = S[-1]+S[0:-1]
        if S==T:
            Flag = True
            break
if Flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 8980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

int main() {
    int r,c,k,x,y,z;
	cin >> r>> c>> k;
    ll a[3*r+1][c];
    int v[r][c];
    fr(i,r){
      fr(j,c){
        v[i][j]=0;
      }
    }
    fr(i,k){
      cin >> x>> y >> z;
      v[x-1][y-1]=z;
    }
    fr(i,3*r+1){
      fr(j,c){
        if(i==0)a[i][j]=0;
        else if(j==0)a[i][j]=a[int((i-1)/3)*3][j]+v[(i-1)/3][0];
        else if(i%3==1){
          a[i][j]=max(a[i-1][j]+v[(i-1)/3][j],a[i][j-1]);
        }
        else{
          a[i][j]=max(a[i-1][j-1]+v[(i-1)/3][j],max(a[i-1][j],a[i][j-1]));
        }
      }
    }
  cout <<a[3*r][c-1]<< endl;
}

Measured memory_bytes: 249700