akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,k,place=0,l;
  long long int ans=1000000000;
  long long int plus,zero;
  long long int x[100000];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int i=k-1;i<n;i++){
    if(x[i]<=0 && x[i-k+1]<=0){
      ans=min(ans,abs(x[i-k+1]));
    }
    else if(x[i]>=0 && x[i-k+1]<=0){
      ans=min(ans,abs(x[i]*2)+abs(x[i-k+1]));
      ans=min(ans,abs(x[i])+abs(x[i-k+1]*2));
    }
    else if(x[i]>=0 && x[i-k+1]>=0){
      if(ans<x[i]) break;
      else ans=min(ans,abs(x[i]));
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();//ヒント
        int[] s = new int[m];
        int[] c = new int[m];
        int[] ans = new int[n];
        Arrays.fill(ans,-1);
        int range = (int)Math.pow(10,n);
        for(int i = 0;i < m;i++){
            s[i] = sc.nextInt()-1;
            c[i] = sc.nextInt();
        }
            
        for(int i = 0;i <= range;i++){
            String str = String.valueOf(i);
            if(str.length()==n){
                boolean flag = true;
                for(int j=0;j<m;j++){
                    flag = flag&&(str.charAt(s[j])==c[j]+'0');
                }
                if(flag){
                    System.out.println(i);
                    return;
                }
            }
        }
        System.out.println(-1);
    }
}

Measured memory_bytes: 23760
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll d; cin >> d;
    vector<ll> c(26);
    rep(i,26) cin >> c.at(i);
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,d) rep(j,26) cin >> s.at(i).at(j);
    vector<ll> last(26,0);

    ll bestsat = -1;

    srand(time(NULL));
    vector<ll> best(d,0);
    ll times = 100000;
    while(times--){
        ll sat = 0;
        vector<ll> ans(d,0);
        rep(i,d){
            ans.at(i) = (rand() % 26) + 1;
        }
            for(int i=1;i<=d;i++){
                ll t = ans.at(i-1);
                t--;
                last.at(t) = i;
                sat += s.at(i-1).at(t);
                for(int j=0;j<26;j++){
                    sat -= c.at(j) * (i - last.at(j));
                }
                //cout << sat << endl;
                if(sat>bestsat){
                    bestsat = sat;
                    best = ans;
                }
            }
    }

    rep(i,d){
        cout << best.at(i) << endl;
    }
  
    //cout << bestsat << endl;

    /*
    for(int i=1;i<=d;i++){
        ll t; cin >> t;
        t--;
        last.at(t) = i;
        sat += s.at(i-1).at(t);
        for(int j=0;j<26;j++){
            sat -= c.at(j) * (i - last.at(j));
        }
        cout << sat << endl;
    }
    */
    return 0;
}

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

template<typename T> inline void chmin(T &a, T b){
	if(a > b) a = b;
}

