akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;
//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;
int dy[2] = {0, 0};
int dx[2] = {-1, 1};

int n;
vector<pair<int, int> > adj[100050];
int cnt;
vector<int> ret;
vector<bool> visited;

void dfs(int here, int c) {
	if(visited[here]) return;
	visited[here] = true;

	int nc = 0;

	for(int i=0; i<adj[here].size(); ++i) {
		int there = adj[here][i].F;
		int idx = adj[here][i].S;
		if(visited[there]) continue;

		if(nc+1 == c) {
			nc = nc + 2;
		} else {
			nc = nc + 1;
		}

		ret[idx] = nc;
		dfs(there, nc);
	}
}

int main(void) {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL);
	//freopen("in.txt", "r", stdin);
	cin >> n;
	ret.resize(n-1);
	rep(i,0,n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		adj[a].pb(mp(b,i));
		adj[b].pb(mp(a,i));
	}
	cnt = 0;
	rep(i,0,n) {
		cnt = max(cnt, sz(adj[i]));
	}
	visited = vector<bool>(n, false);
	dfs(0,0);

	cout << cnt << endl;
	rep(i,0,sz(ret)) {
		cout << ret[i] << endl;
	}

	return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  vector<vector<int>> G(N);
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    G.at(A-1).push_back(B-1);
    G.at(B-1).push_back(A-1);
  }
  int count=0;
  for(int i=0;i<N;i++){
    bool a=true;
    for(int j=0;j<G.at(i).size();j++){
      int A=G.at(i).at(j);
      if(H.at(i)<=H.at(A)){
        a=false;
      }
    }
    if(a){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 8748
// orz dxm
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define y0 yORZDXM
#define y1 yORZDXM
#define y2 yORZDXM
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;

int n, m, ans = 0;

int main(){
	scanf("%d%d", &n, &m);
	REP(i, 1, n) REP(j, 1, m) ans += (j / 10 >= 2 && j % 10 >= 2 && i == ((j / 10) * (j % 10)));
	printf("%d\n", ans);
	return 0;
}



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


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

int k=1;
int c=0;
int f=0;
for(int i=0;i<n;i++)
{
    if(a[i]==k)
    {
        f++;
        k++;
    } else{
        c++;
    }
}

if(f==0)
{
    cout<<"-1";
} else{
    cout<<c;
}
    return 0;

}


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

int main(){
  int N;
  cin >> N;
  bool a=false;
  for(int i=0;i<9;i++){
    for(int j=0;j<9;j++){
      if(N==(i+1)*(j+1)){
        a=true;
        break;
      }
    }
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
} 

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    ll x,y;cin >> x >> y;
    if(x%y==0)cout << -1;
    else cout << x ;
    cout << endl;
}

Measured memory_bytes: 3644
import java.io.*;
import java.util.*;


public class Main{

   
    public static void main(String[] args) {
    FastReader sc=new FastReader();
    int N=sc.nextInt();
    int[] a=new int[N];
    double sum=0;
    for(int i=0;i<N;i++){
        a[i]=sc.nextInt();
        sum+=a[i];    
    }
  int avg=(int)Math.round(sum/N);
 int mini=0;
 for(int i=0;i<N;i++){
 mini+=Math.pow(a[i]-avg,2);
 }
        System.out.print(mini);
    
    
    }
    
}



class FastReader{
    BufferedReader br ;
    StringTokenizer st;
public FastReader(){
    InputStreamReader inr =new InputStreamReader(System.in);
    br=new BufferedReader(inr);

}

String next(){
    while(st==null || !st.hasMoreElements()){
    try{
    st=new StringTokenizer(br.readLine());
    }
    catch(IOException e){
        e.printStackTrace();
    }}
    return st.nextToken();
}

int nextInt(){
    return Integer.parseInt(next());
}

double nextDouble(){
    return Double.parseDouble(next());

}

long nextLong(){
    return Long.parseLong(next());
}


String nextLine(){
    String str="";
    try{
        str=br.readLine();
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }
    return str;
}
}

Measured memory_bytes: 22864
#include <iostream>
using namespace std;
int main(){
    int k,x;
    cin>>k>>x;
    long long a=max((x-k+1),-1000000);
    long long b=min((x+k-1),1000000);
    while(a<=b){
        cout<<a<<" ";
        a++;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
x,y = map(int,input().split())

if x <= 0 or x >= 13 or y <= 0 or y >= 13:
    sys.exit()
if x >= y:
    sys.exit()

A = (1, 3, 5, 7, 8, 10, 12)
B = (4, 6, 9, 11)

if x == 2 or y == 2:
    print("No")
    sys.exit()
if x in A and y in A:
    print("Yes")
elif x in B and y in B:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin>>n>>x;
  int c=1;
  int s=0;
  for(int i=0;i<n;i++){
    int l;
    cin>>l;
    s+=l;
    if(s<=x)
      c++;
    else
      break;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

const int MAX = 510000; //nCrのr
//const ll INF = (ll)1e18 + 1;

#include <cassert>
long long fac[MAX], finv[MAX], inv[MAX], facn[MAX];
class mint {
public:
    long long x;
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    //mint operator-() const{ return mint(-x);}
    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 {
        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;
    }

};

ll combination(ll n, ll r) {
  if (r < 0 || r > n) return 0;
  if ( r * 2 > n ) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  for (ll i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
int main(){
  int N, P; cin >> N >> P;

  vector<int> a(N);
  rep(i, N) cin >> a[i];
  vector<int> que(2, 0);
  rep(i, N) que[a[i] % 2]++;
  int n = que[0], m = que[1];
  ll ans = pow(2, n);
  if (P == 0){
    ll tmp = 0;
    for (int i = 0; 2 * i <= m; ++i){
      tmp += combination(m, 2 * i);
    }
    ans *= tmp;
  }
  else {
    ll tmp = 0;
    for (int i = 0; 2 * i - 1 <= m; ++i){
      tmp += combination(m, 2 * i - 1);
    }
    ans *= tmp;
  }
  cout << ans << endl;
}


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

int main(void)

{	
	int i,n;
	int henka[200]={0};
	char str[200];
	scanf("%d %s",&n,str);
	
	for(i=0;i<=n-1;i++){
		if(str[i]=='I'){
			henka[i+1]=henka[i]+1;
		} else{
			henka[i+1]=henka[i]-1;
		}
	}
	
	for(i=0;i<=n-1;i++){
		if(henka[i]>=henka[i+1]){
			henka[i+1]=henka[i];
		} else{
			henka[i+1]=henka[i+1];
		}
	}
	
	printf("%d\n",henka[n]);
	return 0;
}

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

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i);
    if (i < vec.size() - 1)
    {
      cout << ", ";
    }
  }
  cout << "]...size: " << vec.size() << endl;
}

int main()
{
  int n;
  cin >> n;
  vector<int> vec(n);

  rep(i, n)
  {
    int x, y, b, p;
    cin >> x >> y >> b >> p;

    int normal_sum = x * b + y * p;

    if (b >= 5 && p >= 2)
    {
      vec.at(i) = normal_sum * 0.8;
    }
    else
    {
      int discount_sum = (x * max(5, b) + y * max(2, p)) * 0.8;
      vec.at(i) = min(normal_sum, discount_sum);
    }
  }

  rep(i, n)
  {
    printf("%d\n", vec.at(i));
  }
}



Measured memory_bytes: 3160
/* AOJ (Aizu Online Judge) My Practice
 * Author: Leonardone @ NEETSDKASU
 */
#include <stdio.h>

int main(void) {
    
    int s = 0, t = 0, i, x;
    
    for (i = 0; i < 4; i++) {
        scanf("%d", &x);
        s += x;
    }

    for (i = 0; i < 4; i++) {
        scanf("%d", &x);
        t += x;
    }
    
    printf("%d\n", t > s ? t : s);
    
    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int dsum(long long int x){
    int ret = 0;
    while(x>0){
        ret+= x%10;
        x/=10;
    }
    return ret;
}
int main(){
    vector<long long> a;
    vector<long long> b;
    for(int i=1;i<100;++i){
        a.push_back(i);
        b.push_back(dsum(i));
    }
    for(int i=0;i<16;++i){
        for(int j=100;j<1000;++j){
           long long x=j;
           for(int k=0;k<i;++k){
               x=x*10+9;
           }
           a.push_back(x);
           b.push_back(dsum(x));
        }
    }
    long long mia=-1,mib;
    vector<long long> c;
    for(int i=a.size()-1;i>=0;--i){
       if(mia>0 && a[i]*mib > mia*b[i]){
       }
       else{
            mia = a[i];
            mib = b[i];
            c.push_back(a[i]); 
       }
    }
    //for(int i=c.size()-1;i>=0;--i)
    //    cout<<c[i]<<endl;
    reverse(c.begin(),c.end());
    //for(int i=0;i<100000;++i)
    //    cout<<a[i]<<" "<<b[i]<<endl;
    int k;
    //for(int i=1;i<a.size();++i){
    //    //cout<<a[i]<<" ";
    //    if(a[i]*b[i-1] < a[i-1]*b[i]){
    //        cout<<"!!!"<<endl;
    //        cout<<a[i-1]<<" "<<a[i]<<endl;
    //    }
    //}
    cin>>k;
    for(int i=0;i<k;++i){
        cout<<c[i]<<"\n";
    }
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] X = new int[N];
        int[] x = new int[N];
        for(int i=0;i<N;++i)X[i]=scan.nextInt();
        for(int i=0;i<N;++i)x[i]=X[i];
        Arrays.sort(x);
        int bef = x[N/2 -1];
        int aft = x[N/2];
        for(int i=0;i<N;++i)System.out.println((X[i]<=bef ? aft:bef));
}
}

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


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

    int max = 0;
    int cnt = 0;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
            if (i == s.length() - 1) {
                if (cnt > max) max = cnt;
            }
        }
        else {
            if (cnt > max) max = cnt;
            cnt = 0;
        }
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 mod=1e9+7;
const int INF=1001001001;

int dp[105][5][1005];
int main() {
  string S;
  int K;
  cin>>S>>K;
  int N=S.size();
  dp[0][0][0]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<1000;k++){
        if(dp[i][j][k]==0){continue;}
        int lim=j?9:S[i]-'0';
        for(int d=0;d<lim+1;d++){
          if(d==0){(dp[i+1][j||(d<lim)][k]+=dp[i][j][k])%=mod;}
          else{(dp[i+1][j||(d<lim)][k+1]+=dp[i][j][k])%=mod;}
        }
      }
    }
  }
  cout<<(dp[N][0][K]+dp[N][1][K])<<endl;
  return 0;  
}

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

