akhauriyash/Code-Regression huggingface dataset:
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x,y)       for(int i = 0;i < (y);i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x,y)        for(int i = 0; i < (y);i++)cin >> (x).at(i)

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

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

void solve() {
    int a,b;
    read(a);
    read(b);
    if(a > b){
        println("a > b");
    } else if(a == b) {
        println("a == b");
    } else {
        println("a < b");
    }
}

signed main() {
    solve();
    return 0;
}


Measured memory_bytes: 3208
#include "iostream"
using namespace std;
int main() {
	for (int i = 0; i < 10000; i++) {
		int x,y;
		cin >> x >> y;
		if (x == 0 && y == 0) {
			break;
		}
		else if(x > y){
			cout << y << " " << x << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	ll n, c;
	cin >> n >> c;
	vector<ll> x(n), v(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> v[i];
	}

	vector<ll> dp1(n);
	dp1[0] = v[0] - x[0];
	for (int i = 1; i < n; i++) {
		dp1[i] = dp1[i - 1] + v[i] - (x[i] - x[i - 1]);
	}
	for (int i = 1; i < n; i++) {
		dp1[i] = max(dp1[i], dp1[i - 1]);
	}

	vector<ll> dp2(n);
	dp2[n - 1] = v[n - 1] - (c - x[n - 1]);
	for (int i = n - 2; i >= 0; --i) {
		dp2[i] = dp2[i + 1] + v[i] - (x[i + 1] - x[i]);
	}
	for (int i = n - 2; i >= 0; --i) {
		dp2[i] = max(dp2[i], dp2[i + 1]);
	}

	ll ans = max(0LL, dp2[0]);
	for (int i = 0; i < n; i++) {
		ll tmp = dp1[i];
		if (i + 1<n && dp2[i + 1] - x[i] > 0) tmp += dp2[i + 1] - x[i];
		ans = max(ans, tmp);
	}
	for (int i = n - 1; i >= 0; --i) {
		ll tmp = dp2[i];
		if (i >= 1 && dp1[i - 1] - (c - x[i]) > 0) tmp += dp1[i - 1] - (c - x[i]);
		ans = max(ans, tmp);
	}

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


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

#define ll long long
using namespace std;

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<ll> a(x);
    for (int i = 0; i < x; i++)cin >> a[i];
    vector<ll> b(y);
    for (int i = 0; i < y; i++)cin >> b[i];
    vector<ll> c(z);
    for (int i = 0; i < z; i++)cin >> c[i];

    vector<ll> ab;
    for (int i = 0; i < x; i++)
        for (int j = 0; j < y; j++)
            ab.push_back(a[i] + b[j]);
    sort(ab.begin(), ab.end());
    reverse(ab.begin(), ab.end());

    vector<ll> abc;
    for (int i = 0; i < min(k, (int) ab.size()); i++)
        for (int j = 0; j < z; j++)
            abc.push_back(ab[i] + c[j]);
    sort(abc.begin(), abc.end());
    reverse(abc.begin(), abc.end());

    for (int i = 0; i < k; i++)cout << abc[i] << endl;
    return 0;
}

Measured memory_bytes: 43496
def scm(s):
    x, y = s
    def gcd(x, y):
        while y:
            x, y = y, x % y
        return x
    gcd = gcd(x, y)
    print(x * y // gcd)

if __name__ == "__main__":
    import sys
    in_str = []
    for line in sys.stdin:
        in_str.append(line)
    scm([int(_) for _ in in_str[0].split()])

Measured memory_bytes: 3060
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A = new int[n];
        int v, i, j;
        for(i=0;i<n;i++){
            A[i] = sc.nextInt();
        }
        for(int k=0;k<n;k++){
	    if(k==n-1){
		System.out.println(A[k]); 
	    }
	    else{
		System.out.print(A[k]+" ");
	    }
	}
        for(i=1;i<n;i++){
            v = A[i];
            j = i -1;
            while(j>=0 && A[j]>v){
                A[j+1] = A[j];
                j=j-1;
            }
            A[j+1] = v;
            for(int k=0;k<n;k++){
                if(k==n-1){
                    System.out.println(A[k]); 
                }
                else{
                    System.out.print(A[k]+" ");
                }
            }
        }
    }
}



Measured memory_bytes: 31848
#D
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7

def comb(n, x):
    numerator = 1
    for i in range(n, n - x, -1):
        numerator = numerator * i % mod

    denominator = 1
    for j in range(x, 1, -1):
        denominator = denominator * j % mod

    d = pow(denominator, mod-2, mod)

    return numerator * d

a = comb(n, a)
b = comb(n, b)

print((pow(2, n, mod) - 1 - a - b) % mod)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}


