akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

template<int mod> struct modint {
  int x;
  modint(): x(0) {}
  modint(int a) { x = a % mod; if (x < 0) x += mod; }
  modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; }
  modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; }
  modint &operator*=(modint that) { x = (i64) x * that.x % mod; return *this; }
  modint &operator/=(modint that) { return *this *= that.inverse(); }
  modint operator-() { return modint(-this->x); }
  friend ostream& operator<<(ostream &out, modint m) { return out << m.x; }
  modint inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return modint(u);
  }
  #define op(o, p) modint operator o(modint that) { return modint(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  #define op(o) bool operator o(modint that) const { return x o that.x; }
    op(==) op(!=) op(<) op(<=) op(>) op(>=)
  #undef op
};

using mint = modint<1000000007>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n, m;
  cin >> n >> m;
  vi32 x(n), y(m);
  rep(i, n) cin >> x[i];
  rep(i, m) cin >> y[i];
  vector<mint> xdist(n - 1), ydist(m - 1);
  rep(i, n - 1) xdist[i] = x[i + 1] - x[i];
  rep(i, m - 1) ydist[i] = y[i + 1] - y[i];
  vector<mint> xsum(n), ysum(m), xrsum(n), yrsum(m);
  partial_sum(all(xdist), xsum.begin() + 1);
  partial_sum(all(xsum), xrsum.begin());
  partial_sum(all(ydist), ysum.begin() + 1);
  partial_sum(all(ysum), yrsum.begin());
  mint xx = 0, yy = 0;
  {
    mint acc = 0;
    rep(i, n - 1) {
      acc += xdist[i];
      xx += acc * (i + 1);
      xx -= xrsum[i];
    }
  }
  {
    mint acc = 0;
    rep(i, m - 1) {
      acc += ydist[i];
      yy += acc * (i + 1);
      yy -= yrsum[i];
    }
  }
  cout << xx * yy << endl;
  return 0;
}


Measured memory_bytes: 3456
import java.util.Scanner;
 
public class Main {
	static final long MOD = 1_000_000_007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		
		long ans = modPow(10, n) - modPow(9, n) - modPow(9, n) + modPow(8, n);
		ans %= MOD;
		ans = (ans + MOD) % MOD;
		
		System.out.println(ans);
		
		sc.close();
	}
	
	static long modPow(long base, long n) {
		long re = 1;
		for (int i = 0; i < n; i++) {
			re = re * base % MOD;
		}
		return re;
	}
}



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

