akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main() {
    int n; cin >> n;
    map<int, int> mp;
    int L=0, R=0;
    rep(i, n+1) {
        int a; cin >> a;
        if(mp[a] != 0) {
            L = mp[a];
            R = i + 1;
            break;
        }
        mp[a] = i + 1;
    }
    combination C(n+1);
    for(int k=1;k<=n+1;k++) {
        ll ans = C(n+1, k).x - C(L+n-R, k-1).x;
        cout << (ans+mod)%mod << endl;
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
string S[101];
int dp[101][101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) {
		FOR(x,W) dp[y][x]=1<<30;
		cin>>S[y];
	}
	dp[0][0]=0;
	FOR(y,H) FOR(x,W) {
		if(y) dp[y][x]=min(dp[y][x],dp[y-1][x]+(S[y][x]!=S[y-1][x]));
		if(x) dp[y][x]=min(dp[y][x],dp[y][x-1]+(S[y][x]!=S[y][x-1]));
	}
	
	int ret=dp[H-1][W-1];
	if(S[0][0]=='#') ret++;
	
	cout<<(ret+1)/2<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

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

    if (N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    string half = S.substr(0, N / 2);
    string half2 = S.substr(N / 2);

    if (half.compare(half2) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
 
class Stack {
  private:
    int top;
    int a[100];
 
  public:
    static const int MAX = 100;
 
    Stack() {
      top = 0;
    }
 
    bool isEmpty() {
      return top == 0;
    }
 
    bool isFull() {
      return top >= MAX;
    }
 
    void push(int x) {
      if (isFull()) {
        cout << "full" << endl;
        return;
      }
      top++;
      a[top] = x;
    }
 
    int pop() {
      if (isEmpty()) {
        cout << "empty" << endl;
        return 0;
      }
      top --;
      return a[top + 1];
    }
};
 
int main() {
  Stack stack;
  string str;
  int x;
  while (cin >> str) {
    if (str == "+") {
      stack.push(stack.pop() + stack.pop());
    } else if (str == "-") {
      x = stack.pop();
      stack.push(stack.pop() - x);
    } else if (str == "*") {
      stack.push(stack.pop() * stack.pop());
    } else {
      stack.push(atoi(str.c_str()));
    }
  }
 
  cout << stack.pop() << endl;
  return 0;
}

Measured memory_bytes: 3168
#include <stdio.h>

int main(void);

int main(void)
{
    int S, h, m, s;

    scanf("%d", &S);

    h = S / (3600);
    m = (S % 3600)/60;
    s = (S % 3600)%60;
    printf("%d:%d:%d\n", h, m, s);

    return(0);
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
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 int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    vector<vector<int>> ans(h, vector<int>(w));
    vector<int> nos(h, -2);
    int now = 1;
    rep(i, h){
        bool first = !(s[i][0] == '#');
        rep(j, w){
            ans[i][j] = now;
            if(j+1 == w){
                // いちごなし
                if(first) nos[i] = -1;
                else now++;
            }
            else if(s[i][j+1] == '#'){
                if(first) first = 0;
                else now++;
            }
        }
    }
    int save = -1;
    rep(i, h){
        if(nos[i] == -2){
            if(save == -1){
                save = i;
                for(int j=save-1; j>=0; j--) nos[j] = save;
            }
            save = i;
        }
        else{
            nos[i] = save;
        }
    }
    rep(i, h){
        if(nos[i] != -2){
            rep(j, w) ans[i][j] = ans[nos[i]][j];
        }
    }

    rep(i, h){
        rep(j, w) cout << ans[i][j] << (j==w-1 ? "\n":" ");
    }

}

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

using namespace std;
using ll = long long;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> acc(N + 1);
  unordered_map<ll, ll> now;
  now[0]++;
  ll ans = 0;
  for (int i = 1; i <= N; ++i) {
    ll A;
    cin >> A;
    acc[i] = (acc[i - 1] + A - 1) % K;
    if (i >= K) now[acc[i - K]]--;
    ans += now[acc[i]]++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int r, g, b;
    cin >> r >> g >> b;

    int num = r * 100 + g * 10 + b;
    cout << ((num % 4 == 0) ? "YES" : "NO") << endl;

    return 0;
}


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

vector <lli> v ;
int main()
{
    lli h , n , aux ;
    cin >> h >> n ;

    for (lli i = 0 ; i < h ; i++)
    {
        cin >> aux ;
        v.pb(aux) ;
    }

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

    lli i = h - 1 ;

    while (n > 0 && i >= 0)
    {
        n-- ;
        i-- ;
    }

    lli sum = 0 ;

    while (i >= 0)
    {
        sum += v[i] ;
        i-- ;
    }

    cout << sum << endl ;

    return 0 ;
}

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

int main(){
  int n;
  cin >> n;
  while(n != 0){
    int ans = 0;
    int num, sum;
    for(int i = 1; i < n; i++){
      sum = 0;
      num = i;
      while(sum < n){
        sum += num;
        num++;
        //cerr << "sum = " << sum << endl;
      }
      if(sum == n)ans++;
    }
    cout << ans << endl;
    cin >> n;
  }

}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int w, h, n;
    cin >> w >> h >> n;
    vector<vector<bool>> iswhite(w+1, vector<bool>(h+1, true));
    
    /*
    auto show = [&](void) {
        repeat(i, w) {
            repeat(j, h) {
                if ( iswhite[i][j] ) cout << "o ";
                else cout << "x ";
            }
            cout << endl;
        }
    };
    */
    
    auto blackjudge = [](int i, int j, int x, int y, int a) {
        bool res;
        if (a == 1) {
            res = (i < x);
        }
        else if (a == 2) {
            res = (i >= x);
        }
        else if (a == 3) {
            res = (j < y);
        }
        else if (a == 4) {
            res = (j >= y);
        }
        return res;
    };
    
    rep(n) {
        int x, y, a;
        cin >> x >> y >> a;
        repeat_to(i, w) {
            repeat_to(j, h) {
                if( !iswhite[i][j] ) continue;
                if( blackjudge(i, j, x, y, a) ) {
                    iswhite[i][j] = false;
                }
            }
        }
        //show(); cout << endl;
    }
        
    int ans = 0;
    repeat(i, w) {
        repeat(j, h) {
            if( iswhite[i][j] ) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

#n,x = [int(i) for i in readline().split()]
#n = int(input())
n,z,w = [int(i) for i in readline().split()]
a = [w] + [int(i) for i in readline().split()]
n += 1

dps = [0]*(n)+[10**18]
dpg = [0]*(n+1)

for i in range(n-1,0,-1):
    dps[i] = max(max(dpg[j] for j in range(i+1,n+1)),abs(a[-1]-a[i-1]))
    dpg[i] = min(min(dps[j] for j in range(i+1,n+1)),abs(a[-1]-a[i-1]))
    

print(dps[1])
#print(dps)
#print(dpg)

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

int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9){
    cout<<"hon";

  }
  else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
    cout<<"pon";
  }
  else{
    cout<<"bon";
  }
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;

const int N = 1e5 + 5;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s, t;
	cin >> t >> s;
	s += t;
	cout << s << "\n";
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int h;
  cin>>h;
  int c;
  for(int j=0;j<100;j++){
    long long int x=pow(2,j);
    if(h/x==0){
      c=j;
      j=100;
    }
  }
long long int d=pow(2,c)-1;
cout<<d;
  

}


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

inline int get_int()
{
	int x=0,f=1;
	char c;
	for(c=getchar();(!isdigit(c))&&(c!='-');c=getchar());
	if(c=='-') f=-1,c=getchar();
	for(;isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+c-'0';
	return x*f;
}

int main(int argc, char const *argv[])
{
	ll n,a,b,c;
	cin >> n >> a >> b;
	if (a < b) swap(a, b);
	c = a - b;
	if (c%2 == 0){
		printf("%lld\n", c/2);
	}else{
		ll x = min(b, n - a + 1) + (a - b - 1) / 2;
		printf("%lld\n", x);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<climits> //INT_MIN/MAX
using namespace std;

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(ll (i)=(s);(i)>(e);(i)--)
#define MOD 1000000007
#define llong long long
#define debug(x) cout<<#x<<": "<<x<<endl
typedef long long ll;
llong N;

/* 2017/01/18 問題 -----  abc051 a /Link ----- */
/* -----解説等-----
問題:


*/

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


    string S;
    cin >> S;
    FOR(i, 0, 5) {
        cout << S[i];
    }
    cout << " ";
    FOR(i, 6, 13) {
        cout << S[i] ;
    }
    cout << " ";

    FOR(i, 14, 19) {
        cout << S[i] ;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad

calc :: [Int] -> Int -> [Int] -> Bool
calc b c a = c + (foldl1 (+) $ zipWith (*) a b) > 0

main = do
  (n:m:c:_) <- map read . words <$> getLine
  b <- map read . words <$> getLine
  a <- replicateM n $ map read . words <$> getLine
  print $ length . filter (== True) $ map (calc b c) $ a


Measured memory_bytes: 1020
a,b=map(int,input().split())
lista=[]
import fractions
import math
gcd=fractions.gcd(a,b)

for i in range(1,int(gcd**0.5)+1): 
    if gcd% i == 0: 
        lista.append(i)
        if i!=int(gcd/i):
            lista.append(int(gcd/i))

#print(lista)
lista=lista[1:]
lista.sort()
listb=[]
for i in range(len(lista)):
    flag = True
    for j in range(len(listb)):
        if lista[i]%listb[j]==0:
            flag = False    
    if flag==True:
        listb.append(lista[i])

print(len(listb)+1)



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

int main(){
	long long a[200005];
	long long n;
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	} 
	long long Max=-1;
	long long ans=0;
	for(long long i=1;i<=n;i++){
		Max=max(a[i],Max);
		ans+=abs(Max-a[i]);
	}
	cout<<ans;
}

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

int main(){
  string s;
  cin >> s;
  int n=0;
  int k=s.size();
  for(int i=0;i<k;i++){
    if(s.at(i)=='0'){
      n++;
    }
  }
  cout << 2*min(n,k-n) << endl;
}

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


int main() {
	int K, P, N, A;
	cin >> N;

	for (N; N > 0;N--) {
		cin >> K >> P;
		A = K % P;
		if (A == 0) {
			A = P;
		}
		cout << A << endl;

	}
	
	
	
	return 0;
}



Measured memory_bytes: 3104
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	r, b := 0, 0
	for _, ss := range s {
		if ss == 'R' {
			r++
		} else {
			b++
		}
	}
	if r > b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

#define int long long

const int mod = 1e9 + 7;
int nr[100];

main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		
		int bit = 0;
		
		while(x)
		{
			if(x & 1)
			{
				nr[bit]++;
			}
			
			x /= 2;
			bit++;
		}
	}
	
	int res = 0;
	
	for(int i = 0, bit = 1; i <= 61; i++, bit = (bit * 2) % mod)
			res = (res + ((bit * (n - nr[i])) % mod * nr[i]) % mod) % mod;
	
	cout << res;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n; scanf("%d",&n);
	int bry[n-1]; for (int i=0; i<n-1; i++) scanf("%d",&bry[i]);
	
	int sum = bry[0] + bry[n-2];
	for (int i=1; i<n-1; i++) {
		if (bry[i-1] < bry[i]) {
			sum += bry[i-1];
		} else {
			sum += bry[i];
		}
	}
	printf("%d",sum);
	
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int r = scan.nextInt();
        int n = scan.nextInt();
        while (r != 0 || n != 0) {
            for (int s = 0; s < r; s++) {

                for (int i = 0; i < n; i++) {
                    if (s % 2 != 0 && i % 2 != 0 || s % 2 == 0 && i % 2 == 0) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");

                    }
                }
                System.out.println();
            }
            r = scan.nextInt();
            n = scan.nextInt();
            System.out.println();

        }
    }
}



Measured memory_bytes: 36872
#include<stdio.h>
int main()
{
    long long int N,M;
    long long int k;
    scanf("%lld %lld",&N,&M);
    if(N==1)
    {
        if(M==1)
            printf("1\n");
        else
            printf("%lld\n",M-2);
    }
    else if(N==2)
        printf("0\n");
    else
    {
        if(M==1)
            printf("%lld\n",N-2);
        else
        {
            k=M*N-M*2-N*2+4;
            printf("%lld\n",k);
        }
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if (N % 2 == 0) {
      System.out.println(N / 2);
    } else {
      System.out.println(N / 2 + 1);
    }
  }
}


Measured memory_bytes: 35844
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
#define ull_cin(X) scanf("%llu", &X)
#define lf_cin(X) scanf("%lf", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)

#define  ll_cout(X) printf("%lld\n",X)
#define  ull_cout(X) printf("%llu\n",X)



typedef long long  ll;
typedef unsigned long long  ull;

#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion

static char c[101][101];
int main(void) {
	int h,w,i;

	i_cin2(h,w); 
	for (i = 0; i < h; i++) {
		s_cin(c[i]);
	}
	printf("\n");
	for (i = 0; i < h; i++) {
		s_cout(c[i]); s_cout(c[i]);
	}
		
	return 0;
}



//#define _N 1000000000

//int main(void)
//{
//
//	int  n,i;
//	ull   tmp=1;
//
//	i_cin(n);
//
//	for (i = 1; i <= n; i++) {
//		if (!(tmp % ((ull)_N + 7)))
//			tmp = 1;
//		tmp *= (ull)i;
//	}
//	tmp %= ((ull)_N + 7);
//		
//	ull_cout(tmp);
//	return 0;
//}



Measured memory_bytes: 128
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    var input = chunk.split(" ");
    var output = "";
    var num = new Array();
    
    for(var i = 0; i < input.length; i++){
        num[i] = Number(input[i]);
    }
    
    s = num[0] * num[0] * Math.PI;
    l = num[0] * 2 * Math.PI;
    
    console.log(s.toFixed(6) + " " + l.toFixed(6));
});

