akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    double a,b; cin >> a >> b;
    cout << (int)a/(int)b << " " << (int)a%(int)b << " " << fixed << setprecision(10) <<  a/b << endl;
}





Measured memory_bytes: 3212
s=[list(map(int,list(input().replace('a','0').replace('b','1').replace('c','2')))) for i in range(3)]
i=0
while len(s[i])>0:
  j=s[i][0]
  s[i]=s[i][1:]
  i=j
print(str(i).replace('0','A').replace('1','B').replace('2','C'))

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e3+10, M = 1e6+10;
struct P {
	int x, y, cnt;
};
int a[N][N];
int h, w;
int ch, cw, dh, dw, idx;
int vis[N][N];
int fx[] = {-1, 1, 0, 0};
int fy[] = {0, 0, -1, 1};
int ans;
bool inside(int x, int y) {
	return !(x < 1||x > h||y < 1||y > w);
}
void bfs(int x, int y) {
	deque<P> q;
	q.push_back({x, y, 0});
	while(!q.empty()) {
		P t = q.front();
		q.pop_front();
		if(t.x == dh&&t.y == dw) {
			ans = t.cnt;
			return ;
		}
		if(vis[t.x][t.y]) continue;
		vis[t.x][t.y] = 1;
		for(int i = 0;i < 4;i++) {
			int xx = t.x + fx[i], yy = t.y + fy[i];
			if(inside(xx, yy)&&a[xx][yy] == 0) {
				q.push_front({xx, yy, t.cnt});
			}
		}
		for(int i = t.x - 2;i <= t.x + 2;i++) {
			for(int j = t.y - 2;j <= t.y + 2;j++) {
				if(inside(i, j)&&a[i][j] == 0) {
					q.push_back({i, j, t.cnt + 1});
				}
			}
		}
	}
}
int main() {
	cin>>h>>w;
	cin>>ch>>cw;
	cin>>dh>>dw;
	ans = INF;
	idx = 1;
	for(int i = 1;i <= h;i++) {
		for(int j = 1;j <= w;j++) {
			char c;
			scanf(" %c", &c);
			if(c == '#') a[i][j] = 1;
			else a[i][j] = 0;
		}
	}
	bfs(ch, cw);
	if(ans == INF) cout<<-1;
	else cout<<ans;
	return 0;
}

Measured memory_bytes: 13048
/** Author : Parth Prajapati
 *     Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define vl vector<ll int>
#define pl pair<ll int,ll int>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll MOD = 1e9 + 7;
const double pie = 3.141592653589793;
const ll int MD = 998244353 ;

#define setcount(x) __builtin_popcount(x) // counts set bits
#define parity(x) __builtin_parity(x) // checks parity of the number
#define lzcount(x) __builtin_clz(x) // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x) // count trailing zeros in binary representation of number

template<typename T> T inf() { return (T)__builtin_inf();} // syntax for use inf<datatype>();
template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M) { return ( mod(a,M ) + mod(b,M ))%M; }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M; }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

/************************** main program **************************/


int main()
{
    FASTIO
    //code
	ll int n,a,b;
	cin>>n>>a>>b;
	ll int d1,d2,d;
	if((b-a)&1)
	{
		d1 = a-1;
		d2 = n-b;
		if((b-1) <= (n-a))
			d = b-1;
		else
			d = n-a;
		if(d1 < d2)
		{
			b = b-a+1;
			a = 1;
			if((d1 + 1 + (b-a)/2) < d && (d1 + 1 + (b-a)/2) > 0)
				d = (d1 + 1 + (b-a)/2);
		}
		else
		{
			a = a+n-b+1;
			b = n;
			n = (b-a)/2;
			if((d2 + 1 + n) < d && (d2 + 1 + n) > 0)
				d = (d2 + 1 + n);
		}
	}
	else
	{
		d = (b-a)/2;
	}
	cout<<d;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,i,j,s,count = 0;
	scanf("%d",&n);
	int array[n];
	for (i = 0;i < n;i++)
		scanf("%d",&array[i]);

	for (j = 0;j < n ;j++) {
		for (i = 0;i < n -1;i++) {
			if (array[i+1] < array[i]) {
				s = array[i+1];
				array[i+1] = array[i];
				array[i] = s;
				count++;
			}
		}

	}
	
	for (i = 0;i < n;i++) {
		if (i == n -1)
			printf("%d\n",array[i]);
		else printf("%d ",array[i]);
	}
	printf("%d\n",count);
	return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using Graph = vector<vector<LL>>;

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
long long chmax(long long a,long long b){
  a = max(a,b);
}
long long chmin(long long a, long long b){
  a = min(a,b);
}
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;

    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
}



