akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>

using namespace std;

class inverse {
    public:
    inverse(int n, int mod);
    ~inverse();
    long long get_inv(int x);
    long long get_fact(int x);
    long long get_invfact(int x);
    long long get_comb(int x, int y);
    
    private:
    int mod;
    long long* inv;
    long long* fact;
    long long* invfact;
};

inverse::inverse(int n, int mod) : mod(mod) {
    inv = (long long *)malloc(sizeof(long long) * (n + 1));
    fact = (long long *)malloc(sizeof(long long) * (n + 1));
    invfact = (long long *)malloc(sizeof(long long) * (n + 1));
    inv[1] = 1;
    for (int i = 2; i <= n; i++) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    fact[0] = invfact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    for (int i = 1; i <= n; i++) invfact[i] = invfact[i - 1] * inv[i] % mod;
}

inverse::~inverse() {
    free(inv);
    free(fact);
    free(invfact);
}

long long inverse::get_inv(int x) {
    return inv[x];
}

long long inverse::get_fact(int x) {
    return fact[x];
}

long long inverse::get_invfact(int x) {
    return invfact[x];
}

long long inverse::get_comb(int x, int y) {
    return fact[x] * invfact[y] % mod * invfact[x - y] % mod;
}

int a[100001];
int b[100001];

int main() {
    int n, x, m = 1000000007, i;
    inverse inv(100001, m);
    
    scanf("%d", &n);
    
    for (i = 0; i <= n; i++) scanf("%d", &a[i]);
    
    for (i = 1; i <= n; i++) b[i] = -1;
    
    for (i = 0; i <= n; i++) {
        if (b[a[i]] != -1) {
            x = b[a[i]] + n - i;
        } else {
            b[a[i]] = i;
        }
    }
    
    for (i = 1; i <= n + 1; i++) {
        long long ans = inv.get_comb(n + 1, i);
        
        if (x >= i - 1) {
            ans = ans - inv.get_comb(x, i - 1);
            if (ans < 0) ans += m;
        }
        
        printf("%lld\n", ans);
    }
    
    return 0;
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		long k=sc.nextLong();
		long i1 = n%k;
		long i2 = Math.abs(i1-k);
		long ans = Math.min(i1, i2);
		System.out.println(ans);
		sc.close();
	}
}


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

int main() {
	int A, B;
	cin >> A >> B;
	int num = A, ans = 1;
	if (B == 1) {
		cout << "0" << endl;
		return 0;
	}
	if (A > B) {
		cout << ans << endl;
		return 0;
	}
	if ((B - num) % (A - 1) == 0) {
		ans += (B - num) / (A - 1);
	} else {
		ans += (B - num) / (A - 1) + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused)]

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//入力マクロここまで

use std::cmp::*;

const INI: usize = 0;

fn main() {
    input! {
        n: usize,
        w: usize,
        wv: [(usize, usize);n],
    }

    let mut dp = vec![vec![INI; w + 1]; n + 1];

    for i in 0..n {
        for j in 0..w + 1 {
            dp[i + 1][j] = if wv[i].0 <= j {
                max(dp[i][j - wv[i].0] + wv[i].1, dp[i][j])
            } else {
                dp[i][j]
            }
        }
    }

    println!("{}", dp[n][w]);
}


