akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

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

    int root_n = 1;
    for(; root_n*root_n<n; ++root_n);

    // initialize container
    vector<int> array(n, 0);
    vector<int> blocks(root_n, 0);
    rep(_, 0, q)
    {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0)
        {
            --x;
            array[x] += y;
            blocks[x/root_n] += y;
        }
        else
        {
            --x, --y;
            int block_s = x/root_n + 1;
            int block_t = y/root_n - 1;

            int res = 0;
            for (int i=block_s; i<=block_t; ++i)
                res += blocks[i];
            for (int i=x; i<block_s*root_n and i<=y; ++i)
                res += array[i];
            
            if (y/root_n != x/root_n)
            {
                for (int i=(y/root_n)*root_n; i<=y; ++i)
                    res += array[i];
            }
            printf("%d\n", res);
        }
    }
    return 0;
}



Measured memory_bytes: 3344
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0 for i in range(m)]
b = [0 for i in range(m)]
for i in range(m):
  a[i], b[i] = map(int, input().split())
  a[i] -= 1
  b[i] -= 1
v = [True for i in range(n)]
for i in range(m):
  if h[a[i]] <= h[b[i]]:
    v[a[i]] = False
  if h[a[i]] >= h[b[i]]:
    v[b[i]] = False
ans = 0
for x in v:
  if x:
    ans += 1
print(ans)


Measured memory_bytes: 90080
#include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

typedef pair<int,int> P;

struct UnionFind{
	std::vector<int> data;
	UnionFind(int size): data(size, -1){ }
	// ?????????????????????
	bool unite(int x, int y){
		x=root(x); y=root(y);
		if( x != y ) data[y] = x;
		return x!=y;
	}
	// ??????????????????????????????
	bool find(int x, int y){
		return root(x) == root(y);
	}
	// ??????????????\???????????????
	int root(int x){
		// ???????????????????????????????????????????????????
		return (data[x] < 0)? x : data[x]=root(data[x]);
	}
};

int N, M, a[50000], b[50000], c[50000];
vector<P> vh, vc;

int solve2(UnionFind &uf, const vector<int> &l, int z){
	int sum = 0;
	UnionFind ufl = uf;
	for(auto t: l){
		ufl.unite( z, t );
	}
	for(auto c: vc){
		int i = c.second;
		if( uf.find(a[i], b[i]) ) continue;
		if( !ufl.find(z, a[i]) ) continue;
		if( !ufl.find(z, b[i]) ) continue;
		uf.unite( a[i], b[i] );
		sum += c.first;
	}
	return sum;
}

int solve(int limit){
	int now = limit;
	int z = vh[0].second;
	int ans = 0;
	UnionFind uf(205);
	vector<int> l;
	vh.emplace_back(0,0);
	for(auto v: vh){
		if( v.first >= limit && now != v.first ){
			ans += solve2(uf, l, z);
			l.clear();
		}
		l.push_back( v.second );
		now = max( v.first, limit );
	}
	return ans;
}

int calc(){
	int limit = 0;
	while(1){
		int nx = vh.size()-1;
		bool sink[205]={}; //sink[0] = true;
		while(limit <= vh[nx].first){
			sink[ vh[nx].second ] = true;
			nx--;
			if( nx < 0 ) return limit;
		}

		UnionFind uf(205);
		int z = vh[0].second;
		for(auto c: vc){
			int i = c.second;
			if( sink[ a[i] ] || sink[ b[i] ] ) continue;
			uf.unite( a[i], b[i] );
		}
		rep(i,N) if( !sink[i] && !uf.find(z,i) ) return limit;
		limit = vh[nx].first;
	}
	return limit;
}

int main(){
	while(cin >> N >> M, N|M){
		vh.clear(); vc.clear();
		rep(i,N){
			int h;
			cin >> h;
			vh.emplace_back( -h, i );
		}
		sort( vh.begin(), vh.end() );
		rep(i,M){
			cin >> a[i] >> b[i] >> c[i];
			a[i]--; b[i]--;
			vc.emplace_back( c[i], i );
		}
		sort( vc.begin(), vc.end() );
		cout << solve( calc() ) << endl;
	}
	return 0;
}

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


