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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

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


template <typename T>
struct BIT {
    int n;             // 要素数
    vector<T> bit[2];  // データの格納先
    BIT(int n_) { init(n_); }
    void init(int n_) {
        n = n_ + 1;
        for (int p = 0; p < 2; p++) bit[p].assign(n, 0);
    }
    void add_sub(int p, int i, T x) {
        for (int idx = i; idx < n; idx += (idx & -idx)) {
            (bit[p][idx] += x) %= MOD;
        }
    }
    void add(int l, int r, T x) {  // [l,r) に加算
        add_sub(0, l, -x * (l - 1));
        add_sub(0, r, x * (r - 1));
        add_sub(1, l, x);
        add_sub(1, r, -x);
    }
    T sum_sub(int p, int i) {
        T s(0);
        for (int idx = i; idx > 0; idx -= (idx & -idx)) {
            (s += bit[p][idx]) %= MOD;
        }
        return s;
    }
	T sum(int i)
	{
		ll res = (sum_sub(1, i) * i) % MOD;
		return (res + sum_sub(0, i)) % MOD;
	}
};

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	BIT<ll> bt(2*100000+10);
	bt.add(1, 2, 1);
	ll N, K; cin >> N >> K;
	
	vector<ll> L(N), R(N);
	REP(i, K) cin >> L[i] >> R[i], R[i]++;
	REP(j, N)
	{
		REP(i, K)
		{
			bt.add(min(j+L[i], N+1), min(j+R[i], N+1), bt.sum(j)-bt.sum(j-1));
		}
	}
	
	std::cout << (bt.sum(N)-bt.sum(N-1)+MOD)%MOD << std::endl;
	return 0;
}


Measured memory_bytes: 9520
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	int n;
	cin >> n;
	string pre,suf;
	cin >> pre >> suf;
	for(int i = 0; i < n; i++){
		string sp,ss;
		for(int j = i; j < n; j++){
			sp += pre[j];
		}
		for(int j = 0; j < n-i; j++){
			ss += suf[j];
		}
		if( sp == ss){
			cout << n + i << endl;
			return 0;
		}
	}
	cout << 2 * n << endl;
	return 0;
}

Measured memory_bytes: 256
N, T = map(int,input().split())
c = []
t = []

for i in range(N):
  c1, t1 = map(int,input().split())
  c.append(c1)
  t.append(t1)
  
ans = []

for i in range(N):
  if t[i] <= T:
    ans.append(c[i])

if len(ans) == 0:
  print("TLE")
else:
  print(min(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <string>	

using namespace std;

int main(){
	int count = 0;
	string w, t;
	cin >> w;
	for (int i = 0; i < w.size(); i++){
		if (65 <= w[i] && w[i] <= 90) w[i] = (char)(w[i] + 32);
	}
	while (1){
		cin >> t;
		if (t == "END_OF_TEXT") break;
		for (int i = 0; i < t.size(); i++){
			if (65 <= t[i] && t[i] <= 90) t[i] = (char)(t[i] + 32);
		}
		if (t == w) count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));
 
const ll mod=1e9 + 7;
 

vector<unordered_set<ll> > g;
vector<ll> vis;
ll sz;
 
void dfs(ll x)
{
    vis[x]=1;
    sz++;
    for(auto y:g[x])
    {
        if(!vis[y]) dfs(y);
    }
}
 
void solve()
{
    ll n,m;
    cin>>n>>m;
 
    g.resize(n);
    vis.resize(n);
 
    while(m--)
    {
        ll x,y;
        cin>>x>>y;
        x--,y--;
        g[x].insert(y);
        g[y].insert(x);
    }
 
    ll ans=1;
 
    f(i,n)
    {
        if(!vis[i])
        {
            sz=0;
            dfs(i);
            ans=max(sz,ans);
        }
    }
    cout<<ans<<"\n";
 
    return;
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    ll t=1;
    clock_t launch=clock();
 
    while(t--)
    {
        solve();
    }
 
    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}

Measured memory_bytes: 37452
package main

import (
	"fmt"
)

func main() {
	var n, t int
	fmt.Scan(&n, &t)

	var minCost int
	for i := 0; i < n; i++ {
		var cost, time int
		fmt.Scan(&cost, &time)

		if time <= t {
			if minCost == 0 {
				minCost = cost
				continue
			}
			if cost < minCost {
				minCost = cost
			}
		}
	}
	if minCost == 0 {
		fmt.Println("TLE")
	} else {
		fmt.Println(minCost)
	}
}


Measured memory_bytes: 512
#include <iostream>


using namespace std;

int main(){
	int H, W;

	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
					cout << "#";
			}
			cout << endl;
		}
		cout << endl;

	}

	return 0;
}