int main() {
	
	int n, w;
	cin >> n >> w;
	vector<int> weight(n), value(n);
	rep(i, n) cin >> weight[i] >> value[i];
	
	vector<vector<ll>> dp(n+1, vector<ll>(100001, 1LL << 60));
	
	dp[0][0] = 0;
	for(int i=0; i<n; i++){
		for(int sum_v=0; sum_v<100001; sum_v++){
			if(sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
			chmin(dp[i+1][sum_v], dp[i][sum_v]);
		}
	}
	
	ll ans = 0;
	rep(i, 100001) if(dp[n][i] <= w) ans = i;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 80256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = INT_MIN;
    for(int l=0; l<=n; ++l){
        for(int r=0; l+r<=n; ++r){
            if(l + r > k)
                continue;

            vector<int> w;
            for(int i=0; i<l; ++i)
                w.push_back(v[i]);
            for(int i=0; i<r; ++i)
                w.push_back(v[n-1-i]);

            int sum = accumulate(w.begin(), w.end(), 0);
            sort(w.begin(), w.end());
            for(int i=0; i<min(k-l-r,(int)w.size()); ++i)
                sum -= min(0, w[i]);
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) { cin >> A[i]; }
    sort(A.begin(), A.end());
    vector<ll> B(N);
    B[0] = A[0];
    REP(i, N - 1) { B[i + 1] = B[i] + A[i + 1]; }
    //どの生き物も，大きさが自分の
    // 2 倍以下であるような他の生き物を
    // 吸収することができます
    int cnt = 0;
    // print(A);
    // print(B);
    REP(i, N - 1) {
        if(A[i + 1] > 2 * B[i]) {
            cnt = i + 1;
        }
    }

    cout << N - cnt << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

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

int main(void){
  int n, i;
  vector<int> a;
  vector<int> lGcd;
  vector<int> rGcd;

  cin >> n;
  a.resize(n);
  lGcd.resize(n);
  rGcd.resize(n);
  
  for(i=0;i<n;i++){
    cin >> a[i];
  }

  lGcd[0] = a[0];
  rGcd[n-1] = a[n-1];
  for(i=1;i<n;i++){
    lGcd[i] = gcd(lGcd[i-1],a[i]);
    rGcd[n-1-i] = gcd(a[n-1-i],rGcd[n-i]);
  }

  int ans = max(rGcd[1],lGcd[n-2]);
  for(i=1;i<n-1;i++){
    ans = max(ans,gcd(lGcd[i-1],rGcd[i+1]));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int first = scan.nextInt();
        double[] inputList = new double[first];
        double[] outputList = new double[first];
        
        for (int i = 0; i < first; i++) {
            inputList[i] = scan.nextInt();
        }
        
        double result = 0;
        for (int j = 0; j < first; j++) {
            result += 1 / inputList[j];
        }   
        System.out.println(1 / result);
    }
 }

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <numeric>
#define rep(i,s,n) for (int i = s; i < n; ++i)
#define drep(i,s,n) for (int i = n; i >= s; --i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a, int b)
{
   if (a%b == 0) return(b);
   else          return(gcd(b, a%b));
}
int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
void printvv(vector<vector<auto>> vv, int n)
{
  cout << '[' << endl;
  rep(q, 0, n)
  {
    cout << '[';
    rep(p, 0, n)
    {
      cout << vv.at(q).at(p) << ',';
    }
    cout << ']' << endl;
  }
  cout << ']' << endl;
}

void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

//------------------------------------------------------------
void solve() {
  int sum=0;
  vector<int> v(3);
  rep(i,0,3) cin>>v.at(i);

  sort(all(v));

  if ((v.at(2)-v.at(0))%2 != (v.at(2)-v.at(1))%2)
  {
    v.at(2)++; v.at(1)++; sum++;
  }

  v.at(0) += (v.at(2)-v.at(1)); sum += (v.at(2)-v.at(1));

  sum+=(v.at(2)-v.at(0))/2;

  print(sum);
}


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

using namespace std;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vii = vector<ii>;
using vvii = vector<vii>;

constexpr int INF = 2000000000;
constexpr ll LLINF = 9000000000000000000;

struct UnionFind {
	vi par, rank, size; int c;
	UnionFind(int n) : par(n), rank(n,0), size(n,1), c(n) {
		for (int i = 0; i < n; ++i) par[i] = i;
	}

	int find(int i) { return (par[i] == i ? i : (par[i] = find(par[i]))); }
	bool same(int i, int j) { return find(i) == find(j); }
	int get_size(int i) { return size[find(i)]; }
	int count() { return c; }

	void merge(int i, int j) {
		if ((i = find(i)) == (j = find(j))) return;
		c--;
		if (rank[i] > rank[j]) swap(i, j);
		par[i] = j; size[j] += size[i];
		if (rank[i] == rank[j]) rank[j]++;
	}
};

// Edges are given as (weight, (u, v)) triples.
struct E {int u, v; ll weight;};
bool operator<(const E &l, const E &r){return l.weight < r.weight;}
ll kruskal(vector<E> &edges, int V) {
	sort(edges.begin(), edges.end());
	ll cost = 0;
	int count = 0;
	UnionFind uf(V);
	for (auto &e : edges) {
		if (!uf.same(e.u, e.v)) {
			// (w, (u, v)) is part of the MST
			cost += e.weight;
			uf.merge(e.u, e.v);
			if ((++count) == V - 1) break;
		}
	}
	return cost;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int N;
	cin >> N;
	vii byx(N, {0, 0}), byy(N, {0, 0});
	for (int i = 0; i < N; ++i) {
		cin >> byx[i].first >> byy[i].first;
		byx[i].second = byy[i].second = i;
	}
	
	sort(byx.begin(), byx.end());
	sort(byy.begin(), byy.end());
	
	vector<E> edges;
	for (int i = 0; i + 1 < N; ++i)
		edges.push_back({
			(int)byx[i].second,
			(int)byx[i+1].second, 
			byx[i+1].first - byx[i].first});
	for (int i = 0; i + 1 < N; ++i)
		edges.push_back({
			(int)byy[i].second,
			(int)byy[i+1].second, 
			byy[i+1].first - byy[i].first});
	
	cout << kruskal(edges, N) << endl;
	
	return 0;
}


Measured memory_bytes: 9452
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k=nxt();
    vector <bool> visited;
    visited.resize(k,0);
    visited[1]=1;
    vector <int> dist;
    dist.resize(k,INT_MAX);
    dist[1]=1;
    deque <int> q;
    q.push_back(1);
    while(q.size())
    {
        int x=q.front();
        q.pop_front();
        if(dist[(x*10)%k]>dist[x])
        {
            //visited[(x*10)%k]=1;
            q.push_front((x*10)%k);
            dist[(x*10)%k]=dist[x];
        }
        if(dist[(x+1)%k]>dist[x])
        {
            //visited[(x+1)%k]=1;
            q.push_back((x+1)%k);
            dist[(x+1)%k]=dist[x]+1;
        }
        
    }
    cout<<dist[0]<<endl;
    
    
    return 0;   
}






 
 


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using 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, n, m) for(int (i) = (n); (i) <= (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 998244353;


int main(){
  int W, H, N;
  cin >> W >> H >> N;
  int lx = 0, rx = W, bh = 0, th = H;
  REP(i, N){
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1){
      lx = max(lx, x);
    }
    else if(a==2){
      rx = min(rx, x);
    }
    else if(a==3){
      bh = max(bh, y);
    }
    else if(a==4){
      th = min(th, y);
    }
  }
  cout << max(0, rx-lx) * max(0, th-bh) << endl;
  return 0;
}


Measured memory_bytes: 256
#n = int(input())
#m = int(input())
#k = int(input())
w, h, x, y = map(int, input().split())
#n, m, k = map(int, input().split())
#a = list(map(int, input().split()))
#table = []
'''
for i in range h:
    temp = list(map(int, input().split()))
    table.append(temp)
'''
maxS = w*h/2
a = 0
if (w == 2*x) and (h == 2*y):
    a = 1
print('{:f} {}'.format(maxS, a)) 

Measured memory_bytes: 2940
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var set = new Set();
  for(var i = 0; i < n; i++)set.add(next(1));
  return set.size;
}

Measured memory_bytes: 60096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long a = 1;
            for (int i = 1; i <= n; i++)
            {
                a *= i;
            }

            Console.WriteLine(a);


        }


    }
}