void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
  map<long long, long long> m;
  for (int i=0; i<M; i++) {
    if (m.count(C[i])) m[C[i]] += B[i];
    else m[C[i]] = B[i];
  }
  for (auto a : A) {
    if (m.count(a)) m[a]++;
    else m[a] = 1;
  }

  long long ret = 0;
  int n = 0;
  for (auto iter=m.rbegin(); iter != m.rend() && n < N; iter++) {
    for (int i=0; i<(*iter).second && n < N; i++, n++) ret += (*iter).first;
  }
  cout << ret << endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  std::vector<long long> B(M);
  std::vector<long long> C(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&B[i]);
    scanf("%lld",&C[i]);
  }
  solve(N, M, std::move(A), std::move(B), std::move(C));
  return 0;
}


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

using namespace std;

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

char grid[55][55];
int n, m;

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", grid[i]);
  }
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < m; y++) {
      if (grid[x][y] == '.') {
        continue;
      }
      int found = 0;
      for (int k = 0; k < 4; k++) {
        int xk = x + dx[k];
        int yk = y + dy[k];
        if (xk < 0 || xk >= n || yk < 0 || yk >= m) {
          continue;
        }
        if (grid[xk][yk] == '#') {
          found = 1;
          break;
        }
      }
      if (found == 0) {
        puts("No");
        exit(0);
      }
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
<?php
list($a,$b) = explode(" ",trim(fgets(STDIN)));

// Zero 判定
if ( ($a < 0 && $b > 0) || ($a == 0) || ($b == 0) ) {
	echo 'Zero'.PHP_EOL;
	return 0;
}

// Negative 判定
if ( !($a == $b) && ($a < 0) && !(($a - $b) % 2) ) {
	echo 'Negative'.PHP_EOL;
	return 0;
}

// その他はすべて Positive
echo 'Positive'.PHP_EOL;
return 0;


Measured memory_bytes: 3832
def suicide(lis):
    if len(lis) == 1:
        print lis[0]
        return
    pokakito = []
    for i in range(len(lis)-1):
        check = lis[i] + lis[i+1]
        one = int(str(check)[-1])
        pokakito.append(one)
    else:
        suicide(pokakito)

while True:
    try:
        lis = [int(char) for char in raw_input()]
        suicide(lis)
    except EOFError:
        break

Measured memory_bytes: 4220
#include<cstdio>
#include<cstring>
#include<string>

using namespace std;
char x[12],y[12],z[12];

int main()
{
	scanf("%s",x);
	scanf("%s",y);
	scanf("%s",z);
	char a = x[0] - 32;
	char b = y[0] - 32;
	char c = z[0] - 32;
	printf("%c%c%c\n",a,b,c);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);


int main(){
	string s,t;
	cin>>s>>t;
	std::vector<ll> adj[26];
	char u;
	fo(i,sz(s)){
		u=s[i];
		adj[u-'a'].pb(i);
	}
	for(auto k:t){
		if(sz(adj[k-'a'])>0) ;
		else {
			cout<<-1<<endl;
			return 0;
		}
	}

	ll days=0;
	ll index=-1;
	ll total=0;
	ll tmp;

	fo(i,sz(t)){

		u=t[i];
		auto it=upper_bound(all(adj[u-'a']),index);
		if(it==adj[u-'a'].end()) {
			days++;
			index=adj[u-'a'][0];
		}
		else{
			index=*it;

		}
		//dbg3(index,u,days);


	}
	//dbg(days);
	ll ans=(days*sz(s)+index+1);
	cout<<ans<<endl;

}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N, K;
	cin >> N >> K;
	int A[2000];
	rep(i, N) cin >> A[i];

	int kobetu = 0;
	rep(i, N) {
		for (int j = i + 1; j < N; j++) if (A[i] > A[j]) kobetu++;
	}
	ce(kobetu);
	int zenbu = 0;
	rep(i, N) rep(j, N) if (A[i] > A[j]) zenbu++;
	ce(zenbu);

	ll mod = 1e9 + 7;
	ll kotae = (ll)kobetu * K % mod;

	ll are = (ll)K * (K - 1) / 2 % mod;
	kotae += are * zenbu % mod;

	co(kotae% mod);


	Would you please return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 入力
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();

		// 出力
		System.out.println((X - Z) / (Y + Z));

		sc.close();
	}
}


Measured memory_bytes: 20820
N,x=map (int, input().split())
a=list( map(int, input().split()) )

happy=0
a.sort()

for i in range(N):
    
    if a[i] > x:
        break

    else:
        x=x-a[i]
        happy=happy+1