Measured memory_bytes: 7644
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}



int main() {
	string S;
	int i, j, k;
	//ll N, M, K;
	int N, M, K;

	cin >> S;
	if (S == "ABC")
		cout << "ARC";
	else
		cout << "ABC";

	return 0;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int N, Q;
string S;
 
int main(){
  cin >> N >> Q;
  cin >> S;
  vector<int> L(Q);
  vector<int> R(Q);
 
  vector<int> A(N+1, 0);
 
  for(int i =0; i<N; i++){
    if(S[i] == 'A'){
      if(S[i+1] == 'C'){
        A[i+1] += A[i] +1;
      }else{
        A[i+1] = A[i];
      }
    }else{
      A[i+1] = A[i];
    }
  }
 
 
 
  for(int i = 0; i< Q; i++){
    cin >> L.at(i) >> R.at(i);
  }
 
  for(int i = 0; i< Q; i++){
    cout << A[R.at(i)-1] - A[L.at(i)-1] << endl;
  }
 
  // for(int i = 0; i<N; i++){
  //   cout << A[i] << " ";
  // }
  // cout << endl;
 
 
 
 
 
 
 
 
 
  return 0;
 
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, a,b;
    cin>>n>>a>>b;
    long long prev, cur; long long answer=0;
    cin>>prev;
    for(long long i=1; i<n; i++){
        cin>>cur;
        answer+= min((cur-prev)*a, b);
        prev=cur;
    }
    cout<<answer;

    return 0;
}

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

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

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

    sort(a.begin(), a.end(), greater<int>());

    int countA = 0, countB = 0;
    for (int i = 0; i < n; i += 2)
        countA += a[i];
    for (int i = 1; i < n; i += 2)
        countB += a[i];

    cout << countA - countB << endl;
}