Measured memory_bytes: 1152
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int h,w,dist[1005][1005]={},ans=0,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char c[1005][1005]={};
queue<P> q;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      dist[i][j]=inf;
    }
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> c[i][j];
      if(c[i][j]=='#') {
        dist[i][j]=0,q.push({i,j});
      }
    }
  }
  while(!q.empty()) {
    P p=q.front();
    q.pop();
    for(int i=0; i<4; i++) {
      for(int j=0; j<4; j++) {
        int nx=p.first+dx[i],ny=p.second+dy[i];
        if(0<=nx&&nx<h&&0<=ny&&ny<w) {
          if(dist[nx][ny]>dist[p.first][p.second]+1) {
            dist[nx][ny]=dist[p.first][p.second]+1;
            q.push({nx,ny});
          }
        }
      }
    }
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      ans=max(ans,dist[i][j]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 13328
#import numpy as np
N,K=map(int, input().split())

A=list(map(int, input().split()))
#K=min(K, 30)
for k in range(K):
    B=[0]*(N+1)
    for i in range(N):
        a=A[i]
        start=max(0,i-a)
        end=min(N,i+a+1)
        B[start]+=1
        B[end]-=1
    #B=np.array(B)
    A=[0]*N
    A[0]=B[0]
    for i in range(1,N):
        A[i]=A[i-1]+B[i]

    if min(A)==N:
        break
    #print(B)
    
    
print(*A)


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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXSIZE 2097170

LL dp[25][MAXSIZE];
int arr[25][25];
int n;

void u(LL &x, LL &y){
	x+=y;
	while(x>=MOD)
		x-=MOD;
}

int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	FOR(i,1,n){
		REP(j,n)
			cin>>arr[i][j];
	}
	
	dp[0][0]=1;
	FOR(i,1,n){
		REP(j,1<<n){
			u(dp[i][j],dp[i-1][j]);
			
			if(__builtin_popcount(j)!=i-1)	//submaska dla poprzednich kombinacji
				continue;
			REP(k,n){
				if((((1<<k)&j)!=0)||arr[i][k]==0)
					continue;
				
				u(dp[i][(j|(1<<k))],dp[i-1][j]);
				//cout<<dp[i][(j|(1<<k))]<<"\n";
				//cout<<i<<" "<<(j|(1<<k))<<"\n";
				
			}
		}
	}
	
	cout<<dp[n][(1<<n)-1];
	
	return 0;
}


Measured memory_bytes: 346368
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
bool arr[150];
int main(){
	int n,k;
	cin>>n>>k;
	int sum=0;
	while(k--){
		int d;
		cin>>d;
		for(int i=0;i<d;i++){
			int x;
			cin>>x;
			arr[x]=true;
		}
	}
	for(int i=1;i<=n;i++){
			if(!arr[i]) sum++;
	}
	cout<<sum<<endl;
	 
	return 0;
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    int a, b, c, x, y, ans = INF;
    cin >> a >> b >> c >> x >> y;
    for (int i = 0; i <= 2 * max(x, y); ++i) {
        ans = min(ans, c * i + a * max(0, x - i / 2) + b * max(0, y - i / 2));
    }
    cout << ans << endl;

    return 0;
}

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

int main(void)
{
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a+b>c+d)
    printf("Left\n");
  else if(a+b<c+d)
    printf("Right\n");
  else
    printf("Balanced\n");
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int	main(void)
{
  	int	n;
  	int m;
  	int a[101];
  	int	i;
  	int num;
  	long long	sum;
  	double th;
  	int cnt;
  
  	num = scanf("%d %d\n", &n, &m);
 	if (num != 2)
      	return (0);
  
  	sum = 0;
  	for(i=0;i<n;i++)
    {
      	num = scanf("%d", &a[i]);
      	if (num != 1)
          	return (0);
      	sum += a[i];
    }
  
  	th = (double)sum / 4 / m;
  
  	cnt = 0;
  	for(i=0;i<n;i++)
    {
      	if (a[i] >= th)
          	cnt++;
    }
  	if (m <= cnt)
      	printf("Yes");
  	else
      	printf("No");
  	return (0);
  
}

Measured memory_bytes: 128
#include <stdio.h>

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


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll mod=1e9+7 ;
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; }
//-------------------
ll a[100000+5];

int main() {
	int n;
	scanf("%d", &n);
	multiset<int> M;
	FOR(i,1,n) {
		ll x;
		scanf("%lld", &x);
		auto it=M.lower_bound(x);
		if(it==M.begin()) M.insert(x);
		else {
			it--;
			M.erase(it);
			M.insert(x);
		}
	}
	cout<<M.size()<<endl;
	
}

