akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		int n = in.nextInt();
		long k= in.nextLong();
		long [] freq= new long[(int) (10e5+12)];
		
		for(int i=0; i<n; i++){
			int num= in.nextInt();
			int copies= in.nextInt();
			freq[num] += (long) copies;
		}
		int i=0;
		for(; i<freq.length;i++){
			k-=freq[i];
			if(k<=0){
				break;
			}
		}
		System.out.println(i);
		
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 49860
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let s: String = scan(tokens);
    let mut t: String = String::with_capacity(s.len());
    for _ in 0..s.len() {
        t.push('x');
    }
    println!("{}", t);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;
int main(){
  int N, magic = 0;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++){
      cin >> a[i];
    }
    int counter = 1;
    for(int i = 1; i < N; i++){
      if(a[i-1] == a[i])  counter ++;
      if(a[i-1] != a[i] || i == N-1){
        if(counter != 0){
          //cout << i << " " << counter << endl;
          magic += counter / 2;
        }
        counter = 1;
      }
    }
  cout << magic << endl;
  return 0;
}


Measured memory_bytes: 256
local str = io.read()
local spos = string.find(str, "A")
local epos

if not spos then
	print(0)
end

for i=string.len(str), spos + 1, -1 do
	local v = string.sub(str, i, i)
	if v == "Z" then
		epos = i
		break
	end
end

if not epos or (spos > epos) then
	print(0)
end

print(epos - spos + 1)

Measured memory_bytes: 760
N, K = map(int, input().split())
D = list(map(int, input().split()))

i = N
while True:
  flg = True
  for j in str(i):
    if int(j) in D:
      flg = False
      break

  if flg == True:
    print(i)
    exit()

  i += 1


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    string s, t;
    cin>>s>>t;
    int n = sz(s);
    int mn = INF;
    for(int i = 0; i <= n-sz(t); i++){
        int cnt = 0;
        for(int j = i; j < i+sz(t); j++){
            if(s[j]!=t[j-i])cnt++;
        }
        mn=min(mn, cnt);
    }   
    cout<<mn;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3656
