akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    string s;
    cin >> s;
    ll X,Y;
    cin>>X>>Y;
    ll N=s.size();
    ll si=0;
    while(si<N&&s[si]!='T')si++;
    X-=si;
    
    ll xy=0,d=0;
    vvc<ll> xyl(2,vl(1,0));
    repe(i,si,N){
    	if(s[i]=='T'){
    		if(d)xyl[xy].eb(d);
    		xy=(xy+1)%2;
    		d=0;
    	}else
    		d++;
    }
    if(d)xyl[xy].eb(d);
    
    ll szx=0,szy=0;
    for(auto x:xyl[0])szx+=x;
    for(auto y:xyl[1])szy+=y;
    if(X<-szx||szx<X||Y<-szy||szy<Y){
    	cout<<"No"<<endl;
    	return 0;
    }

    ll xn = xyl[0].size(), yn = xyl[1].size();
    vvc<ll> dpx(xn+1, vl(2*szx+1,false)),dpy(yn+1, vl(2*szy+1,false));
    dpx[0][szx]=dpy[0][szy]=true;
    
    ll dpsz=szx*2+1;
    rep(i,xn){
    	rep(j,dpsz){
            if (j + xyl[0][i] < dpsz) dpx[i + 1][j] |= dpx[i][j + xyl[0][i]];
            if (j - xyl[0][i] > 0) dpx[i + 1][j] |= dpx[i][j - xyl[0][i]];
        }
    }

    dpsz=szy*2+1;
    rep(i,yn){
        rep(j,dpsz){
            if (j + xyl[1][i] < dpsz) dpy[i + 1][j] |= dpy[i][j + xyl[1][i]];
            if (j - xyl[1][i] > 0) dpy[i + 1][j] |= dpy[i][j - xyl[1][i]];
        }
    }

    if (dpx[xn][X + szx] && dpy[yn][Y + szy])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

int a[100010];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int ai;
    cin >> ai;
    a[ai]++;
  }
  int ans = 0;
  for (int i = 1; i <= 100000; ++i) {
    if (a[i] > 0) {
      ++ans;
    }
  }
  if (ans % 2 == 0) {
    --ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.text.DecimalFormat;

public class Main{

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        DecimalFormat df = new DecimalFormat("0.######");
        Double r = Double.parseDouble(br.readLine());
        double area = (Math.PI * r) * r;
        double circumference = 2 * Math.PI * r;
        bw.append(df.format(area) + " " + df.format(circumference) + "\n");
        bw.flush();
    }
}


Measured memory_bytes: 26120
s = input()
n = len(s)
ans = [0]*(n+1)
for i in range(n):
	if s[i] == "<":
		ans[i+1] = max(ans[i+1], ans[i]+1)
	#print(ans)

for i in reversed(range(n)):
	if s[i] == ">":
		ans[i] = max(ans[i+1]+1, ans[i])
	#print(ans)
print(sum(ans))

Measured memory_bytes: 23336
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define All(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, a, b);

  if (a <= 0 && 0 <= b) {
    puts("Zero");
    return;
  }

  if (a > 0) {
    puts("Positive");
    return;
  }

  int n = b - a + 1;
  if (n % 2 == 0) {
    puts("Positive");
    return;
  } else {
    puts("Negative");
    return;
  }
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] height = new int[N+1];
		int[] dp = new int[N+1];
		for(int i = 1; i <= N; i++) {
			height[i] = sc.nextInt();
		}
		dp[1] = 0;
		dp[2] = Math.abs(height[2]-height[1]);
		for(int i = 3; i <= N; i++) {
			int min = Integer.MAX_VALUE;
			for(int j = 1; j <= K && i - j >= 1; j++) {
				int cost = Math.abs(height[i]-height[i-j]);
				min = Math.min(min,cost+dp[i-j]);

			}
			dp[i] = min;
		}
		System.out.println(dp[N]);
	}
}

Measured memory_bytes: 59832
n = int(input())
a = [0] + list(map(int,input().split()))
b = [0]*(n+1)
ans = 1
for i in range(1,n+1):
    b[-i] = sum(a[::n+1-i])
    if b[-i]%2 != a[-i]:
        if a[-i] == 0:
            a[-i] = 1
        else:
            a[-i] = 0