Measured memory_bytes: 3636
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define REP(i,a,n) for(int i = (a); i < (n); i++)
#define ALL(v) v.begin(), v.end()

int main() {
	string S;
	cin >> S;
	int N = S.size();
	int cnt[3] = {};
	rep(i, N) {
		cnt[S[i] - 'a']++;
	}
	rep(i, 3) {
		if (cnt[i]<N / 3 || cnt[i]>(N + 2) / 3) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=100010;
const ll mod=1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
};

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }

  vector<vector<mint>> dp(110, vector<mint>(mx,0));
  vector<mint> r(mx,0);
  dp[0][0]=1;
  
  rep(i,n){
    rep(j,k+1){ r[j+1] = r[j]+dp[i][j]; }
    rep(j,k+1){
      dp[i+1][j] += r[j+1]-r[max(0,j-a[i])];
    }
  }
  ll ans = dp[n][k].x;
  cout << ans << ln;
  return 0;
}

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

int q, t, f, r, i;
char c;
string s;
deque<char> a;

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

    cin >> s >> q;

    for(; i < s.size(); i++)
        a.push_back(s[i]);

    while(q--) {
        cin >> t;
        if(t == 1)
            r = abs(r - 1);
        else if(t == 2) {
            cin >> f >> c;
            if(f == 2) {
                if(r == 0)
                    a.push_back(c);
                else
                    a.push_front(c);
            }
            else {
                if(r == 1)
                    a.push_back(c);
                else
                    a.push_front(c);
            }
        }
    }

    if(r == 0) {
        while(a.size()) {
            cout << a.front();
            a.pop_front();
        }
    }
    if(r == 1) {
        while(a.size()) {
            cout << a.back();
            a.pop_back();
        }
    }
}