int main() {
  LL n,k=-1,sum=0,a=0,b=0,c=0,d=0,ans=0;
  LL MOD = 1000000007;
  LL INF = 1LL << 60;
  string S="",T="",U="";
  cin >> a >> b >> c;
  cout << c << endl << a << endl << b;
  //cout << ans << endl;
}

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

using ll = long long int;

ll arr[5110] = {1};
    
int main(void){
    
    int n,p;
    cin >> n >> p;
    
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        
        for(int j = 5000; j >= 0; j-- )
            arr[j+a] += arr[j];
        
    }
    
    ll res = 0;
    
    for(int i = 0; i<=5000; i++){
       // cout << res << " ";
        if(p == i%2){
            res += arr[i];
        }
    }
    
    cout << res << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> x(n), y(m);
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];

    vector<ll> sx(n+1), sy(m+1);
    rep(i, n) sx[i+1] += (sx[i] + x[i]);
    rep(i, m) sy[i+1] += (sy[i] + y[i]);

    ll X = 0, Y = 0;
    rep(i, n){
        ll s = sx[n] - sx[i+1];
        X += (s - (n-i-1) * x[i])%MOD;
        X %= MOD;
    }

    rep(i, m){
        ll s = sy[m] - sy[i+1];
        Y += (s - (m-i-1) * y[i])%MOD;
        Y %= MOD;
    }

    ll ans = X * Y;
    cout << ans%MOD << endl;
}

Measured memory_bytes: 3328
function main (input) {
  var N = parseInt(input.split('\n')[0]);
  var a = parseInt(input.split('\n')[1]);

  Nperfh = N % 500;
  if (a >= Nperfh) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;


int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n];
   for(ll i=0;i<n;i++)
        cin>>arr[i];
   
   ll las[n][21];
   memset(las,-1,sizeof(las));
   for(ll i=0;i<n;i++)
   {
       if(i>0){
       for(ll j=0;j<21;j++)
            las[i][j] = las[i-1][j];
       }
       
       for(ll j=0;j<21;j++)
       {
           if((1ll<<j)&arr[i])
                las[i][j] = i;
       }
   }
   
   ll ans =  n;
   
   for(ll i=0;i<n;i++)
   {
       ll mini = -1;
       for(ll j=0;j<21;j++)
       {
           ll temp = las[i][j];
           if(temp == -1)
                continue;
           if(temp == 0)
               continue;
           temp--;
           temp = las[temp][j];
           mini = max(mini, temp);
       }
       
       ans+=max((ll)0, i-1-mini);
   }
   
   cout<<ans;
   
   return 0;
}  
   

Measured memory_bytes: 34688
//O(n^1/2)
//理解していない
#include <iostream>
using namespace std;

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

    long long sum = 0;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            long long a = n / i;
            if (a - 1 > i) sum += a - 1;
            //if (i - 1 > a) sum += i - 1;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=input()
b=input()
c=input()
ans=0
for i in range(n):
    if a[i]!=b[i] and a[i]!=c[i] and b[i]!=c[i]:
        ans+=2
    elif (a[i]==b[i] and a[i]!=c[i]) or (a[i]==c[i] and a[i]!=b[i]) or (b[i]==c[i] and a[i]!=b[i]):
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const double pi = 3.141592653589793;



int main(){
    ll N, M;
    cin>>N>>M;
    vector<ll> A(M), B(M);
    vector<vector<ll>> Way(N, vector<ll>(0));
    rep(i, M){
        cin>>A[i]>>B[i];
        A[i]--;
        B[i]--;
        Way[A[i]].push_back(B[i]);
        Way[B[i]].push_back(A[i]);
    }
    priority_queue<pair<ll, ll>,vector<pair<ll, ll>>, greater<pair<ll, ll>>> Q;
    vector<ll> Dist(N, INF);
    vector<ll> Prev(N, -1);
    Dist[0]=0;
    Q.push(pair<ll, ll>(0, 0));
    while(!Q.empty()){
        pair<ll, ll> P=Q.top(); Q.pop();
        ll v=P.second;
      	if(Dist[v]<P.first)continue;
      	ll Sz=Way[v].size();
        for(ll i=0; i<Sz; i++){
            ll e=Way[v][i];
            if(Dist[e]>Dist[v]+1){
                Dist[e]=Dist[v]+1;
                Q.push(pair<ll, ll>(Dist[e], e));
                Prev[e]=v;
              	//cout<<e+1<<" "<<v+1<<endl;
            }
        }

    }
 	
  	cout<<"Yes"<<endl;
    for(ll i=1; i<N; i++){
        cout<<Prev[i]+1<<endl;
    }
}



Measured memory_bytes: 18088
s = list(input())
t = list(input())
for i in range(len(s)-len(t)+1)[::-1]:
    for j in range(len(t)):
        if not s[i+j] == "?":
            if not s[i+j] == t[j]:
                break
    else:
        for j in range(len(t)):
            s[i+j] = t[j]
        for j in range(len(s)):
            if s[j] == "?":
                s[j] = "a"
        print("".join(s))
        break
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;