//
// Created by Abhishek Bansal on 9/02/2020.
//
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

    int n, x, t; cin >> n >> x >> t;
    cout << (n%x==0? (n/x)*t: (n/x+1)*t);
    return 0;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

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

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int l, r, d;
	cin >> l >> r >> d;

	int ans = 0;
	
	for(int i = l; i <= r; i++){
		if(i % d == 0) ans++;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
int h,w;
std::vector<string> s,ans;
int vecx[8] = {1,1,0,-1,-1,-1,0,1};
int vecy[8] = {0,1,1,1,0,-1,-1,-1};
int main(){
  cin >> h >> w;
  s.resize(h);ans.resize(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      if(s[y][x] == '.'){
        int temp=0;
        string in;
        for (int l = 0; l < 8; l++) {
          if(y+vecy[l]<0 || y+vecy[l]>=h || x+vecx[l]<0 || x+vecx[l]>=w) continue;
          if(s[y+vecy[l]][x+vecx[l]] == '#'){
            temp++;
          }
        }
        in = to_string(temp);
        ans[y] += in;
      }else{
        ans[y] += '#';
      }
    }
  }
  for (int i = 0; i < h; i++) {
    cout << ans[i] << endl;
  }
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pb push_back

int main(void)
{
  int n, m;
  cin >> n >> m;
  vec<vec<int>> mp(n, vec<int>(0));
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    mp[a].pb(b);
    mp[b].pb(a);
  }

  int flag = 1;
  rep(i, n) if (mp[i].size() % 2) flag = 0;
  if (!flag) {
    cout << "No" << endl;
    return 0;
  }

  //次数が６以上->三分割
  //次数４が３以上->２回踏む閉路があればOK、なければ次数４の３点が分離して2つの閉路に入ってるので各２点間の異なるパスが2つ取れて組み合わせれば閉路完成
  //次数４が２個->２回踏む閉路があればOK、なければダメ
  //次数４が１個以下->muri

  int if6 = 0;
  vec<int> count4(0);
  rep(i, n) {
    if (mp[i].size() >= 6) if6 = 1;
    if (mp[i].size() == 4) count4.pb(i);
  }
  if (if6) cout << "Yes" << endl;
  else if (count4.size() > 2) cout << "Yes" << endl;
  else if (count4.size() < 2) cout << "No" << endl;
  else {
    //次数４の点を片方抜いて閉路ができるか問題
    int start = count4[0];
    int del = count4[1];
    int flag = 0;
    rep(i, mp[start].size()) {
      vec<int> dp(n, 0);
      dp[start] = 1;
      int cur = mp[start][i];
      if (cur == del) continue;
      dp[cur] = 2;
      while(1) {
        int f = 0;
        rep(j, mp[cur].size()) {
          if (mp[cur][j] == del) continue;
          if (mp[cur][j] == start && dp[cur] != 2) {
            flag = 1;
            break;
          }
          if (dp[mp[cur][j]]) continue;
          cur = mp[cur][j];
          dp[cur] = 1;
          f = 1;
        }
        if (flag) break;
        if (!f) break;
      }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 6144
def step():
    n = int(input()) #sinceramente, isso aqui não serve pra nada
    alturas = list(map(int, input().split()))
    height = 0;

    for i in range(0, len(alturas)-1):
        if alturas[i] > alturas[i+1]:
            height += alturas[i] - alturas[i+1]
            alturas[i+1] = alturas[i]

    print(height)

step()

Measured memory_bytes: 105072
#include <iostream>
#include <string> 
#include <stack>
#include <utility>
#include <set>
#include <vector>
#include <queue>
using namespace std;

const long long int MOD = 1000000007;

long long int search(int n,vector<vector<int>>& from) {
	//cout << n << endl;
	long long int ret = 1;
	if (from[n].empty()) {
		return 2;
	}
	for (auto i : from[n]) {
		ret *= search(i, from);
		ret %= MOD;
	}
	ret++;
	ret %= MOD;
	return ret;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>to(N + 1);
	vector<vector<int>>from(N + 1);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		to[a] = b;
		from[b].push_back(a);
	}
	vector<bool>use(N + 1, true);
	vector<bool>ignore(N + 1);
	long long int ans = 1;
	for (int i = 1; i <= N; i++) {
		if (!use[i]) {
			continue;
		}
		vector<bool>used(N + 1);
		queue<int>Q;
		Q.push(i);
		while (!Q.empty()) {
			int cn = Q.front();
			use[cn] = false;
			used[cn] = true;
			Q.pop();
			if (to[cn]) {
				if (used[to[cn]]) {
					int nx = to[to[cn]];
					to[to[cn]] = 0;
					for (int j = 0; j < from[to[cn]].size(); j++) {
						if (cn == from[to[cn]][j]) {
							swap(from[to[cn]][j], from[to[cn]][from[to[cn]].size() - 1]);
							from[to[cn]].pop_back();
							break;
						}
					}
					while (nx != to[cn]) {
						for (int j = 1; j <= N; j++) {
							if (to[j] == nx) {
								to[j] = to[cn];
							}
						}
						ignore[nx] = true;
						nx = to[nx];
					}
				}
				else {
					Q.push(to[cn]);
				}
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		from[i].clear();
	}
	for (int i = 1; i <= N; i++) {
		if (ignore[i])continue;
		from[to[i]].push_back(i);
	}
	for (int i = 1; i <= N; i++) {
		if (ignore[i]) {
			continue;
		}
		if(to[i]){
			continue;
		}
		//cout << i << "start" << endl;
		ans *= search(i, from);
		ans %= MOD;
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3176
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 anand.oza
 */
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);
        DXorSum2 solver = new DXorSum2();
        solver.solve(1, in, out);
        out.close();
    }

    static class DXorSum2 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n + 1];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }

            int left = 0;
            int right = 0;

            long answer = nc2(n + 1);
            long xor = a[0];
            while (right < n && left < n) {
                if (right + 1 < n && (a[right + 1] & xor) == 0) {
                    right++;
                    xor ^= a[right];
                } else {
                    xor ^= a[left];
                    left++;
                    answer -= (n - 1 - right);
                }
            }

            out.println(answer);
        }

        static long nc2(long n) {
            return n * (n - 1) / 2;
        }

    }

    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: 43880
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

int dp[2][10010];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int> v(N), w(N); rep(i, 0, N) { cin >> v[i] >> w[i]; }
	memset(dp, 0, sizeof(dp));
	rep(i, 0, N) {
		rep(j, 0, W + 1) {
			chmax(dp[(i + 1) & 1][j], dp[i & 1][j]);
			if (j + w[i] > W)continue;
			chmax(dp[(i + 1) & 1][j + w[i]], dp[i & 1][j] + v[i]);
		}
	}
	cout << dp[N & 1][W] << endl;
	return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;

    For(i, 0, 100) {
        if (x - i < 0) continue;

        if (i * 2 + (x - i) * 4 == y) {
            print("Yes");
            return 0;
        }
    }
    print("No");

    return 0;
}


