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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

vector<pii> g[100005];
int c[100005];

void dfs(int n, int p = -1) {
	for (auto q : g[n]) if (q.first != p) {
		c[q.first] = c[n] ^ (q.second & 1);
		dfs(q.first, n);
	}
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	rep(i, 1, n) {
		int u, v, w; read(u, v, w);
		g[u].push_back({v, w});
		g[v].push_back({u, w});
	}

	dfs(1);

	rep(i, 1, n + 1) write(c[i]);
}


Measured memory_bytes: 8448
n, m = map(int, input().split())
a = list(map(int , input().split()))

class Cumulative_Sum:
    def __init__(self, a):
        la = len(a)
        self.s = [0] * (la + 1)
        for i in range(la):
            self.s[i+1] = self.s[i] + a[i]
    # s[l]からs[r]までの和
    def sum(self, l, r):
        return self.s[r] - self.s[l]

cs = Cumulative_Sum(a)
from collections import defaultdict
b = defaultdict(int)

for i in range(n+1):
    b[cs.s[i] % m] += 1

ans = 0
for bi in b:
    if b[bi] > 1:
        ans += b[bi] * (b[bi] - 1) // 2
print(ans)

"""
ans = 0
for i in range(n):
    for j in range(i+1, n+1):
        if cs.sum(i, j) % m == 0:
            ans += 1
#print(ans)
"""

Measured memory_bytes: 62576
#include <bits/stdc++.h>
#include <math.h>  /* M_PI */

using namespace std;
 