char arr[1001][1001];
long long int mod = 1e9+7;
int res=0;

int helper(int n, int w){

    int dp[n+1][w+1];
    dp[n][w]=1;

    for(int i=n;i>=1;i--){
        for(int j=w;j>=1;j--){

            if(i == n and j == w ) continue;

            if(arr[i][j] == '#' ) dp[i][j] = 0;
            else dp[i][j] = (((i == n) ? 0 : dp[i+1][j] )+ (( j == w) ? 0 : dp[i][j+1]) )% mod  ;
        }
    }

    return dp[1][1];
}

void solve(){

    int n,w;
    cin>>n>>w;

    for( int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            cin>>arr[i][j];
        }
    }

    cout<<helper(n,w);
}

int main() {
    solve();
}

Measured memory_bytes: 8476
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;
typedef long long ll;
ll a,b,c,i,j,k,n,m,t;

int main(){
	string a,b;
	cin>>a>>b;
	cout<<b<<a;
	return 0;
}


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

int main() {
  long long X,Y;
  cin >> X >>Y;
  int c = 1;
  for(int i = 0;2*X<=Y;i++){
    c++;
    X = X*2;
   if(X>=Y) break; 
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Min(a,b,c) min((a),min((b),(c)))
#define Max(a,b,c) max((a),max((b),(c)))
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define N 300005
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi 3.14159265359
using namespace std;
typedef long long LL;
int cap[305][305];       
int q[305], *qf, *qb;  
int p[305];            
 
int Edmonds_Karp(int s, int t)
{
    int f = 0;     
    while (true) 
    {
        memset(p, -1, sizeof(p));
        qf = qb = q;
        p[*qb++ = s] = s;
        while (qf < qb && p[t] == -1)
            for (int i = *qf++, j = 0; j < 305; ++j)
                if (p[j] == -1 && cap[i][j])
                    p[*qb++ = j] = i;
        if (p[t] == -1) break;
 
        int df = 1e9;
        for (int i = p[t], j = t; i != j; i = p[j = i])
            df = min(df, cap[i][j]);
        for (int i = p[t], j = t; i != j; i = p[j = i])
            cap[i][j] -= df, cap[j][i] += df;
        f += df;
    }
    return f;
}
int main()
{
	int h,w;
	scanf("%d %d",&h,&w);
	MEM(cap);
	char c[105][105];
	int x,y,x1,y1;
	for(int i=1;i<=h;i++){
		scanf("%s",c[i]+1);
		for(int j=1;j<=w;j++){
			if(c[i][j]=='o'){
				cap[i][j+100]=1;
				cap[j+100][i]=1;
			}
			else if(c[i][j]=='S'){
				cap[0][i]=1e9;
				cap[0][j+100]=1e9;
				x=i;y=j;
			}
			else if(c[i][j]=='T'){
				cap[i][201]=1e9;
				cap[j+100][201]=1e9;
				x1=i;y1=j;
			}
		}
	}
	if(x==x1||y==y1)
	printf("-1\n");
	else{ 
		printf("%d\n",Edmonds_Karp(0,201));
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>

int main()
{
    std::string s;
    std::cin >> s;
    if(s[0] == 'R')
    {
        std::cout << "Sunny";
    }
    else if(s[0] == 'S')
    {
        std::cout << "Cloudy";
    }
    else if(s[0] == 'C')
    {
        std::cout << "Rainy";
    }
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 2e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n;
int a[maxx], b[maxx];

int main() {
	scanf("%d", &n);
	int maxT = 0;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		b[i] = a[i];
		maxT = max(maxT, a[i]);
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++) {
		if(a[i] == maxT) cnt++;
	}
	if(cnt > 1) {
		for(int i = 1; i <= n; i++) printf("%d\n", maxT);
	}
	else {
		sort(b + 1, b + n + 1);
		for(int i = 1; i <= n; i++) {
			if(a[i] != maxT) printf("%d\n", b[n]);
			else printf("%d\n", b[n - 1]);
		}
	}
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];

    int rec=1;
    int ans=0;
    rep(i,n-1){
        if(a[i] == a[i+1]){
            ++rec;
        }
        else{
            ans += rec/2;
            rec = 1;
        }
    }
    ans += rec/2;
    cout<<ans;
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int s;
    scanf("%d",&s);
    int flag=0;

    if(s/1000 == s%1000/100 || s%1000/100 == s%100/10 || s%100/10 == s%10){
        flag=1;
    }
    if(flag){
        printf("Bad\n");
    }else{
        printf("Good\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int n, sum;
long long a[100005];

int main(){
	scanf("%d", &n);
	sum = n;
	int l = 0;
	for(int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	sort(a + 1, a + n + 1);
	a[0] = 0;
	for(int i = 1; i < n; i++){
		a[i] += a[i - 1];
		if((2 * a[i]) < a[i + 1]){
			sum -= (i - l);
			l = i;
		}
	}
	printf("%d", sum);
}
		
			







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

int main()
{


    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    int x, y;
    double width, height, area;
     
    area = 0;

    cin>>width>>height>>x>>y;

    area = (width * height) /2;  
     printf( "%f " , area);  
   
             
    if(2*x==width && 2*y==height) 
    {
    	cout<<1<<endl;
    }
	else
	{
     	cout<<0<<endl;  
	}
}

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

int main(){
  long N, H, max=0;
  cin >> N;
  cin >> H;
  max = H-1;
  for(int i=1; i<N; i++){
    cin >> H;
    if(max<H-1){
      max = H-1;
    }
    else if(max>H){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n;
	cin>>n;
	vector<vector<P>> talk(n);
	rep(i,n){
		int a;
		cin>>a;
		rep(j,a){
			int x,y;
			cin>>x>>y;
			x--;
			talk[i].push_back(P(x,y));
		}
	} 
	int ans=0;
	rep(bit,(1<<n)){
		vector<int> person(n,0);
		int res=0;
		rep(i,n){
			if(bit&(1<<i))person[i]=1,res++;
		}
		rep(i,n){
			if(!(bit&(1<<i))) continue;
			rep(j,talk[i].size()){
				int x=talk[i][j].first, y=talk[i][j].second;
				if(y==1 && person[x]==0)res=0;
				if(y==0 && person[x]==1)res=0;
			}
		}
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> field = new ArrayList<>(Arrays.asList(0,0,0));
		long scoreCount = 0;
		int outCount = 0;
		int finishedGame = 0;
		try {
			int gameNumber = Integer.parseInt(br.readLine());
			while (finishedGame < gameNumber) {
				String line = br.readLine();
				if(line== null) {
					break;
				}
				if(line.equals("HIT")) {
					if(field.get(2)==1) {
						scoreCount++;
					}
					field.remove(2);
					field.add(0, 1);
				}else if(line.equals("OUT")) {
					outCount++;
					if (outCount == 3) {
						System.out.println(scoreCount);
						scoreCount = 0;
						outCount = 0;
						field = new ArrayList<>(Arrays.asList(0,0,0));
						finishedGame++;
					}
				}else if(line.equals("HOMERUN")) {
					scoreCount += 1 + field.stream().filter(base -> base==1).count();
					field = new ArrayList<>(Arrays.asList(0,0,0));
				}
			}
			
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 30684
/*
	Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1000000000;

#define pii pair < int, int >
#define vi vector < int >
#define vvi vector < vector < int > >
#define vpii vector < pair < int, int > >
#define vvpii vector < vector < pair < int, int > > >
#define pb push_back
#define f first
#define s second
#define mp make_pair

int main()
{
	string str;
	cin >> str;
	ll a=0, b=0;
	for(char x: str)
	{
		if(x == 'A')
			a++;
		if(x == 'B')
			b++;
	}
	if(a && b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

using namespace std;

#define ll long long

int main() {
  ll int a, b, x;
  cin >> a >> b >> x;
  if(a!=0) {
    a = (a-1)/x + 1;
  }
  cout << (b/x+1) - a << endl;

  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm> 
#include <bits/stdc++.h>
using namespace std;

void OddString(string s){
  for(int i = 0; i < s.size(); i+= 2){
    cout << s.at(i);
  }
}

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

  OddString(s);
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> A(n + 1);
    for (int x = 1; x <= 100; x++){
        for (int y = 1; y <= 100; y++){
            for (int z = 1; z <= 100; z++){
                int a = x * x + y * y + z * z + x * y + y * z + z * x;
                if (a > n)
                    continue;
                A[a]++;
            }
        }
    }

    for (int i = 1; i <= n; i++)
        cout << A[i] << endl;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
const int N = 2e5 + 5;
char str[N];
int n;
long long ans;
int cnt[26];
int main(){
	scanf("%s" , str + 1);
	n = strlen(str + 1);
	ans = 1;
	memset(cnt , 0 , sizeof(cnt));
	for(int i = 1 ; i <= n ; ++i){
		ans += i - 1 - cnt[str[i] - 'a'];
		++cnt[str[i] - 'a'];
	}
	printf("%lld\n" , ans);
}

Measured memory_bytes: 384
n,m,x,y= map(int,input().split())
lix=list(map(int,input().split()))
liy=list(map(int,input().split()))
lix.append(x)
liy.append(y)
lix.sort()
liy.sort()
if lix[n] < liy[0]:
  print("No War")
else:
  print("War")


Measured memory_bytes: 3060
n = int(input())
a = [int(x) for x in input().split()]
maxa = max(a)
mina = min(a)
if maxa - mina == 0:
    if maxa <= n // 2 or maxa == n - 1:
        print("Yes")
    else:
        print("No")
elif maxa - mina == 1:
    loneCatNum = len([x for x in a if x == mina])
    if loneCatNum + 1 <= maxa and maxa <= (n + loneCatNum) / 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

int main()
{
  long long int n;
  cin>>n;
  for(long long int i=sqrt(n);i>=1;i--)
  {
    if(n%i==0)
    {
      cout<<(i+n/i-2);
      return 0;
    }
  }
}   


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {
        
        public static void Main() {
            var A = NextInt();
            var B = NextInt();

            Console.WriteLine(Enumerable.Range(A, B - A + 1).Select(x => x.ToString()).Count(x => x[0] == x[4] && x[1] == x[3]));
        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 15444
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

/*bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) { // 素数ではない
			return false;
		}
	}
	// 素数である
	return true;
}*/
/*ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/
/*ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}*/
/*ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}*/
/*ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}*/
//printf("%.10f\n", n);

signed main() {
	string s, t;
	ll n, m, k, q, a = 0, b = 0, c = 0, d, x, y, ans = 0;
	cin >> n >> d;
	rep(i, n) {
		cin >> x >> y;
		ld e = pow(x, 2) + pow(y, 2);
		if (sqrt(e) <= d) { ans++; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n,l;
    cin>>n>>l;
    int aji=0;
    rep(i,n){
        aji+=l+i;
    }
    int naji=100000000;
    int k=0;
    int max=0;
    rep(i,n){
        rep(j,n){
            if(i!=j)k+=l+j;
        }

        if(naji>abs(aji-k)){
            naji=abs(aji-k);
            max=k;
        }
        k=0;
    }

    cout<<max<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 106
#define mod 1000000007
int dp[N][N],n,s[N],st[N],v[N],v2[N],ct,as=1;
int pw(int a,int p){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&s[i]),v[i]=s[i];
	sort(v+1,v+n+1);
	v[0]=1;for(int i=1;i<=n;i++)if(v[i]!=v[i-1])v2[++ct]=v[i];
	for(int i=1;i<=n;i++)for(int j=1;j<=ct;j++)if(s[i]==v2[j])st[i]=j;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	if(s[i]==1)
	{
		int su=0;
		for(int j=0;j<=ct+1;j++)su=(su+dp[i-1][j])%mod;
		as=2ll*as*su%mod;
		dp[i][0]=1;
	}
	else if(s[i-1]<=1)
	{
		for(int j=1;j<=st[i];j++)
		dp[i][j]=pw(2,s[i]-v2[j-1]+(j>1));
		dp[i][st[i]+1]=2;
		for(int j=1;j<=st[i];j++)dp[i][j]=(dp[i][j]-dp[i][j+1]+mod)%mod;
	}
	else if(s[i]<=s[i-1])
	{
		for(int j=1;j<=st[i-1]+1;j++)
		if(j>st[i])dp[i][st[i]+1]=(dp[i][st[i]+1]+2ll*dp[i-1][j])%mod;
		else dp[i][j]=dp[i-1][j];
	}
	else
	{
		for(int j=1;j<=st[i-1];j++)dp[i][j]=1ll*dp[i-1][j]*pw(2,s[i]-s[i-1])%mod;
		for(int j=st[i-1]+1;j<=st[i];j++)dp[i][j]=2ll*dp[i-1][st[i-1]+1]*pw(2,s[i]-v2[j-1])%mod;
		dp[i][st[i]+1]=2ll*dp[i-1][st[i-1]+1]%mod;
		for(int j=st[i-1]+1;j<=st[i];j++)dp[i][j]=(dp[i][j]-dp[i][j+1]+mod)%mod;
	}
	int su=0;
	for(int j=0;j<=ct+1;j++)su=(su+dp[n][j])%mod;
	as=1ll*as*su%mod;
	printf("%d\n",as);
}//

Measured memory_bytes: 256
#include <bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v)              \
  cerr << #v ":[ ";          \
  for (auto macro_vi : v)    \
  {                          \
    cerr << macro_vi << " "; \
  }                          \
  cerr << "]" << endl;
#define ddump(v)                     \
  cerr << #v ":" << endl;            \
  for (auto macro_row : v)           \
  {                                  \
    cerr << "[";                     \
    for (auto macro__vi : macro_row) \
    {                                \
      cerr << macro__vi << " ";      \
    }                                \
    cerr << "]" << endl;             \
  }
#define damp(m)                                                   \
  for (auto macro_pair : m)                                       \
  {                                                               \
    cerr << macro_pair.first << ":" << macro_pair.second << endl; \
  }
#define dpair(p) cerr << #p ":" \
                      << "(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define itr(macro_v, i) macro_v.begin() + i
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

struct edge
{
  int id = -1;
  int to = -1;
  edge(int _id, int _to)
  {
    id = _id;
    to = _to;
  }
};
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<edge>> G(n, vector<edge>(0, edge(-1, -1)));
  rep(i, n - 1)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(edge(i, b));
    G[b].push_back(edge(i, a));
  }
  vector<int> color(n - 1, -1);

  int ans = 0;
  queue<int> que;
  int edge_num = G[0].size();
  ans += edge_num;
  int use = ans;
  d(use);
  for (auto e : G[0])
  {
    color[e.id] = use;
    use--;
    que.push(e.to);
  }

  while (!que.empty())
  {
    int c_node = que.front();
    d(c_node);
    que.pop();
    int edge_num = G[c_node].size();
    d(edge_num);
    edge_num--;
    int plus = max(0, edge_num - ans + 1);
    ans += plus;
    int to_edge_color = -1;
    for (auto e : G[c_node])
    {
      if (color[e.id] != -1)
      {
        to_edge_color = color[e.id];
      }
    }
    int use = ans;
    d(use);
    for (auto e : G[c_node])
    {
      if (color[e.id] == to_edge_color)
      {
        continue;
      }
      if (use == to_edge_color)
      {
        use--;
      }
      color[e.id] = use;
      use--;
      que.push(e.to);
    }
  }
  int ma = 1;
  for (auto x : color)
  {
    ma = max(ma, x);
  }
  cout << ma << endl;
  for (auto x : color)
  {
    cout << x << endl;
  }
  // dump(color);
  return 0;
};

Measured memory_bytes: 7040
#![allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

fn main() {
   input! {
      m: usize,
      k: usize,
   }

   if k >= 1 << m {
      println!("-1");
      return;
   }
   if m == 0 {
      if k == 0 {
         println!("0 0");
      } else {
         println!("-1");
      }
      return;
   }
   if m == 1 {
      if k == 0 {
         println!("1 1 0 0");
      } else {
         println!("-1");
      }
      return;
   }

   for i in 0..1 << m {
      if i != k {
         print!("{} ", i);
      }
   }
   print!("{} ", k);
   for i in (0..1 << m).rev() {
      if i != k {
         print!("{} ", i);
      }
   }
   println!("{}", k);
}


Measured memory_bytes: 2128
def resolve():
	S=input()
	Slist=[int(i) for i in list(S)]
	N=len(S)
	
	if N%2==0:
		s1='10'*(N//2)
		s2='01'*(N//2)
	else:
		s1='10'*(N//2)+'1'
		s2='01'*(N//2)+'0'
	s1List=[int(i) for i in list(s1)]
	s2List=[int(i) for i in list(s2)]
	
	print(min(sum([1 for i in range(N) if Slist[i]!=s1List[i]]),sum([1 for i in range(N) if Slist[i]!=s2List[i]])))
resolve()

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  string s;
  cin >> s;
  
  int sum = 0;
  rep(i, s.size()){
    int n;
    if(s[i]=='0') n = 0;
    if(s[i]=='1') n = 1;
    if(s[i]=='2') n = 2;
    if(s[i]=='3') n = 3;
    if(s[i]=='4') n = 4;
    if(s[i]=='5') n = 5;
    if(s[i]=='6') n = 6;
    if(s[i]=='7') n = 7;
    if(s[i]=='8') n = 8;
    if(s[i]=='9') n = 9;
    sum += n;
  }
  
    
    
    
   
  
  
  
    
 
  
  if(sum%9==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
    
}

      
      
       




Measured memory_bytes: 3748
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int main() {
    ll N; cin >> N;
    vi a(N);
    rep (i, 0, N) cin >> a[i];
    vi left(N+1, 0), right(N+1,0);
    rep(i, 0, N) left[i+1] = gcd(left[i], a[i]);
    for (int i = N-1; i >= 0; --i) right[i] = gcd(right[i+1], a[i]);

    int res = 0;
    rep(i, 0, N) {
        int l = left[i];
        int r = right[i+1];
        chmax(res, gcd(l, r));
    }

    cout << res << endl;
  
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h> 

int main(){
  int N,i,j;
  int A[100];

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

  return 0;
}

void trace(int a[],int n){
  int i;
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
}

void insert(int a[],int n){
  int j,i,v;
  for(i=1;i<n;i++){
    v=a[i];
    j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
    trace(a,n);
  }
}    

Measured memory_bytes: 604
main();

function main(){
    var num;
    var str;
    
    for(var i=1;i<=9;++i){
        for(var j=1;j<=9;++j){
            num = i * j;
            str = i + "x" + j + "=" + num;
            console.log(str);
        }
    }
}

Measured memory_bytes: 15376
#include<stdio.h>

int main(){
  int n =0;
  long a[4000] = {};
  long i = 0;
  long long sum = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    sum += a[i];
  }
  printf("%lld",sum-n);
  return 0;
}
  



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}


long long power(long long x, long long n, long long mod = 1000000007) {
    if (n <= 0) return 1;
    if (n % 2 == 0) return power(x * x % mod, n/2, mod);
    else return x * power(x, n-1, mod) % mod;
}

// auto mod int
struct mint {
    LL x;
    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 {
        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(const 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;
    }
    LL operator()() const {
        return x;
    }
};
using VM = vector<mint>;
using VVM = vector<VM>;




void solve() {
    int n;
    cin >> n;
    mint ans = power(10,n);
    ans -= power(9,n) * 2;
    ans += power(8,n);
    cout << ans() << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>

int main() {
	/*
	int n, m;
	scanf("%d%d", &n, &m);
	printf("%d", (n - 1)*(m - 1));
	*/
	/*
	char s[200],o[10];
	int l,i;
	s[0] = '\0';
	o[0] = '\0';

	scanf("%s", s);

	l = strlen(s);
	sprintf(o, "%c%d%c", s[0], l-2,s[l-1]);

	printf("%s", o);
	*/
	/*
	unsigned int n,a[100000],x2=0,x4=0;
	unsigned int i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] % 4==0)
			x4++;
		else if (a[i] % 2==0)
			x2++;
	}
	if (x2 != 0)x2--;
	if (x4 >= (n - x2)/2)
		printf("Yes");
	else
		printf("No");
		*/

	int h, w, n, a[10000],c[10000];
	int i,j,k=0;


	scanf("%d%d", &h, &w);
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);

	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < a[i]; j++) {
			c[k] = i+1;
			k++;
		}
	}

	for (i = 0; i < h; i++) {
		if (i % 2 == 0) {
			for (j = 0; j < w; j++) {
				printf("%d ", c[i*w + j]);
			}
		}
		else {
			for (j = w-1; j >= 0; j--) {
				printf("%d ", c[i*w + j]);
			}
		}
		putchar('\n');
	}

	return(0);
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            var S = int.Parse(Console.ReadLine());
            int h, m, s;
            h = S / 3600;
            m = (S % 3600) / 60;
            s = (S % 60);
            Console.WriteLine("{0}:{1}:{2}", h, m, s);
        }
    }
}


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll a, b;
	cin >> a >> b;

	ll x = 1, y = 1;
	vector<Vec> ans(100, Vec(100, 1));
	rep(i, 50) rep(j, 100) ans[i][j] = 0;

	rep(i, 25){
		if(y == b) break;
		rep(j, 50){
			if(y == b) break;
			ans[i*2][j*2] = 1;
			y++;
		}
	}
	repr(i, 49){
		if(x == a) break;
		rep(j, 50){
			if(x == a) break;
			ans[i*2+1][j*2] = 0;
			x++;
		}
	}

	cosp(100); co(100);
	rep(i, 100){
		rep(j, 100) cout << (!ans[i][j] ? '.' : '#');
		cout << endl;
	}

	return 0;
}


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

#define LL long long
LL n,m, minx=1e9, maxx=0, miny=1e9, maxy=0;
int a,b;
bool valid=false;
bool connect1[300001];
bool connectn[300001];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>a>>b;
        if(a==1){
            connect1[b]=true;
        }
        if(b==n){
            connectn[a]=true;
        }
    }
    
    for(int i=1;i<=n;i++){
        if(connect1[i] && connectn[i]){
            valid=true;
        }
    }
    if(valid){
        cout<<"POSSIBLE"<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}


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

int n, x;
ll b[100001];

ll find(int s) {
	ll res = 0;
	for (int i = s; i > 0; i = i & (i - 1))
		res = max(res, b[i]);
	return res;
}

void update(int s, ll val) {
	for (int i = s; i <= n; i += (i & -i))
		b[i] = max(b[i], val);
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		update(x, find(x - 1) + x);
	}
	printf("%lld\n", (ll)n * (n + 1) / 2 - find(n));
	return 0;
}

Measured memory_bytes: 3972
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        int q = sc.nextInt();
        long[] a = new long[n];
        for(int i=0;i<q;i++){
            a[sc.nextInt()-1]++;
        }
        for(int i=0;i<n;i++){
            if(a[i]+k-q<=0){
                System.out.println("No");
            }
            else{
                System.out.println("Yes");
            }
        }
    }
}

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

void solve(){	
	ll a1,a2 ;
	double b ;
	cin>>a1>>b ;
	a2=a1 ;

	//ll ib=b*100 ;
	ll iib=b*100+0.5 ;
 	//cout<<ib<<" "<<iib<<"\n" ;

	//a1*=ib ;
	a2*=iib ;

	//cout<<a1<<" "<<a2<<"\n"  ;

	//a1=a1/100 ;
	a2/=100 ;

	//cout<<a1<<" "<<a2<<"\n"  ;

	cout<<a2 ;

	/* 
	6500826032929845
	6507473094313209	
	*/
}

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n+1);
    vector<vector<int>> rev(n+1);
    rep(i, n + m - 1) {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        rev[b].push_back(a);
    }
    vector<map<int,int>> visit(n+1);
    vector<int> distance(n+1, 0);
    int root = -1;
    for (int i = 1; i <= n;i++) {
        if (rev[i].size() == 0) {
            root = i;
            break;
        }
    }
    vector<int> parents(n+1, -1);
    function<void(int, int, int)> dfs = [&](int current, int from, int dist) {
        visit[current][from] = dist;
        if (visit[current].size() == rev[current].size()) {
            int u = 0;
            int par = -1;
            for (auto p : visit[current]) {
                if (u < p.second) {
                    par = p.first;
                    u = p.second;
                }
            }
            distance[current] = u;
            parents[current] = par;
            for (auto next : graph[current]) {
                dfs(next, current, u + 1);
            }
        }
    };
    parents[root] = 0;
    distance[root] = 0;
    for (auto next : graph[root]) {
        dfs(next, root, 1);
    }
    for (int i = 1; i <= n; i++) {
        cout << parents[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 36648