akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
  char str[1201];
  int alphabet[26] = {};
  
  while(fscanf(stdin,"%s",str) != EOF){
    for(int i = 0;str[i] != '\0';i++){
      if('A' <= str[i] && str[i] <= 'Z'){
        alphabet[str[i] - 'A']++;
      }else if('a' <= str[i] && str[i] <= 'z'){
        alphabet[str[i] - 'a']++;
      }
    }
  }
  
  for(int i = 0;i < 26;i++){
    printf("%c : %d\n",i+'a',alphabet[i]);
  }
    
  return 0;
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
   int N; cin >> N;
   map<string, int> V;
   for (int i = 0; i < N; i++)
   {   string x; cin >> x;
       V[x] ++;
   }
   cout << V.size() << endl;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    ll n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll res = 0;
    rep(i,n){
        if(i % 2 == 0 && a[i] & 1)res++;
    }
    out(res);
}

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



int main(){
    ll n;cin>>n;
    ll an=0;
    rep(i,1,n+1){
        if(i%3==0||i%5==0)continue;
        an+=i;
    }
    cout<<an<<endl;
}
    









Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct edge {
  int to, cost;
  edge() {}
  edge(int t, int c): to(t), cost(c) {}
};

const ll INF = 1LL << 50;
int N, Q, K;
int a[100010], b[100010], c[100010];
vector<edge> G[100010];
ll dis[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    G[a[i]].emplace_back(b[i], c[i]);
    G[b[i]].emplace_back(a[i], c[i]);
  }
  cin >> Q >> K;
  K--;
  fill_n((ll*)dis, 100010, INF);
  dis[K] = 0;
  queue<int> que;
  que.emplace(K);
  while (!que.empty()) {
    int cur = que.front();
    que.pop();
    for (edge &e : G[cur]) {
      if (dis[e.to] == INF) {
        dis[e.to] = dis[cur] + e.cost;
        que.emplace(e.to);
      }
    }
  }
  for (int i = 0; i < Q; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    cout << dis[x] + dis[y] << endl;
  }

  return 0;
}

Measured memory_bytes: 9972
def main():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        exit(0)
    p = list(map(int, input().split()))
    mx = max(p)
    mn = min(p)
    c = list(set(range(mn-1, mx+2)) - set(p))
    diff = 1000
    ans = 1000
    for i in c:
        if (abs(x-i) < diff) or (abs(x-i) == diff and x < ans):
            diff = abs(x-i)
            ans = i
    print(ans)
    
            
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  int n,k,r,s,p;
  cin >> n>>k;
  cin >> r>>s>>p;
  string t;cin >>t;
  int score = 0;
  string prev="";
  for(int i=0;i<t.size();++i){
    string tmp = t.substr(i,1);
    if(i<k){
      if(tmp =="r") {
        score += p;
        prev += "p";
      } else if(tmp =="s"){
        score += r;
        prev += "r";
      } else {
        score += s;
        prev += "s";
      }
    } else {
      string tmp_p = prev.substr(i-k,1);
      if(tmp =="r") {
        if(tmp_p != "p"){
          score += p;
          prev += "p";
        } else {
          prev += "x";
        }
      } else if(tmp =="s"){
        if(tmp_p != "r"){
          score += r;
          prev += "r";
        } else {
          prev += "x";
        }
      } else {
        if(tmp_p != "s"){
          score += s;
          prev += "s";
        } else {
          prev += "x";
        }
      }
    }
    //cout << score << endl;
  }
  cout << score << endl;
  return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    int cnt = 0;
    rep(i, 0, n) {
        int a;
        cin >> a;
        if (a == cnt + 1) { ++cnt; }
    }

    if (cnt == 0) {
        cout << -1 << endl;
    } else {
        cout << n - cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left

n = int(input())
l = list(map(int,input().split()))

l.sort()
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    count+=bisect_left(l,l[j]+l[i])-j-1
print(count)

Measured memory_bytes: 3188
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string n_str = to_string(n);
    int s = 0;
    for(auto n_char : n_str) s += (int)(n_char - '0');
    cout << (n % s == 0 ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
inline char gc()
{
	static const int SIZE=1<<23;
	static char buf[SIZE],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,stdin),p1==p2)?EOF:*p1++;
}
//#define getchar gc
template<typename T>
inline T read(T &x)
{
	x=0;
	char ch;
	bool flag=false;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar())
		if(ch=='-') flag=true;
	while(ch>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	if(flag) x=-x;
	return x;
}
template<typename T>
inline void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
	return;
}
template<typename T>
inline void writeln(T x)
{
	write(x);
	putchar('\n');
	return;
}
const int N=200005;
int n;
int a[N];
bool isbig(int pos,int k)
{
	return a[pos]>k;
}
int check(int k)
{
	for(int i=0;i<n-1;i++)
	{
		if(isbig(n+i,k)&&isbig(n+i+1,k)) return false;
		if(isbig(n-i,k)&&isbig(n-i-1,k)) return false;
		if(!isbig(n+i,k)&&!isbig(n+i+1,k)) return true;
		if(!isbig(n-i,k)&&!isbig(n-i-1,k)) return true;
	}
	return !isbig(1,k)&&!isbig(1,k);
}
int main()
{
	read(n);
	for(int i=1;i<=2*n-1;i++)
		read(a[i]);
	int l=1,r=2*n-1,ans;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	write(ans);
	return 0; 
}

