akhauriyash/Code-Regression huggingface dataset:
object Main{
  def main(args: Array[String]): Unit = {
    var sc = new java.util.Scanner(System.in)
    while(sc.hasNext){
      var a:Int= sc.nextInt
      var b:Int = sc.nextInt
      var n:Int = sc.nextInt
      var sum:Int = 0
      for(i <- 0 until n){
        a *= 10
        sum += (a/b)%10
        a %= b
        
      }
      println(sum)
    }
  }
}

Measured memory_bytes: 45184
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template<class T, class U> bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }

void solve(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll& i : a) cin >> i;
    string s;
    cin >> s;
    set<ll, greater<ll>> base;
    for(ll i = n; i--; ){
        if(s[i] == '0'){
            for(ll b : base) chmin(a[i], a[i] ^ b);
            if(a[i]) base.insert(a[i]);
        }
        else{
            for(ll b : base) chmin(a[i], a[i] ^ b);
            if(a[i]){
                cout << 1 << endl;
                return;
            }
        }
    }
    cout << 0 << endl;
}
int main(){
    ll t;
    cin >> t;
    while(t--) solve();
}

Measured memory_bytes: 3580
#include <iostream>

int main()
{
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	int count = 1;
	for (int i = 0; i < n-1; i++)
	{
		if (s[i] != s[i + 1]) { count += 1; }
	}
	std::cout << count;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    int a[35]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<a[n-1]<<endl;
    return 0;

}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n, m;
    cin >> n >> m;
    vector<ll> arr(n + 1);
    vector<ll> pen(n + 1);
    ll ac = 0;
    ll pe = 0;
    FOR(i, m)
    {
        ll p; string s;
        cin >> p >> s;
        if (s == "AC") arr[p] = 1;
        else if (arr[p] == 0) pen[p]++;
    }
    FOR(i, n + 1) if (arr[i]) {ac++; pe += pen[i]; }
    cout << ac << " " << pe << '\n';
}



Measured memory_bytes: 1792
use std::io;
use std::str::FromStr;
use std::collections::HashMap;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}


fn main() {
    let n: usize = input();
    let mut sum = 0;
    let mut nums = vec![1; n+1];
    for i in 2..(n+1) {
        let mut j = 1;
        while i * j <= n {
            nums[i * j] += 1;
            j += 1;
        }
    }
    // println!("{:?}", nums);
    for i in 1..(n+1) {
        sum += i * nums[i];
    }
    println!("{}", sum);
}


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

int modpow(int base,int n,int mod){
	int res=1;
	while(n){
		if(n&1)res=1L*res*base%mod;
		base=1L*base*base%mod;
		n>>=1;
	}
	return res;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int bcnt=0;
	vector<bool>x(n);
	for(int i=0;i<n;++i){
		char X; cin>>X;
		x.at(i)=(X-'0');
		bcnt+=x.at(i);
	}
	reverse(x.begin(),x.end());
	int set=0,mask=0;
	for(int i=0;i<n;++i){
		if(x.at(i)){
			set=(set+modpow(2,i,bcnt+1))%(bcnt+1);
			if(bcnt-1>0)mask=(mask+modpow(2,i,bcnt-1))%(bcnt-1);
		}
	}
	for(int i=n-1;i>=0;--i){
		int ans=0,bitc=bcnt,tmask=0;
		if(x.at(i)){
			--bitc;
			if(bitc>0)tmask=mask-modpow(2,i,bitc)+bitc;
		}
		else{
			++bitc;
			tmask=set+modpow(2,i,bitc);
		}
		if(bitc>0){
			tmask%=bitc;
			++ans;
		}
		while(tmask){
			bitc=0;
			for(int j=1;j<=tmask;j<<=1){
				if(j&tmask)++bitc;
			}
			tmask%=bitc;
			++ans;
		}
		cout<<ans<<"\n"s; 
	}
}


Measured memory_bytes: 3672
def resolve():
	n, m, x = map(int, input().split())
	books = [list(map(int, input().split())) for _ in range(n)]

	pay = float('inf')
	for i in range(1 << n):
		selected = []
		for j in range(n):
			if i >> j & 1:
				selected.append(j)
		rem = [0] * m
		tmp_pay = 0
		for j in selected:
			tmp_pay += books[j][0]
			for k in range(1, m+1):
				rem[k-1] += books[j][k]
		done = True
		for j in range(m):
			if rem[j] < x:
				done = False
		if done:
			pay = min(pay, tmp_pay)
	if pay == float('inf'):
		print(-1)
	else:
		print(pay)
resolve()

Measured memory_bytes: 68564
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
L,R = map(int,input().split())