Measured memory_bytes: 4992
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int num=scan.nextInt();
    int order[]=new int[num];
    int lev[]=new int[num];
    int plus[]=new int[num-1];
    int Ans=0;
    for(int a=0; a<num; a++){
      order[a]=scan.nextInt();
    }
    for(int a=0; a<num; a++){
      lev[a]=scan.nextInt();
    }
    for(int a=0; a<num-1; a++){
      plus[a]=scan.nextInt();
    }
    for(int a=0; a<num; a++){
      Ans+=lev[order[a]-1];
    }
    for(int a=1; a<num; a++){
      if(order[a]-order[a-1]==1){
        Ans+=plus[order[a-1]-1];
      }
    }
    System.out.println(Ans);
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = sc.next();
            }

            int ac = 0;
            int wa = 0;
            int tle = 0;
            int re = 0;
            for (int i = 0; i < N; i++) {
                if ("AC".equals(S[i])) {
                    ac++;
                } else if ("WA".equals(S[i])) {
                    wa++;
                } else if ("TLE".equals(S[i])) {
                    tle++;
                } else if ("RE".equals(S[i])) {
                    re++;
                }
            }

            System.out.println("AC x " + ac);
            System.out.println("WA x " + wa);
            System.out.println("TLE x " + tle);
            System.out.println("RE x " + re);
        }
    }
}


Measured memory_bytes: 55424
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		prepareFact();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int sum = m * 3;
		long ans = combiMod(n - 1 + sum, n - 1);
		for(int i = m * 2 + 1; i <= sum; i ++) {
			long tmp = combiMod(n - 2 + (sum - i), n - 2);
			tmp = mod(tmp * (long)n);
			ans = mod(ans - tmp);
		}

		long minus = 0;
		for(int i = m + 2; i <= n; i += 2) {
			long tmp = permMod(n - 1 + (sum - i) / 2, n - 1);
			tmp = mod(tmp * combiMod(n, i));
			minus = mod(minus + tmp);
		}
		minus = mod(minus * invMod(factMod[n - 1]));
		ans = mod(ans - minus);
		System.out.println(ans);
	}

	static long MOD = 998244353;
	public static long mod(long i) {
		return i % MOD + ((i % MOD) < 0 ? MOD : 0);
	}
	
	static long powerMod(long x, long y) {
		if (y == 0) {
			return 1;
		} else if (y == 1) {
			return x;
		} else if (y % 2 == 0) {
			long tmp = powerMod(x, y / 2);
			return mod(tmp * tmp);
		} else {
			long tmp = powerMod(x, y / 2);
			return mod(mod(tmp * tmp) * x);
		}
	}
	
	static long invMod(long x) {
		return powerMod(x, MOD - 2);
	}
	
	static int MAX_FACT = 2_500_100;
	static long factMod[] = new long[MAX_FACT];
	static void prepareFact() {
		factMod[0] = 1;
		for(int i = 1; i < MAX_FACT; i ++) {
			factMod[i] = mod(factMod[i - 1] * i);
		}
	}
	
	static long combiMod(int n, int r) {
		if(n < 0 || n < r) { return 0; }
		if(r == 0 || r == n) { return 1; }
		return mod(mod(factMod[n] * invMod(factMod[r])) * invMod(factMod[n - r]));
	}

	static long permMod(int n, int r) {
		if(n < 0 || n < r) { return 0; }
		if(r == 0) { return 1; }
		return mod(factMod[n] * invMod(factMod[n - r]));
	}
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(i,n) for(ll i=1;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG(x) cerr << x << "\n"

int main(){
    float a,b;
    cin >> a >> b;
    cout << ceil((a+b)/2);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

int a,b;

int main(){
    cin>>a>>b;
    out(max(0,a-2*b));
    
    
}


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

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

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



  
int main() {
  ll N,A,B;
  cin >> N >> A >> B;
  ll X1,X2;
  cin >> X1;
  ll ans = 0;
  rep(i,N-1){
    cin >> X2;
    ans += min((X2-X1)*A, B);
    X1 = X2;
  }
  
  cout << ans << endl;
    
}
      
       





Measured memory_bytes: 3632
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n;

	cin >> n;

	REP(i, n) {
		string s;
		cin >> s;
		if (s == "Y") {
			cout << "Four" << endl;
			return 0;
		}
	}

	cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int MAX = 101;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim()
{
    int u, mincost;
    int d[MAX], p[MAX], color[MAX];
     for(int i=0; i<MAX; i++)
     {
         color[i] = WHITE;
         d[i] = INFTY;
         p[i] = -1;
     }
     d[0] = 0;
     while(1)
     {
         mincost = INFTY;
         for(int i=0; i<n; i++)
         {
             if(color[i] != BLACK && d[i] < mincost)
             {
                 mincost = d[i];
                 u = i;
             }
         }
         if(mincost == INFTY)
                break;
         color[u] = BLACK;
         for(int v=0; v<n; v++)
         {
             if(color[v] != BLACK && M[u][v] != -1)
             {
                 if(M[u][v] < d[v])
                 {
                     d[v] = M[u][v];
                     p[v] = u;
                     color[v] = GRAY;
                 }
             }
         }
     }
     int sum = 0;
     for(int i=0; i<n; i++)
     {
         if(p[i] != -1)
            sum += M[i][p[i]];
     }
     return sum;
}
int main()
{
     cin >> n;
     int e;
     for(int i=0; i<n; i++)
     {
         for(int j=0; j<n; j++)
         {
             cin >> e;
             if(e == -1)
                M[i][j] = INFTY;
             else
                M[i][j] = e;
         }
     }
     cout << prim() << endl;
     return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    int a,b,c,x; cin >> a >> b >> c >> x;

    int count = 0;
    for (int i = 0; i < a + 1; ++i) {
        for (int j = 0; j < b + 1; ++j) {
            for (int k = 0; k < c + 1; ++k) {
                if(i * 500 + j * 100 + k * 50 == x)count++;
            }
        }
    }
    print(count);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int a[10];
	while(scanf("%1d",&a[0])!=EOF){
		for(int i=1;i<10;i++) scanf("%1d",&a[i]);
		for(int i=9;i>0;i--){
			for(int j=0;j<i;j++) a[j] += a[j+1];
		}
		cout << a[0]%10 << endl;
	}
}

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n;
        cin>>n;

        ll d;
        cin>>d;

        d*=d;

        ll ans=0;

        for(ll i=0;i<n;i++)
        {
            ll x,y;
            cin>>x>>y;

            if(x*x+y*y<=d)
            ans++;
        }

        cout<<ans;
    }
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	ll h,w;
	cin >> h>>w;
	if (h>w) swap(h,w);

	if (h==1) {
		if (w==1) cout << "1" << endl;
		else cout << w-2 << endl;
	}
	else if (h==2) {
		cout << "0" << endl;
	}
	else {
		cout << (h-2)*(w-2) << endl;
	}
	return 0;
}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
    ll n,m,sum = 0; cin>>n>>m;
    rep(i,m){
        ll now; cin>>now;
        sum += now;
    }
    if(n<sum) cout<<-1<<endl;
    else cout<<n-sum<<endl;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll mp[1111][1111];
