akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

vector<long long> divisor(long long n){
    vector<long long> ret;
    for(int64_t i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    sort(ret.begin(),ret.end());
    return ret;
}

int main()
{
	ll n,ans=0;
	cin >> n;
	for(ll i=1;i<=n;i++){
		vll v=divisor(i);
		if(SIZE(v)==8 && i%2) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
X = int(input())

prime = [0] * (2 * X)

for i in range(2, 2 * X):
	if prime[i] == 0:
		for j in range(2, (2 * X) // i):
			prime[j * i] = 1
	else:
		continue

for i in range(X, 2 * X):
	if prime[i] == 0:
		print(i)
		break


Measured memory_bytes: 41200
#include <bits/stdc++.h>
using namespace std;
vector<int>a[1005];
int main()
{
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    int f=0;
    for(int i=0; i<n; i++)
    {
        int x;
        scanf("%d",&x);
        for(int j=0;j<x;j++)
            a[f/w].push_back(i+1),f++;
    }
 
    for(int i=0; i<h; i++)
    {
        if(i&1)reverse(a[i].begin(),a[i].end());
        printf("%d",a[i][0]);
        for(int j=1; j<w; j++)
            printf(" %d",a[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    long long n = N/K;
    long long ans = 0;
    ans += n*n*n;
    if(!(K%2)){
        int m = N%K;
        if(m >= K/2) n++;
        ans += n*n*n;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef int LL;
#define pb push_back
const LL maxn=1e6+9;
struct node{
	LL to,nxt;
}dis[maxn];
LL n,num;
LL head[maxn],p[maxn],dep[maxn];
std::vector<LL> V[3],a[3];
void Add(LL u,LL v){
	dis[++num]=(node){v,head[u]}; head[u]=num;
}
void Dfs(LL u,LL f){
	V[dep[u]].pb(u);
	for(LL i=head[u];i;i=dis[i].nxt){
		LL v(dis[i].to); if(v==f) continue;
		dep[v]=(dep[u]^1); Dfs(v,u); 
	}
}
int main(){
	scanf("%d",&n);
	for(LL i=1;i<n;++i){
		LL u,v; scanf("%d%d",&u,&v);
		Add(u,v); Add(v,u);
	}
	for(LL i=1;i<=n;++i){
		a[i%3].pb(i);
	}
	LL ret(n/3);
	Dfs(1,0);
	if(V[0].size()>V[1].size()) std::swap(V[0],V[1]);
	LL tot0(0),tot1(0),tot2(0);
	if(V[0].size()<=ret){
		for(LL i=0;i<V[0].size();++i){
			LL x(V[0][i]);
			p[x]=a[0][tot0++];
		}
		for(LL i=0;i<V[1].size();++i){
			LL x(V[1][i]);
            if(tot2<a[2].size()) p[x]=a[2][tot2++];
		    else if(tot0<a[0].size()) p[x]=a[0][tot0++];
		    else p[x]=a[1][tot1++];
		}
		for(LL i=1;i<=n;++i) printf("%d ",p[i]); puts("");
		return 0;
	}
	for(LL i=0;i<V[0].size();++i){
		LL x(V[0][i]);
		if(tot1<a[1].size()) p[x]=a[1][tot1++];
		else if(tot0<a[0].size()) p[x]=a[0][tot0++];
		else p[x]=a[2][tot2++];
	}
	for(LL i=0;i<V[1].size();++i){
		LL x(V[1][i]);
		if(tot2<a[2].size()) p[x]=a[2][tot2++];
		else if(tot0<a[0].size()) p[x]=a[0][tot0++];
		else p[x]=a[1][tot1++];
	}
	for(LL i=1;i<=n;++i) printf("%d ",p[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 18412
N, M, S = gets.split.map(&:to_i)
@g, amax = Array.new(N + 1){[]}, 0
M.times do
  u, v, a, b = gets.split.map(&:to_i)
  @g[u] << [v, a, b]; @g[v] << [u, a, b]
  amax = a if a > amax
end
Cs, Ds = [nil], [nil]
N.times do
  c, d = gets.split.map(&:to_i)
  Cs << c; Ds << d
end
MAX = amax*(N - 1)
INF = 10**20

class Stop
  include Comparable
  attr_accessor :i, :t, :m
  
  def initialize(i, t, m)
    @i, @t, @m = i, t, [m, MAX].min
  end

  def <=>(other)
    @t <=> other.t
  end
end

class PriorityQueue
  def initialize
    @q = [nil]
  end

  def bubble_up(i)
    pi = i / 2
    return if i <= 1 || @q[pi] <= @q[i]
    @q[i], @q[pi] = @q[pi], @q[i]
    bubble_up(pi)
  end

  def add(e)
    @q << e
    bubble_up(@q.size - 1)
  end

  def bubble_down(i)
    ci = i * 2
    return if ci > @q.size - 1
    ci += 1 if ci != @q.size - 1 && @q[ci] > @q[ci + 1]
    return if @q[i] <= @q[ci]
    @q[i], @q[ci] = @q[ci], @q[i]
    bubble_down(ci)
  end

  def pop
    @q[1], @q[-1] = @q[-1], @q[1]
    ret = @q.pop
    bubble_down(1)
    ret
  end

  def empty?
    @q.size == 1
  end
end

dp = Array.new(N + 1){Array.new(MAX + 1, INF)}
dp[1][[S, MAX].min] = 0
q = PriorityQueue.new
q.add(Stop.new(1, 0, S))
while !q.empty?
  c = q.pop
  i, t, m = c.i, c.t, c.m
  next if t > dp[i][m]
  if m + Cs[i] <= MAX
    t1, m1 = t + Ds[i], m + Cs[i]
    if dp[i][m1] > t1
      dp[i][m1] = t1
      q.add(Stop.new(i, t1, m1))
    end
  end
  @g[i].each do |j, a, b|
    next if m < a
    t1, m1 = t + b, m - a
    if dp[j][m1] > t1
      dp[j][m1] = t1
      q.add(Stop.new(j, t1, m1))
    end
  end
end
(2 .. N).each{|i| puts dp[i].min}

Measured memory_bytes: 21008
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
 
#define int long long int
#define ld long double
#define mod 1000000007 
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define forn(i,s, e) for (int i = s; i <= e; i++)
#define fornd(i,s, e) for (int i = s ; i >= e; i--)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define print(x) for(auto el: x) cout<<el<<" ";cout<<"\n"
#define PSET(x,y) fixed<<setprecision(y)<<x
// #define bits(x) __builtin_popcount(x)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*void fileio()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}*/
 
 
template <typename T> 
void swap(T& a, T& b){
    T temp = a;
    a = b;
    b = temp;
}
void selfadd(int& a, int b){
    a = a+b;
    if(a>=mod)
        a = a-mod;
}
void selfsub(int& a, int b){
    a = a-b+mod;
    if(a>=mod)
        a = a-mod;
}  
const int N = 200005; 

int bit[N];
void update(int index,int value,int n){

    for(;index<=n;index += index &(-index)){
        bit[index] = max(bit[index],value);
    }
}
int value(int index){
    int res= 0;
    for(;index >0 ;index -= index & (-index)){
        res = max(res,bit[index]);
    }
    return res;
}


void solve(){
    
    int n;
    cin>>n;
    int* h = new int[n]();
    int* b = new int[n]();
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    memset(bit,0,sizeof(bit));
    int ans = 0;
    for(int i=0;i<n;i++){
        int temp= value(h[i]-1) + b[i];
        ans = max(ans,temp);
        update(h[i], temp, n);
    }
    cout<<ans<<endl;


}
 
int32_t main()
{
    //fileio();
    fast;
    // int t;
    // cin>>t;
    // for(int y=1;y<=t;y++)
    {
        // cout<<"Case #"<<y<<": ";
        solve();
    }
    return 0;
} 

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define int long long

using namespace std;

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

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << '\n';


    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int n,m;
	cin>>n>>m;
	int k[m];
	int s[m][n];
	rep(i,m){
		cin>>k[i];
		rep(j,k[i])cin>>s[i][j],s[i][j]--;
	}
	int p[m];
	rep(i,m)cin>>p[i];

	int sw[n],ans=0,flag=0;
	for(int bit=0;bit<(1<<n);bit++){
		rep(i,n)sw[i]=0;
		flag=0;
		for(int i=0;i<n;i++){
			if(bit & (1<<i))sw[i]++;
		}
		rep(i,m){
			int sum=0;
			rep(j,k[i]){
				sum+=sw[s[i][j]];
			}
			if(sum%2!=p[i]){
				flag=1;
				break;
			}
		}
		if(flag==0)ans++;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int data[100],a,i,j,tmp,min,c=0;
  scanf("%d",&a);
  for(i=0;i<a;i++){
      scanf("%d",&data[i]);
  }
  for(i=0;i<a-1;i++){
      min=i;
      for(j=i;j<a;j++){
        if(data[j]<data[min])
        min=j;
      }
      tmp=data[i];
      data[i]=data[min];
      data[min]=tmp;
      if(data[i]!=data[min]) c++;
    }
       
 
  for(i=0;i<a;i++){
      printf("%d",data[i]);
      if(i!=a-1) printf(" ");
    }
  printf("\n");
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 604
//libs

#include <bits/stdc++.h>

//other stuff

using namespace std;

//function call

//main

int main(){	
	long long n=0,h=0,c=0;
	cin >> n;
	int a[n*3];
	for(int i=0;i<3*n;i++){
		cin >> a[i];
	}
	sort(a,a+(n*3),greater<int>());
	while(c<n){
		h += a[c*2+1];
		c++;
	}
	cout<<h<<endl;
return 0;
}

//functions



Measured memory_bytes: 1408
def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum += c[i]*(d-last_d[i])
        
    return (score - sum)

def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    #print(c)

    #print(s)

    last_d = [0 for i in range(26)]
    
    ans = []
    
    score = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])):
                max = s[i][j] + c[j] * (i-last_d[j])
                idx = j
        last_d[idx] = i+1
        score += s[i][j]
        down_score(i+1,c,last_d,score)
        
        ans.append(idx)

    for i in range(D):
        print(ans[i]+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9500
from collections import deque
s = deque(list(input()))
n = int(input())
flag = True
for _ in range(n):
    q = list(map(str, input().split()))
    if len(q) == 1:
        if flag:
            flag = False
        else:
            flag = True
    if len(q) == 3:
        if (q[1] == "1" and flag == False) or (q[1] == "2" and flag):
            s.append(q[2])
        else:
            s.appendleft(q[2])
if flag == False:
    s.reverse()
print("".join(s))

Measured memory_bytes: 8676
use std::io::{self};

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let s = s.trim_right().to_owned();
    let vec: Vec<&str> = s.split_whitespace().collect();
    let n: i32 = vec[0].parse().unwrap_or(0);
    let i: i32 = vec[1].parse().unwrap_or(0);
    println!("{}", format!("{}", n - i + 1));
}


Measured memory_bytes: 4352
#  --*-coding:utf-8-*--

import math



def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    s = sum(A)

    D1 = []
    D2 = []

    for i in range(1, int(math.sqrt(s))+1):
        if s%i == 0:
            D1.append(s//i)
            D2.append(i)

    for d in D1 + list(reversed(D2)):
        B = sorted([a%d for a in A])
        x = sum(B[:-sum(B)//d])
        
        if x <= K:
            print(d)
            return

main()


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int A, B, C;
  cin >> A >> B >> C;

  int K;
  cin >> K;

  bool flag = false;

  for (int i = 0; i <= K; i++){
    int A1 = A * pow(2,i);
    for(int j = 0; j <= K-i; j++){
      int B1 = B * pow(2,j);
      int C1 = C * pow(2,K-i-j);
      if((C1>B1)&&(B1>A1)) flag = true;
      if(flag) break;
    }
    if(flag) break;
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

vector<P> a;
ll ans;
vector<P> cur;
ll n;

vector<P> prime_decomposition(ll n) {
  vector<P> res;
  for (ll p = 2; p * p <= n; p++) {
    if (n % p != 0) continue;
    ll cnt = 0;
    while (n % p == 0) {
      cnt++;
      n /= p;
    }
    res.push_back({p, cnt});
  }
  if (n != 1) {
    res.push_back({n, 1});
  }
  return res;
}

void dfs(ll pos) {
  if (pos == SZ(a)) {
    // check
    ll deg = 0;
    REP(i, SZ(cur)) { deg = max(deg, cur[i].second); }
    FOR(d, 1, deg + 1) {
      // d乗数
      ll k = 1;
      bool valid = true;
      REP(i, SZ(cur)) {
        if (cur[i].second % d != 0) {
          valid = false;
          break;
        }
        REP(_, cur[i].second / d) { k *= cur[i].first; }
      }
      // DUMP(k);
      if (k == 1 || k == n || !valid) {
        continue;
      }
      ll kd = 1;
      REP(_, d) { kd *= k; }
      if ((n / kd) % k == 1) {
        ans++;
      }
    }
    return;
  }
  REP(i, a[pos].second + 1) {
    cur.push_back({a[pos].first, i});
    dfs(pos + 1);
    cur.pop_back();
  }
}

int main() {
  cin >> n;
  a = prime_decomposition(n);
  ans = 0;
  dfs(0);
  for (ll i = 1; i * i <= n - 1; i++) {
    if ((n - 1) % i == 0) {
      ans++;
      if (i != (n - 1) / i) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define M 23456
#define N 512
int a[N];

vi v={1}, v2;
void ad(int a, int c){
	v2.clear();
	for(int j : v){
		REP(k, c+1) v2.EB(j), j*=a;
	}
	swap(v, v2);
}
vi u;

int main(){
	int n; int k; scanf("%d%d", &n, &k);
	int s = 0;
	REP(i, n) scanf("%d", a+i), s += a[i];
	FOR(i, 2, M){
		if(s%i==0){
			int c = 0;
			while(s%i==0) s/=i, c++;
			ad(i, c);
		}
	}
	if(s>1) ad(s, 1);
	// for(int i : v) DEBUG("%d ", i);
	// DEBUG("\n");

	int ans = 1;
	for(int &x : v){
		u.clear();
		int sm = 0;
		REP(i, n){
			int b = a[i] - a[i]/x*x;
			u.EB(b);
			sm += b;
		}
		sort(u.begin(), u.end(), greater<int>());
		int z = 0;
		FOR(i, sm/x, n) z += u[i];
		DEBUG("%d -> sm=%d, min=%d\n", x, sm, z);
		if(z <= k) LAR(ans, x);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
struct edge{int u,v;ll c;};
bool cmp(edge& e1,edge& e2){
    return e1.c<e2.c;
}
struct UnionFind{
    vector<int> siz,par;
    vector<ll> cst;
    UnionFind(int n){
        siz.resize(n,1);
        par.resize(n);
        for(int i=0;i<n;i++)par[i]=i;
    }
    int find(int x){
        if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
    }
    bool unite(int u,int v){
        u=find(u);v=find(v);
        if(u==v)return false;
        if(siz[u]<siz[v])swap(u,v);
        siz[u]+=siz[v];
        par[v]=u;
        return true;
    }
};
int main(){
    int n,m,k;cin>>n>>m>>k;
    vector<int> c(n);
    for(int i=0;i<n;i++){
        cin>>c[i];
        if(c[i]==0)c[i]=n+i;
    }
    vector<edge> es;
    for(int i=0;i<m;i++){
        int a,b;ll w;cin>>a>>b>>w;--a;--b;
        es.push_back({c[a],c[b],w});
    }
    sort(all(es),cmp);
    int co=0;
    UnionFind uf(n*2);
    ll ans=0;
    for(auto e:es){
        if(uf.unite(e.u,e.v)){
            ans+=e.c;
            co++;
            if(co==k-1){
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3824
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 100000 + 10;

int n;
int h[MAXN];
int ans;

int main() {
	
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &h[i]);
	}
	
	int last = n;
	int mx = h[n];
	for (int i = n - 1; i >= 1; i--) {
		if (h[i] < mx) {
			mx = h[i];
			last = i;
		}
		else {
//			printf("%d\n", i);
//			printf("%d %d\n", mx, h[i]);
			mx = max(mx, h[i]);
			ans = max(ans, last - i);
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
	
}

Measured memory_bytes: 512
#include<stdio.h>

int main()
{
    int a,b;
    char op;
    scanf("%d %c %d",&a,&op,&b);
    if(1<=a && a<=1000000000 && 1<=b && b<=1000000000){
        if(op=='+') printf("%d",a+b);
        if(op=='-') printf("%d",a-b);
    }
return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define int long long
using namespace std;


int32_t main(){
      
      int n ,m;
      cin >> n >> m;
      vector<pair<int,int>> f(m);

      for(auto &it : f){
            cin >> it.second >> it.first; 
      }

      sort(f.begin() , f.end());
      
      int fi = 0;
      int ans = 0;

      for(int x=0;x<m;x++){
            if(fi <= f[x].second){
                  ans++;
                  fi = f[x].first;
            }
      }

      cout << ans << endl;

     return 0;
}

Measured memory_bytes: 1792
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
#define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N 			1e5+5
#define M           1000000007
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j,k;
void Anon_mouS(){
	int a[3][3];
	for(i=0;i<3;i++)for(j=0;j<3;j++)cin>>a[i][j];
	int n;
	cin>>n;
	bool b[3][3];
	mem0(b);
	for(k=0;k<n;k++){
		int x;
		cin>>x;
		for(i=0;i<3;i++)for(j=0;j<3;j++)if(a[i][j]==x){
			b[i][j]=1;
			break;
		}
	}
	for(i=0;i<3;i++)if(b[i][0] and b[i][1] and b[i][2] or b[0][i] and b[1][i] and b[2][i]){
		cout<<"Yes"<<endl;
		return;
	}
	if(b[0][0] and b[1][1] and b[2][2] or b[0][2] and b[1][1] and b[2][0]){
		cout<<"Yes"<<endl;
		return;
	}
	cout<<"No"<<endl;
}
int32_t main(){
    fastio;
    // file;
    // sieve();
    int q=1;
    // cin>>q;
    while(q--)Anon_mouS();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
   
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int T;
	T=1;
	while(T--)
	{
		int n,x,t;
		cin>>n>>x>>t;
		if(n%x==0) x=n/x;
		else x=n/x+1;
		cout<<x*t<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define int long long

using namespace std;
const int maxn = 2e5 + 7;
int n, ans, Maxa[maxn], Minb[maxn];
pair<int, int> p[maxn], pmax, Min[maxn];

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> p[i].first >> p[i].second;
        ans = max(ans, p[i].second - p[i].first + 1);
        pmax = max(pmax, p[i]);
    }
    if(n == 2)
    {
        int ans = 0;
        for(int i = 1; i <= n; i++) ans += p[i].second - p[i].first + 1;
        cout << ans;
        exit(0);
    }
    sort(p + 1, p + n + 1, [](const pair<int, int> &a, const pair<int, int> &b)
         {
             if(a.second == b.second) return a.first < b.first;
             return a.second < b.second;
         });
    Maxa[1] = p[1].first;
    for(int i = 2; i <= n; i++) Maxa[i] = max(Maxa[i - 1], p[i].first);
    for(int i = n; i > 1; i--)
    {
        if(p[i].second <= pmax.second)
        {
            ans = max(ans, max(p[i].second - pmax.first + 1, 0ll) + max(p[1].second - Maxa[i - 1] + 1, 0ll));
        }
    }
    int Max = 0;
    for(int i = 2; i <= n; i++)
    {
        if(p[i] != pmax) Max = max(Max, p[i].second - p[i].first + 1);
    }
    ans = max(ans, max(p[1].second - pmax.first + 1, 0ll) + Max);
    cout << ans;
}


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

int main(){
  long n;
  cin >> n;
  double x[n];
  string u[n];
  double kekka = 0;
  for(long i = 0;i < n;i++){
    cin >> x[i] >> u[i];
    if(u[i] == "JPY"){
      kekka += x[i];
    }
    else{
      kekka += 380000*x[i];
    }
  }
  cout << kekka << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define MID ((l+r)>>1)
#define lc (rt<<1)
#define rc (rt<<1|1)
#define ls lc,l,MID
#define rs rc,MID+1,r
#define st 1,1,n
#define PII pair<int,int>
#define PLL pair<LL,LL>
using namespace std;
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
const int N=1e5+1;
const LL M=1e18;
int main(){Accel
	int n,x;
	int a=0,b=0,c=0;
	cin>>n>>x;
	while(x>=10000)a=x/10000,x%=10000;
	while(x>=5000)b=1,x-=5000;
	while(x>=1000)c=x/1000,x%=1000;
	while(a+b+c<=n){
		if(a+b+c==n)return printf("%d %d %d\n",a,b,c),0;
		if(a+b+c+4<=n&&b)b--,c+=5;
		else if(a+b+c+1<=n&&a)a--,b+=2;
		else break;
	}
	puts("-1 -1 -1");
}

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

int main(){
  double X, K, D;
  cin >> X >> K >> D;
  
  double r;
  r = min(floor(abs(X)/D),K);
  if (X>0){
    X = X-r*D;
  }else{
    X = X+r*D;
  }
  
  if (((K-r)-floor((K-r)/2)*2)==0){
    X = X;
  }else{
    X = min(abs(X-D), abs(X+D));
  }

/*
  for (double i = 0; i < K; i++){
    if (abs(X-D) < abs(X+D)){
      X = X-D;
    }else{
      X = X+D;
    }
  }
  */
  cout << fixed << setprecision(0) << abs(X);
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;
ll m = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  ll temp = 0;
  for(int i=1; i<n; i++) temp += a[i];
  ll sum = 0;
  rep(i, n-1) {
    sum = (sum % m + ((a[i] % m) * (temp % m)) % m) % m;
    // sum = sum % m + ((a[i] % m) * (temp % m)) % m;
    temp -= a[i+1];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4740
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

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

    for (ll i = max(X - K + 1, -100000LL); i <= min(X + K - 1, 100000LL); i++)
    {
        cout << i << (i == min(X + K - 1, 100000LL) ? "\n" : " ");
    }
    
}

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

int main(){
    int a,b;
    cin >> a >> b;
    string A = to_string(a);
    string B = to_string(b);
    string C="", D="";
    rep(i,b) C += A;
    rep(i,a) D += B;
    cout << min(C,D) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
int main()
{
	int a = 0, b = 0;
	std::cin >> a >> b ;
	std::cout << a/b << " " << a%b <<  " " << std::setiosflags(std::ios::fixed) << std::setprecision(5) << (double)a/b << std::endl;
	return 0;
}


Measured memory_bytes: 3208
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;

int n;
string seq;
set<string> D;
map<string, vector<string> > M;
vector<string> ans;

void dfs(int cur, vector<string> path){
    if ( cur == seq.size() ){
	string s = "";
	for ( int i = 0; i < path.size(); i++ ){
	    if ( i ) s += ' ';
	    s += path[i];
	}
	ans.push_back(s);
	return;
    }

    string target = "";
    for ( int i = cur; i < cur + 50 && i < seq.size(); i++ ){
	target +=  seq[i];
	if ( D.find(target) != D.end() ){
	    vector<string> v = M[target];
	    for ( int j = 0; j < v.size(); j++ ){
		vector<string> np = path;
		np.push_back(v[j]);
		dfs(i+1, np);
	    }
	    //return;
	}
    }


}

void compute(){
    cin >> seq;
    
    vector<string> path;
    ans.clear();

    dfs(0, path);

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

    for ( int i = 0; i < ans.size(); i++ ){
	cout << ans[i] << "." << endl;
    }
    cout << "--" << endl;
}

string getNumber(string str){
    string num = "";
    for ( int i = 0; i < str.size(); i++ ){
	char ch = str[i];
	if ( 'a' <= ch && ch <='c' ) num += '2';
	if ( 'd' <= ch && ch <='f' ) num += '3';
	if ( 'g' <= ch && ch <='i' ) num += '4';
	if ( 'j' <= ch && ch <='l' ) num += '5';
	if ( 'm' <= ch && ch <='o' ) num += '6';
	if ( 'p' <= ch && ch <='s' ) num += '7';
	if ( 't' <= ch && ch <='v' ) num += '8';
	if ( 'w' <= ch && ch <='z' ) num += '9';
    }
    return num;
}

main(){
    string str, number;
    while( cin >> n && n){
	D.clear();
	M = map<string, vector<string> >();
	for ( int i = 0; i < n; i++ ){
	    cin >> str;
	    number = getNumber(str);
	    D.insert(number);
	    M[number].push_back(str);
	}

	compute();
    }
}

Measured memory_bytes: 0
a, b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0:
    print("Possible")
elif a % 3 == 1 and b % 3 == 2:
    print("Possible")
elif a % 3 == 2 and b % 3 == 1:
    print("Possible")
else:
    print("Impossible")


Measured memory_bytes: 8996
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

long long inf = 1e9+7;

int main(void){
    int n;
    string a, b, c;
    cin >> n;
    cin >> a;
    cin >> b;
    cin >> c;
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] && b[i] == c[i]) ans += 0;
        else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) ans++;
        else ans += 2;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

const ll MOD = 1000000007;

struct mint {
    ll x;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    mint operator-() const {
        return mint(-x);
    }
    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t/2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) {
    return os << a.x;
}

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

int main() {
    int K;
    string S;
    cin >> K >> S;
    int N = S.size();

    combination nCk(2000009);
    mint ans = 0;
    for(int i=N;i<=K+N;++i){
        mint tmp = nCk(i,N) - nCk(i-1,N);
        mint al1 = 25;
        mint al2 = 26;
        tmp*=(al1.pow(i-N));
        tmp*=(al2.pow(K+N-i));
        ans+=tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 35648
#include <stdio.h>
#include <string.h>

struct era {
    char era_name[8];
    int era_year;
};

void trans(int year, int month, int day);

int main(void)
{
    int year, month, day;
    while (scanf("%d %d %d", &year, &month, &day) != EOF) {
        trans(year, month, day);
    }
    return 0;
}


void trans(int year, int month, int day)
{
    int n = 0;
    struct era data;
    if (year - 1989 > 1) {
        strcpy(data.era_name, "heisei");
        data.era_year = year - 1989 + 1;
    } else if (year -1989 == 0) {
        if (month - 1 > 0) {
            strcpy(data.era_name, "heisei");
            data.era_year = 1;
        } else if (month - 1 == 0) {
            if (day - 8 >= 0) {
                strcpy(data.era_name, "heisei");
                data.era_year = 1;
            } else {
                strcpy(data.era_name, "showa");
                data.era_year = 64;
            }
        }
    } else if (year - 1926 > 0) {
        strcpy(data.era_name, "showa");
        data.era_year = year - 1926 + 1;
    } else if (year - 1926 == 0) {
        if (month - 12 == 0) {
            if (day - 25 >= 0){
                strcpy(data.era_name, "showa");
                data.era_year = 1;
            } else {
                strcpy(data.era_name, "taisho");
                data.era_year = 15;
            }
        } else {
            strcpy(data.era_name, "taisho");
            data.era_year = 15;
        }
    } else if (year - 1912 > 0) {
        strcpy(data.era_name, "taisho");
        data.era_year = year - 1912 + 1;
    } else if (year - 1912 == 0) {
        if (month - 7 > 0) {
            strcpy(data.era_name, "taisho");
            data.era_year = 1;
        } else if (month - 7 == 0) {
            if (day - 30 >= 0) {
                strcpy(data.era_name, "taisho");
                data.era_year = 1;
            } else {
                strcpy(data.era_name, "meiji");
                data.era_year = 45;
            }
        } else {
            strcpy(data.era_name, "meiji");
            data.era_year = 45;
        }
    } else if (year - 1868 > 0) {
        strcpy(data.era_name, "meiji");
        data.era_year = year - 1868 + 1;
    } else if (year - 1868 == 0) {
        if (month - 9 > 0) {
            strcpy(data.era_name, "meiji");
            data.era_year = 1;
        } else if (month - 9 == 0) {
            if (day - 8 >= 0) {
                strcpy(data.era_name, "meiji");
                data.era_year = 1;
            } else {
                n += 1;
            }
        } else {
            n += 1;
        }
    } else {
        n += 1;
    }
    if (n == 1) {
        printf("pre-meiji\n");
    } else {
        printf("%s %d %d %d\n", data.era_name, data.era_year, month, day);
    }
}
		
	    
   	    

Measured memory_bytes: 1036
#include<iostream>

#define INF 5000000

using namespace std;
const int V=120;
int map[V][V]={INF};
int dis[V];
bool used[V];

int dijkstra(int s,int e){
	fill(dis,dis+V,INF);
	fill(used,used+V,false);
	dis[s]=0;
	while(true){
		int v=-1;
		for(int u=0;u<V;u++){
			if(!used[u] && (v==-1 || dis[u]<dis[v]))v=u;
		}
		if(v==-1)break;
		used[v]=true;
		for(int u=0;u<V;u++){
			dis[u]=min(dis[v]+map[v][u],dis[u]);
		}
	}
	if(dis[e]!=INF)return dis[e];
	else return -1;
}

int main(){
	int N,K;
	while(cin>>N>>K && N && K){
		fill((int*)map,(int*)map+V*V,INF);
		for(int loop=0;loop<K;loop++){
			int check;
			cin>>check;
			if(check==0){
				int s,e;
				cin>>s>>e;
				cout<<dijkstra(s,e)<<endl;
			}
			else {
				int c,d,e;
				cin>>c>>d>>e;
				map[c][d]=map[d][c]=min(map[c][d],e);
			}
		}
	}
}

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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    int v[55], c[55];
    for(int i = 0; i < n; ++i)
        scanf("%d", &v[i]);
    for(int i = 0; i < n; ++i)
        scanf("%d", &c[i]);
    int ans = 0;
    for(int i = 0; i < n; ++i)
    {
        if(v[i] - c[i] > 0)
            ans += v[i] - c[i];
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  int x,n;cin>>x>>n;
  vector<int> P(n);
  rep(i,n){
    cin>>P[i];
  }
  map<int,int> mp;
  rep(i,n){
    mp[P[i]] = 1;
  }
  rep(dist, 110){
    if(mp.count(x-dist) == 0){
      cout<<x-dist<<endl;
      return 0;
    }
    if(mp.count(x+dist) == 0){
      cout<<x+dist<<endl;
      return 0;
    }
  }
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    int A = S.size();
    if (S.at(A-1) == 's'){
        cout << S << "es" << endl;
    }
    else {
        cout << S << "s" << endl;
    }
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int a[100010];
int main()
{
	int n;
	cin>>n;
	a[0]=0;
	a[n+1]=0;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=abs(a[i]-a[i-1]);
	}
	sum+=abs(a[n+1]-a[n]);
	for(int i=1;i<=n;i++)
	{
		cout<<sum-abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])<<endl;
	}
	return 0;
}

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

int main() {
    int n, m, l;
    int A[100][100], B[100][100];
    long C[100][100];
    int x,y;
    
    
    cin >> n >> m >> l;
    
    for (int i = 0; i < n; i++){
        for (int j = 0; j < l; j++) {
            C[i][j] = 0;
        }
    }
    
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++) {
            cin >> x;
            A[i][j] = x;
        }
    }
    
    for (int j = 0; j < m; j++) {
        for (int k = 0; k < l; k++) {
            cin >> y;
            B[j][k] = y;
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            for (int k = 0; k < l; k++) {
                C[i][k] += A[i][j] * B[j][k];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l - 1; j++) {
            cout << C[i][j] << " ";
        }
        cout << C[i][l - 1] << endl;
    }
    return 0;
}



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


#define ll long long

int mod=1e9+7;


ll ways(int a[],int n,int k){

    vector<vector<ll>> dp(n+1,vector<ll>(k+1,0));

    for(int i=0;i<=n;i++){
        dp[i][0]=1;

    }
    


    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++){

            // for(int cand=0;cand<=a[i-1];cand++){
            //     if(cand<=j){
            //         dp[i][j]=dp[i-1][j-cand];
            //         dp[i][j]%=mod;
            //     }else{
            //         break;
            //     }
            // } // it will take o(n*k^2) time complexity so we need to optimize it so: 
            // optimization :
            //
            
            dp[i][j]=(mod+dp[i][j-1]+dp[i-1][j]-((j-a[i-1]-1>=0)?dp[i-1][j-a[i-1]-1]:0))%mod;
            


        }
    }

    return dp[n][k];
}



int main() {
   
   int n,k;
   cin>>n>>k;
   int a[n];

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

   cout<<ways(a,n,k);




}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;
    cin >> s;
    long long ans = 0;
    long long run = 0;
    long long prev_climax = 0;
    for (int i=0; i<=s.length(); i++) {
        if (i == s.length() || (i > 0 && s[i] != s[i - 1])) {
            if (s[i - 1] == '<') {
                ans += (run + 1) * run / 2;
                prev_climax = run;
            } else {
                ans += (run + 1) * run / 2;
                ans -= min(prev_climax, run);
            }
            run = 1;
        } else {
            run++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 




vector<pair<int,int>> adj[100005];
ll dist[100005];
int n;
void dfs(int node,int par){
     for(auto ch:adj[node]){
          if(ch.fi==par)continue;
          dist[ch.fi]=dist[node]+ch.se;
          dfs(ch.fi,node);
     }
}




int main()
{
     cin>>n;
     for(int i=1;i<n;i++){
          int u,v,w;
          cin>>u>>v>>w;
          adj[u].push_back({v,w});
          adj[v].push_back({u,w});
     }
     dist[1]=0;
     dfs(1,-1);
     for(int i=1;i<=n;i++){
          if(dist[i]%2)cout<<1;
          else cout<<0;
          cout<<endl;
     }

}



































Measured memory_bytes: 12612
import java.util.*;
import static java.lang.System.*;

class Guidebook implements Comparable<Guidebook>{
  public String city;
  public int score;
  public int number;
  
  public int compareTo(Guidebook obj){
    if(this.city.equals(obj.city)){
      return obj.score - this.score;
    }else{
      return this.city.compareTo(obj.city);
    }
  }
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int s[] = new int[M];
    for(int i=0; i<M; i++){
      int k = sc.nextInt();
      for(int j=0; j<k; j++){
        int a = sc.nextInt();
        s[i] += 1 << (a-1);
      }
    }
    int p[] = new int[M];
    for(int i=0; i<M; i++) p[i] = sc.nextInt();
    int ans = 0;
    for(int i=0; i<(1<<N); i++){
      boolean check = true;
      for(int j=0; j<M; j++){
        int tmp = i & s[j];
        int cnt = 0;
        while(tmp > 0){
          if((tmp & 1) == 1) cnt++;
          tmp >>= 1;
        }
        if(cnt % 2 != p[j]){
          check = false;
          break;
        }
      }
      if(check == true) ans++;
    }
    out.println(ans);
      
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}



Measured memory_bytes: 22100
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const ll INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

int main(){
	int n;
	cin >> n;
	vector<pll> line(n);
	foreach(i, line)cin>>i.first>>i.second;
	sort(all(line), [](pll a, pll b){
			return a.first + a.second > b.first + b.second;
			});
	ll ans = 0;
	rep(i, n)ans += (i&1)?-line[i].second:line[i].first;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)


int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	cin >> N;

	int d;
	set<int> s;
	for (size_t i = 0; i < N; i++)
	{
		cin >> d;
		s.insert(d);
	}
	cout << s.size() << endl;
	return 0;
}


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

using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll arr[n] , sqsum = 0, sumsq = 0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sqsum += arr[i];
        sumsq += (arr[i] * arr[i]) %mod;
    }
    sqsum %= mod;
    sumsq %= mod;
    sqsum *= sqsum;
    sqsum %= mod;
    cout<<(((sqsum - sumsq + mod) % mod) * 500000004) % mod<<endl;
    return 0;
}


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

int main() {
  ll n;
  cin >> n;
  string ans = "";
  while (n > 0) {
    n--;
    ans += 'a' + n % 26;
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 3580
import math
N, K = map(int, input().split())
As = list(map(int, input().split()))
Fs = list(map(int, input().split()))

As.sort()
As.reverse()
Fs.sort()
arr = []
M = 0
for a, f in zip(As, Fs):
    af = a*f
    arr.append((af, a, f))
    M = af if af > M else M

f = -1
t = M
while f + 1 < t:
    m = f + math.ceil((t-f) / 2)
    k = K
    for AF, A, F in arr:
        d = A - m // F
        d = d if d >= 0 else 0
        if d > k:
            f = m
            break
        k -= d
    else:
        t = m

print(t)

Measured memory_bytes: 126816