ans = 2019
for i in range(L,R+1):
    if ans==0:
        break
    for j in range(i+1,R+1):
        ans = min(ans, (i*j)%2019)
        if ans==0:
            break

print(ans)

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a + b > c + d) {
    cout << "Left" << endl;
  } else if (a + b == c + d) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }

  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];
    
    int ans = b.back();
    rep(i,n-1){
        ans += b[i];
        if(a[i+1]-a[i] == 1) ans += c[a[i]-1];
    }
    
    cout << ans << endl;
}

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

int main() {
  LL N, K;
  cin >> N >> K;
  LL H[N];
  priority_queue<int> que;
  
  for (LL i = 0; i < N; i++) {
    cin >> H[i];
    que.push(H[i]);
  }
  
  LL ans = 0;
  if (N > K) {
    for (LL i = 0; i < K; i++) {
      que.pop();
    }
    while (!que.empty()) {
      ans = ans + que.top();
      que.pop();
    }
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 2676
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    int[][] d = new int[10][10];

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int e=K/2;
        int d;
        if(K%2==1){
            d=e+1;
        }else{
            d=e;
        }
        System.out.println(d*e);
    }
}

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

signed main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> matrix(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> matrix[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << h); i++)
    {
        for (int j = 0; j < (1 << w); j++)
        {
            int cnt = 0;
            for (int a = 0; a < h; a++)
            {
                for (int b = 0; b < w; b++)
                {
                    if (((i >> a) & 1) and ((j >> b) & 1))
                    {
                        if (matrix[a][b] == '#')
                            cnt++;
                    }
                }
            }
            ans += cnt == k;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h> // Include every standard library 
using namespace std; 


void fst() {
    ios::sync_with_stdio(0);
    cin.tie(0);    
    #ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    #endif 
}
  
typedef long long LL; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
  
#define fi first 
#define se second 
#define mp make_pair 
#define pb(x) push_back(x)
#define all(v) v.begin(), v.end() 
#define input_arr(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";


main(){
	  int x,y,z;
	  cin>>x>>y>>z;
	  cout<<z<<" "<<x<<" "<<y;
	  





}


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

int main(void){
    int n, c=0; cin>>n;
    int a[n], b[n];
    for(int i=0; i<n; i++) cin>>a[i], b[i]=a[i];
    sort(a, a+n);
    for(int i=0; i<n; i++)  if(a[i]!=b[i]) c++;
    cout<<( c==0 || c==2 ? "YES" : "NO")<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int,int>;
using P = pair<ll,ll>;
const int inf = numeric_limits<int>::max()/3;

int main(void){
  int n;
  cin >> n;
  vector< ll > A(n);
  for(int i = 0;i < n;++i){
    cin >> A[i];
  }
  ll res = 0;
  int l = 0,r = 1;
  ll bit = A[0];
  while(l < n){
    while(r < n && (bit & A[r]) == 0){
      bit |= A[r];
      ++r;
    }
    res += r - l;
    bit ^= A[l];
    ++l;
  }
  cout << res << endl;
  return 0;
}



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

int main(){
 int a,b,c,x;
 cin >> a >> b >> c >> x;
 int ans=0;
 rep(i,a+1){
     rep(j,b+1){
         rep(k,c+1){
             int tmp=i*500+j*100+k*50;
           if(tmp==x){
               ans++;
           }  
         }
     }
 }
 cout << ans << endl;
 return 0;   
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int N = 100100;


int main(){

int t,out=0;cin>>t;
while( t-- ){
    int n , k ,ans=0;
    cin>>n>>k;
    while( 1 ){
        if( n < k ){ ans= 0 ; break;}
        if( n%k==0){ ans=n/k; break;}
        int x = ( n%k + n/k )/( n/k +1 );
        n -= x* (n/k +1);
    }
    out^=ans;
}
if(out)cout<<"Takahashi"<<endl;
else   cout<<"Aoki"<<endl;

return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
   int n;
   ll k;
   cin >> n >> k;
   vector<int> a(n);
   rep(i,n) cin >> a[i];
   rep(i,n) --a[i];
   int now = 0;
   vector<int> before(n,-1);
   vector<int> res;
   int cnt = 0;
   int q = 0;
   while(1){
       if(before[now] >= 0){
           q = cnt;
           break;
       }
       res.push_back(now);
       before[now] = cnt;
       now = a[now];
       cnt ++;
   }
   if(k <= res.size()-1){
       cout << res[k]+1 << endl;
       return 0;
   }

   q -= before[now];
   k -= before[now];
   cout << res[(k%q)+before[now]]+1 << endl;
    return 0;
}

Measured memory_bytes: 5844
s = gets.chomp
K = gets.to_i

h = {}
(?a..?z).each{|c|
  next if !s[c]
  h[c] = 1
  s.scan(/#{c}/){
    (1..K).each{|i|
      h[$&+$'[0,i]] = 1
    }
  }
  break if h.size >= K
}
puts h.keys.min(K)[-1]


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>M;
    if(N*2 >= M){
        cout<<M/2<<endl;
    }else{
        ll rest = M - N*2;
        cout<<N + rest/4<<endl;
    }
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <bitset>

using namespace std;

int n, m;
const int MOD = 998244353;
long long ans = 0;
long long fact[6100000];
long long ufact[6100000];

long long inq(long long a, long long b)
{
    if (b == 0) return 1;
    long long l = inq(a, b / 2);
    if (b % 2) return l * l % MOD * a % MOD;
    return l * l % MOD;
}

long long cnk(long long n, long long k)
{
    return fact[n] * ufact[k] % MOD * ufact[n - k] % MOD;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	fact[0] = 1, ufact[0] = 1;
	cin >> n >> m;
	for (int i = 1; i <= n + 3 * m; i++) fact[i] = fact[i - 1] * i % MOD, ufact[i] = inq(fact[i], MOD - 2);
	ans = cnk(3 * m + n - 1, n - 1);
	ans = (ans + MOD - n) % MOD;
	n--;
	for (int bad_len = 2 * m + 1; bad_len < 3 * m; bad_len++)
    {
        int cnt_pos = 3 * m - bad_len - 1;
        ans = (ans + MOD - cnt_pos * cnk(3 * m - bad_len + 1 + n - 2, n - 2) % MOD) % MOD;
        ans = (ans + MOD - 2 * cnk(3 * m - bad_len + 1 + n - 1, n - 1) % MOD) % MOD;
    }
    for (int b = m + 1; b <= min(3 * m, n + 1); b++)
    {
        int p = 3 * m + b;
        int g = n + 1 - b;
        int len = 3 * m + g;
        int kek = len - n - 1;
        if (kek % 2 == 0)
        {
            kek /= 2;
            ans = (ans + MOD - cnk(kek + n, n) * cnk(n + 1, g) % MOD) % MOD;
        }
    }
    cout << ans;
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	FOR(i,0,n)cin >> a[i];
	sort(ALL(a));
	int ans = 0;
	bool hugou = true;
	FORR(i,n-1,0){
		if(!hugou)a[i] *= -1;
		ans += a[i];
		hugou = !hugou;
	}
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k; cin >> n >> k;
  long long int ans=0;
  if(k==0){cout << ((long long int) n * n) << endl; return 0;}
  for(int a=k+1;a<=n;a++){
    ans += (n/a) * (a - k) + (((n % a)>0) && ((n % a) - k >= 0) ? (n%a) - k + 1 : 0);
   // cout << a << ":" << (n/a) * (a - k) + (((n % a) > 0) && ((n % a) - k >= 0) ? (n%a) - k + 1 : 0) << endl;
  }
  
  cout << ans << endl;
  return 0;
}
  

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int r;
    cin >> r;
    cout << r * r * 3 << endl;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  int x, y;
  y = 0;
  
  for (int i = 0; i < N; i++){
    cin >> x;
    y += min(x, K - x);
  }
  cout << 2 * y << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
long long ans, arr[10];
 
int main() {
	int n; scanf("%d",&n);
	for(int i = 1; i<=n;i++){
		char name[20]; scanf("%s",name);
		if(name[0]=='M') arr[0]++;
		else if(name[0]=='A') arr[1]++;
		else if(name[0]=='R') arr[2]++;
		else if(name[0]=='C') arr[3]++;
		else if(name[0]=='H') arr[4]++;
	}
	
	for(int i=0; i <5; i++){
		for(int j=i+1; j<5;j++){
			for(int k=j+1; k<5; k++){
				ans += arr[i]*arr[j]*arr[k];
			}
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
import java.math.BigDecimal;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        long a = sc.nextLong();
        double b = sc.nextDouble();
        long lb = 0;
        for (int i=0; i<1000; i++) {
            double tmp = (double)i / (double)100;
            if (tmp==b) {
                lb = i;
            }
        }

//        System.out.println(lb);

        System.out.println((a*lb)/(long)100);
    }
}


Measured memory_bytes: 37272
n=int(input())
ans = [0 for _ in range(10001)]
for i in range(1, 101):
  for j in range(1, 101):
    for k in range(1, 101):
      v = i*i + j*j + k*k + i*j + j*k + k*i
      if v < 10001:
        ans[v] += 1

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

Measured memory_bytes: 86448
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>

//#include"gap.h"

using namespace std;

const int int_max = 2147483647;

int N, Q;
int seg[1000000];

int Max_N = 1;

void update(int i, int x){
	i += Max_N-1;
	seg[i] = x;

	while (i>0)
	{
		i = (i-1)/2;
		seg[i] = min(seg[2*i+1], seg[2*i+2]);
	}

}

int find(int s, int t, int k, int l, int r){
	if(r <= s || t <= l) return int_max;

	if(s <= l && r <= t) return seg[k];
	else{
		int vl = find(s, t, 2*k+1, l, (l+r)/2);
		int vr = find(s, t, 2*k+2, (l+r)/2, r);

		return min(vl, vr);
	}
}


int main(){

	cin >> N >> Q;

	while (Max_N <= N){
		Max_N *= 2;
	}


	for(int i=0; i<Max_N*2-1; i++){
		seg[i] = int_max;
	}

	for(int i=0; i<Q; i++){
		int com, x, y;
		cin >> com >> x >> y;

		if(com == 0){
			update(x, y);
		}
		if(com == 1){
			cout << find(x, y+1, 0, 0, Max_N) << endl;
		}

	}


	return 0;
}



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

typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define IMX INT_MAX
#define IMN INT_MIN
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl; 
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int main() 
{
 // OJ; // For Input and Output File
  FIO;

  int N, X, T;
  int minTime = 0;
  cin >> N >> X >> T;
  while(N > 0)
  {
    N = N - X;
    minTime += T;
  }
  cout << minTime; 
return 0;
   
}

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

using namespace std;

int main(){
	
	int a,b;
	int x = 0;
	
	cin >> a >> b;
	vector<vector<int>> vec1;
	vector<int> vec2(b);
	
	vec1 = vector<vector<int>>(a, vector<int>(b,0));
	
	
	for (int i = 0; i < a; i++){

		for(int j = 0; j < b; j++){

			cin >> vec1.at(i).at(j) ;
		}
	}
	for (int j = 0; j<b; j++){
		cin >> vec2.at(j);
	}
		
	for(int i = 0; i<a; i++){
		x = 0;
		for(int j = 0; j<b; j++){
			x =  x + vec1.at(i).at(j) * vec2.at(j);
		   
		}
		cout << x << endl;
		x = 0;
	}
}
	


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

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

Measured memory_bytes: 3660
n=int(input())
arr=list(map(int,input().split()))
mod=pow(10,9)+7
tempa=sum(arr)%mod
tempa=(tempa*tempa)%mod
tempb=0
for i in arr:
	tempb=(tempb+(i*i))%mod
ans=(tempa-tempb)%mod
ans=ans*pow(2,mod-2,mod)
print(ans%mod)

Measured memory_bytes: 31436
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var kx = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int k = kx[0], x = kx[1];
        if (500 * k >= x) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

Measured memory_bytes: 27284
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

const int mod = 1000000009;

struct Mat{
  int v[80][80];
  int h,w;

  Mat():h(0),w(0){}
  Mat(int h, int w):h(h),w(w){}
};

vector<Mat> A2;

Mat operator * (const Mat &a, const Mat &b){
  Mat c(a.h,b.w);
  for(int i = 0; i < a.h; ++i){
    for(int j = 0; j <= i && j <= a.h - i - 1; ++j){
      c.v[i][j] = 0;
      for(int k = 0; k < a.w; ++k){
        c.v[i][j] += (long long)a.v[i][k] * b.v[k][j] % mod;
        c.v[i][j] %= mod;
      }
      c.v[j][i] = c.v[c.h-i-1][c.w-j-1] = c.v[c.w-j-1][c.w-i-1] = c.v[i][j];
    }
  }
  return c;
}


Mat power(const Mat &a, long long e)
{
  Mat x = a;
  Mat ret(a.h,a.w);
  
  for(int i = 0; i < ret.h; ++i) for(int j = 0; j < ret.w; ++j)
      ret.v[i][j] = i == j ? 1 : 0;
  A2[0] = ret;

  int ref = 1;
  while(e){if(e&1)ret=ret*A2[ref];++ref;e>>=1;};
  
  return ret;
}

int solve(int w, long long h, int n, const vector<pair<long long, int> > &st)
{
  long long pre = 0;
  Mat b1(w,1), b2(w,1);
  Mat A(w,w);

  for(int i = 0; i < w; ++i){
    b1.v[i][0] = 0;
    b2.v[i][0] = 0;
  }
  b1.v[0][0] = 1;
  for(int i = 0; i < w; ++i){
    for(int j = 0; j < w; ++j){
      if( abs(i-j) <= 1 ) A.v[i][j] = 1;
      else A.v[i][j] = 0;
    }
  }

  A2.clear();
  A2.push_back(A);
  A2.push_back(A);
  for(int i = 2; i < 65; ++i){
    A2.push_back( A2[i-1] * A2[i-1] );
  }
  
  for(int i = 0; i < n; ++i){
    Mat Ae = power(A, st[i].first - pre);
    for(int j = 0; j < w; ++j){
      for(int k = 0; k < w; ++k){
        b2.v[j][0] += (long long)Ae.v[j][k] * b1.v[k][0] % mod;
        b2.v[j][0] %= mod;
      }
    }

    for(int j = 0; j < w; ++j){
      b1.v[j][0] = j!=st[i].second?b2.v[j][0]:0;
      b2.v[j][0] = 0;
    }

    pre = st[i].first;
  }

  return b1.v[w-1][0];
}

int main()
{
  int W,N;
  long long H;
  int tc = 1;

  while( cin >> W >> H >> N ){
    if( W == 0 && H == 0 && N == 0 ) break;
    
    vector<pair<long long,int> > stones;
    for(int i = 0; i < N; ++i){
      int x;
      long long y;
      cin >> x >> y;
      stones.push_back(make_pair(y-1,x-1));
    }
    stones.push_back(make_pair(H-1,W));
    sort(stones.begin(),stones.end());
    
    int res = solve(W,H,N+1,stones);

    cout << "Case " << tc << ": " << res << endl;
    ++tc;
  }
  return 0;
}

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

int plusminus(int x,int m){
  if(m==0)	return(x);
  else		return(-x);
}

char pmc(int x,int m){
  if(m==0)	return('+');
  else		return('-');
}

int main(void){
  string s;
  cin >> s;
  int vec[4];
  for(int i=0;i<4;i++){
    vec[i]=s[i]-'0';
  }
  bool check=false;
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        if(plusminus(vec[1],i)+plusminus(vec[2],j)+plusminus(vec[3],k)==7-vec[0]){
          check=true;
          cout << vec[0] << pmc(vec[1],i) << vec[1] << pmc(vec[2],j) << vec[2] << pmc(vec[3],k) << vec[3] << "=7" << endl;
          break;
        }
      }
      if(check)	break;
    }
    if(check) break;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll n,t,x,y,sx=0,sy=0,st=0,p,i;
    cin>>n;
    int f=0;
    for (i=0;i<n;i++)
    {
        cin>>t>>x>>y;
        if (t-st<abs(x-sx)+abs(y-sy))
        {
            f=1;
            p=0;
        }
        else
            p=(t-st)-abs(x-sx)-abs(y-sy);
        if (p&1)
            f=1;
        st=t;
        sx=x;
        sy=y;
    }
    if (f)
        cout<<"No\n";
    else
        cout<<"Yes\n";
}

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

const int N = 1e5 + 50;

int x, y, z, n;
long long ans, tot, sum, l[N], r[N];
struct coin {
  int a, b, c;
  bool operator < (coin const &A) const {
    return a - b > A.a - A.b;
  }
} a[N];
priority_queue<long long> g;

int main() {
  scanf("%d%d%d", &x, &y, &z);
  n = x + y + z;
  for(int i = 1; i <= n; ++i) 
    scanf("%d%d%d", &a[i].a, &a[i].b, &a[i].c);
  sort(a + 1, a + 1 + n);
  // for(int i = 1; i <= n; ++i)
  //   cout << a[i].a << ' ' << a[i].b << ' ' << a[i].c << '\n';
  for(int i = 1; i <= n; ++i) tot += a[i].c;
  for(int i = 1; i <= x; ++i)
    g.push(a[i].c - a[i].a), sum += a[i].c - a[i].a;
  for(int i = x; i <= n - y; ++i) {
    if(i != x && g.top() > a[i].c - a[i].a) {
      sum -= g.top(), g.pop();
      sum += a[i].c - a[i].a, g.push(a[i].c - a[i].a);
    }
    l[i] = sum;
  }
  sum = 0;
  while(g.size()) g.pop();
  for(int i = n; i >= n - y + 1; --i)
    g.push(a[i].c - a[i].b), sum += a[i].c - a[i].b;
  for(int i = n - y + 1; i >= x; --i) {
    if(i != n - y + 1 && g.top() > a[i].c - a[i].b) {
      sum -= g.top(), g.pop();
      sum += a[i].c - a[i].b, g.push(a[i].c - a[i].b);
    }
    r[i] = sum;
  }
  for(int i = x; i <= n - y; ++i)
    ans = max(ans, tot - l[i] - r[i + 1]);
  printf("%lld\n", ans);
  return 0;
} 


Measured memory_bytes: 2808
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np


def main():
    N, M, K = map(int, input().split())
    A = np.cumsum([0] + list(map(int, input().split())))
    B = np.cumsum([0] + list(map(int, input().split())))

    ans = 0
    j = M
    for i in range(N + 1):
        if A[i] > K:
            break
        while A[i] + B[j] > K:
            j -= 1
        ans = max(ans, i + j)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 52968
#include <algorithm>
#include <cstdio>
#include <queue>
const int N=100005;
long long f[N],g[N];
struct info{int x,y,z;}a[N];
bool cmp(info a,info b){return a.x-a.y>b.x-b.y;}
std::priority_queue<int,std::vector<int>,std::greater<int> > q;
int main(){
	int n,X,Y,Z;
	scanf("%d%d%d\n",&X,&Y,&Z);
	n=X+Y+Z;
	for (int i=1;i<=n;i++)
		scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
	std::sort(a+1,a+n+1,cmp);
	for (int i=1;i<=X+Z;i++){
		q.push(a[i].x-a[i].z);
		f[i]=f[i-1]+a[i].x-a[i].z;
		if (i>X) f[i]-=q.top(),q.pop();
	}
	for (;!q.empty();q.pop());
	for (int i=n;i>X;i--){
		q.push(a[i].y-a[i].z);
		g[i]=g[i+1]+a[i].y-a[i].z;
		if (i<=n-Y) g[i]-=q.top(),q.pop();
	}
	long long ans=f[X]+g[X+1];
	for (int i=X+1;i<=n-Y;i++) ans=std::max(ans,f[i]+g[i+1]);
	for (int i=1;i<=n;i++) ans+=a[i].z;
	printf("%lld\n",ans);
}

Measured memory_bytes: 2944
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

const MOD: i64 = 1_000_000_007;

fn main() {
    let n = scan!(i64);
    let mut ans = 1;
    for i in 1..n + 1 {
        ans *= i;
        ans %= MOD;
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int c[3][3];
  REP(i,3){
    REP(j,3){
      cin>>c[i][j];
    }
  }
  
  int a[3],b[3];
  a[0] = 0;
  REP(i,3){
    b[i] = c[0][i] - a[0];
  }
  for(int i=1;i<=2;i++){
    a[i] = c[i][0] - b[0];
  }
  
  bool flag = true;
  REP(i,3){
    REP(j,3){
      if(c[i][j]==a[i]+b[j]){
        continue;
      }else{
        flag = false;
        break;
      }
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),ans = 0;
        int[][] list = new int[a][2];
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < 2; j++) {
                list[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < a; i++) {
            ans += list[i][1]-list[i][0]+1;
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 24656
n = gets.to_i
cs = gets.chomp.chars
cs2 = cs.dup.sort

a = 0
b = 0
n.times do |i|
  next if cs[i] == cs2[i]

  if cs[i] == 'W'
    a += 1
  elsif cs[i] == 'R'
    b += 1
  end
end

puts [a, b].max

Measured memory_bytes: 31968
N = int(input())
P = list(map(int, input().split()))
Q = list(range(1, N+1))
ans = 0
for i in range(N):
    if P[i] != Q[i]:
        ans += 1

if ans == 2 or ans == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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; }

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;cin>>N;
    vector<int>V(N+2,0);
    for(int i=1;i<N+1;i++) cin>>V[i];
    V[N+1]=0;
    int S=0;
    REP(i,V.size()-1) S+=abs(V[i]-V[i+1]);
    for(int i=1;i<V.size()-1;i++){
        cout<<S-abs(V[i-1]-V[i])-abs(V[i+1]-V[i])+abs(V[i+1]-V[i-1])<<endl;
    }
}


Measured memory_bytes: 1664
n, m = map(int, input().split())
a = list(map(lambda x: -int(x), input().split()))
import heapq
import math
value = -sum(a)
heapq.heapify(a)

for i in range(m):
  use = heapq.heappop(a)
  value += math.floor(use/2)
  heapq.heappush(a, math.ceil(use/2))
  
print(value)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  
  int l = a + b;
  int r = c + d;
  
  if (l > r) {
    cout << "Left" << endl;
  } else if (l < r) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3600
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,M = inputlist()
graph = [[] for _ in range(N+1)]
for i in range(M):
    A,B = inputlist()
    graph[A].append(B)
    graph[B].append(A)
ans = [0]*(N+1)
seen = [False]*(N+1)

from collections import deque
que = deque()
que.append(1)
while len(que) != 0:
    k = que.popleft()
    seen[k] = True
    for i in graph[k]:
        if seen[i]:
            continue
        ans[i] = k
        que.append(i)
        seen[i] = True
ansa = ans[2:]
n = len(ansa)
say = "Yes"
for i in range(n):
    if ansa[i] == 0:
        print("No")
        exit()
print(say)
for i in range(n):
    print(ansa[i])

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

// https://ei1333.github.io/algorithm/union-find.html
struct UnionFind
{
    std::vector< int > data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if (x == y) return(false);
        if (data[x] > data[y]) std::swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }

    int find(int k)
    {
        if (data[k] < 0) return(k);
        return(data[k] = find(data[k]));
    }

    int size(int k)
    {
        return(-data[find(k)]);
    }
};

int main()
{
    int n, m;
    std::cin >> n >> m;

    UnionFind uf(n);
    for (auto i = 0; i < m; ++i)
    {
        int s, d;
        std::cin >> s >> d;
        uf.unite(s - 1, d - 1);
    }

    int max = 1;
    for (auto i = 0; i < n; ++i)
    {
        const auto v = uf.size(i);
        if (max < v)
        {
            max = v;
        }
    }

    std::cout << max;
    return 0;
}

Measured memory_bytes: 4052
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] a_str = in.readLine().split(" ");
    int[] a = new int[3];
    a[0] = Integer.parseInt(a_str[0]);
    a[1] = Integer.parseInt(a_str[1]);
    a[2] = Integer.parseInt(a_str[2]);
    int min = Math.min(Math.min(a[0],a[1]),a[2]);
    int sum = a[0] + a[1] + a[2];
    int max = Math.max(Math.max(a[0],a[1]),a[2]);
    System.out.println(max-(sum-min-max) + (sum-min-max)-min);
  }
}

Measured memory_bytes: 21076
fun main(args: Array<String>) {
    val (n, m, x, y) = readLine()!!.split(' ').map { it.toInt() }
    val xs = readLine()!!.split(' ').map { it.toInt() }.plus(x)
    val ys = readLine()!!.split(' ').map { it.toInt() }.plus(y)
    println(if (xs.max()!! < ys.min()!!) "No War" else "War")
}


Measured memory_bytes: 38316
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    N -= 1
    ans = ""
    while N >= 0:
        ans = chr(ord('a') + N % 26) + ans
        N = N // 26
        N -= 1

    print(ans)




if __name__ == '__main__':
    main()



Measured memory_bytes: 9072
import bisect

N=int(input())
a=list(map(int,input().split()))
b=sorted(a)
M=b[N-1]
i=bisect.bisect_left(b,M/2)

if i==0: print(M,b[0])
elif abs(M/2-b[i-1])<=abs(M/2-b[i]): print(M,b[i-1])
else: print(M,b[i])

Measured memory_bytes: 14428
////=====BIsmillahir Rahmanir Rahim =====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
         Comilla University

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define fi 2*acos(0.0)
#define ee 2.71828
#define ll  long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl printf("\n")
#define infinity 1e16
#define mod 1000000007
#define cn continue
#define csprint1 printf("Case %lld: ", cs++)
#define csprint2 printf("Case %lld:\n", cs++)
#define sf(a) scanf("%lld", &a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define all(v) v.begin(),v.end()
#define pfn(a) printf("%lld\n",a)
#define pfs(a) printf("%lld ",a)

using namespace __gnu_pbds;
using namespace std;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<pl> vpi;
typedef vector<pl> vpl;
typedef tree<pair<ll, int> , null_type, less<pair<ll, int> >, rb_tree_tag, tree_order_statistics_node_update> ost;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(int mask,int bit){return mask & (1<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

/*----------------------Graph Moves----------------*/
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

///=====================================///
const long long maX=1e5+5;
vector<ll>ara[maX];
ll dp[maX],vis[maX];
ll dfs(ll x){
    if(vis[x])return dp[x];
    ll ans=0;
    for(ll i=0;i<ara[x].size();i++){
        ans=max(ans,dfs(ara[x][i])+1);
    }
    vis[x]=1;
    dp[x]=ans;
    return dp[x];
}
int main(){
    ll n,m;
    sff(n,m);
    ll cc=0;
    for(ll i=1;i<=m;i++){
        ll x,y;sff(x,y);
        ara[x].pb(y);
    }
    ll mx=0;
    for(ll i=1;i<=n;i++){
        dfs(i);
        mx=max(mx,dp[i]);
    }
    pfn(mx);
return 0;
}


Measured memory_bytes: 12872
# coding: utf-8
# Your code here!
def saiki(num,lis):
    if num==H:
        cand.append(lis)
    else:
        saiki(num+1,lis+[lis[-1]])
        saiki(num+1,lis+[num])
#全探索
H,W,K=map(int,input().split())

S=[]
for h in range(H):
    s=list(input())
    S.append(list(map(int,s)))
        
cand=[]

saiki(1,[0])

ans=[]
for item in cand:
    temp=len(list(set(item)))-1
    wa=[[0]*W for i in range(H)]
    for i in range(H):
        for j in range(W):
            wa[item[i]][j]+=S[i][j]
    #クラスタを作っていきたい
    sam=[0]*H
    count=0
    for w in range(W):
        judge=False
        for h in range(H):
            if wa[h][w]>K:
                judge=True
            sam[h]+=wa[h][w]
            if w!=W-1:
                if sam[h]+wa[h][w+1]>K:
                    count+=1
                    for i in range(H):
                        
                        sam[i]=0
                    break
        if judge:
            count=10**9
            break
    """
    print("------------------")
    print(item)
    print(sam)
    """
    ans.append(temp+count)
    #print(wa)
print(min(ans))
#print(cand)
#print(S)

Measured memory_bytes: 47964
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

#define maru 0
#define batu 1


int dfs(string &data,int player,int left,int right){
    if(left==right)return data[left]-'0';
    
    bool dfsed=false;
    if(data[left]!='0'+player){
        dfsed=true;
        if( dfs(data,!player,left+1,right)==player )return player;
    }
    if(data[right]!='0'+player){
        dfsed=true;
        if( dfs(data,!player,left,right-1)==player )return player;
    }
    if(!dfsed)if( dfs(data,!player,left,right)==player )return player;
    return !player;
}



int main(){
    string s;
    cin>>s;
    string data="";
    rep(i,s.size()) if(i==0||s[i-1]!=s[i])if(s[i]=='o')data+='0';else data+='1';
    

    bool res = dfs(data,maru,0,data.size()-1);

    if(res==maru)cout<<'o'<<endl;
    else cout<<'x'<<endl;
}

Measured memory_bytes: 3180
/*#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ss string
#define ull unsigned ll
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define For(i,j,k) for(int i = (int) j; i <= (int) k; i++)
#define Rep(i,j,k) for(int i = (int) j; i >= (int) k; i--)
const int N = 5e5;const int sult = 0;
ll a,b,c,d;
void solve()
{
    ll ans = -1e18;
    cin >> a >> b >> c >> d;
    ans = max(ans,b * d);
    ans = max(ans,a * d);
    ans = max(ans,b * c);
    ans = max(ans,a * c);
    cout << ans << '\n';
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int T = 1;
    if(sult)cin >> T;
    for(;T;T--)solve();
}


Measured memory_bytes: 3664
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  ll x;
  cin >> x;
  int count = 0;
  ll money = 100;
  while (true) {
    count++;
    money += money / 100;
    if (money >= x) {
      cout << count << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, from, to) for (int i = from; i < to; i++)

int N;
int factor[101];
int func(int x)
{
  int res = 0;
  rep(i, 2, N + 1) if (factor[i] >= x) res++;
  return res;
}

int main()
{
  cin >> N;
  memset(factor, 0, sizeof(factor));
  rep(j, 2, N + 1)
  {
    int cur = j;
    for (int i = 2; i <= cur; i++)
    {
      while (cur % i == 0)
      {
        cur /= i;
        factor[i]++;
      }
    }
  }
  int ans = func(74) + func(24) * (func(2) - 1) + func(14) * (func(4) - 1) + func(4) * (func(4) - 1) * (func(2) - 2) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> s)
    {
        if(s == ".") break;
        string t = "";
        int cnt = 0;
        for(int i = 0; i < s.size(); i++)
        {
            if(s[i] == '+') cnt++;
            else if(s[i] == '-') cnt--;
            else if(s[i] == ']')
            {
                string tmp = "";
                while(t.size())
                {
                    char ch = t.back(); t.pop_back();
                    if(ch == '[') break;
                    tmp += ch;
                }
                t += tmp;
            }
            else if(s[i] == '[') t += s[i];
            else if(s[i] == '?')
            {
                t += 'A';
                cnt = 0;
            }
            else
            {
                char ch = s[i] + cnt % 26;
                if(ch > 'Z') ch = (ch - 'Z') % 26 + 'A' - 1;
                else if(ch < 'A') ch = 'Z' - ('A' - ch) % 26 + 1;
                t += ch;
                cnt = 0;
            }
        }
        cout << t << endl;
    }
    return 0;
}




Measured memory_bytes: 3128