akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int h, w, d;
  cin >> h >> w >> d;
  vector<vector<pair<int, int>>> vp(d, vector<pair<int, int>>((h*w+d-1)/d, {-1, -1}));
  rep(i, h){
    rep(j, w){
      int a;
      cin >> a;
      a--;
      int i1 = a % d;
      int i2 = a / d;
      vp.at(i1).at(i2) = {i, j};
    }
  }
  rep(i, d){
    if(vp.at(i).back().first == -1) vp.at(i).pop_back();
  }
  vector<vector<int>> cost(d, vector<int>());
  rep(i, d){
    cost.at(i).push_back(0);
    rep2(j, 1, vp.at(i).size()){
      auto pr = vp.at(i).at(j-1);
      auto no = vp.at(i).at(j);
      int cpr = cost.at(i).back();
      cost.at(i).push_back(abs(pr.first-no.first) + abs(pr.second - no.second) + cpr);
    }
  }

  int q;
  cin >> q;
  rep(_q, q){
    int l, r;
    cin >> l >> r;
    l--; r--;
    int index = l % d;
    int st = l / d;
    int fn = r / d;
    cout << cost.at(index).at(fn) - cost.at(index).at(st) << endl;
  }
  return 0;
}

Measured memory_bytes: 10240
#include<stdio.h>
 
int main(){
  int a,b;

  scanf("%d %d",&a,&b);
  
  if(a<b) printf("a < b\n");
  if(a==b) printf("a == b\n");
  if(a>b) printf("a > b\n");
  
  return 0;
}


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

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2 << endl;
  return 0;
}

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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll k, a, b;
  cin >> k >> a >> b;
  bool flag = 0;
  for (ll i = a; i <= b; i++) {
    if (i%k == 0) flag = 1;
  }
  if (flag) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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

long long com(long long n,long long k){
	
}
long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}
class G{
	long long node;
	long long w;
	
};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string w;
	cin>>w;
	vector<bool>data(27,true);
	for(int i=0;i<w.length();i++){
		data[w[i]-'a'] = !data[w[i]-'a'];
	}
	bool ans=true;
	for(int i=0;i<27;i++){
		if(!data[i])ans=false;
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}

	


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

long long n, a, b, ansc = 1;
vector<long long> v;
double ans = 0;

void solve();

int main() {
  cout << fixed << setprecision(10);
  cin >> n >> a >> b;
  for(int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end(), greater<long long>());
  solve();
  cout << ans << endl << ansc << endl;
  return 0;
}