Measured memory_bytes: 3644
from collections import Counter
from itertools import combinations

n = int(input())
s = []
for i in range(n):
    temp = input()[0]
    if temp in ['M', 'A', 'R', 'C', 'H']:
        s.append(temp)

c = Counter(s)
combi = combinations(c.values(), 3)

ans = 0
for a, b, c in combi:
    ans += a * b * c

print(ans)


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,Int k){
    Mint num(1),dom(1);
    for(Int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}


template<typename T, typename ...Ts>
vector<T> fusion(vector<T> bs,Ts... ts){
  auto append=[&](auto vs){for(auto v:vs) bs.emplace_back(v);};
  initializer_list<Int>{(void(append(ts)),0)...};
  return bs;
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n,k;
  cin>>n>>k;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  vector<Int> ps,ns,zs;
  for(Int i=0;i<n;i++){
    if(as[i]> 0) ps.emplace_back(+as[i]);
    if(as[i]< 0) ns.emplace_back(-as[i]);
    if(as[i]==0) zs.emplace_back( as[i]);
  }

  using M = Mint<Int>;
  // ans > 0
  if((Int)ps.size()+(Int)ns.size()/2*2>=k){
    Int d=min(k,(Int)ns.size())/2*2;
    if(k-d>(int)ps.size()) goto UKU;

    sort(ps.rbegin(),ps.rend());
    sort(ns.rbegin(),ns.rend());

    M ans{1};
    for(Int i=0;i<d;i++) ans*=M(ns[i]);
    for(Int i=0;i<k-d;i++) ans*=M(ps[i]);

    for(Int i=k-d;i<k and i+1<(int)ps.size() and i-(k-d)+2<=d;i+=2){
      if(ps[i+0]*ps[i+1]>ns[d-(i-(k-d)+1)]*ns[d-(i-(k-d)+2)]){
        ans*=M(ps[i+0]);
        ans*=M(ps[i+1]);
        ans/=M(ns[d-(i-(k-d)+1)]);
        ans/=M(ns[d-(i-(k-d)+2)]);
        continue;
      }
      break;
    }
    drop(ans);
  }
  UKU:

  // ans = 0
  if(!zs.empty()) drop(0);

  // ans < 0
  auto bs=fusion(ps,ns);
  sort(bs.begin(),bs.end());
  M ans{1};
  for(Int i=0;i<k;i++) ans*=M(bs[i]);
  cout<<-ans<<newl;
  return 0;
}


Measured memory_bytes: 11160
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000001
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int SQRT(int x) {
    int ok = 1;
    int ng = INF;
    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if(mid * mid <= x) ok = mid;
        else ng = mid;
    }
    return ok;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //REP(i, 1, 100) cout << i << " " << SQRT(i) << endl;
    int Q; cin >> Q;
    while(Q--) {
        int A, B;
        cin >> A >> B;
        if (A > B) swap(A, B);
        int cnt = SQRT(A * B - 1);
        int ans = 0;
        //cout << "*" << cnt << " " << A * B - cnt * cnt <<" ";
        if (cnt >= A * B - cnt * cnt)ans--;
        ans += cnt;
        if (A <= cnt) cnt--;
        ans += cnt;
        //cout << cnt << endl;
        //cout << "**" << cnt << " " << cnt2 << " " << cnt + cnt2 << endl;
        cout << ans << endl;
    }
    

    return 0;
}
// 1 10
//(1 9)
// 2 4
//[3 3]
// 4 2
// 5 1

// 1 4
//(1 3)
// 2 1

// 2 8
// 1 15
// 3 5
// 5 3
// 7 2
// 15 1

// 4 4
// 1 15
// 2 7
// 3 5

// 1 7
// 2 3
// 3 2
// 6 1

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e2 + 10;
const int  INF = 0x3f3f3f3f;
struct EDGE{ int v, w, nxt; }Edge[maxn * maxn];
int Head[maxn], cnt, id, N;
int ID[3][maxn];
int Weight[3][maxn];
 
inline void init()
{
    memset(Head, -1, sizeof(Head));
    cnt = id = 0;
}
 