Measured memory_bytes: 1152
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  bool w;
  int ans = 1;
  if(S[0]=='W') w = true;
  else w = false;
  for(int i=1;i<S.size();++i) {
    if(S[i]=='W') {
      if(!w) {
        ans++;
        w = true;
      }
    }
    else {
      if(w) {
        ans++;
        w = false;
      }
    }
  }
  cout<<ans-1<<endl;
}



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

int main(){
	ll x;
	cin >> x;
	map<ll,int> mp;
	for (ll i = -1000; i <= 1000 ; ++i) {
		mp[i*i*i*i*i] = i;
	}
	for (ll i = -1000; i <= 1000 ; ++i) {
		ll a = i*i*i*i*i;
		ll temp = a - x;
		if(mp[temp] != 0){
			cout << i << " " << mp[temp] << endl;
			return 0;
		}
	}
    return 0;
}



Measured memory_bytes: 3816
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10

vector<int> a;
vector<int> b;
vector<int> support;


int main() {
	int N; cin >> N;
	a.assign(N+1, 0);
	b.assign(N+1, -1);
	support.assign(N + 1, 0);
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	int cnt = N;

	while (cnt > 0) {
		b[cnt] = (a[cnt] + support[cnt]) % 2;
		if (b[cnt] == 1) {
			vector<int> divers;
			for (int i = 1; i*i <= cnt; i++) {
				if (cnt%i == 0) {
					divers.push_back(i);
					if(cnt/i!=i)divers.push_back(cnt/i);
				}
			}
			for (int i = 0; i < divers.size(); i++) {
				support[divers[i]] += 1;
				support[divers[i]] %= 2;
			}

		}
		cnt--;
	}

	int M = 0;
	vector<int> out;
	for (int i = 1; i <= N; i++) {
		if (b[i] == 1) {
			M++;
			out.push_back(i);
		}
	}
	cout << M << endl;
	for (int i = 0; i < out.size(); i++) {
		cout << out[i];
		if (i != out.size() - 1)cout << " ";
	}
	cout << endl;







	return 0;
}


Measured memory_bytes: 3832
#include <iostream>

using namespace std;

int main()
{
    int K, S;
    cin >> K >> S;

    int counter = 0;
    for (int X = 0; X <= K; X++){
        for(int Y = 0; Y <= K; Y++){
            int Z = S - (X + Y);
            if (Z >= 0 && Z <= K) counter++;
        }
    }
    cout << counter << endl;
}


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

int main(){
    std::ios_base::sync_with_stdio(false);
    set<string> st; 
    int n;
    cin >> n;
    while(n--){
        string BUFF,c;
        cin >> BUFF >> c;
        if(BUFF=="insert")st.insert(c);
        else cout << (st.find(c)!=st.end()?"yes":"no") << endl;
    }   
}



Measured memory_bytes: 28952
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
a=gi
puts a+a**2+a**3