Measured memory_bytes: 5588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
  int i, j;
  int la, lb, lc;

  char a[20];
  char b[20];
  char c[20];

  //scanf("%[^\n]%*c", a);
  scanf("%s%*c", a);
  scanf("%s%*c", b);
  scanf("%s%*c", c);
  la = strlen(a);
  lb = strlen(b);
  lc = strlen(c);

  if (a[la-1] != b[0]) {
    printf("NO");
  }
  else if (b[lb-1]!=c[0]) {
    printf("NO");
  }
  else {
    printf("YES");
  }

  return 0;
}

Measured memory_bytes: 128
if __name__=="__main__":
    # Problem B
    X, Y = map(int, input().split(' '))
    ans = "No"
    for i in range(X):
        if i*2 + (X-i)*4 == Y or i*4 + (X-i)*2 == Y:
            ans = "Yes"
            break
    print(ans)

Measured memory_bytes: 9112
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9 + 5;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
using namespace std;

int n,m,u,v;
int memo[110000];
bool fl[110000];
vector<int> eg[110000];


int dp(int v){
    if(fl[v]){
        return memo[v];
    }
    int ans = 0;
    for(int to: eg[v]){
        ans = max(ans, dp(to) + 1);
    }
    fl[v] = true;
    memo[v] = ans;
    return ans;
}
using namespace std;
int main(){
   

    int n;
    int a,b,cnt=0;
    cin >>n;
    bool fl = false;

    REP(i,n){
        cin >> a >> b;
        if(a == b){
            cnt ++ ;
            fl = true;
            if(cnt == 3){
                cout << "Yes" <<endl;
                return 0;
            }
            continue;
        }
        fl = false;
        cnt = 0;
    }
    cout << "No" <<endl;
}





Measured memory_bytes: 6212
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2565

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	
	while(true){
		int N, con = 0;
		int up = -INF, lo = INF;
		bool flag = true;
		string  x;
		vector<int> s;
		cin>>N;
		
		if(!N) break;
		
		for(int i = 0; i < N; i++){
			cin>>x;
			if(x == "x") {
				s.push_back(INF);
				con++;
			} else s.push_back(stoi(x));
		}
		
		for(int i = 0; i < N && flag; i++){
			int a = -INF/2, b = INF/2;
			// cout<<"a,b "<<a<<" "<<b<<" i = "<<i<<" "<<s[i]<<endl;
			if(s[i] == INF){
				if(i){
					a = s[i-1];
					b = s[i-1];
				}
				if(i != N-1){
					if(s[i+1] == INF) flag = false;
					b = min(b, s[i+1]);
					a = max(a, s[i+1]);
				}
				
				// cout<<"<><><>"<<endl;
				
				if(i%2){
					// cout<<up<<" "<<a<<endl;
					up = max(up, a+1);
					// if(up > (int)1e9) flag = false;
				} else {
					// cout<<lo<<" "<<b<<endl;
					lo = min(lo, b-1);
					// if(lo < (int)-1e9) flag = false;
				}
			} else {
				if(i%2){
					if(i && s[i-1] != INF && s[i-1] >= s[i]) flag = false;
					if(i != N-1&& s[i+1] != INF && s[i+1] >= s[i]) flag = false;
				} else {
					if(i && s[i-1] != INF && s[i-1] <= s[i]) flag = false;
					if(i != N-1&& s[i+1] != INF && s[i+1] <= s[i]) flag = false;
				}
			}
		}
		
		if(!con) up = -INF, lo = INF;
		
		// cout<<lo<<" "<<up<<endl;
		
		if(!flag || up > lo) cout<<"none"<<endl;
		else if(up == lo) cout<<up<<endl;
		else cout<<"ambiguous"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3080
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,m = li()

cnt = [0]*n
for _ in range(m):
    a,b = li_()
    cnt[a] += 1
    cnt[b] += 1
    
exist = True
for c in cnt:
    if c%2:
        exist = False
        break

if exist:
    print("YES")
else:
    print("NO")

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 2e5+5;

ll n , dp[N] , nxt[N] , mod = 998244353;
ll seg[4*N];
vector< pair<ll,ll> > v;

void update(int node , int st , int en , int idx , int val)
{
    if (st == en)
    {
        seg[node] = val;
        return;
    }
    int mid = (st+en)/2;
    if (idx >= st && idx <= mid) update(2*node , st , mid , idx , val);
    else update(2*node+1 , mid+1 , en , idx , val);
    seg[node] = max(seg[2*node] , seg[2*node+1]);
}

ll query(int node , int st , int en , int l , int r)
{
    if (st > r || en < l) return -2e9;

    if (st >= l && en <= r)
        return seg[node];

    int mid = (st+en)/2;
    return max(query(2*node , st , mid , l , r) , query(2*node+1 , mid+1 , en , l , r));
}

ll solve(int i)
{
    if (i > n)
        return 1;

    if (dp[i] != -1)
        return dp[i];

    ll ans = solve(i+1);

    ans += solve(nxt[i]);
    ans %= mod;

    return dp[i] = ans;
}

int UP(ll val)
{
    int up = upper_bound(v.begin() , v.end() , make_pair(val , (ll)3e9)) - v.begin();
    up--;
    return up;
}

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

    cin >> n;
    for(int i=1; i<=n; i++)
    {
        ll x,d;
        cin >> x >> d;
        v.push_back({x,d});
    }
    v.push_back({-3e9,-3e9});
    sort(v.begin() , v.end());

    for(int i=n; i>0; i--)
    {
        int up = UP(v[i].f+v[i].s-1);
        if (up==i)
        {
            nxt[i] = i+1;
            update(1,1,n,i,i+1);
        }
        else
        {
            nxt[i] = query(1,1,n,i+1,up);
            update(1,1,n,i,nxt[i]);
        }
    }

    memset(dp , -1 , sizeof(dp));
    cout << solve(1) << "\n";

    return 0;
}