inline void AddEdge(int From, int To, int Weight)
{
    Edge[cnt].v = To;
    Edge[cnt].w = Weight;
    Edge[cnt].nxt = Head[From];
    Head[From] = cnt++;
}
 
struct Node{
    int first, second;
    Node(){};
    Node(int f, int s):first(f), second(s){};
    bool operator < (const Node & rhs) const{
        return this->first < rhs.first;
    };
};
int Dis[maxn];
int Dij()
{
    int st = ID[1][1];
    int des = ID[2][N];
    for(int i=0; i<=id; i++) Dis[i] = -INF;
    Dis[st] = Weight[1][1];
    priority_queue<Node> que;
    que.push(Node(Dis[st], st));
    while(!que.empty()){
        Node T = que.top();
        que.pop();
        if(T.first != Dis[T.second]) continue;
        for(int i=Head[T.second]; i != -1; i=Edge[i].nxt){
            int Eiv = Edge[i].v;
            if(Dis[Eiv] < Dis[T.second] + Edge[i].w){
                Dis[Eiv] = Dis[T.second] + Edge[i].w;
                que.push(Node(Dis[Eiv], Eiv));
            }
        }
    }
    return Dis[des];
}
 
#define Debug 0
int main(void)
{
#if Debug
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    while(~scanf("%d", &N)){
        init();
        for(int i=1; i<=2; i++)
            for(int j=1; j<=N; j++){
                ID[i][j] = id++;
                scanf("%d", &Weight[i][j]);
                if(j != 1) AddEdge(ID[i][j-1], ID[i][j], Weight[i][j]);
                if(i != 1) AddEdge(ID[i-1][j], ID[i][j], Weight[i][j]);
            }
//        for(int i=1; i<=2; i++){
//            for(int j=1; j<=N; j++){
//                printf("%d ", ID[i][j]);
//            }puts("");
//        }puts("");
        printf("%d\n", Dij());
    }
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = [0] + A
A = list(accumulate(A))

B = [0] + B
B = list(accumulate(B))

ans = 0
b_cnt = m
for a_cnt in range(n+1):
    if A[a_cnt] > k: continue

    while A[a_cnt]+B[b_cnt] > k:
        b_cnt -= 1
    ans = max(ans, a_cnt+b_cnt)

print(ans)

Measured memory_bytes: 42336
#include <iostream>

using namespace std;
typedef long long ll;

//计算n转成b进制形式之后每位的和
ll cal(ll b, ll n) {
    ll r = 0;
    while (n) {
        r += n % b;
        n /= b;
    }
    return r;
}

int main() {
    ll n, s;
    cin >> n >> s;
    if (n < s) {
        cout << -1 << endl;
        return 0;
    }
    if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }
    //先暴力尝试所有sqrt(n)以内的数
    for (ll i = 2; i * i <= n; ++i) {
        if (cal(i, n) == s) {
            cout << i << endl;
            return 0;
        }
    }
    /*
     * 否则b>sqrt(n)，则b进制下，n可以表示成两位数n = bq + r
     * s = q + r则：
     * b = (n-s)/q+1
     * 枚举n-s的约数q即可，因为b>sqrt(n)，所以q<sqrt(n)
     * */
    ll ans = 0;
    for (ll i = 1; i * i <= n; ++i) {
        if ((n - s) % i == 0) {
            ll b = (n - s) / i + 1;
            if (cal(b, n) == s) {
                ans = b;
            }
        }
    }
    if (ans != 0) {
        cout << ans << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc142/tasks/abc142_d

#include "algorithm"
#include "iostream"
#include "vector"
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;

template <class T>
inline bool chmax(T& a, T b);
template <class T>
inline bool chmin(T& a, T b);

vector<pair<ll, ll>> factorize(ll n) {
  vector<pair<ll, ll>> res;

  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;

    auto r = pair<ll, ll>(i, 0);

    while (n % i == 0) {
      n /= i;
      r.second++;
    }

    res.push_back(r);
  }

  // sqrt(n) 以上の素因数は高々一つ
  if (n != 1) res.emplace_back(n, 1);

  return res;
}

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

void solve() {
  ll A, B;
  cin >> A >> B;

  ll g = gcd(A, B);
  auto f = factorize(g);
  ll res = f.size() + 1;
  cout << res << endl;
}

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
#endif

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

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


Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()

    left = 0
    right = 0
    for c in s:
        if c == '(':
            right += 1
        else:
            if right > 0:
                right -= 1
            else:
                left += 1

    print('(' * left + s + ')' * right)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=200005;
const int mod=1e9+7;
const int inv2=(mod+1)>>1;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
int n,a[MAXN];
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
struct bittree
{
	int bit[MAXN];
	int lowbit(int x){return x&-x;}
	void modify(int x,int c){for(;x<=n;x+=lowbit(x))ad(bit[x],c);}
	int qry(int x){int ret=0;for(;x>=1;x-=lowbit(x))ad(ret,bit[x]);return ret;}
}bi,bi1,bi2;
int id[MAXN],d[MAXN],nxt[MAXN],pre[MAXN],rnk[MAXN];
bool cmp(int n1,int n2){return a[n1]<a[n2];}
int main()
{
//	freopen("e.in","r",stdin);
//	freopen("e.out","w",stdout);
	n=read();for(int i=1;i<=n;i++)a[i]=read(),id[i]=i;
	sort(id+1,id+1+n,cmp);int sum=1;
	for(int i=1;i<=n;i++)rnk[id[i]]=i;
	for(int i=1;i<=n;i++)sum=1LL*sum*(a[id[i]]-i+1)%mod;if(!sum)return pr2(0),0;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int u=id[i];
		d[i]=1LL*pow_mod(a[u]-i+1,mod-2)*(a[u]-i)%mod;
		d[i]=d[i-1]?1LL*d[i-1]*d[i]%mod:d[i];
	}nxt[n+1]=n+1;
	for(int i=1;i<=n;i++)pre[i]=(!d[i-1]?i-1:pre[i-1]);
	for(int i=n;i>=1;i--)nxt[i]=(!d[i+1]?i+1:nxt[i+1]);
	for(int i=n;i>=1;i--)
	{
		int u=rnk[i];
		int nx=(bi.qry(nxt[u])-bi.qry(u-1)+mod)%mod;
		nx=1LL*nx*pow_mod(d[u],mod-2)%mod*(a[i]-u)%mod;
		ad(ans,1LL*nx*inv2%mod*sum%mod);
		bi.modify(u,1LL*pow_mod(a[i]-u+1,mod-2)*d[u-1]%mod);
		
		nx=(bi2.qry(u)-bi2.qry(pre[u]-1)+mod)%mod;int tot=bi1.qry(u);
		nx=1LL*nx*d[u-1]%mod*pow_mod(a[i]-u+1,mod-2)%mod;
		nx=1LL*nx*inv2%mod*sum%mod;
		nx=(1LL*sum*tot%mod-nx+mod)%mod;
		ad(ans,nx);
		bi1.modify(u,1);
		int val=(a[i]-u);
		if(d[u])bi2.modify(u,1LL*val*pow_mod(d[u],mod-2)%mod);
		else bi2.modify(u,val);
	}pr2(ans);
	return 0;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

ll N, L, R;
vector<int> A(100010, 0);
vector<ll> fac(300001); //n! (mod M)
vector<ll> ifac(300001); //k! ^ {M - 2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

void Factorial(){
	fac[0] = 1;
	for(ll i = 0; i < 300000; i++) fac[i + 1] = fac[i] * (i + 1) % MOD; // n!(mod M)
	return;
}

ll Pow(ll x, ll n){ //x^n(mod M) ←普通にpow(x, n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n & 1) ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

void Reciprocal(){
	ifac[0] = 1;
	for(ll i = 0; i < 300000; i++) ifac[i + 1] = ifac[i] * Pow(i + 1, MOD - 2) % MOD; // k! ^ {M - 2} (mod M) ←累乗にmpowを採用
	return;
}

ll nCr(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    ll tmp = (ifac[a - b] * ifac[b]) % MOD;
    return (tmp * fac[a]) % MOD;
}

int main(void){
	
	scanf("%lld", &N);
	for(int i = 0; i < N + 1; ++i) scanf("%d", &A[i]);
	
	vector<int> v(100010, -1);
	for(int i = 0; i < N + 1; ++i){
	    if(v[A[i]] >= 0){
	        L = v[A[i]];
	        R = i;
	        break;
	    }
	    v[A[i]] = i;
	}

	Factorial();
	Reciprocal();
	
	int cnt = L + (N - R);
    for(int r = 1; r <= N + 1; ++r){
        ll ans = nCr(N + 1, r);
        ll sub = nCr(cnt, r - 1);
        if(ans - sub < 0) ans += MOD;
        printf("%lld\n", ans - sub);
    }
    
    return 0;
}


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

int main(){
  
  long long N,K;
  cin >> N >> K;
  vector<double> p(N);
  vector<double> E(N);
  
  for(int i = 0; i < N; i++){
  	cin >> p.at(i);
  }
  
  for(int i = 0; i < N; i++){
  	E.at(i) = (p.at(i)+1)/2;
  }
  
  double sum = 0;
  
  for(int i = 0; i<K; i++){
    		sum += E.at(i); 
  }
  
  int i = 0;
  double max = sum;
  
  while(i + K <N){
  		sum += E.at(K + i);
    	sum -= E.at(i);
    if(sum > max){
    max = sum;
    }
    i++;
  }
cout << fixed << setprecision(1);
  cout << max << endl;
}


Measured memory_bytes: 3328
//

fun main() {
    nomura2020a()
}

fun nomura2020a() {
    val (h1, m1, h2, m2, k) = readLine()!!.split(" ").map { it.toInt() }
    println(h2 * 60 + m2 - k - h1 * 60 - m1)
}


Measured memory_bytes: 36376
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int kk = sc.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        long[][][] dp = new long[n + 1][n + 1][256];
        dp[0][0][0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= i - 1; j++) {
                for (int k = 0; k < 256; k++) {
                    dp[i][j][k] += dp[i - 1][j][k];
                    dp[i][j][k] %= MOD;
                    dp[i][j + 1][k ^ arr[i]] += dp[i - 1][j][k];
                    dp[i][j + 1][k ^ arr[i]] %= MOD;
                }
            }
        }
        long total = 0;
        for (int i = 0; i <= n; i++) {
            if (dp[n][i][kk] != 0) {
                total += dp[n][i][kk] * kaijo(i) % MOD;
                total %= MOD;
            }
       }
        System.out.println(total);
    }
    
    static long kaijo(long x) {
        if (x == 0) {
            return 1;
        } else {
            return x * kaijo(x - 1) % MOD;
        }
    }
}