int main() {
    double r;
    cin >> r;
    
    double a, c;
    a = (r * r) * M_PI;
    c = (r + r) * M_PI;
    
    cout << fixed << setprecision(6);
    cout << a << " " << c << endl;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC100 C
// 2020.05.25
ll func(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  ll ans = 0;
  REP(i, N){
    ll tmp; cin >> tmp;
    if(tmp%2 == 0) ans += func(tmp);
  }
  cout << ans << endl;
}

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

int main(){

  int W, a, b;
  cin >> W >> a >> b;
  
  if(b + W < a) cout << a-b-W << endl;
  else if(a+W < b) cout << b-a-W << endl;
  else cout << 0 << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, a, b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  REP(i, n) { cin >> x[i]; }
  ll ans = 0;
  for (ll i = 0; i < n - 1; i++) {
    if((x[i+1]-x[i])*a<b){
      ans += (x[i + 1] - x[i]) * a;
    } else{
      ans += b;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3972
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>

using namespace std;

typedef long long LL;

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

const int N = 1000 + 10;

struct Line
{
	int a, b, c;
	Line() {}
	Line(int, int);

	int operator < (const Line &that) const {
		return (a < that.a) || (a == that.a && b < that.b) || (a == that.a && b == that.b && c < that.c);
	}

	int operator == (const Line &that) const {
		return a == that.a && b == that.b && c == that.c;
	}

	int on(int x, int y) {
		return x * a + y * b + c == 0;
	}
};

int n;
int x[N], y[N];
vector<pair<Line, pair<int, int> > > vec;

Line::Line(int i, int j)
{
	a = 2 * x[j] - 2 * x[i];
	b = 2 * y[j] - 2 * y[i];
	c = x[i] * x[i] + y[i] * y[i] - x[j] * x[j] - y[j] * y[j];
	int gcd = __gcd(__gcd(abs(a), abs(b)), abs(c));
	a /= gcd; b /= gcd; c /= gcd;
	if (a == 0 && b == 0) {
		for( ; ; );
	}
	if (a < 0) {
		a *= -1; b *= -1; c *= -1;
	} else if (a == 0 && b < 0) {
		a *= -1; b *= -1; c *= -1;
	}
}

int check(Line line, vector<int> &ids)
{
	int cnt = 0;
	for(int i = 0; i < n; ++ i) {
		if (line.on(x[i], y[i])) {
			ids.push_back(i);
			++ cnt;
		}
	}
	/*
	   cout << line.a << ' ' << line.b << ' ' << line.c << endl;
	   cout << ids.size() << endl;
	   cout << cnt << endl;
	 */
	if (cnt > 2 || (int)ids.size() != n) 
		return false;

	return true;
}

void solve() {
	vec.clear();
	for(int i = 0; i < n; ++ i) {
		scanf("%d%d", x + i, y + i);
		x[i] *= 2; y[i] *= 2;
		for(int j = 0; j < i; ++ j) {
			if (x[i] == x[j] && y[i] == y[j]) {
				cout << "No" << endl;
				return;
			}
			vec.push_back(make_pair(Line(i, j), make_pair(i, j)));
		}
	}
	int flag = false;
	for(int i = 2; i < n; ++ i) {
		if ((x[i] - x[0]) * (y[1] - y[0]) - (y[i] - y[0]) * (x[1] - x[0])) {
			flag = true;
			break;
		}
	}
	if (! flag) {
		cout << "No" << endl;
		return;
	}

	sort(vec.begin(), vec.end());
	for(int i = 0, j; i < (int)vec.size(); i = j) {
		for(j = i; j < (int)vec.size() && vec[j].first == vec[i].first; ++ j);
		if (j - i < n / 2 - 10) continue;

		vector<int> ids;
		for(int k = i; k < j; ++ k) {
			ids.push_back(vec[k].second.first);
			ids.push_back(vec[k].second.second);
		}
		if (check(vec[i].first, ids)) {
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}

int main() {
	for( ; cin >> n && n; ) {
		solve();
	}
	return 0;
}

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

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

	multiset<double> s;
	
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		s.insert(a);
	}

	for(int i = 0;i < n-1;i++){
		double val1 = *(s.begin());
		s.erase(s.begin());
		double val2 = *(s.begin());
		s.erase(s.begin());
		
		s.insert((val1+val2)/2.0);
	}
	
	cout << *(s.begin()) << endl;

}


Measured memory_bytes: 256
def resolve():
    N, M = map(int, input().split())
    A = sorted(map(int, input().split()), reverse=True)
    ok_line = sum(A)/(4*M)
    cnt = 0
    for a in A:
        if not (a < ok_line):
            cnt += 1
    ans = True if M <= cnt else False
    return print("Yes" if ans else "No")

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3064
/*
  AtCoder Beginner Contest 081
  B - Shift only
*/

#include<iostream>
#include<limits>
using namespace std;

int N;
int A;

int main() {
  scanf("%d", &N);

  int minval = numeric_limits<int>::max();
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A);
    int count = 0;
    while (A % 2 == 0) {
      ++count;
      A /= 2;
    }
    minval = min(minval, count);
  }

  printf("%d\n", minval);
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var m = parseInt(input[0].split(" ")[1]);
  var ans=0;
  for(i=1;i<=10000;i++){
    ans += Math.pow(1-Math.pow((1/2),m),i-1)*Math.pow((1/2),m)*(1900*m+(n-m)*100)*i;
  }
  ans=Math.round(ans);
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7752
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			if ((B - 1) % (A - 1) == 0) {
				System.out.println((B - 1) / (A - 1));
			} else {
				System.out.println((B - 1) / (A - 1) + 1);
			}

		}
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int n[300000];

int main()
{



string x;
cin>>x;

for(int i = 0; i < x.size(); i++){

n[i] = x[i];

}

for(int i = 0; i < 4; i++)
{

    n[i] -= 48;
}
if(n[0] + n[1] + n[2] + n[3] == 7)
{
   cout<< n[0]<< "+" <<n[1]<< "+"<< n[2]<< "+" <<n[3]<< "=" << "7";
   return 0;
}
if(n[0] - n[1] + n[2] + n[3] == 7)
{
   cout<< n[0]<< "-" <<n[1]<< "+"<< n[2]<< "+" <<n[3]<< "=" << "7";
   return 0;
}
if(n[0] + n[1] - n[2] + n[3] == 7)
{
   cout<< n[0]<< "+" <<n[1]<< "-"<< n[2]<< "+" <<n[3]<< "=" << "7";
   return 0;
}
if(n[0] + n[1] + n[2] - n[3] == 7)
{
   cout<< n[0]<< "+" <<n[1]<< "+"<< n[2]<< "-" <<n[3]<< "=" << "7";
   return 0;
}
if(n[0] - n[1] - n[2] + n[3] == 7)
{
   cout<< n[0]<< "-" <<n[1]<< "-"<< n[2]<< "+" <<n[3]<< "=" << "7";
   return 0;
}
if(n[0] + n[1] - n[2] - n[3] == 7)
{
   cout<< n[0]<< "+" <<n[1]<< "-"<< n[2]<< "-" <<n[3]<< "=" << "7";
   return 0;
}
if(n[0] - n[1] - n[2] - n[3] == 7)
{
   cout<<n[0]<< "-" <<n[1]<< "-"<< n[2]<< "-" <<n[3]<< "=" << "7";
   return 0;
}
if(n[0] - n[1] + n[2] - n[3] == 7)
{
   cout<<n[0]<< "-" <<n[1]<< "+"<< n[2]<< "-" <<n[3]<< "=" << "7";
   return 0;
}



    return 0;
}


Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007

using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
bool isPrime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
} 
int main()
{
    fast();
    ll x;
    cin>>x;
    while(true)
    {
        if(isPrime(x))
        {
            cout<<x;
            exit(0);
        }
        x++;
    }
}

Measured memory_bytes: 256
n = int(input())

ab = []
ans = []
for i in range(1, int(n**(0.5))+1):
	ab.clear()
	if n%i == 0:
		ab.append(i)
		ab.append(int(n/i))
		ans.append(len(str(max(ab))))
			
if len(ans) == 0:
	ans.append(1)

print(min(ans))


Measured memory_bytes: 3188
def f(n):
    if n == 0:
        return 0
    return f(n % bin(n).count("1")) + 1


def solve():
    N = int(input())
    X = input()
    p = X.count("1")
    rem_plus = 0
    rem_minus = 0
    for i in range(N):
        k = N - i - 1
        if X[i] == "0":
            continue
        elif p > 1:
            rem_minus = (rem_minus + pow(2, k, p - 1)) % (p - 1)
        rem_plus = (rem_plus + pow(2, k, p + 1)) % (p + 1)
    for i in range(N):
        k = N - i - 1
        if X[i] == "0":
            print(f((rem_plus + pow(2, k, p + 1)) % (p + 1)) + 1)
        elif p > 1:
            print(f((rem_minus - pow(2, k, p - 1)) % (p - 1)) + 1)
        else:
            print(0)


if __name__ == "__main__":
    solve()


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

int N, M;
vector<int> s, c;

bool ok(string str)
{
    if (str.size() != N)
        return false;
    for (int i = 0; i < M; ++i)
        if (str[s[i]] != (char)(c[i] + '0'))
            return false;
    return true;
}

string solve()
{
    for (int i = 0; i <= 999; ++i)
    {
        string str = to_string(i);
        if (ok(str))
            return str;
    }
    return "-1";
}

int main()
{
    cin >> N >> M;
    s.resize(M);
    c.resize(M);
    for (int i = 0; i < M; ++i)
        cin >> s[i] >> c[i], --s[i];
    cout << solve() << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
    static int gcd(int b,int a)
    {
        if(b%a==0)
        return a;
        return gcd(a,b%a);
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        long gc;
        if(a>b)
        gc=gcd(a,b);
        else
        gc=gcd(b,a);
        long mul=(long)a*b;
        System.out.println(mul/gc);
    }
}

Measured memory_bytes: 21972
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-4;

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

long double QR, RP, PQ;
long double x[100];
long double y[100];
long double z[100];
long double dist(int i, int j){
	long double dx = abs(x[i] - x[j]);
	long double dy = abs(y[i] - y[j]);
	long double dz = abs(z[i] - z[j]);
	return sqrt(dx * dx + dy * dy + dz * dz);
}

int main(){
	int T;
	int n;
	long double pq, qr, rp;
	cin >> T;
	rep(t, T){
		cin >> QR >> RP >> PQ;
		cin >> n;
		rep(i, n){
			cin >> x[i] >> y[i] >> z[i];
		}
	
		rep(i, n) rep(j, n) rep(k, n){
			if(i == j || j == k || k == i) continue;
			pq = dist(i, j);
			qr = dist(j, k);
			rp = dist(k, i);
			long double ratio = pq / PQ;
			if(abs(ratio - qr / QR) < EPS && abs(ratio - rp / RP) < EPS){
				cout << i + 1 << " " << j + 1 << " " << k + 1 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
/*
                                                              _        ___    
                                                             //      /        
----__----------------)__----__------__--_/_----__---)__-----/------/___------
  /   ) /   / /   /  /   ) /   )   /   ) /    /   ) /   )   /      /    )     
_(___(_(___/_(___(__/_____(___(___/___/_(_ __(___/_/_______/______(____/______
          /                      /                                            
      (_ /                      /                                             */
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ld long double
#define repo(i, begin, end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define ll long long
#define bug(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<"  ";
#define fastr ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--) 
#define fi first
#define se second
#define tit(v,i,c) get<c>(v[i])
#define mt make_tuple 
#define pb push_back
#define eb emplace_back
#define mp make_pair
double jk=0.004;
#define power(x,y) pow(x,y)+jk
#define endl "\n"
const long long mod=1e9+7;
const long long N=1000000000;
const int val=1000005;
int in(){
int n;cin>>n;
return n;}
void _do_(){
	int n;
	cin>>n;
	ll a[n];
	rep(i,0,n){cin>>a[i];
		if(a[i]==0){cout<<0<<endl;return;}
	}
	//for(auto x:a)cout<<x<<" ";cout<<endl;
	ld ans=1;
	rep(i,0,n){
		ans*=a[i];
		if(ans<0||ans>1000000000000000000){ans=-1;}
		if(ans<0)break;
		
	}

	cout<<(ll)ans<<endl;



















	

}
signed main(){
fastr
int tc;
//cin>>tc;
tc=1;
while(tc--)_do_();
cerr<<"Time elapsed:";
cerr<<1000*clock()/CLOCKS_PER_SEC<<" ms ";
return 0;}

Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
const int maxn=6e6+7;
typedef long long ll;
const ll mod=1e10+7;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c))c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
#define read read()

ll a[maxn];
int Sheryang()
{
    int n=read;
    for(int i=1;i<=n;i++){
        a[i]=read;
    }

    sort(a+1,a+1+n);

    int ans=0;
    for(int i=1;i<=n;i++) if(a[i]&1) ans^=(n-i+1);

    if(!ans) printf("second\n" );
    else printf("first\n");

    return 0;
}






Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b,c;
    cin >> a >> b >> c;
    cout << (min(a,min(b,c))==5 && max(a,max(b,c))==7 && a+b+c==17 ? "YES":"NO") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    int a[n][m];
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        int tmp=c;
        for(int j=0;j<m;j++){
            tmp += a[i][j]*b[j];
        }
        ans+=(tmp>0?1:0);

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

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

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

    bool negative_even = true;
    int min_abs = INT_MAX;
    long long ans = 0;

    for(int i = 1; i <= N; i++) {
        int A;
        cin >> A;
        ans += abs(A);
        if(A < 0) {
            negative_even ^= true;
        }
        if(abs(A) < min_abs) {
            min_abs = abs(A);
        }
    }
    if(!negative_even) {
        ans -= 2 * min_abs;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
K = int(input())
S = input()

mod = 10**9+7

m = 2*10**6 +10 
fac = [1]*m
ninv = [1]*m
finv = [1]*m
for i in range(2,m):
    fac[i] = fac[i-1]*i%mod
    ninv[i] = (-(mod//i)*ninv[mod%i])%mod
    finv[i] = finv[i-1]*ninv[i]%mod

def comb(n,k):
    return (fac[n]*finv[k]%mod)*finv[n-k]%mod

N = len(S)
ans = 0

for i in range(K+1):
    j = K - i
    tmp = pow(25,j,mod)*pow(26,i,mod)%mod
    tmp *= comb(j+N-1,j)
    tmp %= mod
    ans += tmp
    ans %= mod

print(ans)

Measured memory_bytes: 117640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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; }

int main(){
    vector <int> Z;
    int X,Y,A,B,C; cin >> X >> Y >> A >> B >> C;
    vector <int> P(A);
    rep(i,A) cin >> P[i];
    sort(P.begin(),P.end(),greater<int>());
    rep(i,X) Z.push_back(P[i]);
    
    vector <int> Q(B);
    rep(i,B) cin >> Q[i];
    sort(Q.begin(),Q.end(),greater<int>());
    rep(i,Y) Z.push_back(Q[i]);
        
    sort(Z.begin(),Z.end());
    ll sum=0;
    for (auto i:Z){
        sum+=i;
        //cout << i << " ";
    }
    //cout << endl;
    //cout << sum << endl;
    
    vector <int> R(C);rep(i,C) cin >> R[i];
    sort(R.begin(),R.end(),greater<int>());
    
    
    int cnt1=0;
    rep(i,C){
        if (R[i]>Z[i]){
            sum-=Z[i];
            sum+=R[i];
        }
        else{
            break;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a,b,x,y,z;
  cin >> a>> b;
  x=a+b;
  y=a-b;
  z=a*b;
   cout << max(x,max(y,z)) << endl;
  return 0;
}
  
  

Measured memory_bytes: 256
def max_digit(numA, numB):
    a = len(str(numA))
    b = len(str(numB))
    return max(a, b)
ans = 10
n = int(input())
for i in range(1, int(n ** 0.5) + 1):
    if n % i != 0:
        continue
    result = max_digit(i, n // i)
    if ans > result:
        ans = result
print(ans)

Measured memory_bytes: 3064
/* Coached by Dukkha */
#include <stdio.h>
#include <stdlib.h>

#define N 50
#define INF 0x7fffffff

long long min(long long a, long long b) { return a < b ? a : b; }

int xx[N], yy[N], ii[N], xx_[N], n, k;

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return xx[i] - xx[j];
}

int solve(int y1, int y2) {
	int i, cnt = 0, w = INF;

	for (i = 0; i < n; i++) {
		int x = xx[ii[i]], y = yy[ii[i]];

		if (y1 <= y && y <= y2)
			xx_[cnt++] = x;
		if (cnt >= k)
			w = min(w, xx_[cnt - 1] - xx_[cnt - k]);
	}
	return w;
}

int main() {
	int i, j;
	long long ans;

	scanf("%d%d", &n, &k);
	for (i = 0; i < n; i++)
		scanf("%d%d", &xx[i], &yy[i]);
	for (i = 0; i < n; i++)
		ii[i] = i;
	qsort(ii, n, sizeof *ii, compare);
	ans = (long long) INF * INF;
	for (i = 0; i < n; i++)
		for (j = i + 1; j < n; j++) {
			int yi = yy[i], yj = yy[j], w;
			long long a;

			if (yi > yj) {
				int tmp;
				
				tmp = yi, yi = yj, yj = tmp;
			}
			w = solve(yi, yj);
			if (w == INF)
				continue;
			a = (long long) w * (yj - yi);
			ans = min(ans, a);
		}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

int gcm(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while(k != 0);
	return result;
}


int main(){
  int N, X;
  cin >> N >> X;
  vector<int> v(N);
  
  for(int i = 0; i < N; i++){
    cin >> v.at(i);
    v.at(i) = abs(v.at(i) - X);
  }
  
  int g = v.at(0);
  for(int i = 1; i < N; i++){
    g = gcm(g, v.at(i));
  }
  
  cout << g << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll inf = LLONG_MAX/4;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,w,wi,vi;
  cin >> n >> w;
  vector<ll> mw(100001,inf);
  mw[0] = 0;
  for(ll i = 0; i < n; ++i){
    cin >> wi >> vi;
    for(ll j = 100000-vi; j >= 0; --j){
      mw[j+vi] = min(mw[j+vi],mw[j]+wi);
    }
  }
  for(ll i = 100000; i >= 0; --i){
    if(mw[i] <= w){
      cout << i;
      break;
    }
  }
  return 0;
}

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

int k,n;
int a[200005];
int fr[200005],bk[200005],f[200005];
int stk[200005],ind[200005],tail = 0;

int main() {
  scanf("%d%d",&n,&k);
  for(int i = 0;i < n;i++)
  	scanf("%d",&a[i]);
  for(int i = 0;i < n;i++) {
  	if(!tail) stk[tail] = a[i], ind[tail++] = i;
    else {
      while(tail && a[i] < stk[tail-1]) {
      	tail--;
        fr[ind[tail]] = i;
      }
      stk[tail] = a[i];
      ind[tail++] = i;
    }
  }
  while(tail) {
    tail--;
  	fr[ind[tail]] = n;
  }
  for(int i = n-1;~i;i--) {
  	if(!tail) stk[tail] = a[i], ind[tail++] = i;
    else {
      while(tail && a[i] > stk[tail-1]) {
      	tail--;
        bk[ind[tail]] = i;
      }
      stk[tail] = a[i];
      ind[tail++] = i;
    }
  }
  while(tail) {
  	tail--;
    bk[ind[tail]] = -1;
  }
  int ans = n - k + 1;
  for(int i = 0;i + k < n;i++) {
  	if(fr[i] > i+k && bk[i+k] < i) {
      ans--;
      f[i+k] = 1;
    }
  }
  for(int z = 0,t = 1,i = 1;i < n;i++) {
  	if(a[i] > a[i-1]) t++;
    else t = 1;
    if(t >= k && !f[i]) ans-=z, z = 1;
  }
  //for(int i = 0;i < n;i++) printf("%d ",fr[i]);
  //puts("");
  //for(int i = 0;i < n;i++) printf("%d ",bk[i]);
  printf("%d\n",ans);
}

Measured memory_bytes: 4864
#include "bits/stdc++.h"
#define oo 1000000000000000098
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;

template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int n;
int ans;
int a[MAXN];
int main()
{
    //~ freopen("file.in", "r", stdin);
    scanf("%d",&n);
	int k;scanf("%d",&k);
	for(int i=1;i<=n;i++)
		scanf("%d",a+i);
	ll ans=oo;
	for(int i=k;i<=n;i++){
		int id=i-k+1,sh=0;
		if(a[id]<0&&a[i]>0)
			sh=-a[id];
		umin(ans,abs(a[id])+abs(a[i])+sh+0ll);
	}
	int id = 1;
	for(; id <= n; id ++)
		if(a[id] >= 0)
			break;
	ans=oo;
	for(int i = id - 1, cnt = k-1; i >= 1 && cnt; i --, cnt --)
	{
		if(i + k - 1 > n)
			continue;
		ll dm = abs(a[i])*2 + a[i + k - 1];
		umin(ans, dm);
	}
	if(id - k > 0)
		umin(ans, (ll)(abs(a[id- k])));
	for(int i = id, cnt = k-1; i <= n && cnt; i ++, cnt --)
	{
		if(i - k + 1 < 1)
			continue;
		ll dm = a[i] * 2 + abs(a[i - k + 1]);
		umin(ans, dm);
	}
	if(id + k - 1 <= n)
		umin(ans, (ll)(a[id + k - 1]));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include <functional>

int main(void){
    int N, C[50], V[50];
    scanf("%d", &N);
    for(int i=0;i<N;i++){
        scanf("%d", &V[i]);
    };
    for(int i=0;i<N;i++){
        scanf("%d", &C[i]);
    }
    int vc[50];
    for(int i=0;i<N;i++){
        vc[i] = V[i] - C[i];
    }
    std::sort(vc, vc+N, std::greater<int>());
    int sum = 0;
    for(int i=0;i<N;i++){
        // printf("%d ", vc[i]);
        if(vc[i] > 0) sum += vc[i];
        else break;
    }
    printf("%d", sum);
}

Measured memory_bytes: 128
S=input()[::-1]
num=(len(S)//5)+1
while num > 0:
  for i in ['dream'[::-1], 'dreamer'[::-1], 'erase'[::-1], 'eraser'[::-1]]:
    if S[:len(i)] == i:
      S = S[len(i):]
    if S == '':
      print('YES')
      exit()
  num -= 1
print('NO')

Measured memory_bytes: 9096
#include<iostream>
#include<algorithm> 
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int maxn= 2e5+5;
const double pi = acos(-1.0);
const ll mod = 1e9+7;
int main()
{
  int l,r;
	int d;
	cin>>l>>r>>d;
	cout<<r/d-(l-1)/d<<endl; 
 	
    return 0;
}

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

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

namespace chrono = std::chrono;
using namespace std::literals;

[[gnu::constructor]]
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

int main() {
    int n; cin >> n;
    std::string s = std::to_string(n);
    int m = std::accumulate(s.begin(), s.end(), 0) - s.length() * (int)'0';
    if (n % m == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
///*/////////////////////////////*///
/// IN THE NAME OF ALMIGHTY ALLAH ///
///*/////////////////////////////*///

///*////////////////////*///
/// Author : SAIFULLAH29 ///
///*////////////////////*///

///*//////////////////////////////////////////*///
/// "When you want something, all the universe ///
///  conspires in helping you to achieve it."  ///
///              - Paulo Coelho, The Alchemist ///
///*//////////////////////////////////////////*///

#include <bits/stdc++.h>

#define SS           " "
#define endl         "\n"
#define EPS          1e-9
#define gcd          __gcd
#define pb           push_back
#define pi           acos(-1.0)
#define Ars          greater<int>()
#define vi           vector<int>
#define vvi          vector<vector<int> >
#define flush        cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define wow          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

typedef long long              ll;
typedef double                 dbl;
typedef unsigned long long     ull;

void solve()
{
    int a;
    cin>>a;
    cout<<(~a)+2<<endl;
}

int main()
{
    wow

    int t=1;
    //cin>>t;

    while(t--)
        solve();

    return 0;
}

///*////////////////////////////////////////////*///
/// "There is only one thing that makes a dream  ///
/// impossible to achieve: the fear of failure." ///
///                - Paulo Coelho, The Alchemist ///
///*////////////////////////////////////////////*///


Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Stream;
 
public class Main {    
    public static void main(String[] args)throws IOException{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String sn = input.readLine();
        int x = Integer.parseInt(sn);

        int y = lcm(x,360);
        System.out.println(y/x);
    }
    
    static int lcm (int a, int b) {
        int temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (int)(c/b);
    }
        
}

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

const int SIZE=2510;
const int INF=1e9;
struct edge{int from,to,cost;};

int N,M,P;
vector<edge> es;
int dist[SIZE];
bool negative[SIZE];

void shortest_path(int s)
{
    for(int i=0;i<N;i++) dist[i]=INF;
    dist[s]=0;
    for(int i=0;i<N-1;i++){
        for(edge e:es){
            if(dist[e.from]!=INF){
                dist[e.to]=min(dist[e.to],dist[e.from]+e.cost);
            }
        }
    }
}

bool find_negative_loop()
{
    for(int i=0;i<N;i++) negative[i]=false;
    for(int i=0;i<N;i++){
        for(edge e:es){            
            if(dist[e.to]!=INF and dist[e.to]>dist[e.from]+e.cost){
                dist[e.to]=dist[e.from]+e.cost;
                negative[e.to]=true;
            }
            if(negative[e.from]) negative[e.to]=true;
        }
    }
    return negative[N-1];
}

int main()
{
    cin>>N>>M>>P;
    for(int i=0;i<M;i++){
        int a,b,c; cin>>a>>b>>c;
        a--; b--;
        es.push_back({a,b,P-c});
    }
    shortest_path(0);
    if(find_negative_loop()){
        cout<<-1<<endl;
    }else{
        cout<<max(-dist[N-1],0)<<endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<double> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dp[i + 1][j] += dp[i][j] * (1 - P[i]);
      dp[i + 1][j + 1] += dp[i][j] * P[i];
    }
  }
  double res = 0;
  for (int i = (N + 1) / 2; i <= N; i++) {
    res += dp[N][i];
  }
  cout << setprecision(10) << res << '\n';
  return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
signed main()
{
	int N, sum = 0;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum % (N * (N + 1) / 2) == 0) {
		bool flag = true;
		int d = sum / (N * (N + 1) / 2), cnt = 0;
		for (int i = 1; i <= N; i++) {
			if ((A[i - 1] - A[i % N] + d + N * 1000000000) % N != 0 || (A[i - 1] - A[i % N] + d) / N < 0) {
				flag = false;
				break;
			}
			else {
				cnt += (A[i - 1] - A[i % N] + d) / N;
			}
		}
		cout << (flag && cnt == d ? "YES" : "NO") << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
n,k=map(int,input().split())
lists=[]
for _ in range(k):
  d=int(input())
  lis=list(map(int,input().split()))
  lists.append(lis)
ans=[0]*n
for list in lists:
  for i in range(len(list)):
    ans[list[i]-1]+=1
count=0
for h in ans:
  if h==0:
    count+=1
print(count)

Measured memory_bytes: 9164
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	String fileName = "prizes";

	public void solve() throws IOException {
		int n = nextInt();
		int a = nextInt();
		if (n % 500 <= a)
			out.println("Yes");
		else
			out.println("No");
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out, true);
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader br;
	StringTokenizer in;
	static PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

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

}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int ans=0;
  
  for(int i=1; i<=N; i++){
    int wa =0;
    int ii = i;
    for(int j=0; j<5; j++){
      wa += ii%10;
      ii /=10;
    }
    if(A<=wa && wa<=B)ans+=i;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
	
	int a,b,c;
	int kdi;
	int nym=0;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	for(kdi=a;kdi<=b;kdi++){
		
		if(c%kdi==0){
			nym++;
		}
	}
		printf("%d\n",nym);
		
		return 0;
	}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y << endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
 
using namespace std;
 
bool compare(ll &x, ll &y){
    return x>=y;
}
 
ll mode=pow(10,9)+7;

 
int main(){ 
    
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 
	ll a,b,c;
	cin>>a>>b>>c;
	ll ans=c-a+b;
	if (ans<0){
		ans=0;
	}
	cout<<ans<<endl;

    return 0; 
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;
ll int dp[105][100005];
int main()
{
  fastio();

 
ll int T;
T=1;
while(T--)
{
ll int n,k,i,j;
cin>>n>>k;
ll int a[n+1],sum[k+1];
for(i=1;i<=n;i++)
	cin>>a[i];

for(i=0;i<=k;i++)
{
	dp[0][i]=0;

}
for(i=0;i<=n;i++)
{
	dp[i][0]=1;
}
for(i=1;i<=n;i++)
{	sum[0]=dp[i-1][0]%MOD;
	for(j=1;j<=k;j++)
{	sum[j]=sum[j-1]%MOD+dp[i-1][j]%MOD;
sum[j]%=MOD;}
	for(j=0;j<=k;j++)
	if(j<=a[i])
	{
		dp[i][j]=sum[j];
		dp[i][j]%=MOD;
	}
	else
	{dp[i][j]=sum[j]-sum[j-a[i]-1];
		dp[i][j]+=MOD;
		dp[i][j]%=MOD;
	}}
cout<<dp[n][k]<<endl;
}

    return 0;
}

Measured memory_bytes: 80896
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

string S;

signed main()
{
    cin >> S;

    for (char c='a'; c<='z'; c++) {
        bool find = false;
        REP(i,S.length()) {
            if (S[i] == c) find = true;
        }
        if (!find) {
            cout << c << endl;
            return 0;
        }
    }

    cout << "None" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define ALL(x) x.begin(), x.end()

const int MAX_N = 3010;
const int MAX = 2e5+10;
const int MOD = 1e9+7;
int H, W, N;
vii v;
ll dp[MAX_N];

ll fac[MAX];
ll finv[MAX];
ll inv[MAX];

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR (i, 2, MAX) {
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}

ll nCk (int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

ll f (int x, int y) {
    return nCk(x+y, x);
}

int main () {
    cin >> H >> W >> N;
    init();
    v = vii(N+2);
    REP (i, N) cin >> v[i].first >> v[i].second;
    v[N].first = 1; v[N].second = 1;
    v[N+1].first = H; v[N+1].second = W;
    sort(ALL(v));

    dp[0] = 0;
    FOR (i, 1, N+2) {
        dp[i] = f(v[i].first-1, v[i].second-1);
        FOR (j, 1, i) {
            (dp[i] += MOD - (dp[j] * f(v[i].first-v[j].first, v[i].second-v[j].second) % MOD)) %= MOD;
        }
    }
    cout << dp[N+1] << endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<stdlib.h>

int main(){
  int A, B;
  char S[20];

  scanf("%d %d", &A, &B);
  scanf("%s", S);

  int i;
  for(i=0; i<(A+B+1); i++){
    if(i==A){
      if(S[i]!='-'){
        printf("No\n");
        return 0;
      }else continue;
    }
    if((S[i]<'0')||(S[i]>'9')){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n;
ll a[62]={};

int main(){
	cin>>n;
	REP(i,n){
		ll t;
		cin>>t;
		int co=0;
		while(t){
			if(t%2==1){
				a[co]++;
			}
			co++;
			t/=2;
		}
	}
	ll ans=0;
	ll nn=1;
	REP(i,62){
		ll tans=(a[i]*(n-a[i]))%MOD;
		tans=(tans*nn)%MOD;
		nn*=2;
		nn%=MOD;
		ans+=tans;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  string s;
  cin>>s;
  
  cout<<s;
  
  if(s[s.size()-1]=='s')
  cout<<"es";
  else
  cout<<"s"<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 3656
import java.util.*;
class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt() ;
      ArrayList<Integer> arr = new ArrayList<>();
      for(int i = 0;i<n ; i++){
          arr.add(scan.nextInt());
      }
      
      Collections.sort(arr,Collections.reverseOrder()) ;
      //System.out.println(arr);
      
      int sum = 0 , sum2 = 0 ;
      for(int i = 0;i<n ; i++){
          if(i%2==0){
             sum+=arr.get(i) ;
              
          }else{
              sum2+=arr.get(i);
          }
      }
      
      System.out.println(Math.abs(sum-sum2));
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n;
ll a[maxx], b[maxx];
ll ans;

void Init() {
	scanf("%d", &n);
	for(int i = 1; i <= n + 1; i++) scanf("%lld", &a[i]);
	for(int i = 1; i <= n; i++) scanf("%lld", &b[i]);
}

void Solve() {
	for(int i = 1; i <= n; i++) {
		if(a[i] + a[i + 1] > b[i]) {
			ans += b[i];
			ll tmp = min(a[i], b[i]);
			a[i] -= tmp;
			b[i] -= tmp;
			a[i + 1] -= b[i];
		}
		else {
			ans += a[i] + a[i + 1];
			b[i] -= a[i] + a[i + 1];
			a[i] = a[i + 1] = 0;
		}
	}
	printf("%lld\n", ans);
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  if(n == 1){
    int f, s;
    cin >> f >> s;
    cout << f + s << endl;
    return 0;
  }
  vector<vector<int>> a(2, vector<int>(n));
  for(int i = 0; i < n; i++){
    cin >> a[0][i];
  }
  for(int i = 0; i < n; i++){
    cin >> a[1][i];
  }
  
  int ans = 0;
  for(int i = 0; i <= n; i++) {
    int tmp = 0;
    for(int j = 0; j < i; j++) {
      tmp += a[0][j];
    }
    if(i < n - 1){
      tmp += a[0][i];
    }
    for(int j = i; j < n; j++){
      tmp += a[1][j];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
S = H.times.map { gets.chomp.chars }

def check(h, w)
  return false if h < 0 || h >= H
  return false if w < 0 || w >= W

  S[h][w] == '#'
end

H.times do |h|
  W.times do |w|
    next if S[h][w] == '.'
    next if check(h - 1, w) || check(h + 1, w) || check(h, w + 1) || check(h, w - 1)

    puts 'No'
    exit
  end
end
puts 'Yes'

Measured memory_bytes: 1916
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int N = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		sc.close();
		if(a==1) a=14;
		if(b==1) b=14;
		out.println(a>b?"Alice":a<b?"Bob":"Draw");
	}
}


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

int main() {
  string s;
  cin >> s;
  vector<bool> app(26);
  rep(i, s.size()) app[s[i] - 'a'] = true;
  rep(i, 26) if(!app[i]) {
    cout << string(1, i + 'a') << "\n";
    return 0;
  }
  
  cout << "None" << "\n";
  return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1LL<<60);

ll H,W,K,N;
ll hh,ww;
ll y[100000],x[100000];

vector<ll> g[100005];
vector<ll> G[100005];

ll uc=0;

ll func(vector<ll> &T,vector<ll> &t,int l,int r, int Y){

  
  ll L=T[l];
  ll R=T[r-1];


  ll cnt = (R+1)/2 - (L-1+1)/2;

  ll res=-cnt;
  
  vector<ll> :: iterator it, it2;
  it =lower_bound(t.begin(),t.end(),L);
  it2=upper_bound(t.begin(),t.end(),R);
  
  map<int,int> mp;
  while(it!=it2){
    mp[*it]=1;
    it++;
  }


  vector<ll> dp(cnt+1,INF);

  int sx=L;
  if(sx%2==0)sx++;
  
  dp[0]=0;
  for(int i=0;i<cnt;i++){
    if(dp[i]==INF)continue;
    int px=sx+2*i;
    
    if(mp[px]){
      dp[i+1]=min(dp[i+1],dp[i]+2);
    }else{
      dp[i+1]=min(dp[i+1],dp[i]+1);
    }

    if(i+2<=cnt){
      if(mp[px+1]){
        dp[i+2]=min(dp[i+2],dp[i]+4);
      }else{
        dp[i+2]=min(dp[i+2],dp[i]+2);
      }
    }
  }

  res+=dp[cnt];
    
  return res;
}

ll solve(){
  
  hh=(H+1)/2;
  ww=(W+1)/2;
  if( ww > K )return -1;
  K-=ww;

  ll res = 0;
  ll excost = 0;
  
  for(int i=2;i<H;i+=2){
    res+=ww;
    
    if(G[i].empty()){
      continue;
    }

    int last=0;
    for(int j=1;j<(int)G[i].size();j++){
      if(G[i][j-1]+3<G[i][j]){
        ll val = func(G[i],g[i],last,j,i);
        res += val;
        excost += val;
        last=j;
      }
    }
    
    if(last+1<(int)G[i].size()){
      ll val = func(G[i],g[i],last,G[i].size(),i);
      res += val;
      excost += val;
    }
  }

  int cc=min(K,excost);
  res-=cc*2LL;
  K-=cc;
  
  return max(0LL,res-K);
}

int main(){
  cin>>W>>H>>K>>N;


  for(int i=1;i<=H;i++){
    G[i].push_back(1);
    G[i].push_back(W);
  }
  
  for(int i=0;i<N;i++){
    cin>>x[i]>>y[i];
    G[ y[i] ].push_back( x[i] );

    if(x[i]+2<=W)
      G[ y[i] ].push_back( x[i]+2 );
    if(x[i]-2>=1)
      G[ y[i] ].push_back( x[i]-2 );

    g[ y[i] ].push_back( x[i] );
    
  }

  for(int i=1;i<=H;i++){
    sort(g[i].begin(),g[i].end());
    sort(G[i].begin(),G[i].end());
    G[i].erase( unique(G[i].begin(),G[i].end()) , G[i].end() );
  }
  
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 13728
while True :
	char_line = raw_input().split()
	a = int(char_line[0])
	b = int(char_line[2])
	if char_line[1] == '?':
		break
	elif char_line[1] =='+':
		print(a+b)
	elif char_line[1]=='-':
		print(a-b)
	elif char_line[1]=='*':
		print(a*b)
	else:
		print(a/b)

Measured memory_bytes: 6340