akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int H,W;
        String tmpStr;        
        
        while(true){
            H = scan.nextInt();
            W = scan.nextInt();
            if(H==0 && W==0){
                return;
            }
            
            for(int i=0; i<H; i++){
                tmpStr = "";
                for(int j=0; j<W; j++){
                    tmpStr += (i%2+j)%2==0 ? "#" : ".";
                }
                System.out.println(tmpStr);
            }
        System.out.println();
        }
    }
}


Measured memory_bytes: 55064
A,B,K = map(int,input().split())

X = A-K
if(X >= 0):
  A=X
  print(A,B)
  
elif(X < 0 ):
  A=0
  if(B+X>=0):
    B=B+X
    print(A,B)
  elif(B+X<0):
    print(0,0)
  



Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}
/*

 */
int n, k;
string s;

int main()
{
  cin >> n>>k;
  cin >> s;

  vector<int> a,b;
  a.push_back(0);
  b.push_back(0);
  int cnt = 0;
  for (int i = 0; i < n; i++)
  {
    if(s[i]=='1'){
      if(cnt==0){
        a.push_back(i);
      }
      cnt++;
    } else {
      if(cnt>0){
        b.push_back(i);
        cnt = 0;
      }
    }
  }
  a.push_back(n);
  b.push_back(n);

  int m = min(a.size(), b.size());

/*   for (size_t i = 0; i < m; i++)
  {
    cerr << "a[i] = "<< a[i] << ", b[i] = "<< b[i] << endl;
  } */

  int ans = 0;
  for (int i = 0; i < m-k; i++)
  {
    ans = max(ans, b[i + k] - a[i]);
  }

  if(m<=k){
    ans = n;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1020
n = int(input())
ns = list(map(int, input().split()))
d = [0] * 60
ans = 0
mod = 10 ** 9 + 7
for i in range(60):
    for num in ns:
        d[i] += (num >> i) & 1
    ans = (ans + d[i] * (n-d[i]) * 2 ** i) % mod
print(ans)

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> b, f, r, v;  // b棟f階のr番目の部屋にv人
    for (int i = 0; i < n; i++) {
        int tmpB, tmpF, tmpR, tmpV;
        cin >> tmpB >> tmpF >> tmpR >> tmpV;
        b.push_back(tmpB - 1);
        f.push_back(tmpF - 1);
        r.push_back(tmpR - 1);
        v.push_back(tmpV);
    }

    // 0で初期化する
    vector<vector<vector<int>>> buildings(4, vector<vector<int>>(3, vector<int>(10, 0)));

    // 格納する
    for (int i = 0; i < n; i++) {
        buildings.at(b.at(i)).at(f.at(i)).at(r.at(i)) += v.at(i);
    }

    // 出力する
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << buildings.at(i).at(j).at(k);
            }
            cout << endl;
        }
        if (i != 3) cout << "####################" << endl;
    }

    return 0;
}


Measured memory_bytes: 3148
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(k: usize, s: String) -> String {
    use std::collections::HashSet;

    let mut hs: HashSet<String> = HashSet::new();

    let mut cs: Vec<char> = s.clone().chars().collect();
    cs.sort();

//    println!("{:?}", cs);

    for c in cs {
        for (i, tc) in s.clone().chars().enumerate() {
            if tc == c {
                for n in 1..k+1 {
                    hs.insert(s.chars().skip(i).take(n).collect());
                }
            }
        }

        if hs.len() >= k as usize {
            break
        }
    }

    let mut v = hs.into_iter().collect::<Vec<String>>();
    v.sort();

//    println!("{:?}", v);

    v[k-1].clone()
}


fn main() {
    let s = read_line!();

    let k = parse_line!(usize);

    println!("{}", solve(k, s));
}

#[test]
fn solve_test() {
    assert_eq!(solve(4, "aba".to_string()), "b");
    assert_eq!(solve(5, "atcoderandatcodeer".to_string()), "andat");
    assert_eq!(solve(1, "z".to_string()), "z");
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <string.h>
#include <vector>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("file.1", "r", stdin);

  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a <= k)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll inf = 12345678999999;