int main(){
  int a, b, ans;
  cin >> a >> b;
  
  
  if(a+b > a-b){
   ans = a+b; 
  }else{
   ans = a-b;
  }
  
  if(ans < a*b){
    ans = a*b;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
int minus[200010],plus[200010];
int a[200010];
int main(){
	int n;
	scanf("%d",&n);
	long long ans=0;
	for(int i=0;i<n;i++)scanf("%d",a+i);
	for(int i=0;i<n;i++){
		if(i+a[i]<=n)ans+=minus[i+a[i]];
		if(i-a[i]>=0)ans+=plus[i-a[i]];
		if(i+a[i]<=n)plus[i+a[i]]++;
		if(i-a[i]>=0)minus[i-a[i]]++;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 4048
import sys
input = sys.stdin.readline

N,M=map(int,input().split())

end=[[] for i in range(N+2)]

for i in [0]*M:
    l,r,a=map(int,input().split())
    end[r+1].append((l,a))

#Starry Sky tree
seg_el=1<<18#Segment treeの台の要素数

SEG=[0]*(2*seg_el-1)#Segment tree.色々考えると0で初期化してOKそう
ADD=[0]*(2*seg_el-1)#加算用Segment tree,SEG[k]+ADD[k]がkにおける本当の最大値
seg_el_list=[524286, 262142, 131070, 65534, 32766, 16382, 8190, 4094, 2046, 1022, 510, 254, 126, 62, 30, 14, 6, 2, 0]

def update(k):#SEGのkより上のノードを更新（反映）
    while k>=0:
        k=(k-1)//2
        if SEG[k]==max(SEG[k*2+1]+ADD[k*2+1],SEG[k*2+2]+ADD[k*2+2]):
            break
        SEG[k]=max(SEG[k*2+1]+ADD[k*2+1],SEG[k*2+2]+ADD[k*2+2])

def to_seg(a):#aが終点となる区間をSegment treeの座標へ変換  
    b=(a&(-a)).bit_length()
    return seg_el_list[b]+a//(1<<(b-1))

def add(a,b,x):#区間(a,b]にxを加算
    #print(a,b,x)
    while b!=0:
        ADD[to_seg(b)]+=x
        update(to_seg(b))
        b-=(b&(-b))

    while a!=0:
        ADD[to_seg(a)]+=-x
        update(to_seg(a))
        a-=(a&(-a))
    
for i in range(N+2):
    for b,k in end[i]:
        add(b,i,k)#点数がもらえる区間から出たときにその分を加算

    SEG[i+seg_el-1]=SEG[0]
    update(i+seg_el-1)

print(SEG[0])

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(auto& e : h) cin >> e;
    sort(begin(h), end(h));
    int ans = 1e9 + 7;
    for(int i = 0;i + k <= n;i++) {
        ans = min(ans, h[i+k-1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
n, m, c = map(int, input().split())
B = list(map(int, input().split()))

ans = 0
for i in range(n):
    A = list(map(int, input().split()))
    s = c + sum([a*b for a, b in zip(A, B)])
    if s > 0:  ans += 1

print(ans)


Measured memory_bytes: 9140
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int s;
    cin >> s;
    int a = s / 100, b = s % 100;
    if (0 < a && a < 13 && 0 < b && b < 13)
        cout << "AMBIGUOUS" << endl;
    else if (0 < a && a < 13)
        cout << "MMYY" << endl;
    else if (0 < b && b < 13)
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
#define ll long long
using namespace std;
static const int INF = (1 << 21);

int main() {
	int p = -1;
	string S, T;
	cin >> S >> T;
	if (S.length() < T.length()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	for (int i = S.length() - T.length();i >= 0;i--) {
		int f = 0;
		for (int j = 0;j < T.length();j++) {
			if (S[i + j] != T[j]&&S[i + j] != '?') f = 1;
		}
		if (f == 0) {
			p = i;break;
		}
	}
	if (p == -1) cout << "UNRESTORABLE" << endl;
	else{
		for (int i = 0;i < S.length();i++) {
			if (i >= p + T.length() || i < p) { if (S[i] == '?') S[i] = 'a'; }
			else { S[i] = T[i - p]; }
		}
		cout << S << endl;
	}

}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
char ch,a[26]="abcdefghijklmnopqrstuvwxyz";
int i,kazu[26]={0};


while(scanf("%c",&ch)!=EOF){
        ch=tolower(ch);

        for(i=0;i<26;i++){
            if(ch==a[i])kazu[i]++;
            }
}

                for(i=0;i<26;i++){
printf("%c : %d\n",a[i],kazu[i]);

}
return 0;
}

Measured memory_bytes: 544
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int main() {
  ios_base::sync_with_stdio(0);
 ll int t, i, j, k, p, q, r, x, y, u, v, n, m;
    t=1;
    //cin>>t;
    while(t--){
    string s;
    cin>>s;
    ll int sum=0;
    for(auto it:s){
        sum+=it-'0';
    }
    //cout<<sum;
    if(sum%9==0)cout<<"Yes";
    else cout<<"No";
    }



  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;

  return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m) {
  int i, u, v;
  while (m--) {
    cin >> u >> v;
    g[u - 1].pb(v - 1);
    g[v - 1].pb(u - 1);
  }
}

void dfs(int u, int par) {
  for (int v : g[u]) {
    if (v == par) continue;
    dfs(v, u);
  }
}





Measured memory_bytes: 10976
N = int(input())
X = [-1] * (N+1)
Y = [0] * 1000
L = [{} for _ in range(N+1)]
k = 2
while k <= N:
    X[k] = 1
    L[k][k] = 1
    for i in range(k*2, N+1, k):
        X[i] = 0
        L[i][k] = 1
    d = 2
    while k**d <= N:
        for i in range(k**d, N+1, k**d):
            L[i][k] += 1
        d += 1
    while k <= N and X[k] >= 0:
        k += 1

for l in L:
    for p in l:
        Y[p] += l[p]

ans = 1
for y in Y:
    ans *= y + 1
print(ans % (10**9+7))


Measured memory_bytes: 3316
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
const int N = 3e5 + 10, mod = 1e9 + 7;
char s[N];
int dp[N][3][3];
int main() {
	scanf("%s", s + 1); int n = strlen(s + 1); dp[0][0][0] = 1;
	for(int i = 1; i <= n; i ++) {
		for(int x1 = 0; x1 < 3; x1 ++) {
			for(int x0 = 0; x0 < 3; x0 ++) if(dp[i - 1][x1][x0]) {
				for(int x = 0; x < 2; x ++) {
					if(s[i] != '?' && x != s[i] - '0') continue ;
					int y1 = x1, y0 = x0;
					if(x == 1) {
						if(y0) y0 --;
						else y1 = y1 == 2 ? 2 : y1 + 1;
					} else {
						y0 = y0 == 2 ? 1 : y0 + 1;
					}
					(dp[i][y1][y0] += dp[i - 1][x1][x0]) %= mod;
				}
			}
		}
	}
	int ans = ((long long) dp[n][1][0] + dp[n][2][0] + dp[n][2][1] + dp[n][2][2]) % mod;
	printf("%d\n", ans);
	return 0;
}
/*
优先级：
(1) 000 -> 0
(2) delete 01 / 10
(3) 111 -> 1
维护111..000栈
0 <= 2, 01删
*/

Measured memory_bytes: 11008
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
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; }

template<typename T>
struct BIT{
    int n;
    vector<T> d;
    BIT(int n = 0):n(n), d(n+1){}
    void add(int i, T x = 1){
        for(i++; i <= n; i += i&-i){
            d[i] += x;
        }
    }
    T sum(int i){
        T x = 0;
        for(i++; i; i -= i&-i){
            x += d[i];
        }
        return x;
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<int> left(n+1, -1);
	vector<vector<int>> Y(n);
	rep(i,n){
		int l = left[a[i]];
		if(l != -1) Y[l].push_back(i);
		left[a[i]] = i;
	}
	vector<vector<P>> querys(n);
	rep(qi,q){
		int l, r;
		cin >> l >> r;
		--l; --r;
		querys[l].emplace_back(r, qi);
	}
	BIT<int> bit(n);
	vector<int> ans(q);
	for(int x = n-1; x >= 0; --x){
		for(int y : Y[x]) bit.add(y, 1);
		for(P query : querys[x]){
			int r = query.first;
			int i = query.second;
			ans[i] = r - x + 1 - bit.sum(r);
		}
	}
	rep(i,q) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 63132
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;


int main()
{
    // 整数の入力
    ll N,M;
    vector<ll> S,T;
    cin >> N >> M;
    for (int i = 0; i < N; i++)
    {
        ll s;
        cin >> s;
        S.push_back(s);
    }

    for (int i = 0; i < M; i++)
    {
        ll t;
        cin >> t;
        T.push_back(t);
    }

    ll **data = new ll*[N+1];
    for (int i = 0;i<=N;i++){
        data[i] = new ll[M+1];
        for(int j = 0;j<=M;j++){
            data[i][j] = 1;
        }
    }
    for (int i = 1;i<=N;i++){
        for(int j = 1;j<=M;j++){
            if(S[i-1] == T[j-1]){
                data[i][j] = (data[i-1][j] + data[i][j-1]) % BASE_NUM;
            }else{
                data[i][j] = (BASE_NUM + data[i-1][j] + data[i][j-1] - data[i-1][j-1]) % BASE_NUM;
            }
        }
    }

    cout << data[N][M] << endl;
    return 0;
}

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

int main(){
  int  N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++)
    cin >> S.at(i);
  sort(S.begin(), S.end());
  for (int i = 0; i < N; i++)
    cout << S.at(i);
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
  if(a < b){
    ll temp = a+b;
    a = temp - a;
    b = temp - b;
  }
  ll c = 1;
  if(b == 0)return a;
  while(c != 0){
    c = a%b;
    if(c == 0)return b;
    a = b;
    b = c;
  }
}
int main(){
    int n;
    cin >> n;
    ll a[n];
    ll GCD;
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    GCD = a[0];
    for(int i = 1;i < n;i++){
        GCD = gcd(GCD,a[i]);
        if(GCD == 1)break;
    }
    cout << GCD << endl;
    //cin >> n;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=0;
b=a/15;
System.out.println(a*800-b*200);
}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
void outputV(vector<int> v) {
  for (int i = 0; i < v.size(); i++) {
    if (i) {
      cout << ' ';
    }
    cout << v[i];
  }
  cout << endl;
}

void outputV(vector<vector<int>> v) {
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v[i].size(); j++) {
      if (j) {
        cout << ' ';
      }
      cout << v[i][j];
    }
    cout << endl;
  }
}

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  vector<int> dp(n,INF);
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
      int index=i+j;
      if(index>=n){
        break;
      }
      int v=dp[i]+abs(h[index]-h[i]);
      dp[index]=min(dp[index],v);
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 4032
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

long long n;
long long sum(long long i) {
    return (i*(i-1))/2;
}
int main() {
    cin >> n;
    long long sum = 0;
    while(n>0) {
        if(n%3 != 0 && n%5!=0) {
            sum+=n;
        }
        n--;
    }
    cout << sum;
}

Measured memory_bytes: 3532
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(){
    char s[100];
    scanf("%s",s);
    int l = strlen(s);
    int count =0;
    int i;
    for(i=0;i<l/2;i++){
        if(s[i]!=s[l-1-i]){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
#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 N;
ll A[202020];
ll B[202020];
ll C[202020];
double E[202020];

template<class C> C veccross(pair<C,C> p1,pair<C,C> p2,pair<C,C> p3) {
	p3.first-=p1.first;p2.first-=p1.first;
	p3.second-=p1.second;p2.second-=p1.second;
	return p3.first*p2.second-p2.first*p3.second;
}

template<class C> vector<int> convex_hull(vector< pair<C, C> >& vp) {
	vector<pair<pair<C, C>, int> > sorted;
	vector<int> res;
	int i,k=0,rb;
	
	if(vp.size()<=2) {
		if(vp.size()>=1) res.push_back(0);
		if(vp.size()>=2 && vp[0]!=vp[1]) res.push_back(1);
		return res;
	}
	
	FOR(i,vp.size()) sorted.push_back(make_pair(vp[i],i));
	sort(sorted.begin(),sorted.end());
	
	res.resize(vp.size()*2);
	/* bottom */
	FOR(i,vp.size()) {
		while(k>1 && veccross(vp[res[k-2]],vp[res[k-1]],sorted[i].first)<=0) k--;
		res[k++]=sorted[i].second;
	}
	/* top */
	for(rb=k, i=vp.size()-2;i>=0;i--) {
		while(k>rb && veccross(vp[res[k-2]],vp[res[k-1]],sorted[i].first)<=0) k--;
		res[k++]=sorted[i].second;
	}
	res.resize(k-1);
	return res;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	FOR(i,N) cin>>B[i];
	x=max_element(A,A+N)-A;
	rotate(A,A+x,A+N);
	rotate(B,B+x,B+N);
	A[N]=A[0];
	B[N]=B[0];
	for(i=1;i<N;i++) C[i+1]=2*C[i]+2*B[i]-C[i-1];
	
	vector<pair<ll,ll>> V;
	FOR(i,N+1) V.push_back({i,A[i]-C[i]});
	auto W=convex_hull(V);
	
	double ret=0;
	FOR(i,W.size()) {
		int L=W[i],R=W[i+1];
		//cout<<L<<":"<<V[L].second<<"  "<<R<<":"<<V[R].second<<endl;
		for(x=L;x<R;x++) {
			//cout<<x<<" "<<(1.0*(V[L].second*(R-x)+V[R].second*(x-L))/(R-L))<<" "<<C[x]<<endl;
			ret+=1.0*(V[L].second*(R-x)+V[R].second*(x-L))/(R-L)+C[x];
		}
		if(R==N) break;
	}
	
	
	_P("%.12lf\n",ret/N);
}


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: 20248
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, n,m , M, K,a;

vector<ll> v,w;
int main(){
    cin >> N;
    ll minn = 0;
    ll ans = 1;
    cin >> n;
    minn = n;
    for(int i = 0; i < N-1 ; ++i){
        cin >>n;
        if(n < minn) {ans += 1;minn = n;}
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=a;s>0?i<n:i>n;i+=s)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>inline bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10, mod = 1e9+7; const long long llinf = 1e18;
// head

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> S(m),C(m);
  for range(i,m){cin >> S[i] >> C[i];}
  for range(i,1000){
    string s = to_string(i);
    // if (i == 702) cout << s << " " << s.length() << endl;
    if (s.length()!= n) continue;
    bool ok = true;
    if (i == 702) {
      // cout << i << endl;
      // cout << 
      }
    for range(j,m){
      int sj = S[j] -1 ; int cj = C[j];
      if (s[sj] - '0'!= cj) {
        ok = false;
        // if (i == 702)cout << s[sj] << " " << cj << (((int)s[sj]) != cj) << endl;
        // cout << s[sj] << " " << cj << endl;
      }
    }
    if (ok) {
      cout << i << endl;
      return 0;
      }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanString()
	fmt.Fprintln(wr, strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(n, "1", "0"), "9", "1"), "0", "9"))
}


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

using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
const ll mod = 1e9 + 9;
const ll maxn = 2e5 + 10;
string s;
bool is_pal(string  t) {
    int len = t.size();
    bool ret = 1;
    _rep(i, 0, len / 2) {
        ret &= (t[i] == t[len - i - 1]);
    }
    return ret;
}
signed main() {
    cin >> s;
    int n = s.size();
    bool okay = 1;
    okay &= is_pal(s);
    okay &= is_pal(s.substr(0, ((n - 1) / 2)));
    okay &= is_pal(s.substr((n + 3) / 2 - 1, n - ((n + 3) / 2 - 1) + 1));
    cout << (okay ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,i,point,max,min,result;
  while(1){
    max = -1;
    min = 1001;
    result = 0;
    scanf("%d",&n);
    if(n==0)break;
    for( i = 0; i < n; i++){
      scanf("%d",&point);
      result += point;
      if(max < point)
	max = point;
      if(min > point)
	min = point;
    }
    result = (result - min - max)/(n-2); 
    printf("%d\n",result);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n,w;
	cin>>n>>w;
	long* weight = new long[n];
	long* cost = new long[n];
	for(int i=0;i<n;i++){
	    cin>>weight[i]>>cost[i];
	}
	int V =0;
	for(int i=0;i<n;i++){
	    V += cost[i];
	}
	long** dp = new long*[n+1];
	for(int i=0;i<=n;i++){
	    dp[i] = new long[V+1];
	}
	for(int i=0;i<=n;i++){
	    dp[i][0]=0;
	}
	for(int i=0;i<=V;i++){
	    dp[0][i]=0;
	}
	for(int i=0;i<=V;i++){
	    dp[1][i]=INT_MAX;
	}
	dp[1][0]=0;
	dp[1][cost[0]]=weight[0];
	for(int i=2;i<=n;i++){
	    for(int j=1;j<=V;j++){
	        dp[i][j] = dp[i-1][j];
	        if(j>=cost[i-1]){
	            dp[i][j] = min(dp[i][j],weight[i-1]+dp[i-1][j-cost[i-1]]);
	        }
	    }
	}
	for(int i=V;i>=0;i--){
	    if(dp[n][i]<=w){
	        cout<<i<<'\n';
	        break;
	    }
	}
 
}

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

int main(){
    int N, P[10];
    cin >> N;
    for(int i=0; i<N; i++) cin >> P[i];
    int ans = accumulate(P, P+N, 0) - *max_element(P, P+N)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include<iterator>
#include <map>
using namespace std;
// bool cmp(long long a, long long b){
//     return a > b;
// }
int main() {
    // ios_base::sync_with_stdio(false);
    long long t, ch, i, h, a, b, l, r, z, p = 1, x, y, weight, j, k = 0, n, m = 1, ch1, q, count, ans = 1e16;
    long long fl;
    string s, s1;
//    cin >> t;
    // long long d, g, w;
    // long long kol = 0, ch2;
//    for (long long test_case = 0; test_case < t; test_case++){
//        cin >> n;
//        for (i )
//        }
//    }
    long long d;
    cin >> x >> k >> d;
    t = ceil((double)abs(x) / (double)d);
    if (t >= k) {
        t = k;
        ans = min(ans, abs(abs(x) - abs(d * t)));
    }else{
        long long check = (k - t);
        if (check % 2 == 0)
            ans = min(ans, abs(abs(x) - abs(d * t)));
        else{
            ans = min(ans, abs(abs(x) - abs(d * t) + d));
            ans = min(ans, abs(abs(x) - abs(d * t) - d));
        }
    }
    cout << ans;
    return 0;
}


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

int main(){
    
    string s;
    int k;
    cin >> s >> k;
    
    int n = 0;
    for(int i = 0;;i++){
        if(s[i]=='1') n++;
        else break;
    }
    
    if(k <= n) cout << 1 << endl;
    else cout << s[n] << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
using ll=long long;
int main(){

  string S;
  cin>>S;
  ll count=0;
  for(size_t i=0;i<=S.length()-1;i++){
  
    if(S[i]=='W')count++;
    else break;
  }
  ll level=0;
  ll ans=0;
  for(size_t i=count;i<=S.length()-1;i++){
    
    if(S[i]=='W'){
    
      ans+=i-count-level;
      level++;
    }
  }
  cout<<ans;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  REP(i, n) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end(), greater<int>());
  
  int diff = 0;
  int sign = 1;
  REP(i, n) {
    diff += a.at(i) * sign;
    sign *= -1;
  }
  
  cout << diff << endl;
  
  return 0;
}

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

int main() {

    string S;
    cin >> S;

    int c_red = 0;
    int c_blue = 0;

    for (int i=0; i<S.length(); i++) {
        if (S[i] == '0') {
            c_red++;;
        }
        else {
            c_blue++;
        }
    }

    cout << S.length() - abs(c_red - c_blue) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#define MAX1 20
#define MAX2 200

int solve(int,int);

int n;
int a[MAX1];
int main(){
   int i,q,k;

    scanf("%d",&n);
    for(i=0;i<n;i++){
       scanf("%d",&a[i]);
    }    
    scanf("%d",&q);
    for(i=0;i<q;i++){
       scanf("%d",&k);
       if((solve(0,k))==1) printf("yes\n");
       else printf("no\n");
    }    
    return 0;


}
//引数mの整数が作れるかどうかを判定
int solve(int i,int m){
    int res;
    if(m==0)
       return 1;
    if(i>=n)
       return 0;

    res=solve(i+1,m) || solve(i+1,m-a[i]);//再帰呼び出し

    return res;
        

}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int main(){
  int t,n,x,y,ans,sx,sy;
  int mp[121][121];
  while(1){
    cin>>t>>n;
    for(int i=0;i<121;i++){
      for(int j=0;j<121;j++){
	mp[i][j]=0;
      }
    }
    ans=0;
    if(t==0 && n==0) break;
    for(int i=0;i<n;i++){
      cin>>x>>y;
      mp[y+60][x+60]=-1;
    }
    cin>>sx>>sy;
    mp[sy+60][sx+60]=1;
    for(int i=1;i<=t;i++){
      for(int j=0;j<121;j++){
	for(int k=0;k<121;k++){
	  if(mp[j][k]==i){
	    for(int l=-1;l<2;l++){
	      if(mp[j+l][k]==0 ){
		mp[j+l][k]=i+1;
		ans++;
	      }
	      if(mp[j][k+l]==0 ){
		mp[j][k+l]=i+1;
		ans++;
	      }
	      if(mp[j+l][k+l]==0 ){
		mp[j+l][k+l]=i+1;
		ans++;
	      }
	    }
	  }
	}
      }
    }
    cout<<ans+1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
using namespace std;
 
int main ()
{
int a, b, t;
cin >> a >> b >> t;
int x = (t + 0.5) / a;
int res = x * b ;
cout << res << endl;
    return 0;
}
// ans = 1 + 1 + - 1 + 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

using namespace std::chrono;

int main(void)
{
    IOS
    const int A = 26;
    const int M = 10000;
    const int TL = 1800;
    auto stime = system_clock::now();
    int D; cin >> D;
    vector<int> c(A);
    REP(i,A) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(A));
    REP(i,D) REP(j,A) cin >> s[i][j];

    vector<int> last(A,-1);
    vector<int> base(D);
    REP(i,D) {
        int mx = 0,a = -1;
        REP(j,A) {
            int tmp = (i-last[j])*c[j] + s[i][j];
            if (mx < tmp) {
                mx = tmp;
                a = j;
            }
        }
        base[i]=a;
        last[a] = i;
    }
    auto calc = [&](const vector<int> &a){
        vector<int> l(A,-1);
        int score = 0;
        REP(i,D) {
            score += s[i][a[i]];
            l[a[i]] = i;
            REP(j,A) {
                score -= c[j]* (i-l[j]);
            }
        }
        return score;
    };

    int basescore = calc(base);
    int maxscore = basescore;
    vector<int> ans(base);

    random_device seed_gen;
    mt19937 engine(seed_gen());
    int loopcount = 0;
    while(true) {
        // time count
        auto time = system_clock::now();
        int t = duration_cast<milliseconds>(time-stime).count();
        if (t >= TL) break;

        int mx = basescore;
        vector<int> a1(base);
        REP(_,M) {
            vector<int> a2(a1);
            a2[engine()%D] = engine() % A;
            int tmp = calc(a2);
            if (mx < tmp) {
                a1=a2;
                mx = tmp;
            }
        }
        if (maxscore < mx) {
            ans=a1;
            maxscore = mx;
        }
        loopcount++;
    }

    //cerr << loopcount << endl;
    REP(i,D) OUT(ans[i]+1)

    return 0;
}

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

int n;
ll dp[MAX*4];
ll height[MAX];
ll beauty[MAX];

void build(int idx, int left, int right) {
    if (left==right) {dp[idx]=beauty[left]; return;}

    int mid=(left+right)/2;
    build(idx*2,left,mid);
    build(idx*2+1,mid+1,right);
    dp[idx]=max(dp[idx*2],dp[idx*2+1]);
}

void update(int idx, int left, int right, int a, ll val) {
    if (left>a || right<a) {return;}
    if (left==right) {dp[idx]=val; return;}

    int mid=(left+right)/2;
    update(idx*2,left,mid,a,val);
    update(idx*2+1,mid+1,right,a,val);
    dp[idx]=max(dp[idx*2],dp[idx*2+1]);
}

ll query(int idx, int left, int right, int a, int b) {
    if (left>=a && right<=b) {return dp[idx];}
    if (left>b || right<a) {return 0;}

    int mid=(left+right)/2;
    return max(query(idx*2,left,mid,a,b),query(idx*2+1,mid+1,right,a,b));
}

int main() {
    cin >> n;
    for (int i=0;i<n;i++) {cin >> height[i];}
    for (int i=0;i<n;i++) {cin >> beauty[i];}

    for (int i=0;i<n;i++) {
        ll mmax=query(1,0,n-1,0,height[i]-1);
        update(1,0,n-1,height[i]-1,mmax+beauty[i]);
    }
    cout << query(1,0,n-1,0,n-1) << endl;
}


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

using namespace std;

typedef long long LL;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define fin "\n"


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

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}

LL calc(vector<LL>& a,LL x){
    int N=a.size();
    LL res=0;
    FOR(i,1,N){
        if(a[i-1]+a[i]>x){
            LL m=a[i-1]+a[i]-x;
            res+=m;
            a[i]-=min(a[i],m);
        }
    }
    return res;
}
int main(){
    LL N,x;
    cin>>N>>x;
    vector<LL> a(N);
    for(auto &it:a)cin>>it;
    auto b=a;
    reverse(a.begin(),a.end());
    cout<<min(calc(a,x),calc(b,x))<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

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

        int n = sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt();

        String str1 = String.valueOf(s.charAt(k-1));
        String replaced = s;

        for (int i = 0; i < n; i++) {
            String str2 = String.valueOf(s.charAt(i));
            if (!str2.matches(str1)){
                replaced = replaced.replace(str2,"*");
            }
        }

        System.out.println(replaced);

        sc.close();
    }
}

Measured memory_bytes: 25172
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class ABC129_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int va[] = new int[3];

            for (int i = 0; i < 3; i++) {
                va[i] = in.nextInt();
            }
            Arrays.sort(va);
            out.println(va[0] + va[1]);

        }

    }
}



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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	int mini = 10000000000, maxi = 0;
	for (auto x : a) {
		if (x < mini)mini = x;
		if (x > maxi)maxi = x;
	}
	cout << maxi - mini << endl;

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int N;
int f[50][50] = {0};

int search(vector<int> &data,int s,int t)
{
    if(f[s][t] == 1)
    {
        return 1;
    }
    int connect = 0;
    
    data[s] = 1;
    for(int i =0;i<N;i++)
    {
        if(f[s][i] == 1 && data[i] == 0)
        {
            connect += search(data,i,t);
            if(connect == 1)
            {
                break;
            }
        }
    }
    
    data[s] = 0;
    return connect;
}

int main()
{
    int M;
    cin >> N >> M;
    vector<pair<int,int>> A;
    for(int i = 0;i<M;i++)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        pair<int,int> p = {a,b};
        A.push_back(p);
        f[a][b] = 1;
        f[b][a] = 1;
    }
    
    int ans = 0;
    for(int i = 0;i<M;i++) //50
    {
        f[A[i].first][A[i].second]=0;
        f[A[i].second][A[i].first]=0;
        
        vector<int> data(N,0);
        ans += (1 - search(data,A[i].first,A[i].second));
        
        f[A[i].first][A[i].second]=1;
        f[A[i].second][A[i].first]=1;
    }
    
    //sort(A.begin(),A.end());
    //int ans = 0;
    
    
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#define H_MAX 500000

int parent(int i){
  return (int)i/2;
}

int left(int i){
  return i*2;
}

int right(int i){
  return i*2+1;
}

void maxHeapify(int *H, int i, int heap_size){
  int l, r, largest, x;
  l = left(i);
  r = right(i);
  
  // Select node whose value is max among left, itself and right node.
  if( l <= heap_size && H[l] > H[i] ) largest = l;
  else largest = i;
  if( r <= heap_size && H[r] > H[largest] ) largest = r;

  if( largest != i ){
    x = H[i];
    H[i] = H[largest];
    H[largest] = x;
    maxHeapify( H, largest, heap_size);
  }
}

void buildMaxHeap(int *H, int heap_size){
  int i;
  for(i = heap_size; i >= 1; i--){
    maxHeapify( H, i, heap_size);
  }
}

int main(){
  int H[H_MAX], heap_size, i;

  scanf("%d",&heap_size);
  for(i = 1; i < heap_size+1; i++){
    scanf("%d",&H[i]);
  }
  buildMaxHeap( H, heap_size);

  for(i = 1; i < heap_size+1; i++){
    printf(" %d",H[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3684
#include <iostream>
#include <set>
#define ll long long
using namespace std;

int main() {
    ll useless;
    cin >> useless;
    string a;
    cin >> a;
    ll length = a.size(), size = 1;
    for(int i =1; i < length; i++) {
        if(a[i] != a[i-1]) size++;
    }
    cout << size << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int D[60];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> D[i];
	}
	D[N] = 0;
	D[N + 1] = 24;
	sort(D, D + N);
	for (int i = 1; i < N; i += 2) {
		D[i] = 24 - D[i];
	}
	sort(D, D + N + 2);
	int ans = 24;
	for (int i = 0; i <= N; i++) {
		ans = min(ans, D[i + 1] - D[i]);
	}
	cout << ans << endl;
}

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

int main(){
    int n;
    cin>>n;
    int a[26],b[26];
    string s;
    cin>>s;
    for(int i=0;i<26;i++) a[i]=0;
    for(int i=0;i<s.size();i++){
        a[s[i]-'a']++;
    }
    for(int i=1;i<n;i++){
        string t;
        cin>>t;
        for(int l=0;l<26;l++) b[l]=0;
        for(int j=0;j<t.size();j++){
            b[t[j]-'a']++;
        }
        for(int k=0;k<26;k++){
            a[k]=min(a[k],b[k]);
        }
        
    }
    bool flg=true;
    for(int i=0;i<26;i++){
        while(a[i]>0){
            cout<<char(97+i);
            flg=false;
            a[i]--;
        }
    }
    if(flg) cout<<endl;
}

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


Measured memory_bytes: 2020
def f_division_or_substraction():
    N = int(input())

    def divisor_list(n):
        """n の正の約数のリスト"""
        ret = set()
        for k in range(1, int(n**0.5) + 1):
            if n % k == 0:
                ret.update({k, n // k})
        return sorted(ret)

    ans = (len(divisor_list(N - 1)) - 1)  # K >= 2 なので、-1 する
    for k in divisor_list(N):
        if k == 1:
            continue
        n = N
        while n % k == 0:
            n //= k
        ans += 1 if n % k == 1 else 0
    return ans

print(f_division_or_substraction())

Measured memory_bytes: 3580
a,b,c = list(map(int,input().split()))

count = 0
for i in range(30):
    if a%2 == 0 and b%2 ==0 and c%2 == 0:
        d = int((a+b)/2)
        e = int((b+c)/2)
        f = int((a+c)/2)
        a,b,c = d,e,f
        count +=1
if count <30:
    print(count)
else:
    print(-1)


Measured memory_bytes: 3060
h,w=map(int,input().split())
c=[list(map(int,input().split())) for i in range(10)]

for k in range(10):
  for i in range(10):
    for j in range(10):
      c[i][j]=min(c[i][j],c[i][k]+c[k][j])

ans=0

for i in range(h):
  li=list(map(int,input().split()))
  for a in li:
    if a!=-1:
      ans+=c[a][1]
print(ans)

Measured memory_bytes: 3064
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let (a, b) = (it.next().unwrap(), it.next().unwrap());

    if (a - b) <= 0 {
        println!("{}", 0);
        return;
    }
    println!("{}", a - b);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
    int n,d,x,a[101]={0},i,j,c=0;
    scanf("%d%d%d",&n,&d,&x);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(i=1;i<=n;i++){
        j=0;
        while((1+(j*a[i]))<=d){
            c++;
            j++;
        }
    }
    c+=x;
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
order = [0] * (n+1)
for i in range(n):
    p = int(input())
    order[p] = i+1
order[0] = 10**9

cnt = 0
ans = 0
for x, y in zip(order[:-1], order[1:]):
    if x > y:
        ans = max(cnt, ans)
        cnt = 0
    else:
        cnt += 1
ans = max(cnt, ans)

answer = n - ans - 1
print(answer)


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

using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  vector<int> east(n, 0);
  vector<int> west(n, 0);
  
  for(int i = 0; i < n - 1; i++){
    if(s[i] == 'E'){
      east[i + 1] = east[i] + 1;
    }else{
      east[i + 1] = east[i];
    }
  }
  
  for(int i = n - 1; i > 0; i--){
    if(s[i] == 'W'){
      west[i - 1] = west[i] + 1;
    }else{
      west[i - 1] = west[i];
    }
  }
  
  int max_see_leader = 0;
  for(int i = 0; i < n; i++){
    int num_of_see_leader = west[i] + east[i];
    if(num_of_see_leader > max_see_leader){
      max_see_leader = num_of_see_leader;
    }
  }
  
  cout << n - 1 - max_see_leader << '\n';
  
  return 0;
}

Measured memory_bytes: 2948
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	scan(N);scan(M);
	int a[51],b[51];
	rep(i,M){
		scan(a[i]);scan(b[i]);
	}
	int count=0;
	rep(i,M){
		int mindis[51][51];
		rep1(j,N){
			rep1(k,N){
				if(j==k) mindis[j][k]=0;
				else mindis[j][k]=INF;
			}
		}
		rep(j,M){
			mindis[a[j]][b[j]]=0;
			mindis[b[j]][a[j]]=0;
		}
		mindis[a[i]][b[i]]=INF;
		mindis[b[i]][a[i]]=INF;
		rep1(l,N){
			rep1(j,N){
				rep1(k,N){
					mindis[j][k]=min(mindis[j][k],mindis[j][l]+mindis[l][k]);
					mindis[k][j]=min(mindis[k][j],mindis[j][l]+mindis[l][k]);
				}
			}
		}
		/*int flag=1;
		prin(i);
		rep1(j,N){
			rep1(k,N){
				printf("%d ",mindis[j][k]);
			}
			kaigyo;
		}*/
		if(mindis[a[i]][b[i]]!=0) count++;
	}
	prin(count);
	return 0;
}


Measured memory_bytes: 256
n = input()
for i in range(n):
	xa,ya,ra,xb,yb,rb = map(float, raw_input().split())
	if abs(ra-rb) <= ((xa-xb)**2+(ya-yb)**2)**0.5 <= ra+rb: print 1
	elif abs(ra-rb) >= ((xa-xb)**2+(ya-yb)**2)**0.5:
		if rb < ra: print 2
		else: print -2
	else: print 0

Measured memory_bytes: 6500
#include<bits/stdc++.h>
using namespace std;
main(void){
    int a,b,c=0;
    cin>>a>>b;
    char s[a+b+1];
    cin>>s;
    if(s[a]!='-'){
            cout<<"No";
            return 0;
    }
    for(int i=0;i<a+b+1;i++){
        if(s[i]=='0'|| s[i]=='1'|| s[i]=='2'|| s[i]=='3'|| s[i]=='4'|| s[i]=='5'|| s[i]=='6'|| s[i]=='7'|| s[i]=='8'|| s[i]=='9' ){
            c++;
        }
    }
    cout<<(c==a+b?"Yes":"No");
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    h, w, a, b = LI()
    ans = [0,1]
    for y in range(h):
        for x in range(w):
            i = (x < a) ^ (y >= b)
            print(ans[i], end="")
        print()
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 121816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n, d;
    cin >> n >> d;
    ll x, y;
    ll ans = 0;
    rep1(i, n){
        cin >> x >> y;
        if (x*x + y*y <= d*d) ans++;
    } 
    cout << ans << endl;
    //printf("%.12f", ans);
}

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

int main(){
    int n;  cin >> n;
    vector<pair<int, int>> r(n), b(n);
    for(int i=0; i<n; i++){
        int a, b;   cin >> a >> b;
        r.at(i) = {a, b};
    }
    for(int i=0; i<n; i++){
        int x, y;   cin >> x >> y;
        b.at(i) = {x, y};
    }

    sort(r.begin(), r.end());   sort(b.begin(), b.end());
    vector<bool> ok(n, false);
    int ans=0;
    
    for(int i=0; i<n; i++){
        int bef=-1;
        for(int j=0; j<n; j++){
            if(ok[j]) continue;
            if(b[i].first<=r[j].first) continue;
            if(b[i].second<=r[j].second) continue;
            if(bef==-1){
                bef = j;
                ok[bef] = true; 
            }else if(r[bef].second<r[j].second){
                ok[bef] = false;
                bef = j;    ok[j] = true;
            }            
        }
    }
    for(auto x: ok) if(x) ans += 1;
    cout << ans << endl;
}




Measured memory_bytes: 256
/*
author:Rahul Chocha
school of eng. and applied science
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define MAXI INT_MAX
#define MINI INT_MIN
#define din(t) long long t; cin >> t;
#define fi(i, l, r, d) for (i = l; i < r; i += d)
#define fd(i, l, r, d) for (i = l - 1; i >= r; i -= d)
#define pb push_back
#define mp make_pair


void speed_up()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}

ll int findMinDiff(ll int arr[], ll int n) 
{ 
   // Sort array in non-decreasing order 
   sort(arr, arr+n); 
  
   // Initialize difference as infinite 
   ll int diff = INT_MAX; 
  
   // Find the min diff by comparing adjacent 
   // pairs in sorted array 
   for (ll int i=0; i<n-1; i++) 
      if (arr[i+1] - arr[i] > diff) 
          diff = arr[i+1] - arr[i]; 
  
   // Return min diff 
   return diff; 
}
int main()
{   
	speed_up();
	//din(t)
	ll t=1;
	while(t--){
      din(n)
      cout<<!n;  
	}

	
}


Measured memory_bytes: 3652