int main()
{
	int n, l;
	cin >> n >> l;
	vector<int>apple(n);
	int sum = 0;
	rep(i, n) {
		apple[i] = l + i;
		sum += apple[i];
	}
	int ans = sum;
	//cout << sum << endl;
	int compare = 1e9;
	rep(i, n) {
		int tmp = sum - apple[i];
		int para = abs(sum - tmp);
		if (compare > para) {
			ans = tmp;
			compare = para;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,m;
  cin>>n>>m;
  vll x(n);
  rep(i,n) cin>>x[i];
  map<ll,ll> t;
  map<ll,ll> p;
  rep(i,n){
    p[x[i]%m]++;
    t[x[i]]++;
  }
  map<ll,ll> dd;
  for(auto e:t){
    if(e.S>=2){
      dd[e.F%m]+=e.S/2;
    }
  }
  ll ans=0;
  for(int i=0;i<=m/2;i++){
    ll a=m-i;
    if(a==m) a=0;
    if(a==i){
      ans+=p[a]/2;
    }
    else{
      if(p[i]>p[a]){
        ans+=p[a];
        ans+=min(dd[i],(p[i]-p[a])/2);
      }
      else{
        ans+=p[i];
        ans+=min(dd[a],(p[a]-p[i])/2);
      }
    }
  }
  COUT(ans);
}

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

#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

ll gcdll(ll a, ll b){
    if(!b) return a;
    return gcdll(b, a%b);
}

int gcd(int a, int b){
    if(!b) return a;
    return  gcd(b, a%b);
}

void seive(int n){
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;

    for(int i=2; i*i<=n; i++){
        if(is_prime[i]){
            for(int j=i*i; j<=n; j+=i){
                is_prime[j] = false;
            }
        }
    }
}

vector<int> constructZFunc(string s){
    int n = s.size();
    vector<int> z(n);
    int l, r;
    l = r = 0;
    z[0] = 0;
    rep(i, 1, n-1){
        z[i] = 0;
        if(i<=r){
            z[i] = min(r-i+1, z[i-l]);  /// initialization, req. for linear time approach.
        }
        while(i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if(i+z[i]-1 > r){
            r = i+z[i]-1;
            l = i;
        }
    }
    return z;
}

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

    ll h, k;
    cin>>h>>k;
    ll a[h];
    fr(i, h) cin>>a[i];

    sort(a, a+h);
    ll cnt = 0;
    cnt = accumulate(a, a+max(0ll, h-k), 0ll);
    cout<<cnt;

    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for (i=a;i<b;i++)
#define rep2(i,a,b) for (i=a;i>=b;i--)
#define mod 1000000007
#define mod2 998244353
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF  1e9+5
#define f first
#define s second
#define endl '\n'
#define ll long long
#define ii pair <int,int>
#define pll pair <ll,ll>
#define vi vector <int>
#define vl vector <ll>
#define vvi vector < vi >
#define vii vector < ii >
#define vpl vector < pll >
#define vvii vector < vii >
#define vll vector < ll >
#define vb  vector <bool>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define cset(a) __builtin_popcountll(a)
#define FILL(a, b, T) fill_n((T *)a, sizeof(a) / sizeof(T), b)
#define debug(x) cerr << #x << " is " << x << endl;
#define st pair<ll,pll>
using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// unordered_map<long long, int, custom_hash> safe_map;
// FOR VIEWERS, CODE STARTS HERE

int main()
{
    // #ifndef ONLINE_JUDGE
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
    // #endif
    FIO;
    ll t, q, n, m, prev, maxx,  i, j, k1, k2, k3, k, x, y, flag, sum, cnt, ans;
    cin>>n;
    string ss1, ss2;
    cin>>ss1>>ss2;
    rep(i,0,sz(ss1))
    {
        cout<<ss1[i]<<ss2[i];
    }
    cout<<endl;
    return 0;    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();
    int T = sc.nextInt();
    int A = sc.nextInt();

    int index = 0;
    double min = Integer.MAX_VALUE;
    for (int i=0; i<N; i++) {
      int h = sc.nextInt();
      double t = T - h * 0.006d;
      if (Math.abs(A - t) < min) {
        index = i;
        min = Math.abs(A - t);
      }
    }

    System.out.println(index+1);

  }
}

Measured memory_bytes: 24788
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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 N, M;
lint a[1010], b[1010], c[1010][20];
lint dp[1 << 12];

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

  cin >> N >> M;
  rep(i, M) {
    cin >> a[i] >> b[i];
    rep(j, b[i]) {
      cin >> c[i][j];
      c[i][j]--;
    }
  }

  for (int i = 0; i < 1 << N; i++) dp[i] = INF;
  dp[0] = 0;

  for (int i = 0; i < M; i++) {
    int now = 0;
    for (int j = 0; j < b[i]; j++) {
      now |= (1 << (c[i][j]));
    }

    for (int bit = 0; bit < 1 << N; bit++) {
      chmin(dp[bit | now], dp[bit] + a[i]);
    }
  }

  if (dp[(1 << N) - 1] == INF) dp[(1 << N) - 1] = -1;
  cout << dp[(1 << N) - 1] << endl;

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std ; 
#define ll long long
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
#define test   ll int tcase ; cin>>tcase ; while(tcase--) 
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
    io ; 
   int n,k; cin>>n>>k ; 
   int arr[n]  ; 
   for(int i = 0  ; i<n ; i++) cin>>arr[i] ; 

   sort(arr,arr+n) ;
   int sum = 0 ; 
   for(int i = 0 ; i<k ;i++){
       sum+=arr[i] ; 
   }   
   cout<<sum ; 
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int n,tmp,ans;
double ave;
std::vector<int> x;


void solve(){
        tmp=0;
        rep(i,n){
                ans+=pow(x.at(i)-ave,2);
        }
        cout<<ans<<endl;
}

int main(){
        cin>>n;
        ave=0;
        rep(i,n){
                cin>>tmp;
                x.push_back(tmp);
                ave+=tmp;
        }
        ave/=n;
        ave=round(ave);

        solve();
        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 A, B, C, X, cnt;
  cin >> A >> B >> C >> X;
  rep(i, A+1){
    rep(j, B+1){
      rep(k, C+1){
        if(500*i+100*j+50*k==X) cnt++;
      }
    }
  }
  cout << cnt << endl;
} 

Measured memory_bytes: 256
import collections

Point = collections.namedtuple("Point", "x y")
Line = collections.namedtuple("Line", "first second")


def cross(line1, line2):
    def get_s(a, b, c):
        x1 = a.x - c.x
        x2 = b.x - c.x
        y1 = a.y - c.y
        y2 = b.y - c.y
        return (x1 * y2) - (x2 * y1)

    s1 = get_s(line1.first, line1.second, line2.first)
    s2 = get_s(line1.first, line1.second, line2.second)

    if not (s1 > 0) ^ (s2 > 0):
        return False

    s3 = get_s(line2.first, line2.second, line1.first)
    s4 = get_s(line2.first, line2.second, line1.second)

    if not (s3 > 0) ^ (s4 > 0):
        return False

    return True


if __name__ == '__main__':
    while 1:
        try:
            xa, ya, xb, yb, xc, yc, xd, yd = map(float, raw_input().split(','))
            A = Point(xa, ya)
            B = Point(xb, yb)
            C = Point(xc, yc)
            D = Point(xd, yd)
            points = [A, B, C, D]
            f = False
            for i in xrange(4):
                line1 = Line(points[(i + 0) % 4], points[(i + 2) % 4])
                line2 = Line(points[(i + 1) % 4], points[(i + 3) % 4])
                if not cross(line1, line2):
                    f = True

            for i in xrange(4):
                line1 = Line(points[i], points[(i + 1) % 4])
                line2 = Line(points[(i + 2) % 4], points[(i + 3) % 4])
                if cross(line1, line2):
                    f = True

            if f:
                print "NO"
            else:
                print "YES"
        except EOFError:
            break

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,k;
	scanf("%d %d",&n,&k);
	int id;
	for(int i=0;i<n;i++) {
		int t;
		scanf("%d",&t);
		if(t == 1) {id = i;}
	}
	int bs = 999999;
	for(int i=min(id-k+1,0);i<=id;i++) {
		int lf = (i+k-2)/(k-1);
		int rt = ((n-i-1)+k-2)/(k-1);
		bs = min(bs,lf+rt);
	}
	printf("%d\n",bs);
}

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

for _ in range(t):
    n = int(input())
    block = list(map(int, input().split()))

    diff = []
    for i in range(len(block) - 1):
        d = block[i+1] - block[i]
        diff.append(d)

    up = max(0, max(diff))
    down = abs(min(0, min(diff)))
    print(up, down)



Measured memory_bytes: 5604
# Vicfred
# https://atcoder.jp/contests/abc044/tasks/abc044_b
# implementation
w = input()

english = {}

for ch in w:
    if ch in english:
        english[ch] += 1
    else:
        english[ch] = 1

beautiful = True
for value in english.values():
    if value%2 == 1:
        beautiful = False

if beautiful:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double sum = 0;
        for (int i = 0; i < n; i++) {
            sum += 1/sc.nextDouble();
        }
        System.out.println(1/sum);
    }
}

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

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            bool[] prime = new bool[1000000];
            for(int i=3; i < 1000000; i += 2) {
                prime[i] = true;
            }
            prime[2] = true;
            for(int i=3; i < 1000000; i += 2) {
                if(prime[i]) {
                    for(int l = 2; i * l < 1000000; ++l) {
                        prime[l * i] = false;
                    }
                }
            }
            string input;
            int count;
            while((input = Console.ReadLine()) != null) {
                int max = int.Parse(input);
                count = max >= 2 ? 1 : 0;
                for(int i=3; i <= max; i += 2) {
                    count += prime[i] ? 1 : 0;
                }
                Console.WriteLine(count);
            }
        }
    }
}

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