Measured memory_bytes: 58196
"""
【最長共通部分列問題】
2つの文字列s,tが与えられたときの2つの共通部分文字列の長さの最大値とその文字列
!!制約!!
1<=n,m<=1000
"""
#-------------------------------------------------------------------------------

#入力,準備
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for i in range(m+1)] for j in range(n+1)]


#メイン

#dp[i][j]:=s_1~s_iとt_1~t_jに対するLCSの長さ

for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1 #同じならくっつけられる
        else:
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
#print(dp[n][m])

#dpを逆からたどって文字列を復元
ans = ''
while(dp[n][m]>0):
  if dp[n][m] == dp[n-1][m-1] +1 and dp[n][m] == dp[n-1][m] +1 and dp[n][m] == dp[n][m-1] +1:
    ans += s[n-1]
    n -= 1
    m -= 1
  elif dp[n-1][m] > dp[n][m-1]:
    n -= 1
  else:
    m -= 1
print(''.join(reversed(list(ans))))

Measured memory_bytes: 119900
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	long long a[n+1], b[n];
	for(int i=0; i<n+1; i++)
		cin >> a[i];
	long long res=0;
	for(int i=0; i<n; i++){
		cin >> b[i];
		if(b[i]>=a[i]){
			res+=a[i];
			b[i]-=a[i];
			if(b[i]>=a[i+1]){
				res+=a[i+1];
				a[i+1]=0;
			} 
			else{
				res+=b[i];
				a[i+1]-=b[i];
			} 
		}
		else res+=b[i];
	}
	cout << res;
}

