akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
 
    using namespace std;
    using namespace __gnu_pbds;
 
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define int long long
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
 
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
 
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
 
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> omultiset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> oset;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> oset1;
 
/*.....................................................................................................................*/
 
    const ll mod=(ll)1e9+ 7;
 
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
 
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;} 
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
 
    //A.erase(unique(A.begin(),A.end()),A.end());
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll  man  =   (int)2e6+2 ,  inf   =   1e18;
 
 
/*......................................................................................................................*/

signed main()
{
    fast;
    int n,ans=0;
    cin>>n;
    vector<long double>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    map<pair<int,int>,int>cnt;
    for(int i=0;i<n;i++)
    {
        long double y=a[i];
        y*=1000000000;
        ll x=round(y);
        pair<int,int>p;
        while(x%2==0)
        {
            x/=2;
            p.first++;
        }
        while(x%5==0)
        {
            x/=5;
            p.second++;
        }
        cnt[p]++;
    }
    for(auto x:cnt)
    {
        for(auto y:cnt)
        {
            if((x.first.first+y.first.first>=18))
            {
                if(x.first.second+y.first.second>=18)
                {
                    if(x<y)
                    {
                        ans+=(x.second*y.second);
                    }
                    else if(x==y)
                    {
                        ans+=(x.second*(x.second-1))/2;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}   

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
#define dpair pair<double,double>

template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}
template <typename Val>
void show_vec(vector<Val> *v){
  cout<<endl;
  rep(i,v->size()){
    cout<<v->at(i)<<" ";
  }
  cout<<endl;
}

template <typename Val,typename Number>
void count_vector(vector<Val>* A,vector<pair<Number,Val>>*R){
  sort(A->begin(),A->end());
  int count = 1;
  rep(i,A->size()){
    if(i<A->size()-1){
      if(A->at(i)==A->at(i+1))count++;
      else{
        R->emplace_back(count,A->at(i));
        count = 1;
      }
    }else{
      R->emplace_back(count,A->at(i));
    }
  }
}


struct Point{
  int x;
  int y;
};

int stair(ll n,vector<ll>* F){
  if(n==0&&F->at(n)==-1){
    F->at(n)=1;
    return F->at(n);
  }else if(n==1&&F->at(n)==-1){
    F->at(n)=stair(0,F)+1;
    return F->at(n);
  }else{
    if(F->at(n)==-1){
      F->at(n)=stair(n-2,F)%1000000007+stair(n-1,F)%1000000007;
    }
    return F->at(n);
  }
}

//int stair_stop(ll n,vector<ll>* F,ll N){}

//---------------------------------------------------------------
int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> a(M);
  vector<ll>F(N,-1);
  llrep(i,M){
    cin>>a.at(i);
    F.at(a.at(i)-1)=0;
  }
  stair(N-1,&F);
  ll ans = F.at(N-1)%1000000007;
  //show_vec(&F);

  cout<<ans<<endl;

}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
struct union_find{
  size_t n;
  vector<int> par;
  size_t group;
  union_find(){}
  union_find(size_t _n):n(_n),group(_n){
    par.resize(n,-1);
  }
  void reset(size_t _n){
    n = _n;
    group = n;
    par.clear();
    par.resize(n,-1);
  }
  int root(int k){
    if(par[k]<0)return k;
    return par[k] = root(par[k]);
  }
  int size(int k){
    k = root(k);
    return -par[k];
  }
  auto operator[](int k){
    return size(k);
  }
  bool unite(int a,int b){
    a = root(a);
    b = root(b);
    if(a==b)return false;
    if(size(a)<size(b))swap(a,b);
    group--;
    par[a] += par[b];
    par[b] = a;
    return true;
  }
  auto operator()(int a,int b){
    return unite(a,b);
  }
  bool same(int a,int b){
    return root(a) == root(b);
  }
};
signed main(){

  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  cin>>s;

  union_find row(h*w);
  union_find col(h*w);

  auto v = [&](int i,int j){
    return i*w+j;
  };

  rep(i,h){
    rep(j,w-1)if(s[i][j]=='.'&&s[i][j+1]=='.'){
      row.unite(v(i,j),v(i,j+1));
    }
  }
  rep(j,w){
    rep(i,h-1)if(s[i][j]=='.'&&s[i+1][j]=='.'){
      col.unite(v(i,j),v(i+1,j));
    }
  }
  ll ans = 0;
  rep(i,h)rep(j,w){
    ll tmp = row.size(v(i,j))+col.size(v(i,j));
    chmax(ans,tmp-1);
  }
  cout<<(ans)<<endl;

}

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

using namespace std;
const int MOD = 1000000007;
typedef long long Int;

Int dp[51][51][5001];

int main()
{
  int n, k;
  
  scanf("%d %d", &n, &k);
  
  dp[0][0][2500] = 1;
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      for (int d = -2500; d <= 2500; d++) {
        int current_d = d + 2500;
        int minus_d = d - 2 * (i + 1) + 2500;
        int plus_d = d + 2 * (i + 1) + 2500;
        
        if (minus_d >= 0) {
          dp[i + 1][j + 1][minus_d] = (dp[i + 1][j + 1][minus_d] + dp[i][j][current_d]) % MOD;
        }
        
        dp[i + 1][j][current_d] = (dp[i + 1][j][current_d] + (2 * j + 1) * dp[i][j][current_d]) % MOD;
        
        if (j > 0 && plus_d <= 5000) {
          dp[i + 1][j - 1][plus_d] = (dp[i + 1][j - 1][plus_d] + j * j * dp[i][j][current_d]) % MOD;
        }
      }
    }
  }
  
  printf("%lld\n", dp[n][0][k + 2500]);
  
  return 0;
}

Measured memory_bytes: 99840
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    S=ST()
    ans = 0
    now = 0
    for s in S:
        if s=="I":
            now += 1
        else:
            now -=1
        ans = max(ans,now)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <vector>
#include <iostream>

using namespace std;

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

    vector<int> c(N, 0);
    for (int i = 0; i < M; i++) {
        int ai, bi;
        cin >> ai >> bi;
        c[--ai]++;
        c[--bi]++;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include<map>
#include<vector>
#include<algorithm>
#include <stdio.h>
#include<set>
#include<string>
#include<unordered_map>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#include<bitset>
#define ll long long 
using namespace std;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

int arr[100005][3];
int n;
ll dp[100005][3];
ll fun(int day, int pre) {
	if (day == n + 1)
		return 0;
	if (dp[day][pre] != -1)
		return dp[day][pre];
	if (pre == 1)
		return dp[day][pre]=max(arr[day][2] + fun(day + 1, 2), arr[day][3] + fun(day + 1, 3));
	if (pre == 2)
		return dp[day][pre] = max(arr[day][1] + fun(day + 1, 1), arr[day][3] + fun(day + 1, 3));
	if (pre == 3)
		return dp[day][pre] = max(arr[day][1] + fun(day + 1, 1), arr[day][2] + fun(day + 1, 2));
}
int main()
{
	  cin >> n;
	  for (int i = 1; i <= n; i++)
		  for (int j= 1;j<= 3; j++)
			  cin >> arr[i][j];
	  memset(dp, -1, sizeof dp);
	  cout<< max({ arr[1][1]+fun(2,1),arr[1][2]+fun(2,2),arr[1][3]+fun(2,3) });

	return 0;
}

Measured memory_bytes: 9984
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

#define REP(i,e,s) for(register int i=e; i<=s; i++)
#define DREP(i,e,s) for(register int i=e; i>=s; i--)
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)

int read() {
	int x=0,f=1,ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const int MAXN=100000+10;
char a[MAXN];
int l[MAXN],r[MAXN],ans[MAXN],s[2];
int main() {
	scanf("%s",a+1);
	int n=strlen(a+1);
	REP(i,1,n) {
		if(a[i]=='R'&&a[i+1]=='L') {
			memset(s,0,sizeof(s));
			for(int j=i; a[j]=='R'; j--) s[(i-j)%2]++;
			for(int j=i+1; a[j]=='L'; j++) s[(j-i)%2]++;
			ans[i]=s[0];
			ans[i+1]=s[1];
		}
	}
	REP(i,1,n) printf("%d ",ans[i]);
	return 0;
}

/*
5
1 2 2 2 1
*/


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[1000];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int b,m,e;
    cin>>b>>m>>e;
    int t[1000];
    for(int k=0;k<(e-b);k++){
      t[b+(k+e-m)%(e-b)]=a[b+k];
    }
    for(int k=b;k<e;k++){
      a[k]=t[k];
    }
  }
  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3108
from sys import stdin
import math

lun_list = []

data = stdin.readline().rstrip().split()
K = int(data[0])

for i in range(1, 10):
    lun_list.append(i)

n_f_idx, n_l_idx = 0, 8

while(1):
    f_idx, l_idx = n_f_idx, n_l_idx
    for idx in range(f_idx, l_idx+1):
        for j in range(10):
            if abs(int(str(lun_list[idx])[-1]) - j) > 1:
                continue
            else:
                num = int(str(lun_list[idx]) + str(j))
                lun_list.append(num)
                n_l_idx += 1
    
    n_f_idx = l_idx + 1

    if len(lun_list) > K:
        print(lun_list[K-1])
        break


Measured memory_bytes: 11032
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>

class MyDfs {
public:
  MyDfs(const size_t max_depth,
        const int a, const int b, const int c,
        const std::vector<unsigned int> l_array)
    : max_depth_(max_depth),
      a_(a), b_(b), c_(c),
      l_array_(l_array) {
    assert(l_array_.size() == max_depth);
  };

  int search(const size_t depth, const int a, const int b, const int c) const {
    if (depth == max_depth_) {
      const int mp = std::abs(a - a_) + std::abs(b - b_) + std::abs(c - c_) - 10 * 3;
      if (a == 0 || b == 0 || c == 0) {
        return 1e+9;
      } else {
        return mp;
      }
    }
    const int ret_0 = search(depth + 1, a, b, c);
    const int ret_1 = search(depth + 1, a + l_array_.at(depth), b, c) + 10;
    const int ret_2 = search(depth + 1, a, b + l_array_.at(depth), c) + 10;
    const int ret_3 = search(depth + 1, a, b, c + l_array_.at(depth)) + 10;
    return std::min({ret_0, ret_1, ret_2, ret_3});
  }

private:
  const size_t max_depth_;
  const int a_;
  const int b_;
  const int c_;
  const std::vector<unsigned int> l_array_;
};

int main() {
  unsigned int n, a, b, c;
  std::cin >> n >> a >> b >> c;

  std::vector<unsigned int> l_array(n);
  for (size_t i = 0; i < n; ++i) {
    std::cin >> l_array.at(i);
  }

  MyDfs dfs(n, a, b, c, l_array);
  std::cout << dfs.search(0, 0, 0, 0) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long i,j,n,m,mas[300005],x;
int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    cin >> n >> m;
    i=0;
    while (i<n)
    {
        cin >> mas[i];
        i++;
    }
    m--;
    x=0;
    while (x*m+1<n)
    {
        x++;
    }
    cout << x;
    return 0;
}


Measured memory_bytes: 1024
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
x=input()
m=int(x,2)
c=x.count("1")
l=[1]*(2*10**5+2)
for i in range(1,2*10**5+1):
    l[i]=l[i%str(bin(i)).count("1")]+1
deka=0
for i in range(n):
    if x[i]=="1":
        deka+=pow(2,n-i-1,c+1)
        deka%=c+1
tiisa=0
if c!=1:
    for i in range(n):
        if x[i]=="1":
            tiisa+=pow(2,n-i-1,c-1)
            tiisa%=c-1

for i in range(n):
    if x[i]=="0":
        nex=(deka+pow(2,n-i-1,c+1))%(c+1)
    else:
        if c-1==0:
            nex=-1
        else:
            nex=(tiisa-pow(2,n-i-1,c-1))%(c-1)
    if nex==0:
        print(1)
    elif nex==-1:
        print(0)
    else:
        print(l[nex])

Measured memory_bytes: 80556
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if (n%2==0||n%10==5||n%10==6){
		printf("-1\n");
		return 0;	
	}
	int sum=1;
	for (int i=1; i<=n; i++){
		if ((7*sum)%n==0){
			printf("%d\n",i);
			return 0;
		}
		sum=(sum*10+1)%n;
	}
	printf("-1\n");
	return 0;
}

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