void solve() {
  long long cnta = 1, cntall = 1;
  for(int i = 0; i < a; ++i) {
    ans += v[i];
    if(i != 0) {
      if(v[i] == v[i - 1])
        ++cnta;
      else
        cnta = 1;
    }
  }
  ans /= (double)a;
  cntall = cnta;
  for(int i = a; i < n; ++i) {
    if(v[i] != v[i - 1]) break;
    ++cntall;
  }
  if(a != cnta)
    for(long long i = 1; i <= cnta; ++i) {
      ansc *= cntall + 1 - i;
      ansc /= i;
    }
  else {
    ansc = 0;
    for(long long j = a; j <= min(b, cntall); ++j) {
      long long now = 1;
      for(long long i = 1; i <= j; ++i) {
        now *= cntall + 1 - i;
        now /= i;
      }
      ansc += now;
    }
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int n,i,k;char c;ll f0,f1,f2;
int main(){
	scanf("%d",&n);scanf("%d",&f0);f1=f2=-1e18;
	for (n--;n--;){
		scanf(" %c%d",&c,&k);
		if (c=='-') k=-k;
		ll v0=f0+k,v1=f1-k,v2=f2+k;
		f0=max(v0,max(v1,v2));
		if (c=='+') f1=max(v1,v2),f2=v2;
		else f1=max(v0,max(v1,v2)),f2=max(v1,v2);
	}
	printf("%lld",f0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;
const int MOD = 1000000007;
const int MAX = 1000000;

int main(){
        int a,b;
        cin >> a >> b;
        if(a == 1 && b == 1){
                cout << 1 << " " << 2 << endl;
                cout << "#." << endl;
                return 0;
        }
        bool sw = false;
        if(a > b) {swap(a,b);sw = true;}
        vector<vector<char>> maze(99,vector<char>(99,'.'));
        int n = b+a-2;
        int i = 1,j = 1;
        while(n > 0){
                maze[i][j] = '#';
                j += 2;
                if(j > 98){
                        j = 1;
                        i += 2;
                }
                n--;
        }

        n = a-1;
        i = 0;
        j = 1;
        while(n > 0){
                maze[i][j] = '#';
                maze[i+1][j-1] = '#';
                j += 2;
                if(j > 98){
                        i += 2;
                        j = 1;
                }
                n--;
        }

        if(a==1){
                maze[98][98] = '#';
        }

        cout << 99 << " " << 99 << endl;
        if(sw){
                rep(i,99){
                        rep(j,99){
                                cout << (maze[i][j] == '.' ? '#' : '.') ;
                        }
                cout << endl;
                }
        }
        else{
            rep(i,99){
                    rep(j,99){
                            cout << maze[i][j] ;
                    }
                    cout << endl;
            }
        }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  string s;cin>>s;int ans=INF;
  for(int i=0;i<(int)s.size()-2;i++){
    int t=stoi(s.substr(i, 3));
    ans=min(ans, abs(t-753));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	p, q := input()
	a := sub(permitationNumber(p), permitationNumber(q))
	fmt.Println(a)
}

func sub(p, q int) int {
	if p < q {
		return q - p
	}
	return p - q
}

func permitationNumber(n []int) int {
	if len(n) <= 1 {
		return 0
	}
	return permitationNumber(n[1:]) + minNumber(n[0], n[1:])*factorial(len(n)-1)
}

func minNumber(m int, n []int) int {
	c := 0
	for _, v := range n {
		if v < m {
			c++
		}
	}
	return c
}

func factorial(n int) int {
	s := 1
	for ; n > 1; n-- {
		s *= n
	}
	return s
}

func input() ([]int, []int) {
	var n int
	fmt.Scan(&n)
	p := make([]int, n, n)
	q := make([]int, n, n)
	for i := range p {
		fmt.Scan(&p[i])
	}
	for i := range q {
		fmt.Scan(&q[i])
	}
	return p, q
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define maxn 1000119
int num[maxn],tree[maxn],booll[maxn],nnn[maxn],N,ww;;
struct tt
{
    int l,r;
    int pos;
};
tt ask[maxn];
bool cmp(tt x,tt y)
{ 
    return x.r<y.r;
}
int lowbit(int n) 
{
    return n&(-n);
}
void add(int n,int now)
{
    while(n<=N)
    {
        tree[n]+=now;
        n+=lowbit(n);
    }
}
int sum(int n)
{
    int ans=0;
    while(n!=0)
    {
        ans+=tree[n];
        n-=lowbit(n);
    }
    return ans;
}
int main()
{
        scanf("%d%d",&N,&ww);
        for(int i=1;i<=N;i++)
            scanf("%d",&num[i]);
        for(int i=1;i<=ww;i++)
        {
            scanf("%d%d",&ask[i].l,&ask[i].r);
            ask[i].pos=i; 
        }
        sort(ask+1,ask+1+ww,cmp);
        int next=1;
        for(int i=1;i<=ww;i++)
        {
            for(int j=next;j<=ask[i].r;j++)
            {
                if(booll[num[j]]) 
                    add(booll[num[j]],-1);
                add(j,1);
                booll[num[j]]=j;
            }
            next=ask[i].r+1;
            nnn[ask[i].pos]=sum(ask[i].r)-sum(ask[i].l-1);
        }
    for(int i=1;i<=ww;i++)
      cout<<nnn[i]<<endl;
    return  0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


int main() {
    ll n;
    cin >> n;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];

    vector<ll> y(n);
    rep(i, n) y[i] = x[i];
    sort(y.begin(), y.end());

    ll left = y[n/2 - 1];
    ll right = y[n/2];

    if(left == right){
        rep(i, n) cout << left << endl;
        return 0;
    }

    rep(i, n){
        if(x[i] <= left) cout << right << endl;
        else             cout << left << endl;
    }



    
    return 0;
}

Measured memory_bytes: 5376
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 1000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

int main()
{
    fast
    char ch;
    cin>>ch;
    if(ch>='A'&&ch<='Z')
    {
        cout<<"A";
    }
    else
    {
        cout<<'a';
    }
}
//a+b=a?b+2?(a&b)
//a+b==(a&b)+(a|b)
//__builtin_popcount(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";



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

int main(){
    using namespace std;
    int N,D;
    cin >> N >> D;
    int one_tree_num = 2*D+1;
    int num = N/one_tree_num + 1;
    if (N % one_tree_num == 0) num -=1 ;
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,n;
	long long a[10005],b[10005],suma,sumb,t,count=0,s1=0,s2=0,s3=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	 scanf("%lld",&a[i]);
	for(i=0;i<n;i++)
	 scanf("%lld",&b[i]);
    for(i=0;i<n;i++)
    {
    	if(a[i]!=b[i]) break;
	}
	if(i==n)  count=1;
	else
	{
		suma=0;sumb=0;
	  for(i=0;i<n;i++)
	  {
	  	suma+=a[i];
	  	sumb+=b[i];
	  }
	  t=sumb-suma;
	  if(t<=0) count=-1;
	  else
	  {
	  	 for(i=0;i<n;i++)
	  	 {
	  	 	if(a[i]<b[i])
	  	 	{
	  	 	  s1=s1+(b[i]-a[i])/2;
			  if((b[i]-a[i])%2!=0) 
			  {
			  	 s1++; s2++;
			  }
			}
		 }
		 if(s1>t) count=-1;
		 else
		 	count=1;
	  }
	}
  if(count==-1)  printf("No\n");
  else  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        A: [u64; N],
    }
    let mut map:HashMap<u64,u64> = HashMap::new();
    for i in 0..N{
        *map.entry(A[i]).or_insert(0) += 1;
    }
    let len = map.len() as u64;
    println!("{:?}",len - if (N as u64 - len)%2==0{0}else{1});
}

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

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

  if(n==0) {
    cout<<x<<endl;
    return 0;
  }

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

  sort(p, p+n);

  int a = lower_bound(p, p+n, x) - p;

  if(a==n) cout<<x<<endl;
  else if(p[a]!=x) cout<<x<<endl;
  else {
    int move = 1;
    while(a-move>=0 || a+move<n) {
      if(a-move>=0) {
        if(p[a-move]!=x-move) {
          cout<<x-move<<endl;
          return 0;
        }
      }
      if(a+move<n) {
        if(p[a+move]!=x+move) {
          cout<<x+move<<endl;
          return 0;
        }
      }
      move++;
    }

    if(a+move==n) cout<<p[0]-1<<endl;
    else cout<<p[n-1]+1<<endl;
  }

  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main() {
  int N, K, output = 1;
  scanf("%d %d", &N, &K);
  for(int i = 0; i < N; i++) {
    (output+K > output*2) ? output *= 2 : output += K;
  }
  printf("%d\n", output);
  return 0;
}

Measured memory_bytes: 1708
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define debug(args...) fprintf(stderr,args)
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define REP(i,a,b) for(int i = a; i >= b; --i)

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

int n, p;

int main(){
	scanf("%d%d",&n,&p);
	bool ok = false;
	FOR(i,1,n){
		int a;
		scanf("%d",&a);
		if(a % 2) ok = true;
	}
	if(ok) printf("%lld\n", (1LL<<(n-1)));
	else if(p) printf("0\n");
	else printf("%lld\n",1LL<<n);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define ll long long
#define coYes cout << "Yes" << endl
#define coYES cout << "YES" << endl
#define coyes cout << "yes" << endl
#define coNo cout << "No" << endl
#define coNO cout << "NO" << endl
#define cono cout << "no" << endl
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){ //最大公約数
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    int A,B,m,MIN,MINA=100001,MINB=100001;
    cin >> A >> B >> m;
    vector<int> a(A),b(B);
    rep0(i,A){
        cin >> a[i];
        MINA=min(a[i],MINA);
    }
    rep0(i,B){
        cin >> b[i];
        MINB=min(b[i],MINB);    
    }
    MIN=MINA+MINB;
    vector<int> x(m),y(m),c(m);
    rep0(i,m)
        cin >> x[i] >> y[i] >> c[i];
    rep0(i,m){
        MIN=min(a[x[i]-1]+b[y[i]-1]-c[i],MIN);
        //cout << "MIN: " <<MIN << endl;
    }
    cout << MIN << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

int main(void) {
    ll k; int n;
    scanf("%lld %d", &k, &n);
    vector<ll> arr(n);
    ll val = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &arr[i]);
        if (!i)
            val = arr[0];
        else
            val = max(val, arr[i] - arr[i - 1]);
    }
    val = max(val, k - arr[n - 1] + arr[0]);    
    printf("%lld\n", k - val);
    return 0;
}

Measured memory_bytes: 1792
from collections import Counter
import math
N=int(input())
s=[]
z=Counter()
def prime(a):
    i=2
    while i*i<=a:
        if a%i==0:return 0
        i+=1
    return 1

def vsum(a):
    s=0
    for i in range(1,a+1):
        s+=i
        if s==a:return i
        elif s>a:return i-1

if N==1:
    print(0)
    exit()
elif prime(N)==1:
    print(1)
    exit()

for i in range(2,int(math.sqrt(N))):
    while N%i==0:
        s.append(i)
        N=N//i
        if N==1:break
        elif prime(N)==1:
            s.append(N)
            break

z=Counter(s)
ans=0
for key,values in z.items():
    ans+=vsum(values)
print(ans)




Measured memory_bytes: 68268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T="";
  cin >> S;
  reverse(S.begin(),S.end());
  string a,b,c,d;
  a="maerd";
  b="remaerd";
  c="esare";
  d="resare";
  int t=0;
  int s=S.size();
  while (t+2<s){
    if (S[t+2]=='e'){
      T+=a;
      t+=5;
    }
    else if (S[t+2]=='m'){
      T+=b;
      t+=7;
    }
    else if (S[t+2]=='a'){
      T+=c;
      t+=5;
    }
    else if (S[t+2]=='s'){
      T+=d;
      t+=6;
    }
    else {
      break;
    }
  }
  if (T==S){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}    

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

const int INF = 1 << 30;

struct edge {int to, cost; };

int V;
int d[100][100];

vector<edge> G[100];
priority_queue<P, vector<P>, greater<P> > que;

void dijkstra(int s,int a){
  for(int i = 0; i < V; i++) d[a][i] = INF;
  que.push(P(0, s));
  d[a][s] = 0;

  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[a][v] < p.first) continue;
    for(int i = 0; i < G[v].size(); i++){
      edge e = G[v][i];
      int Min = (a == 0 ? d[a][v] + e.cost : min(d[a][v] + e.cost, d[a-1][v] + e.cost/2));
      if(d[a][e.to] > Min){
        d[a][e.to] = Min;
        que.push(P(d[a][e.to], e.to));
      }
    }
  }
}

int main(){
  int c,m,s,e,From,To,Cost;
  edge E;
  while(scanf("%d%d%d%d%d",&c,&V,&m,&s,&e)!=EOF,c|V|m|s--|e--){
    for(int i = 0; i < m; i++){
      scanf("%d%d%d",&From,&To,&Cost);

      From--,To--;
      E.to = From,E.cost = Cost;
      G[To].push_back(E);
      E.to = To;
      G[From].push_back(E);
    }

    for(int i = 0; i <= c; i++) dijkstra(s, i);

    printf("%d\n",d[c][e]);

    for(int i = 0; i < 100; i++) G[i].clear();
  }
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
bool Check(bool can[50],int n){
  for(int i=0;i<n;i++){
    if(!can[i])return true;
  }
  return false;
}
int main(void){
  int root[50][50];
  int e,n;
  cin>>n>>e;
  int edge[50][2];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      root[i][j]=0;
    }
  }
  for(int i=0;i<e;i++){
    int a,b;
    cin>>a>>b;
    root[a-1][b-1]=1;
    root[b-1][a-1]=1;
    edge[i][0]=a-1;
    edge[i][1]=b-1;
  }
  int count=0;
  for(int i=0;i<e;i++){
    root[edge[i][0]][edge[i][1]]=0;
    root[edge[i][1]][edge[i][0]]=0;
    queue<int>que;
    que.push(0);
    bool can[50];
    for(int j=0;j<n;j++)can[j]=false;
    while(!que.empty()){
      int now=que.front();
      que.pop();
      can[now]=true;
      for(int k=0;k<n;k++){
        if(root[now][k]==1){
          if(!can[k]){
            que.push(k);
          }
        }
      }
    }
    if(Check(can,n)){
      count++;
    }
    root[edge[i][0]][edge[i][1]]=1;
    root[edge[i][1]][edge[i][0]]=1;
  }
  cout<<count<<endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int N2=N;
  int count=1;
  while(1){
    if(N2%360==0){
      cout << count << endl;
      return 0;
    }
    count++;
    N2+=N;
  }
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    int m=a+b;
    int n=b+c;
    int p=c+a;
    int x=m>n?n:m;
    int min=x>p?p:x;
    cout<<min<<"\n";
}

Measured memory_bytes: 256
import Data.List

-- 部分文字列をまともに求めると爆発するのでn文字で足きり
-- n+1文字の文字列から先頭から1,..,n文字までの部分文字列が辞書順で前に来る
substrings :: Int -> String -> [String]
substrings _ "" = []
substrings 0 _ = []
substrings n s@(_:r) = (substrings' n s) ++ (substrings n r)
    where
        substrings' _ "" = []
        substrings' 0 _ = []
        substrings' n (c:r) = [c:""] ++ (map ((:)c) $ substrings' (n - 1) r)

pickup_small :: Ord a => Int -> [a] -> [a]
pickup_small n l = take' n $ sort $ nub l
    where
        take' n l = take (minimum [n, length l]) l

kth :: Int -> String -> String
kth k s = (foldr f [] $ substrings k s) !! (k - 1)
    where
        f e r = pickup_small k (e:r)

main = do
    s <- getLine
    k <- readLn
    putStrLn $ kth k s


Measured memory_bytes: 28028
#include <iostream>
using namespace std;
int n;
int main() {
cin>>n;
int arr[n][3];
for(int i=0;i<n;i++)
cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
for(int i=1;i<n;i++)
{
 arr[i][0]+=max(arr[i-1][1],arr[i-1][2]);
 arr[i][1]+=max(arr[i-1][0],arr[i-1][2]);
 arr[i][2]+=max(arr[i-1][0],arr[i-1][1]);
}
cout<<max(arr[n-1][0],max(arr[n-1][1],arr[n-1][2]));
	return 0;
}

Measured memory_bytes: 4744
// Contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include"iostream"
#include"string"
#include"vector"
#include"algorithm"

using namespace std;

int main()
{
	/*int n,k;
	cin >> n;
	vector<char>s(n);
	for (int j = 0; j < n; j++)  cin >> s[j];
	cin >> k;
	for (int i = 0; i < n; i++)
	{
		if (s[i] != s[k-1]) {
			s[i] = '*';
		}
	}

	for (int l = 0; l < n; l++)
	{
		cout << s[l] ;
	}*/
	
	int n;
	cin >>n ;
	double sum=0;

	vector<double>a(n);
	for (int i = 0; i < n; i++)cin >> a[i];

	for (int i = 0; i < n; i++) {
		sum = sum+1/a[i];
	}
	
	cout <<1/ sum << endl;

}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
  int n,k;
  std::cin >> n>>k;
  std::vector<double> a(n,0);
  rep(i,n){
    int d=i+1,c=0;
    for(;d<k;d*=2){
      c++;
    }
    a[i]=1.0/pow(2,c);
    //std::cout << 1.0/pow(2,c) << std::endl;
  }
  std::cout <<keta(15)<< sum(all(a),0.0)/n << std::endl;
  
}