Measured memory_bytes: 1792
import java.io.*;
public class Main {
 public static void main(String[] args){
  try{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   int a[];
   a=new int[50];
   while(true){
    String str[];
    str= new String[50];
    str=br.readLine().split(" ");
    int n=Integer.parseInt(str[0]);
    if(n==0)break;
    str=br.readLine().split(" ");
    for(int i=0;i<n;i++)a[i]=Integer.parseInt(str[i]);
    int idx=0,cnt=0,f=0;
    for(int i=1;i<n;i++){
     if(a[i-1]==a[i]-1)cnt++;
     else{
      if(f!=0)System.out.print(" ");
      f=1;
      if(cnt==0){System.out.print(a[i-1]);idx++;}
      else {
       System.out.print(a[idx]);
       System.out.print("-");
       System.out.print(a[i-1]);
       idx=i;
      }
      cnt=0;
     }
    }//for
    if(cnt!=0){
     if(f==1)System.out.print(" ");
     System.out.print(a[idx]);
     System.out.print("-");
    }
    if(cnt==0 && f==1)System.out.print(" ");
    System.out.print(a[n-1]);
    System.out.print("\n");
   }
  } 
  catch(Exception e){return ;}
 }
}


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

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=500;

int n,h;
int fa[N],ok[N],ou[N],into[N];

