akhauriyash/Code-Regression huggingface dataset:
//start of jonathanirvings' template v3.0.3 (BETA)

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n,x;
int pos[200005];

int main()
{
  scanf("%d",&n);
  REPN(i,n)
  {
    scanf("%d",&x);
    pos[x] = i;
  }
  int risan = 1;
  int now = 1;
  FORN(i,2,n)
  {
    if (pos[i] > pos[i-1]) ++now;
    else now = 1;
    MAX(risan,now);
  }
  printf("%d\n",n-risan);
  return 0;
}











Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

string i_to_05b(unsigned int n){
	string s = "";
	do{
		char c = (n & 1U) + '0' ;
		s.push_back( c );
		n >>= 1;
	}while( n != 0 );

	while( s.size() < 5 )
		s.push_back('0');
	reverse( s.begin() , s.end() );
	
	return s;
}

void makeTable1(map<char,string>& table1){
	table1[' ']  = "101";
	table1['\''] = "000000";
	table1[',']  = "000011";
	table1['-']  = "10010001";
	table1['.']  = "010001";
	table1['?']  = "000001";
	table1['A']  = "100101";
	table1['B']  = "10011010";
	table1['C']  = "0101";
	table1['D']  = "0001";
	table1['E']  = "110";
	table1['F']  = "01001";
	table1['G']  = "10011011";
	table1['H']  = "010000";
	table1['I']  = "0111";
	table1['J']  = "10011000";
	table1['K']  = "0110";
	table1['L']  = "00100";
	table1['M']  = "10011001";
	table1['N']  = "10011110";
	table1['O']  = "00101";
	table1['P']  = "111";
	table1['Q']  = "10011111";
	table1['R']  = "1000";
	table1['S']  = "00110";
	table1['T']  = "00111";
	table1['U']  = "10011100";
	table1['V']  = "10011101";
	table1['W']  = "000010";
	table1['X']  = "10010010";
	table1['Y']  = "10010011";
	table1['Z']  = "10010000";
}

void makeTable2(map<string,char>& table2){
	for(char c = 'A' ; c <= 'Z' ; ++c){
		table2[ i_to_05b( (int)(c - 'A') ) ] = c;
	}
	table2["11010"] = ' ';
	table2["11011"] = '.';
	table2["11100"] = ',';
	table2["11101"] = '-';
	table2["11110"] = '\'';
	table2["11111"] = '?';
}

string encode(string p, map<char,string> table1){
	
	string c = "";
	for(int i=0 ; i<p.size() ; ++i ){
		c += table1[ p[i] ];
	}
	return c;
}
string decode(string c , map<string,char> table2){
	string p = "";
	while( c.size() % 5 != 0){
		c.push_back('0');
	}
	for(int i=0 ; i+5 <= c.size() ; i += 5 ){
		p.push_back( table2[ c.substr( i , 5 ) ] );
	}
	return p;
}