if ans == -1:
    print(-1)
else:
    lis = []
    for i in range(1,n+1):
        if a[i] == 1:
            lis.append(str(i))
    print(len(lis))
    print(" ".join(lis))

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

int main()
{
  std::string s, t;
  std::cin >> s >> t;
  std::sort(s.begin(), s.end());
  std::sort(t.begin(), t.end(), std::greater<char>());

  if ( t > s ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	if(n%2==1)
	{
		cout << "No" << endl;
	}
	else
	{
		bool flag=true;
		for(int i=0;i<n/2;i++)
			if(s[i]!=s[i+n/2])
				flag=false;
		cout << (flag ? "Yes":"No") << endl;
	}




}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
#include<atcoder/dsu>
#include<atcoder/fenwicktree>
#include<atcoder/math>

using namespace std;
using namespace atcoder;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	if (x >= m)x %= m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 19;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	while (b) {
		int r = a % b; a = b; b = r;
	}
	return a;
}

void solve() {
	int n, m, a, b; cin >> n >> m >> a >> b;
	ll ans = floor_sum(n, m, a, b);
	cout << ans << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(15);
	//init_f();
	//init();
	//expr();
	int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


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

int main () {
  int N;
  string S;
  cin >> N >> S;
  int x = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'I') {
      x++;
      if (x > ans) {
        ans = x;
      }
    }
    else x--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	boolean J = true;
	  	int i,j;
	  	
	  	while(J) {
	  		
		  	int  h = scanner.nextInt();			//入力
		  	int  w = scanner.nextInt();
		  	
		  	if( h == 0 && w == 0 )
		  		break;
	  		
		  	for(i = 1; i <= h ; i ++){
		  		for(j = 1; j <= w ; j++){
		  			if(j == w) 
		  				System.out.println("#");
		  			else{
		  				if(i == 1 || j == 1 || i == h)
		  					System.out.print("#");
		  				else
		  					System.out.print(".");
		  					
		  			}
		  		}
		  	}
		  	System.out.print("\n");
		  	
  		}
        scanner.close();
  }
}


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


int main(){
	int X, Y, Z;
	cin >> X >> Y >> Z;
	int ans = (X-Z)/(Y+Z);
	cout << ans << endl;
}
			

		












Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int s,w;
    cin >> s >> w;
    if(w>=s) cout << "unsafe"<<endl;
    else cout << "safe" << endl;
    
    
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

