akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int sd10(ll n){
    int sum = 0;
    while(n){
        sum ++;
        n /= 10;
    }
    return sum;
}

int main(void){
    Cin(ll, n);
    int ans = 100;
    for(int i = 1; i <= sqrt(n); i ++){
        if(n % i != 0) continue;
        ans = min(ans, max(sd10(i), sd10(n/i)));
    }
    Cout(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  int mn=INT_MAX;
  for(int i=0;i<n;i++)
  {
    cin>>v[i];
    if(v[i]<mn)
        mn=v[i];
  }
  vector<bool> v1(k+1);
  for(int i=0;i<=k;i++)
  {
    v1[i]=false;
    for(int j=0;j<n;j++)
    {
       if(i>=v[j]&&!v1[i-v[j]])
       {
         v1[i]=true;
         break;
       }
    }
  }
  if(v1[k])
    cout<<"First"<<endl;
  else
    cout<<"Second"<<endl;
  return 0;
}


Measured memory_bytes: 3576
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int x, t;
    cin >> x >> t;
    cout << max(0, x - t) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#define INF 1<<30
using namespace std;
int main() {
	cin.tie(0);ios::sync_with_stdio(false);
	int V, E, r; cin >> V >> E >> r;
	vector<vector<pair<int,int>>> g(V);
	vector<int> dp(V);
	queue<int> q;

	//input
	int s, t, d;
	for (int i = 0; i < E; i++) {
		cin >> s >> t >> d;
		g[s].push_back(make_pair(t, d));
	}

	//initialize
	fill(dp.begin(), dp.end(), INF);
	dp[r] = 0;
	q.push(r);

	//Dijkstra
	while (!q.empty()) {
		int k = q.front(); q.pop();
		for (int i = 0; i < g[k].size();i++) {
			int next = g[k][i].first;
			int w = g[k][i].second;
			if (dp[k] + w < dp[next]) {
				dp[next] = dp[k] + w;
				q.push(next);
			}
		}
	}

	//output
	for (int i = 0; i < V;i++) {
		if (dp[i] == INF) { cout << "INF" << endl; }
		else { cout << dp[i] << endl; }
	}
}

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
struct UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main() {
    int n, m, x, y, tmp;
    cin >> n >> m;
    vector<int> p(n);
    rep(i, n) {
        cin >> tmp;
        p[i] = tmp - 1;
    }
    
    UnionFind uf(n);
    
    rep(i, m) {
        cin >> x >> y;
        uf.unite(x - 1, y - 1);
    }
    
    int count = 0;
    rep(i, n) {
        if(uf.same(i, p[i])) count++;
    }
    cout << count << endl;
    
    return 0;
}


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

using namespace std;

int main()
{
	int n;
	int square_x[256];
	int square_y[256];

	while (true){
		scanf("%d", &n);

		if (n == 0){
			break;
		}

		for (int i = 0; i < 256; i++){
			square_x[i] = square_y[i] = 0;
		}
		square_x[0] = square_y[0] = 1;

		int nico, chino;
		for (int i = 1; i < n; i++){
			scanf("%d %d", &nico, &chino);

			switch (chino){
				case 0:
					square_x[i] = square_x[nico] - 1;
					square_y[i] = square_y[nico];
					break;
				case 1:
					square_x[i] = square_x[nico];
					square_y[i] = square_y[nico] - 1;
					break;
				case 2:
					square_x[i] = square_x[nico] + 1;
					square_y[i] = square_y[nico];
					break;
				case 3:
					square_x[i] = square_x[nico];
					square_y[i] = square_y[nico] + 1;
					break;
			}
		}

		for (int i = 0; i < n - 1; i++){
			for (int j = i + 1; j < n; j++){
				if (square_x[i] > square_x[j]){
					square_x[i] ^= square_x[j];
					square_x[j] ^= square_x[i];
					square_x[i] ^= square_x[j];
				}
				if (square_y[i] > square_y[j]){
					square_y[i] ^= square_y[j];
					square_y[j] ^= square_y[i];
					square_y[i] ^= square_y[j];
				}
			}
		}

		printf("%d %d\n", square_x[n - 1] - square_x[0] + 1, square_y[n - 1] - square_y[0] + 1);
	}

	return (0);
}

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

int main(int argc, char const *argv[])
{
  while(1)
  {
    int a, b;
    char op;
    cin >> a >> op >> b;
    if(op == '?') break;

    if(op == '+' || op == '-')
      cout << (op == '+' ? a+b : a-b) << endl;
    else
      cout << (op == '*' ? a*b : a/b) << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int n;
	cin >> n;
	vector<int>d(n);
	rep(i, n) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	cout<<d[n / 2 ] - d[n / 2-1];
	return 0;
}

Measured memory_bytes: 3768
#include <iostream>

int main() {
  long a,b;

  while(std::cin >> a >> b) {
    long gcd = 1;
    long lcm = 1;

    long min;
    long cnt = 2;

    do {
      while((a % cnt == 0) && a % cnt == b % cnt) {
        a /= cnt;
        b /= cnt;
        gcd *= cnt;
      }
      min = (a < b) ? a : b;
      ++cnt;
    }while(min > cnt);

    lcm = gcd * a * b;
    std::cout << gcd << " " << lcm <<std::endl;
  }

}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define rALL(x) x.rbegin(),x.rend()

using namespace std;
using ll=long long;


int main(){
  int k,s;cin>>k>>s;
  int ans=0;
  rep(x,min((k+1),s+1)){
    int rem=s-x;
    rep(y,min(k+1,rem+1)){
      int rem2=rem-y;
      if(rem2>=0&&rem2<k+1)ans++;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3520
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
    string s;
    cin >> s;
    REP(i,s.size()){
        cout << 'x';
    }
    cout << endl;



    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N, K = map(int, input().split())
A = list(map(int ,input().split()))

d = defaultdict(int)
for i in A:
    d[i] += 1

d_ = sorted(d.items(), key=lambda x:x[1], reverse=True)
n =len(d_)
ans = 0
if n <= K:
    print(0)
    exit()
else:
    for i in range(K,n):
        ans += d_[i][1]
print(ans)

Measured memory_bytes: 44316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n, k;
  cin >> n >> k;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  ll res = 0;
  rep(i, k) res += v.at(i);
  cout << res << endl;
}

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

int main(){
    int a;
    cin >> a;
    int x = a;
    int cnt = 0;
    while(x >= 100){
        x -= 100;
        cnt++;
    }
    while(x > 0){
        if(x >= 5)x -= 5;
        else if(x >= 4)x -= 4;
        else if(x >= 3)x -= 3;
        else if(x >= 2)x -= 2;
        else if(x >= 1)x -= 1;
        cnt--;
        if(cnt == -1)break;
    }
    if(cnt != -1)cout << "1" << endl;
    else cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(ll i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<ll>cnt(3,0);
    vector<vector<ll>>pl(3);
    rep(i,n){
        if(s[i]=='R'){
            cnt[0]++;
            pl[0].push_back(i);
        }
        if(s[i]=='G'){
            cnt[1]++;
            pl[1].push_back(i);
        }
        if(s[i]=='B'){
            cnt[2]++;
            pl[2].push_back(i);
        }
    }
    ll ans=cnt[0]*cnt[1]*cnt[2];
    if(ans==0){
        cout<<ans<<endl;
        return 0;
    }
    for(ll a:pl[0])for(ll b:pl[1]){
        ll aa=a;
        ll bb=b;
        if(aa>bb)swap(aa,bb);
        
        
        if(2*aa-bb>=0&&s[2*aa-bb]=='B')ans--;
        if(2*bb-aa<n&&s[2*bb-aa]=='B')ans--;
        if((aa+bb)%2==0&&s[(aa+bb)/2]=='B')ans--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
int main() {
 	string s;
  cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
   cout << "Bad" << endl; 
  } else {
   cout << "Good" << endl; 
  }
}

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

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    int cnt=0;
    for(int i=1;i<n;i++){
        if(h[i]<h[i-1]){
            swap(h[i],h[i-1]);
            cnt++;
        }
    }
    cout << n-cnt << endl;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n ;
  vector<int> v(n);
  
  rep(i,n)
    cin >> v.at(i) ;
  
  sort(all(v));
  
  cout << v.at(n-1) - v.at(0);


}


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

int N=0, P=0;
// レストラン名
string S;
// ソートの順番通りにpairの配列を生成
// <<レストラン名, 点数>, 番号>
pair<pair<string, int>, int> R[150];

int main(){
  cin >> N;
  rep(n, N){
    cin >> S >> P;
    // 配列に格納
    R[n] = make_pair(make_pair(S, -P), n);
  }
  // 配列のそーとはbegin, endを使えないので注意
  sort(R, R+N);
  rep(i, N){
    // 0インデックスを1インデックスに変換
    cout << R[i].second + 1 << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
num = 0
mi = 10**9
for i in range(n):
    num += abs(a[i])
    if abs(mi) >= abs(a[i]):
        mi = a[i]
cnt = 0
for i in range(n):
    if a[i] < 0:
        cnt += 1
if cnt%2 == 1:
    print(num-2*abs(mi))
else:
    print(num)

Measured memory_bytes: 20064
s, t = [elem for elem in input().split()]
a, b = [int(elem) for elem in input().split()]
u = input()

dic = {}
dic[s] = a
dic[t] = b
if u == s:
  dic[s] -= 1
else:
  dic[t] -= 1
print(dic[s], dic[t])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<int,ll> P;
typedef pair<P,P> P2;
const ll INF=100000000000000001;
int main() {
	ll k;
	ll a[100001]={};
	cin>>k;
	for(int i=0;i<k;++i)cin>>a[i];
	ll t1=2;
	ll t2=2;
	bool flg=true;
	for(int i=k-1;i>=0;--i){
		if(t1<a[i]){
			t1=a[i];
		}else if(t1%a[i]!=0){
			t1=a[i]*(t1/a[i]+1);
		}
		if(t2<a[i]){
			t2=a[i];
		}else if(t2%a[i]!=0){
			t2=a[i]*(t2/a[i]);
		}
		t2+=a[i]-1;

	}

	ll t3=t1;
	for(int i=0;i<k;++i){
		t3=(t3/a[i])*a[i];
	}
	if(t3!=2)flg=false;
	if(flg){
		cout<<t1<<" "<<t2<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


set<int> divisors(int x)
{
    set<int> s;
    for(int i = 1; i*i <= x; ++i)
        if(x % i == 0)
            s.insert(i), s.insert(x/i);
    return s;
}

int freq[1000005];

int32_t main()
{


    IOS


    int n;
    cin >> n;

   	map<int,int> mp;


    vector<int> v(n);

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



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

    int ans = 0;


    for(int i = 0; i < n; i++)
    {	
    	freq[v[i]]++;
    	if(mp[v[i]] > 1)continue;

    	set<int> div = divisors(v[i]);
    	bool ok = true;

    	for(auto j : div)
    	{
    		if(j == v[i])break;
    		if(freq[j] > 0)
    		{
    			ok = false;
    			break;
    		}
    		//trace1(j);
    	}
    	if(ok)ans++;
    	


    }


    cout << ans;




    return 0;
}


Measured memory_bytes: 24008
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <utility>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    int D; cin >> D;
    int ans = 0;
    while(N>0){
        ans++;
        N -= (2*D+1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, a, b = gets.chomp.split().map(&:to_i)

if (b - a).even?
  puts (b-a)/2
else
  ans1 = b-1
  ans2 = n-a
  ans3 = (a-1) + 1+ ((b-(a-1)-1)-1)/2
  ans4 = (n-b) + 1+ (n-(a+(n-b)+1))/2

  #p [ans1, ans2, ans3, ans4]
  puts [ans1, ans2, ans3, ans4].min
end

Measured memory_bytes: 1788
#coding:utf-8
def main():
    L,R = list(map(int,input().split()))
    if R - L >= 2019:
        print(0)
        return
    else:
        min_r = 2019
        for i in range(L,R):
            for j in range(i+1,R+1):
                min_r = min(min_r,(i*j)%2019)
        print(min_r)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38896
#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>;


int main (){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll asset = 1000;
  
  rep(i, n-1){
    if(a[i] < a[i+1]){
      ll add = asset / a[i];
      asset += add * (a[i+1] - a[i]);
    }
  }
  
  cout << asset << endl; 
  
  return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main()
{
    /*
    [in]    input_a   長方形の縦の長さ
    [in]    input_b   長方形の横の長さ
    [out]   l   長方形の周の長さ
    [out]   S   長方形の面積
    */
    int input_a, input_b, l, S;

    /* 入力 */
    scanf("%d %d", &input_a, &input_b);

    l = 2 * (input_a + input_b);
    S = input_a * input_b;
    
    printf("%d %d\n", S, l);
}


Measured memory_bytes: 2064
# include "bits/stdc++.h"

using namespace std;

#define endl "\n"
typedef long long int ll;
#define f first
#define s second

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;

ll INF = 1e10;
int MOD = 1e9+7;

int main(){
    #ifndef ONLINE_JUDGE
        freopen("debug.txt", "w", stderr);
    #endif
    fastio();
    int n;
   	cin>>n;
   	string s;
   	cin>>s;
   	int fr = 0;
   	vector<char> req;
   	for(int i=0;i<n;++i) fr += s[i]=='R';
   	for(int i=0;i<n;++i) if(i < fr) req.push_back('R'); else req.push_back('W');

   	int p = 0;
   	int cnt1 = 0, cnt2 = 0;
   	while(p < n){
   		if(req[p] == s[p]){
   			++p;
   		}
   		else{
   			if(req[p] == 'W')
   				++cnt1;
   			else
   				++cnt2;
   			++p;
   		}
   	}
   	cout<<max(cnt1, cnt2);
    return 0;
}


Measured memory_bytes: 3876
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, std::vector<long long> H){
  for (int i = N-2; i >= 0; i--) {
    if (H[i] > H[i+1]) {
      H[i]--;
    }
    if (H[i] > H[i+1]) {
      std::cout << "No" << std::endl;
      return;
    }
  }
  std::cout << "Yes" << std::endl;
  return;
}

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


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

#define fr first
#define sc second

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int NMAX = 5e4 + 1, INF = 1e9 + 19, MOD = 1e9;
ll LINF = 1e18;
const double EPS = 1e-8;

main() {
//    freopen("input.txt", "r", stdin);
    ll q, h, s, d;
    scanf("%lld%lld%lld%lld", &q, &h, &s, &d);
    ll n;
    scanf("%lld", &n);
    h = min(q * 2, h);
    s = min(min(q * 4, h * 2), s);
    d = min(min(q * 8, h * 4), min(s * 2, d));
    ll ans = 0;
    ans += (n / 2) * d;
    n %= 2;
    ans += n * s;
    printf("%lld", ans);
}


Measured memory_bytes: 256
<?php
  
$input = [];
while ($line = fgets(STDIN)) {
   $input[] = trim($line);
}

$S = $input[0];
$T = $input[1];

$preg = '/^' . $S . '[a-z]{1}$/';
$ret = preg_match($preg, $T);

if($ret === 1){
  echo 'Yes';
}else if($ret === 0){
  echo 'No';
}

Measured memory_bytes: 16452
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	if(a==f&&b==e&&c==d)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
} 

Measured memory_bytes: 256
from operator import mul
from functools import reduce

def main():

    def cmb(n,r):
        r = min(n-r,r)
        if r == 0: return 1
        over = reduce(mul, range(n, n - r, -1))
        under = reduce(mul, range(1,r + 1))
        return over // under

    n, k = map(int, input().split())
    mod = 10**9+7

    # 青をi個に分割する組みわせ
    # i個に分割するにはi-1個区切りが必要
    # 区切りを入れられる場所はk-1
    # k-1Ci-1 
    for i in range(1, k+1):
        #cmb(k-1, i-1))
    # 赤の分割
    # 分け方として0を許すように考えて
    # n-k個 + 端2つをi+1に分割する（n-k+1の選べる場所からi個区切りを選ぶ（青がi個だから））
        #cmb(n-k+2, i)
        if n-k+1 >= i:
            print(cmb(k-1, i-1) * cmb(n-k+1, i) % mod)
        else:
            print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3944
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

ans = 0
d = dict()
for i in range(n):
    if t[i] == "r" and d.get(i) != "r":
        ans += p
        d[i+k] = "r"
    elif t[i] == "s" and d.get(i) != "s":
        ans += r
        d[i+k] = "s"
    elif t[i] == "p" and d.get(i) != "p":
        ans += s
        d[i+k] = "p"

print(ans)

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

void fnInput(vector<int>& rvnCard)
{
  int nCardSiz;
  cin >> nCardSiz;

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

  sort(begin(rvnCard), end(rvnCard), greater<int>() );
}

int fnGameExec(const vector<int>& cnrvnCard)
{
  int nAlicePnt = 0, nBobPnt = 0;

  for (int i = 0; i < cnrvnCard.size(); i++)
  {
    if (i % 2 == 0)
      nAlicePnt += cnrvnCard[i];
    else
      nBobPnt  += cnrvnCard[i];
  }

  return (nAlicePnt - nBobPnt);
}

int main()
{
  vector<int> vnCard;
  fnInput(vnCard);
  cout << fnGameExec(vnCard) << endl;

  return 0;
}


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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,int>>
#define pb push_back
#define mod 1000000007
#define mx 305
using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

double dp[mx][mx][mx];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int c1 = 0, c2 = 0, c3 = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x == 1) c1++;
        else if (x == 2) c2++;
        else c3++;
    }
    for (int k = 0; k < mx; k++) {
        for (int j = 0; k + j < mx; j++) {
            for (int i = 0; i + j + k < mx; i++) {
                if (i == 0 && j == 0 && k == 0) continue;
                if (i) dp[i][j][k] += ((1.0 * i) / (i + j + k)) * dp[i - 1][j][k];
                if (j) dp[i][j][k] += ((1.0 * j) / (i + j + k)) * dp[i + 1][j - 1][k];
                if (k) dp[i][j][k] += ((1.0 * k) / (i + j + k)) * dp[i][j + 1][k - 1];
                dp[i][j][k] += (1.0 * n) / (i + j + k);
            }
        }
    }
    cout << fixed << setprecision(10) << dp[c1][c2][c3];
    return 0;

}


ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

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


Measured memory_bytes: 221440
import bisect


def main(S, T):
    for i in range(len(S)-len(T), -1, -1):
        flag = True
        for j in range(len(T)):
            if not (S[i+j] == '?' or S[i+j] == T[j]):
                flag = False
                break
        if flag:
            for k, c in enumerate(S):
                if i <= k <= i+j:
                    S[k] = T[k-i]
                elif S[k] == '?':
                    S[k] = 'a'
            return ''.join(S)
    return 'UNRESTORABLE'


if __name__ == '__main__':
    S = input()
    T = input()
    print(main(list(S), T))

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll sum[10][10] = {0LL};

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

  ll N;
  cin >> N;

  for(int n = 1; n < 10; n++){
    for(int m = 1; m < 10; m++){

      ll tmp_ans = 0;
      if(n == m && N >= m){
        tmp_ans++;
      }

      ll pow10 = 10;
      while(true){
        ll max_val = 10*((n+1)*(pow10/10)-1)+m;
        ll min_val = n * pow10 + m;
        if(max_val <= N){
          tmp_ans += pow10/10;
        }else{
          tmp_ans += max((N - min_val + 10) / 10, 0LL);
          break;
        }
        pow10 = pow10* 10;
      }
      sum[n][m] = tmp_ans;
    }
  }

  ll ans = 0;

  for(int i = 1; i <= N; i++){

    string s = to_string(i);

    int max_num = s[0] - '0';
    int min_num = s[s.length()-1] - '0';

    // cout << i << " " << max_num << " " << min_num << endl;
    ans += sum[min_num][max_num];   
  }

  cout << ans << endl;

  





  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
s=[]
c=[]
for i in range(m):
  news,newc=map(int,input().split())
  s.append(news)
  c.append(newc)
unchi = -1
if n==1:
  for i in range(10):
    hentai = True
    for u in range(m):
      if i!=c[u]:
        hentai = False
    if hentai and unchi==-1:
      unchi = i
if n==2:
  num = [1,0]
  for q in range(9):
    a=q+1
    for b in range(10):
      num[0]=a
      num[1]=b
      hentai = True
      for u in range(m):
        if num[s[u]-1]!=c[u]:
          hentai = False
      if hentai and unchi==-1:
        unchi = num[0]*10+num[1]
if n==3:
  num = [1,0,0]
  for q in range(9):
    a=q+1
    for b in range(10):
      for f in range(10):
        num[0]=a
        num[1]=b
        num[2]=f
        hentai = True
        for u in range(m):
          if num[s[u]-1]!=c[u]:
            hentai = False
        if hentai and unchi==-1:
          unchi = num[0]*100+num[1]*10+num[2]
print(unchi)

Measured memory_bytes: 3064
s = input().split(" ")
n = int(s[0])
numbers = [ i for i in input() if i != " "]
 
for i in range(n, 100001):
  found = False
  snum = str(i)
  for num in numbers:
    if num in snum:
      found = True
      break
  
  if found == False:
     print(i)
     break

Measured memory_bytes: 3060
function Main(input) {
	const lines = input.split('\n');
	let [a, b] = lines[0].split(' ').map(v => v*1).sort((a, b) {
		if (a < b) return 1;
		if (a > b) return -1;
		return 0;
	});
	const x = a * b;
	let r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	console.log(x/b);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<cstdio>
#include<iostream>
#include<algorithm>
#include <vector>
#include <string>
using namespace std;

int main(){
    string s;

    cin >> s;
    int n = (int)s.length();
    for(int i = 0; i < n;i++){
        cout << "x";
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
int x0=0,y0=0;
int t,x,y;
int i,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&t,&x,&y);
if(abs(x-x0)+abs(y-y0)>t||(abs(x-x0)+abs(y-y0)-t)%2!=0) break;
}
if(i==n) printf("Yes\n");
else printf("No\n");
return 0;
}

Measured memory_bytes: 128
MOD = 998244353
n, s = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)
dp = Array.new(n + 1) { Array.new(s + 1, 0) }

# dp[確認した数字][合計] の出現数
dp[0][0] = 1

n.times do |current|
  dp_current = dp[current]
  dp_next = dp[current + 1]
  num = nums[current]
  (s + 1).times do |current_sum|
    count = dp_current[current_sum]
    next if count.zero?
    dp_next[current_sum] += (count * 2) % MOD
    next_sum = current_sum + num
    dp_next[next_sum] += count % MOD if next_sum <= s
  end
end

puts dp.last.last % MOD


Measured memory_bytes: 84700
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int f(int i){
	switch(i){
	case 2:
		return 1;
	case 4:
	case 6:
	case 9:
	case 11:
		return 2;
	default:
		return 3;
	}
}
 
int main(void){
	int x, y;
	cin >> x >> y;
	cout << (f(x) == f(y) ? "Yes" : "No") << endl;	
	return 0;
}

Measured memory_bytes: 256
def main():
    x, k, d = [int(e) for e in input().split()]

    x = abs(x)
    if d >= x:
        if k % 2 == 0:
            print(x)
        else:
            print(d - x)
    else:
        if k > x // d:
            if k % 2 == (x // d) % 2:
                print(x % d)
            else:
                print(d - x % d)
        else:
            print(x - k * d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61860
n, a, b = gets.split.map(&:to_i)
s = gets.chomp

passed = 0
passed_f = 0
count_d = 0
s.chars.each_with_index do |ss, i|
  if ss == 'a'
    if passed < a + b
      passed += 1
      puts 'Yes'
    else
      puts 'No'
    end
    count_d += 1
  elsif ss == 'b'
    if passed < a + b && (i+1) - count_d <= b
      passed += 1
      puts 'Yes'
    else
      puts 'No'
    end
  else
    puts 'No'
    count_d += 1
  end
end


Measured memory_bytes: 9852
#include<iostream>
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<climits>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<iomanip>
#include<sstream>
using namespace std;
#define ll long long
inline ll read() {
    char ch = getchar(); ll x = 0, f = 1;
    while(ch < '0' || ch > '9') {
        if(ch == '-') f = -1;
        ch = getchar();
    } while('0' <= ch && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    } return x * f;
}
int main(){
//	freopen("03.txt","r",stdin);
	int n=read();
	for (int i=1;i<=n;i++)
	{
		ll x=read();
		ll y=read();
		if (x!=y)
		{ 
		ll p,o=sqrt((ll)(x)*y-1);
		if (o*o>(x*y-1)) o--;
		if (o*(o+1)<(x*y))
			p=o*2-1;
		else
		p=o*2-2;
		printf("%lld\n",p);
		}
		else
			printf("%lld\n",2*x-2);
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	double x1,y1,x2,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}


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

int main() {
  string s, t; cin >> s >> t;
  int n = s.size();
  string ans = "No";
  REP(i, n) {
    if (s == t) ans = "Yes";
    else s = (s + s[0]).erase(0, 1);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> p(n);
  for(int i=0;i<n;i++)
    cin>>p[i];
  
  sort(p.begin(),p.end());
  int sum=0;
  for(int i=0;i<k;i++)
    sum+=p[i];
  cout<<sum<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h,w;cin >> h >> w;
	if(h%3==0 || w%3==0) cout << 0 << endl;
	else{
		ll ans=10000000000000000;
		if(h%2==1){
			for(ll i=1;i<w;++i){
				ans=min(ans,max(i*h,(w-i)*(h/2+1))-min(i*h,(w-i)*(h/2)));
			}
		}
		else{
			for(ll i=1;i<w;++i){
				ans=min(ans,max(i*h,(w-i)*(h/2))-min(i*h,(w-i)*(h/2)));
			}
		}
		if(w%2==1){
			for(ll i=1;i<h;++i){
				ans=min(ans,max(i*w,(h-i)*(w/2+1))-min(i*w,(h-i)*(w/2)));
			}
		}
		else{
			for(ll i=1;i<h;++i){
				ans=min(ans,max(i*w,(h-i)*(w/2))-min(i*w,(h-i)*(w/2)));
			}
		}
		cout << min(ans,min(w,h)) << endl;
	}
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    long n, a, b, c, d;
    readlnTo(n, a, b, c, d);
    foreach(i; iota(n)) {
        auto pmax = d * i;
        auto pmin = c * i;
        auto mmax = d * (n-i-1);
        auto mmin = c * (n-i-1);
        auto diff = b-a;
        if(pmin - mmax <= diff && diff <= pmax - mmin) {
            writeln("YES");
            return;
        }
    }
    writeln("NO");
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
    public static void main (String args[]){
         Scanner sc = new Scanner(System.in); 
         int a = sc.nextInt();
         int b = sc.nextInt();
         
         if ((a*b) % 2 == 0)
            System.out.println("Even");
        
        else
            System.out.println("Odd");
    }
        
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <math.h>

int main(){
	float v,t,y;
	while(scanf("%f",&v) != EOF){
		t = v / 9.8;
		y = t * t * 4.9;
		printf("%d\n",(int)ceilf(y / 5.0) + 1);
	}
	return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double p = 0;
    int mw = a;
    int ms = 0;
    int w = 0;
    int s = 0;
    bool q = false;

    //操作1をi回行う( i = 0 ～ f/(100*a) )
    rep(i, f/(100*a) + 1) {
        //操作2をj回行う( j = 0 ～ f/(100*b) )
        rep(j, f/(100*b) + 1) {

            w = i*a + j*b;

            if(100*w >= f) {
                break;
            }

            rep(k, e*w/c + 1) {
                rep(l, e*w/d + 1) {
                    s = k*c + l*d;

                    if(100*w + s > f) {
                        break;
                    }

                    if( 100*w + s <= f && w != 0 ) {
                        
                        if( w*e > s && p < s/(double)w ) {
                            mw = w;
                            ms = s;
                            p = s/(double)w;
                        }

                        if( w*e == s && p < s/(double)w ) {
                            mw = w;
                            ms = s;
                            p = s/(double)w;
                            q = true;
                            break;
                        }
                    }
                    if(q) { break; }
                }
                if(q) { break; }
            }
            if(q) { break; }
        }
        if(q) { break; }
    }

    cout << 100*mw + ms << " " << ms << endl;
    return 0;
}

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

int main() {
 int  N,K;
   cin >> N >> K;
  
  if (((N%2 == 1) && ((N+1)/2 >= K)) ||((N%2 == 0) && ((N)/2 >= K))){
    
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}
  
    
  

 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin>>s;
	int n=s.size();
	string t=s;
	reverse(s.begin(),s.end());
	if(t!=s)
	 cout<<"No";
	else
	{
		string s1=s.substr(0,n/2);
		string s2=t.substr(0,n/2);
		string t1=s1,t2=s2;
		reverse(s1.begin(),s1.end());
		reverse(s2.begin(),s2.end());
		if(t1==s1 && t2==s2)
		 cout<<"Yes";
		else
		 cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3612
n,m=map(int, input().split())
A=list()
b=list()
for i in range(n):
    A.append(list(map(int,input().split())))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    c=0
    for j in range(m):
        c += A[i][j]*b[j]
    print(c)


Measured memory_bytes: 6004
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // qsort()
#include <stdbool.h>

#define MAX_N 10000

typedef struct customer_tbl
{
	int use;
	int latency;
} customer_t;

int
cmp_func(const void *l_, const void *r_)
{
	const customer_t *l = (const customer_t*) l_;
	const customer_t *r = (const customer_t*) r_;

	if (l->use < r->use)
		return -1;

	if (l->use > r->use)
		return 1;

	return 0;
}

int
main(int argc, char **argv)
{
	customer_t customers[MAX_N];
	int n, i;

	while (true)
	{
		scanf("%d", &n);
		if (n == 0)
			break;

		for (i = 0; i < n; ++i)
			scanf("%d", &customers[i].use);

		qsort(customers, n, sizeof(customer_t), cmp_func);

		customers[0].latency = 0;
		long total = 0;
		for (i = 1; i < n; ++i)
		{
			customers[i].latency = customers[i - 1].latency + customers[i - 1].use;
			total += customers[i].latency;
		}

		printf("%ld\n", total);
	}

	return 0;
}

Measured memory_bytes: 804
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main(){
int N,M; cin >> N >> M;
 vector<vector<int>> dist(N,vector<int> (N,INF));
 vector<tuple<int,int,int>> Edge;
 
  for(int i = 0; i < N; i++){ dist[i][i] = 0;}
  
  for(int i = 0; i < M; i++){
    int a,b,c; cin >> a >> b >> c; a--; b--;
    dist[a][b] = c; dist[b][a] = c; Edge.push_back(make_tuple(a,b,c)); }
  
  for(int k = 0; k < N; k++){
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        dist[i][j] = min(dist[i][k]+dist[k][j], dist[i][j]);}}}
  
  // Warshall - Floyd
  
  int cnt = 0;
  
  for(int k = 0; k < M; k++){
    //Edge[k]に含まれる辺が、ある二点i,jを結ぶ最短経路の一部になっているのかを調べる
    bool flag = false;
    
    int x = get<0>(Edge[k]); int y = get<1>(Edge[k]); int c = get<2>(Edge[k]);
    
    for(int i = 0; i < N-1; i++){
      for(int j = i+1; j < N; j++){
 // i → x →(直接) → y　→ j,ないし i → y　→(直接)　→ x　→ jがdist[i][j]と等しかったら、
  //辺Edge[k]は i と j を結ぶ最短経路の一部と言える
        int res1 = dist[i][x]+c+dist[y][j]; int res2 = dist[i][y]+c+dist[x][j];
        if( min(res1,res2) == dist[i][j]){ flag = true;}
      }
    }
    if(flag){ cnt++;}
  }
  //求めるのは、M個の辺のうち、最短経路 でない　本数
  cout << M-cnt << endl; return 0;}
        
      

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    int b,c;
    cin >> b >> c;
    // 出力
  	if(b*c % 2==0){
    	cout << "Even" << endl;
    }else{
    	cout << "Odd" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
template <typename T>
class segment_tree {
public:
	segment_tree(int n_) : n(__lowest_power_of_2(n_)), dat(n * 2, 0), lazy(n * 2, 0) {}

	template <typename Iterator>
	segment_tree(Iterator left, Iterator right)
		: n(__lowest_power_of_2(std::distance(left, right))), dat(n * 2, 0), lazy(n * 2, 0) {
		std::copy(left + n, right + n, dat.begin());
		for (int i = n - 1; i >= 1; --i) {
			dat[i] = std::max(dat[i * 2], dat[i * 2 + 1]);
		}
	}

private:
	int n;
	std::vector<T> dat, lazy;

public:
	void add(int ql, int qr, const T &x) { __add(1, 0, n, ql, qr, x); }

	T sum(int ql, int qr) { return __sum(1, 0, n, ql, qr); }

private:
	void __flush_lazy(int v, int l, int r) {
		if (lazy[v] % 2 == 1) {
			dat[v] = r - l - dat[v];
		}
		if (v < n) {
			lazy[v * 2] += lazy[v];
			lazy[v * 2 + 1] += lazy[v];
		}
		lazy[v] = 0;
	}

	void __update_dat(int v) { dat[v] = dat[v * 2] + dat[v * 2 + 1]; }

	void __add(int n, int l, int r, const int ql, const int qr, const T &x) {
		__flush_lazy(n, l, r);
		if (r <= ql || qr <= l) {
			return;
		}
		else if (ql <= l && r <= qr) {
			lazy[n] += x;
			__flush_lazy(n, l, r);
		}
		else {
			int m = (l + r) / 2;
			__add(n * 2, l, m, ql, qr, x);
			__add(n * 2 + 1, m, r, ql, qr, x);
			__update_dat(n);
		}
	}

	T __sum(int n, int l, int r, const int ql, const int qr) {
		__flush_lazy(n, l, r);
		if (r <= ql || qr <= l) {
			return 0;
		}
		else if (ql <= l && r <= qr) {
			return dat[n];
		}
		else {
			int m = (l + r) / 2;
			T res_left = __sum(n * 2, l, m, ql, qr);
			T res_right = __sum(n * 2 + 1, m, r, ql, qr);
			__update_dat(n);
			return res_left + res_right;
		}
	}

	int __lowest_power_of_2(int x) const {
		int res = 1;
		while (res < x) res <<= 1;
		return res;
	}
};
vector<int> ll;
vector<int> rr;
vector<vector<int> >ed;
int pp = 0;
void dfs(int a, int p) {
	ll[a] = pp;
	pp++;
	for (int i = 0; i < ed[a].size(); i++) {
		if (ed[a][i] != p) {
			dfs(ed[a][i], a);
		}
	}
	rr[a] = pp;
	pp++;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q;
	cin >> N >> Q;
	vector<int> A(N);
	ed.resize(N);
	rr.resize(N);
	ll.resize(N);
	int a;
	for (int i = 1; i < N; i++) {
		cin >> a;
		a--;
		ed[a].push_back(i);
	}
	dfs(0, -1);
	segment_tree<int> sg(2 * N);
	for (int i = 0; i < N; i++) {
		char c;
		cin >> c;
		if (c == 'G') {
			sg.add(ll[i], ll[i] + 1, 1);
			sg.add(rr[i], rr[i] + 1, 1);
		}
	}

	vector<int> qu(Q);
	for (int i = 0; i < Q; i++) {
		cin >> qu[i];
	}
	//cerr << sg.sum(0, 2 * N) << endl;
	for (int i = 0; i < Q; i++) {
		sg.add(ll[qu[i] - 1], rr[qu[i] - 1] + 1, 1);
		int sm = sg.sum(0, 2 * N);
		//cerr << sm << endl;
		if (sm > N) {
			cout << "broccoli" << endl;
		}
		else {
			cout << "cauliflower" << endl;
		}
	}
	//cout << res << endl;
}


Measured memory_bytes: 24140
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	ll N, M;
	cin >> N >> M;

	if (M <= N) {
		cout << M / 2 << endl;
	}
	else
	if (M / 2 <= N && N < M) {
		cout << M / 2 << endl;
	}
	else
	if (N < M / 2){
		M -= (2 * N);
		cout << N +  M / 4 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

double dp[3010][3010];

int main ()
{
    int N; cin >> N;
    vector<double> p(N);
    REP(i,N) cin >> p[i];

    dp[0][0] = 1.0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            dp[i + 1][j] += (1.0 - p[i]) * dp[i][j];
            dp[i + 1][j + 1] += p[i] * dp[i][j];
        }
    }

    double ans = 0.0;
    for (int i = 0; i <= N; i++) {
        if (i > N / 2) {
            ans += dp[N][i];
        }
    }

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 70784
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N; cin >> N;
	vector<ll> A(N), B(N), C(N);
	for (int i = 0; i < N;i++) cin >> A[i];
	for (int i = 0; i < N;i++) cin >> B[i];
	for (int i = 0; i < N;i++) cin >> C[i];
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	vector<ll>BA(N+1, 0);
//	vector<ll> CB(N + 1, 0);
	for (int i = 0; i < N;i++) {
		BA[i+1] = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
//		CB[i+1] = lower_bound(B.begin(), B.end(), C[i]) - B.begin();
	}
	for (int i = 0; i < N;i++) {
		BA[i + 1] += BA[i];
//		CB[i + 1] += CB[i];
	}
	ll res = 0;
	for (int i = 0; i < N;i++) {
		res += BA[lower_bound(B.begin(), B.end(), C[i]) - B.begin()];
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3456