ll seica[1111][1111];
ll now[1111];
ll day[1111];

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

	ll n;cin >> n;
	REP(i, n){
		REP(j, n-1){
			cin >> mp[i][j];
			mp[i][j]--;
			seica[i][mp[i][j]] = j;
		}
	}

	while(true){
		ll ok = true;
		ll change = false;
		REP(i, n){
			if(now[i] != n-1)ok = false;
			ll aite = mp[i][now[i]];
			if(seica[aite][i] != now[aite])continue;

			now[i]++;
			now[aite]++;
			ll tmp = max(day[i], day[aite]);
			day[i] = tmp+1;
			day[aite] = tmp+1;
			change = true;
		}

		if(ok){
			break;
		}
		if(!change){
			cout << -1 << endl;
			return 0;
		}
	}

	ll ans = 0;
	REP(i, n)ans = max(ans, day[i]);
	cout << ans << endl;

	return 0;
}


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

vector<int> to[200005];
vector<int> ans;


int main(){
  int n, m;
  cin >> n >> m;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    --a;
    --b;
    to[b].push_back(a);
    to[a].push_back(b); 
  }
  vector<int> dist(n, -1);
  vector<int> ans(n, -1);
  queue<int> que;
  dist[0] = 0;
  que.push(0);
  
  while (!que.empty()) {
    int v = que.front(); // キューから先頭頂点を取り出す
    //cout << v << endl;
    que.pop();
    // v から辿れる頂点をすべて調べる
    for (int nv : to[v]) {
      if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない
      // 新たな白色頂点 nv について距離情報を更新してキューに追加する
      dist[nv] = dist[v] + 1;
      if(ans[nv]==-1) ans[nv]=v+1;
      que.push(nv);
    }
  }
  /*for(auto k:to[5]){
    cout << k << endl;
  }*/
  rep(i,n){
    if(dist[i]==-1){
      cout << "No" << endl;
      return 0;
    } 
    else {
      cout << "Yes" << endl;
      for(int i=1;i<n;i++) cout << ans[i] << endl;
      return 0;
    }
  }

  
}

Measured memory_bytes: 12888
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop, core.thread;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }


immutable MO = 10L^^9 + 7;