using namespace std;

typedef long long ll;

char s[200100];
ll sol,b;

int main(){
	scanf("%s",s);
	int n = strlen(s);
	for(int i = 0; i < n; i++) {
		if(s[i] == 'B')b++;
		else sol += b;
	}
	
	printf("%lld",sol);
	return 0;
}

Measured memory_bytes: 384
NK = [int(i) for i in input().split(" ")]
info = []
for i in range(NK[1]):
    d = int(input())
    A = [int(i) for i in input().split(" ")]
    info.append(A)

have_okasi = [0]*NK[0]
for A in info:
    for a in A:
        have_okasi[a-1] += 1
print(have_okasi.count(0))

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{

    vector<int> v(5);
    rep(i, 5) cin >> v[i];

    rep(i, 5)
    {
        if (!v[i])
        {
            cout << i + 1 << '\n';
            return 0;
        }
    }
}


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

def divisore(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


def factorization(n):
    p=2
    fcr=[]
    while p*p<=n:
        while n%p==0:
            fcr.append(p)
            n//=p
        p+=1
    if n>1:
        fcr.append(n)
    return fcr


l=divisore(n)[1:]

ans=0
for i in l:
  t_l=factorization(i)
  if len(set(t_l))!=1:
    continue


  if n%i==0:
    ans+=1
    n//=i

print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> ans;

  int sum = 0;
  for(int i = 1; i <= n; ++i){
    sum += i;
    ans.push_back(i);
    if(sum >= n){
      for(auto itr : ans){
        if(sum - n != itr){
          cout << itr << endl;
        }
      }
      return 0;
    }
  }
  return 0;
}


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