int main()
{
  int N,K,Q=0;
  std::cin>>N>>K>>Q;
  
  int A[N];
  for(int i=0;i<N;++i)
  {
    A[i]=0;
  }
  
  for(int i=0;i<Q;++i)
  {
    int temp=0;
    std::cin>>temp;
    
    A[temp-1]++;
  }
  
  for(int i=0;i<N;++i)
  {    
    if(A[i]>Q-K)
    {
      std::cout<<"Yes"<<std::endl;
    }
    else
    {
      std::cout<<"No"<<std::endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define pq priority_queue
#define st first
#define nd second

using namespace std;
typedef long long ll;
ll const inf = 1e9;
ll const mod = 998244353;

int main()
{
    string s;
    cin >> s;
    ll a = 0, b = 0;
    ll black = 0, white = 0;
    fr(i, 0, s.size()){
        if(s[i] == 'B'){
            black ++;
        }
        else{
            b += black;
        }
    }
    cout << b << endl;
    return 0;

}


Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        long A = reader.nextLong();
        long B = reader.nextLong();
        long GCD = 0;
        long a = A;
        long b = B;
        while (true) {
            long c = a % b;
            if (c == 0) {
                GCD = b;
                break;
            }
            a = b;
            b = c;
        }
        long ans = A * B / GCD;
        System.out.println(ans);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 21332
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int s = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		
		// 計算
		long result = 0;
		long[][] dp = new long[3001][3001];
		int MOD = 998244353;
		dp[0][0] = 1;
		for(int i = 0; i < n; i++){
		    for(int j = 0; j < dp[0].length; j++){
		        if(j-a[i] >= 0) dp[i+1][j] = dp[i][j-a[i]];
		        dp[i+1][j] += dp[i][j]*2%MOD;
		        dp[i+1][j] %= MOD;
		    }
		}
		result = dp[n][s];
		
		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 96792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B;
    cin >>A>>B;
    
    cout << A*B << endl;


    return 0;
    

}

Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BResale {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int v[] = new int[n];
            int c[] = new int[n];
            long ans = 0;
            for (int i = 0; i < n; i++) v[i] = in.nextInt();
            for (int i = 0; i < n; i++) c[i] = in.nextInt();
            for (int i = 0; i < n; i++) {
                if (v[i] > c[i]) ans += v[i] - c[i];
            }
            out.println(ans);

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
count=0
for i in range(n):
    a=list(map(int,input().split()))
    ans=0
    for j in range(m):
        ans+=a[j]*b[j]
    if ans+c>0:
        count+=1
            
print(count)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static double solve[][] = new double[3001][3001];
    public static double probabilities[] = new double[3000];
    public static void main(String args[])throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n=Long.parseLong(br.readLine());
        String S[]=br.readLine().split(" ");
        for(int i=0;i<n;i++)
            probabilities[i]=Double.parseDouble(S[i]);
        for(int i=0;i<=n;i++)
        {
            for(int j=i;j<=n;j++)
                solve[i][j]=0;
        }
        solve[0][0]=1;
        for(int i=0;i<=n;i++)
        {
            for(int j=i;j<=n;j++)
            {
                solve[i][j+1]+=solve[i][j]*(1-probabilities[j]);
                solve[i+1][j+1]=solve[i][j]*(probabilities[j]);
            }
        }
        double totalProbability=0.0d;
        for(int i=0;i<(n+1)/2;i++)
            totalProbability+=solve[i][(int)n];
        System.out.println(1-totalProbability);
    }
}

Measured memory_bytes: 129024
package main

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

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

	roads := newUnionFind(n)
	for i := 0; i < k; i++ {
		p := readInt()
		q := readInt()
		roads.unite(p-1, q-1)
	}
	rails := newUnionFind(n)
	for i := 0; i < l; i++ {
		r := readInt()
		s := readInt()
		rails.unite(r-1, s-1)
	}

	m := make(map[[2]int]int)
	for i := 0; i < n; i++ {
		roads.par[i] = roads.root(i)
		rails.par[i] = rails.root(i)
		key := [2]int{roads.par[i], rails.par[i]}
		m[key]++
	}

	results := make([]string, n)
	for i := 0; i < n; i++ {
		key := [2]int{roads.par[i], rails.par[i]}
		results[i] = strconv.Itoa(m[key])
	}
	fmt.Println(strings.Join(results, " "))
}

// UnionFind .
type UnionFind struct {
	par  []int
	rank []int
}

func newUnionFind(n int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, n)
	u.rank = make([]int, n)
	for i := range u.par {
		u.par[i] = i
		u.rank[i] = 0
	}
	return u
}