int N;
int[] X, Y;

int[][] G;
long[][] dp;

void solve(int u, int p) {
  foreach (v; G[u]) {
    if (v != p) {
      solve(v, u);
    }
  }
  dp[u][0] = 1;
  dp[u][1] = 1;
  foreach (v; G[u]) {
    if (v != p) {
      (dp[u][0] *= (dp[v][0] + dp[v][1])) %= MO;
      (dp[u][1] *= dp[v][0]) %= MO;
    }
  }
}

void main() {
  try {
    for (; ; ) {
      N = readInt();
      X = new int[N - 1];
      Y = new int[N - 1];
      foreach (i; 0 .. N - 1) {
        X[i] = readInt() - 1;
        Y[i] = readInt() - 1;
      }
      G = new int[][N];
      foreach (i; 0 .. N - 1) {
        G[X[i]] ~= Y[i];
        G[Y[i]] ~= X[i];
      }
      dp = new long[][](N, 2);
      solve(0, -1);
      long ans = (dp[0][0] + dp[0][1]) % MO;
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 18044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int iCount, startNum, endNum;
  int result = 0;
  cin >> iCount;
  
  for (int i=0;i<iCount;i++){
    cin >> startNum >> endNum;
    result += endNum - startNum + 1;
  }
  cout << result << endl;
}

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

static const int MAX = 100; //頂点数の最大値100まで対応可能
static const int INFTY = (1<<21);   //適当な値で\inftyを表す
static const int WHITE = 0; //未訪問の頂点を白色で表す
static const int GRAY = 1; //その時点で決定された最短経路木Sに属する
static const int BLACK = 2; //訪問済みの頂点を黒色で表す

int n, M[MAX][MAX]; //Mはuからvへの辺の重みを記録する隣接行列

void dijkstra(){
    int minv;
    int d[MAX], color[MAX];

    for(int i = 0; i < n; i++){
        d[i] = INFTY; //すべての頂点について最短コストを\inftyで初期化しておく（最短経路探索問題だから）
        color[i] = WHITE; //すべての頂点を未訪問としておく
    }

    d[0] = 0; //スタート地点からスタート地点までの距離は0
    color[0] = GRAY; //スタート地点をSに所属させる
    while(1){
        minv = INFTY;
        int u = -1; //最初0の親を-1にしておく
        for(int i = 0; i < n; i++){ 
            if(minv > d[i] && color[i] != BLACK){  //頂点が訪問済みでなく, かつ, スタート地点からiまでの最短コストがminv未満
                u = i; //最短コストを取る点をiへと更新する
                minv = d[i]; //最短コストをd[i]へと更新する
            }
        }
        
        //　V/Sの中でd[u]が最小となる点uの選択が完了した.

        if(u==-1) break;
        color[u] = BLACK; //uを訪問済みにするs
        for(int v = 0; v < n; v++){
            if(color[v] != BLACK && M[u][v] != INFTY){ //vが未訪問の点であり, かつuとvの間にedgeが存在する
                if(d[v] > d[u] + M[u][v]){ //uからedgeを通りvへ向かう距離の方が, それまでのd[v]より小さいならば
                    d[v] = d[u] + M[u][v]; //d[v]の値を更新する
                    color[v] = GRAY; //vを決定された最短経路木Sに属させる
                }
            }
        }
    }

    for(int i = 0; i < n; i++){
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl; //距離が\inftyか?? 
    }
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            M[i][j] = INFTY;
        }
    }

    int k, c, u, v;
    for(int i = 0; i < n; i++){
        cin >> u >> k; //頂点番号を出次数を入力する
        for(int j = 0; j < k; j++){
            cin >> v >> c;
            M[u][v] = c; //有効辺の重みを入力する
        }
    }

    dijkstra(); //Dijkstra法を実施する
    return 0;
}




Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if((i&1) == 0 && (v[i]&1) == 1) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
    string s;
     cin>>s;
     int n = s.size(),d=10;
     int suffix[n],c[2019];
     memset(c,0,sizeof(c));
     long long ans=0; 
    suffix[n-1] = s[n-1]-'0';
     for(int i=n-2;i>=0;i--)
     { 
        suffix[i]=((int)(s[i]-'0')*d+suffix[i+1])%2019;
         d*=10; 
        d%=2019;
        
    } 
        for(int i=0;i<n;i++)
    {  
        c[suffix[i]]++;
     } 
    c[0]++; 
    for(int i=0;i<2019;i++)
        { 
        if((c[i]*(c[i]-1)/2)!=0)                
        ans+=c[i]*(c[i]-1)/2;
 } 
     cout<<ans<<"\n"; return 0;
 }