Measured memory_bytes: 19948
H, W = map(int, input().split())
A = []
mod = 10**9
mod += 7
# print(mod)
for h in range(H):
	A.append(list(input()))
dp = [[0 for w in range(W)] for h in range(H)]
dp[0][0] = 1
for i in range(H):
	for j in range(W):
		if A[i][j] != "#":
			if i > 0 and A[i-1][j] != '#':
				dp[i][j] = (dp[i][j]%mod + dp[i-1][j]%mod)%mod
			if j > 0 and A[i][j-1] != '#':
				dp[i][j] = (dp[i][j]%mod + dp[i][j-1]%mod)%mod
# print(dp)
print(dp[H-1][W-1])



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

int main(){
    int H,W;
    cin >> H >> W;
    string s;
    for (int i = 0; i < W + 2; i++) {
        cout << "#";
        if (i == W + 1) {
            cout << endl;
        }
    }
    for (int i = 0; i < H; i++) {
        cin >> s;
        cout << "#" << s << "#" << endl;
    }
    for (int i = 0; i < W + 2; i++) {
        cout << "#";
        if (i == W + 1) {
            cout << endl;
        }
    }
}


Measured memory_bytes: 256
"use strict";
const Main = function(input){
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let tax =1.08;
   let ans1 =[];
   let ans2 = 0;
   for(let i =0 ; i<=xs[0]; i++){
      ans1.push(Math.floor(i*tax));
      if(ans1[i]==xs[0]){
         ans2 = Math.ceil(xs[0]/tax);
         break;
      }else{
         ans2 = -1;
      }
   } 
   if(ans2 != -1){
     console.log(ans2);
    }else{
     console.log(":(");
    }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 8268
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
	int a = rint, b = rint;
	lcm(a, b).writeln;
}
/// 最大公約数。最大の公約数。
/// 例 gcd(12, -18) = 6, gcd(-12, -18) = 6, gcd(12, 0) = 12, gcd(0, 0) = 0
/// ※本当は gcd(0, 0) は存在しないが便宜上 0 を返している
long gcd(long a, long b){
	if(a < 0) a = -a;
	if(b == 0) return a;
	if(b < 0) return gcd(a, -b);
	if(a % b == 0) return b;
	if(a < b) return gcd(b, a);
	else return gcd(b, a % b);
}

/// 最小公倍数。0以上で最小の公倍数。
/// 例 lcm(12, -18) = 36, lcm(-12, -18) = 36, lcm(12, 0) = 36, lcm(0, 0) = 0
long lcm(long a, long b){
	if(a < 0) a = -a; if(b < 0) b = -b;
	if(a == 0 && b == 0) return 0;
	return (a / gcd(a, b) * b);
}


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

using namespace std;

int main(){
	
	int n;
	cin>>n;
	map<string,int> m;
	for(int i=0;i<n;i++){
		string a;
		cin>>a;
		m[a]+=1;
	}
	int max=0;
	for(const auto &v: m){
		int x=v.second;
		if(x>max){
			max=x;
		}
	}
	for(auto it=m.begin();it!=m.end();it++){
		if(it->second==max){
			cout<<it->first<<endl;
		}
	}
	
	return 0;
}

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