int main(){
	string p;
	map<char,string> table1;
	map<string,char> table2;
	makeTable1(table1);
	makeTable2(table2);

	while( getline( cin , p ) ){
		//cout << decode( "000000000100" , table2 ) << endl;
		cout << decode( encode( p , table1 ) , table2 ) << endl;
		//cout << decode( encode( "PETER POTTER" , table1 ) , table2) << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}

void solve()
{
    long long a,b;
    cin>>a>>b;
    long long ans=(a*b)/__gcd(a,b);
    cout<<ans<<endl;

}
int main()
{
    int tc=1;
    while(tc--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c;
    int ans;

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

    if(b+c > a){
        ans = b+c-a;
    }else if(b+c  <= a){
        ans = 0;
    }

    printf("%d\n", ans);

    return 0;
}

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

#define pr 0.000001
typedef long long ll;

ll max(ll a, ll b)
{
    return a>b ? a : b;
}
ll min(ll a, ll b)
{
    return a<b ? a : b;
}
int comparetor (const void * a, const void * b)
{
	return ( *(int*)a - *(int*)b );
}
int main()
{
    int arr[3];
    scanf("%d %d %d", &arr[0], &arr[1], &arr[2]);
    int c5=0, c7=0;
    for(int i=0; i<3; i++)
    {
    	if(arr[i]==7)
    		c7++;
    	else if(arr[i]==5)
    		c5++;
    }
    if(c5==2 && c7==1)
    	printf("YES\n");
    else
    	printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility>
using namespace std;

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

typedef long long ll;
typedef vector<vector<int>> Graph;

int main() {
	//入力;
	int a, b;
	cin >> a >> b;
	if (b % a == 0) cout << a + b;
	else cout << b - a;
	cout << endl;


	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
   	ll a , b ;
   	cin >> a >> b ;
   	if (a > b) swap(a , b) ;
   	cout << max(2 * b - 1 , a + b) ;
    
    return (0) ;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 105;

int t[N], v[N], z[400 * N], mv, to, s;

int main() {
    int n, i, j = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) scanf("%d", t + i), t[i] *= 2;
    for(int i = 1; i <= n; ++i) scanf("%d", v + i), v[i] *= 2;

    for(int i = 1; i <= n; ++i) {
        to += t[i];
        z[j] = min(z[j], v[i]);
        for(++j; j <= to; ++j) z[j] = min(z[j - 1] + 1, v[i]);
        j--;
    }

    for(int i = j - 1; i >= 1; i--) s += mv = (min(z[i], mv + 1));
    printf("%.9f\n", s / 4.0);
}


Measured memory_bytes: 384
#include<stdio.h>

/*構造体の定義*/
typedef struct {
	char suit;
	int value;
} Card ;


void swap_Card(Card *x, Card *y)
{
	Card temp = *x;
	*x = *y;
	*y = temp;
}


/*
void BubbleSort(Card A[], int N) {
	int i, j;
	Card temp;

	for (i = 0; i < N-1; i++) {
		for (j = N - 1; j > i ; j--) {
			if (A[j].value < A[j - 1].value) {
				temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
			}
		}
	}
}
*/

void BubbleSort(Card A[], int N) {
	int i, j;
	Card temp;

	for (i = 0; i < N; i++) {
		for (j = N - 1; j >= i + 1; j--) {
			if (A[j].value < A[j - 1].value) {
				temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
			}
		}
	}
}

/*
void SelectionSort(Card A[], int N) {
	int i, j;
	int minj;
	Card temp;

	for (i = 0; i < N-1; i++) {
		minj = i;
		for (j = i+1; j < N; j++) {
			if (A[j].value < A[minj].value) {
				minj = j;
			}
		}
		temp = A[i];
		A[i] = A[minj];
		A[minj] = temp;
	}
}
*/

void SelectionSort(Card A[], int N) {
	int i, j;
	int minj;
	Card temp;

	for (i = 0; i < N; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (A[j].value < A[minj].value) {
				minj = j;
			}
		}
		temp = A[i];
		A[i] = A[minj];
		A[minj] = temp;
	}
}



int main()
{
	int N;
	scanf("%d\n", &N);

	int i,j;
	Card BC[36];
	Card SC[36];

	for (i = 0; i < N; i++) {
		Card c;
		scanf("%c", &c.suit);
		scanf("%d ", &c.value);
		BC[i] = c;
		SC[i] = c;
	}

    
	/* 
    for (i = 0; i < N - 1; i++) {
        for (j = N - 1; j > i; j--) {
            if (BC[j].value < BC[j - 1].value)
                swap_Card(&BC[j], &BC[j - 1]);
        }
    }
	
	
    for (i = 0; i < N - 1; i++) {
        int minj = i;
        for (j = i + 1; j < N; j++) {
            if (SC[j].value < SC[minj].value)
                minj = j;
        }
        swap_Card(&SC[i], &SC[minj]);
    }
    */
    
    BubbleSort(BC,N);
    SelectionSort(SC,N);
	
	/* Output */
	for (i = 0; i < N - 1; i++) {
		printf("%c%d ", BC[i].suit, BC[i].value);
	}
	printf("%c%d\n", BC[N - 1].suit, BC[N - 1].value);
	puts("Stable");

	for (i = 0; i < N - 1; i++) {
		printf("%c%d ", SC[i].suit, SC[i].value);
	}
	printf("%c%d\n", SC[N - 1].suit, SC[N - 1].value);

	for (i = 0; i < N; i++) {
		if (BC[i].suit != SC[i].suit) {
			puts("Not stable");
			return 0;
		}
	}
	puts("Stable");

	return 0;
}


Measured memory_bytes: 2024
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
t, ans = sum(B), 0
j = M
for i in range(N+1):
   while j>0 and t>K:
       j -= 1
       t -= B[j]
   if t>K: break
   ans = max(ans, i+j)
   if i==N: break
   t += A[i]

print(ans)
  


Measured memory_bytes: 118144
#include<bits/stdc++.h>
using namespace std;
int main(void){

  long long W, H, x, y;
  cin >> W >> H >> x >> y;

  printf("%lf %d", (double)W * (double)H / 2 , x * 2 == W && y * 2 == H);


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
    int x, max = 0, num;
    scanf("%d", &x);
    for (int b = 1; b < 1000; b++) {
        for (int p = 2; p < 10; p++) {
            num = 1;
            for (int i = 0; i < p; i++) {
                num *= b;
            }
            if (num <= x && max < num) {
                max = num;
            }
        }
    }
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    
    int cnt,n;
    
    while(1){
        cin >> n;
        if(!n){
            return 0;
        }
        cnt = 0;
        n = 1000 - n;
        cnt += n / 500;
        n %= 500;
        cnt += n / 100;
        n %= 100;
        cnt += n / 50;
        n %= 50;
        cnt += n / 10;
        n %= 10;
        cnt += n / 5;
        n %= 5;
        cnt += n;
        
        cout << cnt << endl;
    }
}


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

#define LEN 100005
#define MAX 100

typedef struct pp{
  char name[MAX];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void initialize(void);

void enqueue(P);
P dequeue(void);


int main(){
  P u;
  int elaps = 0, n;
  int i, q;
 
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", u.name);
    scanf("%d", &u.t);
    enqueue(u);
  }
 
  while(head != tail){
    u=dequeue();
    if(u.t>q){
      u.t=u.t-q;
      enqueue(u);
      elaps+=q;
    }
    else{
      printf("%s %d\n",u.name,u.t+elaps);
      elaps+=u.t;
    }
  }
  
  return 0;
}
void initialize(void){
  head=0;
  tail=0;
}
 

void enqueue(P x){
 
    Q[tail]=x;
    if(tail+1==LEN)
      tail=0;
    else
      tail++;

}
P dequeue(void){
  P x;
  
    x=Q[head];
    if(head+1==LEN)
      head=0;
    else
      head++;

  return x;
}

Measured memory_bytes: 10756
#include<bits/stdc++.h>
#define F first
#define S second
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

void  solve(){
    int n,m, mx = 0;
    cin>>n>>m;
    vector<string> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int k=0;k<n;k++){
        for(int l=0;l<m;l++){
                    if( a[k][l] == '#' ) continue;
                    queue<pair<pair<int,int>,int>> q;
                    int visi[n][m] = {0};
                    for(int i=0;i<n;i++)
                    for(int j=0;j<m;j++) visi[i][j] =0;
                    q.push({{k,l},0});
                    visi[k][l] =1;
                    while(q.size()){
                        int j,i,cnt;
                        i = q.front().F.F;
                        j = q.front().F.S;
                        cnt = q.front().S;
                        //cout<<i<<" "<<j<<" "<<cnt<<"* "<<u<<" "<<v<<endl;
                        q.pop();
                        mx = max(mx,cnt);
                        //if(k == 2&&l == 0) cout<<mx<<" "<<cnt<<" "<<i<<" "<<j<<endl;
                        //if(i == 0&&j == 1&&k==2&&l==0) cout<<visi[0][2]<<"**";
                        if(i!=0&&a[i-1][j] == '.'&&visi[i-1][j]==0) 
                        {q.push({{i-1,j},cnt+1}); visi[i-1][j] =1;}  
                        if(i!=n-1&&a[i+1][j] == '.'&&visi[i+1][j]==0) {
                            q.push({{i+1,j},cnt+1});
                            visi[i+1][j] =1;
                        }
                        if(j!=0&&a[i][j-1] == '.'&&visi[i][j-1]==0){
                            q.push({{i,j-1},cnt+1});
                            visi[i][j-1]=1;
                        }
                        if(j!=m-1&&a[i][j+1] == '.'&&visi[i][j+1]==0) {
                            q.push({{i,j+1},cnt+1});
                            visi[i][j+1]=1;
                        }
                    }
                
            
        }
    }
    cout<<mx;
}
        
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   // int n; cin>>n; for(int i=0;i<n;i++)
        solve();
    return 0;
}

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

typedef long long ll; 
const ll segN=(1LL<<32);
vector<ll> G;
struct data{
  vector<ll> *v;
  bool flg;
  data* ch[2];
  
  void init(){
    v=new vector<ll>;
    flg=false;
    ch[0]=(data*)malloc(sizeof(data));
    ch[1]=(data*)malloc(sizeof(data));
    ch[0]->ch[0]=NULL;
    ch[1]->ch[0]=NULL;
  }
  
  void add(ll i,ll x,ll l,ll r){
    //    cout<<i<<' '<<x<<' '<<l<<' '<<r<<endl;
    ll m=(l+r)/2;
    if(ch[0]==NULL)init();
    if(i<l || r<=i)return;
    v->push_back(x);
    if(r-l==1)return;
    ch[0]->add(i,x,l,m);
    ch[1]->add(i,x,m,r);
  }
   
  void add(ll i,ll x){
    add(i,x,0,segN);
  }
  
  ll sum(ll a,ll b,ll c,ll d,ll l,ll r){
    ll m=(l+r)/2;
    if(ch[0]==NULL)return 0;
    if(b<=l || r<=a)return 0;
    if(a<=l && r<=b){
      if(!flg)sort(v->begin(),v->end());
      flg=true;      
      vector<ll> :: iterator A,B;
      A=lower_bound(v->begin(),v->end(),c);
      B=upper_bound(v->begin(),v->end(),d);
      return B-A;
    }
    
    ll res=0;
    res+=ch[0]->sum(a,b,c,d,l,m);
    res+=ch[1]->sum(a,b,c,d,m,r);
    return res;
  }
 
  ll sum(ll a,ll b,ll c,ll d){
    return sum(a,b,c,d,0,segN);
  }
};
 
 
   

data T;
 
int main(){
  ll d=1e9;
  int n,m;
  int ax,ay,bx,by;
  T.init();
  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++){
    scanf("%d %d",&ax,&ay);
    T.add(ax+d,ay);
  }
  for(int i=0;i<m;i++){
    scanf("%d %d %d %d",&ax,&ay,&bx,&by);
    cout<<T.sum(ax+d,bx+d+1,ay,by)<<endl;
  }
  return 0;
}

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

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

  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    for (int j = l; j <= r; j++) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#define rep(i,N) for(int i=0;i<int(N);i++)
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<string> S(N);
    rep(i,N){
        cin >> S[i];
    }
    map<string,int> words;
    int currentMax=0;
    string arg_max;
    rep(i,N){
        words[S[i]]+=1;
    }

    for(auto it = words.cbegin(); it != words.cend(); ++it ) {
        if (it ->second > currentMax) {
            arg_max = it->first;
            currentMax = it->second;
        }
    }
    vector<string> ans;
    for(auto it = words.cbegin(); it != words.cend(); ++it ) {
        if(currentMax == it -> second){
            ans.push_back(it -> first);
        }
    }
    rep(i,ans.size()){
        cout << ans.at(i) <<endl;
    }

}