Measured memory_bytes: 976
a = int(input())

list=input().split()
list=[int(i) for i in list]

count =0 
counts=0
flag= True
new=[]

while flag==True:
  check=list
  if count>0:
    check=new
    new=[]
  for i in check:
    if i%2 != 0:
      print(count)
      flag=False
      break
    i//=2
    new.append(i)
    counts+=1
    if counts==a:
      counts=0
      count+=1
      break

Measured memory_bytes: 3064
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if(m == -1 && f == -1 && r == -1){
                break;
            }else {
                if(m == -1 || f == -1){
                    System.out.println("F");
                }else if(m + f >= 80){
                    System.out.println("A");
                }else if(m + f >= 65){
                    System.out.println("B");
                }else if(m + f >= 50){
                    System.out.println("C");
                }else if(m + f >= 30 && r >= 50){
                    System.out.println("C");
                }else if(m + f >= 30 && r < 50){
                    System.out.println("D");
                }else{
                    System.out.println("F");
                }
                
            }
        }
    }
}



Measured memory_bytes: 26036
#include<bits/stdc++.h>
#define N 800005
#define upd(x,y,z) x=z((x),(y))
using namespace std;
int n,V,a[N],b[N],ly,s[N][20],p[N][20],f[N],g[N],Ans[N];
int main()
{
	scanf("%d%d",&n,&V);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	while(V>=1)
	{
		b[++ly]=V;V=V/2;
	}
	b[++ly]=0;
	for (int i=n;i>=1;i--)
	{
		for (int j=1;j<=ly;j++)
		{
			if (i==n||a[i+1]-a[i]>b[j]) s[i][j]=i;
			else s[i][j]=s[i+1][j];
		}
	}
	f[0]=0;
	for (int i=0;i<(1<<ly);i++)
	{
		//cout<<i<<' '<<f[i]<<endl;
		for (int j=1;j<=ly;j++)
			if (!(i&(1<<j-1)))
				upd(f[i^(1<<j-1)],s[f[i]+1][j],max);
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=ly;j++)
		{
			if (i==1||a[i]-a[i-1]>b[j]) p[i][j]=i;
			else p[i][j]=p[i-1][j];
		}
	}
	for (int i=1;i<=n+1;i++)
		Ans[i]=n+5;
	for (int i=0;i<(1<<ly);i++)
		g[i]=n+1;
	
	for (int i=0;i<(1<<ly);i++)
	{
		//cout<<i<<' '<<g[i]<<endl;
		for (int j=1;j<=ly;j++)
			if (!(i&(1<<j-1)))
				upd(g[i^(1<<j-1)],p[g[i]-1][j],min);
	}
	for (int i=0;i<(1<<ly);i++)
	if ((i&1)==0)
	{
		//cout<<i<<' '<<(((1<<ly)-1)^i^1)<<endl;
		upd(Ans[f[i]+1],g[((1<<ly)-1)^i^1],min);
	}
	for (int i=n-1;i>=1;i--)
		upd(Ans[i],Ans[i+1],min);
	for (int i=1;i<=n;i++)
	{
		//cout<<s[i][1]<<' '<<Ans[i]<<endl;
		if (i!=1&&s[i][1]==s[i-1][1])Ans[i]=Ans[i-1];
		puts(s[i][1]<Ans[i]-1?"Impossible":"Possible");
	}
}