using namespace std;
using namespace std::chrono;
#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

ll big = 1000000007ll;
ll big2 = 1000000009ll;
ll n,m,T,k,q;

ll ANS[1000001] = {0};

vector<ll> A;
ll FAC[200000] = {0};
ll INV[200000] = {0};

ll upp(ll i, ll j){
    if(j == 0)return 1;
    if(j % 2 == 0){
        ll h = upp(i,j/2);
        return (h*h)%big;
    }
    return (i*upp(i,j-1))%big;
}

void setup(){
    ll t = 1;
    ll tm = upp(199999, big-2);
    for(ll c1 = 0; c1 < 200000; c1++){
        FAC[c1] = t;
        //INV[199999-c1] = tm;
        INV[c1] = upp(t,big-2);
        t *= (c1+1);
        tm *= (199999-c1);
        t %= big;
        tm %= big;
    }

}

ll bin(ll i, ll j){
    if(i <j )return 0;
    ll a = FAC[i];
    ll b = INV[j];
    ll c = INV[i-j];
    return (((a*b)%big)*c)%big;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d,e;

    bool is[200000] = {0};
    ll var[200000] = {0};
    ll bb = 0;
    cin >> n;
    for(ll c1 = 0; c1 < n+1;c1++){
        cin >> a;
        if(is[a] == 1){
            bb = n-c1+var[a];
        }
        is[a] = 1;
        var[a] = c1;
    }
    setup();
    for(ll c1 = 1; c1 <= n; c1++){
        a = bin(n,c1);
        if(c1 >= 2)a += bin(n-1,c1-1) - bin(bb,c1-1) + big*big;
        if(c1 >= 2)a += bin(n-1,c1-2);
        a %= big;
      //  cout <<bin(n,c1) << " "<<(bin(n-1,c1-1) - bin(bb,c1-1) + big*big)%big << " " <<bin(n-1,c1-2) << " " <<  a << "\n";
        cout << a << "\n";
    }

    cout << 1  << "\n";

    //cout << bin(4,2);

    return 0;
}



Measured memory_bytes: 7040
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to count all possible 
// triangles with arr[] elements 
int findNumberOfTriangles(int arr[], int n) 
{ 
    // Count of triangles 
    int count = 0; 
  
    // The three loops select three 
    // different values from array 
    for (int i = 0; i < n; i++) { 
        for (int j = i + 1; j < n; j++) { 
  
            // The innermost loop checks for 
            // the triangle property 
            for (int k = j + 1; k < n; k++) 
  
                // Sum of two sides is greater 
                // than the third 
                if ( 
                    arr[i] + arr[j] > arr[k] 
                    && arr[i] + arr[k] > arr[j] 
                    && arr[k] + arr[j] > arr[i] && arr[i]!=arr[j] && arr[j]!=arr[k] && arr[k]!=arr[i]) 
                    count++; 
        } 
    } 
    return count; 
} 
  
// Driver code 
int main() 
{ 
    int n;
    cin>>n;
    int arr[n];
    int i;
    for(i =0 ; i < n; i++)
    	cin>>arr[i];
    int size = n; 
  
    cout << findNumberOfTriangles(arr, size); 
  
    return 0; 
} 

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int d, ans=0;
	vector<int> c, t, ld;
	vector< vector<int> >s;

	cin>> d;

	c.resize(26);
	rep(i, 26) cin>> c[i];
	s.resize(d);
	rep(i, d){
		s[i].resize(26);
		rep(j, 26) cin>> s[i][j];
	}
	t.resize(d);
	rep(i, d){
		cin>> t[i];
		t[i]--;
	}
	ld.resize(26);

	int m;
	vector<int> qd, qq;
	cin>> m;
	qd.resize(m);
	qq.resize(m);
	rep(i, m) cin>> qd[i] >> qq[i];

	rep(k, m){
		t[qd[k]-1]=qq[k]-1;
		ans=0;
		rep(i, 26) ld[i]=0;

		rep(i, d){
			ans+=s[i][t[i]];
			ld[t[i]]=i+1;
			rep(j, 26) ans-=(i-ld[j]+1)*c[j];
		}
		cout<< ans << endl;
	}
 
	return 0;
}

Measured memory_bytes: 3984
package main

import "fmt"

