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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}

int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

// 最大公約数
ll gcd(ll a, ll b) {
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }

  sort(begin(ret), end(ret));
  return (ret);
}

bool IsPrime(ll num) {
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
    {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}

int main() {
  ll A, B; cin >> A >> B;
  ll gc = gcd(A, B);
  auto d = divisor(gc);
  ll ans = 0;
  for(int i = 0; i < d.size(); ++i) {
    if(IsPrime(d[i])) ans++;

  }
  cout << ans + 1 << endl;
}

Measured memory_bytes: 384
n = int(input())
a = input().split()
a = [int(m) for m in a]
xyli = []
for i in range(n - 1):
    if i == 0:
        snu = a[i]
        ara = sum(a) - a[i]
        xyli.append(abs(snu - ara))
    else:
        snu += a[i]
        ara -= a[i]
        xyli.append(abs(snu - ara))
print(min(xyli))

Measured memory_bytes: 24936
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define pb push_back
#define pob pop_back
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define all(x) x.begin(), x.end()
#define M_PI 3.14159265358979323846
#define epsilon (double)(0.00000000001)
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
    return;
}
ll powe[200005];
void power()
{
    powe[0]=1;
    REP(i,1,200005)
    {
        powe[i]=mymod(2*powe[i-1],num);
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
}
ll n; 
struct node
{
	vll adj;
    ll dist;
   // ll max_depth;
    ll cwgd;
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    REP(i,0,m)
    {
        ll a;
        cin>>a;
        sum+=a;
    }
    cout<<((sum>n)?-1:n-sum)<<endl;
	return 0;
}

Measured memory_bytes: 3656
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def _make_prime_numbers(N: int):
    # N以下の素数を列挙 -> set
    # まずエラトステネスの篩を作成
    is_prime = [True] * (N + 1)
    is_prime[0] = False  # 0と1は素数ではない
    is_prime[1] = False
    for i in range(2, int(N ** 0.5) + 1):
        if is_prime[i]:
            for j in range(i * 2, N + 1, i):  # iの倍数は素数でない
                is_prime[j] = False

    primes = []
    for i, flg in enumerate(is_prime):
        if flg:
            primes.append(i)

    return primes


primes = _make_prime_numbers(10**6)


from bisect import bisect_left


def fast_factorization(N: int):
    # -> List[Tuple[int,int]] (素数,冪数)を格納
    # 素数配列primesを使ってO(log N)で因数分解
    if N == 1:
        return []  # 1は素数ではない
    # 素因数分解
    arr = []
    temp = N
    for p in primes[:bisect_left(primes, N**(1 / 2)) + 1]:
        if temp % p == 0:
            cnt = 0
            while temp % p == 0:
                cnt += 1
                temp //= p
            arr.append((p, cnt))
            if temp == 1:  # 早期終了
                break

    if temp != 1:  # √Nより大きい素因数はたかだか1個ある
        arr.append((temp, 1))
    if arr == []:  # 自身が素数だった場合
        arr.append((temp, 1))

    return arr


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from math import gcd


N = a_int()
A = ints()

# setかはすぐわかる
# setでなければ not coprime
# pairは互いに素かをみればいいのか
# つまり因数分解して足してったときにすべての素数のべき数が1以下であれば良い

g_set = 0
cnt = defaultdict(lambda: 0)
flg = 1  # pairwiseであるフラグ
for a in A:
    g_set = gcd(g_set, a)
    if flg:
        for p, n in fast_factorization(a):
            if cnt[p] != 0:
                flg = 0
            cnt[p] += n


# print(cnt)
# for v in cnt.values():
#     if v > 1:
#         flg = 0
#         break

if g_set > 1:
    print('not coprime')
elif flg:
    print('pairwise coprime')
else:
    print('setwise coprime')


Measured memory_bytes: 192104
#include<bits/stdc++.h>
#include<random>
#include<algorithm>
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
 
 
int main(){
  int N;
  cin >> N;
 
  map<string,int> s;
 
  rep(i,N){
    string temp;
    cin >> temp;
    auto result = s.find(temp);
    if(result == s.end()){
      s.insert(make_pair(temp,0));
    }
    else{
      s[temp] = s[temp] + 1;
    }
  }
  
  multimap<int,string,greater<int>> s2;
  for(auto i =s.begin(); i != s.end() ; i++) s2.insert(make_pair(i->second,i->first));

  multimap<int,string>::iterator i = s2.begin();
  int temp = i->first;
  vector<string> answer;
  for(; i != s2.end() ; ++i){
    if(i->first != temp) break;
    else answer.push_back(i->second);
  }

  sort(answer.begin(),answer.end());
  rep(i,answer.size()) cout << answer.at(i) << endl;

 
  return 0;
}


Measured memory_bytes: 41200
#include<stdio.h>
int main(){
	int n,a[100000],i,max=-100000,min=10000000000;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	
	for(i=0;i<n;i++){
		if(a[i]>max)max=a[i];
		if(min>a[i])min=a[i];
	}
	
	printf("%d\n",max-min);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb emplace_back
typedef pair<int,int> pi;

int idx[3];
string a,b,c;

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cin >> a >> b >> c;
	char cur = 'a';
	while (1) {
		if (cur == 'a') {
			if (a.size() == idx[0]) {
				cout << 'A';
				break;
			}
			cur = a[idx[0]];
			++idx[0];
		} else if (cur == 'b') {
			if (b.size() == idx[1]) {
				cout << 'B';
				break;
			}
			cur = b[idx[1]];
			++idx[1];
		} else if (cur == 'c') {
			if (c.size() == idx[2]) {
				cout << 'C';
				break;
			}
			cur = c[idx[2]];
			++idx[2];
		}
	}
	return 0;
}


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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    // 57

    ll N,f=0;
    cin >> N;
    int n = N;
    while(n!=0){
        f += n%10;
        n /=10;
    }

    if(N%f == 0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}

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

public class Main {
	public static void main (String[] args) {
	   InputReader in = new InputReader(System.in);
	   int n = in.readInt();
	   int arr[] = new int[n]; 
	   int sum = 0; 
	   for(int i = 0; i<n; i++) {
		   arr[i] = in.readInt();
		   sum += arr[i]; 
	   }
	   Arrays.sort(arr);
	   if(sum % 10 != 0) {
		   System.out.println(sum); 
		   return; 
	   }
	   int result = 0; 
	   for(int i = 0; i<n; i++) {
		   if((sum - arr[i])%10 != 0) {
			   System.out.println( sum - arr[i]);  
			  return ; 
		   }
	   }
	   System.out.println(0);
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 23380
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        //System.out.println("Enter first string ");
        String s1 = s.next();
        //System.out.println("Enter second string ");
        String s2 = s.next();
        System.out.println(s2.concat(s1));
    }
}

Measured memory_bytes: 22484
//TLEになってしまった

#include<iostream>
#include<vector>
#include<utility>
using namespace std;
#define INF 1000000000

void dfs(vector< vector<int> >& rel,vector<int>& v,int c,int k){
  int l=rel[k].size();
  for(int i=0;i<l;i++){
    if(v[rel[k][i]]==0){
      v[rel[k][i]]=c;
      dfs(rel,v,c,rel[k][i]);
    }
  }
}


int main(){
  int n,m;cin >> n >> m;
  vector<int> v(n,0);//番号を記録(訪問済みでない場合は0)
  vector< vector<int> > rel(n);//隣接リスト

  //隣接リスト、Nodeの行列を作る必要ない
  for(int i=0;i<m;i++){
    int x,y;cin >> x >> y;
    rel[x].push_back(y);rel[y].push_back(x);
  }

  int col=0;
  for(int i=0;i<n;i++){
    if(v[i]==0){
      col++;
      dfs(rel,v,col,i);
    }
  }

  int q;cin >>q;
  for(int i=0;i<q;i++){
    int s,t;cin >> s >> t;
    //非連結だと0だろ
    if(v[s]==0 or v[s]!=v[t]) cout << "no" << endl;
    else cout << "yes" << endl;
  }
  # if 0
  for(int i=0;i<n;i++){cout <<  v[i] << " ";}
  cout << endl;
  # endif
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/10/23  Problem: ARC 100 C / Link: http://arc100.contest.atcoder.jp/tasks/arc100_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----

bitのsubst

----解説ここまで---- */

template<typename F>
vector<typename F::t> ZetaTransformSubset(const int n, const vector<typename F::t>& A) {
	using T = typename F::t;
	vector<T>a = A;
	for (int i = 0; i < n; i++) {
		for (int s = 0; s < 1 << n; s++) {
			if ((s >> i & 1) == 1)
				a[s] = F::op(a[s], a[s ^ (1 << i)]);
		}
	}
	return a;
}


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

	int N; cin >> N;
	int M = 1 << N;
	vector<PII> a(M);
	FOR(i, 0, M) {
		cin >> a[i].first; a[i].second = 0;
	}
	struct F {
		using t = PII;
		F() {}
		static t op(const t& a, const t& b) {
			t ret;
			int x[4];
			x[0] = a.first, x[1] = a.second, x[2] = b.first, x[3] = b.second;
			sort(x, x + 4);
			ret.first = x[3], ret.second = x[2];
			return ret;
		}
	};
	vector<PII> b = ZetaTransformSubset<F>(N, a);

	int ans = 0;
	FOR(i, 1, M) {
		ans = max(ans, b[i].first + b[i].second);
		cout << ans << "\n";
	}

	return 0;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int c[1000005];
int v1[1000005];
int solve(){
    int n,a,b; cin>>n>>a>>b;
    cout<<min(n*a,b);
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

n,w=map(int,input().split())
dp=[0]*(w+1)
c,p=map(int,input().split())
dp[c]=p

def ans(n,w):
  for _ in range(1,n):
    c,p=map(int,input().split())
    for j in range(w,c,-1):
      if dp[j-c] != 0 and dp[j]<dp[j-c]+p:
        dp[j]=dp[j-c]+p
    if dp[c] < p:
      dp[c]=p
  return max(dp)
print(ans(n,w))


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

#define int long long
#define all(V) (V).begin(),(V).end()
#define umap unordered_map
#define uset unordered_set
#define br cout<<"\n";

const int MAXN=1e5+10, MOD=1e9+7;
int n,m;
int arr[MAXN];
int t[5*MAXN],lazy[5*MAXN];

int doit(int a,int b){
	return a+b;
}

void build(int start,int end,int index=1){
	if(start==end){
		t[index]=0;
		return ;
	}
	int mid = start+end >> 1;
	build(start,mid,index << 1);
	build(mid+1,end,index<<1|1);
	t[index] = doit(t[index<<1], t[index<<1|1]);
}

void propagate(int start,int end,int index){
	t[index] += (end-start+1)*lazy[index];
	// bcz leaf not hv childs
	if(start!=end){
		lazy[index<<1] += lazy[index];
		lazy[index<<1|1] += lazy[index];
	}
	lazy[index]=0;
}

int Query(int start,int end,int l,int r,int index=1){
	
	if(lazy[index]!=0){
		propagate(start,end,index);
	}
	// out range
	if(r<start or end<l){
		return 0;
	}
	// in Raange
	if( l<=start and end<=r){
		return t[index];
	}
	int mid = start+end >>1;
	return doit(Query(start,mid,l,r,index<<1), Query(mid+1,end,l,r,index<<1|1));
}

void pUpdate(int start,int end,int point,int val,int index=1){
	if(start==end){
		t[index]+=val;
		return ;
	}
	int mid = start+end>>1;
	if(point <= mid){
		pUpdate(start,mid,point,val,index<<1);
	}
	else{
		pUpdate(mid+1,end,point,val,index<<1|1);
	}
	t[index] = doit(t[index <<  1] , t[index << 1 | 1]);
}


void rangeUpdate(int start,int end,int l,int r,int val,int index){
	if(l>end or r<start){
		return;
	}
	// in range
	if(l<=start and end<=r){
		lazy[index]+=val;
		return;
	}
	int mid = start+end>>1;
	rangeUpdate(start,mid,l,r,val,index<<1);
	rangeUpdate(mid+1,end,l,r,val,index<<1|1);
	t[index] = doit(t[index<<1],t[index<<1|1]);
}




signed main()
{
// 	#ifndef ONLINE_JUDGE
// 		freopen("./input.txt","r",stdin);
// 		freopen("./output.txt","w",stdout);
// 	#endif
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cin>>n>>m;
	build(0,n-1);
	for(int i=1; i<=m; i++){
		int q; cin>>q;
		if(q==1){
			int t; cin>>t;
			cout<<Query(0,n-1,t-1,t-1,1); br;
		}
		else{
			int s,t,x; cin>>s>>t>>x;
			rangeUpdate(0,n-1,s-1,t-1,x,1);
		}
	}	

}


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

int main()
{
	int a,b,c;
	cin>>a>>b;
	if (b/100==1) c=a*1000+b;
	else if (b/10>0) c=a*100+b;
	else c=a*10+b;
	if ((int)sqrt(c)*(int)sqrt(c)==c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import functools as ft

def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a

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

	max_num = max(nums)
	g = ft.reduce(lambda x, y: gcd(x, y), nums)

	if K <= max_num and K % g == 0:
		print("POSSIBLE")
	else:
		print("IMPOSSIBLE")

if __name__ == '__main__':
	main()

Measured memory_bytes: 14596
def query_sum(bit, idx):
    sum_ = 0
    while idx > 0:
        sum_ += bit[idx]
        idx -= idx & -idx
    return sum_


def add_sum(bit, idx, value):
    """
    add value to a[i].
    """
    while idx <= len(bit):
        bit[idx] += value
        idx += idx & -idx


S = input()
bit = [0] * (len(S) + 1000)
num_whites = 0
for i, char in enumerate(S, start=1):
    if char == "W":
        add_sum(bit, i, 1)
        num_whites += 1


num_flips = 0
for i, char in enumerate(S, start=1):
    if char == "B":
        this_num_flips = num_whites - query_sum(bit, i)
        num_flips += this_num_flips

print(num_flips)


Measured memory_bytes: 4968
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define PB push_back
#define loop(i,x,y) for(int i=x;i<y;i++)
#define rloop(i,x,y) for(int i=x;i>y;i--)
#define NL cout<<"\n"
#define ans(x) cout<<x<<"\n"
#define out(x) cout<<x<<" "
#define F first
#define S second
#define ansf(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
  string s[]={"MON", "TUE", "WED", "THU", "FRI","SAT","SUN"};
  std::map<string,int> mp;
  loop(i,0,7)
    mp[s[i]]=i+1;
  string ss;
  cin>>ss;
  int x=mp[ss]%7;
  ans(7-x);

}
signed main()
{
  // FAST;
  int T=1;
  // cin>>T;
  while(T--) solve();
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
odd = 0
even2 = 0
even4 = 0
for x in a:
    if x % 2 == 1:
        odd += 1
    elif x % 4 == 0:
        even4 += 1
    else:
        even2 += 1
if even4 - odd > -1:
    print('Yes')
elif even4 - odd == -1 and even2 == 0:
    print('Yes')
else:
    print("No")


Measured memory_bytes: 15020
#include <stdio.h>

int main(void)
{

	char  I[1000]="\0";
	char  O[1000]="\0";
	int B;

	scanf("%s",I);
	scanf("%d",&B);

	int i=0;

	while(I[i*B]!='\0' && i*B < 1000){
		O[i]=I[i*B];
		i++;
	}
	
	printf("%s",O);

	
	return 0;
}



Measured memory_bytes: 128
import java.awt.geom.*;
import java.util.*;
public class Main {
	//0352 start
	//0405 cording end
	//0406 WA
	//0408 AC 00:09sec 1445byte
	private void doit() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- > 0){
			String str = sc.next();
			Parse p = new Parse(str);
			int res = p.exp();
			System.out.println(res);
		}
	}
	
	class Parse{
		String str;
		int pos;
		public Parse(String str){
			this.str = str;
			pos = 0;
		}
		
		private int exp() {
			int res = term();
			while(true){
				char op = str.charAt(pos);
				if((op == '+') || (op == '-')){
					int old = res;
					pos++;
					res = term();
					switch(op){
					case '+': 
						res = old + res;
						break;
					case '-':
						res = old - res;
						break;
					}
				}
				else{
					break;
				}
			}
			return res;
		}

		private int term() {
			int res = fact();
			while(true){
				char op = str.charAt(pos);
				if((op == '*') || (op == '/')){
					int old = res;
					pos++;
					res = fact();
					switch(op){
					case '*':
						res = old * res;
						break;
					case '/':
						res = old / res;
						break;
					}
				}
				else{
					break;
				}
			}
			return res;
		}

		private int fact() {
			if(Character.isDigit(str.charAt(pos))){
				int t = str.charAt(pos) - '0';
				pos++;
				while(Character.isDigit(str.charAt(pos))){
					t = t * 10 + (str.charAt(pos) - '0');
					pos++;
				}
				return t;
			}
			else if(str.charAt(pos) == '('){
				pos++;
				int res = exp();
				pos++;
				return res;
			}
			return 0;
		}
	}

	

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

Measured memory_bytes: 12000
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

S=input()
T=input()

dT = dict()
dS = dict()

for i,t in enumerate(T):
    if t not in dT:
        dT[t] = [i]
    else:
        dT[t].append(i)
for i,s in enumerate(S):
    if s not in dS:
        dS[s] = [i]
    else:
        dS[s].append(i)

def ans():
    for c in map(chr,range(ord('a'),ord('z')+1)):
        if c in dT:
            res = S[dT[c][0]]
            for i in dT[c]:
                if res != S[i]:
                    return 0
    for c in map(chr,range(ord('a'),ord('z')+1)):
        if c in dS:
            res = T[dS[c][0]]
            for i in dS[c]:
                if res != T[i]:
                    return 0
    return 1

yn(ans())
    


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

int main()
{
	int n,i,j,k=0;
	cin>>n;
	j=n;
	while(j!=0)
	{
	   k=k+j%10	;
	   j/=10;
	}
	if(n%k==0) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)

int main(){
  int x;

  rep(i, 5){
    cin >> x;
    //cout << x << i << endl;
    if (x == 0){
      cout << i+1 << endl;
    }
  }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, k;
    cin >> n >> k;
    vint h(n);
    rep(i, n) cin >> h[i];

    sort(rall(h));

    ll ans = 0;
    rep(i, n) {
        if (k > 0) --k;
        else {
            ans += h[i];
        }
    }

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

Measured memory_bytes: 1152
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <numeric>

using namespace std;

int main(void)
{
	bool wusage[3001] = { false, };
	bool susage[3001] = { false, };
	int a, b, c, d, e, f;
	int sw = 0, s = 0;
	double per = -1;
	cin >> a >> b >> c >> d >> e >> f;

	wusage[0] = true;
	for (int i = 0; i <= f; i+=100)
	{
		if (wusage[i] == true)
		{
			if (i + 100 * a <= f)
			{
				wusage[i + 100 * a] = true;
			}
			if (i + 100 * b <= f)
			{
				wusage[i + 100 * b] = true;
			}
		}
	}

	susage[0] = true;
	for (int i = 0; i <= f; i++)
	{
		if (susage[i] == true)
		{
			if (i + c <= f)
			{
				susage[i + c] = true;
			}

			if (i + d <= f)
			{
				susage[i + d] = true;
			}
		}
	}

	for (int a = 100; a <= f; a += 100)
	{
		for (int b = 0; b <= f-a; b++)
		{
			if ((wusage[a] == true && susage[b] == true) && b <= a/100*e)
			{
				if (per < 1.0*b / (a + b))
				{
					per = 1.0*b / (a + b);
					sw = a + b;
					s = b;
				}
			}
		}
	}

	cout << sw << ' ' << s << endl;
	return 0;

}

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

int main() {
	
	int H, W, h, w;
	
	cin >> H >> W >> h >> w;
	
	cout << H * W - h * W - (H - h) * w << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#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 P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
int cnt[1010];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	for (int i = n; i >= 1; i--) {
		for (auto p : prime_factor(i)) {
			while (p.second--)cnt[p.first]++;
		}
	}
	int ans = 1;
	rep(i, 1010) {
		ans *= cnt[i] + 1; ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
	long N, K;
	cin >> N >> K;

	long digitCount = 1;
	while (true)
	{
		long calcNum = pow(K, digitCount);
		if (calcNum > N)
		{
			break;
		}
		digitCount++;
	}

	cout << digitCount << endl;
	return 0;
}

Measured memory_bytes: 3524
import sys
# -*- coding: utf-8 -*-
# 	入力
n=int(input())
t=0
x=0
y=0
s="Yes"
for i in range(n):
  t1,x1,y1=map(int,sys.stdin.readline().split())
  if abs(x1-x)+abs(y1-y) > (t1-t):
    s="No"
    break
  if ((x1 + y1) % 2) == (t1 % 2):
    x=x1
    y=y1
    t=t1
  else:
    s="No"
    break
# 出力
print(s)

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;

  if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
    cout << 0 << endl;
    return 0;
  }

  if(a == b && b == c){
    cout << -1 << endl;
    return 0;
  }

  int count = 0;
  while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
    int na = b / 2 + c / 2;
    int nb = a / 2 + c / 2;
    int nc = a / 2 + b / 2;
    a = na; b = nb; c = nc;
    ++count;
  }

  cout << count << endl;

  return 0;
}


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

int main(){
	int n;
	cin>>n;
	int a[n+1],b[n];
	for(int i=1;i<n;i++){
		cin>>b[i];
	}
	a[1]=b[1];
	for(int i=2;i<n;i++){
		a[i]=min(b[i-1],b[i]);
	}
	a[n]=b[n-1];
	int s=0;
	for(int i=1;i<=n;i++){
		s+=a[i];
	} 
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}


int N, A, X[55];
map< int, lint > dp[55];

int main() {
	cin >> N >> A;
	
	for_(i,0,N) {
		cin >> X[i];
		X[i] -= A;
	}
	
	dp[0][0] = 1;
	
	for_(i,0,N) {
		for (pair< int, lint > p : dp[i]) {
			int j = p.first;
			lint c = p.second;
			
			dp[i + 1][j] += c;
			dp[i + 1][j + X[i]] += c;
		}
	}
	
	cout << dp[N][0] - 1 << endl;
}

Measured memory_bytes: 1664
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

x = int(input())
ans = 0
k = make_divisors(x)
for i in k:
    j = x//i
    l, r = 0, x
    flag = False
    while r-l > 1:
        key = (r+l)//2
        a, b = key+i, key
        if a**4+a**3*b+a**2*b**2+a*b**3+b**4 == j:
            ans = (a, b)
            flag = True
            break
        elif(a**4+a**3*b+a**2*b**2+a*b**3+b**4) > j:
            r = key 
        else:
            l = key
    if flag:
        break
    a, b = l+i, l
    if a**4+a**3*b+a**2*b**2+a*b**3+b**4 == j:
        ans = (a, b)
        flag = True
        break
    a, b = r+i, r
    if a**4+a**3*b+a**2*b**2+a*b**3+b**4 == j:
        ans = (a, b)
        flag = True
        break

if ans == 0:
    for i in range(1, 100):
        for j in range(1, 100):
            if i**5+j**5 == x:
                ans = (i, -j)
                break
        if ans != 0:
            break
    pass

print(*ans)

Measured memory_bytes: 9564
#include<iostream>
using namespace std;
int main()
{
    int i,n,k;
    cin>>n>>k;
    int a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n-k;i++)
    {
        if(a[i]<a[k+i])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}


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

const int N = 1e5 + 10 , M = 5e5+10 ,  MOD = 1e9+7;
const int OO = 0x3f3f3f3f;
const double EPS = 1e-3;

#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define F first
#define S second
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 

int a, b;



int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	

    cin >> a >> b;

    if(a>=13)
        cout << b <<"\n";
    else if(a>=6 && a<= 12)
        cout << b/2 << "\n";
    else 
        cout << 0 << "\n";
    
 


    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <ctime>
#include <climits>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    double x = 0, y = 0;
    double deg = 90;
    const double PI = atan(1.0) * 4.0;

    int a, b;
    char c;
    while (cin >> a >> c >> b && (a || b)) {
        x += a * cos(deg * PI / 180.0);
        y += a * sin(deg * PI / 180.0);
        deg = deg - b;
    }
    cout << (int)x << endl;
    cout << (int)y << endl;

    return 0;
}

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

typedef long long ll;

int main() {

	int n, k, q;
	scanf("%d%d%d", &n, &k, &q);
	vector<int> scores(n, k - q);

	for (int i = 0; i < q; i++) {
		int a; scanf("%d", &a);
		scores[a - 1] += 1;
	}

	for (int i = 0; i < n; i++) {
		if (scores[i] > 0)
			printf("Yes\n");
		else 
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define Num 1001
int main () {
    char str[Num];
    int cou[100]={0};
    int i,j;
    
    //複数行に渡る文字列をload
    while (fgets (str,sizeof(str),stdin) != NULL) {
        for (i = 0;i < Num;i ++) { //read str[i]
            for (j = 0;j < 26;j ++) { //j=0 -> a
                if (str[i] - 'a' - j == 0 || str[i] - 'A' - j == 0) {
                    cou[j] ++;
                }
            }
            if (str[i] == '\0') { //after reading str
                break;
            }
        }
    }
    for (i = 0 ;i < 26;i ++) {
        printf ("%c : %d\n",'a' + i,cou[i]); //%c
    }
    
    
    return 0;
}


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

#define LL long long

bool cmp(pair<int,int>a, pair<int,int>b) {return a.first < b.first;}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n, x, y; cin >> n;
    vector<pair<int,int>> v;
    for(int i = 0; i < n; i++) {
        cin >> x >> y;
        v.push_back({y, x});
    }   

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

    LL cur = 0;
    for(int i = 0; i < n; i++) {
        cur += v[i].second;
        if(cur > v[i].first) return cout << "No", 0;
    }
    cout << "Yes";
}

Measured memory_bytes: 5256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/9
Solved on 2019/3/9
@author: shinjisu
"""


# ABC 121
# import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**12


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def prob_B():
    N, M, C = getIntList()
    dmp((N, M, C))
    B = getIntList()
    dmp(B)
    count = 0
    for i in range(N):
        res = C
        A = getIntList()
        for j in range(M):
            res += A[j]*B[j]
        dmp(res, 'res')
        if res > 0:
            count += 1
    return count


debug = False  # True False
ans = prob_B()
print(ans)
#for row in ans:
#    print(row)


def prob_C():
    S = input()
    red = 0
    blue = 0
    for cube in S:
        if cube == '0':
            red += 1
        else:
            blue += 1
    dmp((red, blue))
    return min(red, blue)*2


def prob_D():
    global N, M, A, B
    N, M = getIntList()
    dmp((N, M))
    A = zeros(M)
    B = zeros(M)
    for i in range(M):
        A[i], B[i] = getIntList()
    dmp(A, 'A')
    dmp(B, 'B')
    count = dmp(countInconv(), 'orginal')
    for i in range(M):
        A[i] = -1
        B[i] = -1
        dmp(A, 'A')
        dmp(B, 'B')
        print(countInconv())
    return count


def prob_A():
    H, W = getIntList()
    h, w = getIntList()
    dmp((H, W))
    dmp((h, w))
    ans = (H-h)*(W-w)
    return ans




Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <vector>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int count = 0;
    for(int i = 0;i < N;i++){
        cin >> a.at(i);
        if(i%2==0){
            if(a.at(i)%2==1){
                count++;
            }
        }
    }
    cout << count << endl;
    
    
    
    
    
    
}

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

#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
//long long mod=1000000007;
//int count=INT_MAX;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
int isPal(string a,string b){
    int n=a.size();
    fori(0,n){
        if(a[i]!=b[i]) return 0;
        
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    //cout<<t;
    //scanf("%d",&t);
    while(t--){
        char c;
        cin>>c;
        if(c>='a'&&c<='z'){
            cout<<"a"<<endl;
        }
        else{
            cout<<"A"<<endl;
        }
        

    }
    
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n,m; cin >> n >> m;
    cout << (n*(n-1) + m*(m-1))/2 << endl;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]
diff = A - B

def enough(t):
    counter = 0
    for h in H:
        if h > B*t: counter += ((h - B*t) + diff - 1 ) // diff
    return True if counter <= t else False

left, right = 0, (max(H) + B - 1)// B
while right - left > 1:
    mid = (left + right) // 2
    if enough(mid): right = mid
    else: left = mid
print(right)

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << endl;
  return 0;
}


Measured memory_bytes: 256
n  = int(input())
aa = [int(i) for i in input().split()]

aa = sorted(aa)

a, b, is_a = 0, 0, True
while len(aa) != 0:
    if is_a:
        a += aa.pop(-1)
        is_a = False
    else:
        b += aa.pop(-1)
        is_a = True

print(a-b)

Measured memory_bytes: 3060
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
typedef long long  ll;
int main()
{
int n;
cin>>n;
ll sum=0;
ll b[n-1]={0};
for(int i=0;i<n-1;i++)
    cin>>b[i];
sum=b[0];
for(int i=1;i<n-1;i++)
    sum+=min(b[i-1],b[i]);
    sum+=b[n-2];
    cout<<sum;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	string s,t; cin>>s>>t;
	vector<ll> M(26,100);
	rep(i,s.sz){
		ll tmp=s[i]-'a';
		if(M[tmp]==100){
			M[tmp]=t[i]-'a';
		}
		else if(M[tmp]!=t[i]-'a'){
			cout<<"No";
			return 0;
		}
	}
	sort(M.bg,M.ed);
	ll mem=M[0];
	rep1(i,25){
		if(M[i]==100) break;
		else if(M[i]==mem){
			cout<<"No";
			return 0;
		}
		mem=M[i];
	}
	cout<<"Yes";
}

Measured memory_bytes: 776
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int H,W;
string s[20];
int dir[5]={0,1,0,-1,0};
vector<vector<int> >calc(int sx,int sy)
{
	vector<vector<int> >d(H,vector<int>(W,1e9));
	d[sx][sy]=0;
	queue<pair<int,int> >P;
	P.push(make_pair(sx,sy));
	while(!P.empty())
	{
		int x=P.front().first,y=P.front().second;
		P.pop();
		for(int r=0;r<4;r++)
		{
			int tx=x+dir[r],ty=y+dir[r+1];
			if(tx<0||ty<0||tx>=H||ty>=W||s[tx][ty]=='#'||d[tx][ty]<=d[x][y]+1)continue;
			d[tx][ty]=d[x][y]+1;
			P.push(make_pair(tx,ty));
		}
	}
	return d;
}
main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)cin>>s[i];
	int ans=0;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		if(s[i][j]=='#')continue;
		vector<vector<int> >d=calc(i,j);
		for(int I=0;I<H;I++)for(int J=0;J<W;J++)
		{
			if(s[I][J]!='#')ans=max(ans,d[I][J]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String[] dimention = sc.nextLine().split(" ");
      int n = Integer.parseInt(dimention[0]);
      int m = Integer.parseInt(dimention[1]);
      
      //declaration of matrices
      int[][] matrix_1 = new int[n][m];
      int[] matrix_2 = new int[m];
      int[] answer = new int[n];
      
      //initialization of matrix_1
      for (int row = 0; row < n; row ++) {
         String[] input = sc.nextLine().split(" ");
         for(int col = 0; col < m; col ++) {
            matrix_1[row][col] = Integer.parseInt(input[col]);
         }
      }
      
      //initialization of matrix_2
      for (int i = 0; i < m; i ++) {
         matrix_2[i] = Integer.parseInt(sc.nextLine());
      }
      
      //calculation
      for (int row = 0; row < n; row ++) {
         int temp = 0;
         for (int col = 0; col < m; col ++) {
            temp += matrix_1[row][col] * matrix_2[col];
         }
         answer[row] = temp;
      }
      
      //print out
      for(int i = 0; i < n; i ++) {
         System.out.println(answer[i]);
      }
      
   }
}


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

int main() {
	int a,b,c,d,e;
	cin >> a;
	b=a/3600;
	c=a%3600;
	d=c/60;
	e=c%60;
	cout << b << ":" << d << ":" <<  e << endl;
	return 0;
}

Measured memory_bytes: 1164