int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a - b + 1) * (a - c + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static long S;
    static void input()
    {
        S = long.Parse(ReadLine());
    }
    static void solve()
    {
        input();
        long v = 1000000000;
        long Y = (v - S % v) % v;
        long X = (S + Y) / v;

        WriteLine($"0 0 {X} {Y} 1 1000000000");
    }
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
int n; cin>>n;
  map<string,int> mp;
  while (n--) {
    string s; cin>>s; mp[s]++;
  }
  int hi = 0;
  for (auto p: mp) hi = max(hi, p.second);
  vector<string> ans;
  for (auto p: mp) {
    if (p.second == hi) {
      ans.push_back(p.first);
    }
  }
  sort(ans.begin(), ans.end());
  for (auto x: ans) cout<<x<<"\n";
  
  

  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 25584
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define fst first
#define snd second
using namespace std;
typedef long long ll;

const int N=55;
int dp[N][N][N], usable[N];

int can(int a, int b, int k){
    int &r=dp[a][b][k];
    if(r!=-1)return r;
    if(k==1){return r=(usable[k]&&a%k==b)||a==b;}
    if(usable[k])r=can(a%k,b,k-1)||can(a,b,k-1);
    else r=can(a,b,k-1);
    return r;
}

int A[N],B[N],n;

int main(){
    cin >> n;
    fore(x,0,n)cin>>A[x];
    fore(x,0,n)cin>>B[x];
    ll ans=0;
    fore(i,1,51)usable[i]=1;
    
    int c=1;memset(dp,-1,sizeof(dp));
    fore(i,0,n)c&=can(A[i],B[i],50);
    if(!c){cout<<"-1\n";exit(0);}
    
    for(int x=50; x>=1; x--){
        usable[x]=0;
        memset(dp,-1,sizeof(dp));
        int c=1;
        fore(i,0,n)c&=can(A[i],B[i],50);
        if(!c){
            ans |= 1LL<<x;
            usable[x]=1;
        }
    }
    cout << ans << "\n";
}


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

int main() {
    double d;
    int S;
    while(cin >> d){
        S = 0;
        for(int i = 1;d*i < 600;i++){
            S = S + (d*i*d*i)*d ;
        }
        cout << S << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    if (A >= B) {
        ans += A;
        --A;
    } else {
        ans += B;
        --B;
    }
    if (A >= B) {
        ans += A;
    } else {
        ans += B;
    }
    print(ans);

    
}

int main()
{
    solve();

    return 0;
}


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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 200200;
const long long Q = 100000001;
const long long mod = 1e9 + 7;
const long long MAGIC = 30;

using namespace std;

long long a, b, c, k;

void solve()
{
        cin >> a >> b >> c >> k;
        if(k % 2){
                cout << b - a << "\n";
        }
        else{
                cout << a - b << "\n";
        }
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("maze.in");
        //fout("maze.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 256
class Factorial():
    def __init__(self, mod=10**9 + 7):
        self.mod = mod
        self._factorial = [1]
        self._size = 1
        self._factorial_inv = [1]
        self._size_inv = 1

    def __call__(self, n):
        return self.fact(n)

    def fact(self, n):
        ''' n! % mod '''
        if n >= self.mod:
            return 0
        self._make(n)
        return self._factorial[n]

    def fact_inv(self, n):
        ''' n!^-1 % mod '''
        if n >= self.mod:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        self._make(n)
        if self._size_inv < n+1:
            self._factorial_inv += [-1] * (n+1-self._size_inv)
            self._size_inv = n+1
        if self._factorial_inv[n] == -1:
            self._factorial_inv[n] = self.modinv(self._factorial[n])
        return self._factorial_inv[n]

    def comb(self, n, r):
        ''' nCr % mod '''
        if r > n:
            return 0
        t = self.fact_inv(n-r)*self.fact_inv(r) % self.mod
        return self(n)*t % self.mod

    def comb_with_repetition(self, n, r):
        ''' nHr % mod '''
        t = self.fact_inv(n-1)*self.fact_inv(r) % self.mod
        return self(n+r-1)*t % self.mod

    def perm(self, n, r):
        ''' nPr % mod '''
        if r > n:
            return 0
        return self(n)*self.fact_inv(n-r) % self.mod

    @staticmethod
    def xgcd(a, b):
        '''
        Return (gcd(a, b), x, y) such that a*x + b*y = gcd(a, b)
        '''
        x0, x1, y0, y1 = 0, 1, 1, 0
        while a != 0:
            (q, a), b = divmod(b, a), a
            y0, y1 = y1, y0 - q * y1
            x0, x1 = x1, x0 - q * x1
        return b, x0, y0

    def modinv(self, n):
        g, x, _ = self.xgcd(n, self.mod)
        if g != 1:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        return x % self.mod

    def _make(self, n):
        if n >= self.mod:
            n = self.mod
        if self._size < n+1:
            for i in range(self._size, n+1):
                self._factorial.append(self._factorial[i-1]*i % self.mod)
            self._size = n+1

    def _make_inv(self, n):
        if n >= self.mod:
            n = self.mod
        self._make(n)
        if self._size_inv < n+1:
            for i in range(self._size_inv, n+1):
                self._factorial_inv.append(self.modinv(self._factorial[i]))
            self._size_inv = n+1


x, y = sorted(map(int, input().split()))
q, r = divmod(x+y, 3)
if r != 0:
    print(0)
else:
    comb = Factorial().comb
    print(comb(q, y-q))


Measured memory_bytes: 38092
#define ll long long int
#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n, h, t1, t2; cin>>n>>h;
	std::vector<int> v(2*n);
	std::map<int, int> map;
	for(int i=0; i<n; i++)
	{
		cin>>t1>>t2;
		v[i] = t1; v[i+n] = t2;
		if(map[t2]==1)
			map[t2] = 1;
		else
			map[t2] = 2;
		map[t1] = 1;
	}
	sort(v.begin(), v.end());
	int k = 2*n-1, c = 0;
	while(h>0)
	{
		if(map[v[k]]==1)
		{
			t1 = int(ceil(h*1.0/v[k]));
			h = h - v[k]*(t1);
			c += t1;
		}
		if(map[v[k]]==2)
		{
			h = h - v[k];
			k--;
			c++;
		}
	}
	cout<<c<<endl;
	return 0;
}

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

/*
駅iからi+1にいく時
今までかかった時間val
val-s[i]%f[i] ==0
val = val+c[i] 
(val-s[i])%f[i] !=0
val = s[i] + ((val-s[i])/f[i] + 1)*f[i] + c[i];



*/


int main(void){
    long long x,y;
    scanf("%lld %lld",&x,&y);
    long long val = x,counter = 0;
    while(val<=y){
        val = val*2;
        counter++;
    }
    printf("%lld\n",counter);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using I4 = tuple<int,int,int,int>;
using VI4 = vector<I4>;

void vvi_print(vvi &VV, int H, int W){
	rpz(h,H){
		rpz(w,W){
			printf("%d ",VV[h][w]);
		}puts("");
	}puts("--");
}

#define MAX 500
int H,W;
vvi A(MAX, vi(MAX));

void solve(int H, int W, vvi &A){
	VI4 YX;//[i]:{y,x,y',x'}

	// vvi_print(A,H,W);//

	int y1,x1,x2,y2;

	rpz(h, H){
		rpz(w, W){
			if(A[h][w]==0) continue;
			if(A[h][w]%2==0) continue;
			y1 = y2 = h, x1 = x2 = w;
			if(w+1==W) y2++; else x2++;
			y2 = min(H-1, y2), x2 = min(W-1, x2);
			if(y1==y2 && x1==x2) continue;
			A[y1][x1]--, A[y2][x2]++;
			YX.emplace_back(y1,x1,y2,x2);
		}
	}
	// vvi_print(A,H,W);//

	cout<< YX.size() <<endl;
	for(auto t:YX){
		tie(y1,x1,y2,x2) = t;
		printf("%d %d %d %d\n",y1+1,x1+1,y2+1,x2+1);
	}
}

int main(){
	cin>>H>>W;
	rpz(i,H) rpz(j,W)cin>>A[i][j];
	solve(H,W,A);
}


Measured memory_bytes: 5232
#include <cstdio>
#include <algorithm>
long long n, a[100005], s, ans=1;
int main() {
	int i;
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", a+i);
	std::sort(a, a+n);
	for(i=0; i<n-1; i++) {
		s += a[i];
		s*2 >= a[i+1] ? ans++ : ans=1;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;

ll a[1000010];

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

    for (int i = 0; i < 1000000; i++) {
        a[i] = s;
        if (s%2 == 0) {
            s = s / 2;
        }
        else {
            s = s * 3 + 1;
        }
    }
    for (ll i = 0; i < 1000000; i++) { 
        for (ll j = i + 1; j < 1000000; j++) {
            if (a[i] == a[j]) {
                cout << j + 1 << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 11384
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int long long
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

struct debugger
{
    template <typename T>
    debugger &operator,(const T &v)
    {
        cerr << v << " ";
        return *this;
    }
} dbg;

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

int findGCD(int arr[], int n)
{
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

int32_t main()
{
    fast;
    int k;
    cin >> k;
    int res = 0;
    for (int i1 = 1; i1 <= k; i1++)
    {
        for (int i2 = 1; i2 <= k; i2++)
        {
            for (int i3 = 1; i3 <= k; i3++)
            {
                int arr[] = { i1, i2, i3 }; 
                int n = sizeof(arr) / sizeof(arr[0]); 
                res += findGCD(arr, n); 
            }
        }
    }
    cout << res;
}


Measured memory_bytes: 3584
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N,L[10];
  cin>>N;
  for (int i(0);i<N;i++){
    cin>>L[i];
  }
  int sum(0);
  for (int i(0);i<N;i++){
    sum+=L[i];
  }

  for (int i(0);i<N;i++){
    if (sum-L[i] <= L[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    TA = [list(map(int, input().split(' '))) for _ in range(N)]
    if N == 1:
        print(sum(TA[0]))
        return
    cur_t, cur_a = TA[0]
    for t, a in TA[1:]:
        ratio = max([(cur_t + t - 1) // t, (cur_a + a - 1) // a])
        cur_t, cur_a = ratio * t, ratio * a
    print(cur_t + cur_a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int h,w,n;
	cin>>h>>w>>n;
	int d=0,x=0,y=0;
	vector<vector<int>> res(h,vector<int>(w,0));
	for(int i=0;i<n;++i){
		int t;
		cin>>t;
		for(int j=0;j<t;++j){
			res[x][y]=i+1;
			if(x+dx[d]<0||x+dx[d]>=h||y+dy[d]<0||y+dy[d]>=w||res[x+dx[d]][y+dy[d]]!=0) d=(d+1)%4;
			x+=dx[d];
			y+=dy[d];
		}
	}
	for(int i=0;i<h;++i)
		for(int j=0;j<w;++j)
			cout<<res[i][j]<<" \n"[j==w-1];
}




Measured memory_bytes: 3684
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	string str;cin>>str;
	vector<ll> vec(2019 , 0);
	ll ans = 0;
	vec[str[0]-'0'] = 1;
	for(int i = 1;i<str.size();i++)
	{
		vector<ll> cur(2019 , 0);
		for(int j = 0;j<2019;j++)
		{
			int change = (j*10 + str[i]-'0')%2019;
			cur[change] += (vec[j]);	
		}	
		cur[str[i]-'0'] += 1;
		
		ans+=cur[0];
		vec = cur;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3720
// DP

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

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;
    }

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

// 無限大の値
  const long long INF = 1LL << 60;

// DP テーブル
  long long dp[100010];

// DP テーブル全体を初期化 (最小化問題なので INF に初期化)
  for (int i = 0; i < 100010; ++i) dp[i] = INF;

// 初期条件
  dp[0] = 0;

// ループ
  for (int i = 0; i < n-1; ++i) {
    for(int k = 0; k < K; k++) {
        if(i >= k)
        chmin( dp[i+1], dp[i-k] + abs(h[i-k]-h[i+1]) );
    }
  }

// 解を得て出力
  cout << dp[n-1] << endl;
  
}

Measured memory_bytes: 4356
#include<bits/stdc++.h>
#define  __  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

int main()
{
    __;

    int n,white=0,ans=0;

    string s;

	cin >> n >> s;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '.') white++;
	}

	 ans = white;

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

		if (s[i] == '#') white++;

		else white--;

		if (ans > white) ans = white;
	}

	cout<<ans;

    return 0;
}


Measured memory_bytes: 720
#include<iostream>

using namespace std;
using ll = long long int;

int main(void) {
    ll a, b, k;
    cin >> a >> b >> k;
    if (a - k > 0) cout << a - k << " " << b << endl;
    else {
        if (b + a - k > 0) cout << 0 << " " << b + a - k << endl;
        else cout << 0 << " " << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
// Big two primes
#define X 1001100011100001111ll
#define mod 1000000007
#define ll long long
#define all(a) a.begin(),a.end()
#define sortall(a) sort(all(a))
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define nloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define arrip(n)  int a[n]; fo(i, n) cin >> a[i];
#define arrop(n)  fo(i,n) cout<<a[i]<<" ";
#define pb push_back
#define mp make_pair
#define itr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626

#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int>
#define fi first
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vpi vector<pi>
#define sz(s) s.size()
#define bits(n) __builtin_popcount(n)//Count set bits

const int MAXN = (int)((1e5) + 100);
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int max(int a, int b) {if (a > b) return a; else return b;}
int min(int a, int b) {if (a < b) return a; else return b;}



int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("atcoderi.txt", "r", stdin);
	freopen("atcodero.txt", "w", stdout);
#endif
	fio;

	int n, a, b;
	cin >> n >> a >> b;

	int x = (n / (a + b));
	//cout << x << endl;
	int c = x * a;
	n = n % (a + b);
	//cout << y << endl;

	c = c + min(n, a);
	cout << c << endl;
}

Measured memory_bytes: 3648
ch_dic = {}
n = int(input())
word_list = []
for i in range(n):
    word_list.append(input())
for ch in word_list[0]:
    if ch not in ch_dic:
        ch_dic[ch] = 1
    else:
        ch_dic[ch] += 1

for i in range(1,n):
    ch_list = word_list[i]
    chs = {}
    for ch in ch_list:
        if ch not in chs:
            chs[ch] = 1
        else:
            chs[ch] += 1
    
    for key in ch_dic.copy().keys():
        if key in chs:
            ch_dic[key] = min(chs[key],ch_dic[key])
        else:
            del ch_dic[key]
out = ""
for key,value in ch_dic.items():
    out += key*value
print("".join(sorted(out)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define pll pair<ll,ll>
#define pii pair<int,int>
#define F first
#define S second
const int maxn = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    vector<char>v1;
    vector<char>v2;
    int f = 0;
    string s;
    cin >> s;
    int t;
    cin >> t;
    while(t--) {
        int tp;
        cin >> tp;
        if (tp == 1) {
            f ^= 1;
            continue;
        }
        int ff;
        char c;
        cin >> ff >> c;
        ff--;
        if(ff^f){
            v2.push_back(c);
        }
        else {
            v1.push_back(c);
        }
    }
    if (f) {
        swap(v1,v2);
        reverse(s.begin(), s.end());
    }
    while(v1.size()) {
        cout << v1.back();
        v1.pop_back();
    }
    cout << s ;
    for (auto i:v2) {
        cout << i;
    }
    cout << '\n';
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll n,ans;
    cin>>n;
    ans=n*(n+1)/2-n;
    cout<<ans;
}

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

using namespace std;

int main(){
  int x, b=1;
  cin >> x;
  for (int p=2; p<10; p++){
    float q = float(1.0/p);
    int a = int (pow(x,q));
    if(int(pow(a,p))>b){
      b = int(pow(a,p));
    }
  }
  cout << b << endl;
}


Measured memory_bytes: 512
#ABC51 B
k, s = (int(_) for _ in input().split())
done = []
if s == 3*k:
    print(1)
else:
    ans = 0
    for i in range(k+1):
        for j in range(k+1):
            remainder = s - i - j
            if 0 <= remainder <= k:
                ans += 1
    print(ans)
                
        
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
#define size_t ll
const int mod = 1000000007;
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
int n,ans=0,t=INT_MIN;
std::vector<pair<ll,ll>> x;
int main(){
  cin >> n;
  x.resize(n);
  for (size_t i = 0; i < n; i++) {
    ll temp1,temp2;
    cin >> temp1 >> temp2;
    x[i] = make_pair(temp1+temp2,temp1-temp2);
  }
  sort(all(x));
  for (size_t i = 0; i < n; i++) {
    if(t <= x[i].second){
      ans++;
      t = x[i].first;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  if (a <= 0 && 0 <= b) puts("Zero");
  else if (b < 0 && ((b - a + 1) & 1)) puts("Negative");
  else puts("Positive");
  
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
static const int INF = 1e8;
int main(){
    int h, n; sc(h), sc(n);
    vector<int> a(n), b(n), dp(1e5, INF);
    dp[0] = 0;
    rep(i, 0, n) sc(a[i]), sc(b[i]);
    rep(i, 0, 1e5){
        rep(j, 0, n){
            if (i+a[j]>1e5) continue;
            dp[i+a[j]] = min(dp[i+a[j]], dp[i]+b[j]);
        }
    }
    rep(i, 1, 1e5-1){
        dp[1e5-1-i] = min(dp[1e5-1-i], dp[1e5-i]);
    }
    cout << dp[h] << endl;
    return 0;
}

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

int main(){
int A,B,C,D;
cin>>A>>B>>C>>D;
if(A+B>C+D){
  cout<<"Left"<<endl;
}else if(A+B==C+D){
  cout<<"Balanced"<<endl;
}else{cout<<"Right"<<endl;
     }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<cstring>

using namespace std;

typedef pair<int,int> P;

const int MAX=100000;

int n;
vector<int> G[MAX];
int order[MAX]={};
bool inS[MAX]={};
stack<int> roots;
int k;
vector<P> brg;

void visit(int v,int p)
{
	order[v]=++k;
	inS[v]=true;
	roots.push(v);
	for(int i=0;i<G[v].size();i++)
	{
		int to=G[v][i];
		if(order[to]==0)
		{
			visit(to,v);
		}
		else if(to!=p&&inS[to])
		{
			while(order[roots.top()]>order[to])roots.pop();
		}
	}
	if(v==roots.top())
	{
		if(p!=-1)brg.push_back(P(min(p,v),max(p,v)));
		roots.pop();
	}
	return;
}

void bridge()
{
	k=0;
	for(int i=0;i<n;i++)
	{
		if(order[i]==0)
		{
			visit(i,-1);
		}
	}
	return;
}

int main()
{
	cin>>n;
	int e;
	cin>>e;
	int u,v;
	for(int i=0;i<e;i++)
	{
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bridge();
	sort(brg.begin(),brg.end());
	for(int i=0;i<brg.size();i++)
	{
		cout<<brg[i].first<<" "<<brg[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 6752
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>

#include <map>
 
using namespace std;
typedef long long ll; 


ll ans,mx,sum,mn=1e18,flag;

int main(){
	ll l,r;
	cin>>l>>r;
	for(ll i=l; i <= r; i++){
		for(ll j = i+1; j <= r; j++){
			ll flag= (i*j)%2019;
			mn = min(mn,flag);
			if(mn==0){
				cout<<mn<<endl;
				return 0;
			}
		}	
	}
	cout<<mn<<endl;
	
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,M,K;






int main()
{

	cin >> N >> M >>K;
	int ans = 0;

	REP(i,N){
		ans = i*M;
		if(ans == K){
			cout << "Yes";
			return 0;
		}
		REP(j,M){
			ans += N-2*i;
			if(ans == K){
				cout << "Yes";
				return 0;
			}
		}
	}
	REP(i,M){
		ans = i*N;
		if(ans == K){
			cout << "Yes";
			return 0;
		}
		REP(j,N){
			ans += M-2*i;
			if(ans == K){
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;

}



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

int main()
{
    // int N,M;
    // cin >> N>>M;
    // int Mat[N][M];
    int m, f, r;
    cin >> m >> f >> r;
    int mf = 0;
    while((m!=-1) || (f!=-1) || (r!=-1)){
        mf = m + f;
        if (m == -1 or f == -1){
            cout << "F" << endl;
        }else if ( mf>= 80)
        {
            cout << "A" << endl;
        }else if ( mf>= 65)
        {
            cout << "B" << endl;
        }else if ( mf>= 50)
        {
            cout << "C" << endl;
        }else if ( mf>= 30 and r >= 50)
        {
            cout << "C" << endl;
        }else if ( mf>= 30)
        {
            cout << "D" << endl;
        }else
        {
            cout << "F" << endl;
        }
        
        
        cin >> m >> f >> r;
    }
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

ll N , M;
priority_queue<ll> que;

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

    cin >> N >> M ;
    
    rep(i, N){
        ll inp; cin >> inp;
        que.push(inp);
    }
    
    rep(i, M){
        ll nxt = que.top();
        que.pop();
        nxt /= 2;
        que.push(nxt);
    }
    
    ll ans = 0;
    rep(i, N){
        ans += que.top();
        que.pop();
    }
    
    cout << ans << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
n,a,b=map(int,input().split())
mod=10**9+7
def C(n,r,mod):
    r=min(r,n-r)
    bunsi=bunbo=1
    for i in range(1,r+1):
        bunsi*= (n+1-i)%mod ;bunsi%=mod
        bunbo*= i %mod  ;bunbo%=mod
    return bunsi * pow(bunbo,mod-2,mod) %mod
print((pow(2,n,mod)-1-C(n,a,mod)-C(n,b,mod)) %mod)

Measured memory_bytes: 3188
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program {
    internal static void Main(string[] args) {
        int[] inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        if (inp[1] == 100) {
            switch (inp[0]) {
                case 0:
                    WriteLine(101);
                    return;

                case 1:
                    WriteLine(10100);
                    return;

                case 2:
                    WriteLine(1010000);
                    return;               
            }
        }

        WriteLine((Math.Pow(100, inp[0]) * inp[1]));

    }
}

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

#define f_io ios::sync_with_stdio(false);cin.tie(0)
#define ll long long
#define FOR(a,b,c) for(ll a=b;a<c;a++)
#define cases long t;cin>>t;while(t--)


int main(){

        ll n,ans=0;
        string s;
        cin>>n;
        cin>>s;
        FOR(i,0,n-2){
            if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
        }
        cout<<ans<<endl;

    return 0;
}


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

vector<ll> sum;
ll i;
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}
ll query(ll i,ll j,vector<ll> &s){//区間[i,j]の和
    return s[j]-s[i];
}


int main(){
    ll n,k;cin>>n>>k;
    string s;cin>>s;
    vector<ll> a;

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

    vector<ll> Nums;
    int now=1;//今見ている数
    int cnt=0;//nowがいくつ並んでいるか
    for(i=0;i<n;i++){
        if(s[i]==(char)('0'+now)){cnt++;}
        else{
            Nums.push_back(cnt);//最初に1がなければ0が追加される
            now=1-now;//0 1の交換
            cnt=1;//新しいのをカウント
        }
    }
    if(cnt!=0){Nums.push_back(cnt);}

    //0で終わっていたらたす
    if(Nums.size()%2==0){Nums.push_back(0);}
    //1で始まり1で終わる

    pre_process(Nums,sum);

    ll add=2*k+1;
    ll ans=-1;
    for(i=1;i<=sum.size()-add;i+=2){
        if(i+add-1>sum.size()){cout<<n<<endl;return 0;}
        ans=max(ans,query(i-1,i+add-1,sum));
    }

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

Measured memory_bytes: 2164