func (u UnionFind) root(x int) int {
	if u.par[x] == x {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}

func (u UnionFind) same(x, y int) bool {
	return u.root(x) == u.root(y)
}

func (u UnionFind) unite(x, y int) {
	x = u.root(x)
	y = u.root(y)
	if x == y {
		return
	}
	if u.rank[x] < u.rank[y] {
		u.par[x] = y
	} else {
		u.par[y] = x
		if u.rank[x] == u.rank[y] {
			u.rank[x]++
		}
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 28928
W, H, N = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(N)]
xmax = 0 # a=1
xmin = W # a=2
ymax = 0 # a=3
ymin = H # a=4

for x,y,a in data:
    if a == 1: # x以下
        xmax = max(x, xmax)
    elif a == 2: # x以上
        xmin = min(x, xmin)
    elif a == 3: # y以下
        ymax = max(y, ymax)
    else: # y以上
        ymin = min(y, ymin)
S = max(0,(xmin - xmax)) * max(0,(ymin - ymax))
print(S if S>=0 else 0)

Measured memory_bytes: 3064
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		char[] cs = sc.next().toCharArray();
		int[] r = new int[cs.length];
		int[] l = new int[cs.length];
		for (int i = 0; i < cs.length; ++i) {
			if (cs[i] == 'L') {
				l[i] = l[i - 1] + 1;
			}
		}
		for (int i = cs.length - 1; i >= 0; --i) {
			if (cs[i] == 'R') {
				r[i] = r[i + 1] + 1;
			}
		}
		PrintWriter pw = new PrintWriter(System.out);
		int[] cnt = new int[cs.length];
		for (int i = 0; i < cs.length; ++i) {
			if (cs[i] == 'R') {
				++cnt[i + r[i] - r[i] % 2];
			} else {
				++cnt[i - l[i] + l[i] % 2];
			}
		}
		for (int i = 0; i < cs.length; ++i) {
			pw.print(cnt[i] + (i == cs.length - 1 ? "\n" : " "));
		}
		pw.close();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 39432
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <numeric>

#define rep(i, n) for(int i = 0;i < (int)(n); i++)
#define pb push_back
typedef long long ll;

using namespace std;

int gcd(int x, int y)
{
    int r;

    if(x == 0 || y == 0)  // 引数チェック
    {
        fprintf(stderr, "引数エラーです。\n");
        return 0;
    }

    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

int main() {
    int n, x;
    cin >> n >> x;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    rep(i, n){
        v[i] -= x;
    }
    ll ans = v[0];
    rep(i, n){
        ans = gcd(ans,v[i]);
    }
    cout << abs(ans) << endl;
}


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

class Cube{
public:
 int f[6];
 Cube(){}
 void roll_z(){ roll(1,2,4,3);} //
 void roll_y(){ roll(0,2,5,3);} // to W
 void roll_x(){ roll(0,1,5,4);} // to N
 void roll(int i, int j, int k, int l){
  int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
 }
 void move(char ch){
  if(ch=='E') for(int i=0;i<3;i++) roll_y();
  if(ch=='W') roll_y();
  if(ch=='N') roll_x();
  if(ch=='S') for(int i=0;i<3;i++) roll_x();
 }
};

int main(){
  Cube c;
  string com;

  for(int i=0;i<6;i++) cin >> c.f[i];
  cin >> com;

  for(int i=0;i<com.size();i++) c.move(com[i]);

  cout <<c.f[0]<<endl;

  return 0;
}

Measured memory_bytes: 1204
N = int(input())
INPUT = input()
X_list = list(map(int, INPUT.split()))
X_sorted = sorted(X_list)
criterion = X_sorted[int(N / 2 - 1)]

for i in range(N):
    if X_list[i] > criterion:
        print(criterion)
    else:
        print(X_sorted[int(N / 2)])

Measured memory_bytes: 27528
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int h,w,n;
    cin >> h >> w >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    vector<vector<int>> s(h,vector<int> (w,0));
    //rep(i,h) s[i].resize(w);
    int x = 0, y = 0;
    rep(i,n){
        rep(j,v[i]){
            s[x][y] = (i+1) ;
            //cout<<x<<" "<<y<<" "<< (i+1) << endl;
            y++;
            if(y==w){
                x++;
                y = 0;
            } 
        }
    }
    
    rep(i,h){
        if((i+1)%2==0) reverse(s[i].begin(),s[i].end());
    }
    //cout<<h<<" "<<w<<endl;
    rep(i,h){
        rep(k,w){
            if(k!=w-1)cout<<s[i][k]<<" ";
            else cout<<s[i][k];
        }
        //cout<<i<<endl;
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
N,T = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(N)]

dp1 = [[0]*T for _ in range(N+1)]
dp2 = [[0]*T for _ in range(N+1)]

for i in range(N):
    for j in range(T):
        if j < L[i][0]:
            dp1[i+1][j] = dp1[i][j]
        else:
            dp1[i+1][j] = max(dp1[i][j], dp1[i][j-L[i][0]]+L[i][1])
        k = N-i
        if j < L[k-1][0]:
            dp2[k-1][j] = dp2[k][j]
        else:
            dp2[k-1][j] = max(dp2[k][j], dp2[k][j-L[k-1][0]]+L[k-1][1])
            
ans = 0
for i in range(N):
    for j in range(T):
        ans = max(ans, dp1[i][j]+dp2[i+1][T-j-1]+L[i][1])
        
print(ans)

Measured memory_bytes: 179588
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define ll long long
int n;
ll a[111111];
int c1,c2;
int main(){
	cin>>n;
	rep(i,n)cin>>a[i];

	rep(i,n){
		if(a[i]%4==0)c1++;
		if(a[i]%4>0&&a[i]%2==0)c2++;
	}
	int t=n-1;
	if(c1>=1){
		t-=c1*2;
	}
	if(c2>=2){
		c2--;
		t-=c2;
	}
	if(t<=0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


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


int main() {
	int N, max=1, countmax = 0;
	cin >> N;

	for (int i = 1; i <= N; ++i){
		int counter = 0;
		int n = i;
		while (n % 2 == 0) {
			n /= 2;
			++counter;
		}
		if (counter > countmax) {
			countmax = counter;
			max = i;
		}
	}
	cout << max << endl;

}


Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();
    if (k <= a) {
      System.out.println(k);
    } else if (a < k && k <= a+b) {
      System.out.println(a);
    } else {
      System.out.println(2*a + b - k);
    }
  }
}


Measured memory_bytes: 35580
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) std::begin(x), std::end(x)
using namespace std;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }

template <typename UnaryPredicate>
int64_t binsearch(int64_t l, int64_t r, UnaryPredicate p) {
    assert (l <= r);
    -- l;
    while (r - l > 1) {
        int64_t m = l + (r - l) / 2;
        (p(m) ? r : l) = m;
    }
    return r;
}

int64_t solve(int64_t n, int64_t m, int64_t v, int64_t p, vector<int64_t> a) {
    sort(ALL(a));
    int k = binsearch(0, n, [&](int j) {
        int64_t limit = a[j] + m;
        int64_t used = 0;
        int cnt = 0;
        REP_R (i, n) if (i != j) {
            ++ cnt;
            if (cnt <= p - 1) {
                used += m;
            } else if (limit < a[i]) {
                return false;
            } else {
                used += min(m, limit - a[i]);
            }
        }
        return m * (v - 1) <= used;
    });
    return n - k;
}

int main() {
    int64_t n, m, v, p; cin >> n >> m >> v >> p;
    vector<int64_t> a(n);
    REP (i, n) {
        cin >> a[i];
    }
    cout << solve(n, m, v, p, a) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int q,i;
	int c,a,n;
	int max=0;
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d %d %d",&c,&a,&n);
		if(c!=0){
			while(c>=1 && a>=1 && n>=1){
				max+=1;
				c=c-1;
				a=a-1;
				n=n-1;
			}
			while(c>=2 && a>=1){
				max+=1;
				c=c-2;
				a=a-1;
			}
			while(c>=3){
				max+=1;
				c=c-3;
			}
		}	
		printf("%d\n",max);
		max=0;
	}
	return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n,k;
	cin>>n>>k;
	
	int prev = 1;
	
	while(n){
		if(2*prev <= (prev+k)) prev = prev*2, n--;
		else break;
	}
	
	while(n--) prev += k;
	
	cout<<prev<<endl;	
		
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
int top, S[200];//?????¶??????top?????¨??\?????¨??°???????????´??´?????°???S
void push(int x)
{
	 top++;
	S[top] = x; //??\?????¶?????????????????°???
}
int pop()
{ 
	int x= S[top];
	top--;//????????¶??????????????°?????????????????????
	return x;
}
int main()
{
	int a, b;
	top = 0;//?????????
	int i = 0;
	char s[100];
	//cout << "---";
	while (scanf("%s",s)!=EOF)
	{

		if (s[0] == '+')
		{
			a = pop();

			b = pop();
	
			push(a + b);
		
		}
		else if (s[0] == '-')
		{
			b = pop();
		
			a = pop();
		
			push(a - b);
		
		}
		else if (s[0] == '*')
		{
			a = pop();
		
			b = pop();
		
			push(a*b);
		
		}
		else
		{
			push(atoi(s));

		}
		i++;
	}
	printf("%d\n", pop());
	return 0;

}

Measured memory_bytes: 2640
#include <algorithm>
#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()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

int main() {
    ll N;
    cin >> N;
    string s = to_string(N);
    int keta = s.size();
    int ans = 9 * (keta - 1);

    int dp[keta + 1][2][10]; // smaller
    memset(dp, -1, sizeof(dp));
    dp[0][0][0] = 1;

    for (int i = 0; i < keta + 1; i++) {
        for (int j = 0; j < 10; j++) {
            if (dp[i][1][j] != -1)
                dp[i + 1][1][9] = max(dp[i + 1][1][9], dp[i][1][j] + 9);
            if (s[i] - '0' != 0) {
                int num = s[i] - '0' - 1;
                dp[i + 1][1][num] = max(dp[i + 1][1][num], dp[i][0][j] + num);
            }
            int num = s[i] - '0';
            dp[i + 1][0][num] = max(dp[i + 1][0][num], dp[i][0][j] + num);
        }
    }

    rep(j, 10) {
        ans = max(ans, dp[keta][0][j]);
        ans = max(ans, dp[keta][1][j]);
    }

    cout << ans - 1 << endl;
}

Measured memory_bytes: 3696
# https://atcoder.jp/contests/arc101/tasks/arc101_b
"""
タグ: 中央値、二分探索、転倒数
"""
class Bit:
    def __init__(self, n):
        self.n = n
        self.tree = [0]*(n+1)
        self.el = [0]*(n+1)
        self.depth = n.bit_length() - 1

    def sum(self, i):
        """ 区間[0,i) の総和を求める """
        s = 0
        i -= 1
        while i >= 0:
            s += self.tree[i]
            i = (i & (i + 1) )- 1
        return s

    def add(self, i, x):
        self.el[i] += x
        while i < self.n:
            self.tree[i] += x
            i |= i + 1

class BitSet2:
    """ 座標圧縮が必要な場合 """
    def __init__(self, data, A=[]):
        """ BitSetに入り得る値を先読みした物を data に格納 """
        self.data = sorted(list(set(data)))
        self.n = len(self.data)
        self.p = Bit(self.n + 1)
        self.size = 0
        self.flip = 0
        self.code = {}
        self.decode = {}
        for i, b in enumerate(self.data):
            self.code[b] = i
            self.decode[i] = b
        for a in A:
            self.add(a)

    def add(self,x):
        self.p.add(self.code[x], 1)
        self.size += 1
        self.flip += self.size - self.p.sum(self.code[x]+1)

    def remove(self,x):
        self.p.add(x, -1)
        self.size -= 1

    def flip_counter(self):
        return self.flip

def binary_search_int(ok, ng, test):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if test(mid):
            ok = mid
        else:
            ng = mid
    return ok

def test(x):
    S = [0]
    for a in A:
        if a >= x:
            S.append(S[-1]+1)
        else:
            S.append(S[-1]-1)
    B = BitSet2(S,S)
    cnt = M - B.flip_counter()
    return cnt >= ceil(M/2)

import sys
from math import ceil
input = sys.stdin.readline

N = int(input())
M = N*(N+1)//2
A = list(map(int, input().split()))
AS = sorted(A)
mi, ma = AS[0], AS[-1]
print(binary_search_int(mi,ma+1,test))


Measured memory_bytes: 178200
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nm = scanner.nextLine().split(" ", 2);
        int n = Integer.parseInt(nm[0]);
        int m = Integer.parseInt(nm[1]);

        long[][] ab = new long[n][2];
        for (int i = 0; i < n; i++) {
            String[] line = scanner.nextLine().split(" ", 2);
            ab[i][0] = Long.parseLong(line[0]);
            ab[i][1] = Long.parseLong(line[1]);
        }

        long[][] cd = new long[m][2];
        for (int i = 0; i < m; i++) {
            String[] line = scanner.nextLine().split(" ", 2);
            cd[i][0] = Long.parseLong(line[0]);
            cd[i][1] = Long.parseLong(line[1]);
        }

        for (int i = 0; i < n; i++) {
            long a = ab[i][0];
            long b = ab[i][1];

            long minDist = 0;
            long minJ = 0;
            for (int j = 0; j < m; j++) {
                long c = cd[j][0];
                long d = cd[j][1];
                long dist = Math.abs(a - c) + Math.abs(b - d);

                if (j == 0 || dist < minDist) {
                    minDist = dist;
                    minJ = j;
                }
            }
            System.out.printf("%d\n", minJ + 1);
        }
    }
}


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