Measured memory_bytes: 48256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 100000
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, int > pli;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, m;
  cin >> n >> m;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  pli sum[MAX_N];
  sum[0] = make_pair(a[0] % m, 0);
  for(int i = 1; i < n; i++){
    sum[i] = make_pair(
        (sum[i - 1].first + a[i]) % m, i);
  }

  sort(sum, sum + n);

  ll ans = 0;
  ll s = 0;
  for(int i = 0; i < n; i++){
    ans += distance(lower_bound(
          sum, sum + n, make_pair(s, i)),
        upper_bound(sum, sum + n, 
          make_pair(s, n - 1)));
    s = (s + a[i]) % m;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2304
N, W = map(int, input().split())
Ls = [tuple(map(int, input().split())) for _ in range(N)]

INF = float("inf")
dp = [INF] * (10 ** 5 + 1)
dp[0] = 0

mv = 0
for m, v in Ls:
    mv += v
    for i in range(mv, v - 1, -1):
        dp[i] = min(dp[i], dp[i - v] + m)

for i in range(mv, -1, -1):
    if dp[i] <= W:
        print(i)
        break

Measured memory_bytes: 60620
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}



int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{


string s;
cin>>s;
bool f=true;
for(int i=1;i<4;i++)
{
	if(s[i]==s[i-1])
	{
		f=false;
		break;
	}
}

if(f)
cout<<"Good";
else
cout<<"Bad";











}return 0;}