Measured memory_bytes: 106748
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  string b;
  cin >> b;
  rep(i, b.size()) {
    if (b[i] == 'A') {
      cout << "T";
    }
    if (b[i] == 'T') {
      cout << "A";
    }
    if (b[i] == 'C') {
      cout << "G";
    }
    if (b[i] == 'G') {
      cout << "C";
    }
  }
  ENDL;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(void){
  int N; cin >> N;
  bool OK = false;
  for(int i = 0; i <= N / 4; i++){
      for(int j = 0; j <= N / 7; j++){
          if(4 * i + 7 * j == N) OK = true;
      }
  }
  if(OK != true) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

const int mod = 1e9 + 7;
const int inf = 9e18;
const int N = 1e5 + 5;

int a,b,k;

void solve(){
    cin>>k>>a>>b;
    if(b/k-(a-1)/k>0)
        cout<<"OK";
    else
        cout<<"NG";
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    
    int hoge,mae;
    int count=0;
    int max=0;
    for(int i=0;i<n;i++){
        cin>>hoge;
        if(i==0){
            mae=hoge;
            continue;
        }
        if(mae>=hoge){
            count++;
        }else{
            if(count>max)max=count;
            count=0;
        }
        
        if(i==n-1){
            if(count>max)max=count;
        }
        
        mae=hoge;
    }
    cout<<max<<endl;
}

Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : March 08 2020 17:30:20 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    string s;
    cin >> s;
    int n = sz(s);
    bool ok = 1;
    int i = 0;
    for(i=0;i<n-1;i+=2){
        ok &= (s[i]=='h' and s[i+1]=='i');
    }
    ok &= (i==n);
    cout << (ok ? "Yes" : "No" ) << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n,k;
  cin>>n>>k;
  vecll h(n);
  for(auto&& e:h)cin>>e;
  boost::sort(h);
  boost::reverse(h);
  for(auto&& i:irange(0,min(n,k))) h[i] = 0;
  cout<<boost::accumulate(h,0l)<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ss, ee) for (int i = (ss); i < (ee); ++i)

string s, t;
void input() { cin >> s >> t; }
void solve() {
  int ans = 0;
  rep(i, 0, s.size()) ans += (s[i] != t[i]);
  cout << ans << endl;
}

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

Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>

using namespace std;

int H, W, n, input[15], data[10][10], map[10][10], px[15], py[15];
bool ans;

bool check(int y, int x){
  if(y<0 || y>=H) return false;
  if(x<0 || x>=W) return false;
  return true;
}

bool settable(int y, int x, int h, int w){
  for(int i=y;i<y+h;i++){
    for(int j=x;j<x+w;j++){
      if(data[i][j]) return false;
    }
  }
  return true;
}

void setPanel(int y, int x, int h, int w, int p){
  for(int i=y;i<y+h;i++){
    for(int j=x;j<x+w;j++){
      data[i][j] = p;
    }
  }
}

bool finish(){
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(data[i][j] == 0) return false;
    }
  }
  return true;
}

bool solve(int p){
  if(p == -1){
    if(finish()){
      if(ans) return true;
      ans = true;
      for(int i=0;i<H;i++) for(int j=0;j<W;j++) map[i][j] = data[i][j];
    }
    return false;
  }
  for(int h=1;h<=input[p];h++){
    if(input[p] % h != 0) continue;
    int w = input[p] / h;
    for(int i=py[p]-h+1;i<=py[p];i++){
      for(int j=px[p]-w+1;j<=px[p];j++){
        if(!check(i, j)) continue;
        data[py[p]][px[p]] = 0;
        if(settable(i, j, h, w)){
          setPanel(i, j, h, w, p+1);
          if(solve(p-1)) return true;
          setPanel(i, j, h, w, 0);
        }
        data[py[p]][px[p]] = p+1;
      }
    }
  }
  return false;
}

main(){
  while(cin >> W >> H >> n && (W|H|n)){
    for(int i=0;i<n;i++){
      int a, b;
      cin >> a >> b;
      input[a-1] = b;
    }
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        cin >> data[i][j];
        if(data[i][j] != 0){
          px[data[i][j]-1] = j;
          py[data[i][j]-1] = i;
        }
      }
    }
    ans = false;
    if(!solve(n-1) && ans){
      for(int i=0;i<H;i++){
        cout << map[i][0];
        for(int j=1;j<W;j++){
          cout << ' ' << map[i][j];
        }
        cout << endl;
      }
    }else cout << "NA" << endl;
  }
}

