akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

template <typename T>
class BellmanFord {
 private:
  const ll INF = 1LL << 60;
  ll n_;
  vector<tuple<ll, ll, T>> edges_;
  vector<vector<ll>> to_, rto_;
  vector<T> dist_;
  vector<bool> reachableFromSrc_, reachableToDst_;

  void dfs(ll u, const vector<vector<ll>>& to, vector<bool>& reachable) {
    if (reachable[u]) return;
    reachable[u] = true;
    for (ll v : to[u]) {
      dfs(v, to, reachable);
    }
  }

 public:
  BellmanFord(ll n)
      : n_(n),
        dist_(n, INF),
        to_(n),
        rto_(n),
        reachableFromSrc_(n, false),
        reachableToDst_(n, false) {}

  void addEdge(ll u, ll v, ll w) {
    edges_.emplace_back(u, v, w);
    to_[u].emplace_back(v);
    rto_[v].emplace_back(u);
  }

  bool exec(ll src, ll dst, T& ans) {
    // To remove edges which is not involved in path from src to dst
    dfs(src, to_, reachableFromSrc_);
    dfs(dst, rto_, reachableToDst_);

    dist_[src] = 0;
    rep(i, n_) {
      for (auto& e : edges_) {
        ll u = get<0>(e);
        ll v = get<1>(e);
        ll w = get<2>(e);
        if (reachableFromSrc_[u] && reachableFromSrc_[v] &&
            reachableToDst_[u] && reachableToDst_[v]) {
          if (dist_[v] > dist_[u] + w) {
            dist_[v] = dist_[u] + w;
          }
        }
      }
    }
    for (auto& e : edges_) {
      ll u = get<0>(e);
      ll v = get<1>(e);
      ll w = get<2>(e);
      if (reachableFromSrc_[u] && reachableFromSrc_[v] && reachableToDst_[u] &&
          reachableToDst_[v]) {
        if (dist_[v] > dist_[u] + w) {
          // has negative cycle
          return true;
        }
      }
    }
    // no negative cycle
    ans = dist_[dst];
    return false;
  }
};

int main() {
  //
  ll n, m, p;
  cin >> n >> m >> p;
  BellmanFord<ll> g(n);

  rep(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    c -= p;
    c = -c;
    g.addEdge(a, b, c);
  }
  ll ret = 0;
  if (g.exec(0, n - 1, ret)) {
    cout << -1 << endl;
  } else {
    cout << max(0LL, -ret) << endl;
  }

  return 0;
}


Measured memory_bytes: 896
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    D, T, S = map(int, input().split())
    print('Yes') if D -T*S <= 0 else print('No')

if __name__ == "__main__":
    main()

Measured memory_bytes: 9480
'''ika tako　　ABC164Dの類題
基本は、1桁目、2桁目と下から10進数の数字として見て、
素数ｐで割った余りを考え、余りが同じである数字のスタートとエンドを
選ぶ組み合わせの数が答。
但し、10進数で考えているので、ｐが2と5のケースは別扱い。
末尾が2、5の倍数なら2の倍数。先頭の数字を0番目として、
i番目に2、5の倍数が出てきたら、
そこを右端とする部分文字列は i+1  個作れる。
'''
from collections import defaultdict

def solve2(s):
    ans = 0
    for i, c in enumerate(s):
        if c in '02468':
            ans += i + 1
    return ans

def solve5(s):
    ans = 0
    for i, c in enumerate(s):
        if c in '05':
            ans += i + 1
    return ans

def solve_other(s, p):
    reminders = defaultdict(lambda: 0)
    tmp = 0
    mul = 1
    for c in s[::-1]:
        c = int(c)
        tmp = (tmp + c * mul) % p
        mul = mul * 10 % p
        reminders[tmp] += 1
    reminders[0] += 1
    ans = 0
    for r, cnt in reminders.items():
        ans += cnt * (cnt - 1) // 2
    return ans

n, p = list(map(int, input().split()))
s = input()
if p == 2:
    print(solve2(s))
elif p == 5:
    print(solve5(s))
else:
    print(solve_other(s, p))

Measured memory_bytes: 4576
#include <stdio.h>
int main(){
	int harga;
	scanf("%d", &harga);
	int ribuan;
	ribuan = harga/1000;
	int uang = ribuan*1000;
	int change = uang - harga;
	if(harga%1000==0){
		printf("%d", change);
	}
	else{
		printf("%d", change+1000);
	}
	return 0;
}

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