Measured memory_bytes: 256
while True:
    (H,W) = [int(x) for x in input().split()]
    if H == W == 0:
     break

    for h in range(H):
     for w in range(W):
      if h == 0 or h == H - 1 or w == 0 or w == W - 1:
       print("#", end="")
       if w == W - 1:
        print()
        break
      elif not w == 0 and not w == W - 1:
       print(".", end="")

    print()

Measured memory_bytes: 6808
h,w,k = map(int,input().split())
c = [[0]*w for _ in range(h)] #[h][w]
for i in range(h):
    f = input()
    for j in range(w):
        if f[j]=='#':
            c[i][j]+=1
            
yoko = [0]*h
tate = [0]*w
for i in range(h):
    yoko[i]=sum(c[i])
    for j in range(w):
        tate[j]+=c[i][j]
aaa = sum(yoko)
if aaa==k:
    ans=1
    for i in range(h):
        if yoko[i]==0:
            ans*=2
    for j in range(w):
        if tate[j]==0:
            ans*=2
    print(ans)
    exit()
    
ans = 0
for i in range(2**h-1):
    for j in range(2**w-1):
        cnt=0
        check1=[]
        check2=[]
        for n in range(h):
            if (i>>n)&1:
                cnt+=yoko[n]
                check1.append(n)
        for m in range(w):
            if (j>>m)&1:
                cnt+=tate[m]
                check2.append(m)
        for n in check1:
            for m in check2:
                if c[n][m]==1:
                    cnt-=1
        if aaa-cnt==k:
            ans+=1
        

print(ans)