Measured memory_bytes: 4580
def mul(m) : 
      
    # Multiply elements one by one 
    res = 1
    for x in m: 
        res = res * x
        if res == 0:
             return 0 
        if res > 10**18:
             return -1
    return res
 
n = int(input())
a = list(map(int, input().split()))
a.sort()
z = mul(a)
print(z)

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int n, p[22];
signed main() {
    cin >> n;
    for (int i = 1; i <= n; i++) { cin >> p[i]; }
    int ans = 0;
    for (int i = 2; i < n; i++) {
        ans += p[i]
            == p[i - 1] + p[i] + p[i + 1] - max({p[i - 1], p[i], p[i + 1]}) - min({p[i - 1], p[i], p[i + 1]});
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
  } else {
    int a,b;
    cin >> a >> b;
    cout << a + b << endl;
  }
}


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



int main(){
  ll n,p;
  std::cin >> n>>p;
  if(n==1){
    std::cout << p << '\n';
    return 0;
  }



  //素数列挙
  ll now=2;
  std::vector<ll> pri(pow(p,(1.0/n))+3,1);
  for (int i = 2; i < pri.size(); i++) {
    if(pri[i]!=1)continue;
    else {
      if(i+i>=pri.size())continue;
      for (int j = i+i; j < pri.size(); j+=i)pri[j]=0;
    }
  }

  // ll op = p;
  // unordered_map<ll, ll> mp;
  // ll t = 2;
  // while (p > 1 && t * t <= op) {
  //   if (p % t == 0) {
  //     mp[t]++;
  //     p /= t;
  //   } else {
  //     t++;
  //   }
  // }
  // if (p > 1) mp[p]++;


  // rep(i,pri.size()){
  //   std::cout<<i <<":"<<pri[i] << '\n';
  // }

  ll ans=1;
  ll i=1;
  while (1) {
    i++;
    if(pri.size()>i){

      if(pri[i]!=1)continue;
      ll temp =i;
      if(p%temp==0){



        int cnt=0;
        while (p%temp==0) {
          cnt++;
          p/=temp;
        }

        ans*=pow(i,cnt/n);

      }
    }else break;
  }

  std::cout << ans << '\n';
  return 0;
}


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

typedef long long ll;

int main() 
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll a,b,c,k;
    while(cin >> a >> b >> c >> k)
        cout << (k%2 == 0? a-b : b-a) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

vector<int> getdiv(int n){
    vector<int> d;
    for(int i=1; i*i<=n; ++i){
        if(n % i == 0){
            d.emplace_back(i);
            if(i*i != n) d.emplace_back(n / i);
        }
    }
    return d;
}

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    rep(i, n) scanf("%d", &a[i]);
    int t[n];
    rep(i, n) t[i] = 0;
    vector<int> ans;
    rrep(i, n){
        if(a[i] == t[i]) continue;
        ans.emplace_back(i+1);
        auto d = getdiv(i+1);
        for(int j: d) t[j-1] ^= 1;
    }
    printf("%d\n", ans.size());
    if(ans.size()){
        printf("%d", ans[0]);
        For(i, 1, ans.size()) printf(" %d", ans[i]);
        printf("\n");
    }
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n;
    cin >> n;
    map<ll, ll> mp;
    rep(i, n)
    {
        ll x;
        cin >> x;
        mp[x-1]++, mp[x]++, mp[x+1]++;
    }
    ll ans = 0;
    itr(it, mp) ans = max(ans, it->sd); cout << ans;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;
  if(a*b>c){
    cout << c << endl;
  }else{
    cout << a*b << endl;
  }
  
   return 0;
}


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

#define MAXN 200007
#define MOD 1000000007

int n , k ;
long long a[ MAXN ] ;

long long ans = 1 ;

pair < long long , int > b[ MAXN ] ;

void input ( ) {
    cin >> n >> k ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        cin >> a[ i ] ;
        b[ i ] = { abs ( a[ i ] ) , i } ;
    }
    sort ( b + 1 , b + n + 1 , greater < pair < long long , int > > ( ) ) ;
}