#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);

#define csh(a,n) memset(a,n,sizeof(a));
int main()
{
    int n;
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
    	cout<<"bust"<<endl;
	}
	else
	cout<<"win"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
H, W = list(map(int, input().split()))
L = []

for i in range(H):
	L.append(input().split())

print("#" * (W + 2))

for i in range(H):
	print("#", end = "")
	print("".join(L[i]), end = "")
	print("#")

print("#" * (W + 2))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
struct UnionFind
{
  vector< int > data;
  int parts;
  UnionFind(int size)
  {
    data.assign(size, -1);
    parts = size;
  }
  void Union(int x,int y)
  {
    x = Find(x), y = Find(y);
    if(x == y) return;
    --parts;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
  int Find(int x)
  {
    if(data[x] < 0) return(x);
    return(data[x] = Find(data[x]));
  }
  int size()
  {
    return(parts);
  }
};
 
int main()
{
  int N;
  int X1[50], Y1[50], X2[50], Y2[50];
 
  while(cin >> N, N) {
    vector< int > nums1, nums2;
    long long orr[300][300] = {{}};
 
    for(int i = 0; i < N; i++) {
      cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
      if(X1[i] > X2[i]) swap(X1[i], X2[i]);
      if(Y1[i] > Y2[i]) swap(Y1[i], Y2[i]);
      nums1.push_back(X1[i]);
      nums1.push_back(X2[i]);
      nums2.push_back(Y1[i]);
      nums2.push_back(Y2[i]);
    }
    nums1.push_back(-1);
    nums2.push_back(-1);
    sort(nums1.begin(), nums1.end());
    nums1.erase(unique(nums1.begin(), nums1.end()), nums1.end());
    sort(nums2.begin(), nums2.end());
    nums2.erase(unique(nums2.begin(), nums2.end()), nums2.end());
    for(int i = 0; i < N; i++) {
      X1[i] = lower_bound(nums1.begin(), nums1.end(), X1[i]) - nums1.begin();
      X2[i] = lower_bound(nums1.begin(), nums1.end(), X2[i]) - nums1.begin();
      Y1[i] = lower_bound(nums2.begin(), nums2.end(), Y1[i]) - nums2.begin();
      Y2[i] = lower_bound(nums2.begin(), nums2.end(), Y2[i]) - nums2.begin();
      for(int j = X1[i]; j < X2[i]; j++) {
        for(int k = Y1[i]; k < Y2[i]; k++) {
          orr[j][k] |= 1LL << i;
        }
      }
    }
    UnionFind uftree(nums1.size() * nums2.size());
    for(int j = 0; j < nums1.size(); j++) {
      for(int k = 1; k < nums2.size(); k++) {
        if(orr[j][k - 1] == orr[j][k]) {
          uftree.Union(j * nums2.size() + k - 1, j * nums2.size() + k);
        }
      }
    }
    for(int j = 1; j < nums1.size(); j++) {
      for(int k = 0; k < nums2.size(); k++) {
        if(orr[j - 1][k] == orr[j][k]) {
          uftree.Union(j * nums2.size() + k - nums2.size(), j * nums2.size() + k);
        }
      }
    }
    cout << uftree.size() << endl;
  }
}

Measured memory_bytes: 1968
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int ans=0;
  int a,b,c;
  while(A%2==0 && B%2==0 && C%2==0){
    ans++;
    a=(B+C)/2;
    b=(A+C)/2;
    c=(A+B)/2;
    A=a;
    B=b;
    C=c;
    if(A==B && B==C){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	if(a>b)
	{
		for(size_t i = 0; i<a; i++)
		{
			cout<<b;
		}
		cout<<endl;
	}
	else
	{
		for(size_t i = 0; i<b; i++)
		{
			cout<<a;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)

for bit in range(1<<(n-1)):
  f=s[0]
  a=int(s[0])
  for i in range(n-1):
    if bit & (1<<i):
      f+="+"+s[i+1]
      a+=int(s[i+1])
    else:
      f+="-"+s[i+1]
      a-=int(s[i+1])
  if a==7:
    print(f+"=7")
    exit()

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

int main(){
    int n,l;
    cin >> n>>l;
    int ans = (2*l+n-1)*n/2;
    if(l>=0){
        ans =ans-l;
    }
    else if(l+n-1<0){
        ans = ans-l-n+1;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		int[] dp = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 2; i < n;i++) {
			dp[i] = Math.min((dp[i-2] + Math.abs(h[i] - h[i-2])), (dp[i-1] + Math.abs(h[i] - h[i-1])));
		}
		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 61884
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var N int
	fmt.Scan(&N)
	a := make([]int, N+1)
	for i := 1; i <= N; i++ {
		a[i] = nextInt(sc)
	}
	// fmt.Println("a", a)
	// ans := make(map[int]int, 0)
	box := make(map[int]bool, 0)
	for i := N; i >= 1; i-- {
		if i > N/2 { // N以下にiの倍数は存在しないので、必ず箱iにはボールを入れないといけない
			// fmt.Println("d0 - i", i)
			if a[i] == 1 {
				box[i] = true
			}
		} else {
			var t int
			for j := i; j <= N; j += i {
				if box[j] {
					t++
				}
			}
			if ((a[i] == 0) && (t%2 == 1)) ||
				((a[i] == 1) && (t%2 == 0)) {
				box[i] = true
			}
		}
	}
	fmt.Println(len(box))
	if len(box) > 0 {
		for k := range box {
			fmt.Print(k, " ")
		}
		fmt.Println()
	}
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
int n,m,first[100001],tot,d[100001],s,t;
struct E{int from,v,w;}e[2000010];
struct N{int x,d;bool operator <(const N &b)const{return d>b.d;}}z;
priority_queue<N>q;
void in(int u,int v,int w){tot++;e[tot].v=v;e[tot].w=w;e[tot].from=first[u];first[u]=tot;}
int dij(){
	int x;memset(d,0x3f,sizeof(d));
	d[s]=0;q.push((N){s,d[s]});
	while(!q.empty()){z=q.top();q.pop();if(z.d!=d[z.x])continue;x=z.x;
		for(int i=first[x];i;i=e[i].from)
		if(d[e[i].v]>d[x]+e[i].w)d[e[i].v]=d[x]+e[i].w,q.push((N){e[i].v,d[e[i].v]});}
	return d[t];}
int main(){
	int i,j;scanf("%d",&n);
	for(i=1;i<=n;i++)for(j=0;j<=9;j++)in(i,((i-1)*10+j)%n+1,j);
	for(j=1;j<=9;j++)in(0,j+1,j);
	s=0;t=1;printf("%d",dij());}

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

using namespace std;

void bsort(long long *x){
  long long tmp;
  if ((*(x+0)) > (*(x+1))) {
    tmp = (*(x+0));
    (*(x+0)) = (*(x+1));
    (*(x+1)) = tmp;
  }
  if ((*(x+1)) > (*(x+2))) {
    tmp = (*(x+1));
    (*(x+1)) = (*(x+2));
    (*(x+2)) = tmp;
  }
  if ((*(x+0)) > (*(x+1))) {
    tmp = (*(x+0));
    (*(x+0)) = (*(x+1));
    (*(x+1)) = tmp;
  }
  //  return(x);
}

int main (){
  long long H, W, diff, mindiff, area[3], x, y; 
  mindiff = 1LL<<62;
  cin >> H >> W;
  y = floor(H/3);
  for (int i=-1;i<2;i++) {
    x = floor(W/2);
    if (y + i < 0 || y + i > H) {
      continue;
    }
    for (int j=-1;j<2;j++) {
      if (x + j < 0 || x + j > W) {
	continue;
      }
      area[0] = W * (y+i);
      area[1] = (x+j) * (H-(y+i));
      area[2] = (W - (x+j)) * (H-(y+i));
      bsort(area);
      diff = area[2] - area[0];
      mindiff = mindiff > diff?diff :mindiff;
    }
    long long yy = floor(2*H/3);
    for (int j=-1;j<2;j++) {
      if (yy + j < 0 || yy + j > H) {
	continue;
      }

      area[0] = W * (y+i);
      area[1] = W * (yy+j-(y+i));
      area[2] = W * (H-(yy+j));
      bsort(area);
      diff = area[2] - area[0];
      mindiff = mindiff > diff?diff :mindiff;
    }
    
  }

  x = floor(W/3);
  for (int i=-1;i<2;i++) {
    y = floor(H/2);
    if (x + i < 0 || x + i > W) {
      continue;
    }

    for (int j=-1;j<2;j++) {
      if (y + j < 0 || y + j > H) {
	continue;
      }
      area[0] = H * (x+i);
      area[1] = (y+j) * (W-(x+i));
      area[2] = (H - (y+j)) * (W-(x+i));
      //      cout << area[0] << " " << area[1] << " " << area[2] << endl;
      bsort(area);
      diff = area[2] - area[0];
      //      cerr << x+i << " " << y+j << " " << diff << endl;
      mindiff = mindiff > diff?diff :mindiff;
    }
    //    cout << mindiff << endl;

    long long xx = floor(2*W/3);
    for (int j=-1;j<2;j++) {
      if (xx + j < 0 || xx + j > W) {
	continue;
      }

      area[0] = H * (x+i);
      area[1] = H * (xx+j-(x+i));
      area[2] = H * (W-(xx+j));
      //      cout << area[0] << " " << area[1] << " " << area[2] << endl;
      bsort(area);
      diff = area[2] - area[0];
      //      cerr << x+i << " " << y << " " << diff << endl;
      mindiff = mindiff > diff?diff :mindiff;
    }
    //    cout << mindiff << endl;

  }
  cout << mindiff << endl;
}


Measured memory_bytes: 256
#dream dreamer erase eraser
import sys

S = input()
index = len(S)
while index > 7:
    five = S[index-5:index]
    six = S[index-6:index]
    seven = S[index-7:index]
    if five == "dream" or five == "erase":
        index -= 5
    elif six == "eraser":
        index -= 6
    elif seven == "dreamer":
        index -= 7
    else:
        print("NO")
        sys.exit()

last = S[:index]
if last == "dream" or last == "erase" or last == "eraser" or last == "dreamer":
    print("YES")
else:
    print("NO")

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

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

    int n;
    cin >> n;
    vector<vector<int>> a(n+1, vector<int>(3));
    rep(i,n) cin >> a[i+1][0] >> a[i+1][1] >> a[i+1][2];
    
    vector<vector<int>> dp(n+1, vector<int>(3, 0));
    
    for(int i=1; i<=n; i++){
        rep(j, 3){
            rep(k, 3){
                if(j==k) continue;
                
                dp[i][k] = max(dp[i-1][j] + a[i][k], dp[i][k]);
            }
        }
    }
    
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;

    return 0;
}

Measured memory_bytes: 11264
import re
out=[]
for w in input().split(" "):
    if re.search("apple",w)!=None:out.append(re.sub("apple","peach",w))
    elif re.search("peach",w)!=None:out.append(re.sub("peach","apple",w))
    else:out.append(w)
print(' '.join(out))

Measured memory_bytes: 7608
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
#include <vector>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>

int main()
{
	int n;
	cin >> n;
	double ans = 0;
	rep(i, n) {
		double x;
		string u;
		cin >> x >> u;
		if (u == "JPY")
			ans += x;
		if (u == "BTC")
			ans += x * 380000;
	}
	printf("%.10f\n",ans);
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll sdiff(vector<ll>& v) {
    sort(ALL(v));
    return v.back() - v[0];
}

ll type2(int H, int W){
    // Wの適当なところで割って、残りを半分
    ll best = (ll)H*W;
    vector<ll> s(3);
    for (ll w=1; w<W; ++w){
        s[0] = w * H;
        ll _w = W - w;
        if (H % 2) {
            s[1] = _w * (H / 2);
            s[2] = _w * (H - H/2);
        } else {
            s[1] = s[2] = _w * (H / 2);
        }
        best = min(best, sdiff(s));
    }
    return best;
}
ll type3(int H, int W){
    // Wサイドで割る
    return (W%3 == 0) ? 0 : H;
}
ll solve(int H, int W) {
    vector<ll> v {
        type2(H,W),
        type2(W,H),
        type3(H,W),
        type3(W,H)
    };
    return *min_element(ALL(v));
}

int main() {
    int H,W; cin >>H>>W;
    cout << solve(H,W) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    x = II()
    if x == 1: print(1); exit(0)
    b = 2; p = 2
    maxv = 0
    while True:
        if b**2 > x: break
        if b**p > x:
            maxv = max(maxv, b**(p-1))
            b += 1; p = 2
            continue
        p += 1
    print(maxv)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    /*
    int a, b ;
    cin >> a >> b ;
    //*/

    string a;
    cin >> a ;

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    //*
    if( a.at(5) == '1' || a.at(6) - '0' > 4 ){
        cout << "TBD" << endl;
    } else {
        cout << "Heisei" << endl;
    }
    //*/
    
    //cout << a / b << endl;

    return 0; 
}


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

typedef long long ll;

int main() {
	string a;
	cin >> a;
	if (a.size() == 2) {
		cout << a << endl;
	} else {
		for (int i = 0;i < 3;i++) {
			cout << a[a.size()-i-1];
		}
cout << endl;
	}
}

Measured memory_bytes: 256
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
auto cmn=[](auto&x,auto y){if(x>y){x=y;return true;}return false;};
auto cmx=[](auto&x,auto y){if(x<y){x=y;return true;}return false;};
int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    std::string s;
    std::cin >> s;

    usize ans = s.length();
    for (char c='a'; c<='z'; c++) {
        usize now = 0;
        for (usize i=0, j=0; i<s.length(); i=j+1) {
            for (j=i; j<s.length() && s.at(j)!=c; j++);
            cmx(now, j-i);
        }
        cmn(ans, now);
    }
    std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

string w;

int main()
{
    cin >> w;
    map<char, int> mp;
    rep(i, w.size()) mp[w[i]]++;
    for(auto it = mp.begin(); it != mp.end(); it++){
        int v = it->se;
        if(v & 1){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}



Measured memory_bytes: 256
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for _ in range(n):
    (b, f, r, v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print('', data[b][f][r], end='')
        print()
    if b != 3:
        print('#' * 20)

Measured memory_bytes: 6728
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[]strArray = new String[s.length()];
		
		int zero=0;
		int one=0;
		
		for(int i=0;i<s.length(); i++) {
			strArray[i]=String.valueOf(s.charAt(i));
		}
		
		for(int i=0; i<s.length(); i++) {
			if(strArray[i].equals("0"))  zero++;			
			else 	one++;
		}
		if(zero<=one) System.out.println(zero*2);
		else System.out.println(one*2);
	}
}


Measured memory_bytes: 31692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main(){
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    for (ll i = 0; i < tx - sx; i++) cout << "R";
	for (ll i = 0; i < ty - sy; i++) cout << "U";
	for (ll i = 0; i < tx - sx; i++) cout << "L";
	for (ll i = 0; i < ty - sy; i++) cout << "D";
    cout << "L";
	for (ll i = 0; i < ty - sy+1; i++) cout << "U";
	for (ll i = 0; i < tx - sx+1; i++) cout << "R";
    cout << "D";
    cout << "R";
	for (ll i = 0; i < ty - sy+1; i++) cout << "D";
	for (ll i = 0; i < tx - sx+1; i++) cout << "L";
    cout << "U";
    cout << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
int map[110][110];
int h,w;
void find(){
	int i,j;
	for(i=0;i<h+2;i++){
		if(i==0||i==h+1){
			for(j=0;j<w+2;j++)
				printf("#");
			printf("\n");
		}
		else{
			printf("#");
			printf("%s",map[i-1]);
			printf("#\n"); 
		}
	}
}
int main(){
	int i,j;
	while(scanf("%d%d",&h,&w)!=EOF){
		getchar();
		for(i=0;i<h;i++)
			scanf("%s",map[i]);
		find();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(void)
{
  int max = 0, cnt[101];
  int n;

  for(int i = 0 ; i < 101 ; i++) {
    cnt[i] = 0;
  }

  while(scanf("%d",&n) != EOF) {
    cnt[n]++;
  }
  for(int i = 0 ; i < 101 ; i++) {
    if(max < cnt[i]) max = cnt[i];
  }
  for(int i = 0 ; i < 101 ; i++) {
    if(cnt[i] == max) cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 0
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var a = o.a();
  var s = o.a(1);
  return a>=3200?s:"red";
}

Measured memory_bytes: 22076
#include<iostream>
using namespace std;
int main() {
	char a, b, c;
	int haiku5 = 0, haiku7 = 0;
	cin >> a >> b >> c;
	if (a == '5')haiku5++;
	else if (a == '7')haiku7++;
	if (b == '5')haiku5++;
	else if (b == '7')haiku7++;
	if (c == '5')haiku5++;
	else if (c == '7')haiku7++;
	if (haiku5 == 2 && haiku7 == 1) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
	return 0;

}

Measured memory_bytes: 256
(defn Grouping [x y]
  (if (let [ns (list x y)] (or
    (every? (partial contains? #{1 3 5 7 8 10}) ns)
    (every? (partial contains? #{4 6 9 11}) ns)
    (every? (partial = 2) ns)))
    "Yes"
    "No"))
(println (Grouping (int (read)) (int (read))))

Measured memory_bytes: 60176
ARG_N = gets.to_i
arms = Array.new ARG_N
ARG_N.times do |i|
  arms[i] = gets.split.map(&:to_i)
end
arms = arms.sort_by{|a| a[0]}

dp = []
dp[0] = - 10**9+1
ARG_N.times do |i|
  arm = arms[i]
  left = arm[0] - arm[1]
  right = arm[0] + arm[1]
  if dp[-1] <= left
    dp.push right
  end

  if right < dp[-1] && dp[-2] < left
    dp[-1] = right
  end
end

puts dp.length - 1

Measured memory_bytes: 12664
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  dset(10);
  in6 n;
  cin >> n;
  vi value(n);
  rep(i,n) cin >> value[i];
  sort(all(value));
  ind sum = value[0];
  repa(i,1,n) {
    sum += value[i]*pow(2,i-1);
  }
  cout << sum/pow(2,n-1);
  hinata;
}

Measured memory_bytes: 4120
# https://atcoder.jp/contests/abc099/tasks/abc099_c

# DPを考えてみる
# dp[i]: i円を引き出すのに必要な回数
# dp[0] = 1
# dp[1] = 1
# dp[6] の倍数 = 1
# dp[9] の倍数 = 1

# 10万以下でありえる値
# 6**7 # 279936
# 9**6 # 531441
c = [1] + [6**i for i in range(1,7)] + [9**i for i in range(1,6)]

Inf = int(1e18)

n = int(input())
dp = [Inf] * (n + 1)
dp[0] = 0

# 金額毎
for ci in c:
    for i in range(ci, n+1):
        # ある金額のminは，その金額を降ろさないmin + 1回
        # 1000円でc=9の場合，dp[1000] = min(dp[1000], dp[1000-9]+ 1)
        dp[i] = min(dp[i], dp[i-ci] + 1)

print(dp[n])

Measured memory_bytes: 39920
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 1000000;
ll mod = INF;

int n;
string s;

int main(){
    cin >> n;
    cin >> s;
    int R=0,W=0;
    int todoR=0,todoW=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R')R++;
    }
    W=n-R;

    for(int i=0;i<R;i++){
        if(s[i]=='W')todoW++;
    }

    for(int i=R;i<n;i++){
        if(s[i]=='R')todoR++;
    }

    //ans =  min(todoR,todoW)+max(todoR,todoW)-min(todoR,todoW)
    cout << max(todoR,todoW)<<endl;

    return 0;
}

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

using namespace std;

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> L;
  int _l;
  for (int i = 0; i < N; ++i) {
    cin >> _l;
    L.push_back(_l);
  }
  int position = 0;
  int cnt = 0;
  while (position <= X && cnt < N + 1){
    position += L[cnt];
    ++cnt;
  }
  cout << cnt << endl;
  return 0;
}

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

//ITP1-8-A

int main(){
	char ch;
	while(1){
		scanf("%c",&ch);
		if('a'<=ch && ch<='z'){
			ch+='A'-'a';
		}else if('A'<=ch && ch<='Z'){
			ch+='a'-'A';
		}
		printf("%c",ch);
		if(ch=='\n') break;
	}
	return 0;
}

Measured memory_bytes: 932
#include<iostream>
#include<iomanip>

using namespace std;

int main()
{
    int a,b,i,j;
    while(1){
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        for(i = 1;i <= a;i++){
            for(j = 1;j <= b;j++){
                if(i % 2 == 1){
                    if(j % 2 == 1){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }else{
                    if(j % 2 == 1){
                        cout << ".";
                    }else{
                        cout << "#";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, W;
  cin >> N >> W;
  ll w[105], v[105];
  ll dp[100005][101];
  rep(i, N){
    cin >> w[i+1] >> v[i+1];
  }

  rep(i, W+1){
    rep(j, N+1){
      if (i == 0){
        dp[0][j] = 0;
      } else if (j == 0) {
        dp[i][0] = 0;
      } else {
        if (i - w[j] >= 0){
          dp[i][j] = max(dp[i-w[j]][j-1]+v[j], dp[i][j-1]);
        } else {
          dp[i][j] = dp[i][j-1];
        }
      }
    }
  }

  cout << dp[W][N] << endl;
}


Measured memory_bytes: 79232
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		int ans=(n+1)/2;
		printf("%d\n", ans);
	}
	return 0;
}


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

#define count_ones __builtin_popcountl
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);

    ll a, b, k;
    cin >> a >> b >> k;
    ll aa = min(a, k);
    a -= aa;
    b -= min(b, k - aa);
    cout << a << ' ' << b;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int width = in.nextInt();
		int height = in.nextInt();
		int rute = in.nextInt();
		int couse = 0;
		int[] x = new int [rute];
		int[] y = new int [rute];
		x[0] = in.nextInt();
		y[0] = in.nextInt();
		for(int i = 1;i < rute;i++){
			x[i] = in.nextInt();
			y[i] = in.nextInt();
			while(x[i] <= width && y[i] <= height){
				if(x[i-1] < x[i] && y[i-1] < y[i]){
					if(x[i]-x[i-1] > y[i]-y[i-1]) couse = couse + x[i]-x[i-1];
					else couse = couse + y[i]-y[i-1];
				}
				else if(x[i-1] > x[i] && y[i-1] > y[i]){
					if(x[i-1]-x[i] > y[i-1]-y[i]) couse = couse + x[i-1]-x[i];
					else couse = couse + y[i-1]-y[i];
				}
				else{
					if(x[i]-x[i-1] >= 0){
						couse = couse + x[i]-x[i-1];
					}
					else{
						couse = couse - x[i]+x[i-1];
					}
					if(y[i]-y[i-1] >= 0){
						couse = couse + y[i]-y[i-1];
					}
					else{
						couse = couse - y[i]+y[i-1];
					}
				}
				break;
			}
		}
		System.out.println(couse);
	}
}

Measured memory_bytes: 25472
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,k;
  cin >> n >> k;
  int ans = 0;
  rep(i,n){
    int h;
    cin >> h;
    if(k<=h)++ans;
  }
  cout << ans << endl;
}


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

int main(){
    long N;
    int A[100010];
    long long sumcost = 0;

    cin >> N;
    A[0] = 0;
    for(int i=1;i<=N;i++) cin >> A[i];
    A[N+1] = 0;

    for(int i=0;i<=N;i++){
        sumcost += abs(A[i+1] - A[i]);
    }

    for(int i=1;i<=N;i++){
        if((A[i-1] <= A[i] && A[i] <= A[i+1]) || (A[i-1] >= A[i] && A[i] >= A[i+1])){
            cout << sumcost << endl;
        }
        else{
            cout << sumcost - 2*min(abs(A[i+1] - A[i]), abs(A[i] - A[i-1])) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1664
a,b,c=map(int,input().split())
if a<b:
    if b<c:
        print(a,b,c)
    elif c<a:
        print(c,a,b)
    else:
        print(a,c,b)
elif a<c:
    print(b,a,c)
elif b<c:
    print(b,c,a)
else:
    print(c,b,a)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000005
#define MAX 100000
//#define mp make_pair
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[MAX], b[MAX];
int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	rep(i,n)scanf("%d", &a[i]);
	for(int i = 1;i < n;i++){
		if(a[i] > a[i-1])b[i] = 1;
		else b[i] = -1;
	}
	if(b[n-1] == 1)b[n] = -1;
	else b[n] = 1;
	int f = b[1], ans = 0, tmp = m-a[0];
	for(int i = 1;i < n;i++){
		tmp += m-a[i];
		if(f != b[i+1]){
			ans = max(ans, tmp);
			tmp = m-a[i];
			f = b[i+1];
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3984
#include <stdio.h>

int n;

int saiki(int ima)
{
	if (ima == n)
	{
		return 1;
	}

	if (ima > n)
	{
		return 0;
	}
	
	int res=0;

	res +=saiki(ima+1)+saiki(ima+2)+saiki(ima+3);
	return res; 
}
int main()
{
	int x = saiki(0);
	for(;;)
	{
		scanf("%d", &n);
		if (n==0)
		{
			break;
		}
		printf("%d\n", saiki(0)/ 10 / 365 +1);

	}

	

	
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int x, k;
	cin >> k >> x; k--;
	for (int i = x - k; i <= x + k; i++) {
		cout << i;
		if (i != x + k) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	vector<int> a(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> a[i];
	}

	auto cost = INT_MAX;
	for (auto i = -100; i <= 100; ++i)
	{
		auto sum = 0;
		for (auto j = 0; j < N; ++j)
		{
			auto diff = i - a[j];
			sum += diff * diff;
		}

		cost = min(cost, sum);
	}

	cout << cost << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a; string in;
    cin >> a >> in;

    string res = in;
    if(a < 3200){
        res = "red";
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
	while(true) {
		int d;
		if(scanf("%d", &d)<1)break;
		int sum = 0;
		for(int i = 0; i < 600; i+=d) {
			sum += i*i*d;
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#define max(a,b) ((a > b)?(a):(b))

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

int main()
{
    int n, h;
    int i;
    scanf("%d %d", &n, &h);
    int a[n], b[n];
    for(i=0;i<n;i++) scanf("%d %d", &a[i], &b[i]);
    
    int max_a = 0;
    
    for(i=0;i<n;i++){
        max_a = max(max_a, a[i]);
    }
    
    qsort(b, n, sizeof(int), compare_int);
    
    int sum = 0;
    int count = 0;
    
    for(i=n-1;b[i]>=max_a;i--){
        count += 1;
        sum += b[i];
        if (sum >= h){
            printf("%d", count);
            return 0;
        }
    }
    
    while(sum < h){
        count += 1;
        sum += max_a;
    }
    
    printf("%d", count);
    
    return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char a[200005];

int read(){
	int s=0,w=1;
	char ch;
	ch = getchar(); 
	while(ch < '0' || ch > '9'){if(ch == '-')w = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){s = s*10 + (ch-'0');ch = getchar();}
	return s*w;
}

int n;
int dp[200005][4];

int main(){
	scanf("%s",a+1);
	n = strlen(a+1);
	dp[1][1] = 1;
	dp[1][2] = 0;
	dp[2][1] = (a[1]==a[2])?0:2;
	dp[2][2] = 1;
	for(int i = 3;i <= n;++i){
        if(dp[i-1][1]&&a[i-1]!=a[i])
            dp[i][1]=max(dp[i][1],dp[i-1][1]+1);
        if(dp[i-1][2])
            dp[i][1]=max(dp[i][1],dp[i-1][2]+1);
        if(dp[i-2][1])
            dp[i][2]=max(dp[i][2],dp[i-2][1]+1);
        if(dp[i-2][2]&&(a[i-2-1]!=a[i-1]||a[i-2]!=a[i]))
            dp[i][2]=max(dp[i][2],dp[i-2][2]+1);
	}
	int ans = max(dp[n][1],dp[n][2]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3712