if x!=0 and happy==N:
    happy=happy-1
    
print(happy)


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n, m, A[100][100], b[100], c[100];
 cin >> n >> m;
 for ( int i = 0; i < n; i++)
  for ( int j = 0; j < m; j++) cin >> A[i][j];
 for ( int i = 0; i < m; i++) cin >> b[i];
 for ( int i = 0; i < n; i++){
  c[i] = 0;
  for ( int j = 0; j < m; j++){
   c[i] += A[i][j]*b[j];
  }
  }
 for ( int i = 0; i < n; i++ ) cout << c[i] << endl;
 return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int h,w,d;

int a[353][353];

pii rev[353*353];

int nxt[353*353][20];

int main(){
  scanf("%d%d%d",&h,&w,&d);
  REP(i,h)REP(j,w)scanf("%d",&a[i][j]),a[i][j]--;
  REP(i,h)REP(j,w)rev[a[i][j]] = pii(i,j);
  REP(i,h*w){
    int to = i+d;
    if(to>=h*w)continue;
    pii s = rev[i];
    pii t = rev[to];
    nxt[i][0] = abs(s.first-t.first) + abs(s.second-t.second);
  }
  FORR(i,0,h*w){
    FOR(j,1,20){
      nxt[i][j] = nxt[i][j-1];
      if(i+(1ll<<(j-1))*d<h*w){
        nxt[i][j] += nxt[i+(1ll<<(j-1))*d][j-1];
      }
    }
  }
  // REP(i,h*w){
  //   REP(j,10)printf("%3d",nxt[i][j]);puts("");
  // }
  int q;
  scanf("%d",&q);
  while(q--){
    int l,r;
    scanf("%d%d",&l,&r);
    l--;r--;
    int ans = 0;
    FORR(i,0,20){
      if(l+(1ll<<i)*d<=r){
        ans += nxt[l][i];
        l += (1<<i)*d;
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 12032
def main():
    n = int(input())
    x = list(map(int, input().split()))
    ans = 0
    for i in range(n-1):
        if x[i] > x[i+1]:
            ans += x[i]-x[i+1]
            x[i+1] = x[i]
    print(ans)


main()


Measured memory_bytes: 32124
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long

ll a[100009], r[100009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	ll t = 1;
	for (int i = 0; i < n; i++) {
		if (i == 0 || i == n - 1) r[i] = t;
		else r[i] = t * 2;
		t *= -1;
	}
	sort(r, r + n);
	ll sa = 0, sb = 0;
	for (int i = 0; i < n; i++) {
		sa += a[i] * r[i];
		sb += a[i] * r[n - i - 1] * -1;
	}
	cout << max(sa, sb) << '\n';
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
long long ans=0,a,b,c,n,h,w;
int main(){
  cin >> h >> w;
  char c[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> c[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int cnt=0;
      if(i!=0){
        if(c[i-1][j]=='#'){
          cnt++;
        }
      }
      if(i!=h-1){
        if(c[i+1][j]=='#'){
          cnt++;
        }
      }
      if(j!=0){
        if(c[i][j-1]=='#'){
          cnt++;
        }
      }
      if(j!=w-1){
        if(c[i][j+1]=='#'){
          cnt++;
        }
      }
      if(cnt==0&&c[i][j]=='#'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l2=[]
for i in range(n):
  l2.append([l[i][0]+l[i][1],l[i][0]-l[i][1]])
l2.sort()

ans = 0
tt = -10**9
for i in range(n):
    if tt <=l2[i][1]:
        ans += 1
        tt = l2[i][0]
print(ans)

Measured memory_bytes: 42248
#include<cstdio>
#include<cstring>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int a[MAXN];
int sum,n;
int main(){
	SF("%d%d",&n,&sum);
	for(int i=1;i<=n;i++)
		SF("%d",&a[i]);
	sort(a+1,a+1+n);
	int ans=0;
	for(int i=1;i<n;i++){
		if(sum<a[i])
			break;
		sum-=a[i];
		ans++;
	}
	if(a[n]==sum)
		ans++;
	PF("%d",ans);
} 

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

struct ModCombination {
    vector<mint> Fac;
    vector<mint> Facinv;

    ModCombination(int x) {
        Fac.resize(x+1);
        Facinv.resize(x+1);
        Fac[0] = 1;
        for (long long i = 1; i <= x; i++) Fac[i] = Fac[i-1]*i;
        Facinv[x] = Fac[0]/Fac[x];
        for (long long i = x; i > 0; i--) Facinv[i-1] = Facinv[i]*i;
    }

    mint get(int n, int k) {
        if (k < 0 || k > n) return 0;
        return Fac[n]*Facinv[k]*Facinv[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,W,A,B; cin >> H >> W >> A >> B;

    ModCombination MC(H+W);
    mint ans = 0;
    for (int i = 1; i <= W-B; i++) {
        ans += MC.get(H-A+B+i-2,H-A-1)*MC.get(A+W-B-i-1,A-1);
    }

    cout << ans.a << endl;
}

Measured memory_bytes: 3328
//#pragma GCC optimize(3)

#include<bits/stdc++.h>
#define MST(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i = a ; i < b ; ++i)
#define per(i,a,b) for(int i = a ; i > b ; --i)
#define ALL(v) v.begin(),v.end()
#define ft first
#define sd second
using namespace std;
namespace fast_IO{
    const int maxbuff = 1<<17;
    char ibuff[maxbuff],obuff[maxbuff];
    inline char Getchar(){
        static char *p1=ibuff,*p2=ibuff;
        if(p1 == p2) {
            p1 = ibuff;
            p2 = ibuff+fread(ibuff,1,maxbuff,stdin);
            if(p1 == p2) return -1;
        }
        return *p1++;
    }

    int optr = 0;
    inline void Putchar(char c) {
        if(optr == maxbuff) {fwrite(obuff,1,optr,stdout);optr = 0;}
        obuff[optr++] = c;
    }

    inline void Flush() {
        fwrite(obuff,1,optr,stdout);
    }

    template<class T>
    inline int read(T &x) {
        x = 0;
        char c = Getchar();
        if(c == EOF) return -1;
        for( ; (c < '0' || c > '9') && c != EOF ; c = Getchar());
        if(c == EOF) return -1;
        for( ; c >= '0' && c <= '9' ; c = Getchar()) x = x*10+c-'0';
        return 0;
    }

    template<class T>
    inline void write(const T &x,int tag = 0) {
        if(!x) {
            if(!tag) Putchar(x+'0');
            return ;
        }
        write(x/10,1);
        Putchar(x%10+'0');
    }

    template<class T>
    inline void writeln(const T &x) {
        write(x);Putchar('\n');
    }

    template<class T>
    inline void writesp(const T &x) {
        write(x);Putchar(' ');
    }
}
template<class T> void show(T *x,int len,int s = 0) {for(int i = s ; i < s+len-1 ; ++i) cerr << x[i] << ' ';cerr << x[s+len-1] << endl;}
void debug() {cerr << endl;}
template <typename T, typename... Args> void debug(T x,Args... args) {cerr << x << ' ';debug(args...);}
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
#include <ext/pb_ds/priority_queue.hpp>
using namespace __gnu_pbds;
typedef __gnu_pbds::priority_queue<pii,greater<>,pairing_heap_tag> heap;
typedef heap::point_iterator iter;

template<class T>
inline void cmin(T &A,const T &B) {A = (A<B?A:B);}
template<class T>
inline void cmax(T &A,const T &B) {A = (A>B?A:B);}

void solve() {
    LL x,y,n;
    cin >> x >> y >> n;
    x = max(x,y);
    cout << n/x + !!(n%x) << endl;
}

signed main() {
#ifdef LOCAL
    //freopen("input","r",stdin);
    //freopen("output","w",stdout);
#endif
    srand((int)time(0));
    ios::sync_with_stdio(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
typedef pair<int,int> pii;
typedef long long ll;	


ll x, k, d, s;

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

	
	cin >> x >> k >> d;
	x = abs(x);
	s = min(k,x/d);
	x -= s*d;
	k -= s;
//	cout << x << " " << k << " " <<s << "\n";
	if (k % 2 == 0) {
		cout << x << "\n";
	}
	else {
		cout << abs(x-d) << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;

	ll minvalue(ll x,ll y){
		if(x<y)
			return x;
		return y;
	}

	int main()
	{
		std::ios::sync_with_stdio(false);
		ll x,k,d;
		cin>>x>>k>>d;
		x=abs(x);
		if((x/d)>k){
			cout<<x-(k*d)<<"\n";
			return 0;
		}
		ll ans1=x-(x/d)*d;
		ll ans2=abs(ans1-d);
		//cout<<ans1<<" ";
		if((k-x/d)%2==0)
			cout<<ans1<<"\n";
		else
			cout<<ans2<<"\n";
		return 0;
	}


Measured memory_bytes: 3644
a = input()

if 1 <= int(a[:2]) <= 12 and 1 <= int(a[2:]) <= 12:
    print("AMBIGUOUS")
elif 1 <= int(a[:2]) <= 12:
    print("MMYY")
elif 1 <= int(a[2:]) <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll INF=1LL<<60;
const ll mod=1E9+7;

int main(){
  string s,t;
  cin >> s >> t;
  rep(i,s.size()){
    if(s[i]!=t[i]){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}



Measured memory_bytes: 3600
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var NX=Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();
            var N = NX[0];
            var X = NX[1];
            var ms = new List<int>();
            for(var i = 0;i<N;i++)
            {
                ms.Add(int.Parse(Console.ReadLine()));
            }
            var count = N;
            X -= ms.Sum();
            count += (int)(X / ms.Min());
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13396
#include<cstdio>
#include<algorithm>
using namespace std;
int n, w[310], C[4];
double D[310][310][310];
int main() {
	int i, j, k;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
		C[w[i]]++;
	}
	for (i = 0; i <= n; i++) {
		for (j = 0; i+j <= n; j++) {
			for (k = 0; i+j+k <= n; k++) {
				if (i == 0 && j == 0 && k == 0)continue;
				double t1 = 0.0, t2 = 0.0, t3 = 0.0;
				if (i)t1 = D[i - 1][j + 1][k] * i / n;
				if (j)t2 = D[i][j - 1][k + 1] * j / n;
				if (k) t3 = D[i][j][k - 1] * k / n;

				D[i][j][k] = 1.0*n / (i + j + k)*(t1+t2+t3+1);
			}
		}
	}
	printf("%.15f\n", D[C[3]][C[2]][C[1]]);
}

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

ll MOD = 998244353;
ll modpow(ll x, ll y, ll n) {
    ll res = 1;
    x%=n;
    while (y>0) {
        if (y%2==1) {
            res*=x;
            res%=n;
        }
        y/=2;
        x*=x;
        x%=n;
    }
    return res;
}

int main() {
    ll res = 0;
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> facts(n+1), invs(n+1);
    facts[0] = 1;
    invs[0] = 1;
    for (ll i=1; i<=n; i++) {
        facts[i] = (i*facts[i-1])%MOD;
        invs[i] = modpow(facts[i],MOD-2,MOD);
    }
    for (ll i=0; i<=k; i++) {
        /*
        ll ans = m;
        ans*=modpow(m-1,n-1-i,MOD);
        ans%=MOD;
        ans*=facts[n-1];
        ans%=MOD;
        ans*=invs[i];
        ans%=MOD;
        ans*=invs[n-1-i];
        ans%=MOD;
        res+=ans;
        */
        res+=(m*modpow(m-1,n-1-i,MOD)%MOD)*(facts[n-1]*invs[i]%MOD*invs[n-1-i]%MOD);
        res%=MOD;
    }
    cout << res;
    return 0;
}

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

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

    int T;
    cin >> T;
    LL res = 0;
    for (int i = 1; i <= T; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        res += i;
    }
    cout << res <<'\n';

    return 0;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n, q, k;

const int MAX_V = 101010;
struct edge{int to; ll cost;};
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+n, LINF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(int i = 0; i < (int)G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main()
{
    //FILE* fp_in = freopen("input.txt","r",stdin);
    cin >> n;
    rep(i,n-1){
        int to,from;
        ll cost;
        cin >> to >> from >> cost;
        edge e = {to-1,cost};
        G[from-1].pb(e);
        edge er = {from-1,cost};
        G[to-1].pb(er);
    }

    cin >> q >> k;
    k--;

    dijkstra(k);

    rep(i,q){
        int x,y;
        cin >> x >> y;
        x--; y--;
        cout << d[x]+d[y] << endl;
    }

}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

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

	bool res = true;
	for(int i = 0; i < 3; i++){
		if(S[i] == S[i+1]) res = false;
	}

	cout << (res ? "Good" : "Bad") << '\n';

	return 0;
}

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int D = nextInt();
		String ans = "";
		if(D==7||D==5||D==3){
			ans="YES";
		}else{
			ans="NO";
		}




		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  cin >> N;
  cin >> S;
  ;
}
void solve() {
  int cnti = 0;
  int cntd = 0;
  int maxd = -INF;
  rep(i, 0, N - 1) {
    if (S[i] == 'I') {
      cnti++;
    } else {
      cntd++;
    }
    maxd = max(maxd, cnti - cntd);
  }
  cout << max(0LL, maxd) << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

int n;

int main(void) {
	cin >> n;
	int M = 0, MM=0;
	for (int i = 1; i <= n; i++) {
		if (M > n)
			break;
		M += i;
		MM = i;
	}
	int sub = M - n;
	for (int i = 1; i <= MM; i++) {
		if (i != sub)
			cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N]; // 距離で訪問状態 (color) を管理する

void bfs(int s) {
	queue<int> q; // 標準ライブラリの queue を使用
	q.push(s);
	for ( int i = 0; i < n; i++ ) d[i] = INFTY;
	d[s] = 0;
	int u;
	while ( !q.empty() ) {
		u = q.front(); q.pop();
		for ( int v = 0; v < n; v++ ) {
			if ( M[u][v] == 0 ) continue;
			if ( d[v] != INFTY ) continue;
			d [v] = d[u] + 1;
			q.push(v);
		}
	}
	for ( int i = 0; i < n; i++ ) {
		cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
	}
}

int main() {
	int u, k, v;
	
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) M[i][j] = 0;
	}
	
	for ( int i = 0; i < n; i++ ) {
		cin >> u >> k;
		u--;
		for ( int j = 0; j < k; j++ ) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	
	bfs(0);
	
	return 0;
}


Measured memory_bytes: 3156
def main():
	N = int(input())
	A = [int(i) for i in input().split()]
	
	if 0 in A:
		print(0)
		return
	
	res = 1
	top = 10 ** 18
	for a in A:
		res *= a
		if res > top:
			print(-1)
			return
	print(res)

if __name__ == "__main__":
	main()


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

template<typename T>
void trace(T *a, int s, int n) {
    for (int i=s; i<n; i++) {
	cout<<a[i]<<" ";
    }
    cout<<endl;
}



typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e4;

int h,w,k;

ll dp[maxn][11];

bool valid(int mask) {
    bool last=false;
    for (int j=0; j<w-1; j++) {
	if (mask>>j&1) {
	    if (last) return false;
	    last=true;
	} else {
	    last=false;
	}
    }
    return true;
}

ll dfs(int r, int c) {
    if (r<0 || r>h || c<0 || c>=w) return 0;

    //cout<<r<<" "<<c<<endl;
    
    if (r==0) {
	return c==k-1;
    }

    if (~dp[r][c]) return dp[r][c];
    
    ll &res = dp[r][c] = 0;
    
    for (int mask=0; mask<(1<<(w-1)); mask++) {
	if (!valid(mask)) continue;
	//cout<<bitset<4>(mask)<<endl;
	if (mask>>c&1) {
	    res += dfs(r-1,c+1);
	} else if (c>0 && (mask>>(c-1)&1)) {
	    res += dfs(r-1,c-1);
	} else {
	    res += dfs(r-1,c);
	}
	res %= mod;
    }

    return res;
}

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

    memset(dp,-1,sizeof(dp));
    cin>>h>>w>>k;
    ll ans = dfs(h,0);
    ans %= mod;
    ans += mod;
    ans %= mod;
    out(ans);
    return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << double(w * h) / double(2) << " ";
    if(w == x*2 && h == y*2) cout << 1;
    else cout << 0;
    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <array>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; ++i){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int sum = 0;
    for(int i=0; i<n; ++i){
        if(i == n-1){
            sum += p[i] / 2;
        }
        else {
            sum += p[i];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int Count(bool [], int, int);

int main() {
  const int N = 1000000;
  bool num[N];
  for (int i = 0; i < N; i++)
    num[i] = true;

  const int N_MAX = 999999;
  const double MAX = sqrt(N_MAX);
  for (int i = 2; i <= MAX; i++) {
    if (num[i]) {
      for (int j = i; i*j <= N_MAX; j++) {
        num[i * j] = false;
      }
    }
  }

  int data;
  while (cin >> data) {
    cout << Count(num, 2, data) << endl;
  }
}

int Count(bool data[], int begin, int end) {
  int count = 0;
  for(int i = begin; i <= end; i++)
    if (data[i])
      count++;

  return count;
}

Measured memory_bytes: 2132
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n, m; cin >> n >> m;
    vector<vector<int>> g(n);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
    }

    int s, t; cin >> s >> t;
    s--;
    t--;

    queue<pair<int, int>> que;
    vector<vector<bool>> used(n, vector<bool> (4, false));
    que.push({s, 0});
    used[s][0] = true;

    while(!que.empty()){

        int cur = que.front().first;
        int cost = que.front().second;
        int ncost = (cost + 1);
        que.pop();
        if(cur == t && cost % 3 == 0){
            cout << cost / 3 << endl;
            return 0;
        }
        
        for(int i = 0; i < (int)g[cur].size(); i++){
            int nxt = g[cur][i];
            if(!used[nxt][ncost % 3]){
                used[nxt][ncost % 3] = true;
                que.push({nxt, ncost});
            }
        }
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    set<int> st;
    rep(i, n) {
        int a;
        cin >> a;
        st.insert(a);
    }
    cout << st.size() << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

const ll D = 60; //2^60でkを上回る
const ll MAX_N = 200005;
ll to[D][MAX_N] = {};

int main() {

    ll n, k; cin >> n >> k;

    //ダブリングで解く
    //to[i][j]: jから2^i先がどの点になるのか
    for (int i = 0; i < n; ++i) {
        cin >> to[0][i];
        to[0][i]--; //0-index
    }

    for (int i = 0; i < D - 1; ++i) {
        for (int j = 0; j < n; ++j) {
            to[i + 1][j] = to[i][to[i][j]]; //to[i][j]を2回繰り返すだけ
        }
    }

    int v = 0; //最初の位置
    for (int i = D - 1; i >= 0; --i) { //2^60乗でkを超えるので、2^59以下で行き先は表せる
        ll l = 1ll << i; //l個先
        if (l <= k) {
            v = to[i][v];
            k -= l;
        }
    }

    cout << v + 1 << endl; //0-indexにしていたので、戻す
}

Measured memory_bytes: 97308
import java.util.Scanner;

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

        int str = scanner.nextInt();
        int cnt = scanner.nextInt();

        if (str > cnt) {
            int t = str;
            str = cnt;
            cnt = t;
        }

        for (int i=0; i<cnt; i++) {
            System.out.print(str);
        }
    }
}

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

int n,a[100010],sum1,sum2,cnt,s;

int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%4==0) sum1++;
		if(a[i]%4==1||a[i]%4==3) sum2++;
		if(a[i]==2) s++;
		if(a[i]%4==2) cnt++;
	}
	sum1+=s/2;
	if(sum1+1>=sum2+min(1,cnt)) cout<<"Yes"; else cout<<"No";
	
	return 0;
}

Measured memory_bytes: 640
main = do
  i <- read <$> getLine

  print $ [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51] !! (i - 1)

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


int main (){

    int H,W;
    cin >> H >> W;
    char a[H+2][W+2];
    int b[H+2][W+2] = {};
    for(int i = 1; i < H+1; i++) {
        for(int j = 1; j < W+1; j++) {
            cin >> a[i][j];
            b[i][j]++;
        }
    }

    for(int i = 0; i < H+2; i++) {
        for(int j = 0; j < W+2; j++) {
            if(b[i][j] == 0) {
                cout << '#';
            }else if(b[i][j] == 1){
                cout << a[i][j];
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef unsigned long long ll;
typedef pair<ll, ll> pii;
#define X first
#define Y second
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
// change type to pair & use counter for multi-set
typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;

void fastInOut();
const double EPS = 1e-8;
const int MOD = 998244353 ;
const int N = 3e3 + 5;

string s, t;
int ssz, tsz;
int dp[N][N];

int solve(int i=0, int j=0)
{
    if(i == ssz && j == tsz) return 0;
    if(i > ssz || j > tsz) return -1e8;
    int &res = dp[i][j];
    if(~res) return res;
    res = solve(i+1, j+1) + (s[i] == t[j]);
    res = max(res, solve(i+1, j));
    res = max(res, solve(i, j+1));
    return res;
}

void print(int i=0, int j=0)
{
    if(i == ssz && j == tsz) return;
    int &res = dp[i][j];
    //res = solve(i+1, j+1) + (s[i] == t[j]);
    if(res == solve(i+1, j+1) + (s[i] == t[j])) {
        if(s[i] == t[j]) cout << s[i];
        print(i+1, j+1);
        return;
    }
    //res = max(res, solve(i+1, j));
    if(res == solve(i+1, j)) {
        print(i+1, j);
        return;
    }
    //res = max(res, solve(i, j+1));
    print(i, j+1);
    return;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    fastInOut();
    memset(dp, -1, sizeof(dp));
    cin >> s >> t;
    ssz = s.size(); tsz = t.size();
    solve(); print();
    return 0;
}

void fastInOut() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
}


Measured memory_bytes: 36096
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  set<string> A;
  int n = 0; cin>>n;
  for(int i = 0; n > i; i++){
    string s;cin>>s;
    A.insert(s);
  }
  cout << A.size() << endl;
}

Measured memory_bytes: 19284
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  
 
int main() {
    int N; cin >> N;

    string res = "";
    int i = 0;
    if (N == 0) res = "0";
    else {
        while (abs(N) != 0) {
            if (abs(N) % 2 == 1) {
                res += "1";
                N += pow(-1,i+1);
            }
            else res += "0";
            N /= 2;
            i++;
        }
    }

    reverse(res.begin(), res.end());
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(int argc, char const *argv[]) {
  int H, W;
  scanf("%d %d", &H, &W);
  char s[H][W];
  for (int i = 0; i < H; i++) {
    scanf("%s", s[i]);
  }

  // for (int i = 0; i < H; i++) {
  //   for (int j = 0; j < W; j++) {
  //     printf("%c", s[i][j]);
  //   }
  // }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '#') {
        if (i + 1 < H) {
          if (s[i + 1][j] == '#') {
            goto ok;
          }
        }
        if (i - 1 >= 0) {
          if (s[i - 1][j] == '#') {
            goto ok;
          }
        }
        if (j + 1 < W) {
          if (s[i][j + 1] == '#') {
            goto ok;
          }
        }
        if (j - 1 >= 0) {
          if (s[i][j - 1] == '#') {
            goto ok;
          }
        }
        printf("No\n");
        return 0;
        ok:{}
      }
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
void solve() {
	int n;
	cin >> n;
	string s;
	// vector<string> arr;
	vector<pii> pos, neg;
	int initial = 0;
	forn(i, n){
		cin >> s;
		int minValue = 0, totalValue = 0;
		trav(c, s){
			if(c == '(') totalValue++;
			else totalValue--;
			minValue = min(minValue, totalValue);
		}
		if(totalValue < 0){
			neg.pb({-minValue + totalValue, totalValue});
		}else{
			pos.pb({-minValue, -totalValue});
		}
	}
	sort(all(pos));
	sort(all(neg), greater<pii>());
	bool ok = true;
	trav(k, pos){
		if(initial < k.F){
			ok = false;
			break;
		}
		initial += -k.S;
	}
	if(ok)
	trav(k, neg){
		if(initial < (k.F - k.S)){
			ok = false;
			break;
		}
		initial += k.S;
	}
	ok &= (initial == 0);
	if(!ok) cout << "No";
	else cout << "Yes";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 11264
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

   int s,w; cin>>s>>w;

   if(w >= s)cout<<"unsafe\n";
   else cout<<"safe\n";
   

    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



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

int main(){
    string s,t;
    cin >> s >> t;
    bool res = true;
    if(t.size() == s.size() + 1){
        for( int i = 0;i<s.size();i++){
            if(s.at(i) != t.at(i)) res = false;
        }
    } else {
        res = false;
    }
    if(res){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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


int main() {

	int a, b;
	int f;
	bool check = false;
	std::cin >> a >> b;
	f = a;

	for (long long i = 0; i < 1000; i++) {
		if (f%b != 0) {
			std::cout << f << std::endl;
			check = true;
			break;
		}
	}
	if (check == false) {
		std::cout << "-1" << std::endl;
	}
}

Measured memory_bytes: 256
from functools import reduce
import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
t = IR(n)


def lcm_base(a, b):
    return (a * b) // math.gcd(a, b)


def lcm_list(l): return reduce(lcm_base, l, 1)


ans = lcm_list(t)
print(ans)


Measured memory_bytes: 9476