int main(){
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	cout << (s < t ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int ans = (n + 1) / 2;
	printf("%.15f\n", ans * 1.0 / n);
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.array;
 
void main(){
  int n=to!int(readln.chomp);
  while(n--){
    auto s=new bool[32];
    auto input=readln.chomp;
    for(int i=0;i<8;++i){
      int a=(input[i]<='9')?input[i]-'0':input[i]-'a'+10;
      for(int j=0;j<4;++j){
        s[4*i+j]=(a&(1<<(3-j)))?true:false;
      }
    }
    //for(int i=0;i<32;++i)stderr.writef("%d",s[i]?1:0);
    //stderr.writeln();
    string ans;
    int tmp=0;
    for(int i=0;i<24;++i){
      tmp+=s[i+1]?(1<<(23-i)):0;
    }
    ans~=((s[0])?"-":"")~to!string(tmp);
    tmp=0;
    bool f=false;
    for(int i=25;i<32;++i){
      tmp+=(s[i])?(78125<<(31-i)):0;
    }
    int cnt=0;
    if(tmp==0)cnt=0;
    else{
    	if(tmp<1000000)++cnt;
    	if(tmp<100000)++cnt;
    }
    while(tmp%10==0&&tmp!=0)tmp/=10;
    ans~="."~"0".replicate(cnt)~to!string(tmp);
    writeln(ans);
  }
}

Measured memory_bytes: 2032
#include<iostream>
#include<cstring>
using namespace std;
int main() {
	int ans = 0;
	string s; 
	cin>>s;
	for(int i=0;i<s.length()-1;i++) {
		if(s[i]!=s[i+1])
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pll
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<ll,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< tri,vector<tri> ,greater< tri > >

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);
pdqueue pq;
ll c[55],d[55],dist[55][3005];
vector<vl>adj(55),cost(55),wt(55);
pii par[55][3005];
int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	double clk=clock();
	ll n,m,s,u,v,a,b,i,j,dis,x,y,ans,y1;
	tri p;
	cin>>n>>m>>s;
	rep(i,m){
		cin>>u>>v>>a>>b;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
		cost[u].pb(a);
		cost[v].pb(a);
		wt[u].pb(b);
		wt[v].pb(b);
	}
	rep(i,n){
		cin>>c[i]>>d[i];
	}
	s=min(s,2502LL);
	ll iinf=inf;
	iinf*=inf;
	rep(i,n){
		rep(j,2503){
			dist[i][j]=iinf;
		}
	}
	dist[0][s]=0;
	pq.push(mp(dist[0][s],mp(0,s)));
	while(!pq.empty()){
		p=pq.top();
		dis=p.ff;
		x=p.ss.ff;
		y=p.ss.ss;
		pq.pop();
		if(dist[x][y]<dis){
			continue;
		}
		rep(i,adj[x].size()){
			if(y>=cost[x][i]){
				if(dist[adj[x][i]][y-cost[x][i]]>dis+wt[x][i]){
					par[adj[x][i]][y-cost[x][i]]=mp(x,y);
					dist[adj[x][i]][y-cost[x][i]]=dis+wt[x][i];
					pq.push(mp(dist[adj[x][i]][y-cost[x][i]],mp(adj[x][i],y-cost[x][i])));
				}
			}
		}
		y1=y;
		dis+=d[x];
		y+=c[x];
		if(dist[x][y]>dis){
				par[x][y]=mp(x,y1);
				dist[x][y]=dis;
			pq.push(mp(dis,mp(x,y)));
		}
	}
	//cout<<dist[0][3]<<endl;
	f(i,1,n){
		ans=iinf;
		rep(j,2503){
			ans=min(ans,dist[i][j]);
		}
		cout<<ans<<endl;
	}
	//cerr<<(clock()-clk)/CLOCKS_PER_SEC<<endl;
	return 0;
} 


Measured memory_bytes: 9660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n,k;
  cin>>n>>k;
  vector<char> d(k);
  rep(i,k){
      cin>>d[i];
  }
  while(1){
      bool tmp=true;
      string m=to_string(n);
      rep(i,sz(m)){
          rep(j,k){
              if(m[i]==d[j]){
                  tmp=false;
              }
          }
      }
      if(tmp){
          print(n);
          return 0;
      }
      else{
          n++;
      }
  }
}


Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>

#define MAX_N 100000

//累積和で高速化ver

using namespace std;

int main() {
    int N, Q, csum[MAX_N] = {0};
    bool a;
    scanf("%d %d", &N, &Q); getchar();
    for (int i=0; i<N; i++) {
        int c = getchar();
        if (a && c == 'C') csum[i] = csum[i-1] + 1;
        else if (i > 0) csum[i] = csum[i-1];
        if (c == 'A') a = true;
        else a = false;
    }
    for (int i=0; i<Q; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        printf("%d\n", csum[r-1] - csum[l-1]);
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	if (a[0] > 0) {
		cout << -1 << endl;
		return 0;
	}

	for (ll i = 1; i < n; i++) {
		if (a[i] <= a[i - 1] + 1) continue;
		cout << -1 << endl;
		return 0;
	}

	ll ans = 0;
	for (ll i = 1; i < n - 1; i++) {
		if (a[i + 1] - a[i] < 1) ans += a[i];
	}
	ans += a[n - 1];
	cout << ans << endl;
}


Measured memory_bytes: 1792
from collections import deque

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

res = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            continue
        dist = [[-1] * w for _ in range(h)]
        dist[i][j] = 0
        d = deque()
        d.append([i, j])

        while d:
            pos_x, pos_y = d.popleft()
            dist_max = dist[pos_x][pos_y]
            for k in range(4):
                x, y = pos_x + dx[k], pos_y + dy[k]
                if 0 <= x < h and 0 <= y < w and s[x][y] == "." and dist[x][y] == -1:
                    dist[x][y] = dist[pos_x][pos_y] + 1
                    d.append([x, y])

        res = max(res, dist_max)

print(res)

Measured memory_bytes: 45548
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll n,m;
	cin>>n>>m;
	ll sum=0;
	for(ll i=0;i<m;i++)
    {
        ll a;
        cin>>a;
        sum+=a;
    }
    if(n>sum)
        cout<<"No";
    else
        cout<<"Yes";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d;cin>>a>>b>>c>>d;
  while(true){
    c-=b;
    if(c <= 0){
      cout<<"Yes"<<endl;
      break;
    }
    a-=d;
    if(a<=0){
      cout<<"No"<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int MAX = 999999999;

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

    a -= (int)(b < a);
    cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>

#define MAX_N 105

using namespace std;

struct Card
{
    char suit;
    int value;
};

void BubbleSort(Card A[], int N)
{
    for(int i=0; i<N; i++)
    {
        for(int j=N-1; j>=i+1; j--)
        {
            if(A[j].value<A[j-1].value)
            {
                swap(A[j], A[j-1]);
            }
        }
    }
}

void SelectionSort(Card A[], int N)
{
    for(int i=0; i<N; i++)
    {
        int minIdx=i;
        for(int j=i; j<N; j++)
        {
            if(A[j].value<A[minIdx].value)
                minIdx=j;
        }
        if(minIdx!=i)
        {
            swap(A[i], A[minIdx]);
        }
    }
}

void PrintArray(Card A[], int N)
{
    for(int i=0; i<N; i++)
    {
        if(i>0)
            cout<<" ";
        cout<<A[i].suit<<A[i].value;
    }
    cout<<endl;
}

bool IsStable(Card C1[], Card C2[], int N)
{
    for(int i=0; i<N; i++)
    {
        if(C1[i].suit!=C2[i].suit)
            return false;
    }
    return true;
}

int main()
{
    Card C1[MAX_N], C2[MAX_N];
    int N;
    char ch;
    cin>>N;
    for(int i=0; i<N; i++)
        cin>>C1[i].suit>>C1[i].value;
    for(int i=0; i<N; i++)
    {
        C2[i].suit=C1[i].suit;
        C2[i].value=C1[i].value;
    }
    BubbleSort(C1, N);
    SelectionSort(C2, N);
    PrintArray(C1, N);
    cout<<"Stable"<<endl;
    PrintArray(C2, N);
    if(IsStable(C1, C2, N))
    {
        cout<<"Stable"<<endl;
    }
    else
    {
        cout<<"Not stable"<<endl;
    }
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
struct P{
	int pos,time;
};
bool operator<(P a,P b){return a.time<b.time;}
int main() {
	int a[21],n,m,u1,u2;
	P b[21];
	vector<int>e[21];
	cin>>m>>n;
	for(int i=1;i<=m;i++){
		b[i]=P{i,-1};
		a[i]=0;
	}
	for(int i=0;i<n;i++){
		cin>>u1>>u2;
		e[u1].push_back(u2);
		a[u2]++;
	}
	queue<int>p;
	for(int i=1;i<=m;i++){
		if(a[i]==0){
			p.push(i);
			b[i].time=0;
		}
	}
	while(!p.empty()){
		int t=p.front();p.pop();
		for(int i=0;i<e[t].size();i++){
			if(b[e[t][i]].time<b[t].time+1){
				b[e[t][i]].time=b[t].time+1;
				p.push(e[t][i]);
			}
		}
	}
	sort(b+1,b+m+1);
	for(int i=1;i<=m;i++){
		cout<<b[i].pos<<endl;
	}
	//cout<<2<<endl;
}

Measured memory_bytes: 3136
n,m=map(int,input().split())
D=[1] * (n + 1)
for _ in range(m):
    D[int(input())] = 0
for i in range(n+1):
    if i > 1:
        D[i] = (D[i-1] + D[i-2]) % 1000000007 * D[i]
print(D[i])

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

int main() {
  int N;cin>>N;
  vector<long> A(N+1);
  for(int i=1;i<=N;i++)cin>>A[i];
  map<long,long> wa;//a+Aとa-Aが等しければ良い
  for(int i=1;i<=N;i++){
    if(wa.end()!=wa.find(A[i]+i)){
      wa[A[i]+i]++;
    }else{
      wa.insert(pair<long,long>(A[i]+i,1));
    }
  }
  long cnt=0;
  for(int i=1;i<=N;i++){
    if(wa.end()!=wa.find(i-A[i])){
      cnt+=wa[i-A[i]];
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 17152
#include<bits/stdc++.h>
using namespace std;
#define N 51
int k,n,m,p,a[N];
int t1,t2;
int mx=-1e9,mn=1e9;
int num,c[N<<1],d[N<<1];
inline void Add(int x,int y){
	a[y]+=a[x];
	c[++num]=x;d[num]=y;
}
inline void Solve1(){
	for(int i=1;i<n;i++)
	if(a[i]>a[i+1])Add(i,i+1);
}
inline void Solve2(){
	for(int i=n;i>1;i--)
	if(a[i-1]>a[i])Add(i,i-1);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]>mx)mx=a[i],t1=i;
		if(a[i]<mn)mn=a[i],t2=i;
	}
	if(mn>=0){
		Solve1();
	}else
	if(mx<=0){
		Solve2();
	}else
	if(mx>-mn){
		for(int i=1;i<=n;i++)
		if(a[i]<0)Add(t1,i);
		Solve1();
	}else{
		for(int i=1;i<=n;i++)
		if(a[i]>0)Add(t2,i);
		Solve2();
	}
	cout<<num<<endl;
	for(int i=1;i<=num;i++)printf("%d %d\n",c[i],d[i]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	vector<long long> a[3];
	rep(i,3){
		a[i] = vector<long long>(n);
		rep(j,n){
			cin >> a[i][j];
		}
		sort(all(a[i]));
		//for(auto j : a[i]){ cout << j << ' '; } cout << endl;
	}

	long long ans = 0;
	rep(j,n){
		//show(a[1][j])
		long long d1 = distance(a[0].begin(), lower_bound(all(a[0]), a[1][j]));
		long long d2 = distance(upper_bound(all(a[2]), a[1][j]), a[2].end());
		//show(*upper_bound(all(a[2]), a[1][j]))
		//cout << d1 << ' ' << d2 << endl;

		ans += d1 * d2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;

namespace abc136_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var s = CIn.Read().ToCharArray();
      var n = s.Length;

      var ans = new int[n];
      var f = false;

      for (var i = 0; i < n - 1; i++)
      {
        if (f)
        {
          if (s[i] == 'R')
          {
            f = false;
          }
          else
          {
            continue;
          }
        }

        for (var j = i + 1; j < n; j++)
        {
          if (s[j] == 'L')
          {
            ans[j - 1] += (j - i + 1) / 2;
            ans[j] += (j - i) / 2;

            i = j;
            f = true;
            break;
          }
        }
      }

      f = false;

      for (var i = n - 1; i > 0; i--)
      {
        if (f)
        {
          if (s[i] == 'L')
          {
            f = false;
          }
          else
          {
            continue;
          }
        }

        for (var j = i - 1; j >= 0; j--)
        {
          if (s[j] == 'R')
          {
            ans[j + 1] += (i - j + 1) / 2;
            ans[j] += (i - j) / 2;

            i = j;
            f = true;
            break;
          }
        }
      }

      Console.WriteLine(string.Join(" ", ans));
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 15840
MOD = 10 ** 9 + 7

n = int(input())
s = list(str(input()))

if s[0] == "W" or s[-1] == "W":
    print(0)
else:

    dir = [0] * (2*n)

    for i in range(1,2*n):
        if s[i] != s[i-1]:
            dir[i] = dir[i-1]
        else:
            dir[i] = (dir[i-1] + 1) % 2

    c = 0

    for x in dir:
        if x == 0:
            c += 1
    
    #print(c)
    #print(dir)
    if c != n:
        print(0)
    
    else:
        ans = 1
        count = 0

        for i in range(2*n):
            if dir[i] == 0:
                count += 1
            else:
                ans = (ans * count) % MOD
                count -= 1
        
        for k in range(1,n+1):
            ans = (ans * k) % MOD
        
        print(ans)

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

int w, h, n;
int gx, gy;
int x[1002], y[1002];
char t[1002][1002];

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

int par[1000 * 1000 + 2];
int rank[1000 * 1000 + 2];

void init(void){
  for(int i = 0; i < 1000 * 1000 + 2; i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int a){
  if(par[a] == a){
    return a;
  }
  else{
    return par[a] = find(par[a]);
  }
}

void unite(int a, int b){
  a = find(a);
  b = find(b);
  if(a == b) return;

  if(rank[a] < rank[b]){
    par[a] = b;
  }
  else{
    par[b] = a;
    if(rank[a] == rank[b]) rank[a]++;
  }
}

bool same(int a, int b){
  return find(a) == find(b);
}

void solve(){
  if(same(0, gx + gy * w)){
    cout << 0 << endl;
    return;
  }

  for(int i = 0; i < n; i++){
    if(t[y[i]][x[i]] == '.') continue;
    t[y[i]][x[i]] = '.';

    for(int j = 0; j < 4; j++){
      int nx = x[i] + dx[j];
      int ny = y[i] + dy[j];

      if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
      if(t[ny][nx] == '#') continue;

      unite(x[i] + y[i] * w, nx + ny * w);
    }

    if(same(0, gx + gy * w)){
      cout << i + 1 << endl;
      return;
    }
  }

  cout << -1 << endl;
}

int main(){
  while(cin >> w >> h){
    init();

    for(int i = 0; i < h; i++){
      cin >> t[i];

      for(int j = 0; j < w; j++){
	if(t[i][j] == 't'){
	  gx = j;
	  gy = i;
	  t[i][j] = '.';

	}

	if(t[i][j] == '#') continue;

	for(int k = 0; k < 4; k++){
	  int nx = j + dx[k];
	  int ny = i + dy[k];

	  if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
	  if(t[ny][nx] == '#') continue;

	  unite(j + i * w, nx + ny * w);
	}
      }
    }

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

    solve();
  }
}

Measured memory_bytes: 9964
/*
 * author: Tran Minh Khoa
 * Ho Chi Minh University of Science
 */

#include <bits/stdc++.h>

using namespace std;

const int inf = (int) 1e9 + 7;
const long long INF = (long long) 1e18 + 7;

const int N = 123456;
const int M = 1010;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define sqrt(x) (x) * (x)

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define DEBUG(x) cerr << #x << " = " << x << '\n';
#define PR(x, a, b) { cerr << #x << " = "; REP(i, a, b) cerr << x[i] << ' '; cerr << '\n'; }
                 
int main() {
  #ifdef KM777
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
  #endif
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr); cout.tie(nullptr);

  int n, W;
  cin >> n >> W;
  vector<int> u(n + 1), v(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> u[i] >> v[i];
  }
  vector<vector<long long>> dp(n + 1, vector<long long>(W + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= W; j++) {
      if (j >= u[i]) {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - u[i]] + v[i]);
      } else {
        dp[i][j] = dp[i - 1][j];
      }
    }
  }
  long long result = 0;
  for (int i = 1; i <= W; i++) {
    result = max(result, dp[n][i]);
  }
  cout << result << '\n';
  return 0;
}

Measured memory_bytes: 80256
N,K = list(map(int,input().split(" ")))
hs = list(map(int,input().split(" ")))
dp = [9999999999999] * N

dp[0] = 0
for i in range(1,N):
#ind → i-1 ~ i-stepLim -1   [i-stepLim -1:i]
    stepLim = min(K,i)
    dp[i] = min([d+abs(hs[i]-h) for d,h in zip(dp[i-stepLim:i],hs[i-stepLim:i])])
print(dp[-1])

Measured memory_bytes: 13980
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = 16;

int n, a[N][N], dp[(1<<N)], wyn[1<<N];
VI v, num[N+1], submask[1<<N], bity[1<<N];

void licz(int x, const VI& v, int nr, int sum) {
  if (nr == v.size()) {
    if (sum != 0)
      submask[x].PB(sum);
    return;
  }
  licz(x, v, nr+1, sum);
  licz(x, v, nr+1, sum+(1<<v[nr]));
}

signed main() {
  init_ios();
  cin >> n;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      cin >> a[i][j];
  for (int i = 1; i < (1<<N); ++i)
    num[__builtin_popcount(i)].PB(i);
  for (int i = 2; i < (1<<N); ++i) {
    for (int j = 0; j < N; ++j)
      if (i&(1<<j))
        bity[i].PB(j);
  }
  for (int i = 2; i <= N; ++i)
    for (int x: num[i])
      licz(x, bity[x], 0, 0);
  for (int i = 2; i <= n; ++i) {
    for (int mask: num[i]) {
      int v = bity[mask].back();
      int res = wyn[mask^(1<<v)];
      for (int j = 0; j < n; ++j)
        if (j != v && (mask&(1<<j))) {
          res += a[v][j];
        }
      wyn[mask] = res;
    }
  }
  for (int i = 2; i <= n; ++i)
    for (int mask: num[i]) {
      dp[mask] = max(dp[mask], wyn[mask]);
      for (int sub: submask[mask])
        dp[mask] = max(dp[mask], wyn[sub]+dp[mask^sub]);
    }
  cout<<dp[(1<<n)-1]<<"\n";
  return 0;
}

Measured memory_bytes: 351736
// https://atcoder.jp/contests/abc085/tasks/abc085_d
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N;
    ll H;
    cin >> N >> H;
    vector<ll> a(N), b(N);
    ll amax = -1;
    REP(i, N)
    {
        cin >> a[i] >> b[i];
        amax = std::max(amax, a[i]);
    }
    sort(b.begin(), b.end(), std::greater<ll>());
    ll ans = 0;
    REP(i, N)
    {
        if (amax > b[i]) break;
        H -= b[i];
        ++ans;
        if (H <= 0) break;
    }
    if (H > 0)
    {
        ll cnt = (H + amax - 1) / amax;
        ans += cnt;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4788
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

x = int(input())
inf = 10**6
for i in range(x,inf):
    if is_prime(i):
        print(i)
        exit()

Measured memory_bytes: 3060
a = 0
b = 0

n = gets.to_i
n.times do
  c1, c2 = gets.split
  if c1 > c2
    a += 3
  elsif c1 == c2
    a += 1
    b += 1
  elsif c1 < c2
    b += 3
  end
end

printf("%d %d\n", a, b)



Measured memory_bytes: 6872
//g++でビルド
     
    #include "bits/stdc++.h"
     
    using namespace std;
     
    int a, b, k;
     
    int gcd(int s, int t){
        if(t > s){
            return gcd(t, s);
        }
     
        if(s%t == 0){
            return t;
        }else{
            return gcd(t, s%t);
        }
    }
     
    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
     
        cin >> a >> b >> k;
     
        int now = gcd(a, b);
        //cout << now << endl;
     
        int count = 0;
        int result = 0;
     
        for(int i = now; i > 0; i--){
            if(now%i == 0){
                count++;
                if(count == k){
                    result = i;
                    break;
                }
            }
        }
     
     
     
        cout << result << endl;
    }

Measured memory_bytes: 256
N, x = map(int, raw_input().split())
if x == 1 or x == 2*N - 1:
    print 'No'
elif x == N:
    print 'Yes'
    for i in range(1, 2*N):
        print i
elif x < N:
    print 'Yes'
    for i in range(N - 1 + x, 0, -1):
        print i
    for i in range(N+x, 2*N):
        print i
else:
    print 'Yes'
    y = 2*N - x
    for i in range(N - 1 + y, 0, -1):
        print 2*N - i
    for i in range(N+y, 2*N):
        print 2*N - i

Measured memory_bytes: 10244
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <limits>

using namespace std;

int main(void) {
    int64_t A, B, N;
    cin >> A >> B >> N;

    // int64_t ans = numeric_limits<int64_t>::min();
    // for(int x=0; x<=min(A, N); x++) {
    //     ans = max(ans, (A*x)/B - A*(x/B));
    // }

    // cout << ans << endl;
    int64_t x = min(B-1, N);
    cout << (A*x)/B - A*(x/B) << endl;
    return 0;
}


Measured memory_bytes: 3580
#include<stdio.h>

#define N 100



int min(int min,int m){

  if(min > m)
    return m;
  else
    return min;
}
    

int main() {
  int i,j,k,l,n,p[N+1],cost[N+1][N+1],min_cost;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++){
    cost[i][i] = 0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i + l -1;

      for(k=i;k<j;k++){
	if(k == i){
	  min_cost = cost[i][k] + cost[k+1][j] + p[i-1] * p[k] * p[j];
	}
	else{
	  min_cost = min(min_cost, cost[i][k] + cost[k+1][j] + p[i-1] * p[k] * p[j]);
	    }
      }
      cost[i][j] = min_cost;
    }
  }

  printf("%d\n",cost[1][n]);

  return 0;
}
      



Measured memory_bytes: 2148
n=int(input())
def f(x):
    ans=0
    while x>0:
        ans+=x%6
        x=x//6
    return ans
def g(x):
    ans=0
    while x>0:
        ans+=x%9
        x=x//9
    return ans
ans=n
for i in range(n+1):
    ans=min(ans,f(i)+g(n-i))
print(ans)


Measured memory_bytes: 73476
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0'){
	t=(t<<3)+(t<<1)+v-48;
	v=getchar();}
	return t;
}
inline int ksm(re int x,re int y){
	int ans=1;
	while(y){
		if(y&1)ans*=x;
		x*=x;
		y>>=1;
	}
	return ans;
}long long n,k,a[102];
inline int check(re int x){
	int ans=0;
	for(re int i=1;i<=n;++i){
		ans+=(a[i]-x)*(a[i]-x);
	}
	return ans;
}
int ans;
signed main(){
	n=read();
	for(re int i=1;i<=n;++i)a[i]=read();
	ans=1e18;
	for(re int i=1;i<=100;++i)if(check(i)<ans)ans=check(i);
	printf("%lld",ans);
}

Measured memory_bytes: 256
def main():
    import queue
    import sys
    input=sys.stdin.readline
    
    while True:
        w,h=map(int,input().split())
        if w==0 and h==0:
            break
        maze=[list(map(int,input().split())) for _ in range(2*h-1)]
    

        q=queue.Queue()
        dist=[[-1]*w for _ in range(h)]
        dist[0][0]=1
        q.put((0,0))
        while q.qsize()!=0:
            p=q.get()
            ny=p[0]
            nx=p[1]

            y=ny
            x=nx+1
            if  x<w and dist[y][x]==-1 and maze[2*y][nx]==0:
                dist[y][x]=dist[ny][nx]+1
                q.put((y,x))
            
            y=ny
            x=nx-1
            if x>=0 and dist[y][x]==-1 and maze[2*y][x]==0:
                dist[y][x]=dist[ny][nx]+1
                q.put((y,x))
        
            y=ny+1
            x=nx
            if y<h and dist[y][x]==-1 and maze[2*ny+1][x]==0:
                dist[y][x]=dist[ny][nx]+1
                q.put((y,x))
        
            y=ny-1
            x=nx
            if y>=0 and dist[y][x]==-1 and maze[2*ny-1][x]==0:
                dist[y][x]=dist[ny][nx]+1
                q.put((y,x))
        
        if dist[-1][-1]==-1:
            print(0)
        else:
            print(dist[-1][-1])

if __name__=='__main__':
    main()
    


Measured memory_bytes: 6860
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

int mem(vector<int> &dp, int i, int N, vector<int> S)
{
	if(dp[i]!=INF) return dp[i];
	int ret = INF;
	if(i<=N-2) ret = min(ret,mem(dp,i+1,N,S));
	if(i<=N-3) ret = min(ret,mem(dp,i+2,N,S));
	if(i<=N-4) ret = min(ret,mem(dp,i+3,N,S));
	if(S[i]==1) ret++;
	return dp[i]=ret;
}

int main(void) {
	int N;	
	inp(N);
	int K;
	inp(K);
	vector<int> h;
	rep(i,N) {
		int hi;
		inp(hi);
		h.push_back(hi);
	}
	int ans = 0;
	rep(i,N){
		if(h[i]>=K) ans++;
	}
	out(ans);
}


Measured memory_bytes: 892
#from collections import deque
#from heapq import heapify, heappop, heappush
#from bisect import insort
#from math import gcd
#from decimal import Decimal
#mod = 1000000007
#mod = 998244353
N = int(input())
#N, K = map(int, input().split())
#A = list(map(int, input().split()))
#flag = True
#for k in range(N):
ans = N*N*N
print(ans)
#print('Yes')
#print('No')

Measured memory_bytes: 9088
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, K, ret = 0;
    cin >> N >> K;
    FOR(i, 0, N) {
        int H;
        cin >> H;
        if (H >= K)
            ret++;
    }

    cout << ret << endl;
    return 0;
};


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

int main(){
    int N,x,ans=0;
    int t[200010];
    cin >> N ;
    vector<int>  b(N);
    for(int i = 0; i < N; i++){
        cin >> b[i];
        t[i] = b[i];
    }  
    
    sort(b.begin(), b.end());
    int M = N/2;

    for(int i = 0; i < N; i++){
        int a = t[i];
            if(t[i] <= b[M-1]){
                cout << b[M] << endl;
            }
            else{
                cout << b[M-1] << endl;
            }
        
        
    }
 
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int N = rei();
	int ans = 0;
	for(int i=1;i<=N;i++){
		int c = i;
		int d = 0;
		while(c){
			c /= 10;
			d++;
		}
		if(d & 1){
			ans++;
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

int a[501],sum[501];
int main(){
    int h,w,y,x;
    cin>>h>>w>>y>>x;
    if(h%y==0&&w%x==0){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    int cur=10000;
    if(w%x!=0){
        FOR(i,1,w+1){
            if(i-x<0) sum[i]=cur;
            else cur=sum[i-x]-1,sum[i]=cur;
        }
        FOR(i,1,w+1) a[i-1]=sum[i]-sum[i-1];
        rep(i,h){
            rep(j,w) cout<<a[j]<<" ";
            cout<<endl;
        }
    }
    else{
        FOR(i,1,h+1){
            if(i-y<0) sum[i]=cur;
            else cur=sum[i-y]-1,sum[i]=cur;
        }
        FOR(i,1,h+1) a[i-1]=sum[i]-sum[i-1];
        rep(i,h){
            rep(j,w) cout<<a[i]<<" ";
            cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
 
    int N;
    cin >> N;
    string S;
    cin >> S;
    string TT = S.substr(0,N/2)+S.substr(0,N/2);
    
    if(S == TT) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,n,m,c,cnt=0;
long long sum=0;
cin>>n>>m>>c;
int v[n];
int b[m];
for(int i=0;i<m;i++)
cin>>b[i];
t=n;
for(int j=0;j<n;j++){
int a[m];
for(int i=0;i<m;i++){
cin>>a[i];
sum+=(a[i]*b[i]);}
sum+=c;
v[j]=sum;
sum=0;
}
for(int i=0;i<n;i++) {
if(v[i]>0) cnt++;
}
cout<<cnt<<endl;
return 0;
}

Measured memory_bytes: 3628
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

void debug(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,y=1e8,count=0;
    cin>>n;
    int a[n];
    for (int i = 0; i <n; ++i)
    {
    	cin>>a[i];
    }
  
    for (int i = 0; i <n; ++i)
    {
    	int x=1<<1;
    	while(a[i]%x==0){
    		x=x<<1;
    		count++;
    	}
    	y=min(y,count);
    	count=0;
    }
    cout<<y<<endl;
    return 0;
  }

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

using namespace std;

int main()
{
    long long a,b;
    cin>>a>>b;
    //cout<<a<<" "<<b<<endl;
    long long c[3];
    c[0]=a+b;
    c[1]=a-b;
    c[2]=a*b;
    long long ans=c[0];
    for(int i=1;i<3;i++)
    {
        if(ans<c[i])
            ans=c[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
import sys
n = int(input())
v = [[], []]
for i, j in enumerate(input().split()):
    if i & 1:
        v[0].append(int(j))
    else:
        v[1].append(int(j))

v1, v2 = Counter(v[0]), Counter(v[1])
mx1 , mx2 = v1.most_common()[0], v2.most_common()[0]
if mx1[0] == mx2[0]:
    if mx1[1] + mx2[1] == n:
        print(n//2)
        sys.exit() 
    nx1, nx2 = v1.most_common()[1][1], v2.most_common()[1][1]# 次に最も多い数
    if nx1 > nx2:
        print(n - nx1 - mx2[1])
    else:
        print(n - mx1[1] - nx2)
else:
    print(n - mx1[1] - mx2[1])
    


Measured memory_bytes: 24084
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    static long[] ans=new long[100001];
     public static void main (String[] args) throws java.lang.Exception {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
    	int test=1;//c.nextInt();
    	while(test-->0){
    		int n=sc.nextInt();
            Map<String,Integer> mp=new HashMap<>();
            for(int i=0;i<n;i++) 
            mp.merge(sc.nextLine(),1,Integer::sum);
                if(mp.containsKey("AC"))
                pw.println("AC x "+mp.get("AC"));
                else pw.println("AC x "+"0");
                if(mp.containsKey("WA"))
                pw.println("WA x "+mp.get("WA"));
                else pw.println("WA x "+"0");
                if(mp.containsKey("TLE"))
                pw.println("TLE x "+mp.get("TLE"));
                else pw.println("TLE x "+"0");
                if(mp.containsKey("RE"))
                pw.println("RE x "+mp.get("RE"));
                else pw.println("RE x "+"0");
            }
        pw.close();
  }
}

  

Measured memory_bytes: 46344
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);} while(0)
  #define trcc(v) do { cerr << "name : " << #v << "\n"; int cnt = 0; each(x , v){cerr << (cnt++) << " : "; trc(x); } } while(0)
#else
  #define trc(...)
  #define trca(...)
  #define trcc(...)
  int main(){solve();}
#endif

#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(s,t)   rep(i,sz(s)){in(s[i] , t[i]);}
#define in3(s,t,u) rep(i,sz(s)){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
//////////////////

void solve(){
  ins(S);
  if(sz(S) == 1) die(1);
  int ans = sz(S);
  rep(i , sz(S) - 1){
    if(S[i] != S[i + 1]){
      amin(ans , max(i + 1 , sz(S) - i - 1));
    }
  }
  out(ans);
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n;
string s;



int main()
{
	
	  cin>>a>>b;
  if(a>b)
  cout<<a-1<<endl;
  else
    cout<<a<<endl;
}


Measured memory_bytes: 256
#import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm


#N = int(input())
#H1,M1,H2,M2,K= map(int,input().split())
A,B = map(int,input().split())
#B = list(map(int,input().split()))
#S= str(input())
print(A*B)


Measured memory_bytes: 9144
object Main extends App {
  val Array(l, r) = scala.io.StdIn.readLine.split(" ").map(_.toLong)

  var min = 2020
  val rr = List(r, l + 4040).min
  (l until rr).foreach { i =>
    (l + 1 to rr).foreach { j =>
      val aa = (i * j) % 2019
      if (aa < min) {
        min = aa.toInt
      }
    }

  }
  println(min)
}


Measured memory_bytes: 112464