Measured memory_bytes: 1024
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var x = one[0];
  var y = one[1];
  var z = one[2];
  if(x == y && y == z && z == x){
     myout("Yes");
  }else{
     myout("No");
  }
}

Measured memory_bytes: 22456
//In the name of ALLAH the most merciful the most beneficial

#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+8;
static const int INF = 0x3f3f3f3f;
static const int MOD = 998244353;

int main(){
    int ans[con];
    FOR(i,0,con)
        ans[i] = 1000000000;
    int N,k;sc(N);sc(k);
    int arr[N+1];
    FOR(i,1,N+1){
        sc(arr[i]);
    }
    ans[1] = 0;
    ans[2] = abs(arr[2]-arr[1]);
    //Filling uptill first k
    FOR(i,3,k+1){
        
        FOR(j,1,i){
            
            ans[i] = min(ans[i],ans[j]+abs(arr[j]-arr[i]));
        }
    }
    
    FOR(i,k+1,N+1){
        
        FOR(j,i-k,i){
            
            ans[i] = min(ans[i],ans[j]+abs(arr[j]-arr[i]));
        }
    }
    cout << ans[N];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define lb(container, val)      lower_bound(all((container)), val) - (container).begin()
#define ub(container, val)      upper_bound(all((container)), val) - (container).begin()
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define sz(container)           ((int) (container).size())
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (long long) 1000000007
#define inf                     INT_MAX
#define INF                     LLONG_MAX

using namespace std;

#ifdef LOCAL_DEFINE
    #include "../../DEBUG.hpp"
#endif

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
long long MAX() {return LLONG_MIN;}
long long MIN() {return LLONG_MAX;}
template<typename T, typename... Args>
T MAX(T a, Args... args) {return max(a, MAX(args...));}
template<typename T, typename... Args>
T MIN(T a, Args... args) {return min(a, MIN(args...));}

typedef long long ll; 
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;

int main(void) {    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in1", "r", stdin);
#endif
    
    int n, k;
    cin >> n >> k;
    vll arr(n), dp(n, LLONG_MAX);
    forn(i, n) cin >> arr[i];
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    fore(i, 2, n - 1, 1) {
        fore(j, max(0, i - k), i - 1, 1) {
            uin(dp[i], dp[j] + abs(arr[i] - arr[j]));
        }
    }
    cout << dp[n - 1] << '\n';
    
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
/*
	13 21 106
.....................
.####.####.####.####.
..#.#..#.#.#....#....
..#.#..#.#.#....#....
..#.#..#.#.#....#....
.####.####.####.####.
.....................
.####.####.####.####.
....#.#..#....#.#..#.
.####.#..#.####.#..#.
.#....#..#.#....#..#.
.####.####.####.####.
.....................
*/
int main(){
	int h,w,k;cin>>h>>w>>k;
	vector<string> ss(h);
	for(int i=0;i<h;++i)cin>>ss[i];
	vector<vector<int>> res(h,vector<int>(w,-1));
	int now = 0;
	bool ok;
	for(int i=0;i<h;++i){
		ok = false;
		int fst = 1e5;
		for(int j=0;j<w;++j){
			if(ss[i][j]=='#'){
				now++;
				res[i][j] = now;
				ok = true;
				fst = min(fst,j);
			}else{
				if(ok){
					res[i][j] = now;
				}
			}
		}
		if(ok){
			for(int j=fst-1;j>=0;--j){
				res[i][j] = res[i][j+1];
			}
		}
	}
	for(int i=0;i<h-1;++i){
		for(int j=0;j<w;++j){
			if(res[i][j]>0 && res[i+1][j]==-1){
				res[i+1][j] = res[i][j];
			}
		}
	}
	for(int i=h-1;i>0;--i){
		for(int j=0;j<w;++j){
			if(res[i][j]>0 && res[i-1][j]==-1){
				res[i-1][j] = res[i][j];
			}
		}
	}	
	for(auto i:res){
		for(auto j:i){
			cout<<j<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = input[0];
            var R = input[1];

            Console.WriteLine(N >= 10 ? R : R + 100 * (10 - N));
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <climits>
#include <vector>
#include <cmath>
#include <cstring>
#include <set>

using namespace std;

int main(void)
{

    char S1, S2, S3;
    cin >> S1 >> S2 >> S3;

    bool res = ((S1 != S2) || (S2 != S3) || (S3 != S1));
    cout << (res ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-08-22 20:51:54 +0900
# LastModified: 2020-08-22 21:06:18 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    N = input()
    N_sum = 0
    for n in N:
        N_sum += int(n)
    if N_sum % 9 == 0:
        print('Yes')
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 9276
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A11,A12,A13,A21,A22,A23,A31,A32,A33;
        cin>>A11>>A12>>A13>>A21>>A22>>A23>>A31>>A32>>A33;
    bool a11=false,a12=false,a13=false,a21=false,a22=false,a23=false,a31=false,a32=false,a33=false;
    int N;
    cin>>N;
    int b[N];
    for(int i=0;i<N;i++){
        cin>>b[i];
        if(b[i]==A11){
            a11=true;
        }
        if(b[i]==A12){
            a12=true;
        }
        if(b[i]==A13){
            a13=true;
        }
        if(b[i]==A21){
            a21=true;
        }
        if(b[i]==A22){
            a22=true;
        }
        if(b[i]==A23){
            a23=true;
        }
        if(b[i]==A31){
            a31=true;
        }
        if(b[i]==A32){
            a32=true;
        }
        if(b[i]==A33){
            a33=true;
        }
    }
    if(a11&&a12&&a13){
        cout<<"Yes"<<endl;
    }
    else if(a21&&a22&&a23){
        cout<<"Yes"<<endl;
    }
    else if(a31&&a32&&a33){
        cout<<"Yes"<<endl;
    }
    else if(a11&&a21&&a31){
        cout<<"Yes"<<endl;
    }
    else if(a12&&a22&&a32){
        cout<<"Yes"<<endl;
    }
    else if(a13&&a23&&a33){
        cout<<"Yes"<<endl;
    }
    else if(a11&&a22&&a33){
        cout<<"Yes"<<endl;
    }
    else if(a13&&a22&&a31){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		C_Tests solver = new C_Tests();
		solver.solve(1, in, out);
		out.close();
	}

	static class C_Tests {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			long x = in.nextInt();
			Test[] tests = new Test[n];
			long need = 0;
			for (int i = 0; i < n; i++) {
				Test t = new Test();
				t.b = in.nextInt();
				t.l = in.nextInt();
				t.u = in.nextInt();
				tests[i] = t;

				need += t.b * t.l;
			}

			Arrays.sort(tests, (u, v) -> (-Long.compare(u.profitAt(x), v.profitAt(x))));
			long[] prefix = new long[n + 1];
			for (int i = 0; i < n; i++) {
				prefix[i + 1] = prefix[i] + tests[i].profitAt(x);
			}
			long l = -1;
			long r = x * n;
			while (r - l > 1) {
				long m = l + (r - l) / 2;
				long best = 0;
				for (int fixed = 0; fixed < n; fixed++) {
					long cur = tests[fixed].profitAt(m % x);
					int other = (int) (m / x);
					cur += prefix[other];
					if (fixed < other) {
						cur -= tests[fixed].profitAt(x);
						if (other < n) {
							cur += tests[other].profitAt(x);
						}
					}
					best = Math.max(best, cur);
				}
				if (need <= best) {
					r = m;
				} else {
					l = m;
				}
			}
			out.println(r);
		}

		class Test {
			long b;
			long l;
			long u;

			long profitAt(long n) {
				long ls = Math.min(n, b);
				long us = n - ls;
				return ls * l + us * u;
			}

		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 50244
#include<stdio.h>
#include<map>
#include<cstring>
using namespace std;
typedef unsigned long long ull; 

const int M=1586;
const ull base=233,mod=212370440130137957ll;

int n,num;
char s[M];
map<ull,bool> ch_hash;

void hash()
{
	ull ans=0;
	int len=strlen(s);
	for(int i=0;i<len;i++)
		ans=(ans*base%mod+int(s[i]))%mod;
	if(!ch_hash[ans])
	{
		ch_hash[ans]=true;
		num++;
	}
}

int main()
{
	scanf("%d",&n);
	while(n--)
	{
		scanf("%s",s);
		hash();
	}
	printf("%d\n",num);
	return 0;
}


Measured memory_bytes: 15720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    string s;
    cin >> s;
    int n = s.size();
    int sum = 0;
    rep(i, 0, n) sum += s[i] - '0';
    if (sum % 9 == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 3752
#include<stdio.h>
int main()
{
	int tensu[3], i, j, k, l;
	for (i = 0; i < 3; i++)
	{
		scanf("%d", &tensu[i]);
	}
	for (i = 0; i < 3; i++)
	{
		k = i;
		for (j = i + 1; j < 3; j++)
		{
			if (tensu[k] >= tensu[j])
			{
				k = j;
			}
		}
		l = tensu[i];
		tensu[i] = tensu[k];
		tensu[k] = l;
	}
	printf("%d %d %d\n", tensu[0], tensu[1], tensu[2]);
	return 0;
}

Measured memory_bytes: 2756
#include<cstdio>
using namespace std;
int main(void){
   int n;
   while(scanf("%d",&n),n){
      int flag[201] = {2};
      for(int i = 0; i < n;i++){
         int idx;scanf("%d",&idx);
         flag[idx] = 1;
      }

      int turn = 1;
      int t_num = 0,h_num = 0;
      for(int i = 1;;i++){
         int check = 0;
         for(int j = 1;j <= 2*n;j++){
            if(turn == 1){
               if(flag[j] == 1){
                  flag[j] = 2;
                  t_num++;
                  if(t_num == n) goto kitune;
                  turn = 0;
               }
            }
            else if(turn == 0){
               if(flag[j] == 0){
                  flag[j] = 2;
                  h_num++;
                  if(h_num == n) goto kitune;
                  turn = 1;
               }
            }
         }
         turn = 1-turn;
      }
      kitune:;
      printf("%d\n%d\n",n-h_num,n-t_num);
   }
   return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
using namespace std;

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

const long long INF = 1LL << 60;

int n;
long long h[100010];

long long dp[100010];


int main(){
	cin >> n;
    for (int i = 0; i < n; ++i) cin >> h[i];

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

	dp[0] = 0;

	for (int i = 1; i < n; ++i) {
		chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
		if(i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
	}

	cout << dp[n-1] << endl;

	return 0;
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
ans=0

l=[]
r=[]

for i in range(n):
  nu=i+1
  x=a[i]
  l.append(x+nu)
  r.append(nu-x)
  
di1={}
di2={}

for i in range(0,n):
  if i==n-1:
    continue
  else:
    if l[i] not in di1:
      di1[l[i]]=0
    di1[l[i]]+=1
    if r[i+1] not in di2:
      di2[r[i+1]]=0
    di2[r[i+1]]+=1
    if r[i+1] in di1:
      ans+=di1[r[i+1]]
      
print(ans)

Measured memory_bytes: 59216
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,c=0;
    cin>>n;
    priority_queue<ll>o,e;
    for(int i=0;i<n;i++)
    {
      ll x;
      cin>>x;
      if(x&1)
        o.push(x);
      else
        e.push(x);
    }
//cerr<<e.size()<<endl;
    while(!e.empty())
    {
      ll cur=e.top();
      //cerr<<cur<<" ";
      e.pop();
      while(cur%2==0)
      {
        c++;
        cur/=2;
      }
    }
    cout<<c<<endl;
}
return 0;
}

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

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(long long i = 0;i < n;i++)
int main()
{
  long long N;
  int A[300000];
  long long  sum=0;
  long long  ans=0;
  string S;
  cin>>S;
  if(S[S.length()-1]!='s'){
    S+="s";
  cout<<S;
  return 0;
  }else{

    cout<<S<<"es";
  }
  return 0;
}




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

int main() {
    int a, b;
    cin >> a >> b;

    if (a < 2*b) cout << 0 << endl;
    else if (a >= 2*b) cout << a-2*b << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <atcoder/math>
using namespace std;
using namespace atcoder;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T; cin >> T;
    while(T--) {
        int N, M, A, B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << endl;
    }

    return 0;
}


Measured memory_bytes: 3532
#include <stdio.h>

int main(){
	int a[1000];
	int b[1000];
	int i;
	int n;
	while(scanf("%d", &a[i])!=EOF)
	{
		scanf("%d", &b[i]);
		i++;
		n=i;
	}
	for(i=0;i<n;i++)
	{
		printf("%d\n", a[i]+b[i]);
	}
	return 0;
}

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

int main() {
  int N, A, B, C;
  cin>>N>>A>>B>>C;
  int l[N];
  for(int i=0;i<N;++i) cin>>l[i];
  int four = 1;
  for(int i=0;i<=N;++i) four *= 4;
  int tmp1, tmp2;
  vector<int> S;
  bool aru1, aru2, aru3;
  int l1, l2, l3;
  int ans = inf;
  int tmpans;
  for(int bit=0;bit<four;++bit) {
    tmp1 = bit;
    tmp2 = four/4;
    S.clear();
    for(int i=0;i<N;++i) {
      S.push_back(tmp1/tmp2);
      tmp1 %= tmp2;
      tmp2 /= 4;
    }
    aru1 = false;
    aru2 = false;
    aru3 = false;
    l1 = 0;
    l2 = 0;
    l3 = 0;
    tmpans = 0;
    for(int i=0;i<N;++i) {
      if(S[i]==0) {
        if(aru1) tmpans += 10;
        else aru1 = true;
        l1 += l[i];
      }
      if(S[i]==1) {
        if(aru2) tmpans += 10;
        else aru2 = true;
        l2 += l[i];
      }
      if(S[i]==2) {
        if(aru3) tmpans += 10;
        else aru3 = true;
        l3 += l[i];
      }
    }
    if(!aru1 || !aru2 || !aru3) continue;
    tmpans += abs(A-l1);
    tmpans += abs(B-l2);
    tmpans += abs(C-l3);
    ans = min(ans, tmpans);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
ll M=1e9 + 7;
const int N=1e5 + 5;
ll power(ll x, ll y)
{
    ll res=1;
    x=x%M;
    while(y>0)
    {
        if( y&1 )
        {
            res = (res*x)%M;
        }
        y = y >> 1;
        x = (x*x)%M;
    }
    return res%M;
}



/*
ll C(ll n, ll r)
{
    ll j1=1;
    //r=min(r,n-r);
    for(ll i=n;i>n-r;i--)
    {
        j1 = (j1*i)%M;
    }
    ll j2=1;
    for(ll i=1;i<=r;i++) j2 = (j2*i)%M;
    j2=power(j2,M-2);
    j1 = (j1*j2)%M;
    return j1;
    
    
}
*/


int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	ll n,k; cin>>n>>k; ll ans=0;
	ll fact[n+1]={0};
	fact[0]=1;
	for(ll i=1;i<=n;i++)
	    fact[i]=(fact[i-1]*i)%M;
	
	for(ll i=0;i<=min(n-1,k);i++)
	{
	    ll j1=( fact[n]*power( (fact[i]*fact[n-i])%M ,M-2) )%M;
	    ll j2=( fact[n-1]*power( (fact[i]*fact[n-1-i])%M ,M-2) )%M;
	    
	    //ans = ans + (C(n,i)*C(n-1,i))%M;
	    ans += ( j1*j2 )%M;
	    ans%=M;
	}
	cout<<ans;
	
	
	return 0;
}


Measured memory_bytes: 1792
table = [[0 for i in range(101)] for j in range(101)]
Row, Col = list(map(int, input().split()))

R_total = 0
C_total = 0

for i in range(Row):
    num = list(map(int, input().split()))
    R_num = 0
    for j in range(Col):
        table[i][j] = num[j]
        R_num += num[j]
    table[i][j+1] = R_num

for c in range(Col+1):
    C_num = 0
    for r in range(Row):
        C_num += table[r][c]
    table[r+1][c] = C_num

for i in range(Row+1):
    for j in range(Col+1):
        if j > 0: print(" ", end="")
        print(f"{table[i][j]}", end="")
    print()


    
        


Measured memory_bytes: 6760
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int player[][]=new int[n][3];
		int sum[]=new int[n];
		int checknum;
		for(int i=0;i<n;i++){
			for(int j=0;j<3;j++){
				player[i][j]=sc.nextInt();
			}
		}
		for(int i=0;i<3;i++){
			for(int j=0;j<n;j++){
				checknum=player[j][i];
				for(int k=0;k<n;k++){
					if(checknum == player[k][i] && k!=j){
						player[k][i]=0;
						player[j][i]=0;
					}		
				}
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<3;j++){
				sum[i]+=player[i][j];
			}
			System.out.println(sum[i]);
		}
		
	}

}

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

struct union_find{
    vector<ll> parent;
    vector<ll> nums;
    union_find(ll n){
        parent.resize(n);
        nums.resize(n, 1LL);
        rep(i, 0, n) parent[i] = i;
    }

    ll root(ll x){
        if(parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }

    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx != ry){
            parent[rx] = ry;
            nums[ry] += nums[rx];
        }
    }

    bool same(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return true;
        return false;
    }

    ll size(ll x){
        return nums[root(x)];
    }
};  

int main(){
    ll N, M;
    cin >> N >> M;
    union_find t(N);
    vector<ll> p(N);
    rep(i, 0, N){
        cin >> p[i];
        p[i]--;
    }
    rep(i, 0, M){
        ll x, y;
        cin >> x >> y;
        x--; y--;
        t.unite(x, y);
    }
    ll ans = 0;
    rep(i, 0, N){
        if(t.same(i, p[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560