inline int read()
{
	int o=0; char ch=' ';
	for(;ch<'0'||ch>'9';ch=getchar());
	for(;ch>='0'&&ch<='9';ch=getchar())o=o*10+ch-48;
	return o;
}

inline int gf(int o)
{return fa[o]==o?o:fa[o]=gf(fa[o]);}

int main()
{
	cin>>n>>h;
	int a,b,c,d;
	fo(i,1,h<<1)fa[i]=i;
	fo(i,1,n){
		a=read(),b=read(),c=read(),d=read();
		int zb=0,yb=0; 
		if(c)zb=c+h;else zb=a;
		if(d)yb=d;else yb=b+h;
		++ou[zb]; ++into[yb];
		fa[gf(yb)]=gf(zb);
	}
	fo(i,1,(h<<1))if(into[i]!=ou[i])ok[i]=1;
	fo(i,1,h)if(into[i]>ou[i]){
		puts("NO"); return 0;
	}
	fo(i,h+1,h<<1)if(into[i]<ou[i]){
		puts("NO"); return 0;
	}
	fo(i,1,h<<1)ok[gf(i)]|=ok[i];
	fo(i,1,h<<1)if((into[i]||ou[i])&&!ok[i]&&fa[i]==i){
		puts("NO"); return 0;
	}
	puts("YES");
}