type rect struct {
	h int
	w int
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	br := make([][]bool, h)
	for i := range br {
		br[i] = make([]bool, w)
	}
	ar := make([]rect, 0)
	for i := 0; i < h; i++ {
		var s string
		fmt.Scan(&s)
		for j, v := range s {
			if v == '#' {
				br[i][j] = true
				ar = append(ar, rect{h: i, w: j})
			}
		}
	}
	sum := 0
	for {
		temp := []rect{}
		sousa := false
		for _, v := range ar {
			if v.h != 0 {
				if !br[v.h-1][v.w] {
					sousa = true
					br[v.h-1][v.w] = true
					temp = append(temp, rect{h: v.h - 1, w: v.w})
				}
			}
			if v.h != h-1 {
				if !br[v.h+1][v.w] {
					sousa = true
					br[v.h+1][v.w] = true
					temp = append(temp, rect{h: v.h + 1, w: v.w})
				}
			}
			if v.w != 0 {
				if !br[v.h][v.w-1] {
					sousa = true
					br[v.h][v.w-1] = true
					temp = append(temp, rect{h: v.h, w: v.w - 1})
				}
			}
			if v.w != w-1 {
				if !br[v.h][v.w+1] {
					sousa = true
					br[v.h][v.w+1] = true
					temp = append(temp, rect{h: v.h, w: v.w + 1})
				}
			}
		}
		if sousa == false {
			fmt.Println(sum)
			return
		}
		sum++
		ar = temp
	}
}


Measured memory_bytes: 52992
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long

int inf = (1LL <<  62);
using namespace std;

vector<int> re_yaku(int num){
    vector<int> ans;
    for(int i = 1; i*i < num; i++){
        if(num % i == 0){
            ans.push_back(i);
        }
    }
    if(num == pow((int)sqrt(num), 2)){
        ans.push_back((int)sqrt(num));
    }
    return ans;
}



signed main(){
    int n;
    cin >> n;
    vector<int> v = re_yaku(n);
    int a = v[v.size() - 1];
    int b = n / a;
    int k = 0;
    while(1){
        if(a == 0 && b == 0){
            break;
        }
        a /= 10;
        b /= 10;
        k++;
    }
    cout << k;
}


Measured memory_bytes: 256
from bisect import bisect_left
import sys
s = input()
t = input()

d = {char:[] for char in 'abcdefghijklmnopqrstuvwxyz'}
for i in range(len(s)):
    d[s[i]].append(i)

cnt = 0
index = 0
for char in t:
    if not d[char]:
        print(-1)
        sys.exit()
    i = bisect_left(d[char], index)
    if i == len(d[char]):
        cnt += 1
        index = d[char][0]
    else:
        index = d[char][i]
    index += 1

ans = cnt * len(s) + index
print(ans)

Measured memory_bytes: 7796
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>

using namespace std;

int main()
{
    int a,b;
    scanf("%2d%2d",&a,&b);
    bool flag1=false,flag2=false;
    if(b>0&&b<=12)
        flag1=true;
    if(a<=12&&a>0)
        flag2=true;
    if(flag1&&flag2)
        cout<<"AMBIGUOUS"<<endl;
    else if(flag1)
        cout<<"YYMM"<<endl;
    else if(flag2)
        cout<<"MMYY"<<endl;
    else
        cout<<"NA"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> tile1(n);
	vector<int> tile2(n,1);
	int p = 0;
	while (2 * p <= n - 1) {
		tile1[2 * p] = 1;
		tile2[2 * p] = 0;
		p++;
	}
	int ans1 = 0, ans2 = 0;
	rep(i, n) {
		if ((s[i] - '0') != tile1[i]) ans1++;
		if ((s[i] - '0') != tile2[i]) ans2++;
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}


Measured memory_bytes: 1280
# coding: utf-8
line = input().rstrip().split()
val = []
val.append(int(line[0]))
val.append(int(line[1]))
val.append(int(line[2]))
val.sort()
for i in range(len(val)):
    if i==len(val) -1:
        print(str(val[i]))
    else:
        print(str(val[i]) + " ", end="")


Measured memory_bytes: 5604
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	int a,b,c;
	for(;cin>>a>>b>>c;){
	if(abs(a-b)>abs(a-c))cout<<'B'<<endl;
	else
	cout<<'A'<<endl;
}
	return 0;
} 

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
M = 10**9+7
from collections import defaultdict

d = defaultdict(int)

lcl_cnt = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        if A[i] > A[j]:
            d[A[i]]+=1

            if i < j:
                lcl_cnt += 1

ans = lcl_cnt * K

for _, v in d.items():
    ans += (K-1)*v*K//2%M
    
print(ans%M)

Measured memory_bytes: 9520
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };


double eps = 1e-4;



double integ(double v1, double v2, double dx) {
	return (v1 + v2) * dx / 2.0;
}