Measured memory_bytes: 14268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int tc;
ll x, k, d;
int main()
{
    FIO
    cin>>x>>k>>d;
    ll tmpx = abs(x);
    ll y = tmpx / d;
    // cout<<y<<endl;
    if(y < k)
    {
        if((k - y) %2 == 0)
        {
            cout<<tmpx - y*d<<endl;
        }
        else
        {
            cout<<min(abs(tmpx - (y-1)*d), abs(tmpx - (y+1)*d))<<endl;
        }
    }
    else
    {
        cout<<abs(tmpx - k*d)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define print(x) cout << x << '\n';

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.in", "r", stdin);
    
    int n, X, a;
    int mn;
    cin >> n >> X;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(i == 0) mn = abs(X-a);
        if(i > 0){
            mn = __gcd(abs(X-a), mn);
        }
    }
    cout << mn;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> que = new LinkedList<Integer>();
		while(sc.hasNextInt()) {
			int x = sc.nextInt();
			if(x != 0) que.push(x);
			else System.out.println(que.pop());
		}
	}
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  string s;
  cin>>n;
  cin>>s;
  ll r=0;
  ll l=0;
  rep(i,n){
    if(s[i]=='('){
      r++;
    }
    else if(r>0&&s[i]==')'){
      r--;
    }
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]==')'){
      l++;
    }
    else if(l>0&&s[i]=='('){
      l--;
    }
  }
  vector<char> lll(0),rr(0);
  while(l){
    lll.pb('(');
    l--;
  }
  while(r){
    rr.pb(')');
    r--;
  }
  rep(i,sz(lll)){
    cout<<lll[i];
  }
  cout<<s;
  rep(i,sz(rr)){
    cout<<rr[i];
  }
}
  


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;

		Console.WriteLine("{0}",(n+1)/2-1);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m = MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------// 
void solve(){
   int a, b;
   cin >> a >> b;
   if (a + b == 15) cout << "+" << endl;
   else if ( a * b == 15) cout << "*" << endl;
   else cout << "x" << endl;	
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    ll h, w;
    cin >> h >> w;
    if(h==1 || w==1) cout << 1 << endl;
    else if((h*w)%2 == 0) cout << (h*w)/2 << endl;
    else cout << ((h*w)/2)+1 << endl;
}


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

using namespace std;
typedef long long ll;
const int N = 200010;
int _w;

int n, a[N];
ll ans;

namespace SGT {
	int v[N*4], ql, qr, qv;
	void _init( int o, int L, int R ) {
		if( L == R ) {
			v[o] = L;
		} else {
			int M = (L+R)/2, lc = o<<1, rc = lc|1;
			_init(lc, L, M), _init(rc, M+1, R);
			v[o] = a[v[lc]] < a[v[rc]] ? v[lc] : v[rc];
		}
	}
	void init() {
		_init(1, 1, n);
	}
	void _query( int o, int L, int R ) {
		if( L >= ql && R <= qr ) {
			if( !qv || a[v[o]] < a[qv] )
				qv = v[o];
		} else {
			int M = (L+R)/2, lc = o<<1, rc = lc|1;
			if( ql <= M ) _query(lc, L, M);
			if( qr > M ) _query(rc, M+1, R);
		}
	}
	int query( int l, int r ) {
		ql = l, qr = r, qv = 0;
		_query(1, 1, n);
		return qv;
	}
}

void solve( int L, int R ) {
	if( L > R ) return;
	int M = SGT::query(L, R);
	ans += 1LL * (M-L+1) * (R-M+1) * a[M];
	solve(L, M-1), solve(M+1, R);
}

int main() {
	_w = scanf( "%d", &n );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", a+i );
	SGT::init();
	solve(1, n);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9344
#include<iostream>
#include<string>
using namespace std;
int main(){
   int N,X;
   cin >> N >> X;
   int i;
   int m,min;
   cin>>m;
   min=m;
   X=X-m;
   for(i=1;i<N;i++){
     cin >> m;
     X=X-m;
     if(m<min)min=m;
   }
   cout << N+X/min;
   return 0;
}

Measured memory_bytes: 256
x, y = map(int,input().split())
p = 10 ** 9 + 7
if (x + y) % 3 != 0 or 2*x < y or 2*y < x:
    print(0)
    exit()
a = (2 * y -x) // 3
b = (2 * x -y) // 3

n = a + b
fac = [0] * (n + 1)
fac[0] = 1
for i in range(n):
    fac[i + 1] = fac[i] * (i + 1) % p
def mcomb(n,k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k],p - 2, p) * pow(fac[k], p - 2, p) % p