Measured memory_bytes: 256
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void YES()
{
	OUT("YES");
}
void NO()
{
	OUT("NO");
}
void YESNO(const bool cond)
{
	OUT(cond ? "YES" : "NO");
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}
void YesNo(const bool cond)
{
	OUT(cond ? "Yes" : "No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n)
{
	for (ll i = n - 1; i > 1; --i)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r)
{
	if (r * 2 > n) r = n - r;

	ll dividend = 1, divisor = 1;

	for (ll i = 1; i <= r; ++i) {
		dividend *= n - i + 1;
		divisor *= i;
	}

	return dividend / divisor;
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0) return false;
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

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

void Main()
{
	inll n, m, X, Y;
	ll xmax = -1, ymin = 999;
	REP(i, n)
	{
		inll x_;
		xmax = max(xmax, (ll)x_);
	}
	REP(i, m)
	{
		inll y_;
		ymin = min(ymin, (ll)y_);
	}

	FOR(i, X+1, Y+1)
	{
		if (xmax < i && i <= ymin) return OUT("No War");
	}
	
	return OUT("War");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

int main(void){
  int A,B;
  cin >> A >> B;
  if(A*B%2==1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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


const int SIZE = 101;

int main(){
  int n,m,l;
  int a[SIZE][SIZE],b[SIZE][SIZE];
  long long c[SIZE][SIZE] = {};

  cin >> n >> m >> l;

  for(int i=0;i<n;++i){
    for(int k=0;k<m;++k){
      cin >> a[i][k];
    }
  }

  for(int i=0;i<m;++i){
    for(int k=0;k<l;++k){
      cin >> b[i][k];
    }
  }

  for(int i=0;i<n;++i){
    for(int k=0;k<l;++k){
      for(int e=0;e<m;++e){
	c[i][k] += a[i][e]*b[e][k];
      }
    }
  }

  for(int i=0;i<n;++i){
    for(int k=0;k<l;++k){
      cout << c[i][k];

      if(k!=l-1){
	cout << " ";
      }
    }
    cout <<endl;
  }

  return 0;
}



Measured memory_bytes: 3280
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;
    const int lim = 100000;
    vs64 cnt(lim + 1, 0);

    s64 sum = 0;
    rep (i, n)
    {
        int a;
        cin >> a;
        sum += a;
        ++cnt[a];
    }

    int q;
    cin >> q;
    while (q--)
    {
        int b, c;
        cin >> b >> c;

        sum = sum - cnt[b] * b + cnt[b] * c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << "\n";
    }

    return 0;
}



Measured memory_bytes: 3988
#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<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
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++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
int n, m;
ll x[1 << 17];
bool onunite[1 << 17];
int cc[1 << 17],pp[1<<17];
ll val[1 << 17];

struct edge {
	ll cost; int a,b;
	bool operator<(const edge &e)const {
		if (e.cost != cost)return e.cost > cost;
		if (e.a != a)return e.a > a;
		return e.b > b;
	}
};
edge e[1 << 17];

struct uf {
	vector<int> par, r;
	uf(int n) {
		par.resize(n); r.resize(n, 0);
		rep(i, n)par[i] = i;
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return find(par[x]);
	}
	int unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y)return 0;
		if (r[x] < r[y]) {
			par[x] = y;
			return x;
		}
		else {
			par[y] = x;
			if (r[x] == r[y])r[x]++;
			return y;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
ll sum[1 << 17];
int main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> sum[i];
	}
	rep(i, m) {
		int a, b; ll c;
		cin >> a >> b >> c; a--; b--;
		e[i] = { c,a,b };
	}
	sort(e, e + m);
	uf u(n);
	rep(i, m) {
		if (u.same(e[i].a, e[i].b)) {
			onunite[i] = false;
		}
		else {
			onunite[i] = true;
			int chi = u.unite(e[i].a, e[i].b);
			int par = u.find(chi);
			cc[i] = chi; pp[i] = par;
			val[i] = sum[chi];
			sum[par] += sum[chi];
		}
	}
	int ans = 0;
	per(i, m) {
		ll cost = e[i].cost;
		int aa = u.find(e[i].a);
		if (cost > sum[aa]) {
			ans++;
			//辺を切る
			if (onunite[i]) {
				sum[cc[i]] = val[i]; sum[pp[i]] -= val[i];
				u.par[cc[i]] = cc[i];
			}
		}
	}
	cout << ans << endl;
	//stop
	return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
int main(){
  cin.tie(nullptr);ios::sync_with_stdio(false);
  string s,t;cin >> s >> t;
  ll n = s.size(),m = t.size(),i,j;
  ll next[n][26];
  for(i=0;i<n;i++) fill(next[i],next[i]+26,-1);
  for(i=0;i<n;i++) next[i][s[i]-'a'] = i;
  ll now;
  for(j=0;j<26;j++){
    now = -1;
    for(i=n-1;i>=0;i--){
      if(next[i][j] == -1) next[i][j] = now;
      else now = next[i][j];
    }
    for(i=n-1;next[i][j]==-1 && i>=0;i--) next[i][j] = now;
  }
  ll ans = 0,point = 0;
  for(i=0;i<m;i++){
    if(next[point][t[i]-'a'] == -1){
      printf("-1\n");return 0;
    }
    if(next[point][t[i]-'a'] < point) ans += next[point][t[i]-'a']-point+n;
    else ans += next[point][t[i]-'a']-point;
    ans++;point = next[point][t[i]-'a']+1;
    if(point == n) point = 0;
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 24160
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll X;
  cin >> X;

  ll time = 1;
  while(time  * (time + 1) / 2 < X) time++;

  cout << time << endl;
  
  return 0;
}

Measured memory_bytes: 256
n,m,s,t = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
for i in range(-101,101):
    if x[-1] < i <= y[0] and s < i <= t:
        print("No War")
        exit()
print("War")


Measured memory_bytes: 38384
#include <iostream>

using namespace std;

int main()
{
	long long int k, s;
	long long int ans = 0;
	
	cin >> k >> s;
	
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			if (s - (x + y) >= 0 && s - (x + y) <= k) ans++;
		}
	}
	
	cout << ans << endl;
	
	return (0);
}

Measured memory_bytes: 256
#include <iostream>

int main(){

    int n = 0,y = 0;
    int k = 0;

    std::cin >> n >> y ;

    k = y / 10000;

    for (int a = k; a >= 0 ; a-- ){
        for(int b = n; b >= 0; b-- ) {
            int l = 0, c = 0;
            l = y - (10000 * a + 5000 * b) ;
            c = n - (a+b);
            if ( l / 1000 == c ){
                if( c < 0) continue;
                std::cout << a << " " << b << " " << c << std::endl; 
                return 0;
            }
        }
    }
    std::cout << "-1 -1 -1";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  string s;
  cin >> n >> m >> s;
  vector<ll> v;
  int c=1,t=s[0]=='R';
  REP(i,1,n) {
    int r=s[i]=='R';
    if(t!=r) {
      v.pb(c);
      c=1;
      t=r;
    } else c++;
  }
  if(c) v.pb(c);
  ll ans=n-v.size();
  pr(min(n-1,ans+m*2));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

Measured memory_bytes: 1480