Measured memory_bytes: 9236
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define repb(i, n) for (int i = (int) n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int) m; i < (int) n; i++)
#define repsb(i, m, n) for (int i = (int) m; i >= (int) n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define pb(a) push_back(a)
#define ll long long int
const ll LLINF = 1e18 + 10;
int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return 1; } return 0; }
template < class T > bool chmin(T & a,const T & b) { if (b < a) { a = b; return 1; } return 0; }
//vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));
using namespace std;
int main(int argc, char const * argv[]){
    string s;
    cin>>s;
    int cnt = 0;
    int tmp = 0;
    rep(i, s.size())
    {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G')
        {
            cnt++;
            tmp = max(cnt,tmp);
        }
        else
            cnt = 0;
    }
    cout<<tmp<<endl;
    return 0;
}

Measured memory_bytes: 3608
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
void sleep( double sec = 1021 ){
  clock_t s = clock();
  while( clock() - s < CLOCKS_PER_SEC * sec );
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/

void build(){

}
int n;
void init(){
  n = getint();
}
void solve(){
  int px = 0 , py = 0 , pt = 0;
  while( n -- ){
    int t = getint();
    int x = getint();
    int y = getint();
    int nd = abs( x - px ) + abs( y - py );
    if( nd > (t - pt) or nd % 2 != (t - pt) % 2 ){
      puts( "No" );
      Bye;
    }
    px = x;
    py = y;
    pt = t;
  }
  puts( "Yes" );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>
using namespace std;
 
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
 
const ll INF =1LL << 62;
const int inf =1 << 29;

ll t[2][100005];

int main(){
    ll N,c;
    cin >> N >> c;
    vector<ll> x(N+2),v(N+2);
    rep(i,N) cin >> x[i+1] >> v[i+1];
    x[0] = 0; v[0] = 0;
    x[N+1] = c; v[N+1] = 0;
    //right
    ll ans = 0,st = 0;
    ll lmax=0,rmax=0;
    FOR(i,1,N+1){
        // 右にi個目まで取る。
        st += v[i];
        st -= x[i]-x[i-1];
       // t[0][i] = st;
        ans = max(st, ans);
        rmax = max(rmax,st);
        t[0][i] = rmax;
    }
    //cout << rmax << endl;
    //left
    st = 0;
    x[0] = 0;
    FOR(i,0,N){
        // 左にi+1個目まで取る。
        st += v[N-i];
        st -= (c-x[N-i])-(c-x[N-(i-1)]);
        //t[1][i] = st;
        ans = max(st, ans);
        lmax = max(lmax,st);
        t[1][i] = lmax;
    }
    //cout << lmax << endl;
    //right the left
    st = 0;
    for(int i=1; i<=N && x[i]*2 <= c; i++){
        st += v[i];
        st -= x[i] - x[i-1];
        //cout << i << ": "<< st-x[i]+t[1][N-i-1] << endl;
        ans = max(st-x[i]+t[1][N-i-1],ans);
    }
    // cout << ans << endl;
    //left then right
    st =0;
    for(int i=0; i<N && (c-x[N-i])*2 <= c; i++){
        st += v[N-i];
        st -= (c-x[N-i]) - (c-x[N-(i-1)]);
        //cout << i+1 << ": "<< st-(c-x[N-i])+rmax << endl;
        ans = max(st-(c-x[N-i])+t[0][N-(i+1)],ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
h,w = map(int,input().split())
s = [input() for _ in range(h)]
ans = [[0 for _ in range(w)] for _ in range(h)]
lst = [-1,0,1]

def f(a,b):
    for i in lst:
        for j in lst:
            th = a+i
            tw = b+j
            if 0 <= th <= h-1 and 0 <= tw <= w-1 and s[th][tw] != "#":
                ans[th][tw] += 1 

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            f(i,j)
            ans[i][j] = "#"

for i in range(h):
    print("".join(map(str,ans[i])))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());
using ll = long long;
using P = pair<int, int>;

struct Sieve
{
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1)
  {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i)
    {
      if (f[i])
        continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i)
      {
        if (!f[j])
          f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x; }
  vector<int> factorList(int x)
  {
    vector<int> res;
    while (x != 1)
    {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x)
  {
    vector<int> fl = factorList(x);
    if (fl.size() == 0)
      return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl)
    {
      if (res.back().first == p)
      {
        res.back().second++;
      }
      else
      {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main()
{
  int N;
  cin >> N;
  Sieve sieve(N);
  long long ans = 0;
  rep(i, N)
  {
    vector<P> Ps = sieve.factor(i + 1);
    long long fK = 1;
    rep(j, Ps.size())
    {
      fK *= Ps[j].second + 1;
    }
    ans += (i + 1) * fK;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	int N, i, j;
	scanf("%d", &N);
	char **W = (char **)malloc(sizeof(char *) * N);
	int *L = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		W[i] = (char *)malloc(sizeof(char) * 11);
		scanf("%s", W[i]);
		for(L[i] = 0; W[i][L[i]] != '\0'; L[i]++){}
	}
	for(i = 1; i < N; i++){
//		printf("L[%d] = %d\n", i, L[i]);
		if(W[i - 1][L[i - 1] - 1] != W[i][0]){
//			printf("i = %d\n", i);
			printf("No\n");
			return 0;
		}
	}
	for(i = 0; i < N; i++){
		for(j = i + 1; j < N; j++){
			if(strcmp(W[i], W[j]) == 0){
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void) {
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b)*h / 2;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	while(1){
		ll n; cin >> n;
		if(n==0) break;
		vl x(n),y(n);
		rep(i,n) cin >> x[i] >> y[i];
		bool f[25][25];
		rep(i,21) rep(j,21) f[i][j] = false;
		ll nx = 10, ny = 10;
		f[10][10] = true;
		ll m; cin >> m;
		map<char,ll> mp;
		mp['N'] = 1; mp['E'] = 0; mp['S'] = 3; mp['W'] = 2;
		while(m--){
			char s; ll t; cin >> s >> t;
			REP(i,1,t+1){
				nx += dx[mp[s]];
				ny += dy[mp[s]];
				f[nx][ny] = true;
			}
		}
		ll ans = 0;
		rep(i,n){
			if(f[x[i]][y[i]]) ans++;
		}
		if(ans < n) puts("No");
		else puts("Yes");
	}
}


Measured memory_bytes: 3024
#include <stdio.h>
int main() {
	int n, equal = 0;
	scanf("%d",&n);
	char str[n+1];
	scanf("%s",&str);

	for (int i = 0, j = n/2; i < n; i++,j++)
	{
		if (str[i] == str[j])
		{
			equal++;
		}
	}
	if (n % 2 == 1)
	{
		puts("No\n");
		return 0;
	}
	equal == n/2 ? puts("Yes\n") : puts("No\n");
	return 0;
}

Measured memory_bytes: 1608
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){a%=mod;b%=mod;return a*b%mod;}
inline int power(int a,int b,int MOD){a%=mod;int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
const int MAXN=1e5+5;
vector<int>graph[MAXN];
int distancea[MAXN],distanceb[MAXN];
void dfsa(int start,int parent,int distance)
{
       distance++;
       distancea[start]=distance;
       for(auto &x:graph[start])
        if(x!=parent)
            dfsa(x,start,distance);
}
void dfsb(int start,int parent,int distance)
{
       distance++;
       distanceb[start]=distance;
       for(auto &x:graph[start])
        if(x!=parent)
            dfsb(x,start,distance);
}
signed main()
{
     SPEED;
     int n,u,v;
     cin>>n>>u>>v;
     for(int i=0;i<n-1;i++)
     {
          int from,to;
          cin>>from>>to;
          graph[from].emplace_back(to);
          graph[to].emplace_back(from);
     }
     dfsa(u,-1,-1);
     dfsb(v,-1,-1);
     int res=0;
     for(int i=1;i<=n;i++)
     {
          if(distancea[i]<distanceb[i])
            res=max(res,distanceb[i]-1);
     }
     cout<<res<<endl;
     time();
     return 0;
}

Measured memory_bytes: 11264
N = int(input())

for h in range(1, 3501):
    for n in range(h, 3501):
        q = 4 * h * n - N * h - N * n
        if q <= 0:
            continue
        p = N * h * n
        if p >= q and p % q == 0:
            w = int(p / q)
            print(str(h) + ' ' + str(n) + ' ' + str(w))
            exit()

Measured memory_bytes: 3188