Measured memory_bytes: 868
// 2011/07/27 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;
		if(n==0&&m==0)
			break;

		int p[1000];
		for(int i=0; i<n; i++)
			cin >> p[i];

		// ツソツーツトツ（ツ降ツ渉）
		for(int i=0; i<n-1; i++)
			for(int j=i+1; j<n; j++)
				if(p[i]<p[j]){
					int tmp = p[i];
					p[i] = p[j];
					p[j] = tmp;
				}

		// mツ古つつィツつォツづ可鳴ウツ猟ソツづづ按づゥ
		for(int i=m-1; i<n; i+=m)
			p[i] = 0;

		// ツ債計
		int sum = 0;
		for(int i=0; i<n; i++)
			sum += p[i];

		cout << sum << endl;
	}

	return 0;
}

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

using namespace std;

int prime(long long n) {
    if(n < 2)
        return 0;
    for(long long i = 2; i * i <= n; i++)
        if(n%i == 0)
            return 0;
    return 1;
}

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

    long long n, s = 0, q;
    cin >> n;
    q = n;

    for(long long i = 1; i*i <= q; i++)
        if(n%i == 0) {
            if(prime(i)) {
                long long cnt = 0, t = 1;
                while(n > 0 && n % i == 0)
                    cnt++, n /= i;
                while(cnt > 0) {
                    if(cnt - t >= 0)
                        s++;
                    cnt -= t, t++;
                }
            }
        }

    if(prime(n))
        s++;

    cout << s;

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
 
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    map<string,int> mp;
    int maxi=0;
    for(int i=0;i<n;i++){
        cin >> s[i];
        mp[s[i]]++;
        maxi=max(maxi,mp[s[i]]);
    }
    vector<string> ans;
    for(auto x:mp){
        if(x.second==maxi){
            ans.push_back(x.first);
        }
    }
    sort(ans.begin(),ans.end());
    for(auto x:ans){
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 33520
# author:  Taichicchi
# created: 12.09.2020 17:49:24

from itertools import permutations
import sys

N = int(input())

P = int("".join(input().split()))
Q = int("".join(input().split()))

perm = permutations([str(i) for i in range(1, N + 1)], N)

ls = []

for i in perm:
    ls.append(int("".join(i)))

print(abs(ls.index(P) - ls.index(Q)))


Measured memory_bytes: 10532
#include <cstdio>

int main(){
    long long int n, m, l, a[100][100], b[100][100], t;
    scanf("%lld %lld %lld", &n, &m, &l);
    for(int i = 0; i<n; i++){
        for(int j = 0; j<m; j++){
            scanf("%lld", &a[i][j]);
        }
    }
    for(int i = 0; i<m; i++){
        for(int j = 0; j<l; j++){
            scanf("%lld", &b[i][j]);
        }
    }
    for(int i = 0; i<n; i++){
        for(int j = 0; j<l; j++){
            t = 0;
            for(int k = 0; k<m; k++){
                t += a[i][k] * b[k][j];
            }
            printf("%lld", t);
            if(j<l-1){
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2768
/**
 * @Author:      G_BG
 * @DateTime:    2018-10-06 21:58:25
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define dwn(x, y, z) for (int x = y; x >= z;--x)
#define lowbit(x) (x & (-x))
typedef long long LL;
typedef unsigned long long ULL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn=1e2+10;
int x[maxn],y[maxn],h[maxn];
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    int n;cin >> n;
    int flag=0;
    int cx,cy;
    int xt,yt,ht;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i]!=0 && flag != 1) {
          xt=x[i];
          yt=y[i];
          ht=h[i];
          flag=1;
        }
    }
    int needH;
    for ( cx = 0; cx <= 100; cx++) {
        for ( cy = 0; cy <= 100; cy++) {
            flag=0;
            needH = ht + abs(xt - cx) + abs(yt - cy);
            for (int i = 0; i < n; i++) {
                if (h[i]>0) {
                    if (needH - abs(x[i] - cx) - abs(y[i] - cy) != h[i]) {
                        flag= -1;
                        break;
                    }
                }else{
                    if (needH - abs(x[i] - cx) - abs(y[i]- cy) > 0) {
                        flag = -1;
                        break;
                    }
                }
            }
            if (flag == 0) {
              cout << cx << " " << cy << " " << needH << endl;
              //system("pause");
              return 0;
            }
        }
    }
   // system("pause");
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
 
 
using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+7,M=3e5+5,MOD=1e9+7;

std::vector<pair<int,int>> wa[20];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	int n;

	scanf("%d",&n);

	for(int i=0;i<n;i++){
		int k;
		scanf("%d",&k);

		for(int j=0;j<k;j++){
			int x,y;
			scanf("%d %d",&x,&y);
			x--;
			wa[i].pb({x,y});
		}
	}
	int ans = 0;
	for(int mask=0;mask<(1<<n);mask++){
		bool ok = true;
		for(int i = 0;i<n;i++){
			if(mask&(1<<i)){
				for(auto p : wa[i]){
					if(p.second == 1 && !(mask&(1<<p.first)))
						ok = false;
					
					if(p.second == 0 && mask&(1<<p.first))
						ok = false;
				}
			}
		}
		if(ok)ans = max(ans,__builtin_popcount(mask));
	}

	printf("%d\n",ans );
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // input N K d1 A11,A12,...,A1d1 d2 ... AKdK
        // Aij の割当がない番号の個数を出力せよ
        Scanner sc = new Scanner(System.in);
        int sunukeNum = sc.nextInt();
        int sweetsNum = sc.nextInt();
        List<Integer> hasSweetsSunuke = new ArrayList<>();
        for(int i = 0; i < sunukeNum; i++){
            hasSweetsSunuke.add(0);
        }
        int trickNum = sunukeNum;
        for(int i = 0; i < sweetsNum; i++){
            int sweetsNo = sc.nextInt();
            for(int j = 0; j < sweetsNo; j++){
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            }
            if(trickNum == 0){
                System.out.println(0);
                return;
            }
        }
        System.out.println(trickNum);
    }
}

Measured memory_bytes: 39640
#include <bits/stdc++.h>
#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 REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int H, W;
vector<string> s;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

// まわりに黒があるか探す
bool paint(int x, int y) {
  bool ok = false;
  REP(i, 4) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx < 0 || H <= nx || ny < 0 || W <= ny) { continue; }
    if(s[nx][ny] == '#') { ok = true; }
  }
  return ok;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> H >> W;
  s.resize(H);
  REP(i, H) cin >> s[i];
  bool ok = true;
  REP(x, H) {
    REP(y, W) {
      if(s[x][y] == '#') {
        if(!paint(x, y)) { ok = false; }
      }
    }
  }
  if(ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin >> a >> b >> c;
    if(4 * a * b < (c - a - b) * (c - a - b) && c - a - b > 0){
        print("Yes");
    }else{
        print("No");
    }


}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
gray = 399
brown = 799
green = 1199
lblue = 1599
blue = 1999
yellow = 2399
orange = 2799
red = 3199
count = 0
result = [0, 0, 0, 0, 0, 0, 0, 0]
for i in a:
    if 0 < i <= gray:
        result[0] += 1
    elif gray < i <= brown:
        result[1] += 1
    elif brown < i <= green:
        result[2] += 1
    elif green < i <= lblue:
        result[3] += 1
    elif lblue < i <= blue:
        result[4] += 1
    elif blue < i <= yellow:
        result[5] += 1
    elif yellow < i <= orange:
        result[6] += 1
    elif orange < i <= red:
        result[7] += 1
    else:
        count += 1
minout = sum(i>0 for i in result)
maxout = minout + count
if minout == 0:
    minout = 1
print(minout, maxout)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#define BIG 1000000000
using namespace std;
int a,b,c,ans;
int main() {
	scanf("%d%d%d",&a,&b,&c);
	ans=BIG;
	ans=min(ans,abs(c-b)+abs(b-a));
	ans=min(ans,abs(b-c)+abs(c-a));
	ans=min(ans,abs(c-a)+abs(a-b));
	ans=min(ans,abs(a-c)+abs(c-b));
	ans=min(ans,abs(b-a)+abs(a-c));
	ans=min(ans,abs(a-b)+abs(b-c));
	printf("%d",ans);
} 

Measured memory_bytes: 256
import sys
from bisect import bisect_left

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    INF = 10 ** 18
    N = int(rl())
    A = list(map(int, rl().split()))
    graph = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v = map(lambda x: int(x) - 1, rl().split())
        graph[u].append(v)
        graph[v].append(u)
    
    ans = [-1] * N
    stack = [0]
    dp = [INF] * (N + 1)
    rewind = [(-1, -1) for _ in range(N)]
    while stack:
        node = stack.pop()
        if 0 <= node:
            idx = bisect_left(dp, A[node])
            rewind[node] = (idx, dp[idx])
            dp[idx] = A[node]
            ans[node] = bisect_left(dp, INF)
            stack.append(~node)
            for child in graph[node]:
                if ans[child] == -1:
                    stack.append(child)
        else:
            idx, val = rewind[~node]
            dp[idx] = val
    print(*ans, sep='\n')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 142084
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair



string to_string(string s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string) s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(char ch) {
	return string("'")+ch+string("'");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <class InputIterator>
string to_string (InputIterator first, InputIterator last) {
	bool start = true;
	string res = "{";
	while (first!=last) {
		if (!start) {
			res += ", ";
		}
		start = false;
		res += to_string(*first);
		++first;
	}
	res += "}";
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x){
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x){
	for(auto& i:x)
		input>>i;
	return input;
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif



const int mod=1e9+7;

int mul(int a,int b)
{
	return (a*1ll*b)%mod;
	}
	
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	if(a<0)a+=mod;
	}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
		}
	return res;
	}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=505;



void solve(){
int a,p;
cin>>a>>p;
cout<<(a*3+p)/2;
}
	

signed main()
{   
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//cin>>tc;
	
    for(int i=0;i<tc;i++)
	{
	//	cout<<"Case #"<<i+1<<": ";
        solve();
		}
	
	}
/* Intuition > Logic 
 * If you are not confident please dont submit
 * When you feel like Quitting: Remember why you started
 * Game Theory == Skip
 * If n== 1e18 apply binary or Matrix expo

 *  I see those tears in your eyes
   I feel so helpless inside
   Oh love, there's no need to hide
   Just let me love you when your heart is tired
   Cold hands, red eyes
   Packed your bags at midnight
   They've been there for weeks
   You don't know what goodbye means
   Just roll up a cigarette
   Just forget about this mess
   Waiting on the sidelines
   From the sidelines
 */


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

int main()
{
    int A, B, AB;
    cin >> A >> B;
    AB = A + B;
    if (A % 3 == 0 || B % 3 == 0 || AB % 3 == 0)
        cout << "Possible" << endl;
    else
    {
        cout << "Impossible" << endl;
    }
}

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

#define int long long
#define INT int
#define MOD 1000000007

#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;
const long long INF = 1LL << 60;

char fun(int i)
{
    if (i == 0)
    {
        return 'z';
    }
    else
    {
        return 'a' + (i - 1);
    }
}

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

    int temp = 26;
    int sum = 0;

    vector<char> ans;

    while (0 < n)
    {
        int s = n % temp;
        s = (int)ceil((double)s / (temp / 26)) % 26;
        //cout << s << endl;
        ans.pb(fun(s));
        sum += temp;
        n -= temp;
        temp *= 26;
    }

    int l = ans.size();
    rep(i, l)
    {
        cout << ans[l - 1 - i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3672
import sys
import numpy as np
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N, W = map(int, readline().split())
    wv = map(int, read().split())
    dp = np.zeros(W + 1, np.int64)

    for w, v in zip(wv, wv):
        np.maximum(dp[w:], dp[:-w] + v, out=dp[w:])

    print(dp.max())


if __name__ == '__main__':
    main()

Measured memory_bytes: 18228
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
cuma = [0]
for a in A:
    cuma.append(cuma[-1] + a)

cumb = [0]
for b in B:
    cumb.append(cumb[-1] + b)

ans = 0
from bisect import bisect
for i,ca in enumerate(cuma):
    if ca > K: break
    t = K - ca
    j = bisect(cumb, t)
    ans = max(ans, i+j-1)
print(ans)

Measured memory_bytes: 47360
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = long long ;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    vi v = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    ll k;
    cin >> k;
    cout << v.at(k-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int H, W;
int a[550][550];
signed main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++)for (int j = 0; j < W; j++)cin >> a[i][j];
    vint x1, y1, x2, y2;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W - 1; j++) {
            if (a[i][j] % 2 == 1) {
                x1.push_back(j), y1.push_back(i), x2.push_back(j + 1), y2.push_back(i);
                a[i][j + 1]++;
            }
        }
    }
    for (int i = 0; i < H - 1; i++) {
        if (a[i][W - 1] % 2 == 1) {
            x1.push_back(W - 1), y1.push_back(i), x2.push_back(W - 1), y2.push_back(i + 1);
            a[i + 1][W - 1]++;
        }
    }
    cout << x1.size() << endl;
    for (int i = 0; i < x1.size(); i++)cout << y1[i]+1 << " " << x1[i]+1 << " " << y2[i]+1 << " " << x2[i]+1 << endl;
}

Measured memory_bytes: 8276
n = int(input())
list_A = [0]*4
for i in range(n):
    a = input()
    if a == "AC":
        list_A[0]+=1
    elif a == "WA":
        list_A[1]+=1
    elif a == "TLE":
        list_A[2]+=1
    elif a == "RE":
        list_A[3]+=1
print("AC x "+str(list_A[0]))
print("WA x "+str(list_A[1]))
print("TLE x "+str(list_A[2]))
print("RE x "+str(list_A[3]))

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    vector<int> D1(N);
    vector<int> D2(N);
    rep(i,N)cin >> D1[i] >> D2[i];

    int ct = 0;
    bool ok = false;
    rep(i,N){
        if(D1[i] == D2[i])ct++;
        else ct = 0;
        if(ct == 3)ok = true;
    }

    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> order_set;

int main() {
    int H, W;
    scanf("%d %d", &H, &W);
    multiset<int> st;
    map<int, int> mp;
    for (int i = 1; i <= W; i++) {
        st.insert(0);
        mp[i] = i;
    }
    for (int i = 0; i < H; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        auto it = mp.lower_bound(a);
        int left_mx = -1;
        while (it != mp.end() && it->first <= b + 1) {
            left_mx = max(left_mx, it->second);
            st.erase(st.find(it->first - it->second));
            it = mp.erase(it);
        }
        if (left_mx != -1 && b != W) {
            st.insert(b + 1 - left_mx);
            mp[b + 1] = left_mx;
        }
        printf("%d\n", st.empty() ? -1 : *st.begin() + i + 1);

    }
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 22548
// 22
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << left << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef DEBUG
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}
// 3
void _main(int tc) {
  int n;
  cin >> n;
  vector<vector<int>> can(n, vector<int>(n));
  rep(n) { rep(j, n) cin >> can[i][j]; }
  int const mod = 1e9 + 7;
  auto addSelf = [](int &a, int b) -> void {
    a += b;
    if (a >= mod) a -= mod;
  };

  /************* Recursive *************
  vector<vector<int>> mem(n, vector<int>(1 << n, -1));
  function<int(int, int)> f = [&](int i, int mask) -> int {
    if (mask == (1 << n) - 1) return 1;
    if (i == n) return 0;
    if (mem[i][mask] != -1) return mem[i][mask];
    mem[i][mask] = 0;
    rep(j, n) {
      if (can[i][j] && ((mask >> j) & 1) == 0)
        addSelf(mem[i][mask], f(i + 1, mask | (1 << j)));
    }
    return mem[i][mask];
  };
  cout << f(0, 0) << endl;
  *********** End Recursive ***********/

  /************* Iterative ************* O(N*N*2^21) too slow
  vector<vector<int>> mem(n + 1, vector<int>((1 << n)));

  rep(n + 1) { mem[i][(1 << n) - 1] = 1; }

  rep(i, n - 1, -1) {
    rep(mask, (1 << n) - 1, -1) {
      rep(j, n) {
        if (can[i][j] && ((mask >> j) & 1) == 0) {
          addSelf(mem[i][mask], mem[i + 1][mask | (1 << j)]);
        }
      }
    }
  }
  cout << mem[0][0] << endl;
  *********** End Iterative ***********/

  vector<vector<int>> mem(n + 1, vector<int>((1 << n)));

  rep(n + 1) { mem[i][(1 << n) - 1] = 1; }

  rep(mask, (1 << n) - 1, -1) {
    int i = __builtin_popcount(mask);
    rep(j, n) {
      if (i < n && can[i][j] && ((mask >> j) & 1) == 0) {
        addSelf(mem[i][mask], mem[i + 1][mask | (1 << j)]);
      }
    }
  }
  cout << mem[0][0] << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

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

using namespace std;

typedef long long ll;

ll n, ans = 0;

map <ll, bool> used;

void check(ll x)
{
    // cout << x << endl;
    if(x == 1) return;
    ll m = n;
    while(m % x == 0) m /= x;
    m %= x;
    if(m == 1) 
    {
        if(!used[x])
        {
            ans++;
            used[x] = 1;
        }
    }
}

int main()
{
    cin >> n;
    for(ll i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            check(i); check(n / i);
        }
    }
    ll m = n - 1;
    for(ll i = 1; i * i <= m; i++)
    {
        if(m % i == 0)
        {
            check(i), check(m / i);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int M, K;
    cin >> M >> K;
    if(M==1){
        if(K==0){
            cout << "1 1 0 0" << endl;
            return 0;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }

    if(K < (1<<M)){
        for(int i=0; i<(1<<M); i++){
            if(i==K)continue;
            cout << i << ' ';
        }
        cout << K << ' ';
        for(int i=(1<<M)-1; i>=0; i--){
            if(i==K)continue;
            cout << i << ' ';
        }
        cout << K << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <queue>
#include <functional>
#define INF 1e15
using namespace std;

typedef long long ll;
typedef pair<ll,int> P;
struct edge{
	int t,id;
	ll d;

	edge(int tt,int ii,ll dd){
		t=tt;
		id=ii;
		d=dd;
	}
};

int n,m,c;
int a[200001],b[200001],d[200001];
ll cost[100001],x_max;
vector<edge> G[100001];
bool flag[200001];
ll costdata[100001];
int index[100001],datasize;


void dijk(){
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,1));
	for(int i=1;i<=n;i++)cost[i]=INF;
	cost[1]=0;
	while(que.size()){
		P q=que.top();
		que.pop();
		if(q.first!=cost[q.second])continue;
		costdata[datasize]=cost[q.second];
		index[datasize++]=q.second;
		x_max=max(x_max,q.first);
		for(int i=0;i<G[q.second].size();i++){
			edge e=G[q.second][i];
			if(e.d+q.first<cost[e.t]){
				cost[e.t]=e.d+q.first;
				que.push(P(cost[e.t],e.t));
			}
		}
	}
	return;
}

ll func(){
	priority_queue<P,vector<P>,greater<P> > que;
}

int main(void){
	scanf("%d %d %d",&n,&m,&c);
	ll res=INF;
	for(int i=0;i<m;i++){
		scanf("%d %d %d",&a[i],&b[i],&d[i]);
		G[a[i]].push_back(edge(b[i],i,d[i]));
		G[b[i]].push_back(edge(a[i],i,d[i]));
	}
	dijk();
	ll alldist=0;
	for(int i=n-1;i>=0;i--){
		res=min(res,costdata[i]*c+alldist);
		for(int j=0;j<G[index[i]].size();j++){
			edge e=G[index[i]][j];
			if(!flag[e.id]){
				flag[e.id]=true;
				alldist+=e.d;
			}
		}
	}
	res=min(res,alldist);
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 18736
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
int main()
{
   string s;
   cin>>s;
   int ctr=0,ans=0;
   for(int i=0;i<s.size();i++)
   {
       if(s[i]=='R')
       {
           ctr++;
           ans=max(ctr,ans);
       }
       else ctr=0;
   }
   cout<<ans<<endl;
}

   

Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;

int main(){
	char a;
	scanf("%c",&a);
	if(a>='A'&&a<='Z')
        printf("A\n");
    else
        printf("a\n");
	return 0;
}


Measured memory_bytes: 3756
#include <stdio.h>

int gcd ( int x, int y ) {
  while (1) {
    int temp = x;
    x = y;
    y = temp % y;
    if ( y == 0 ) {
      break;
    }
  }
  return x;
}

int main ( void ) {

  int x, y;
  scanf( "%d %d", &x, &y);

  if ( y >= x ) {
    int temp = x;
    x = y;
    y = temp;
  }

  printf ( "%d\n", gcd ( x, y ));
}



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

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	int a,b,c;
	cin >> a >> b >> c;
	cout << min(a + b + 1,c) + b;
	
	
	return 0;
}



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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

lint xor_(lint X) {
    //[0,X]のxor

    lint ans = 0;
    for (lint b = 0; b < 60; b++) {
        // [0,X] で d 桁目に何回1がでたか
        lint T   = (1ll << b) * 2;
        lint k   = (X + 1) / T;
        lint r   = (X + 1) % T;
        lint cnt = k * T / 2 + max(0ll, r - T / 2);
        // dd(b, cnt);
        // d(T);
        // dd(k, r);
        cnt %= 2;
        ans += (1ll << b) * cnt;
    }
    return ans;
}

int main() {
    lint A, B;
    cin >> A >> B;
    cout << (xor_(B) ^ xor_(A - 1)) << endl;
    return 0;
}

Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys
from functools import reduce


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

def gcd_group(A):
    return reduce(gcd, A)


def solve(N: int, A: "List[int]"):
    left = [A[0]] # A[0]からA[i]までのGCD
    right = [A[N-1]] # A[i]からA[N-1]までのGCD
    for i in range(1, N):
        left.append(gcd(left[-1], A[i]))
        right.append(gcd(right[-1], A[-i-1]))
    right.reverse()

    ret = 0
    for i in range(N):
        if i == 0:
            temp = right[1]
        elif i == N-1:
            temp = left[N-2]
        else:
            temp = gcd(left[i-1], right[i+1])

        if temp > ret:
            ret = temp
    print(ret)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17420
N,M = map(int,input().split())
edge =[[] for _ in range(N+1)]
for _ in range(M):
    l,r,d = map(int,input().split())
    edge[l].append([r,d])
    edge[r].append([l,-d])
G = [None]*(N+1)
ok = True
stack = []
for x in range(1,N+1):
    if G[x] is not None: continue
    G[x] = 0
    stack = [x]
    while stack:
        v = stack.pop()
        for to,d in edge[v]:
            if G[to] is None:
                G[to] = G[v] + d
                stack.append(to)
            else:
                if G[to] != G[v] + d:
                    ok = False
                    break
    if ok == False:
        break
print('Yes' if ok else 'No')

Measured memory_bytes: 77216
//abc051_b.cpp
//Sun Oct 21 17:20:13 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int k,s;
	cin >> k >> s;

	ll ans = 0;
	for (int i=k;i>=0;i--){
		if (i>s){
			continue;
		}else{
			if (s-i > 2*k){
				continue;
			}else if (s-i <= k){
				ans += s-i+1;
			}else{
				ans += 2*k-(s-i)+1;
			}
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 256