const ll wall = -12345678;
bool even(string s)
{
	string l,r;
	l = s.substr(0,s.size()/2);
	r = s.substr(s.size()/2);
	if(l == r)return true;
	return false;
}
int main()
{
	string k;
	cin>>k;
	ll ma = wall;
	for(int d = k.size()-1;d>0;d--)
	{
		string s = k.substr(0,d);
		if(even(s))
		{
			ll sz = s.size();
			ma = max(ma,sz);
		}
	 } 
	cout<<ma<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

    long int A,B,tmp;
    long int x,r,ans;

    scanf("%ld %ld",&A,&B);

    x = A*B;

    if(A < B){
        tmp = A;
        A = B;
        B = tmp;
    }

    r = A % B;
    while(r != 0){
        A = B;
        B = r;
        r = A % B;
    }

    ans = x/B;

    printf("%ld\n",ans);
    return 0;
}


Measured memory_bytes: 128
N = int(input())
S =input()
a = 'Yes'
if N%2==0:
  for i in range(int(N/2)):
    if S[i] !=S[int(N/2)+i]:
      a = 'No'
      break
    else:
      continue
else:
  a = 'No'
print(a)

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

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

  ll result = 0;

  for (int bit = 0; bit < pow(2, s.size()-1); bit++) {
    string ts = s;
    int tbit = bit;

    int count = 0;
    ll tmp = 0;
    while (!ts.empty()) {
      tmp += (ts[ts.size()-1] - '0') * pow(10, count);
      if (tbit & 1) {
        result += tmp;
        tmp = 0;
        count = 0;
      } else {
        count++;
      }
      ts.erase(ts.size()-1, 1); // 文字目を削除
      tbit >>= 1;
    }
    if (tmp > 0) result += tmp;
  }

  cout << result << endl;
}




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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

ll Euclid(ll A, ll B){
    if(A<B) swap(A, B);
    ull C = B;
    while(C != 0){
        C = A%B;
        A = B;
        B = C;
    }
    return A;
}

