akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

struct Dijkstra{
  int n,i;
  vector<vector<pair<int,int> > > edge; //cost,to
  vector<int> distance;
  vector<int> prev;

  void init(int v){
    n=v;
    edge.resize(n);
    distance.resize(n);
    prev.resize(n);
  }

  void calc(int start){
    for(i=0;i<n;i++){
      distance[i]=INT_MAX;
      prev[i]=-1;
    }
    distance[start]=0;

    priority_queue<pair<int,int> > q; //cost,to
    int from,to,tmp;
    q.push({0,start});

    while(!q.empty()){
      from=q.top().second;
      q.pop();
      for(i=0;i<edge[from].size();i++){
        int to=edge[from][i].second;
        int tmp=distance[from]+edge[from][i].first;
        if(distance[to]>tmp){
          distance[to]=tmp;
          prev[to]=from;
          q.push({tmp,to});
        }
      }
    }

  }
};

int main(void){
  int n,u,k,v,c,i,j;
  Dijkstra graph;
  cin>>n;
  graph.init(n);
  for(i=0;i<n;i++){
    cin>>u>>k;
    for(j=0;j<k;j++){
      cin>>v>>c;
      graph.edge[u].push_back({c,v});
    }
  }
  graph.calc(0);

  for(i=0;i<n;i++){
    cout<<i<<" "<<graph.distance[i]<<endl;
  }

  return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

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


    if (k < a)
    {
        cout << k << endl;
    }
    else if (k < a + b)
    {
        cout << a << endl;
    }
    else
    {
        cout << a - (k - a - b) << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 int main(){
  ll n ; cin>>n ;
  vector<ll> A(n) ;
  rep(i,n) cin>>A[i] ;
  ll ans=0 ;
  ll now=A[0] ;
  rep(i,n-1){
    if(A[i+1]>=now) now= A[i+1] ;
    else ans+= now-A[i+1] ;
  }
  cout<<ans<<endl ;
   return 0 ;
 }



Measured memory_bytes: 4756
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>

using namespace std;


bool is_balanced(int s, int e, vector<int>& v) {
    int len = e - s + 1;
    for (auto i: v) {
        if (i > len / 2 && len >= 2) {
            return true;
        }
    }
    return false;
}

void print(vector<int> v) {
    cout << "{ ";
    for (auto i : v) {
        cout << i << ", ";
    }
    cout << " }" << endl;
}

int main() {
    string s;
    cin >> s;
    vector<int> v(26, 0);

    int i = 0, j = 0;
    int len = (int) s.size();
    int start, end;

    while (j < len) {
        v[s[j] - 'a']++;
        if (is_balanced(i, j, v)) {
            start = i + 1;
            end = j + 1;
            cout << start << " " << end << endl;
            return 0;
        } else {
            if (j > i + 1) {
                v[s[i] - 'a']--;
                i++;
            }
        }
        j++;
    }

    cout << -1 << " " << -1 << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
	int X, A, B;
	cin >> X >> A >> B;
	if (B <= A) {
		cout << "delicious" << endl;
	}
	else if (B <= A+X) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
	// cin >> A;
}

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

int main(){
    int num = 0;
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s < t){ cout << "Yes" << endl;}
    else{ cout << "No" << endl;}
}

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

typedef long long ll;

int main(){
	const int MOD = 1e9+7;
	const int N = 13;
	string S;
	cin >> S;
	vector<uint> dp(N);
	dp[0] = 1;

	int mul = 1;
	for(int i=S.size()-1; i>=0; i--){
		vector<uint> nextDP(N);

		char c = S[i];
		if(c=='?'){
			for(int k=0; k<10; k++){
				for(int j=0; j<N; j++){
					nextDP[(k*mul+j)%N] += dp[j];
					nextDP[(k*mul+j)%N] %= MOD;
				}
			}
		}else{
			int k=S[i]-'0';
			for(int j=0; j<N; j++){
				nextDP[(k*mul+j)%N] += dp[j];
				nextDP[(k*mul+j)%N] %= MOD;
			}
		}
		dp = nextDP;
		mul *= 10;
		mul %= N;
	}

	cout << dp[5] << endl;

}



Measured memory_bytes: 512
_ = input()
n = [int(i) for i in input().split()]

cnt = 0
min = 10**9

for i in n:
  cnt = 0
  while True:
    if i % 2 == 0:
      i = i / 2
      cnt += 1
    else:
      if min > cnt:
        min = cnt
      break

print(min)


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

#ifdef LOCAL
#define i64 "%lld"
#else
#define i64 "%I64d"
#endif

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 1e5 + 10;
int n; 
pii a[N];

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

    cin >> n;
    forn(i,n) {
        a[i].second = i;
        cin >> a[i].first;
    }
    sort(a, a+n);

    int ans = 0;
    forn(i,n) if ((i ^ (a[i].second)) & 1) ans++;
    cout << ans/2 << endl;
    

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
long long ans;
long long n;

int main(){
    scanf("%lld",&n);
    n--;
    ans+=(n*(n+1))/2;
    printf("%lld\n",ans);
}
/*
    Good Luck
        -Lucina
*/


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

int main () {
  int N , r = 0 , b = 0 ;
  cin >> N ;
  char C ;
  for(int i = 0 ; i < N ; i++ ){
    cin >> C ;
    if(C=='R') r ++ ;
    if(C=='B') b ++ ;
  }
  if(r > b) cout << "Yes" << endl ;
  else cout << "No" << endl ;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF 1e9
#define INFL 1e18
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class ARemainingBalls {
public:
	void solve(std::istream& in, std::ostream& out) {
        string S, T;
        in >> S >> T;
        int A, B;
        in >> A >> B;
        string U;
        in >> U;
        if (S == U) A--;
        else B--;
        out << A << ' ' << B << '\n';
	}
};


int main() {
	ARemainingBalls solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}

int arr[1003];

int main(){

    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("input.txt", "r", stdin);

    int n;
    long long prod = 1, MOD = 1000000007;

    cin >> n;

    for(int j = 2; j <= n; ++j){
        int k = j;
        int i = 2;
        while(k != 1){
            if(k % i == 0){
                while(k % i == 0){
                    ++arr[i];
                    k /= i;
                }
            }
            ++i;
        }
    }

    for(int i = 2; i <= n; ++i)
        if(arr[i] != 0)
            prod = prod * (arr[i] + 1) % MOD;

    cout << prod;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end(),greater<ll>())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N;
  ll W;

  cin>>N>>W;

  ll w[N];
  ll v[N];


  rep(i,N){
    cin>>w[i];
    cin>>v[i];
  }

  vector<vector<ll>> se(4);

  rep(i,N){
    se[w[i]-w[0]].emplace_back(v[i]);
  }

  SORT(se[0]);
  SORT(se[1]);
  SORT(se[2]);
  SORT(se[3]);

  int ses[4];
  rep(i,4){
    ses[i]=se[i].size()+1;
  }

  ll ct=0;

  rep(i,ses[0]){
    rep(j,ses[1]){
      rep(k,ses[2]){
        rep(l,ses[3]){
          ll weight=0;
          ll value=0;

          rep(x1,i){
            weight+=w[0];
            value+=se[0][x1];
          }

          rep(x2,j){
            weight+=w[0]+1;
            value+=se[1][x2];
          }
          rep(x3,k){
            weight+=w[0]+2;
            value+=se[2][x3];
          }
          rep(x4,l){
            weight+=w[0]+3;
            value+=se[3][x4];
          }

          if(weight<=W){
            ct=max(ct,value);
          }

        }
      }
    }
  }

  cout<< ct<<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
use std::io;
fn main() {
	let stdin = io::stdin();
    let mut s = String::new();
    stdin.read_line(&mut s).ok();
    s.pop();
    if s == "abc" || s == "acb" || s == "bac" || s == "bca" || s == "cab" || s == "cba" {
    	println!("Yes");
    } else {
    	println!("No");
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

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

int main(){
	int N,W;
	cin>>N>>W;
	vector<ip> item(N);
	rep(i,N){
		cin>>item[i].first>>item[i].second;
	}
	vector<vector<int>> dp(N+1,vector<int> (W+1,0));
	for(int i = N-1; i>=0; --i){
		for(int ww = 0; ww<=W; ++ww){
			if(item[i].second > ww){
				dp[i][ww] = dp[i+1][ww];
			}else{
				chmax(dp[i][ww], dp[i+1][ww]);
				chmax(dp[i][ww], dp[i+1][ww-item[i].second]+item[i].first);
			}
		}
	}
	cout<<dp[0][W]<<endl;
	return 0;
}


Measured memory_bytes: 6748
N = int(input())
A = [int(n) for n in input().split()]
A = [0] + A + [0]
L = []
LL = []

for i, a in enumerate(A):
    if i < len(A) - 1:
        L.append(abs(A[i] - A[i+1]))
    if i < len(A) - 2:
        LL.append(abs(A[i] - A[i+2]))

s = sum(L)

for i in range(N):
    ans = s - L[i] - L[i+1] + LL[i]
    print(ans)


Measured memory_bytes: 16648
#include <bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin >> N;
  if(N.at(1) == N.at(2) && N.at(2) == N.at(3) || N.at(0) == N.at(1) && N.at(1)== N.at(2)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int sun[MAXN];
int n;
vector<int>G[MAXN];
int dfs(int x, int f){
	int p, s = 0;
	for(int i = 0; i<G[x].size(); i++){
	p=G[x][i];
		if(p!= f)
			s ^= dfs(p, x) + 1;
		} 
	return s;
}
int main(){
	int i, u, v;
	scanf("%d", &n);
	for(i = 1; i < n; ++ i){
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	} printf("%s\n", (G[1].size()==1||dfs(1, -1) )? "Alice" : "Bob");
	return 0;
}

Measured memory_bytes: 11136
a = int(input())
l = list(map(int,input().split()))
sum=0
for i in range(a-2):
  b=l[i]
  c=l[i+1]
  d=l[i+2]
  if c!=min(b,c,d) and c!=max(b,c,d):
    sum +=1
print(sum)
  
  

Measured memory_bytes: 3060
n = int(input().strip())
s = input().strip()
arr = [0] * n
east = 0
west = 0

for i in range(n):
    arr[i] = east
    if s[i] == 'E':
        east += 1
for i in range(n - 1, -1, -1):
    arr[i] += west
    if s[i] == 'W':
        west += 1
ma = max(arr)
idx = i
for i in range(n):
    if arr[i] == ma:
        idx = i
if idx == (n - 1):
    print(s[:idx].count('W'))
else:
    print(s[:idx].count('W') + s[(idx + 1):].count('E'))


Measured memory_bytes: 44388
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
#include<locale>
//freopen("std.in","r",stdin);freopen("stdout.out","w",stdout);
using namespace std;
int main()
{
    long n,k;
    cin>>n>>k;
    long a=0,b=0,x;
    scanf("%ld",&x);
    a=x;
    b=x;
    for(long i=1;i<n;i++)
    {
        scanf("%ld",&x);
        a=__gcd(a,x);
        b=max(x,b);
    }
    if(k%a==0&&k<=b)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define Rep(i, s, n) for (int i = (int)s; i < (int)n; i++)

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

    int p, q, r;
    cin >> p >> q >> r;

    int min = p + q;
    if (min > p + r) min = p + r;
    if (min > q + r) min = q + r;
    cout << min << endl;
}

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

string f(int x, int y, int z, string a, string b, string c) {
    //cout << x << ' ' << y << ' ' << z << ' ' << a << ' ' << b << ' ' << c << endl;
    if(y == 0 && z == 0) {
        string ret;
        for(int i = 0; i < x; i++) ret += a;
        return ret;
    }
    if(x == 0) return f(y, z, 0, b, c, a);
    if(y == 0 && z) return f(x, z, y, a, c, b);

    if(z == 0) {
        if(x <= y) {
            string na = a;
            for(int i = 0; i < y / x; i++) na += b;
            return f(x, y % x, 0, na, b, c);
        }
        else {
            string na = a, nb = a + b;
            return f(x - y, y, 0, na, nb, c);
        }
    }
    else if(x <= z) {
        string na = a + c;
        return f(x, y, z - x, na, b, c);
    }
    else if(x <= y + z) {
        string nb = a + c;
        return f(x - z, z, y, a, nb, b);
    }
    else {
        string na = a, nb = a + b, nc = a + c;
        return f(x - y - z, y, z, na, nb, nc);
    }
}

int X, Y, Z;

int main() {
    cin >> X >> Y >> Z;
    cout << f(X, Y, Z, "a", "b", "c");
}


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

int ans = 0, N, K;
vector<int> child[100000];

int rec(int i){
    int num = 1;
    for(auto j : child[i]){
        num = max(num, rec(j) + 1);
    }
    if(num >= K){
        ans += 1;
        return 0;
    }else{
        return num;
    }
}

int main(){
    long long i, j, k;
    cin >> N >> K;
    for(i=0; i<N; i++){
        int a;
        cin >> a;
        if(i==0 && a != 1) ans += 1;
        if(i > 0) child[a-1].push_back(i);
    }
    for(auto i : child[0]){
        for(auto j : child[i]){
            rec(j);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8832
// AOJ Volume 0 Problem 0089

#include <stdio.h>
#include <string.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))


int get_num(char *str, int *num)
{
	int i;
	int no;
	int n;
	
	i = no = 0;
	while (1){
		n = 0;
		while (str[i] != ',' && str[i] != '\0'){
			n = n * 10 + str[i++] - '0';
		}
		num[no++] = n;
		if (str[i] == '\0'){
			break;
		}
		i++;
	}
	return (no);
}


int main(void)
{
    int n, n_prev;
    int num[100];
	int sum[100], tmp[100];
	char str[1000];
	int i;
	int direction;
	
	memset(sum, 0, sizeof(sum));
	memset(tmp, 0, sizeof(tmp));
	
	n_prev = 0;
	
	while (scanf("%s", str) != EOF){
		n = get_num(str, num);
//		printf("%d\n", n);
		
		if (n > n_prev){
			direction = 0;
		}
		else {
			direction = 1;
		}
		n_prev = n;
		
		if (direction == 0){
			for (i = 1; i <= n; i++){
				tmp[i] = MAX(sum[i - 1] + num[i - 1], sum[i] + num[i - 1]);
//				printf("<%d-%d>", num[i - 1], tmp[i]);
			}
//			printf("\n");
		}
		else {
			for (i = 1; i <= n; i++){
				tmp[i] = MAX(sum[i + 1] + num[i - 1], sum[i] + num[i - 1]);
//				printf("[%d-%d]", num[i - 1], tmp[i]);
			}
		}
		
		memcpy(sum, tmp, sizeof(tmp));
//		printf("\n");
		
	}
	printf("%d\n", sum[1]);
    
    return (0);
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

struct segtree{
    vector<int> d;
    int n;
    segtree(int n_){
        n=1;
        while(n<n_)n*=2;
        d.resize(2*n-1,0);
    }
    //k番目をaにアップデート
    void update(int k,int a){
        k += n-1;
        d[k] = a;
        while(k>0){
            k = (k-1)/2;
            d[k] = min(d[k*2+1],d[k*2+2]);
        }
    };
    int query(int a, int b,int k,int l,int r){
        if(r<=a||b<=l) return 0;
        if(a<=l&&r<=b) return d[k];
        else{
            int vl = query(a,b,k*2+1,l,(l+r)/2);
            int vr = query(a,b,k*2+2,(l+r)/2,r);
            return min(vl,vr);
        }
    };
    int max(int a,int b){
        return query(a,b,0,0,n);
    };
};

int main(){
    int n,k;
    cin >> n >> k;
    segtree st(500010);
    rep(i,n){
        int a;
        cin >> a;
        int b = st.max(max(0,a-k), min(a+k+1,500010));
        st.update(a, b-1);
    }
    int ans = st.query(0,500010,0,0,st.n);
    cout << -ans << endl;
    return 0;
}


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

int main(){

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

    int sum = 0;

    for(int i=0 ; i < N; ++i){
        for(int j = i+1 ; j < N; ++j){
            sum += d[i]*d[j];
        }    
    }

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



Measured memory_bytes: 256
#import heapq
import itertools
import math
#import numpy as np
import sys

def modc(a, b, m):
    c = 1
    for i in range(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1, m) % m
    return c

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

#N = int(input())
X, Y = list(map(int, input().split()))
#S = [input() for _ in range(H)]
#T = [list(map(int,input().split())) for _ in range(N)]
#sys.exit()

if (X + Y) % 3 != 0 :
    print(0)
    sys.exit()

n = int((2 * Y - X) / 3)
m = int((2 * X - Y) / 3)

if n < 0 or m < 0 :
    print(0)
    sys.exit()

ans = modc(n + m, n, 10 ** 9 + 7)
print(ans)

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

using namespace std;

int main() {
	int x1,y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x3,y3,x4,y4;
	int a = x2 - x1;
	int b = y2 - y1;
	x3 = x2 - b;
	y3 = y2 + a;
	x4 = x3 - a;
	y4 = y3 - b;
	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << "\n";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(int(a) for a in input().split())

ans = 0
x_sum = 0
a_sum = 0
r = -1
for l in range(N):
    while x_sum == a_sum and r < N-1:
        r += 1
        x_sum ^= A[r]
        a_sum += A[r]
    if x_sum != a_sum:
        x_sum ^= A[r]
        a_sum -= A[r]
        r -= 1
    ans += r-l+1
    #print(l, r, x_sum, a_sum, ans)
    x_sum ^= A[l]
    a_sum -= A[l]

print(ans)

Measured memory_bytes: 32152
def main():
    a, b, c = (int(i) for i in input().split())
    ans = []
    v = (0--a//2 - a//2) * b * c
    ans.append(v)
    v = (0--b//2 - b//2) * c * a
    ans.append(v)
    v = (0--c//2 - c//2) * a * b
    ans.append(v)
    print(min(ans))


if __name__ == '__main__':
    main()


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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll ans=0,sum=0;
    rep(i,n){
        cin >> a[i];
        ans = (ans + (a[i]*sum)%MOD)%MOD;
        sum += a[i];
        if(sum>MOD) sum %= MOD;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    int n;
    cin>>n;
    vector<string>arr(n);
    for(int i=0;i<n;i++)
    cin>>arr[i];
    // for(auto x:arr)
    // cout<<x;
    map<string ,int >m;
//    //m.insert({arr[0],1});
    for(int i=0;i<n;i++)
    {
        if(m.find(arr[i])!=m.end())
        m[arr[i]]++;
        else m[arr[i]]=1;
    }
    // for(auto x:m)
    // cout<<x.first<<" "<<x.second<<"\n";
    int maxi=INT_MIN;
    
    for(auto x:m)
    maxi=max(maxi,x.second);
    vector<string>ans;
    for(auto x:m)
    if(x.second==maxi)
    ans.push_back(x.first);
    sort(ans.begin(),ans.end());
    for(auto x:ans)
    cout<<x<<"\n";
    
	return 0;
}

Measured memory_bytes: 28404
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char in[10];
int main(){
	scanf("%s",in);
	if(in[0]=='S')printf("Cloudy\n");
	else if(in[0]=='C')printf("Rainy\n");
	else printf("Sunny\n");
}

Measured memory_bytes: 128
// Problem Code: abc170_c

#include <iostream>
#include <cmath>
#include <unordered_set>
#include <limits>

using namespace std;

int forbidden_list(int X, int N, unordered_set<int>& p) {
	int ele, min_d = numeric_limits<int>::max();

	for (int i = 0; i <= 101; i++)
		if (!p.count(i) && abs(X - i) < min_d) {
			ele = i;
			min_d = abs(X - i);
		}

	return ele;
}

int main() {
	int X, N;
	cin >> X >> N;
	unordered_set<int> p(N);
	for (int i = 0; i < N; i++) {
		int val;
		cin >> val;
		p.insert(val);
	}
	cout << forbidden_list(X, N, p);
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
using namespace std;

int main() {
	int N; cin >> N;
	string s, t; cin >> s >> t;

	for (int i = 0; i < N; i++) {
		cout << s[i] << t[i];
	}

	cout << endl;
}

Measured memory_bytes: 256
class UnionFind():
    #ｎは頂点数
    def __init__(self, n):
        self.parent = [-1]*n

    #aの属する集合の根を取得
    def root(self,a):
        if self.parent[a] < 0:return a
        self.parent[a] = self.root(self.parent[a])
        return self.parent[a]
    
    #aの属する集合の要素数を取得
    def size(self,a):
        return -self.parent[self.root(a)]

    #aとbをくっつける
    def connect(self,a,b):
        if self.root(a) == self.root(b):return False
        a = self.root(a);b = self.root(b)
        if self.size(a) < self.size(b):a,b = b,a
        self.parent[a] += self.parent[b]
        self.parent[b] = a
        return True

n = int(input())
x = [0]*n
y = [0]*n
for i in range(n):
    a,b = list(map(int,input().split()))
    x[i] = [a-1,i]
    y[i] = [b-1,i]
x.sort(key=lambda f: f[0])
y.sort(key=lambda f: f[0])

kouho = []
for i in range(n-1):
    kouho.append([abs(x[i][0] - x[i+1][0]),x[i][1],x[i+1][1]])
    kouho.append([abs(y[i][0] - y[i+1][0]),y[i][1],y[i+1][1]])
kouho.sort(key=lambda x: x[0])
uni = UnionFind(n)

ans = 0
for i in range(len(kouho)):
    c,f,t = kouho[i]
    if uni.root(f) == uni.root(t):continue
    ans += c
    uni.connect(f,t)
print(ans)

Measured memory_bytes: 127804
main = do
    s <- fmap (map (map read) . map words . lines) getContents
    mapM_ (mapM_ putStrLn . rect) $ takeWhile (\(a:b:_) -> a /= 0 && b /= 0) s
    where rect (h:w:_) = replicate h (replicate w '#') ++ [""]



Measured memory_bytes: 4068
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int mod=1e9+7;
int dp[50][1<<17];
int fow,S,ans;
int x,y,z;
int n;
int main()
{
    scanf("%d",&n);
    scanf("%d%d%d",&x,&y,&z);
    ans=1;
    for(int i=1;i<=n;i++)
        ans=1ll*ans*10%mod;
    S=(1<<x+y+z)-1;
    fow=(1<<x-1)|(1<<x+y-1)|(1<<x+y+z-1);
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=S;j++)
        {
            for(int k=1;k<=10;k++)
            {
                int T=(j<<k)|(1<<k-1);
                T&=S;
                if ((T&fow)!=fow) dp[i][T]=(dp[i][T]+dp[i-1][j])%mod;
            }
        }
    }
    for(int i=0;i<=S;i++)
        ans=(ans-dp[n][i]+mod)%mod;
    printf("%d\n",ans);
}


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

int main() {
  int N;
  cin>>N;
  vector<int> l(N);

  for(int i=0;i<N;i++) cin>>l[i];
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int ans=0;
  for(int i=0;i<N-2;i++){
    int a=l[i];
    for(int j=i+1;j<N-1;j++){
      int b=l[j];
      int idx=j+1;
      int c=l[idx];
      //cout<<a<<" "<<b<<" "<<c<<" "<<endl;
      while((a<b+c && b<a+c && c<a+b) && idx<N){
        //cout<<a<<" "<<b<<" "<<c<<" "<<endl;
        idx++;
        c = l[idx];
        ans++;

      }
      //ans += N-idx;
    }
  }
  cout<<ans<<endl;
}


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

int main(){
    std::ios::sync_with_stdio(0);
    int n,store=-1;
    cin>>n;
    long long k,sum=0;

    while (n>0){
        n=n-1;
        cin>>k;
        if (k>store){store=k;}

        sum+=store-k;
    }

    cout<<sum;
    return 0;
}

    

        

Measured memory_bytes: 3660
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
	
	Scanner stdIn = new Scanner(System.in);
	
	int a = stdIn.nextInt();
	int b = stdIn.nextInt();
	int c = stdIn.nextInt();
	int d = stdIn.nextInt();
	int total = 0;
	
	if (a < b) {
		total += a;
	}
	else {
		total += b;
	}
	
	if (c < d) {
		total += c;
	}
	else {
		total += d;
	}
	
	System.out.println(total);
	
	}
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        long n = scanner.nextInt();
        long val = (n * (n+1))/2;
        out.println(val-n);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        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());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
#include <stdio.h>

void PrintRectangle(int H,int W){
	int h,w;
	
	for(h=0;h<H;h++){
		if(h==0||h==H-1){
			for(w=0;w<W;w++){
				printf("#");
			}
		}
		else{
			for(w=0;w<W;w++){
				if(w==0||w==W-1){
					printf("#");
			     }
			    else{
					printf(".");
			    }
			}
		}
		printf("\n");
	}
}
		
int main(void)
{
	while(1){
		int H,W,h,w;
		scanf("%d %d",&H,&W);
		if (H==0 && W==0)
			break;
		PrintRectangle(H,W);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include<iostream>
using namespace std;
#define MAX 310000
int main(void){

	int N;
	int kazu[MAX];
	
	while(1){ 
		cin>>N;
		for(int i=0;i<=N;i++){
		    if(i%7==1||i%7==6) kazu[i]=1;
		    else kazu[i]=0;
	    }
		if(N==1)break;
		cout<<N<<":";
		for(int i=2;i<=N;i++){
			if(N%i==0&&kazu[i]==1){
				cout<<" "<<i;
				for(int j=i;j<=N;j+=i){
					kazu[j]=0;
				}
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2336
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int maxn = 3e5;
long long a[maxn];
long long sum[maxn];
long long f[maxn];
long long f1[maxn];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = 0;
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> a[i];
		sum[i+1] = sum[i] + a[i];
	}
	f[0] = inf;
	for(int i=1;i<n;i++) {
		int l = 0;
		int r = i;
		long long s = sum[i+1];
		int res = -1;
		while (l<=r) {
			int g = (l+r) >> 1;
			if (sum[g+1] * 2 >= s) {
				res = g;
				r = g-1;
			} else {
				l = g+1;
			}
		}
		if (res == i) {
			res--;	
		} else {
			if (res) {
				long long t = sum[res+1] * 2 - s;
				long long t1 = s - sum[res] * 2;
				if(abs(t1) < abs(t)) {
					res--;
				}
			}
		}
		f[i] = abs(sum[i+1] - sum[res+1] * 2);
	}

	for(int i=0;i<n/2;i++) {
		swap(a[i], a[n-i-1]);
	}
	memset(sum , 0, sizeof(sum));
	for(int i=0;i<n;i++) sum[i+1] = sum[i] + a[i];
	f1[0] = inf;
	for(int i=1;i<n;i++) {
		int l = 0;
		int r = i;
		long long s = (sum[i+1]);
		int res = -1;
		while (l<=r) {
			int g = (l+r) >> 1;
			if (sum[g+1] * 2 >= s) {
				res = g;
				r = g-1;
			} else {
				l = g+1;
			}
		}	
		if (res == i) {
			res--;	
		} else {
			if (res) {
				long long t = sum[res+1] * 2 - s;
				long long t1 = s - sum[res] * 2;
				if(abs(t1) < abs(t)) {
					res--;
				}
			}
		}
		f1[i] = abs(sum[i+1] - sum[res+1] * 2);
	}
	long long res = inf;
	for(int i=1;i<n-1;i++) {
		long long tl = f[i];
		long long tr = f1[n-i-2];
		long long sr = sum[n - i - 1];
		long long sl = sum[n] - sr;
		long long maxl = (sl + tl) / 2;
		long long minl = (sl - tl) / 2;
		long long maxr = (sr + tr) / 2;
		long long minr = (sr - tr) / 2;
		long long cost = max(tl, tr);
		//cerr << minl << " " << maxl << " " << minr << " " << maxr << endl;
		cost = max(cost, max(maxl, maxr) - min(minl, minr));
		res = min(res, cost);
	}
	cout << res;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string S;
	int t_x, t_y;
	vector<vector<bool>> x(8001, vector<bool>(16001, false));
	vector<vector<bool>> y(8001, vector<bool>(16001, false));
	cin >> S;
	cin >> t_x >> t_y;
	int start;
	for (int i = 0; i < S.size(); i++)
	{
		start = i + 1;
		if (S[i] == 'T')
		{
			start--;
			break;
		}
	}

	int pivot = 8000;

	x[0][pivot + start] = true;
	y[0][pivot] = true;
	int forward = 0;
	bool arrow = true;
	int c_x = 0;
	int c_y = 0;

	for (int i = start; i < S.size(); i++)
	{
		if (S[i] == 'F')
		{
			forward++;
		}
		else
		{

			if (0 < forward)
			{
				if (arrow)
				{
					for (int j = 0; j < 16000; j++)
					{
						if (0 <= j - forward)
							x[c_x + 1][j] = x[c_x][j - forward];
						if (j + forward <= 16000)
							x[c_x + 1][j] = x[c_x][j + forward] | x[c_x + 1][j];
					}
					c_x++;
				}
				else
				{
					for (int j = 0; j < 16000; j++)
					{
						if (0 <= j - forward)
							y[c_y + 1][j] = y[c_y][j - forward];
						if (j + forward <= 16000)
							y[c_y + 1][j] = y[c_y][j + forward] | y[c_y + 1][j];
					}
					c_y++;
				}

				forward = 0;
			}
			arrow = !arrow;
		}
	}

	if (0 < forward)
	{

		if (arrow)
		{
			for (int j = 0; j < 16000; j++)
			{
				if (0 <= j - forward)
					x[c_x + 1][j] = x[c_x][j - forward];
				if (j + forward <= 16000)
					x[c_x + 1][j] = x[c_x][j + forward] | x[c_x + 1][j];
			}
			c_x++;
		}
		else
		{
			for (int j = 0; j < 16000; j++)
			{
				if (0 <= j - forward)
					y[c_y + 1][j] = y[c_y][j - forward];
				if (j + forward <= 16000)
					y[c_y + 1][j] = y[c_y][j + forward] | y[c_y + 1][j];
			}
			c_y++;
		}

		forward = 0;
	}

	if (x[c_x][pivot + t_x] && y[c_y][pivot + t_y])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main(void)
{
  int n;
  scanf("%d", &n);
  int i;
  int a[n];
  int b[n];
  for (i = 0; i <= n; i++)
  {
    b[i] = 0;
  }
  for (i = 2; i <= n; i++)
  {
    scanf("%d", &a[i]);
    b[a[i]]++;
  }
  
  for (i = 1; i <= n; i++)
    printf("%d\n", b[i]);
  
  return 0;
}


Measured memory_bytes: 3284
#include <iostream>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)

int f(int y,int m,int d){
	int res = 0;
	FOR(i,1,y-1) res+=195+!(i%3)*5;
	FOR(i,1,m-1) res+=(!(y%3)?20:(!(i%2)?19:20));
	return res+d;
}
int main(){
	int n,y,m,d;
	cin>>n;
	REP(_,n) {
		cin>>y>>m>>d;
		cout<<f(1000,1,1)-f(y,m,d)<<endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxM = 1e5+7;
const int maxV = 90010;
 
const int MOD = 1e9+7;
 
int T;
const int maxN = 1e5+8;
const ll INF = 1000000000000000010LL;
const int K = 15;
ll a[maxN];
ll b[maxN];
int n;



int main() {
	int k,x;
	scanf("%d%d",&k,&x);
	int l = x-k+1;
	int r = x+k-1;
	for(int i=l;i<r;i++)
	{
		printf("%d ",i);
	}
	printf("%d\n",r);
    return 0;
}

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

int main(){
  int N, K, count=0;
  cin >> N >> K;
  int sunuke[N];
  for(int i=0; i<N; i++)
    sunuke[i] = 0;
  for(int i=0; i<K; i++){
    int d;
    cin >> d;
    for(int j=0; j<d; j++){
      int x;
      cin >> x;
      sunuke[x-1] = 1;
    }
  }
  for(int i=0; i<N; i++){
    if(sunuke[i]==0)
      count++;
  } 
  cout << count << endl;
}

Measured memory_bytes: 3640
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
while(n>0){
   var a=(Arr.shift()).split("").reverse().map(Number);
   var b=(Arr.shift()).split("").reverse().map(Number);
   var c=[];
   var max=Math.max(a.length,b.length);
   for(var i=0;i<max+1;i++)c[i]=0;
   for(var i=0;i<max;i++){
      var sum=0;
      if(a.length>i)sum+=a[i];
      if(b.length>i)sum+=b[i];
      c[i]+=sum;
   }
   for(var i=0;i<max;i++){
      if(c[i]>=10){
         c[i]-=10;
         c[i+1]++;
      }
   }
   if(c[c.length-1]==0)c.pop();
   var str=c.reverse().join("");
   if(c.length>80)str="overflow";
   console.log(str);
   n--;
}

Measured memory_bytes: 7908
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()

    ans = N
    while True:
        res = A[0]
        cnt = 1
        flag = False
        for i in range(1, len(A)):
            a = A[i]
            if a > 2 * res:
                ans = min(ans, len(A) - i)
                A = [res + a] + A[i + 1:]
                flag = True
                break
            else:
                res += a
        if flag:
            continue
        else:
            break

    print(ans)


Measured memory_bytes: 64108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */


int main(void){ 
    int n;
    cin >> n;
    vector<pair<double, string> > v;
    for(int i=0; i<n; i++){
        double x;
        string u;
        cin >> x >> u;
        v.push_back(make_pair(x,u));
    }

    double ans = 0;
    for(int i=0; i<n; i++){
        if(v[i].second == "JPY"){
            ans += v[i].first;
        }
        else{
            ans += v[i].first * 380000.0;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>counter(n);
  vector<int>number(n-1);
  
for(int i=0;i<n;i++){
  counter.at(i)=0;
}

for(int i=0;i<(n-1);i++){
  cin>>number.at(i);
  counter.at(number.at(i)-1)++;
}
for(int i=0;i<n;i++){
  cout<<counter.at(i)<<endl;
}
}

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

int main() {
  int h,w; cin>>h>>w;
  string board[h];
  for(int i=0; i<h ;i++){
    cin>>board[i];
  }
  const int dx[8]={1,1,0,-1,-1,-1,0,1};
  const int dy[8]={0,1,1,1,0,-1,-1,-1};

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(board[i][j]=='#') continue;
      else{
        int num=0;
        for(int t=0;t<8;t++){
          int nj=j+dx[t];
          int ni=i+dy[t];
          if(nj<0 || w<=nj) continue;
          if(ni<0 || h<=ni) continue;
          if(board[ni][nj]=='#')num++;
        }
        board[i][j]=char(num+'0');
      }
    }
  }
  for(int i=0;i<h;i++){
    cout<<board[i]<<endl;
  }
  
}
    
    


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <climits>
using namespace std;


int main(){
  long long n,p,q;
  cin >> n >> p >> q;
  vector<long long> c(n);
  // ps = ( ??¨??¨?£?????????£?????¨?????????????????\?????????????????¨??±?????????????????????, ??\??????)
  vector<pair<long long,int>> ps(n);
  // sum = ??¨??¨???????????????????????§?????????
  long long sum = 0;
  for(int i = 0; i < n; i++){
    cin >> c[i];
    sum += c[i];
    ps[i] = make_pair(c[i] + p * i, i);
  }

  sort(ps.begin(), ps.end());
  // ??????????????????????????¨?????????????????¨????????±????????????????????????????????????
  // ???????????????????????????????????????ps?????????????????????????????°??????

  long long ans = sum;
  // ??????????????\??°??§for??????????????????
  // i = (??????????????\??°)
  for(int i = 1; i <= n; i++){
    // ????????° i = 1 ?????¨??????????????????????????????????????¨?\¨??\ ps[0].second?????\???????????????
    // ???????????¨??§??±?????????????????????????????????
    // ?¬???? i = 2 ?????¨???????????£?????????ps[1].second?????\?????????????????????????????°?????????
    sum -= c[ps[i-1].second] + p * ps[i-1].second;
    // ????´??????????????????????????????§????¶????

    // (??????????????\??°)????????????????????¨????????£??????????´????????????????????????????????????????
    ans = max(ans, sum + p * i * (i-1) + p * q * i);

    // ?????????????¢???????????¶????????????§??????

    // ????????????????????°????????????????????\??\???????????§?????????????????????????????????
    // ??????????????????????????°?????????????????????????????????????????§?????????
    // sum += 2 * p * (i-1) + p * q;
    // ????????§??????????§£??¨???????????????
    // ans = max(ans, sum);

  }

  cout << ans << endl;
  return 0;


}

Measured memory_bytes: 14436
package main

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


var sc = bufio.NewScanner(os.Stdin)
func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func nextText() string {
    sc.Scan()
    return sc.Text()
}

func main() {
  // input
  sc.Split(bufio.ScanWords)
  n := nextInt()

  flag := "YES"
  var once map[int]bool = map[int]bool{}
  var second map[int]bool = map[int]bool{}
  for i := 0; i < n; i++ {
    a := nextInt()
    if once[a] != true {
      once[a] = true
    } else if second[a] != true {
      second[a] = true
      flag = "NO"
      break
    } else {
      flag = "NO"
      break
    }

  }

  // output
  fmt.Println(flag)

}


Measured memory_bytes: 8704
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=1,m=0,D; cin>>n;
    vector<ll> cnt(n,0);
    rep(i,n){
        ll d; cin>>d;
        if(i==0) D=d;
        cnt[d]++;
        m=max(m,d);
    }
    if(D!=0 || cnt[0]!=1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<=m;i++){
        rep(j,cnt[i]) ans=ans*cnt[i-1]%mod;
    }
    cout<<(3*mod+ans)%mod<<endl;
}


Measured memory_bytes: 4032
#include<iostream>
#include<cstdio>

void printLine(int l, char a, char b)
{
  for(int j = 0;  j < l ; j++) {
  if (j % 2 == 0 ) 
  printf("%c", a);
  else
  printf("%c", b);
  }
  printf("\n");
}


int main()
{
  int a, b;
  while(std::cin >> a >> b, a + b != 0 ){
  for(int i = 0 ; i < a;  i++) {
  if (i % 2 == 0){
   printLine(b, '#', '.');
   continue;
  }
   printLine(b, '.', '#');

  }
  printf("\n");}

}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
int main(){
  int l,n;
  cin>>n>>l;
  vector<string> st(n);
  for(int i=0;i<n;i++){
    cin>>st[i];
  }
  sort(st.begin(),st.end());
  for(int i=0;i<n;i++){
    cout<<st[i];
  }
}

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

#define loop(i,n) for(int i=1;i<=n;i++)
#define int long long
int n;
int mai[100002];

signed main(){
    cin>>n;
    int a;
    int sum=0;
    int sub=0;
    loop(i,n){
        cin>>a;
        mai[a]++;
        if(mai[a]==1)sum++;
        else sub++;
    }
    sum-=sub&1;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[200010];
int main()
{
	int n;
	cin>>n;
	int k;
	for(int i=1;i<=n-1;i++)
	{
		cin>>k;
		a[k]++;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<endl; 
	return 0;
}

Measured memory_bytes: 4412
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
	int d, g;
	cin >> d >> g;
	auto p = vector<int>(d + 1), c = vector<int>(d + 1);
	int n = 0, total = 0;
	for(auto i = 1; i <= d; ++i){
		cin >> p[i] >> c[i];
		c[i] /= 100;
		n += p[i];
		total += (p[i] * i);
		total += c[i];
	}
	g /= 100;
	auto dp = vector<vector<int>>(d + 1, vector<int>(total + 1, n));
	dp[0][0] = 0;
	int ans = n;
	for(auto i = 1; i <= d; ++i){
		for(auto j = 1; j <= p[i]; ++j){
			int sum = i * j + (j == p[i] ? c[i] : 0);
			for(auto k = 0; k <= total; ++k){
				dp[i][k] = min(dp[i][k], dp[i - 1][k]);
				if(k + sum <= total){
					dp[i][k + sum] = min(dp[i][k + sum], dp[i - 1][k] + j);
					if(k + sum >= g) ans = min(ans, dp[i][k + sum]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5248
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> x;
	for(int i=0;i!=n;++i){
		int temp;
		cin>>temp;
		x.push_back(temp);
	}
	int cnt=1,next=x[0];
	while(next!=2){
		next=x[next-1];
		++cnt;
		if(cnt>100000){
			cnt=-1;
			break;
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 1020
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f,g,h;
    
    
    while(cin>>a){
        if(a==0){
            break;
        }
            b=1000-a;
            c=b/500;
            d=(b%500)/100;
            e=((b%500)%100)/50;
            f=(((b%500)%100)%50)/10;
            g=((((b%500)%100)%50)%10)/5;
            h=(((((b%500)%100)%50)%10)%5)/1;
            
            cout<<c+d+e+f+g+h<<endl;
    }
        
}



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


int main()
{
    const int Pow[4] = {1, 10, 100, 1000};
    int n, m;
    cin >> n >> m;
    int s[6], c[6];
    for (int i = 1; i <= m; i++) {
        cin >> s[i] >> c[i];
    }
    
    bool ok;
    int xmin, xmax;
    if (n == 1) {xmin = 0; xmax = 9;}
    else if (n == 2) {xmin = 10; xmax = 99;}
    else {xmin = 100; xmax = 999;}
    for (int x = xmin; x <= xmax; x++) {
        ok = true;
        for (int i = 1; i <= m; i++) {
            if (x / Pow[n - s[i]] % 10 != c[i]) {
                ok = false;
                break;
            }
        }
        if (ok) {cout << x << endl; break;}
    }
    if (!ok) cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	for i := 1; i < 10000; i++ {
		if int(float64(i)*0.08) == a && int(float64(i)*0.1) == b {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)
}


Measured memory_bytes: 512
#include <iostream>
#include <map>

const int MAX_VERTEX =  100005;

using namespace std;

int incc [MAX_VERTEX];

int main () {
  int vertexc, queryc;
  cin >> vertexc >> queryc;

  for (int i = 0; i < queryc; i++) {
    int u, v;
    cin >> u >> v;

    incc[u]++;
    incc[v]++;
  }

  for (int i = 1; i <= vertexc; i++) {
    if (incc[i] % 2 == 1) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}

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

  #define MAX 100005
  #define NIL -1

  struct Node {
    int p,l,r;
  };

  struct Node T[MAX];
  int n,D[MAX];

  void print(int u){
    int i,c;
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].p);
    printf("depth = %d, ",D[u]);
    if(T[u].p==NIL)printf("root, ");
    else if(T[u].l==NIL) printf("leaf, ");
    else  printf("internal node, ");

    printf("[");
    for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
      if(i) printf(", ");
      printf("%d",c);
    }
   printf("]\n");
  }

  void rec(int u, int p){
    D[u]=p;
    if(T[u].r!=NIL)rec(T[u].r,p);
    if(T[u].l!=NIL)rec(T[u].l,p+1);
  }


  int main(){
    int num,i,j,d,v,c,l,r;
    scanf("%d",&num);
    for(i=0;i<num;i++){
      T[i].p=T[i].l=T[i].r=NIL;
    }
    for(i=0;i<num;i++){
       scanf("%d",&v);
       scanf("%d",&d);
       for(j=0;j<d;j++){
         scanf("%d",&c);
         if(j==0)T[v].l=c;
         else T[l].r=c;
         l=c;
         T[c].p=v;
       }
    }
    for(i=0;i<num;i++){
      if(T[i].p==NIL)r=i;
    }

    rec(r,0);
    for(i=0;i<num;i++)print(i);

    return 0;
  }



Measured memory_bytes: 6424