int main() {
  int a, b, ans = 0;
  cin >> a >> b;
  for(int i = 0; i <= a; i++) {
    for(int j = 0; j <= a; j++) {
      if(i + j <= b && i + j + a >= b) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
while True:
	try:
		n, m = (int(x.strip()) for x in raw_input().split())
		if n == 0 and m == 0: break
		p = [int(x.strip()) for x in raw_input().split()]
		s = sum(p)
		p.sort(reverse=True)
		for x in p[m - 1::m]:
			s -= x
		print s
	except:
		pass

Measured memory_bytes: 4320
from sys import stdin
#import numpy as np
 
readline = stdin.readline
 
N, Q = map(int, readline().split()) 
C = list(map(int, readline().split())) 
S = [list(map(int, readline().split())) for _ in range(Q)] 
#print(S)
def main(N, Q, C, S):    
  # Binary Indexed Tree 
  # https://juppy.hatenablog.com/entry/2018/11/17/%E8%9F%BB%E6%9C%AC_python_Binary_Indexed_Tree_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0
  b = [0 for _ in range(N+1)]
  def BIT_query(idx): #idxまでの和(1からスタート)
    res_sum = 0
    while idx > 0:
      res_sum += b[idx]
      idx -= idx&(-idx) #一番下の位を減らす（例：13=1011 → 1010 → 1000） 
    return res_sum
  def BIT_update(idx,x): #idxをx増やした時
    while idx <= N:
      b[idx] += x
      idx += idx&(-idx) #一番下の位を繰り上げる（例：13=1011 → 1100 → 10000 ※N=16のとき） 
    return
 
  loc = [0 for _ in range(N)] #各種類の玉のうちの最右端の所在地
  S = [(S[i], i) for i in range(Q)] #クエリ
  S.sort(key = lambda s: s[0][1]) #区間の右端でソート
  #S = np.array(S, dtype = np.int64)
  #print(S)
  ans = [0 for _ in range(Q)]
  k = 0
  for j in range(N):
    if loc[C[j]-1] > 0: #玉の更新
      BIT_update(loc[C[j]-1], -1)
    loc[C[j]-1] = j+1
    BIT_update(j+1, 1)  
    
    if S[k][0][1] == j+1:
      t = BIT_query(j+1)
    while k < len(S) and S[k][0][1] == j+1: #クエリへの返答
      ans[S[k][1]] = t - BIT_query(S[k][0][0]-1)
      k += 1
    if k == len(S):
      break
  return ans
 
ans = main(N, Q, C, S)
for a in ans:
  print(a)

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

using namespace std;

#define int long long
#define MOD 1000000007


#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()


#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }
 
//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
 

int A,B,C;
int N;
int l[8];

int dfs(int i,int a,int b,int c){

    if(i==N){
        if(a==0||b==0||c==0){
            return 1e9;
        }else{
            return abs(A-a)+abs(B-b)+abs(C-c);
        }
    }

    int res1 = dfs(i+1,a,b,c);
    int res2 = dfs(i+1,a+l[i],b,c)+(a>0?10:0);
    int res3 = dfs(i+1,a,b+l[i],c)+(b>0?10:0);
    int res4 = dfs(i+1,a,b,c+l[i])+(c>0?10:0);

    return min({res1,res2,res3,res4});


}

signed main(){
 
    cin >> N >> A >> B >> C;

    //int l[N];
    rep(i,N){
        cin >> l[i];
    }

   cout << dfs(0,0,0,0)<<endl;

    return 0;
 
}


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

int main()
{
  int N; cin>>N;
  vector<int> c(N);
  for(int i=0;i<N;i++) cin>>c[i];

  int Q; cin>>Q;
  vector<int> cur(N,0);
  while(Q--){
    int x,y,z; cin>>x>>y>>z; y--;
    if(x==2){
      if(z>cur[y]){
	cout<<y+1<<endl;
	return 0;
      }
      cur[y]-=z;
    }
    if(x==1){
      if(cur[y]+z>c[y]){
	cout<<y+1<<endl;
	return 0;
      }
      cur[y]+=z;
    }
  }
  cout<<0<<endl;
}



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

int main()
{
	long long N, steps;
	long long A[2] = { 1,1 };
	N = 0; steps = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[1];
		if (A[1] < A[0]) {
			steps += A[0] - A[1];
		}
		if (A[1] >= A[0]) {
			A[0] = A[1];
		}
	}
	cout << steps << endl;
	return 0;
}

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

int main(){
  int n;cin>>n;
  int a[2+1][n+1];
  memset(a,0,sizeof(a));
  for(int i=1;i<3;i++){
    for(int j=1;j<n+1;j++){
      cin>>a[i][j];
      a[i][j]=max(a[i-1][j]+a[i][j],a[i][j-1]+a[i][j]);
    }
  }

  cout<<a[2][n]<<endl;
    
  
  return 0;
}


Measured memory_bytes: 256
/*
	Author: Arjan Singh Bal, IIITM Gwalior
	"Everything in this world is magic, except to the magician"
*/

#include                        <bits/stdc++.h>
#ifdef LOCAL
#include                        "pprint.hpp"
#endif

using namespace std;

template <typename Arg1>
void prn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void prn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; prn(args...); }

template <typename Arg1>
void prs(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void prs(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; prs(args...); }

template <typename Arg1>
void read(Arg1&& arg1)
{ cin>>arg1; }
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args)
{ cin>>arg1; read(args...); }

#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(int i=0; i<n;++i)
#define fr1(i, n)               for(int i=1; i<=n; ++i)
#define rfr(i, n)			    for(int i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
typedef double					f80;

const int mod=1e9+7;

vi vec;

map<ll, int> rem;

ll cal(ll n)
{
	if(!n) return 1;
	if(n==1) return 2;
	if(rem.count(n)) return rem[n];
	if(n&1) return rem[n]=(2*cal(n/2)+cal(n/2-1))%mod;
	return rem[n]=(2*cal(n/2-1)+cal(n/2))%mod;	
}

void solve()
{
	ll n;
	read(n);
	prn(cal(n));
}

int main()
{
#ifdef LOCAL
	freopen("in.txt" , "r" , stdin);
	//freopen("out.txt" , "w" , stdout);
#else	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#endif
	
	int t=1;
	//read(t);
	fr1(tc, t){
		//cout<<"Case #"<<tc<<": ";
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL A, B;

// クッキーの受け渡しを計算.
// @param k: 受け渡しの回数.
// @param b: ターン.
// @return : 再帰処理を行う.
void recursive(int k, bool b){
    if(k == 0) return;
    if(b){
        if(A & 1) A--;
        A >>= 1, B += A;
    }else{
        if(B & 1) B--;
        B >>= 1, A += B;
    }
    recursive(k - 1, !b);
}

int main(){
    
    // 1. 入力情報.
    int K;
    scanf("%lld %lld %d", &A, &B, &K);
    
    // 2. クッキーの枚数を計算.
    recursive(K, true);
    
    // 3. 出力.
    printf("%lld %lld\n", A, B);
    return 0;
    
}

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

using namespace std;

struct RT_node {
	int val;
	bool mod;
};

const int MAX_N = 200010;
int N, Q;
int RT_size;
RT_node RT[3][MAX_N * 4];

void RT_build(int k, int p, int L, int R) {
	RT[k][p].val = N;
	if (R - L == 1) return;
	RT_build(k, p << 1, L, (L + R) / 2);
	RT_build(k, (p << 1) | 1, (L + R) / 2, R);
}

void propagate(int k, int p) {
	int l = p << 1, r = (p << 1) | 1;
	RT[k][p].mod = false;
	if (RT[k][l].val > RT[k][p].val) {
		RT[k][l].val = RT[k][p].val;
		RT[k][l].mod = true;
	}
	if (RT[k][r].val > RT[k][p].val) {
		RT[k][r].val = RT[k][p].val;
		RT[k][r].mod = true;
	}
}

void RT_update(int k, int p, int L, int R, int x, int y, int v) {
	if (x >= R || y <= L) return;
	if (L >= x && R <= y) {
		if (RT[k][p].val > v) {
			RT[k][p].val = v;
			RT[k][p].mod = true;
		}
		return;
	}
	
	if (RT[k][p].mod) propagate(k, p);
	RT_update(k, p << 1, L, (L + R) >> 1, x, y, v);
	RT_update(k, (p << 1) | 1, (L + R) >> 1, R, x, y, v);
}

int RT_query(int k, int p, int L, int R, int x) {
	if (x < L || x >= R) return 1000000;
	if (R - L == 1)
		return RT[k][p].val;
	
	if (RT[k][p].mod) propagate(k, p);
	return min(RT_query(k, p << 1, L, (L + R) >> 1, x),
			   RT_query(k, (p << 1) | 1, (L + R) >> 1, R, x));
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N >> Q;
	
	RT_size = 1;
	while (RT_size <= N)
		RT_size <<= 1;
	RT_build(1, 1, 0, RT_size);
	RT_build(2, 1, 0, RT_size);
	
	long long ans = (long long)(N - 2) * (long long)(N - 2);
	for (int i = 0; i < Q; i++) {
		int t, x;
		cin >> t >> x;
		int res = RT_query(t, 1, 0, RT_size, x);
		ans -= max(0LL, (long long)(res - 2));
		RT_update(3 - t, 1, 0, RT_size, 1, res, x);
	}
	
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 11844
#include <iostream>
#include<fstream>
#include<string>
#include<vector>
#include<iomanip>
using namespace std;

int main()
{
	int K;
	int X;
	while (cin >> K >> X) {
		if (K * 500 >= X)cout << "Yes";
		else cout << "No";
	}
	return 0;
}



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

int main() {

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
<?php

	class Scanner {
	    private $arr = [];
	    private $count = 0;
	    private $pointer = 0;
	    public function next() {
	        if($this->pointer >= $this->count) {
	            $str = trim(fgets(STDIN));
	            $this->arr = explode(' ', $str);
	            $this->count = count($this->arr);
	            $this->pointer = 0;
	        }
	        $result = $this->arr[$this->pointer];
	        $this->pointer++;
	        return $result;
	    }
	    public function hasNext() {
	        return $this->pointer < $this->count;
	    }
	    public function nextInt() {
	        return (int)$this->next();
	    }
	    public function nextDouble() {
	        return (double)$this->next();
	    }
	}
	
	class out {
	    public static function println($str = "") {
	        echo $str . PHP_EOL;
	    }
	}
	
	$sc = new Scanner();
	
	while (true) {
		$n = $sc->nextInt();
		if ($n === 0) {
			break;
		}
		
		$sum = 0;
		$array = [];
		for ($i = 0; $i < $n; $i++) {
			$array[$i] = $sc->nextInt();
			$sum += $array[$i];
		}
		
		$avg = $sum / $n;
		
		$count = 0;
		foreach ($array as $a) {
			if ((int)$avg >= $a) {
				++$count;
			}
		}
		out::println($count);
	}


Measured memory_bytes: 12632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
const int INF=100000000;

bool hantei(LL N,LL K)
{
	if(N%K==1)return true;
	else if(N%K==0)return hantei(N/K,K);
	else return false;
}
int main(){
	LL n=0;
	LL ans=0;
	cin>>n;
	for(LL i=2;i<=sqrt(n);i++)
	{
		if(hantei(n,i))ans++;
		if((n-1)%i==0 && (n-1)/i>sqrt(n))ans++;			
	}
	if(n!=2)cout<<ans+2<<endl;
	else cout<<1<<endl;
	return 0;
}

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

const int mod = 1e9 + 7;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
#define ll long long
#define vi vector < int >
#define si set <int>
#define mii map <int, int>
#define vll vector < ll >
#define pii pair < int , int >
#define ff first
#define tc \
    int ttt; cin >> ttt;\
    while(ttt --)
#define ss second
#define f(i,a,b) for(int i=a;i<b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define nl '\n'
#define all(x) x.begin() , x.end()
#define mne min_element
#define mxe max_element
#define pr(x) cout << fixed << setprecision(10) << x
ll gcd(ll x, ll y) {return y == 0 ? x : gcd(y, x % y);}
int logg(ll x , ll y) {if (x == 0) return -1; return logg(x / y, y) + 1;}
ll poww(ll a, ll b, ll m) {
	if (b == 0) return 1;
	ll ans = 1;
	ans = poww(a, b >> 1, m);
	ans = (ans * ans) % m;
	if (b & 1) ans = (ans * a) % m;
	return ans;
}
// Start of code
int n, k;
int stones[100005];
int dp[100005];

string solve() {

	f(i, 1, k + 1) {
		f(j, 0, n) {
			if (stones[j] > i) continue;
			if (dp[i - stones[j]] == 0) dp[i] = 1;
		}
	}
	return dp[k] ? "First" : "Second";
}

int32_t main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast;
	cin >> n >> k;
	f(i, 0, n) cin >> stones[i];
	cout << solve() ;
}


Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second
int main()
{
    string x1;
    string x2;
    cin >> x1 >> x2;
    if(x2.length() == x1.length()+1)
    {
        ll fl = 1;
        for(ll i=0;i<x1.length();i++)
        {
            if(x1[i]!=x2[i]) fl = 0;
        }
        if(fl==0)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
}
    

Measured memory_bytes: 3576
fun main() {
    val n = readLine()!!
    var result = if(n.last() == '3'){
        "bon"
    }else if (n.last() == '0' || n.last() == '1' || n.last() == '6' || n.last() == '8'){
        "pon"
    }else {
        "hon"
    }

    println(result)
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD =  998244353;

     signed main(){
     int n,t,a;
     cin>>n>>t>>a;
     int h[n],ans=0;
     for(int i=0;i<n;i++)cin>>h[i];
     for(int i=0;i<n;i++)if(abs(1000*(t-a)-h[i]*6)<abs(1000*(t-a)-h[ans]*6))ans=i;
     cout<<ans+1<<endl;

     }

Measured memory_bytes: 256
#include<iostream>

int main(){
	int dp[20][20], map[20][20];
	int w, h;
	while(std::cin >> w >> h, w){
		for(int i=0;i<16;i++){
			for(int j=0;j<16;j++){
				dp[i][j] = 0;
				map[i][j] = 0;
			}
		}

		int n;
		std::cin >> n;
		for(int i=0;i<n;i++){
			int a, b;
			std::cin >> a >> b;
			map[b-1][a-1] = 1;
		}

		if(map[0][0] != 1){
			dp[0][0] = 1;
		}
		for(int i=1;i<w;i++){
			if(map[0][i] != 1){//通れる
				dp[0][i] = dp[0][i-1];
			}
		}
		for(int i=1;i<h;i++){
			if(map[i][0] != 1){
				dp[i][0] = dp[i-1][0];
			}
		}

		for(int y=1;y<h;y++){
			for(int x=1;x<w;x++){
				if(map[y][x] != 1){
					dp[y][x] = dp[y-1][x] + dp[y][x-1];
				}
			}
		}
	
		std::cout << dp[h-1][w-1] << std::endl;
	}
}

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

#define double long double 
typedef long long ll;
typedef long long lint;
constexpr double EPS = 1e-5;
vector<ll> MODS = {

1000000861,
1000000871,
1000000891,
1000000901,
1000000919,
1000000931,
1000000933,
1000000993,
1000001011,
1000001021,
1000001053,
1000001087,
1000001099,
1000001137,
1000001161,
1000001203,
1000001213,
1000001237,
1000001263,
1000001269,
1000001273,
1000001279,
1000001311,
1000001329,
1000001333,
1000001351,
1000001371,
1000001393,
1000001413,
1000001447,
1000001449,
1000001491,
1000001501,
1000001531,
1000001537,
1000001539,
1000001581,
1000001617,
1000001621,
1000001633,
1000001647,
1000001663,
1000001677,
1000001699,
1000001759,
1000001773,
1000001789,
1000001791,
1000001801,
1000001803,
1000001819,
1000001857,
1000001887,
1000001917,
1000001927,
1000001957,
1000001963,
1000001969,
1000002043
};

lint gcd(lint x, lint y){
    while(y){
        lint r = x % y;
        x = y;
        y = r;
    }
    return x;
}

lint extgcd(lint a, lint b, lint& x, lint& y){
    lint d = a;
    if(b){
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else{
        x = 1;
        y = 0;
    }
    return d;
}

lint mod_inverse(lint a, lint m){
    lint x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

struct edge{
    int to;
    double cost;
    vector<ll> x;
};

int MOD_SIZE;
vector<vector<edge> > g;
vector<bool> used;
vector<double> cost;
vector<vector<ll> > modulo;

bool dfs(int v, int p){
    used[v] = true;
    for(auto &e : g[v]){
        if(e.to == p) continue;
        if(used[e.to]){
            if(abs((cost[v]+e.cost)-cost[e.to]) > EPS){
                return false;
            }
            for(int i=0;i<MOD_SIZE;i++){
                if(modulo[i][v]*e.x[i]%MODS[i] != modulo[i][e.to]){
                    return false;
                }
            }
        }
        else{
            cost[e.to] = cost[v] + e.cost;
            for(int i=0;i<MOD_SIZE;i++){
                modulo[i][e.to] = modulo[i][v]*e.x[i]%MODS[i];
            }
            if(!dfs(e.to, v)) return false;
        }
    }
    return true;
}

int main(){
    int n, m;
    cin >> n >> m;
    g.resize(n);
    used.resize(n,false);
    cost.resize(n,0);
    MOD_SIZE=MODS.size();
    modulo.resize(MOD_SIZE,vector<ll>(n,1));
    for(int i=0;i<m;i++){
        int a,b;
        ll x;
        cin >> a >> b >> x;
        a--; b--;
        vector<ll> tmp(MOD_SIZE);
        for(int j=0;j<MOD_SIZE;j++){
            tmp[j] = x%MODS[j];
        }
        g[a].push_back({b,log2(x), tmp});
        for(int j=0;j<MOD_SIZE;j++){
            tmp[j] = mod_inverse(x, MODS[j]);
        }
        g[b].push_back({a,-log2(x), tmp});
    }
    bool ok = true;
    for(int i=0;i<n;i++){
        if(!used[i]){
            ok &= dfs(i,-1);
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 172696
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  if(S[0]==S[S.size()-1]) {
    if(S.size()%2==0) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
  }
  else {
    if(S.size()%2!=0) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
  }
}



Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;

typedef long long ll;
const int mod = 1000000007;

struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};


int main() {
	int N, K;
	N = K = 100000;
	cin >> N >> K;
	vector<ll> A(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	sort(A.begin(), A.end());

	combination C(N);

	mint ans = 0;
	for (int i = 0; i < N; ++i)
		ans += mint(A[i]) * (C(i, K - 1) - C(N - i - 1, K - 1));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5148
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<10&&b<10) cout<<a*b<<endl;
    else cout<<"-1"<<endl;
    return 0;
}

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

ll n, m, ans;
map<ll, ll> cnt;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;

    ++cnt[0];
    ll cur = 0;

    for (int i = 0; i < n; ++i) {
        ll a; cin >> a;
        cur += a;
        cur %= m;
        ans += cnt[cur]++;
    }
    cout << ans;
}


Measured memory_bytes: 7484
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
now = 0
d = []
d.append(0)
for i in range(len(a)):
    d.append(d[i] + a[i])
for k in d:
    if k <= x:
        ans += 1
print(ans)

Measured memory_bytes: 5048
#include <iostream>

using namespace std;

int main(){

    long long int n,a=0,tmp;
    char p;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p>>tmp;
        if(p=='('){
            a+=tmp;
        }else{
            a-=tmp;
        }
        if(a<0){
             cout<<"NO"<<endl;
             return 0;
        }
    }
    if(a==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b; cin >> a >> b;
  ll ans= 0;
  REP(i,45){
      if(i==0){
          if(((b+1)/2 - a/2) % 2 == 1){
              ans++;
          }
          continue;
      }
      ll now = 1ll << i;
          ll  cnt = 0;
          if((a/now) % 2 == 1){
              cnt += now - (a - a/now * now );
          }
          if((b/now) % 2 == 1){
              cnt += b - b/now  * now + 1;
          }
          if(cnt%2 == 1){
              ans += now;
          }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256