int main() {
	double inf = 1e18;
	ll N; cin >> N;
	vector<double> T(N+1);
	vector<double> V(N);
	T[0] = 0;
	REP(i, 1, N+1) {
		cin >> T[i];
		T[i] += T[i - 1];
	}
	REP(i, 0, N) cin >> V[i];
	vector<double> val(2 * T.back() + 1);
	vector<double> tbl_r(N), tbl_l(N);
	tbl_l[0] = inf;
	tbl_r[N - 1] = inf;
	REP(i, 1, N)tbl_l[i] = min(tbl_l[i - 1], V[i - 1] - T[i]);
	for (int i = N - 2; i >= 0; --i) tbl_r[i] = min(tbl_r[i + 1], V[i + 1] + T[i + 1]);
	val[0] = 0;
	int area = 0;
	REP(i, 1, 2 * T.back() + 1) {
		double t = (double)i / 2.0;
		if (t > T[area+1]) ++area;
		double ceil_val = min(t, T.back() - t);
		mins(ceil_val, V[area]);
		mins(ceil_val, tbl_l[area] + t);
		mins(ceil_val, tbl_r[area] - t);
		if (val[i - 1] + 0.5 < ceil_val + eps) val[i] = val[i - 1] + 0.5;
		else if (val[i - 1] < ceil_val + eps) val[i] = val[i - 1];
		else val[i] = val[i - 1] - 0.5;
	}
	double ans = 0;
	REP(i, 1, 2 * T.back() + 1) ans += integ(val[i], val[i - 1], 0.5);
	PRIF(ans, 5);
	return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

ll a[7];

int main(void){
	rep(i, 7) cin >> a[i];
	ll ans = 0;
	ans += 2 * (a[0] / 2);
	ans += 1 * a[1];
	ans += 2 * (a[3] / 2);
	ans += 2 * (a[4] / 2);
	
	ll ans1 = 0;
	if(a[0] > 0 && a[3] > 0 && a[4] > 0){
		ans1 += 3;
		a[0]--; a[3]--; a[4]--;
	}
	ans1 += 2 * (a[0] / 2);
	ans1 += 1 * a[1];
	ans1 += 2 * (a[3] / 2);
	ans1 += 2 * (a[4] / 2);
	printf("%lld\n", max(ans1, ans));
	return 0;
}

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

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

	if(n % 2 == 1) cout << "No" <<  endl;
	else {
		for(int i = 0; i < n / 2; i++) {
			if(s.at(i) != s.at(i+n/2)) {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define FOR(variable,start,end) for(int variable = start; variable < end; ++variable)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ll ans1=max(a,b)*max(c,d);
	ll ans3=min(a,b)*min(c,d);
	ll ans2=max(a,b)*min(c,d);
	ll ans4=min(a,b)*max(c,d);
	cout << max(max(ans1,ans2),max(ans3,ans4)) << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
using namespace std;

int main(void){
  double a;
  while(1){
  if(scanf("%lf", &a) == EOF) break;
  double ans = a;
  for(int i=2; i <= 10; i++){
    if(i%2 == 0){
      a = a * 2;
      ans += a;
    }else{
      a = a / 3;
      ans += a;
    }
  }
  printf("%.9lf\n", ans);
  }
  return 0;
}

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

typedef long long ll;

const int kN = 15, kInf = 0x3f3f3f3f;

int n, m, x, lvl[kN], c[kN], a[kN][kN];
int Check(int S) {
	int cst = 0;
	memset(lvl, 0, sizeof(lvl));
	for(int i = 0; i < m; ++i)
		if((S >> i) & 1) {
			cst += c[i];
			for(int j = 1; j <= n; ++j) lvl[j] += a[i][j];
		}
	//printf("%d : %d\n", S, cst);
	//for(int i = 0; i < m; ++i) printf("%d ", c[i]);
	//printf("\n");
	for(int i = 1; i <= n; ++i) if(lvl[i] < x) return kInf;
	return cst;
}

int main() {
	scanf("%d%d%d", &m, &n, &x);
	for(int i = 0; i < m; ++i) {
		scanf("%d", &c[i]);
		for(int j = 1; j <= n; ++j) scanf("%d", &a[i][j]);
	}
	int ans = kInf;
	for(int S = 0; S < (1 << m); ++S) ans = std::min(ans, Check(S));
	if(ans < kInf) printf("%d\n", ans);
	else printf("-1\n");
	return 0;
}

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

int main(void){
	int t, d, l;
	while(cin >> t >> d >> l, t+d+l){
		int x;
		int ans = 0;
		int last = 0;
		for (int i = 0; i < t; ++i)
		{
			cin >> x;
			if(i == t-1) continue;
			if(x>=l){
				last = d;
				
			}
			if(last > 0){
				ans++;
				last--;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3100
import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

def main():
    N = int(input())
    A = list(map(int, input().split()))
    s = sum(A)
    ans = s * s
    for a in A: ans -= a * a
    print((ans // 2) % mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 105336
# include <bits/stdc++.h>
using namespace std;
# define MOD 1000000007
typedef long long ll;
class box{
public:
    int w, s, v;
};
bool compare(box a, box b){
    return a.s + a.w < b.s + b.w;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	box boxes[n];
	for(int i=0;i<n;i++){
	    cin>>boxes[i].w>>boxes[i].s>>boxes[i].v;
	}
	sort(boxes, boxes + n, compare);
// 	for(int i=0;i<n;i++){
// 	    cout<<boxes[i].w<<" "<<boxes[i].s<<" "<<boxes[i].v<<"\n";
// 	}
    int MAXS = 30001;
	vector<ll> dp(MAXS);
	for(int i=0;i<n;i++){
	    for(int w=min(boxes[i].s, MAXS - boxes[i].w);w>=0;w--){
	        dp[w + boxes[i].w] = max(dp[w + boxes[i].w], dp[w] + boxes[i].v);
	    }
	}
	ll ans = 0;
	for(int i=0;i<MAXS;i++){
	    ans = max(ans, dp[i]);
	}
	cout<<ans;
	return 0;
}

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

vector<vector<pair<int, int>>>E;
vector<char>used;
vector<char>ans;

void solve(int x)
{
	used[x] = true;

	for (int i = 0; i < E[x].size(); i++)
	{
		int y = E[x][i].first;
		if (used[y])continue;
		int w = E[x][i].second;
		if (w % 2)ans[y] = ans[x] ^ 1;
		else ans[y] = ans[x];

		solve(y);
	}
}

int main()
{

	int N; cin >> N;
	E.resize(N);
	used.resize(N);
	ans.resize(N);
	for (int i = 0; i < N-1; i++)
	{
		int u, v, w; cin >> u >> v >> w;
		u--; v--;
		E[u].push_back(make_pair(v, w));
		E[v].push_back(make_pair(u, w));
	}

	solve(0);

	for (int i = 0; i < N; i++)
	{
		cout<<(int)ans[i]<<endl;
	}

	return 0;
}


Measured memory_bytes: 9216
A = int(input())
B = int(input())
C = int(input())
X = int(input())

pat = 0
for a in range(A+1):
	for b in range(B+1):
		for c in range(C+1):
			if a*500+b*100+c*50 == X:
				pat += 1
print(pat)

Measured memory_bytes: 9076
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define ll long long int
using namespace std;
int main()
{
   string s;
  cin>>s;
  if(s[0]=='7' || s[1]=='7' || s[2]=='7' ){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
 }

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

int a['z'-'a'+1][200000];
int sum[200000];

signed main(){
  string A;
  cin >> A;
  int N = A.size();
  FOR(i,0,N){
    a[A[i]-'a'][i]++;
  }
  FOR(i,0,'z'-'a'+1){
    REP(j,0,N-1){
      a[i][j] += a[i][j+1];
    }
  }
  FOR(i,0,200000){
    FOR(j,0,'z'-'a'+1){
      sum[i] += a[j][i];
    }
  }
  ll ans = 0;
  FOR(i,0,N){
    ans += sum[i]-a[A[i]-'a'][i];
  }
  cout << ans+1 << endl;
}


Measured memory_bytes: 21636
// Crt. 2019-12-09  21:17:27
#include <algorithm>
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int n, a[N];

inline int check() {
    int sum[2], tmp = 0;
    long long s = 0;
    sum[0] = sum[1] = 0;
    for (int i = 1; i <= n; ++i)
        sum[a[i] % 2]++, tmp += a[i] == 1, s += a[i];
    if (tmp) return (s - n) % 2 ? 1 : 2;
    if (sum[0] % 2 == 0 && sum[1] == 1) return 0;
    if (sum[0] % 2 == 1 && sum[1] >= 1) return 1; 
    if (sum[0] % 2 == 0 && (sum[1] >= 2 || !sum[1])) return 2;
    return -1;
}

inline void operates() {
    for (int i = 1; i <= n; ++i)
        if (a[i] % 2) --a[i];
    int g = a[1];
    for (int i = 2; i <= n; ++i)
        g = __gcd(g, a[i]);
    for (int i = 1; i <= n; ++i)
        a[i] /= g;
}

bool dfs() {
    int tmp = 0;
    if (tmp = check()) return (tmp == 1);
    return operates(), !dfs();
}

int main() {
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n;

    for (int i = 1; i <= n; ++i)
        scanf("%d", a + i);

    puts(dfs() ? "First" : "Second");

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#define vi vector<int>
#define MAX 7654321
#define pii pair<int,int>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n,m; cin>>n>>m;	
	vector<vi> edge(n);
	vector<int> parent(n,-1),dis(n,MAX);
	for(int i=0,a,b;i<m;i++){
		cin>>a>>b;
		edge[a-1].push_back(b-1);
		edge[b-1].push_back(a-1);
	}

	queue<int> que;
	que.push(0);
	dis[0] = 0;

	while(!que.empty()){
		int cur = que.front();
		que.pop();
		for(int i=0;i<edge[cur].size();i++){
			int next = edge[cur][i];
			if(dis[next] != MAX) continue;
			dis[next] = dis[cur] + 1;
			que.push(next);
			parent[next] = cur+1;
		}
	}

	bool isPossible = true;
	for(int i=1;i<n;i++){
		if(dis[i] == MAX){
			isPossible = false;
			break;
		}
	}
	if(isPossible){
		cout<<"Yes\n";
		for(int i=1;i<n;i++){
			cout<<parent[i]<<'\n';
		}
	}else{
		cout<<"No";
	}
}

Measured memory_bytes: 10200
n, x = map(int, input().split())

pate, slice = [1], [1]
for _ in range(n + 1):
    pate.append(2 * pate[-1] + 1)
    slice.append(2 * slice[-1] + 3)

ans = 0
while n > 0:
    if x >= slice[n - 1] + 2:
        ans += pate[n - 1] + 1
        x -= slice[n - 1] + 2
    elif x < slice[n - 1] + 2:
        x -= 1
    n -= 1
print(ans + (x > 0))

Measured memory_bytes: 61840