Measured memory_bytes: 28404
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 20, mod = 998244353;

int n, m, col[N], lin[N], comb[N][N], f[N][N][2], g[N][N][2], icomb[N][N];
char s[N];

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

int main() {
	read(n), read(m);
	for (R int i = 1; i <= n; ++i) {
		scanf("%s", s + 1);
		for (R int j = 1; j <= m; ++j)
			if (s[j] == '.') lin[i - 1] |= 1 << j >> 1, col[j - 1] |= 1 << i >> 1;
	}
	for (R int i = 0; i <= max(n, m); ++i) {
		comb[i][0] = icomb[i][0] = 1;
		for (R int j = 1; j <= i; ++j) {
			comb[i][j] = addMod(comb[i - 1][j - 1], comb[i - 1][j]);
			icomb[i][j] = quickpow(comb[i][j], mod - 2);
		}
	}
	int ans = 1 << n;
	for (R int i = 1; i <= n; ++i)
		g[i][m][1] = comb[n][i] * (1ll << (n - i)) % mod;
	for (R int i = n; i; --i)
		for (R int j = m; j; --j) {
			for (R int u = i - 1; u; --u) {
				g[u][j][0] = (g[u][j][0] + (2ll * f[i][j][1] + f[i][j][0]) * comb[i][u]) % mod;
				g[u][j][1] = (g[u][j][1] + ((1ll << (i - u)) - 2) * f[i][j][1] % mod * comb[i][u]) % mod;
			}
			for (R int u = j - 1; u; --u) {
				f[i][u][0] = (f[i][u][0] + (2ll * g[i][j][1] + g[i][j][0]) * comb[j][u]) % mod;
				f[i][u][1] = (f[i][u][1] + ((1ll << (j - u)) - 2) * g[i][j][1] % mod * comb[j][u]) % mod;
			}
			ans = (ans + ((1ll << i) - 2) * f[i][j][1] + ((1ll << j) - 2) * g[i][j][1]) % mod;
			f[i][j][1] = ((ll) f[i][j][0] + f[i][j][1] + g[i][j][0] + g[i][j][1]) * icomb[n][i] % mod * icomb[m][j] % mod;
			
		}
	for (R int i = 1; i < 1 << n; ++i)
		for (R int j = 1; j < 1 << m; ++j) {
			int flag = 1, ci = 0, cj = 0;
			for (R int u = 0, w; flag && u < n; ++u)
				if (i & (1 << u))
					++ci, w = lin[u] & j, flag &= (w != j) && (w != 0);
			for (R int u = 0, w; flag && u < m; ++u)
				if (j & (1 << u))
					++cj, w = col[u] & i, flag &= (w != i) && (w != 0);
			if (flag) ans = addMod(ans, f[ci][cj][1]);
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
inline bool can(int i, int j, int h, int w){
    return i >=0 and j >= 0 and i < h and j < w;
}
#define inf 0x3f3f3f3f
main(){
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int h, w, ans = 0;
    cin >> h >> w;
    int maze[h][w], dist[h][w];
    rep(i,0 , h){
        rep(j, 0, w){
            char x;
            cin >> x;
            maze[i][j] = x == '.';
        }
    }
    rep (i, 0, h){
        rep(j, 0, w){
            if (maze[i][j]){
                rep(k, 0, h) rep(l, 0, w) dist[k][l] = inf;
                queue<pii> q; q.push({i,j}); dist[i][j] = 0;
                while(!q.empty()){
                    pii f = q.front(); q.pop();
                    int i = f.first;
                    int j = f.second;
                    
                    if (can(i+1,j,h,w) and dist[i+1][j] == inf and maze[i+1][j]){
                        dist[i+1][j] = dist[i][j] + 1;
                        q.push({i+1, j});
                    }
                    if (can(i-1,j,h,w) and dist[i-1][j] == inf and maze[i-1][j]){
                        dist[i-1][j] = dist[i][j] + 1;
                        q.push({i-1, j});
                    }
                    if (can(i,j+1,h,w) and dist[i][j+1] == inf and maze[i][j + 1]){
                        dist[i][j+1] = dist[i][j] + 1;
                        q.push({i, j+1});
                    }
                    if (can(i,j-1,h,w) and dist[i][j-1] == inf and maze[i][j - 1]){
                        dist[i][j-1] = dist[i][j] + 1;
                        q.push({i, j-1});
                    }
                }
                rep(k, 0, h) rep(l, 0, w) {
                    if (maze[k][l]) ans = max(ans, dist[k][l]);
                }
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int H, W;
    char c[2] = {'#', '.'};
    while(true) {
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; ++i) {
            for(int j = 0; j < W; ++j) {
                cout << c[(i+j)%2];
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>

int main(void){
  int i,m,n,first,year,flg,dec,rst,max,sum;
  double per;

  scanf("%d",&m);
  while(m--){
    scanf("%d%d%d",&first,&year,&n);
    max = 0;
    while(n--){
      scanf("%d%lf%d",&flg,&per,&dec);
      rst = first;
      for(i=sum=0;i<year;i++){
	if(flg){
	  rst = rst + (int)(rst*per) - dec;
	}
	else{
	  sum += (int)(rst*per);
	  rst = rst - dec;
	}
      }
      if(!flg) rst+=sum;
      if(rst > max) max=rst;
    }
    printf("%d\n",max);
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N;
    cin >> N;
    vll data(N);
    for (int i = 0; i < N; i++) {
        cin >> data.at(i);
    }
    int ans = 0, sum = 0;
    for (int i = 0; i < N - 1; i++) {
        if (data.at(i) >= data.at(i + 1)) {
            sum++;
        }
        if (data.at(i) < data.at(i + 1) || i == N - 2) {
            ans = max(ans, sum);
            sum = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = (1<<30);

struct SegT
{
  vector<int> tree;
  int n;
 
  SegT(int n_)
  {
    n = 1;
    while( n < n_ ) n <<= 1;
    tree = vector<int>(2 * n - 1, 0);
  }
  int rmq(int a, int b, int k, int l, int r)
  {
    if( a >= r || b <= l ) return 0;
    if( a <= l && r <= b ) return tree[k];
    return(max(rmq(a, b, 2 * k + 1, l, (l + r) >> 1),
               rmq(a, b, 2 * k + 2, (l + r) >> 1, r)));
  }
  int rmq(int a, int b)
  {
    return (rmq(a, b, 0, 0, n));
  }
  int update(int k, int x)
  {
    k += n - 1;
    tree[k] = x;
    while( k > 0 ) {
      k = (k - 1) >> 1;
      tree[k] = max(tree[2 * k + 1], tree[2 * k + 2]);
    }
  }
};

main() {
  int n;
  cin >> n;
  SegT tree( n+1 );

  Rep(i, n) {
    int x;
    cin >> x;
    tree.update(x, tree.rmq(1, x) + x);
  }

  cout << n * (n+1) / 2 - tree.rmq(1, n+1) << endl;
}

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

vector<int>a,b,c;

//#define SIZE 100000

int n;

vector<int>dp[3];

int rec(int idx,int activity)
{
    int x,y,z;
    if(idx==n)
        return 0;
    if(dp[activity][idx]!=-1)
        return dp[activity][idx];
    if(activity==0)
    {
        y=a[idx]+rec(idx+1,1);
        z=a[idx]+rec(idx+1,2);
        return dp[0][idx]=max(y,z);
    }
    else if(activity==1)
    {
        x=b[idx]+rec(idx+1,0);
        z=b[idx]+rec(idx+1,2);
        return dp[1][idx]=max(x,z);
    }
    else if(activity==2)
    {
        x=c[idx]+rec(idx+1,0);
        y=c[idx]+rec(idx+1,1);
        return dp[2][idx]=max(x,y);
    }
}

int main()
{
    cin>>n;
    int i;
    for(i=0;i<n;i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        a.push_back(x);
        b.push_back(y);
        c.push_back(z);
    }
    for(i=0;i<n;i++)
    {
        dp[0].push_back(-1);
        dp[1].push_back(-1);
        dp[2].push_back(-1);
    }
    int x,y,z;
    x=rec(0,0);
    y=rec(0,1);
    z=rec(0,2);
    int max;
    max=x>y?x:y;
    max=max>z?max:z;
    cout<<max;//<<"\n";
    /*for(i=0;i<n;i++)
    {
        cout<<"activity 1 -> "<<dp[0][i]<<"\n";
        cout<<"activity 2 -> "<<dp[1][i]<<"\n";
        cout<<"activity 3 -> "<<dp[2][i]<<"\n";
    }*/
    return 0;
}


Measured memory_bytes: 7404
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
signed main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<=k)cout<<x*n<<endl;
    else cout<<x*k+y*(n-k)<<endl;
    return 0;
}


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

/* 繰り返し自乗法. */
int modPow(long long a, long long n, long long p) {
	if (n == 0) return 1; // 0乗にも対応する場合.
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

signed main() {
    int N, K;
    cin >> N >> K;

    vector<int> P(N);
    rep (i, N) cin >> P[i];
    sort(P.begin(), P.end());

    ll sum = 0;
    rep (i, K) {
        sum += P[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 3624
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, c;
    scan(n, c);
    auto d = iota(c).map!(i => readln.split.to!(int[])).array;
    auto ban = iota(n).map!(i => readln.split.to!(int[])).array;

    auto cnt = new int[][](3, c);
    auto z = new int[](3);

    foreach (i ; 0 .. n) {
        foreach (j ; 0 .. n) {
            cnt[(i + j) % 3][ban[i][j] - 1]++;
            z[(i + j) % 3]++;
        }
    }

    long ans = inf6;

    foreach (i ; 0 .. c) {
        foreach (j ; 0 .. c) {
            foreach (k ; 0 .. c) {
                if (i == j || j == k || i == k) continue;

                long t;

                foreach (x ; 0 .. c) {
                    t += 1L * cnt[0][x] * d[x][i];
                    t += 1L * cnt[1][x] * d[x][j];
                    t += 1L * cnt[2][x] * d[x][k];
                }

                ans = min(t, ans);
            }
        }
    }

    writeln(ans);
}









void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 8572
import java.util.Scanner;

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

		for(int i = 0; i < M ; i++) {
			ave[sc.nextInt() - 1]++;
			ave[sc.nextInt() - 1]++;
		}
		for(int i = 0; i < ave.length; i++) {
			System.out.println(ave[i]);
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b>>c>>d;
    rep(i,ohara){
        if(a<=i&&i<=b&&c<=i&&i<=d)ans++;
    }
    ans=max(ans-1,0LL);
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <tuple>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

class UnionFind {
public:
    vector<int> par;
    vector<int> rnk;
    vector<int> sze;

    UnionFind(ll n): par(n), rnk(n, 0), sze(n, 1) {
        for (ll i = 0; i < n; ++i) par[i] = i;
    }

    void init(int n) {
        for (int i = 0; i < n; i++) {
            par.resize(n);
            rnk.assign(n, 0);
            sze.assign(n, 1);
        }
    }

    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return 0;
        if (rnk[x] < rnk[y]) {
            sze[y] = sze[x] + sze[y];
            par[x] = y;
        }
        else {
            sze[x] = sze[x] + sze[y];
            par[y] = x;
            if (rnk[x] == rnk[y]) rnk[x]++;
        }
        return 1;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    bool size(int x) {
        return sze[find(x)];
    }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;

    UnionFind uf(n);
    vector<vector<int>> fri(n), block(n);
    for (int i = 0; i < n; i++) {
        fri.push_back(vector<int> {});
        block.push_back(vector<int> {});
    }

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        fri[a].push_back(b);
        fri[b].push_back(a);
        uf.unite(a, b);
    }
    for (int i = 0; i < k; i++) {
        int c, d;
        cin >> c >> d;
        c--;  d--;
        block[c].push_back(d);
        block[d].push_back(c);
    }

    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        int cnt = uf.sze[uf.find(i)] - 1;
        for (auto &j : fri[i]) {
            cnt -= uf.same(i, j);
        }
        for (auto &j : block[i]) {
            cnt -= uf.same(i, j);
        }
        cout << cnt;
    }
    cout << endl;
}

Measured memory_bytes: 17712
#include<iostream>
#include<map>
#include<vector>
#define ll long long
using namespace std;
map< pair<int, int>, int> mp;
int h, w;
int n;
int a, b;
ll ans[10];
int main()
{
	ios::sync_with_stdio(false);
	cin >> h >> w >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a >> b;
		for (int i = a - 2; i <= a; i++)
			for (int j = b - 2; j <= b; j++)
				if (i > 0 && j > 0 && i + 2 <= h && j + 2 <= w)
					mp[make_pair(i, j)]++;
	}
	for (map< pair<int, int>, int>::iterator i = mp.begin(); i != mp.end(); i++)
		ans[i->second]++;
	ans[0] = 1ll * (h - 2) * (w - 2);
	for (int i = 1; i <= 9; i++)
		ans[0] -= ans[i];
	for (int i = 0; i < 10; i++)
		cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 56576
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)
#define mem0(a) memset(a,0,sizeof(a))
#define mem_1(a) memset(a,-1,sizeof(a))
#define mem0x(a) memset(a,0x3f,sizeof(a))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN(a,b) (a)<(b)?(a):(b)
#define INF 0x7f7f7f7f
using namespace std;


typedef long long ll;
//typedef __int64_t i64;
typedef long long unsigned llu;
typedef pair<int,int> P;
typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
const int N = 50001;

//int n,m,q,k,sum=0;

//int cot[N];

ll dp(ll x){
    if(x==1) return 1;
    if(x==2) return 3;
    return 1+dp(x/2)*2;
}
int main(){
    
    ll h;
    
    cin>>h;
    printf("%lld\n",dp(h));
    
    return 0;
}


Measured memory_bytes: 256
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    ll n,m,q;cin >> n >> m >> q;
    vector<vector<ll>> train(n);
    REP(i,m){
        ll l,r;cin >> l >> r;
        train[l-1].PB(r-1);
    }
    REP(i,n){
        sort(ALL(train[i]));
    }
    REP(i,q){
        ll p,q_;cin >> p >> q_;
        ll ans=0;
        FOR(j,p-1,q_-1){
            ans+=ll(upper_bound(ALL(train[j]),q_-1)-train[j].begin());
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

using lint = long long;

int main() {

    int N;
    lint L;
    std::cin >> L >> N;
    std::vector<lint> X(N);
    rep (i, N) std::cin >> X[i];

    lint answer = 0;
    rep (never, 2) {
        std::vector<lint> trees = X, sums(N + 1);
        trees.emplace_back(L);
        rep (i, N) {
            trees.emplace_back(X[i] + L);
            sums[i + 1] = sums[i] + (trees[N + i + 1] - trees[N + i]) * (N - i) * 2;
        }
        lint left = 0, right = 0;
        for (int i = 0, k = N; k > 0; ++i, k -= 2) {
            right += (trees[N + i + 1] - trees[N + i]) * k;
        }
        for (int i = -1, k = N - 1; k > 0; --i, k -= 2) {
            left += (trees[N + i + 1] - trees[N + i]) * k;
        }
        chmax(answer, left + right);
        for (int l = N - N / 2, r = 2, step = N - 1; step > 0; --step, ++r) {
            left -= trees[N] - trees[l];
            right = (trees[N + r] - trees[N]) * step;
            int tr = r + (step - 1) / 2;
            right += (sums[tr] - sums[r]) - (trees[N + tr] - trees[N + r]) * step;
            chmax(answer, left + right);
            if (step % 2 == 1) ++l; 
        }
        rep (i, N) {
            X[i] = L - X[i];
        }
        std::reverse(all(X));
    }
    std::cout << answer << '\n';
    return 0;

}


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

using namespace std;

int main(void) {
    string s;
    cin >> s;
    int size = s.size();
    if(s.at(size - 1) == 's'){
        cout << s + "es" << endl;
    }
    else{
        cout << s + "s" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll a[maxn],b[maxn],p[maxn],n;

int main()
{
	n=read(); rep(i,1,n) p[i]=read();
	rep(i,1,n) a[i]=i*20001,b[i]=(n-i+1)*20001;
	rep(i,1,n) a[p[i]]+=i;
	rep(i,1,n) printf("%lld ",a[i]); puts("");
	rep(i,1,n) printf("%lld ",b[i]); puts("");
	return 0;
}

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

int main(){
	int H , W ;

	while(1){
		cin >> H >> W;
		if ( H == 0 && W == 0  ) break;

		for ( int i = 0; i < H ; i++){
			for ( int j = 0; j < W; j++){
				if ( i == 0 || i == H-1 || j == 0 ||j == W-1){
					cout << "#";
				} else {
					cout << ".";
				}
			}
			cout << "\n";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3036
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n) {int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
//is(string &s) {int c;for(;;){c=gcu();if(c=='\n'||c==' ')return true;s+=c;}}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
template <typename T>
void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

int main() {
	int gems, g;
	while ((gems = g = in())) {
		vector<vector<int>> map(21, vector<int>(21));
		while (g--) {
			int x = in(), y = in();
			map[y][x] = true;
		}
		int operations = in(), x = 10, y = 10;
		while (operations--) {
			int dx = 0, dy = 0;
			switch (gcu()) {
			case 'N' : dy = 1;  break;
			case 'S' : dy = -1; break;
			case 'E' : dx = 1;  break;
			default  : dx = -1; break;
			}
			gcu();
			for (int i = in(); i > 0; i--) {
				x += dx; y += dy;
				if (map[y][x]) {
					map[y][x] = false;
					gems--;
				}
			}
		}
		out(gems ? "No" : "Yes", '\n');
	}
}


Measured memory_bytes: 2600
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n, k;

	cin >> n >> k;

	cout << n - k + 1 << endl;
}

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

using namespace std;

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

  int n;
  double d;
  cin >> n >> d;

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    long double x, y;
    cin >> x >> y;
    long double dist = sqrt(x * x + y * y);
    if (dist <= d) {
      ++cnt;
    }
  }

  cout << cnt << '\n';

  return 0;
}

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

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

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

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

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

  int ans = 0;
  for (int i = 0; i < 2 * n; i += 2) ans += v[i];

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

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  string s;
  cin >> s;
  for(int i=1;i<s.size();i++){
    if(s[i-1]==s[i]){
      cout << "Bad\n";
      return 0;
    }
  }
  cout <<"Good\n";
}


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

int main(int argc, char const *argv[]) {
    long long a;
    double b;
    cin >> a >> b;
    int b_multi = b * 100 + 0.5;
    //cout << b_multi << endl;

    unsigned long long res = a*b_multi/100;
    cout << res << endl;
    return 0;
}


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

int D, G, p[102], c[102], dp[11][10005], no_q, maxi;
int main() {
	scanf("%d %d", &D, &G);
	for (int i = 1; i <= D; i++) {
		scanf("%d %d", &p[i], &c[i]);
		no_q += p[i];
	}
	for (int i = 1; i <= D; i++) {
		for (int j = 1; j <= no_q; j++){
			maxi = dp[i-1][j];
			for (int k = 1; k <= p[i] && k <= j; k++){
				maxi = max(maxi, dp[i-1][j-k] + k*i*100);
				if (k == p[i]){
					maxi = max(maxi, dp[i-1][j-k] + k*i*100 + c[i]);
				}
			}
			dp[i][j] = maxi;
		}
	}
	for (int i = 1; i <= no_q; i++){
		if (dp[D][i] >= G){
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
using namespace std;
const int MOD=100000;
int di[100000];
int abs(int a){
    if(a<0) return -a;
    else return a;
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    di[0]=0;
    for(int i=0;i<n-1;i++){
        scanf("%d",&di[i+1]);
        di[i+1]+=di[i];
    }
    int now=0,ret=0,a;
    for(int i=0;i<m;i++){
        scanf("%d",&a);
        ret+=abs(di[now+a]-di[now]);
        ret%=MOD;
        now+=a;
    }
    printf("%d\n",ret);
}

Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb                 push_back
#define bug(x)             cerr<<#x<<" "<<x<<endl;
#define T int time;        scanf("%d", &time); while(time--)
    vector<ll>ar;
  bool check(ll i,ll n){
    if(abs(i-n)<=1)return true;
    for(ll ii=n-1; ii>i; ii--)if(ar[ii]<ar[ii-1])
      cout<<ar[ii]<<" ";
    cout<<endl;
    return true;
  }

   int main(){
      ll n,k;
      cin>>n>>k;
      ll ar[n+5];
      for(ll i=0; i<n; i++)cin>>ar[i];
      sort(ar,ar+n);
    ll sum=0;
    for(ll i=0; i<n-k; i++)sum+=ar[i];
      cout<<sum<<endl;

     }
   

Measured memory_bytes: 5088
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int x = sc.nextInt();
        int min = Integer.MAX_VALUE;
        
        for(int i = 0; i < n; i++) {
          int value = sc.nextInt();
          x -= value;
          if (value < min) {
            min = value;
          }
        }
        int ans = n;
    
		// 出力
		System.out.println(n + (int)Math.floor(x / min));
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<bool >    vecbool;
typedef vector<string > vecstr;
int main()
{
  string s; cin >> s;
  int n; cin >> n;
  vecint job(n,0);
  vector<char > vc;
  vector<int > vp, vr;
  string shead, stail;
  // ans = shead + s + stail
  char ctmp;
  int itmp;
  int rev = 0;
  REP(i,n){
    cin >> job[i];
    if(job[i] == 1){
      rev ++;
    }else if(job[i] == 2){
      cin >> itmp >> ctmp;
      vr.push_back(rev);
      vc.push_back(ctmp);
      vp.push_back(itmp);
    }
  }
  REP(i,vr.size()){
    if((vp[i] == 1&& (rev - vr[i])%2 ==0)||(vp[i] == 2&& (rev - vr[i])%2 != 0)){
      shead = vc[i] + shead;
    }else{
      stail = stail + vc[i];
    }
  }
  if(rev %2 != 0){
    reverse(s.begin(), s.end());
  }
  cout << shead + s + stail  << endl;
}


Measured memory_bytes: 4076
N,Q=map(int, input().split())
s=input()
S=len(s)
A=[]
for i in range(Q):
  x,y=input().split()
  A.append((x,y))
  
if N==1:
  for x,y in A:
    if s[0]==x:
      print(0)
      exit()
  print(1)
  exit()
  
def L(d):
  for x,y in A:
    if s[d]==x and y=='L':
      d-=1    
    if s[d]==x and y=='R':
      d+=1
    if d<0:
      return False
    elif d==S:
      d-=1
  return True

ok,ng=S,-1
mid=(ok+ng)//2
while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if L(mid):
    ok=mid
  else:
    ng=mid
p=ok
if ok==S:
  print(0)
  exit()

def R(d):
  for x,y in A:
    if s[d]==x and y=='L':
      d-=1    
    if s[d]==x and y=='R':
      d+=1
    if d>=S:
      return False
    elif d<0:
      d+=1
  return True

ok,ng=-1,S
mid=(ok+ng)//2
while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if R(mid):
    ok=mid
  else:
    ng=mid
q=ok

print(q-p+1)


Measured memory_bytes: 23596