akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define DEBUG 1

int max(int a,int b){
	return a>=b ? a:b;
}

int main(){

	int n;
	int *a;

	int ans[100010];

	cin>>n;

	a = new int[n];

	for(int i=0;i<100010;i++){
		ans[i]=0;
	}

	for(int i=0;i<n;i++){
		int tmp;
		cin>>tmp;
		for(int j=tmp-1;j<=tmp+1;j++){
			if(j<0)continue;
			ans[j]++;
		}
	}

	int num=0;

	for(int i=0;i<100010;i++){
		num = max(num,ans[i]);
	}

	cout<<num<<endl;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
	int h,w,i,j;
	while(1){
		scanf("%d %d\n",&h,&w);
		if(h==0 && w==0)	break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2048
#include <iostream>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    string n;
    int num;
    cin >> n;
    num=n.size();
    if(n[num-1]=='2' || n[num-1]=='4' || n[num-1]=='5' || n[num-1]=='7' || n[num-1]=='9'){
        cout << "hon" << endl;
    }else if(n[num-1]=='0' || n[num-1]=='1' || n[num-1]=='6' || n[num-1]=='8'){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Aug  2 21:24:51 JST 2020
 **/

template <class T> bool chmin(T& a, const T& b) { return a > b ? a = b, true : false; }
template <class T> bool chmax(T& a, const T& b) { return a < b ? a = b, true : false; }

signed main() {
    Int n;
    std::string s;
    std::cin >> n >> s;
    Int r = std::count(ALL(s), 'R');
    Int cur_w = 0;
    Int ans = 1e9;
    REP(i, n + 1) {
        Int cur_r = r - (i - cur_w);
        chmin(ans, std::max(cur_w, cur_r));
        cur_w += s[i] == 'W';
    }
    std::cout << ans << std::endl;
}


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

int sum(int n) {
  int s = 0, m;
  s += n / 10000;
  m = n % 10000;
  s += m / 1000;
  m = m % 1000;
  s += m / 100;
  m = m % 100;
  s += m / 10;
  m = m % 10;
  s += m;
  return s;
}

int main() {
  int n, a, b, ans = 0;
  cin >> n >> a >> b;

  for (int i = 1; i <= n; i++) {
    if (sum(i) >= a && sum(i) <= b) ans += i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define len 100005
int head,tail;

typedef struct {
  int time;
  char name[100];
}P;

P Q[len];
int head,tail;

void enquece(P x){
  Q[tail]= x;
  tail = (tail+1)%len;
}
P dequece(){
  P x = Q[head];
  head = (head+1)%len;
  return x;
}
int min(int a,int b){
  return a<b? a:b;
}

int main(void){
  int n,q;
  scanf("%d %d",&n,&q);
  head =1;
  tail= n+1;
  P pro;
  for (int i = 1; i <= n; i++) {
    scanf("%s",Q[i].name );
    scanf("%d",&Q[i].time );
  }

int c;//処理時間
int elaps=0;// 経過時間
// For simulation
 while(head!=tail){
   pro = dequece();
  c= min(q,pro.time);
  elaps+=c;
  pro.time-=c;
  if (pro.time>0) {
    enquece(pro);
  }else{
    printf("%s %d\n",pro.name,elaps );
  }
}

return 0;


  }


Measured memory_bytes: 11888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
 
int main() {
  ll N , A , B ;
  cin >> N >> A >> B ;
  if( (B-A)%2 == 0 ){
    cout << (B-A)/2 << endl ;
    return 0 ;
  }
  ll a = min(A-1,B-1) ;
  ll b = min(N-A,N-B) ;
  cout << min(A+(B-A)/2,(N-B)+1+(B-A-1)/2) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

const double kDelta = 100;
const double kRadius = 10;

int main () {
	ios_base::sync_with_stdio(0);
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);

	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int n;
	cin >> n;

	vector<pair<int, int>> pt;
	for (int i = 0; i < n; ++i) {
		int cur_x, cur_y;
		cin >> cur_x >> cur_y;

		if (cur_x >= min(x1, x2) && cur_x <= max(x1, x2) && cur_y >= min(y1, y2) && cur_y <= max(y1, y2)) {
			pt.pb(mp(abs(cur_x - x1), abs(cur_y - y1)));
		}
   	}

   	sort(pt.begin(), pt.end());
   	int x = abs(x2 - x1);
   	int y = abs(y2 - y1);

   	vector<int> last(sz(pt) + 2, inf);
   	last[0] = -inf;
   	for (int i = 0; i < sz(pt); ++i) {
   		int ind = upper_bound(last.begin(), last.end(), pt[i].sc) - last.begin();
   		last[ind] = pt[i].sc;
   	}

   	int num = 0;
   	while (last[num + 1] < inf) {
   		++num;
   	}
   	
   	double res = kDelta * (x + y) + num * (pi / 2 * kRadius - 2 * kRadius);
   	if (num == min(x, y) + 1) {
   		res += pi / 2 * kRadius; 
   	}

   	cout.precision(20);
   	cout << res << endl;

	return 0;
}


Measured memory_bytes: 2672
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,aa[220000],cntl=0,ab[220000];
pair<int,int> p[220000];
string s,ss[220000];
char c,cc[5000][5000]={};
queue<int> que;
signed main(){
    cin>>n>>m;
    if(m==100){
        cnt=101;
        cnt*=pow(100,n);
        cout<<cnt<<endl;
    }else{
        cout<<m*pow(100,n)<<endl;
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;
int main() {
	int n, k; cin >> n >> k;
	vector<int>l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	reverse(l.begin(), l.end());
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += l[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define cst first
#define dur second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

int n, m;
vector<int> idx[N];

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0 ; i < n ; ++i){
        int a, b;
        scanf("%d%d", &a, &b);
        if(a <= m)idx[a].emplace_back(b);
    }
    ll ans = 0;
    priority_queue<int> pq;
    for(int day = 1 ; day <= m ; ++day){
        for(auto j : idx[day])pq.emplace(j);
        if(pq.size())ans += (1LL * pq.top()), pq.pop();
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 5632
#include<iostream>
using namespace std;
int main(void)
{
	int a,b,i;
	cin>>a>>b;
	if(a<=b){
		for(i=0;i<b;i++) cout<<a;
		cout<<endl;
	}
	else{
		for(i=0;i<a;i++) cout<<b;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, m, q = map(int, input().split())

x = [[0]*n for _ in range(n)]

for i in range(m):
  l, r = map(int, input().split())
  l, r = l-1, r-1
  x[l][r] += 1
  
s = [[0]*(n+1) for _ in range(n+1)]
for i in range(n):
  for j in range(n):
    s[i+1][j+1] = s[i+1][j] + s[i][j+1] - s[i][j] + x[i][j]

for _ in range(q):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  print(s[b+1][b+1] - s[b+1][a] - s[a][b+1] + s[a][a])

Measured memory_bytes: 58712
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long
#define N (2005)

using namespace std;

int g[N][N],h[N][N],mx[N],st[N],n,m,ans;

il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar();
  return q*x;
}

il char gc(){
  RG char ch=getchar();
  while (ch!='#' && ch!='.') ch=getchar(); return ch;
}

int main(){
  n=gi(),m=gi(),ans=max(n,m);
  for (RG int i=1;i<=n;++i)
    for (RG int j=1;j<=m;++j) g[i][j]=gc()=='#';
  for (RG int i=1;i<n;++i)
    for (RG int j=1;j<m;++j)
      h[i][j]=g[i][j]^g[i][j+1]^g[i+1][j]^g[i+1][j+1]^1;
  for (RG int i=1,top;i<n;++i){
    top=0;
    for (RG int j=1;j<m;++j) h[i][j]?++mx[j]:mx[j]=0;
    for (RG int j=1;j<=m;++j){
      while (top && mx[st[top]]>=mx[j])
	ans=max(ans,(j-st[top-1])*(mx[st[top]]+1)),--top;
      st[++top]=j;
    }
  }
  cout<<ans; return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;



int main(void) {
	unsigned long long int a[20000], b[20000], tmp;
	int A, X[20000];
	
	cin >> A;

	for (int i = 0; i < A; i++) {
		cin >> X[i];
		X[i]--;
		a[i] = 30000 * (i + 1);
		b[i] = 30000 * (A - (i + 1));
	}

	for (int i = 0; i < A; i++) {
		b[X[i]] += (i + 1);
	}

	for (int i = 0; i < A; i++) {
		printf("%lld", a[i]);
		if (i != A - 1) {
			printf(" ");
		}
	}
	printf("\n");
	for (int i = 0; i < A; i++) {
		printf("%lld", b[i]);
		if (i != A - 1) {
			printf(" ");
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	int s, w;


	cin >> s>>w;
	if (s<=w)
	{
		cout << "unsafe";
	}
	else
	{
		cout << "safe";
	}
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int H, W, K;
int res[300][300];
char c[300][300];
bool b[300];

int main() {
	cin >> H >> W >> K;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> c[i][j];
			if (c[i][j] == '#')b[i] = true;
		}
	}
	for (int i = 0; i < H; i++) {
		if (b[i]) {
			int num = 0;
			for (; i < H; i++) {
				if (b[i]) {
					for (int j = 0; j < W; j++) {
						if (c[i][j] == '#') {
							for (; j < W; j++) {
								if (c[i][j] == '#') {
									num++;
									res[i][j] = num;
								}
								else {
									res[i][j] = num;
								}
							}
						}
					}
					for (int j = W - 2; j >= 0; j--) {
						if (!res[i][j]) {
							res[i][j] = res[i][j + 1];
						}
					}
				}
				else {
					for (int j = 0; j < W; j++) {
						res[i][j] = res[i - 1][j];
					}
				}
			}
			break;
		}
	}
	for (int i = H - 2; i >= 0; i--) {
		for (int j = 0; j < W; j++) {
			if (!res[i][j]) {
				res[i][j] = res[i + 1][j];
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << res[i][j];
			if (j != W - 1)cout << sp;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1152
import math
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    c=[]
    for j in range(i+1,min(n,i+k+1)):
        c.append(abs(a[j]-a[i])+b[j])
    b[i]=min(c)
print(b[0])

Measured memory_bytes: 52448
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(void)
{
    int N, K;
    int i,j,k,l,m;
    int tmp;
    
    
    scanf("%d %d",&N, &K);
    
    int H[N];
    int dif[N-K+1];
    
    for(i=0; i<N; i++){
        scanf("%d",&H[i]);
    }
    
    qsort(H, N, sizeof(int), compare_int);
    
    for(l=0; l<N-K+1; l++){
        dif[l] = H[l] - H[l+K-1];
    }
    
    for(m=0; m<N-K+1; m++){
        if(dif[0] > dif[m]){
            tmp = dif[0];
            dif[0] = dif[m];
            dif[m] = tmp;
        }
    }
    
    printf("%d\n",dif[0]);
    return 0;
}


Measured memory_bytes: 1020
n,m = map(int,input().split())
x = list(map(int,input().split()))

if n >= m :
  print(0)
else:
  y = [0] * (m-1)
  x.sort()
  for i in range(1,m):
    y[i-1] = abs(x[i] - x[i-1])
  y.sort(reverse=True)
  print(sum(y[n-1:]))


Measured memory_bytes: 13964
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    int sum=0;
    int min=1000000;
    rep(i,n){
        if(i==0){
            sum++;
            min=p[i];
        }
        else{
            if(p[i]<=min){
                min=p[i];
                sum++;
                //cout<<"i="<<i<<endl;
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

vector<string> t = { "dream" , "dreamer" ,"erase" ,"eraser" };
string s;

bool compare(int i) {
	//if (i >= s.size()) {
	//	return false;
	//}
	bool flag = false;
	for (int j = 0; j < 4; j++) {
		if (s.size() - i >= t[j].size() &&
			std::equal(std::begin(t[j]), std::end(t[j]), std::begin(s) + i)) {
			if (compare(i + t[j].size())) {
				flag = true;
			}
		}
	}
	if (i == s.size()) {
		return true;
	}

	return flag;
}

int main() {
	cin >> s;
	int length = s.size();

	bool flag = compare(0);


	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define LLI long long int
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 0
using namespace std;

int main()
{
    int i,j;
    int N;

    scanf("%d", &N);

    LLI ans = 0;
    for( i=1; i<=N; i++)
    {
        if( i % 3 != 0 && i % 5 != 0)
        {
            de(1) printf(">>> %d\n", i);
            ans += i;
        }

    }

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

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  int a[n];
  set<int> s;
  set<int> c;
  rep(i,n){
    int u;
    cin >> u;
    a[i]=u;
    if(s.count(u))c.insert(u);
    s.insert(u);
  }
  int ans=0;
  if(s.count(1)){
    if(c.count(1)){
      cout << 0 << endl;
    }
    else{
      cout << 1 << endl;
    }
    return 0;
  }
  rep(i,n){
    int v=0;
    int o=a[i];
    if(c.count(o)||s.count(1))continue;
    rep(j,1000){
      if(j+2==o)continue;
      if(o%(j+2)==0){
        if(s.count(j+2)||s.count(o/(j+2))){
          v++;
          break;
        }
      }
    }
    if(v==0)ans++;
  }
  cout << ans << endl;
}   


Measured memory_bytes: 13708
use std::io;

fn main() {
    // 一行目を取得、分割
    let mut one_line_buffer = String::new();

    io::stdin().read_line(&mut one_line_buffer).unwrap();
    let one_line_vec: Vec<i64> = one_line_buffer
        .trim()
        .split_whitespace()
        .map(|c| c.parse().unwrap())
        .collect();

    let lake_circumference: i64 = one_line_vec[0];
    let house_num: usize = one_line_vec[1] as usize;

    // 二行目を取得、分割
    let mut two_line_buffer = String::new();
    io::stdin().read_line(&mut two_line_buffer).unwrap();

    let house_distances_from_north: Vec<i64> = two_line_buffer
        .trim()
        .split_whitespace()
        .map(|c| c.parse().unwrap())
        .collect();

    // for i in &house_distances_from_north {
    //     println!("{}", i);
    // }

    // 隣の家間の距離を計算
    let mut house_distances_from_previous: Vec<i64> = vec![];

    house_distances_from_previous.push(
        house_distances_from_north[0]
            + (lake_circumference - house_distances_from_north[house_num - 1]),
    );

    // 家間の最大距離とそのindex
    let mut max_distance: i64 = house_distances_from_previous[0];

    // println!("0: {}", house_distances_from_previous[0]);

    for i in 1..house_num {
        house_distances_from_previous
            .push(house_distances_from_north[i] - house_distances_from_north[i - 1]);

        if house_distances_from_previous[i] > max_distance {
            max_distance = house_distances_from_previous[i];
        }

        // println!("{}: {}", i, house_distances_from_previous[i]);
    }

    let mut distance_sum: i64 = 0;

    for i in house_distances_from_previous {
        distance_sum += i;
    }

    println!("{}", distance_sum - max_distance);
}


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

using namespace std;

int main() {
    string S;
    cin >> S;

    int cnt0 = 0;
    int cnt1 = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '1') cnt1++;
        else cnt0++;
    }
    int res = S.size() - abs(cnt0 - cnt1);
    cout << res << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;
    vector<Monoid> data;
    int n;
    const F f;
    const Monoid M;
    SegmentTree(int x, const F f, const Monoid &M) : f(f), M(M) {
        n = 1;
        while(n<x) n <<= 1;
        data.resize(2*n,M);
    }
    void set(int k, const Monoid &p) {
        data[k+n] = p;
    }
    void build() {
        for(int k = n-1; k > 0; --k) {
            data[k] = f(data[2*k + 0], data[2*k + 1]);
        }
    }
    void update(int k, const Monoid &p) {
        k += n;
        data[k] = p;
        while (k >>= 1) {
            data[k] = f(data[k*2], data[k*2 + 1]);
        }
    }
    Monoid query(int a, int b) {
        Monoid L = M, R = M;
        for(a += n, b += n; a<b; a >>= 1, b >>= 1) {
            if(a&1) L = f(L, data[a++]);
            if(b&1) R = f(data[--b], R);
        }
        return f(L,R);
    }
    Monoid operator[](const int &k) const {
        return data[k+n];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<int> p(n), x(n);
    SegmentTree<int> segmin(n, [](int a,int b){return min(a,b);}, INT_MAX);
    SegmentTree<int> segmax(n, [](int a,int b){return max(a,b);}, INT_MIN);
    REP(i,n) {
        cin >> p[i];
        segmin.update(i,p[i]);
        segmax.update(i,p[i]);
    }
    vector<int> cnt(n);
    REP(i,n-1) {
        cnt[i+1] = cnt[i] + (p[i]>p[i+1]);
    }
    int ans = 1;
    int s = (cnt[k-1]-cnt[0]>0);
    REP(i,n-k) {
        int x = segmin.query(i,i+k+1);
        int y = segmax.query(i,i+k+1);
        if((s || cnt[i+k]-cnt[i+1]>0) && (p[i]!=x || p[i+k]!=y)) {
            if(cnt[i+k]-cnt[i+1]==0) s = 0;
            ++ ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}

void solve(){
    int n;
    cin >> n;
    cout << n * n;
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;

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

	cin >> N;
	cout << N / 500 * 1000 + (N % 500) / 5 * 5 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    string ss, t, s = ""; cin >> ss >> t;
    rep(i, ss.length()){
        if(i+t.length() > ss.length()) break;
        string tmp = ss.substr(i, t.length());
        bool ok = true;
        rep(j, t.length()){
            if(tmp[j] == '?') continue;
            if(tmp[j] != t[j]){
                ok = false;
                break;
            }
        }
        if(ok){
            s = ss.substr(0, i);
            s += t;
            s += ss.substr(i+t.length());
        }
    }
    if(s == ""){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    rep(i, s.length()){
        if(s[i] == '?') s[i] = 'a';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
char s[10];
void query(int x,int y)
{
    printf("? %d %d\n",x,y);
    fflush(stdout);
    scanf("%s",s);
}
int a,b;
int st[4010];
int top;
int ans[4010];
int main()
{
    cin>>a>>b;
    if(a<=b)
    {
        puts("Impossible");
        return 0;
    }
    st[++top]=0;
    for(int i=1;i<a+b;i++)
    {
        if(!top)   st[++top]=i;
        else{
            query(st[top],i);
            if(s[0]=='Y')  st[++top]=i;
            else           top--;          
        }
    }
    int p=st[top];
    for(int i=0;i<a+b;i++)
    {
        query(p,i);
        if(s[0]=='Y')  ans[i]=1;
        else           ans[i]=0;
    }
    printf("! ");
    for(int i=0;i<a+b;i++)  printf("%d",ans[i]);
    puts("");
    return 0;
}

Measured memory_bytes: 724
from itertools import accumulate

N, K = map(int, input().split())
A = list(map(int, input().split()))
for _ in range(min(K, 100)):
    tmp = [0]*N
    for i, ai in enumerate(A):
        tmp[max(0, i-ai)] += 1
        if i+ai+1 < N:
            tmp[i+ai+1] -= 1
    A = accumulate(tmp)
print(*A)


Measured memory_bytes: 175704
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, l, sum int
	fmt.Scan(&n, &l)
	for i := 0; i < n; i++ {
		sum += i + l
	}

	closeSum := sum
	absSum := math.Abs(float64(sum))
	curDiff := absSum
	for i := 0; i < n; i++ {
		diff := math.Abs(absSum - math.Abs(float64(sum-l-i)))
		if diff < curDiff {
			closeSum = sum - l - i
			curDiff = diff
		}
	}
	fmt.Println(closeSum)
}


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

int main(){
  string S;
  cin >> S;
  bool f = "01" <= S.substr(0,2) && S.substr(0,2) <="12";
  bool g = "01" <= S.substr(2,2) && S.substr(2,2) <="12";
  
  if(f && g) {
    cout << "AMBIGUOUS" << endl;
  } else if(f) {cout << "MMYY" << endl;
  } else if(g) {cout << "YYMM" << endl;
  } else cout << "NA" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    ll ans = 0;

    cin >> n;

    for (int i = 1; i <= n; i++)
    {
        if (i % 3 == 0 || i % 5 == 0)
        {
        }
        else
        {
            ans += i;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 2e5 + 9;
const ll inf = 1e6 + 7;
typedef pair<ll,ll> LL;

string s;
ll n,i,dp[3][N];
bool chk(ll pos){
    string p = s.substr(pos,2),q = s.substr(pos - 2,2);
    return (p != q);
}
ll f(ll past,ll pos){
    if (pos > n) return 0;
    if (dp[past][pos] != -1) return dp[past][pos];
    ll ans = 0;
    if (past == 1){
        if (n - pos + 1 > 1) ans = max(ans,1 + f(2,pos + 2));
        if (s[pos] != s[pos - 1]) ans = max(ans,1 + f(1,pos + 1));
    }
    else{
        ans = max(ans,1 + f(1,pos + 1));
        if (n - pos + 1 > 1&&chk(pos)) ans = max(ans,1 + f(2,pos + 2));
    }
    return dp[past][pos] = ans;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    cin>>s; n = s.size(); s = " " + s;
    memset(dp,-1,sizeof(dp));
    cout<<max(f(1,2),f(2,3)) + 1;
}


Measured memory_bytes: 11472
#include<stdio.h>
int main(){
    int g,e;
    int year;
    char c;
    scanf("%d %d",&g,&e);
    if(g==0){
        if(e>1988){
            year=e-1988;
            c='H';
        }else if(e>1925){
            year=e-1925;
            c='S';
        }else if(e>1911){
            year=e-1911;
            c='T';
        }else{
            year=e-1867;
            c='M';
        }
        printf("%c%d\n",c,year);
    }else if(g==1){
        year=e+1867;
        printf("%d\n",year);
    }else if(g==2){
        year=e+1911;
        printf("%d\n",year);
    }else if(g==3){
        year=e+1925;
        printf("%d\n",year);
    }else{
        year=e+1988;
        printf("%d\n",year);
    }
    return 0;
}


Measured memory_bytes: 2768
#include <cstdlib>
#include <iostream>
#include <string>


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

  std::string s;
  std::cin >> s;
  std::string answer = s;
  decltype(s)::size_type j = 0;
  for (decltype(j) i = 0; i < s.length(); i++) {
    if (s[i] != 'B') {
      answer[j++] = s[i];
    } else if (j > 0) {
      answer[--j] = '\0';
    }
  }
  answer[j] = '\0';
  std::cout << answer.c_str() << std::endl;

  return EXIT_SUCCESS;
}


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

ll dp[101][100001];
ll dfs(vector<pair<ll,ll>>& arr,ll index,ll w)
{
  if(w==0)
    return 0;
  if(index>=arr.size())
    return 0;
  if(dp[index][w]!=-1)
    return dp[index][w];
  
  if(arr[index].first<=w)
    return dp[index][w] = max(arr[index].second+dfs(arr,index+1,w-arr[index].first),dfs(arr,index+1,w));
  else
    return dp[index][w] = dfs(arr,index+1,w);
    
  
}

int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,w;
  cin>>n>>w;
  vector<pair<ll,ll>> arr;
  for(ll i=0;i<n;i++)
  {
    int a,b;
    cin>>a>>b;
    arr.push_back({a,b});
  }
  memset(dp,-1,sizeof(dp));
  ll ans = dfs(arr,0,w);
  cout<<ans<<endl;
    
}

Measured memory_bytes: 82504
n, m = map(int,input().split())
L = []
ans, cnt = 0, 0
for i in range(n):
  ab = list(map(int,input().split()))
  L.append(ab)
L.sort()
for j in range(n):
  if m-cnt>L[j][1]:
    cnt+=L[j][1]
    ans+=L[j][0]*L[j][1]
  else:
    ans+=L[j][0]*(m-cnt)
    break
print(ans)

Measured memory_bytes: 27760
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	bs := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i], &bs[i])
	}

	var cnt int
	for i := 0; i < n; i++ {
		if as[i] == bs[i] {
			cnt++
		} else {
			cnt = 0
		}
		if cnt == 3 {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 1772
#include <iostream>
#include <vector>

using namespace std;

const int INF = (1 << 30);

int main(){
	int N;
	cin >> N;
	vector<vector<int>> vals(N, vector<int>(3, 0));
	vector<vector<int>> dp(N+1, vector<int>(3, 0));
	for(int i =0 ; i < N; i++){
		for(int j = 0; j < 3; j++) cin >> vals[i][j];
	}

	for(int i = 1; i <= N; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if (j != k){
					dp[i][j] = max(dp[i][j], dp[i-1][k] + vals[i-1][j]);
				}
			}
		}
	}

	cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;

	return 0;
}

Measured memory_bytes: 13056
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>
#include<queue>

int main()
{
	int n, x, min = 10000, m;
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &m);
		if (m < min) min = m;
		x -= m;
	}
	printf("%d\n", n + x / min);

	return 0;
}

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

int main(void){
    char c;
    cin>>c;
    if('a'<=c && c<='z') puts("a");
    else if('A'<=c && c<='Z') puts("A");
    return 0;
}

Measured memory_bytes: 3616
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int n, k, q; cin>>n>>k>>q;
    vector<int> point(n, k - q);
    for(int i=0; i<q; i++){
        int a; cin>>a;
        a--;
        point[a]++;
    }

    for(int i=0; i<n; i++){
        cout << (0 < point[i] ? "Yes" : "No") << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll N,M;
ll a,b;
vector<pa> P;
int main(){
    cin >> N >> M;
    ll num = M;
    for(int i = 0; i < N; i++){
        cin >> a >> b;
        P.push_back(pa(a,b));
    }
    sort(P.begin(),P.end());
    ll ans = 0;
    for(int i = 0; i < N; i++){
        if(num <= P[i].second){
            ans += num*P[i].first;
            num = 0;
            break;
        } else {
            ans += P[i].first*P[i].second;
            num -= P[i].second;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 2420
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define ll long long
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()

int main(){
    int n;
    cin >> n;
    int a[n];
    int q;
    rep(i, n) cin >> a[i];
    cin >> q;
    rep(i, q){
        int kind, b, e;
        cin >> kind >> b >> e;
        if(kind == 0){
            int ans = INF;
            for(int k = b; k < e; k++){
                ans = min(ans, a[k]);
            }
            cout << ans << endl;
        }else{
            int ans = -INF;
            for(int k = b; k < e; k++){
                ans = max(ans, a[k]);
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		long maxTypeCount = 0;

		for (int i = 0; i < n; i++) {
			String subStart = s.substring(0, i + 1);
			String subEnd = s.substring(i + 1, n);

			long typeCount = subStart.chars()
					.distinct()
					.filter(subStartChar -> subEnd.chars().anyMatch(m -> subStartChar == m))
					.count();
			maxTypeCount = Math.max(maxTypeCount, typeCount);
		}
		System.out.println(maxTypeCount);
	}
}


Measured memory_bytes: 27220
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
const double pie  =3.141592653589793238463;
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define POP(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(),A.end());
#define REV(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n" 
const ll dx[4] = { -1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
ll XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
ll YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
#define precise(x) cout<<fixed<<setprecision(x)
#define t1(x)                cerr<<#x<<": "<<x<<endl
#define t2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
void SieveOfEratosthenes(ll n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // for (ll p=2; p<=n; p++) 
       // if (prime[p]) 
          // cout << p << " "; 
} 

ll power(ll x, ll y) 
{ 
    ll res = 1; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x * x; 
    } 
    return res; 
}
int main()
{
    // fastio
    ll t,i,j,k,l,m,n,a,x,b,y,z,c,h,d,f,e,p,o,nl,np,q,r,g;
    char ch;
    cin>>x;
    string s="";
    while(x>0)
    {
         x--;
         y=(x%26);
         s+=(char)('a' + y);
         x=x/26;
    }   
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}

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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    long n, a, b;
    cin >> n >> a >> b;
    long groupcnt = n / (a + b);
    long blue = a * groupcnt;
    long restblue = min(n % (a + b), a);
    cout << restblue+blue << endl;
}

Measured memory_bytes: 3612
while True:
    L = map(int,raw_input().split())
    H = (L[0])
    W = (L[1])
    
    if H == 0 and W == 0:break
    
    if W % 2 == 1:
        for x in range(0,H):
            if x % 2 == 0:
                print "{}#".format("#."* (W / 2))
            else:
                print "{}.".format(".#"* (W / 2))
            
    else:
        for x in range(0,H):
            if x % 2 == 0:
                print "#." * (W / 2)
            else:
                print ".#" * (W / 2)
    print ""

Measured memory_bytes: 6340
#include <iostream>

using namespace std;

int main(){
    long A[100][100];
    long B[100][100];
    long C[100][100];
    long sum;
    int n,m,l;
    int i,j,k;
    
    for(i = 0;i < 100;i++){
        for(j = 0;j < 100;j++){
            A[i][j] = 0;
            B[i][j] = 0;
            C[i][j] = 0;
        }
    }
    
    cin >> n >> m >> l;
    
    for(i = 0;i < n;i++){
        for(j = 0;j < m;j++){
            cin >> A[i][j];
        }
    }
    
    for(i = 0;i < m;i++){
        for(j = 0;j < l;j++){
            cin >> B[i][j];
        }
    }
    
    for(i = 0;i < n;i++){
        for(k = 0;k < l;k++){
            sum = 0;
            for(j = 0;j < m;j++){
                sum = sum + A[i][j] * B[j][k];
            }
            C[i][k] = sum;
        }
    }
    
    for(i = 0;i < n;i++){
        for(k = 0;k < l;k++){
            if(k == l - 1){
                cout << C[i][k];
            }else{
                cout << C[i][k] << ' ';
            }
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3348
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double find_count(int a, int b) {
    double count =0;
    while (a < b) {
        count++;
        a *= 2;
    }
    return pow(0.5, count);
}

int main () {
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += find_count(i, k)/n;
    }
    std::cout << std::fixed;
    std::cout << std::setprecision(12);
    cout << ans << endl;

    

}

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

int main(){
  string s;
  cin >> s;

  s[3] = '8';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3632
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
string s;
int n;
string dp[60][60];
string F(string a,string b){
	if(a.size()>b.size())return a;
	if(a.size()<b.size())return b;
	if(a>b)return a;
	return b;
}
string f(int l,int r){
	if(!(dp[l][r]==""||dp[l][r]=="*"))return dp[l][r];
	string out="/";
	{
		bool h=true;
		string t="";
		loop(j,l,r)if(isdigit(s[j]))t+=s[j];
		else if(s[j]=='?')t+="9";
		else{
			h=false;
			break;
		}
		if(r-l>1&&s[l]=='0')h=false;
		if(h)out=t;
	}
	if(r-l>=6){
		if(!(s[l]=='L'||s[l]=='R'||s[l]=='?'))return out;
		if(!(s[l+1]=='('||s[l+1]=='?'||s[l+1]=='?'))return out;
		if(!(s[r-1]==')'||s[r-1]=='?'||s[r-1]=='?'))return out;
		loop(j,l+3,r-2)if(s[j]==','||s[j]=='?'){
			string a=f(l+2,j),b=f(j+1,r-1);
			if(a=="/"||b=="/")continue;
			if(s[l]=='L'||s[l]=='?')out=F(out,a);
			if(s[l]=='R'||s[l]=='?')out=F(out,b);
		}
	}
	return dp[l][r]=out;
}
signed main(){
	rep(i,60)rep(j,60)dp[i][j]="";
	
	cin>>s;
	n=s.size();
	string out=f(0,n);
	if(out!="/")cout<<out<<endl;
	else cout<<"invalid"<<endl;
}









Measured memory_bytes: 3264
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

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

typedef long long int int64;


const int N = 305;
char str[N];

int dp[N][N][N];
int ans;

void upd(int &a, int b)
{
    a = max(a, b);
    ans = max(ans, b);
}


int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int k;
    scanf("%s", str + 1);
    scanf("%d", &k);
    int n = strlen(str + 1);

    for (int i = 1; i <= n; i++)
        for (int j = n; j >= i; j--)
            for (int h = 0; h <= k; h++)
            {
                int cur = dp[i][j][h];
                upd(dp[i + 1][j][h], cur);
                upd(dp[i][j - 1][h], cur);
                if (str[i] == str[j] )
                {
                    if (i == j) upd(dp[i + 1][j - 1][h], cur + 1);
                    else upd(dp[i + 1][j - 1][h], cur + 2);
                }
                else if (h < k)
                {
                    if (i == j) upd(dp[i + 1][j - 1][h + 1], cur + 1);
                    else upd(dp[i + 1][j - 1][h + 1], cur + 2);
                }
            }
    printf("%d\n", ans);

	return 0;
}



Measured memory_bytes: 110464
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
 
class DandA {
    static void Main(string[] args) {
        int a = ReadLineInt();
        int b = ReadLineInt();
        Console.WriteLine(6 - (a + b));
    }
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}

    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 11092
#!/usr/bin/env python3

N = int(input())
T = [0] + [int(x) for x in input().split()]
M = int(input())
s = sum(T)

answer = []
for _ in range(M):
    a, b = map(int,input().split())
    answer.append(s+b-T[a])

print(*answer, sep='\n')


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
int partition(int *A, int p, int r){
    int x = A[r - 1];
    int i = p-1;
    int tmp;

    for(int j = p; j < r-1; j++){
        if(A[j] <= x){
            i++;
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    
    i++;

    tmp = A[i];
    
    A[i] = x;
    A[r-1] = tmp;
    

    return i;
}

int main(void){
    int n;
    int A[100000];
    int p;

    scanf("%d", &n);
    
    for(int i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }
    

    p = partition(A, 0, n);

    for(int i = 0; i < p; i++){
        printf("%d ", A[i]);
    }

    printf("[%d] ", A[p]);

    for(int i = p + 1; i < n - 1; i++){
        printf("%d ", A[i]);
    }    

    printf("%d\n", A[n - 1]);

    //printf("\n");
    return 0;
}



Measured memory_bytes: 2124