int main(){
    ll N, K;
    cin >> N >> K;
    ll A[N];
    REP(i, N) cin >> A[i];
    sort(A, A+N);
    ll gcd = A[0];
    REP(i, N) gcd = Euclid(gcd, A[i]);
    if(K%gcd==0 && K<=A[N-1]){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

const int N = 3e5 + 5000;
int n, m, T;
int a[] = { 0, 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 };

int main()
{
#ifdef ONLINE_JUDGE
#else
   // freopen("r.txt", "r", stdin);
    // freopen("w.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);

    cin >> n;
    cout << a[n];
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean[] isPrime=new boolean[100001];
		int[] c=new int[100001];
		for(int i=2;i<=100000;i++) {
			isPrime[i]=true;
		}
		for(int i=2;i<=100000;i++) {
			c[i]=c[i-1];
			if(isPrime[i]) {
				for(int j=2*i;j<=100000;j+=i) {
					isPrime[j]=false;
				}
				if(isPrime[(i+1)/2])c[i]++;
			}
		}
//		for(int i=2;i<=10;i++) {
//		System.out.println(c[i]);
//		}
		int Q = sc.nextInt();
		for(int q=1;q<=Q;q++) {
			int l=sc.nextInt();
			int r=sc.nextInt();
			System.out.println(c[r]-c[l-1]);
		}
	}

	private static boolean isPrime(int i) {
		// TODO 自動生成されたメソッド・スタブ
		double rooti=Math.pow(i, 0.5);
		for(int j=3;j<=rooti;j+=2) {
			if(i%j==0) {
				return false;
			}
		}
		return true;
	}
}
//3 5 13 37 61 73


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

typedef long long int ll;
typedef unsigned long long int ull;

int main() {
  int x, n;

  cin >> x >> n;
  int p[n];
  if (n == 0) {
    cout << x << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p, p + n);
  int a = 100;
  int ans = -1;
  for (int i = -1; i < p[n - 1] + 2; i++) {
    if (find(p, p + n, i) == p + n && ((abs(x - i) < a) || (abs(i - x) < a))) {
      ans = i;
      if (abs(x - i) < abs(i - x)) {
        a = abs(x - i);
      } else {
        a = abs(i - x);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <climits>  // INT_MIN
#include <cmath>
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
const ll INF = 1LL<<60; 

int main() {
    // input
    ll A, B, Q, q;
    cin >> A >> B >> Q;
    vector<ll> Jin(A), Tera(B);
    REP(i, A) cin >> Jin[i];
    REP(i, B) cin >> Tera[i];
    Jin.push_back(INF); Jin.push_back(-INF);
    Tera.push_back(INF); Tera.push_back(-INF);
    sort(Jin.begin(), Jin.end());
    sort(Tera.begin(), Tera.end());
    
    // calculation
    REP(i, Q) {
        cin >> q;
        auto s = lower_bound(Jin.begin(), Jin.end(), q);
        auto t = lower_bound(Tera.begin(), Tera.end(), q);
        
        // 距離の最小値を求める
        vector<ll> ss = {*s, *prev(s)};
        vector<ll> tt = {*t, *prev(t)};
        ll res = INF;
        REP(j, 2) {
            REP(k, 2) {
                if (q < ss[j] && q < tt[k]) {
                    res = min(res, max(ss[j], tt[k]) - q);
                } else if (ss[j] < q && tt[k] < q) {
                    res = min(res, q - min(ss[j], tt[k]));
                } else {
                    // q が間にある
                    res = min(res, abs(tt[k]-ss[j]) + min(abs(tt[k]-q), abs(ss[j]-q)));
                }
            }
        }
        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 2912
#include<bits/stdc++.h>
using namespace std;
int c[5][5];
int main(){
    for(int i=1;i<=3;i++)
        for(int j=1;j<=3;j++)
            cin>>c[i][j];
    for(int a1=0;a1<=100;a1++)
        for(int a2=0;a2<=100;a2++){
            if(c[1][1]-a1!=c[2][1]-a2 || c[1][2]-a1!=c[2][2]-a2 || c[1][3]-a1!=c[2][3]-a2) continue;   
            for(int a3=0;a3<=100;a3++)
                if(c[1][1]-a1==c[3][1]-a3 && c[1][2]-a1==c[3][2]-a3 && c[1][3]-a1==c[3][3]-a3)
                    return cout<<"Yes"<<endl,0;
        }
    cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

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

#define all(x) x.begin(),x.end()

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

int n;
map<Ps,int> dp;

bool func(string s){
	for(int i = 0; i < s.size(); i++){
		string t = s;
		if(i>0){
			char tmp = t[i];
			t[i] = t[i-1];
			t[i-1] = tmp;
		}

		if(t.find("AGC",0)!=string::npos){
			return false;
		}
	}

	return true;
}

int dfs(int i, string s){
	if(dp.count(Ps(i,s))>0){
		return dp[Ps(i,s)];
	}
	if(i == n){
		return 1;
	}

	int res = 0;
	string t = "ACGT";
	for(int j = 0; j < t.size(); j++){
		string x = s + t[j];
		if(func(x)){
			string y = s.substr(1,2) + t[j];
			res = res + (dfs(i+1,y) % mod);
			res %= mod;
		}
	}
	dp[Ps(i,s)] = res;
	// cout << res << endl;
	return res;
}

int main()
{
	cin>>n;
	cout << dfs(0,"TTT") << endl;

	return 0;
}

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

int main(int argc, char *argv[])
{
    int H, W;
    std::cin >> H >> W;
    std::vector<std::string> vec(H); 

    for (int i = 0; i < H; i++) {
        std::cin >> vec[i];
    }

    std::vector<bool> row(H, false);
    std::vector<bool> col(W, false);

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (vec[i][j] == '#') {
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for (int i = 0; i < H; i++) {
        if (row[i]) {
            for (int j = 0; j < W; j++) {
                if (col[j]) {
                    std::cout << vec[i][j];
                }
            }
            std::cout << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
l = [list(map(int,input().split())) for _ in range(q)]
sum = [0]*(n+1)
for i in range(len(s)-1):
    if s[i:i+2]=='AC':
        sum[i+2] = sum[i+1]+1
    else:
        sum[i+2] = sum[i+1]
for l_ in l:
    print(sum[l_[1]]-sum[l_[0]])

Measured memory_bytes: 30640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1ll<<40;

struct Rmin {
private:
	int N;
	vector<ll> node;

public:
	Rmin(vector<ll> v) {
		int size = v.size();
		N = 1;
		while (N < size) N *= 2;
		node.resize(2*N-1, INF);

		for (int i=0; i < size; i++) node[i+N-1] = v[i];
		for (int i=N-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
	}

	Rmin(int size) {
		N = 1;
		while (N < size) N *= 2;
		node.resize(2*N-1, INF);		
	}

	ll Access(int x) {
		return node[x+N-1];
	}

	void Update(int x, ll val) {
		x += N-1;
		node[x] = val;
		while (x > 0) {
			x = (x-1)/2;
			node[x] = min(node[2*x+1], node[2*x+2]);
		}
		return;
	}

	//[a, b)
	ll GetValue(int a, int b, int k=0, int l=0, int r=-1) {
		if (r < 0) r = N;
		if (a >= r || b <= l) return INF;
		if (a <= l && r <= b) return node[k];
		ll vl = GetValue(a, b, k*2+1, l, (l+r)/2);
		ll vr = GetValue(a, b, k*2+2, (l+r)/2, r);
		return min(vl, vr);
	}
};

int main() {
	int n, q, a, b; cin >> n >> q >> a >> b;
	vector<int> qs(q+1);
	qs[0] = a;
	for (int i = 0; i < q; i++) cin >> qs[i+1];
	Rmin dp_l(n+1), dp_r(n+1);
	dp_l.Update(b, -b);
	dp_r.Update(b, b);

	ll total_diff = 0;
	for (int i = 0; i < q; i++) {
		int x = qs[i]; int y = qs[i+1];
		ll diff = abs(y-x);
		ll res = min(dp_l.GetValue(1, y) + y, dp_r.GetValue(y, n+1) - y);
		dp_l.Update(x, res - diff - x);
		dp_r.Update(x, res - diff + x);
		total_diff += diff;
	}

	ll ans_l = INF; ll ans_r = INF;
	for (int i = 1; i < n+1; i++)
	{
		ans_l = min(ans_l, dp_l.Access(i) + i);
		ans_r = min(ans_r, dp_r.Access(i) - i);
	}
	cout << ans_l + total_diff << endl;
}


Measured memory_bytes: 9216
#include <iostream>
#include <stdlib.h>
#include <string>

using namespace std;

int main(void){
    string S;
    int ans[26];
    int ind;

    cin >> S;

    for(int i=0;i<26;i++){
        ans[i] = 0;
    }
    for(int i=0;i<S.length();i++){
        ind = S[i] - 'a';
        if(ans[ind] == 1){
            cout << "no" << endl;
            return 0;
        }
        ans[ind] = 1;
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import math
def lcm(a,b):
  return a*b//math.gcd(a,b)

n=int(input())
a=list(map(int,input().split()))
ans=lcm(a[0],a[1])
for i in range(1,n):
  ans=lcm(ans,a[i])
m=0
for i in a:
  m+=(ans-1)%i
print(m)

Measured memory_bytes: 9208
N,M,C=[int(i) for i in input().split(" ")]
B=[int(i) for i in input().split(" ")]
A=[[int(i) for i in input().split(" ")]for k in range(N)]

print(
    len(
        [
            i
            for i in range(N)
            if sum([A[i][k]*B[k] for k in range(M)]+[C])>0
        ]
    )
)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int main() {
	double N;
	cin >> N;
	int a = (N + 1) / 2;
	cout << (double)a / N << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100100;
int n;
ll m, v, p;
ll a[N];
ll pref[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%lld%lld%lld", &n, &m, &v, &p);
	int ans = 0;
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	sort(a, a + n);
	reverse(a, a + n);
	for (int i = 0; i < n; i++)
		pref[i + 1] = pref[i] + a[i];
	ans = p;
	for (int i = p; i < n; i++) {
		if (a[i] + m < a[p - 1]) break;
		ll cur = v - (n - (i - p + 1));
		if (cur <= 0) {
			ans++;
			continue;
		}
		if (cur * m <= (i - p + 1) * (a[i] + m) - (pref[i] - pref[p - 1]))
			ans++;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		String s=" "+nextLine();
		int n=s.length()-1;
		int k=nextInt();
		ArrayList<String> list=new ArrayList<>();
		for(int i=1;i<=n;i++)
			for(int j=1;j<=5 && i+j-1<=n;j++)
				list.add(s.substring(i,i+j));
		Collections.sort(list);
		String prev="#";
		for(String i:list)
		{
			if(i.equals(prev))
				continue;
			else
			{
				k--;
				prev=i;
				if(k==0)
				{
					out.println(i);
					return;
				}
			}
		}
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 23828
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N, M, C;
	cin >> N >> M >> C;
	int B[20];
	for (int i = 0; i < M; i++) cin >> B[i];
	int A[20];
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) cin >> A[j];
		int tmp = C;
		for (int j = 0; j < M; j++) tmp += A[j] * B[j];
		if (tmp > 0) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int v[300010], w[300010];
int dp[130][100010];
inline void upd(int &v, int x) {
	if (v < x) v = x;
}
int go(int x, int l) {
	if (x <= 128) {
		return dp[x][l];
	}
	int res = go(x / 2, l);
	if (w[x] <= l) upd(res, go(x / 2, l - w[x]) + v[x]);
	return res;
}
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &v[i], &w[i]);
	}
	for (int i = 1; i <= 128; i++) {
		for (int j = 0; j <= 100000; j++) {
			dp[i][j] = dp[i/2][j];
		}
		for (int j = w[i]; j <= 100000; j++) {
			upd(dp[i][j], dp[i/2][j-w[i]] + v[i]);
		}
		for (int j = 1; j <= 100000; j++) {
			upd(dp[i][j], dp[i][j-1]);
		}
	}
	int q;
	scanf("%d", &q);
	while (q--) {
		int x, l;
		scanf("%d%d", &x, &l);
		printf("%d\n", go(x, l));
	}
	return 0;
}


Measured memory_bytes: 53796
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int n, k;
int l[300005];
int r[300005];
int main() {
	string s;
	cin >> n >>s;
	int ans = 0;
	reps(i, n) {
		if (s[i - 1]=='W') {
			l[i] = l[i - 1] + 1;
		}
		else {
			l[i] = l[i - 1];
		}
	}
	for (int i = n - 2; i >= 0; i--) {
		if (s[i + 1]== 'E') {
			r[i] = r[i + 1] + 1;
		}
		else {
			r[i] = r[i + 1];
		}

	}
	int mn = 300005;
	rep(i, n) {
		mn = min(mn,l[i] + r[i]);
	}
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 3076
<?php
while (fscanf(STDIN, "%d", $n) && $n) {
  $cnt = 0;
  for ($i = 1; $i < $n; $i++) {
    $sum = $i;
    for ($j = $i + 1; $j <= $n; $j++) {
      $sum += $j;
      if ($sum == $n) {
        $cnt++;
      }
    }
  }
  print $cnt . "\n";
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=1;i<n;++i)

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

// myampasu~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

struct myamfunc{int val,left,right;};

int N,M;
int x[100];
myamfunc my[10];
int memo[100][100][10];

bool solve(int left,int right,int funcnum){
  if(memo[left][right][funcnum]!=-1)return (bool)memo[left][right][funcnum];
  if(left==right){
    // DEBUG(funcnum);
    // DEBUG(my[funcnum].val);
    // DEBUG(x[left]);
    return (bool)(memo[left][right][funcnum]=(int)my[funcnum].val==x[left]);
  }
  for(int iter=left;iter<right;++iter){
    // cout << left << " " << iter << " " << right << endl;
    // DEBUG(funcnum);
    // cout<<"bunnretu"<<endl<<endl;
    // DEBUG(my[funcnum].left);
    bool result = solve(left,iter,my[funcnum].left) && solve(iter+1,right,my[funcnum].right);
    if(result)return (bool)(memo[left][right][funcnum]=1);
  }
  return (bool)(memo[left][right][funcnum]=0);
}

int main(){
  cin>>N;
  REP(i,N)cin>>x[i];
  cin>>M;
  REP(i,M){
    int a,b,c;
    cin>>a>>b>>c;
    --b;--c;
    my[i] = (myamfunc){a,b,c};
  }
  REP(i,N)REP(j,N)REP(k,M)memo[i][j][k]=-1;
  bool result = solve(0,N-1,0);
  if(result)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 1552
///╔══╗
///╚╗╔╝
///╔╝╚(¯`v´¯)
///╚══╝`.¸.´farzin


#include <bits/stdc++.h>

#define int int64_t
#define pb push_back
#define ibsws ios_base::sync_with_stdio
#define gcd __gcd
#define s second
#define f first
#define mp make_pair
typedef std::pair<int,int> pii ;

using namespace std;

const int N=3e3+10;
int n,a[N],dp[N][N][2];

int32_t main(){
	ibsws(true==false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        dp[i][i][1]=-1*a[i];
        dp[i][i][0]=a[i];
    }
    for(int i=1;i<n;i++){
        for(int j=0;j+i<n;j++){
            dp[j][j+i][0]=max(dp[j+1][j+i][1]+a[j],dp[j][j+i-1][1]+a[j+i]);
            dp[j][j+i][1]=min(dp[j+1][j+i][0]-a[j],dp[j][j+i-1][0]-a[j+i]);
        }
    }
    cout<<dp[0][n-1][0];
}


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

int main() {
  int N;
  cin >> N;
  int A[N-1];
  int num[N]={0};
  for(int i=0; i<N-1; i++){
    cin >> A[i];
    num[A[i]-1]++;
  }
  for(int i=0; i<N; i++){
    cout << num[i] << endl;
  }
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int H, W; scanf("%d %d", &H, &W);
  vector<string> grid(H);
  int white = 0;
  for (int i = 0; i < H; ++i) {
    cin >> grid[i];
    white += count(grid[i].begin(), grid[i].end(), '.');
  }

  vector<vector<int> > visited(H, vector<int>(W, 0));
  visited[0][0] = 1;
  queue<pair<pair<int, int>, int>> que;
  que.push(make_pair(make_pair(0, 0), 1));
  int dist = -1;

  while (not que.empty()) {
    pair<pair<int, int>, int> p = que.front(); que.pop();
    int r = p.first.first, c = p.first.second;
    int d = p.second;
    if (r == H - 1 and c == W - 1) {
      dist = d;
      break;
    }
    for (int dr = -1; dr <= 1; ++dr) {
      for (int dc = -1; dc <= 1; ++dc) {
        if (abs(dr) + abs(dc) != 1) { continue; }
        int nr = r + dr, nc = c + dc;
        if (nr < 0 or nr >= H or nc < 0 or nc >= W) { continue; }
        if (visited[nr][nc] or grid[nr][nc] == '#') { continue; }
        visited[nr][nc] = 1;
        que.push(make_pair(make_pair(nr, nc), d + 1));
      }
    }
  }

  int ans = -1;
  if (dist > 0) { ans = white - dist; }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(int argc, char *args[])
{
	int a, b, x = 0;
	int cat , dog = 0;

	//A B X入力
	scanf("%d %d %d", &a,  &b, &x);
	
	//X=猫がありうるケース
	// →XがA～A+Bの間の場合
	if ((a <= x) && ((a + b) >= x))
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}
	
	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
	int a,b,ans=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		if(i/10000==i%10&&(i%10000)/1000==(i%100)/10)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

cnt = 0
while True:
    if sum(list(1 for x in a if x % 2 == 1)) != 0:
        print(cnt)
        exit()  
    a = list(x // 2 for x in a)
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		StringTokenizer to;
		double[] nums = new double[6];
		String s;
		while ((s = reader.readLine()) != null) {
			to = new StringTokenizer(s);
			for (int i = 0; i < 6; i++) {
				nums[i] = Double.parseDouble(to.nextToken());
			}
			double a = nums[0];
			double b = nums[1];
			double c = nums[2];
			double d = nums[3];
			double e = nums[4];
			double f = nums[5];

			double x = (c * e - f * b) / (a * e - b * d);
			double y = (c * d - f * a) / (b * d - a * e);

			 if(x == -0.0)
                 x = 0.0;
             if(y == -0.0)
                 y = 0.0;
			builder.append(String.format("%.3f %.3f\n", x, y));

		}
		System.out.print(builder);
	}
}

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

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

void input_dolls(vector<pair<int, int>> &dolls, int n) {
	for(int i = 0; i < n; ++i) {
		int h, r;
		cin >> h >> r;
		dolls.emplace_back(h, r);
	}
}

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

	for(int n; cin >> n && n;) {
		vector<pair<int, int>> dolls;
		input_dolls(dolls, n);

		int m;
		cin >> m;
		input_dolls(dolls, m);

		sort(dolls.begin(), dolls.end());

		int prev_h = -1;
		vector<int> dp(1000, 0);
		vector<int> tmp(dp);

		for(const auto &doll : dolls) {
			const int h = doll.first;
			const int r = doll.second;

			if(prev_h < h) {
				tmp = dp;
				prev_h = h;
			}

			const int num = *max_element(tmp.begin(), tmp.begin() + r);
			chmax(dp[r], num + 1);
		}

		cout << *max_element(dp.begin(), dp.end()) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n, flag=1;
	vector<int> v;

	cin>> n;
	v.resize(n);
	for(int i=0;i<n;i++) cin>> v[i];

	sort(v.begin(), v.end());

	for (int i = 1;i < n;i++) {
		if (v[i - 1] == v[i]) flag = 0;
	}

	if (flag) cout << "YES" << endl;
	else cout<< "NO" << endl;

}


Measured memory_bytes: 1024
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let A: i64 = sc.get();
    let B: i64 = sc.get();
    let _C: i64 = sc.get();
    let K: i64 = sc.get();
    if K <= A {
        println!("{}", K);
    } else if K > A && K <= A+B {
        println!("{}", A);
    } else {
        println!("{}", A-(K - (A+B)));
    }
}


Measured memory_bytes: 2164
s = input()
num = len(s)
i, ans = 0, 0
while i < num-1:
    if s[i] != s[i+1]:
        ans += 1
        i += 1
    else:
        if i == num-2: ans += 1
        else: ans += 2
        i += 3
if num == 1: print(1)
elif i == num-1: print(ans+1)
else: print(ans)
    



Measured memory_bytes: 9304
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int x[101], y[101], h[101];

int calcCH(int x, int y,int h, int cx, int cy) {
	return h + abs(x - cx) + abs(y - cy);
}
int calcH(int H, int x, int y, int cx, int cy) {
	return max(H - abs(x - cx) - abs(y - cy), 0LL);
}

vector<vector<int>> ansCand;

signed main() {
	int N;
	cin >> N;
	int p[20001];
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	int sa = 30000;
	int a[20001], b[20001];
	for (int i = 0; i < N; i++) {
		a[i] = sa * (i+1);
		b[i] = sa * (N  - i);
	}
	for (int i = 0; i < N; i++) {
		a[p[i]-1] += i;
	}
	for (int i = 0; i < N-1; i++) {
		cout << a[i] << " ";
	}
	cout << a[N - 1];
	cout << "\n";
	for (int i = 0; i < N-1; i++) {
		cout << b[i] << " ";
	}
	cout << b[N - 1];

	return 0;
}

Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    string S; cin >> S;
    cout << S.substr(0, S.length()-8) << endl;
    return 0;
}


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

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {
        private int A, B;
        private void Scan()
        {
            var sc = new Scanner();
            A = sc.NextInt();
            B = sc.NextInt();
        }

        public void Solve()
        {
            Scan();
            Console.WriteLine((A + B + 1) / 2);
        }


        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
ll n,k;
vll a,f;
bool check(ll x){//全員x以内
  ll cnt=0;
  rep(i,0,n){
   if(a[i]*f[i]>x){
     cnt+=a[i]-x/f[i];
   }
  }
  return cnt<=k;
}

int main(){cout<<fixed<<setprecision(20);
		   //二分探索
           //O(nlog10^12)
           cin>>n>>k;
           a.resize(n);
           f.resize(n);
           rep(i,0,n)cin>>a[i];
           rep(i,0,n)cin>>f[i];
           sort(all(a));
           sort(all(f));
           reverse(all(a));
           ///////////////
           ll ok=1e12,ng=-1;
           while(ok-ng>1){
            ll mid=(ok+ng)/2;
             if(check(mid))ok=mid;
             else ng=mid;
           }
           cout<<ok<<endl;
}

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

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


Measured memory_bytes: 3100
//hail to jwalaji
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
vector<vector<lli>> adj(100005,vector<lli>());
vector<lli> store(100005,-1);
lli dfs(lli u,lli parent=-1){
    lli maxa=1;
    lli storemax=0;
    for(auto & v : adj[u]){
        if(v==parent)continue;
        else{
            if(store[v]!=-1){
                storemax=max(storemax,store[v]);
            }
           else
           storemax=max(storemax,dfs(v,u));
        }
    }
    store[u]=maxa+storemax;
    return maxa+storemax;
}
void solve(lli n){
    lli finalmax=0;
for(lli i=1;i<=n;i++){
        if(store[i]!=-1){
            finalmax=max(finalmax,store[i]);
        }
        else;
    finalmax=max(finalmax,dfs(i,-1));
    //cout<<finalmax-1<<" "<<i<<" hello "<<endl;
}
cout<<finalmax-1<<endl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
lli n,m;
cin>>n>>m;
for(lli i=0;i<m;i++){
    lli x,y;
    cin>>x>>y;
    adj[x].push_back(y);
}
solve(n);
return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  string s;
  
  if (a > b) s = "Alice";
  if (a < b) s = "Bob";
  if (a == 1) s = "Alice";
  if (b == 1) s = "Bob";
  if (a == b) s = "Draw";

  cout << s << endl;
}

Measured memory_bytes: 256
import java.awt.Point;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws java.io.IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		while (true) {
			int m = sc.nextInt();
			int n = sc.nextInt();
			if ((n | m) == 0)
				break;
			Point pos = new Point(1, 1);
			int d = 0;
			boolean flag = true;
			while (flag) {
				String tmp = sc.next();
				char c = tmp.toCharArray()[0];
				switch (c) {
				case 'F':
					int f = sc.nextInt();
					switch (d) {
					case 0:
						for (int i = 0; i < f; i++) {
							int ny = pos.y + 1;
							if (ny <= n)
								pos.y++;
							else
								break;
						}
						break;
					case 1:
						for (int i = 0; i < f; i++) {
							int nx = pos.x + 1;
							if (nx <= m)
								pos.x++;
							else
								break;
						}
						break;
					case 2:
						for (int i = 0; i < f; i++) {
							int ny = pos.y - 1;
							if (ny > 0)
								pos.y--;
							else
								break;
						}
						break;
					case 3:
						for (int i = 0; i < f; i++) {
							int nx = pos.x - 1;
							if (nx > 0)
								pos.x--;
							else
								break;
						}
						break;
					}
					break;

				case 'B':
					int b = sc.nextInt();
					switch (d) {
					case 0:
						for (int i = 0; i < b; i++) {
							int ny = pos.y - 1;
							if (ny > 0)
								pos.y--;
							else
								break;
						}
						break;
					case 1:
						for (int i = 0; i < b; i++) {
							int nx = pos.x - 1;
							if (nx > 0)
								pos.x--;
							else
								break;
						}
						break;
					case 2:
						for (int i = 0; i < b; i++) {
							int ny = pos.y + 1;
							if (ny <= n)
								pos.y++;
							else
								break;
						}
						break;
					case 3:
						for (int i = 0; i < b; i++) {
							int nx = pos.x + 1;
							if (nx <= m)
								pos.x++;
							else
								break;
						}
						break;
					}
					break;
				case 'R':
					d = (d + 1) % 4;
					break;
				case 'L':
					d = (d + 3) % 4;
					break;
				case 'S':
					flag = false;
					break;
				}
			}
			System.out.println(pos.x + " " + pos.y);
		}
	}

}

Measured memory_bytes: 12000
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * pow(i+1, mod - 2, mod) % mod
    return res

n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
all_patern = pow(2, n, mod) - 1
minus_a = combination(n, a)
minus_b = combination(n, b)
print((all_patern - minus_a - minus_b) % mod)

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

bool grid[80][80][6400];

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> grid1(h, vector<int>(w));
    vector<vector<int>> grid2(h, vector<int>(w));
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> grid1[i][j];;
        }
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> grid2[i][j];;
        }
    }
    grid[0][0][abs(grid1[0][0] - grid2[0][0])] = true;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (i + 1 < h){
                int tmp = abs(grid1[i + 1][j] - grid2[i + 1][j]);
                for (int k = 0; k < 6400; k++){
                    if (!grid[i][j][k]) continue;
                    if (k + tmp < 6400) grid[i + 1][j][k + tmp] = true;
                    if (abs(k - tmp) < 6400) grid[i + 1][j][abs(k - tmp)] = true;
                }
            }
            if (j + 1 < w){
                int tmp = abs(grid1[i][j + 1] - grid2[i][j + 1]);
                for (int k = 0; k < 6400; k++){
                    if (!grid[i][j][k]) continue;
                    if (k + tmp < 6400) grid[i][j + 1][k + tmp] = true;
                    if (abs(k - tmp) < 6400) grid[i][j + 1][abs(k - tmp)] = true;
                }
            }
        }
    }
    for (int i = 0; i < 6400; i++){
        if (grid[h - 1][w - 1][i]){
            cout << i << endl;
            return 0;
        }
    }
}

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

int main(){
    int n;
    cin>>n;
    int cnt=0;
    rep(i,n){
        int a; cin>>a;
        if(a%2==1)cnt++;
    }
    if(cnt%2==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N,A[200001],sum[200002],res=0;
  cin >> N;
  REP(i,N)cin >> A[i];
  map<ll,ll> mp;
  sum[0] = 0;
  mp[0]++;
  REP(i,N){
    sum[i+1] = sum[i] + A[i];
    res+=mp[sum[i+1]];
    mp[sum[i+1]]++;
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  int a=0;
  
  for(int i; i<N; i++){
    int x,y;
    cin >>x >>y;
    a +=y-x+1;
  }
  
  cout <<a <<endl;
  
}

Measured memory_bytes: 256