print(mcomb(n,a))

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    int r;
    cin >> r;
    ppp(3*r*r);

    return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<long long> distance(N, -1);
  vector<vector<pair<int, long long>>> tree(N);
  for(int i = 0; i < N - 1; i++){
    int a, b;
    long long c;
    cin >> a >> b >> c;
    a--; b--;
    
    tree[a].push_back(make_pair(b, c));
    tree[b].push_back(make_pair(a, c));
  }
  
  int Q, K;
  cin >> Q >> K;
  K--;
  
  stack<int> s;
  s.push(K);
  distance[K] = 0;
  while(!s.empty()){
    int node = s.top();
    s.pop();
    for(pair<int, long long> next : tree[node]){
      if(distance[next.first] == -1){
        distance[next.first] = next.second + distance[node];
        s.push(next.first);
      }
    }
  }
  
  while(Q--){
    int x, y;
    cin >> x >> y;
    x--; y--;
    cout << distance[x] + distance[y] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 9984
N=int(input())
D=[0]+list(map(int,input().split()))
D.sort()
for i in range(1,N+1):
  if i&1:
    D[i]=(24-D[i])%24
D.sort()
P=24-D[N]
for i in range(N):
  P=min(P,D[i+1]-D[i])
print(P)

Measured memory_bytes: 38384
// Isaunoya
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
inline int read() {
  register int x = 0 , f = 1 ;
  register char c = getchar() ;
  for( ; ! isdigit(c) ; c = getchar()) if(c == '-') f = -1 ;
  for( ; isdigit(c) ; c = getchar()) x = (x << 1) + (x << 3) + (c & 15) ;
  return x * f ;
}
template < class T > inline bool cmax(T & x , T y) {
  return x > y ? 1 : x = y , 0 ;
}
template < class T > inline bool cmin(T & x , T y) {
  return x < y ? 1 : x = y , 0 ;
}
const int MAXN = 1e6 + 10 ;
const int mod7 = 1e9 + 7 ;
const int mod9 = 1e9 + 9 ;
const int mod = 998244353 ;
inline int QP(int x , int y , int Mod){ int ans = 1 ;
  for( ; y ; y >>= 1 , x = (x * x) % Mod)
    if(y & 1) ans = (ans * x) % Mod ;
  return ans ;
}
vector < int > v ;
inline void io() {
  ios :: sync_with_stdio(false) ;
  cin.tie(0) , cout.tie(0) ;
}
#define int long long
#define MAXN 100005
string s;
int t,n,k;
bool fl = 1;
int a[MAXN],nn;
signed main() {
	cin >> s >> k;
	n = s.size();
	for(int i = 1; i < n; i ++)
		if(s[i] != s[0]) {
			fl = 0;
		}
	if(fl == 1) {
		cout<<k*n/2;
		return 0;
	}
	for(int i = 0; i < n; i ++)
		if(i == 0 || s[i] != s[i-1]) { nn ++; a[nn] = 1;} 
		else { a[nn] ++; }
	int ans = 0;
	if(s[0] == s[n-1]) {
		for(int i = 2; i < nn; i ++)
			ans += a[i]/2*k;
		ans += a[1]/2 + a[nn]/2 + (a[1]+a[nn])/2*(k-1);
	} else {
		for(int i = 1; i <= nn; i ++)
			ans += a[i] >> 1 ;;
		ans *= k;
	}
	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class abc088_a {
public:
    void solve(istream& in, ostream& out) {
        int N, A;
        in >> N >> A;
        out << ((N % 500 > A) ? "No" : "Yes") << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	abc088_a solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;
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;
}

template <std::uint_fast64_t Modulus>
class ModInt {
    using u64 = std::uint_fast64_t;

   public:
    u64 a;

    constexpr ModInt(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr ModInt operator+(const ModInt rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator-(const ModInt rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator*(const ModInt rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator/(const ModInt rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr ModInt &operator+=(const ModInt rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr ModInt &operator/=(ModInt rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};

using mint = ModInt<MOD>;

long long modPow(long long x, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }

    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

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

long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

template <typename T>
using Vec = vector<T>;
template <typename T>
using VVec = vector<vector<T>>;
using LL = long long;
int main() {
    LL a, b, x;
    cin >> a >> b >> x;
    auto f = [](LL n, LL x) {
        if (n == -1) {
            return 0LL;
        } else {
            return n / x + 1;
        }
    };

    cout << f(b, x) - f(a - 1, x) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(){

    long long int n,sum =0;
    scanf("%lld", &n);
    for(int i = 1; i <= n; i++){
    if(i % 3 ==0 || i % 5 == 0){

    }else {
        sum += i;
    }
}
printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 1736
#include<iostream>
using namespace std;
int main() {
	char a, b;
	cin >> a >> b;
	if (a == 'H'&&b=='H') {
		cout << "H" << endl;
	}
	else if (a == 'H' && b == 'D') {
		cout << "D" << endl;
	}
	else if (a == 'D' && b == 'H') {
		cout << "D" << endl;
	}
	else if (a == 'D' && b == 'D') {
		cout << "H" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;


int N, L, Q, x[100000], a, b, p, l[100000][18], r[100000][18];

int fl(int x) {
	if (x == -1) {
		if (a == b) {
			return 0;
		}
		else {
			return 1;
		}
	}
	if (l[a][x] >= b) {
		return fl(x - 1);
	}
	else {
		a = l[a][x];
		return (1 << x) + fl(x - 1);
	}
}
int fr(int x) {
	if (x == -1) {
		if (a == b) {
			return 0;
		}
		else {
			return 1;
		}
	}
	if (r[a][x] <= b) {
		return fr(x - 1);
	}
	else {
		a = r[a][x];
		return (1 << x) + fr(x - 1);
	}
	return 0;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> x[i];
	}
	cin >> L >> Q;
	for (int i = 0; i < N; ++i) {
		for (; p < N && x[p] <= x[i] + L; ++p);
		l[i][0] = p - 1;
	}
	p = N - 1;
	for (int i = N - 1; i >= 0; --i) {
		for (; p >= 0 && x[i] - L<=x[p]; --p);
		r[i][0] = p + 1;
	}
	for (int i = 1; i < 18; ++i) {
		for (int j = 0; j < N; ++j) {
			l[j][i] = l[l[j][i - 1]][i - 1];
			r[j][i] = r[r[j][i - 1]][i - 1];
		}
	}
	while (Q--) {
		cin >> a >> b;
		--a;
		--b;
		if (a < b) {
			cout << fl(17) << endl;
		}
		else {
			cout << fr(17) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k[3],n;
  cin>>k[0]>>k[1]>>k[2]>>n;
  sort(k,k+3);
  reverse(k,k+3);
  int b=k[0];
  for(int i=0;i<n;i++){
    b*=2;
  }
  cout<<b+k[1]+k[2]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;


class UnionFind{
public:
    vector<int> par;
    vector<int> rank;
    UnionFind(int n){
        init(n);
    }
    void init(int n){
        par.resize(n);
        for(int i=0;i<n;i++){
            par[i] = i;
        }
        rank.assign(n, 0);
    }
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

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

    vector<int> A(M), B(M);
    for(int i=0;i<M;i++){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    vector<ll> size(N, 1);
    UnionFind uf(N);

    vector<ll> ans(M);
    for(int i=M-1;i>=0;i--){
        if(uf.same(A[i], B[i])) {
            ans[i] = 0;
        }else{
            ll a_size = size[uf.find(A[i])], b_size = size[uf.find(B[i])];
            ans[i] = a_size * b_size;
            uf.unite(A[i], B[i]);
            size[uf.find(A[i])] = a_size + b_size;
        }
    }
    ll cumsum = 0;
    for(int i=0;i<M;i++){
        cumsum += ans[i];
        cout << cumsum << endl;
    }

    return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,a,b) for(int i=a;i>=b;--i)
#define maxn 110
#define maxk 100010

using namespace std;
const int oo = 1e9 + 7;

int n, k, A[maxn], F[2][maxk], pre[maxk];

inline int mod(const int &x) {
    if (x >= 0) return x;
    return (x + oo);
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	FOR(i, 1, n) cin >> A[i];
    F[0][0] = 1;
    FOR(i, 0, k) pre[i] = 1;
    FOR(i, 1, n) {
        FOR(j, 0, k)
            F[i&1][j] = mod(pre[j] - (j-A[i]-1 >= 0 ? pre[j-A[i]-1] : 0));
        pre[0] = F[i&1][0];
        FOR(j, 1, k) {
            pre[j] = pre[j-1] + F[i&1][j];
            if (pre[j] >= oo) pre[j] -= oo;
        }
    }
    cout << F[n&1][k];
	return 0;
}


Measured memory_bytes: 1408
N,M = map(int, input().split(' '))

list_a = []
for m in range(M):
  list_a.append(list(map(int,input().split(' '))))

list_a.sort()

i = 0
cnt_break = 0
flg = False

while True:
  right = list_a[i][1]
  
  while list_a[i][0] < right:
    if i == M-1:
      flg = True
      break
    
    right = min(right,list_a[i][1])
    i += 1

  cnt_break += 1
      
  if flg:
    break
    
  
print(cnt_break)

Measured memory_bytes: 27884
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=110;
typedef long long LL;

int main() {
	int n,k;
	int d,a;
	bool v[MR];
	memset(v,0,sizeof(v));
	cin>>n>>k;
	for(int i=0;i<k;i++){
		cin>>d;
		for(int j=0;j<d;j++){
			cin>>a;
			v[a]=true;
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(!v[i]) cnt++;
	}
	printf("%d\n",cnt);
    return 0;
}

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

int main(){
	int N,K;
	cin>>N>>K;
	
	string S;
	cin>>S;
	
	if(S[K-1]=='A')
		S[K-1]='a';
	else if(S[K-1]=='B')
		S[K-1]='b';
	else if(S[K-1]=='C')
		S[K-1]='c';
	cout<<S<<endl;
	
	return 0;
	
}

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

const int MaxN=1e5+5;

int N;
int F[MaxN];

vector<int> To[MaxN];

void DFS(int u){
	int i=0;
	for(auto v:To[u])
		DFS(v);
	sort(To[u].begin(),To[u].end(),[](int a,int b){return F[a]>F[b];});
	for(auto v:To[u])
		F[u]=max(F[u],F[v]+(++i));
}

int main(){
	int i,fa;
	scanf("%d",&N);
	for(i=2;i<=N;i++){
		scanf("%d",&fa);
		To[fa].push_back(i);
	}
	DFS(1);
	printf("%d\n",F[1]);
	return 0;
}

Measured memory_bytes: 12288
import functools
import fractions
N,K = map(int,input().split())
A = list(map(int,input().split()))
gcd = functools.reduce(fractions.gcd,A)
max_A = max(A)
if K % gcd == 0 and K <= max_A:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

using namespace std;

int N;
map<long long,int> id;
long long seq[100050];
int sz[100050];
vector<int> v[100050];
long long ans = 0;

void Serval(int pos,int dep,int lst)
{
	ans += dep;
	for(int i = 0;i < v[pos].size(); ++ i)
	{
		int nxt = v[pos][i];
		if(nxt != lst)
			Serval(nxt,dep + 1,pos);
	}
}

int main()
{
	scanf("%d",&N);
	for(int i = 1;i <= N; ++ i)
		scanf("%lld",&seq[i]),id[seq[i]] = i,sz[i] = 1;
	sort(seq + 1,seq + 1 + N);
	for(int i = N;i >= 2; -- i)
	{
		int delta = N - 2 * sz[id[seq[i]]];
		if(delta < 0)
		{
			printf("-1\n");
			return 0;
		}
		long long to_find = seq[i] - delta;
		if(!id.count(to_find))
		{
			printf("-1\n");
			return 0;
		}
		sz[id[to_find]] += sz[id[seq[i]]];
		v[id[seq[i]]].push_back(id[to_find]);
		v[id[to_find]].push_back(id[seq[i]]);
	}
	Serval(id[seq[1]],0,0);
	if(ans != seq[1])
	{
		printf("-1\n");
		return 0;
	}
	for(int i = 1;i <= N; ++ i)
	{
		for(int j = 0;j < v[i].size(); ++ j)
		{
			int nxt = v[i][j];
			if(nxt > i) printf("%d %d\n",i,nxt);
		}
	}
}

Measured memory_bytes: 16640
def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fac[n]*finv[r]*finv[n-r]%p

N = pow(10,6)
MOD = pow(10,9)+7

fac = [-1]*(N+1); fac[0] = 1; fac[1] = 1 #階乗
finv = [-1]*(N+1); finv[0] = 1; finv[1] = 1 #階乗の逆元
inv = [-1]*(N+1); inv[0] = 0; inv[1] = 1 #逆元
for i in range(2,N+1):
  fac[i] = fac[i-1]*i%MOD
  inv[i] = MOD - inv[MOD%i]*(MOD//i)%MOD
  finv[i] = finv[i-1]*inv[i]%MOD


X,Y = map(int,input().split())
if (X+Y)%3 != 0:
  print(0)
  exit()
n = (X+Y)//3
if min(X,Y) < n:
  print(0)
  exit()

ans = cmb(n,min(X,Y)-n,MOD)
print(ans)

Measured memory_bytes: 88084
#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>;
const ll N = pow(10, 9);
 
int main() {
  int n,m,c;
  int ans = 0;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep(i,m) cin >> b[i];
  rep(i,n) {
    int A = 0;
    rep(j,m) {
      int a;
      cin >> a;
      A += a*b[j];
    }
    if (A + c > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    vector<vector<int>> E(N);
    REP(i,N-1) {
        int a,b;
        cin>>a>>b;
        E[a-1].pb(b-1);
        E[b-1].pb(a-1);
    }
    vector<int> Fdist(N,0);
    queue<int> que;
    vector<bool> visited(N,false);
    visited[0] = true;
    que.push(0);
    while (!que.empty()) {
        int now = que.front();
        que.pop();
        REP(i,E[now].size()) {
            if (!visited[E[now][i]]) {
                visited[E[now][i]] = true;
                que.push(E[now][i]);
                Fdist[E[now][i]] = Fdist[now] + 1;
            }
        }
    }

    vector<int> Sdist(N,0);
    REP(i,N) visited[i] = false;
    visited[N-1] = true;
    que.push(N-1);
    while (!que.empty()) {
        int now = que.front();
        que.pop();
        REP(i,E[now].size()) {
            if (!visited[E[now][i]]) {
                visited[E[now][i]] = true;
                que.push(E[now][i]);
                Sdist[E[now][i]] = Sdist[now] + 1;
            }
        }
    }

    int ff = 0, ss = 0;
    for (int i=1;i<N-1;i++) {
        if (Fdist[i] <= Sdist[i]) ff++;
        else ss++;
    }
    if (ff > ss) cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	std::string s; cin >> s;
	bool li[4] = {};
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'N') li[0] = true;
		if(s[i] == 'S') li[1] = true;
		if(s[i] == 'W') li[2] = true;
		if(s[i] == 'E') li[3] = true;
	}
	
	if(li[0] ^ li[1] or li[2] ^ li[3]) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


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

int main(void){
  ll A,B,X=0;
  cin >> A >> B;

  ll i,j,k,l;

  for(j=2;2*B/j!=0;j*=2){
    //Bまでの各桁の1の数,
    k = (B/j) * (j/2);
    if( B%j > (j/2-1) ) k += B%j - (j/2 - 1);
    l = ((A-1)/j) * (j/2);
    if( (A-1)%j > (j/2-1) ) l += (A-1)%j - (j/2 - 1 );
    if( (k-l)%2 == 1 ) X += j/2;
  }
// for(j=1;B/j!=0;j*=2){
//   k=0;
//   FOR(i,B-A+1){
//     //k：各桁の1の数j
//     k += (i+A)/j % 2;
//   }
//   if(k%2 == 1)X += j;
// }
  cout << X << endl;
  return 0;
}

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

int main(int argc, char const *argv[]) {
  size_t n, ans = 0;
  cin >> n;

  // n = k * (m + 1)
  for (size_t k = 1; k * k < n; k++)
    if (n % k == 0 && k < n / k - 1) ans += n / k - 1;  // ans += m;

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include<string>
#include<algorithm>
#include<cmath>
#define REP(i,n) for(int i=0; i<int(n); i++)
using namespace std;
int main() {
	int M1, D1, M2, D2;
	cin >> M1 >> D1 >> M2 >> D2;
	if (M1 != M2 && D1 != D2) {
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        int n, i, j, m, k, p, q, o, l, s, tt = 1;
        Double x,y,z;
        int ar[];
        char ch;
        BigInteger an, su, u, v;
        String a,b="",c="",d;
        Scanner sc = new Scanner(System.in);
        n=sc.nextInt();
        m=sc.nextInt();
        for(i=0;i<n;i++)
        {
            b+=(char)(m+'0');
        }
        for(i=0;i<m;i++)
        {
            c+=(char)(n+'0');
        }
        k=0;
        for(i=0;i<n && i<m;i++)
        {
            p=b.charAt(i)-'0';
            q=c.charAt(i)-'0';
            if(p>q)
            {
                break;
            }
            else if(p<q)
            {
                k=1;
                break;
            }
        }
        if(k==0)
        {
            System.out.println(c);
        }
        else
        {
            System.out.println(b);}




    }
}



Measured memory_bytes: 26924
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	/*string s;
	cin >> s;
	bool ok = true;
	rep(i, 3) {
		if (s[i + 1] == s[i])ok = false;
	}
	if (ok)cout << "Good";
	else cout << "Bad";*/

	int N, L;
	cin >> N >> L;
	int i, m = 1e9;
	for (i = 1; i <= N; i++) {
		if (abs(m) > abs(L + i - 1))m = L + i - 1;
	}
	cout << (N * (2 * L + N - 1)) / 2 - m;
	return 0;
}

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

int getDate(int q,int array[]){
	int max=0,key=0;
	for(int i=0;i<100000;i++){
		if(max<array[i]){
			max = array[i];
			key = i;
		}
	}
	return (max >= q) ? key : 0;
}	


int main(){
	int n,q;
	int array[100000];
	while(1){
		cin >> n >> q;
		if(n+q==0) break;
		for(int i=0;i<100000;i++)
			array[i]=0;
		for(int i=0;i<n;i++){
			int m, date;
			cin >> m;
			for(int j=0;j<m;j++){
				cin >> date;
				array[date]++;
			}
		}
		cout << getDate(q,array) << endl;
	}

}

Measured memory_bytes: 1548
class SparseTable:
    def __init__(self, a, func=max, one=-10**18):
        self.table = [a[:]]
        self.n = len(a)
        self.logn = self.n.bit_length()
        self.func = func
        self.one = one

        for i in map(lambda x: 1 << x, range(self.logn - 1)):
            self.table.append([])
            for j in range(self.n - i * 2 + 1):
                self.table[-1].append(self.func(self.table[-2][j],
                                                self.table[-2][j + i]))

    def get_section(self, i, j):
        length = j - i
        log = length.bit_length() - 1
        if length <= 0:
            return self.one
        a = self.func(self.table[log][i], self.table[log][j - (1<<log)])
        return a


def low(m, x):
    mi = 0
    ma = m - 1
    if ma < 0 or sp.get_section(0, m) <= x:
        return - 1
    while mi != ma:
        mm = (mi + ma) // 2 + 1
        if sp.get_section(mm, m) > x:
            mi = mm
        else:
            ma = mm - 1
    return mi


def high(m, x):
    mi = m
    ma = n - 1
    if m >= n or sp.get_section(m, n) <= x:
        return n
    while mi != ma:
        mm = (mi + ma) // 2
        if sp.get_section(m, mm+1) > x:
            ma = mm
        else:
            mi = mm + 1
    return mi


n = int(input())
p = [int(i) for i in input().split()]

sp = SparseTable(p)

ans = 0
for i in range(n):
    j = low(i, p[i])
    k = low(j, p[i])
    l = high(i, p[i])
    m = high(l+1, p[i])
    ans += p[i] * ((i-j) * (m-l) + (j-k) * (l-i))
print(ans)


Measured memory_bytes: 117964
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
double dp[N][N];

int main()
{
    int n;
    cin >> n;
    vector<double> p;
    for(int i = 0; i < n; ++i)
    {
        double a;
        cin >> a;
        p.push_back(a);
    }
    dp[0][0] = 1.0;
    for(int i = 1; i <= n; ++i)
    {
        for(int j = 0; j <= i; ++j)
        {
            if(j == 0)
            {
                dp[i][j] = dp[i-1][j]*(1 - p[i-1]);
            }
            else
            {
                dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1 - p[i-1]);
            }
        }
    }
    // for(int i = 0; i <= n; i++)
    //     for(int j = 0; j <= n; ++j)
    //         cout << dp[i][j] << " \n"[j == n];
    

    double ans = 0;
    for(int j = n; j > n/2; --j)
    {
        ans += dp[n][j];
    }
    cout << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 49960
import math
import fractions

n, m = map(int, input().split())
ac_list = [0 for _ in range(n)]
wa_list = [0 for _ in range(n)]
wa_cnt = 0
cnt = 1
while cnt <= m:
    p, s = input().split()
    p = int(p)
    if s == "AC":
        ac_list[p - 1] = 1
    else:
        if ac_list[p - 1] == 0:
            wa_list[p - 1] += 1
    cnt += 1
for i in range(n):
    if wa_list[i] >= 1 and ac_list[i] == 1:
        wa_cnt += wa_list[i]
print(sum(ac_list), wa_cnt)



Measured memory_bytes: 6904
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

int N,H;
int a, ma, b[100010];
int cnt;
int main() {
    cin>>N>>H;
    REP(i, 0, N){
        cin>>a>>b[i];
        ma=max(a,ma);
    }
    sort(b,b+N);
    RREP(i,0,N){
        if(H<=0||b[i]<=ma) break;
        H-=b[i];
        cnt++;
    }
    if(H>0) cnt += (H+ma-1)/ma;
    p(cnt);
    return 0;
}

Measured memory_bytes: 640