int n;

int main() {
    cin >> n;
    bool flag=true;
    int A[n];
    int cnt=0;
    for (int i=0;i<n;++i) cin >> A[i];
    while (true){
        for (int i=0;i<n;++i){
            if (A[i]%2==0) A[i]=A[i]/2;
            else flag=false;
        }
        if (flag==false) break;
        else ++cnt;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e3+10;
long double dp[maxn][maxn];
long double sum;
int n;
long double pd[maxn];
inline void input();
int main(){
        ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        input();
}
inline void input(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>pd[i];
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j==0){
				dp[i][j]=(long double)(dp[i-1][j]*(long double)(1-pd[i]));
			}
			else{
				dp[i][j]=(long double)(dp[i-1][j-1]*pd[i]);
				dp[i][j]+=(long double)(dp[i-1][j]*(long double)(1-pd[i]));
			}
			//cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
		}
	}
	for(int i=n/2+1;i<=n;i++){
		sum+=dp[n][i];
	}
	cout<<fixed<<setprecision(12)<<sum;
}

Measured memory_bytes: 139776
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void){
	int n, y;

	cin >> n >> y;
	y /= 1000;

	FOR(i, 0, n) {
		FOR(t, 0, n-i) {
			if (9 * i + 4 * t == -n + y) {
				cout << i << " " << t << " " << n - i - t << endl;
				goto end;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	end:
	return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define For(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define sz(x) ((int)(x).size())
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef long long ll;
typedef unsigned long long ull;

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

  ll a,b; cin>>a>>b;
  set<ll> x, y;
  for(int i=2;i*1ll*i<=a;i++) {
    if(a%i==0) {
      x.insert(i);
      while(a%i==0) a/=i;
    }
  }
  if(a>1) x.insert(a);
  for(int i=2;i*1ll*i<=b;i++) {
    if(b%i==0) {
      y.insert(i);
      while(b%i==0) b/=i;
    }
  }
  if(b>1) y.insert(b);
  vector<ll> fin;
  for(ll i: x) {
    if(y.find(i)!=y.end()) {
      fin.pb(i);
    }
  }
  int cnt = fin.size()+1;
  cout<<cnt<<endl;
}


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

int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	string s,t;
	bool ctr=1;
	
	cin>>s;
	cin>>t;
	
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
		{
			ctr=0;
			break;
		}
	}
	
	if(ctr)
		cout<<"Yes \n";
	else cout<<"No \n";
	
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int n, A[50];

int solve(int i, int m) {
	if (m == 0) return 1;
	if (i >= n) return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main() {
	int q, M, i;

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

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &M);
		if (solve(0, M)) {
			printf("yes\n");
		}
		else {
			printf("no\n");
		}
	}

	return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>

int main( void ) 
{
	int room[120]={0};
	int n;
	int b,f,r,v;
	int i;
	
	scanf( "%d", &n );
	for( i=0; i<n; i++ ) {
		scanf( "%d%d%d%d", &b, &f, &r, &v );
		switch( b ) {
			case 1:
					room[10*(f-1)+r-1]+=v;
				break;
			case 2:
					room[29+10*(f-1)+r]+=v;
				break;
			case 3:
					room[59+10*(f-1)+r]+=v;
				break;
			case 4:
					room[89+10*(f-1)+r]+=v;
				break;
			default:
					;
		}
	}

	i=0;
	while( i<120 ) {
		if( 0!=i && 0==i%30 ) {
			printf( "####################\n" );
		}	
		printf( " %d", room[i] );
		i++;
		if( 0!=i && 0==i%10 ) {
			printf( "\n" );
		}
	}
		
	return 0;
}

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

int main(){
  int N,x,y;
  cin >>N;
  
  x=(N-N%10)/10;
  y=N%1000;
  if(x%111==0 || y%111==0){
    cout << "Yes" << endl;
  }
  if(!(x%111==0 || y%111==0)){
    cout << "No" << endl;
  }}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  vector<long long int> l(n);
  vector<long long int> all;
  map<long long int,long long int> hoge;
  for(long long int i=0; i<n; i++){
    cin>>l.at(i);
    hoge[l.at(i)]++;
    if(hoge[l.at(i)]==1){
      all.push_back(l.at(i));
    }
  }
  sort(all.begin(),all.end());
  long long int ans=0;
  for(long long int i=0; i<all.size(); i++){
    for(long long int j=i+1; j<all.size(); j++){
      for(long long int k=j+1; k<all.size(); k++){
        if(all.at(i)+all.at(j)>all.at(k)){
          ans+=hoge[all.at(i)]*hoge[all.at(j)]*hoge[all.at(k)];
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
int main()
{
	std::string s;
	while (std::getline(std::cin, s)) {
		while (s.find("the") == s.npos && s.find("this") == s.npos && s.find("that") == s.npos) {
			for (size_t i = 0; i < s.size(); i ++) {
				if (s[i] >= 'a' && s[i] <= 'y')
					s[i] ++;
				else if (s[i] == 'z')
					s[i] = 'a';
			}
		}
		std::cout << s << std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int k, x;
  cin >> k >> x;
  for(int i = x - k + 1; i <= x + k - 1; i++) {
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for(auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n + 1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for(auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for(auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for(auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int>> name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num)) + 1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)                                                                                                          \
  cerr << "[";                                                                                                         \
  REPI(itr, v) { cerr << *itr << (itr != --v.end() ? ", " : ""); }                                                     \
  cerr << "]" << endl;
#define dpa(v)                                                                                                         \
  cerr << "[ " << endl;                                                                                                \
  REPI(itr, v) {                                                                                                       \
    cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl;            \
  }                                                                                                                    \
  cerr << "]" << endl;

void solve(long long N, std::vector<long long> A) {

  REP(x, N) {
    if(A.at(x) == 0) {
      cout << "0" << endl;
      return;
    }
  }

  int num = 1;
  REP(x, N) {
    if(num > 1000000000000000000 / A.at(x)) {
      cout << "-1" << endl;
      return;
    } else {
      num *= A.at(x);
    }
  }

  cout << num << endl;
}

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


Measured memory_bytes: 4084
import sys

N, T = map(int, input().split())
S = sys.stdin.readlines()
A = []
B = []
for s in S:
    a, b = map(int, s.split())
    A.append(a)
    B.append(b)

dp1 = [[0] * T for _ in range(N + 1)]
for i in range(N):
    for j in range(T):
        here = dp1[i][j]
        if j < A[i]:
            dp1[i + 1][j] = here
        else:
            dp1[i + 1][j] = max(here, dp1[i][j - A[i]] + B[i])

dp2 = [[0] * T for _ in range(N + 2)]
for i in range(N, 0, -1):
    for j in range(T):
        here = dp2[i + 1][j]
        if j < A[i - 1]:
            dp2[i][j] = here
        else:
            dp2[i][j] = max(here, dp2[i + 1][j - A[i - 1]] + B[i - 1])

ans = 0
for i in range(1, N + 1):
    t = 0
    for j in range(T):
        t2 = dp1[i - 1][j] + dp2[i + 1][T - 1 - j]
        t = max(t, t2)
    ans = max(ans, t + B[i - 1])

print(ans)


Measured memory_bytes: 177160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            int cnt = 0;

            for(int i = 0;i < 3; i++)
            {
                if(s[i] == t[i])
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);

        }
    }
}


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

int main(){
    int n;
    int S[4][3][10] = {};
    int b, f, r, v;

    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> b >> f >> r >> v;
        S[b-1][f-1][r-1] += v;
    }
    
    for(int b = 0; b < 4; b++){
        for(int f = 0 ; f < 3; f++){
            for(int r = 0 ; r < 10; r++){
                cout << " " << S[b][f][r];
            }
            cout << endl;
        }
        if(b < 3){cout << "####################" << endl;}
    }    
}



Measured memory_bytes: 3100
fun main(args: Array<String>) {
    val s = readLine() ?: return
    val t = readLine() ?: return

    val ss = s.groupBy { it }.values.map {
        it.size
    }.sorted()
    val tt = t.groupBy { it }.values.map {
        it.size
    }.sorted()

    if (ss == tt) {
        println("Yes")
    } else {
        println("No")
    }
}


Measured memory_bytes: 51120
L,R=map(int,input().split())
M=[]
for i in range(L,R+1):
    for j in range(L,R+1):
        if j<=i:
            continue
        else:
            m = (i*j)%2019
            if m==0:
                print(0)
                exit()
            M.append(m)
print(min(M))

Measured memory_bytes: 6788