void solve ( ) {
    int cnt = 0 ;
    int lst = 0 ;
    int hh = 0 ;
    for ( int i = 1 ; i <= k ; ++ i ) {
        if ( a[ b[ i ].second ] < 0 ) {
            ++ cnt ;
            lst = i ;
        }
        else { hh = i ; }
    }
    if ( ( cnt % 2 ) == 0 ) {
        for ( int i = 1 ; i <= k ; ++ i ) {
            ans = ( ans * b[ i ].first ) % MOD ;
        }
        cout << ans << "\n" ;
    }
    else {
        int nw1 = 0 ;
        for ( int i = k + 1 ; i <= n ; ++ i ) {
            if ( a[ b[ i ].second ] >= 0 ) {
                nw1 = i ;
                break ;
            }
        }
        int nw2 = 0 ;
        for ( int i = k + 1 ; i <= n ; ++ i ) {
            if ( a[ b[ i ].second ] < 0 ) {
                nw2 = i ;
                break ;
            }
        }
        if ( nw1 == 0 && ( nw2 == 0 || cnt == k ) ) {
            for ( int i = 1 ; i <= k ; ++ i ) {
                ans = ( ans * a[ b[ n - i + 1 ].second ] ) % MOD ;
            }
            ans = ( ans + MOD ) % MOD ;
        }
        else {
            if ( nw2 == 0 || cnt == k ) { 
                ans = b[ nw1 ].first ;
                for ( int i = 1 ; i <= k ; ++ i ) {
                    if ( i == lst ) { continue ; }
                    ans = ( ans * b[ i ].first ) % MOD ;
                }
            }
            else if ( nw1 == 0 ) {
                ans = b[ nw2 ].first ;
                for ( int i = 1 ; i <= k ; ++ i ) {
                    if ( i == hh ) { continue ; }
                    ans = ( ans * b[ i ].first ) % MOD ;
                }
            }
            else {
                if ( b[ nw1 ].first * b[ hh ].first >= b[ lst ].first * b[ nw2 ].first ) {
                    ans = b[ nw1 ].first ;
                    for ( int i = 1 ; i <= k ; ++ i ) {
                        if ( i == lst ) { continue ; }
                        ans = ( ans * b[ i ].first ) % MOD ;
                    }
                }
                else {
                    ans = b[ nw2 ].first ;
                    for ( int i = 1 ; i <= k ; ++ i ) {
                        if ( i == hh ) { continue ; }
                        ans = ( ans * b[ i ].first ) % MOD ;
                    }                    
                }
            }
        }
        cout << ans << "\n" ;
    }
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 8328
#include <iostream>
using namespace std;
int main()
{
  int H, W;
  cin >> H >> W;
  char a[H][W];
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
      cin >> a[i][j];
  }
  int check[H][W];
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
      check[i][j] = 0;
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (a[i][j] == '.')
      {
        for (int k = 0; k < H; k++)
        {
          if (a[k][j] == '#')
          {
            check[i][j]++;
            break;
          }
        }
        for (int k = 0; k < W; k++)
        {
          if (a[i][k] == '#')
          {
            check[i][j]++;
            break;
          }
        }
      }
    }
  }
  for (int i = 0; i < H; i++)
  {
    int count = 0;
    for (int j = 0; j < W; j++)
    {
      if (a[i][j] == '#' || (a[i][j] == '.' && 2 == check[i][j]))
      {
        cout << a[i][j];
        count++;
      }
    }
    if (0 < count)
      cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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


    
    string s;
    cin >> s ;
    cout << 700 + 100 * count(all(s), 'o') << endl;

    
  
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

#define INF 1e9
using namespace std;

int main() {

    string N; cin >> N;

    int S = 0;

    for (int i = 0; i < N.size(); ++i) {
        S += N[i] - '0';
    }

    if (stoi(N) % S == 0) {
        puts("Yes");
    } else {
        puts("No");
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, a[101010];
i64 cnt = 0;

int main(){
	cin >> n;
	int mi = INF;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		cnt += abs(a[i]);
		mi = min(mi, abs(a[i]));
	}
	
	for(int i = 0; i < n-1; i++){
		if(a[i] < 0) a[i+1]*=-1;
	}
	
	if(a[n-1] >= 0) cout << cnt << endl;
	else cout << cnt - mi*2 << endl;
	
	return 0;
}

Measured memory_bytes: 640
# frozen_string_literal: true

N = gets.chomp.to_i

ans = Array.new(N, 0)

(1..100).each do |x|
  (1..100).each do |y|
    (1..100).each do |z|
      n = (x + y + z)**2 - x * y - y * z - z * x
      next if n > N || n < 1

      ans[n - 1] += 1
    end
  end
end

ans_array = (1..N).map do |i|
  ans[i - 1]
end

puts ans_array


Measured memory_bytes: 14312
#include <stdio.h>

int main(void) {
  int i, j, k, t, n, m, p, q, l;
  double max = 0;
  scanf("%d", &t);
  for(l = 0; l < t; ++l) {
    scanf("%d%d", &n, &m);
    double v, r, now = 0, sum = 0;
    for(i = 0; i < m; ++i) {
      scanf("%lf%lf", &v, &r);
      sum += r;
      now += v * r;
    }
    now /= sum;
    if(max < now) max = now;
  }
  scanf("%d%d", &p, &q);
  double sum = 0, now = 0, v, r;
  for(i = 0; i < q; ++i) {
    scanf("%lf%lf", &v, &r);
    now += v * r;
    sum += r;
  }
  now /= sum;
  if(max - now > 0.0000001) printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 2752
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <functional>
using namespace std;
signed main(void)
{
	int n, k;
	cin >> n >> k;
	int a[5004];
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int s = 0; int t = 0; int sum =0;
		for (int t = 0; t < n; t++) {
			if (t != i)sum += a[t];
			while (sum >=k) {
				if (s != i)sum -= a[s]; s += 1;
			}
			if (sum >= k - a[i])break;
			if (t == n - 1) { ans += 1; break; }
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
a = [int(s) for s in input().split()]
b = int(a[0] // (a[1] + a[2]))
c = int(a[0] % (a[1] + a[2]))
d = b * a[1]
if c >= a[1]:
  d = d + a[1]
else:
  d = d + c

print(d)

Measured memory_bytes: 61904
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, d;
    while(cin>>a>>b>>c>>d)
    {
        int total = a * b;
        int colored = c * b + d * a - c * d;
        cout<<total - colored<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        var a = int.Parse(Console.ReadLine().Trim());
        var b = int.Parse(Console.ReadLine().Trim());
        var c = int.Parse(Console.ReadLine().Trim());
        var d = int.Parse(Console.ReadLine().Trim());
        var p = int.Parse(Console.ReadLine().Trim());
        int y;
        if (p <= c) y = b;
        else y = b + (p - c) * d;
        Console.WriteLine(Math.Min(y, a * p));
    }
}

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

#define PI acos(-1)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair <int, int> pii;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector<string> vs;

const int INF = 100500;
const int MAXN = 1e5 + 9;

string s;

void input() {                  
	cin >> s;
}

void solve() {
	string t = "";
	for(int i = 0; i < sz(s); i++) {
		if(s[i] == ',') {
			cout << t << ' ';
			t = "";
		}
		else t += s[i];
	}
	cout << t << endl;
}

int main() {     
#ifdef LOCAL
	freopen("xxx.in", "r", stdin);
	freopen("xxx.out", "w", stdout);
#else
	//freopen("xxx.in", "r", stdin);
	//freopen("xxx.out", "w", stdout);
#endif	
	input();
	solve();
	return 0;
}


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

typedef long long ll;
typedef long double ld;

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

    char a, b;

    cin >> a >> b;

    if(a == b) {
        cout << "H" << endl;
    } else {
        cout << "D" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll MOD=998244353;
ll dp[3001][3001];

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  dp[a][b]=1;
  for(ll i=a;i<=c;i++)for(ll j=b;j<=d;j++)if(a!=i || b!=j)dp[i][j]=(i*dp[i][j-1]+j*dp[i-1][j]-(i-1)*(j-1)*dp[i-1][j-1]%MOD+MOD)%MOD;
  cout<<dp[c][d]<<endl;
}


Measured memory_bytes: 73812
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define pb push_back
typedef vector<int> vi;
#define mod 1000000007
#define maxn 100005
vi v[maxn],depth(maxn,0);
vector<bool>vis(maxn);
void dfs(int st)
{
    vis[st]=true;
    for(auto i=v[st].begin();i!=v[st].end();i++)
    {
        if(!vis[*i])
        dfs(*i);
    }
    for(auto i=v[st].begin();i!=v[st].end();i++)
    {
        depth[st]=max(depth[st],depth[*i]+1);
    }
}
int32_t main() {
    int n,m;
    cin>>n>>m;
    for(int i=0,x,y;i<m;i++)
    cin>>x>>y,v[x].pb(y);
    for(int i=1;i<=n;i++)
    if(!vis[i]) dfs(i);
    cout<<*max_element(depth.begin(),depth.end());
    return 0;
}


Measured memory_bytes: 11692
A, B, C = map(int, input().split())
K = int(input())
ans = False
for i in range(K+1):
    j = K - i
    B_i = B*(2**i)
    C_i = C*(2**j)
    if A < B_i and B_i < C_i:
        ans = True

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

constexpr int N = 212345;
int a[N], b[N];

int main(){
	int n, k; scanf("%d%d", &n, &k);
	REP(i, n) scanf("%d", a+i);
	REP(j, k){
		fill(b, b+n, 0);
		REP(i, n){
			b[max(0, i-a[i])]++;
			b[min(n, i+a[i]+1)]--;
		}
		FOR(i, 1, n) b[i] += b[i-1];
		swap(a, b);
		bool ok = true;
		REP(i, n) if(a[i] != b[i]) ok = false;
		if(ok) break;
	}
	REP(i, n) printf("%d ", a[i]);
}


Measured memory_bytes: 5484