akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;
  cin >> n >> k;
  ll sum=0;
  ll a[n];  
  rep(i,n){
    cin >> a[i];
    sum+=a[i];      
  }
  vector<ll> yaku;
  yaku=divisor(sum);
  for(int j=yaku.size()-1; j>=0;j--){
    ll mod_a[n];
    rep(i,n){
      mod_a[i]=a[i]%yaku[j];
    }
    sort(mod_a,mod_a+n);
    ll si=0;
    ll ei=n-1;
    ll tot=0;
    ll kaisu=0;
    rep(i,n){
      //      cout << tot << endl;
      if(tot<=0){
	tot+=mod_a[si];
	//	si++;
	kaisu+=mod_a[si];
	si++;
      }else{
	tot-=(yaku[j]-mod_a[ei]);
	//	ei--;
	kaisu+=(yaku[j]-mod_a[ei]);
	ei--;
      }
      //      cout << kaisu << endl;
    }
    //    cout << yaku[j] << "  " << kaisu << " " <<tot << endl;
    if(tot==0 && kaisu/2<=k){
      cout << yaku[j] << endl;
      return 0;
    }
    
  }

  return 0;
    

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon Aug  1 00:19:18 2016

@author: dotha
"""


N,M = map(int, input().split(' '))
table1 = [1 for i in range(N)]
table2 = [False for i in range(N)]
table2[0] = True
for i in range(M):
    x,y = map(int, input().split(' '))
    x-=1
    y-=1
    if table2[x]:
        table2[y]=True
        if table1[x]==1:
            table2[x] = False
    table1[x]-=1
    table1[y]+=1

print(table2.count(True))

Measured memory_bytes: 4784
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int K,S;
  cin>>K>>S;
  int ans=0;
  REP(x,K+1)REP(y,K+1){
    int z=S-x-y;
    if(z<=K and z>=0){
      ans++;
      // cout<<x<<y<<z<<endl;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int n;
  int count=0;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
    if(v[i]-c[i]>0){
      count += v[i]-c[i];
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X = int(readline())

    if X in (7, 5, 3):
        print('YES')
    else:
        print('NO')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9080
M,K=map(int,input().split())
if M==0:
    if K==0:
        print("0 0")
    else:
        print(-1)
elif M==1:
    if K==0:
        print("0 0 1 1")
    else:
        print(-1)
else:
    if K==0:
        ans=[str(i//2) for i in range(2**(M+1))]
        print(" ".join(ans))
    elif 1<=K<2**M:
        L=[0 for i in range(2**M)]
        X=[]
        for i in range(2**M):
            if L[i]==0:
                X.append((i,i^K))
                L[i]=1
                L[i^K]=1
        st=[]
        for i in range(2**(M-2)):
            a,b=X[2*i]
            c,d=X[2*i+1]
            tmp=[a,c,d,a,b,d,c,b]
            st.append(" ".join([str(i) for i in tmp]))
        print(" ".join(st))
    else:
        print(-1)

Measured memory_bytes: 68828
def main():
    buf = input()
    N = int(buf)
    SP = []
    for i in range(N):
        buf = input()
        buflist = buf.split()
        SP.append((buflist[0], -int(buflist[1]), i+1))
    SP = list(sorted(SP))
    for x in SP:
        print(x[2])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int[][] score = new int[n][3];
			for(int i = 0;i < n;i++){
				for(int j = 0;j < 3;j++){
					score[i][j] = scan.nextInt();
				}
			}
			boolean fl = false;
			for(int i = 0;i < 3;i++){
				for(int j = 0;j < n-1;j++){
					fl = false;
					for(int k = j+1;k < n;k++){
						if(score[j][i] == score[k][i]){
							fl = true;
							score[k][i] = 0;
						}
					}
					if(fl){
						score[j][i] = 0;
					}
				}
			}
			for(int i = 0;i < n;i++){
				System.out.println(score[i][0] + score[i][1] + score[i][2]);
			}
		}
	}
}

Measured memory_bytes: 20980
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

// https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396
struct UnionFind {
	vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
		for (ll i = 0; i < N; i++) par[i] = i;
	}

	ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(ll x, ll y) { // xとyの木を併合
		ll rx = root(x); //xの根をrx
		ll ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
		ll rx = root(x);
		ll ry = root(y);
		return rx == ry;
	}
};

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

	ll N, M;
	cin >> N >> M;

	vector<ll> X(M), Y(M), Z(M);

	for (ll i = 0; i < M; ++i)
	{
		cin >> X[i];
		cin >> Y[i];
		cin >> Z[i];
	}

	UnionFind tree(N);
	for (ll i = 0; i < M; ++i)
	{
		tree.unite(X[i]-1, Y[i]-1);
	}

	ll ans = 0;

	vector<bool> checked(N, false);

	set<ll> roots;

	for (ll i = 0; i < N; ++i)
	{
		roots.insert(tree.root(i));
	}

	cout << roots.size() << endl;

	//system("pause");
}

Measured memory_bytes: 8064
import java.util.Scanner

object Main {
  def calc(x: Int): Int = if (x == 1) (1) else (calc(x / 2) * 2)

  def solve(sc: => Scanner): Unit = {
    val A = Array.fill[Int](4)(sc.nextInt).sorted
    if (A(0) == A(1) && A(2) == A(3)) (println("yes")) else (println("no"))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 45188
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    int Anum = -1;
    int Znum = -1;
    rep(i,s.size()){
        if(s[i]=='A'){
            Anum = i;
            break;
        }
    }
    per(i,s.size()){
        if(s[i]=='Z'){
            Znum = i;
            break;
        }
    }
    
    cout << Znum - Anum + 1 << endl;
    
    
}



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



Measured memory_bytes: 720
## coding: UTF-8


R,C,K = map(int,input().split())
rcv = []
for i in range(K):
    rcv.append(list(map(int,input().split())))

item = [0] * (R*C+1)
for i in range(K):
    index = (rcv[i][0] - 1) * C + (rcv[i][1] - 1) 
    #available[index] = True
    item[index] = rcv[i][2]

#print(item)



def solver(R,C,K):
    empty = []
    prev = []
    for i in range(C):
        empty.append([0] * 4)
        prev.append([0] * 4)
    
    for i in range(R):
        #print('prev', prev)
        now = []
        #ret = []
        zero = max(prev[0])
        now.append([zero, zero+item[i*C], 0, 0]) #一番左
        for j in range(1, C):
            index = i * C + j
            point = item[index]
            #print(i,j,index)
            ret = []
            left = now[-1]
            zero = max(left[0], max(prev[j])) #左からor上から
            ret.append(zero) #0
            one = max(zero + point, left[1]) #左からor上からきてアイテム取得 or 左から一個持った状態で拾わない
            two = max(left[1] + point, left[2])
            three = max(left[2] + point, left[3])
            ret.append(one)
            ret.append(two)
            ret.append(three)
            now.append(ret)
        prev = now
        #print(now)
    
    print(max(now[-1]))


solver(R,C,K)



Measured memory_bytes: 262216
#include <iostream>
#include <algorithm> 
#include <cmath>
//#include <bitset>
//#include <deque>
#include <iterator>
#include <map> 
//#include <queue>
//#include <stack>
#include <string>
#include <vector>
#include <array>
//#include <tuple>
//#include <unordered_map>
//#include <unordered_set>

using namespace std;

typedef long long ll;
struct __{__(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}__; 



int main() {
	int n;
	cin >> n;
	vector<ll> v(n);
	ll sum = 0;
	//vector<int> p;
	ll minn = 1e9 + 7;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		if (v[i] % 10 != 0) 
			minn = min(minn,v[i]);
		sum += v[i];
	}
	if (minn == 1e9 + 7) {
		cout << 0;
	}else {
		if (sum % 10 != 0) {
			cout << sum;
		}else {
			cout << sum - minn;
		}
	}
}




Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			string s = cin.Next();
			if (n % 2 != 0) {
				Console.WriteLine("No");
				return;
			}

			int m = n / 2;
			for (int i = 0; i < m; i++) {
				if (s[i] != s[i + m]){
					Console.WriteLine("No");
					return;
				}
			}

			Console.WriteLine("Yes");
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<int,int>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 














//int ct[100005][2];
const int N=100005;
int n;
int h[N];
int main()
{
     cin>>n;
     for(int i=1;i<=n;i++)cin>>h[i];
     int dp[n+1];
     dp[0]=0;
     dp[1]=0;
     dp[2]=abs(h[2]-h[1]);
     for(int i=3;i<=n;i++)
     {
          dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
     }
     cout<<dp[n];
}
























 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define typeof decltype
#define LL long long
#define pii pair<int,int> 
#define vi vector<int> 
#define vii vector<pii>
#define srt(a) sort(a.begin(),a.end());
#define se second
#define fi first
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

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

int  main()
{
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        cout.precision(10);
        cout << fixed;
#ifdef LOCAL_DEFINE
        freopen("input.txt", "rt", stdin);
#endif
LL n; cin>>n;
LL s=0;
vector <LL> v;
v.pb(0);
forn(i,n){ LL k; cin>>k; s+=k; v.pb(s);}
LL c=1;
LL an=0;
srt(v);
LL b=v[0];
for1(i,n){ if(v[i]==b)c++; else { an+=(c*(c-1))/2; b=v[i]; c=1;}}
an+=(c*(c-1))/2;
cout<<an<<endl; 

#ifdef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

        return 0;
}


Measured memory_bytes: 2420
n,wmax=map(int,input().split(" "))
v=[]
w=[]
ans=[0]*(wmax+1)
for i in range(n):
    vv,ww=map(int,input().split(" "))
    v.append(vv)
    w.append(ww)
for i in range(n):
    for j in range(w[i],wmax+1):
        ans[j]=max([ans[j],ans[j-w[i]]+v[i]])
print(ans[-1])


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

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

    if (a < b)  swap(a, b);
    if (b < c)  swap(c, b);
    if (a < b)  swap(a, b);

    cout << a*10+ b + c << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;

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

    sort(length.begin(), length.end());

    long long res = 0;
    decltype(length)::iterator it;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int high = length[i] + length[j];

            it =  lower_bound(length.begin(), length.end(), high);

            if (distance(length.begin(), it) > j) {
                res += distance(length.begin(), it) - j - 1;
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b){
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

int isChokkaku(int a, int b, int c){
	int max = 0;
	int ot1,ot2;
	max=a; ot1=b; ot2=c;
	
	if(ot1>max) swap(&max, &ot1);
	if(ot2>max) swap(&max, &ot2);

	if(max*max==ot1*ot1+ot2*ot2) return 1;
	else return 0;
}

int main(void){
	int num;
	int i;
	int a,b,c;

	scanf("%d", &num);

	for(i = 0 ; i < num ; i++){
		scanf("%d %d %d", &a, &b, &c);
		if(isChokkaku(a,b,c)) printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int n, a[3];
string s[MAX];
char c[MAX];

bool dfs(int cur){
    if(cur == n){
        puts("Yes");
        rep(i, n) printf("%c\n", c[i]);
        return true;
    }
    rep(i, 2)if(a[s[cur][i^1]-'A'] > 0){
        ++a[s[cur][i]-'A'];
        --a[s[cur][i^1]-'A'];
        c[cur] = s[cur][i];
        if(dfs(cur+1)) return true;
        --a[s[cur][i]-'A'];
        ++a[s[cur][i^1]-'A'];
    }
    return false;
}

int main(){
    scanf("%d", &n);
    rep(i, 3) scanf("%d", &a[i]);
    rep(i, n) cin >> s[i];
    if(dfs(0)) return 0;
    puts("No");
}

Measured memory_bytes: 13260
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int a, b;
    cin >> a >> b;
    for (int i = 1; i < 100000; ++i) {
        if (i * 8 / 100 == a && i / 10 == b) return cout << i, 0;
    }
    cout << -1;
}

Measured memory_bytes: 256
#include <iostream>
using i64 = long long;

int main() {
    constexpr i64 mod = 1000000007;
    int n;
    std::cin >> n;
    i64 a = 1, b = 1, t = 1;
    for (int i = 0; i < n; i++) {
        t = t * 10 % mod;
        a = a * 9 % mod;
        b = b * 8 % mod;
    }

    std::cout << (t + 2 * mod - 2 * a + b) % mod << std::endl;

    return 0;
}


Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define chmin(a,b) a=min(a,b)
const int N=55;

int n,m;
int a[N],b[N];
int dist[N][N];
int task[N];
vector<int> e[N];
LL dp[1<<20];

int main()
{
	
	cin>>n;
	memset(dist,60,sizeof(dist));
	for(int i=1;i<n;i++)
	{
		int u,v;
		cin>>u>>v;
		e[u].pb(v); e[v].pb(u);
		dist[u][v]=dist[v][u]=1;
		a[i]=u; b[i]=v;
	}
	for(int i=1;i<=n;i++)
		dist[i][i]=0;
	for(int k=1;k<=n;k++)
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
		chmin(dist[i][j],dist[i][k]+dist[k][j]);
	cin>>m;
	for(int i=0;i<m;i++)
	{
		int u,v; cin>>u>>v;
		for(int j=1;j<n;j++)
			if(dist[u][a[j]]+dist[b[j]][v]==dist[u][v]-1 ||\
			dist[v][a[j]]+dist[b[j]][u]==dist[u][v]-1) task[j]|=1<<i;
	}
	dp[0]=1;
	for(int i=1;i<n;i++)
	for(int mask=(1<<m)-1;mask>=0;mask--)
		dp[mask|task[i]]+=dp[mask];
	cout<<dp[(1<<m)-1]<<'\n';
	
	return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k; cin >> n >> k;
	vector<int> v(n);
	for(int &i : v)cin >> i;
	for(int i = k; i < n; ++i)cout << (v[i] > v[i-k] ? "Yes\n" : "No\n");		
}


Measured memory_bytes: 3976
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.flush();
	int a,b,c,d;
    cin >> a >> b >> c >> d;
  	if(max(a,c) - min(a,c) <=d)
      cout<<"Yes";
  	else if(abs(a-b)<=d && abs(b-c)<=d)
      cout<<"Yes";
    else 
      cout<<"No";
	return 0;
	// BYE BYE 
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    
    int cnt = 0;
    while (x > 0) {
        x >>= 1;
        ++cnt;
    }
    cout << (1LL << cnt) - 1 << "\n";
    return 0;
}

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

a = 1
b = 1
buff = 1

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

_list = divisor(N)
_list = sorted(_list)
med = len(_list)

if med % 2 == 0:
    ans = str(_list[int(med/2)])
else:
    ans = str(_list[med//2])

print(len(ans))

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;

public class Main {
	public static void main(String[] args) throws IOException {
		final LinkedList<Process> processes = getProcesses();
		final String result = runProcessing(processes);
		
		System.out.print(result);
	}
	
	private static int quantum;
	public static String runProcessing(final LinkedList<Process> processes) {
		final StringBuilder result = new StringBuilder();
		final String lb = System.getProperty("line.separator");
		
		Process process;
		int elapsed = 0;
		while ((process = processes.poll()) != null) {
			if (quantum < process.processingTime) {
				elapsed += quantum;
				process.processingTime -= quantum;
				processes.add(process);
				
			} else {
				elapsed += process.processingTime;
				result.append(process.name).append(" ").append(elapsed).append(lb);
			}
		}
		
		return result.toString();
	}
	
	public static LinkedList<Process> getProcesses() throws IOException {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final String[] requirement = reader.readLine().split(" ");

		final int numberOfPprocess = Integer.parseInt(requirement[0]);
		quantum = Integer.parseInt(requirement[1]);
		
		final LinkedList<Process> processes = new LinkedList<Process>();
		for (int i = 0; i < numberOfPprocess; i++) {
			final String[] line = reader.readLine().split(" ");
			processes.add(new Process(line[0], Integer.parseInt(line[1])));
		}

		return processes;
	}
}

class Process {
	String name;
	int processingTime;

	public Process(String name, int processingTime) {
		this.name = name;
		this.processingTime = processingTime;
	}
}

Measured memory_bytes: 62932
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();

		int ans = 0;
		for (int i = 0; i < a+1; i++) {
			for (int j = 0; j < b+1; j++) {
				for (int k = 0; k < c+1; k++) {

					if (500 * i + 100 * j + 50 * k == x) {
						ans++;
					}

				}
			}
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <tr1/unordered_set>
using namespace std;
int a[50000],b[50000],o[50000];
int main(){
	int H,W,q;
	while(cin >> H >> W >> q && H){
		int ans = 0;
		for(int i = 0 ; i < q ; i++)
			cin >> a[i] >> b[i] >> o[i];
		tr1::unordered_set<int> g[2];
		for(int i = q-1 ; i >= 0 ; i--){
			if(a[i]==0){
				if(!g[0].count(b[i]) && o[i]) ans += W - g[1].size();
				g[0].insert(b[i]);
			}else{
				if(!g[1].count(b[i]) && o[i]) ans += H - g[0].size();
				g[1].insert(b[i]);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static Scanner sc;
    private static int[][] neg8 = new int[][]{{-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            long N, K;
            N = sc.nextInt();
            K = sc.nextInt();

            long ans = (long) (K * Math.pow(K-1, N-1));

            System.out.println(ans);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}



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

int main()
{
   ll n ,k;
   cin>>n>>k;
   for(int i=0;i<n;i++)
   {
       ll temp ;
       cin>>temp;
   }
   ll ans =1;
   n = n-k;
   cout<< ans + ceil( double(n) /(k-1)  ) ;

}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}


//#########################################




int main() {

   int n=D();
   char a[n];
   for(int i=0;i<n;i++){
       cin>>a[i];
       if(a[i]=='Y'){
           cout<<"Four";
           return 0;

       }


   }
  cout<<"Three";

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

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

  int sum = 0;
  rep(i, n+1) sum += abs(a[i]-a[i+1]);

  for(int i = 1; i <= n; ++i) {
    int ans = sum - abs(a[i-1]-a[i]) - abs(a[i]-a[i+1]) + abs(a[i-1]-a[i+1]);
    cout << ans << '\n';
  }

  return 0;
}


Measured memory_bytes: 1664
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

#pragma gcc target ("avx2")
#pragma gcc optimization ("o3")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	ll ans = 0;
	rep1(i, n) {
		rep1(j, n) {
			rep1(k, n) {
				ans += gcd(i, gcd(j, k));
			}
		}
	}
	printf("%lld\n", ans);

	Please AC;
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  string s;cin>>s;
  vector<ll>res;
  reverse(all(s));
  ll id=1;
  ll pid=0,nid=0;
  while(id!=n+1){
    pid=nid;
    nid=pid;
    while(min(pid+m,n)>=id){
      if(s[id]=='0')nid=id;
      id++;
    }
    if(nid==pid){
      cout<<-1<<endl;
      return 0;
    }
    res.push_back(nid-pid);
    if(nid==n)break;
  }
  reverse(all(res));
  for(auto i:res){
    cout<<i<<" ";
  }
  cout<<endl;

  return 0;

}


Measured memory_bytes: 1480
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    char s[102];
    while(scanf("%s",&s)!=EOF)
    {
        int l=strlen(s),cnt=0;
        for(int i=0,j=l-1;i<l,j>=0;i++,j--)
        {
            if(s[i]!=s[j])
             {
                 s[j]=s[i];
                 cnt++;
             }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll n, m;
  cin >> n >> m;
  map<ll, ll> ma;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    ma[a] += b;
  }
  ll c = 0;
  ll ans = 0;
  for(auto itr = ma.begin(); itr != ma.end(); itr++) {
    if (c + itr->second <= m) {
      // 全部買う
      ans += itr->first * itr->second;
      c += itr->second;
      if (c == m) {
          cout << ans;
          return 0;
      }
    } else {
      // 必要な分だけ買う
      ans += itr->first * (m - c);
      cout << ans;
      return 0;
    }
  }
}


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

using std::cin;

int from_num;
std::vector<int> from;

bool canMake(int id, int target);

int main()
{
    cin >> from_num;
    from.reserve(from_num);

    for (auto i = 0; i < from_num; i++) {
        int in;
        cin >> in;
        from.push_back(in);
    }

    int target_num;
    cin >> target_num;

    int target;
    while (target_num--) {
        cin >> target;
        std::cout << (canMake(0, target)? "yes": "no") << std::endl;
    }

    return 0;
}

bool canMake(int id, int target)
{
    if (id == from_num) {
        return (target == 0);
    }

    if (canMake(id + 1, target)) {
        return true;
    }
    if (canMake(id + 1, target - from.at(id))) {
        return true;
    }

    return false;
}

Measured memory_bytes: 1188
n,m,x=map(int, input().split())
C = []
A=[]
for i in range(n):
    tmp=list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])

cost=10**10
for i in range(2**n):
    rikai=[0]*m
    tmp=0
    for j in range(n):
        if (i>>j)%2==1:
            tmp+=C[j]
            rikai=[rikai[k]+A[j][k] for k in range(m)]
    if all([k>=x for k in rikai]):
        cost=min(cost, tmp)
        
if cost!=10**10:
    print(cost)
else:
    print(-1)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
int r,c,k;
LL table[3001][3001];
LL dp[3001][3001][4];

int main(){
  cin>>r>>c>>k;
  REP(i,4){
    REP(j,3001){
      REP(k,3001)dp[j][k][i] = 0;
    }
  }
  REP(i,k){
    int r,c;
    LL v;
    cin>>r>>c>>v;
    table[r][c] = v;
  }

 
  FOR(i,1,r+1){
    FOR(j,1,c+1){
      REP(k,4){
        if(k==0){
          dp[i][j][k] = max(dp[i-1][j][3],dp[i][j-1][k]);
          dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][2] + table[i-1][j]);
        }
        else{
          dp[i][j][k] = dp[i][j-1][k];
          dp[i][j][k] = max(dp[i][j][k],dp[i][j][k-1]);
          dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][k-1] + table[i-1][j]);
          dp[i][j][k] = max(dp[i][j][k],dp[i][j-1][k-1]+table[i][j-1]);
        }
      }
    }
  }

  /*REP(i,4){
    REP(j,r){
      REP(k,c){
        cerr<<dp[j+1][k+1][i]<<" ";
      }
      cerr<<endl;
    }
  }*/

  cout<<max(dp[r][c][3],dp[r][c][2] + table[r][c])<<endl;
  return 0;
}


Measured memory_bytes: 355208
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Solve()
    {
        var input = ReadInts();
        var N = input[0]; // switch
        var M = input[1]; // light
        var ks = new int[M][];

        for (var i = 0; i < M; i++)
        {
            ks[i] = ReadInts().Skip(1).ToArray();
        }
        var p = ReadInts();

        var patterns = (int)Math.Pow(2, N);
        var ans = 0;
        foreach (var pattern in Enumerable.Range(0, patterns))
        {
            var ok = true;
            for (var i = 0; i < M; i++)
            {
                var on = 0;
                foreach (var s in ks[i])
                {
                    if ((pattern >> (s - 1)) % 2 != 0) on++;

                }
                if (on % 2 != p[i])
                {
                    ok = false;
                    break;
                }
            }
            if (ok) ans++;
        }

        Console.WriteLine(ans);
    }


    static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();

    }

    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}

Measured memory_bytes: 13524
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int A = intArray[0];
            int B = intArray[1];
            int C = intArray[2];
            if(A >= B + C)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(B + C - A);
            }
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 28264
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
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 (b<a) { a = b; return 1; } return 0; }

signed main(){
  int n,m;
  cin >> n >> m;
  string s;
  cin >> s;
  vint ans;
  int now = n;
  bool flag = true;
  while(n != 0){
    flag = false;
    if(now > m){
      rep(i,now-m,now){
        if(s[i] == '0'){
          ans.push_back(now-i);
          now = i;
          flag = true;
          // cout << now << endl;
          break;
        }
      }
    }
    else{
      rep(i,0,now){
        if(s[i] == '0'){
          ans.push_back(now-i);
          now = i;
          flag = true;
          // cout << now << endl;
          break;
        }
      }
    }
    if(!flag) break;
  }
  if(now != 0) cout << -1 << endl;
  else{
    int n = ans.size();
    rep(i,0,n){
      cout << ans[n-1-i] << " ";
    }
  }
}

Measured memory_bytes: 1528
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
const int inf=1e9+7;
const int mod=1e9+7;
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
int main(){
	long long A,B,C,K;
	cin>>A>>B>>C>>K;
	cout<<(K%2==0?A-B:B-A)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n;
    cin >> n;
    vector<ll> A(n);
    for (auto & a : A) cin >> a;

    ll mmin = A[0], mmax = A[0];
    for (auto a : A) {
        mmin = min(mmin, a);
        mmax = max(mmax, a);
    }
    cout << mmax - mmin << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> // Replace needed headers for speed up

// -------------8<------- start of library -------8<------------------------
template<typename T>
struct RangeMinimumQuery {
    const T INF;
    int n;
    std::vector<T> val;

    RangeMinimumQuery(int size, T inf = std::numeric_limits<T>::max()) : INF(inf) {
        for (n = 1; n < size; ) n <<= 1;
        val.assign(2 * n + 1, INF);
    }

    // 最小値を返す
    inline T op(T v1, T v2) const { return v1 <= v2 ? v1 : v2; }

    void update(int idx, T v) {
        idx += n - 1;
        val[idx] = v;
        while (0 < idx) {
            idx = (idx - 1) >> 1;
            val[idx] = std::min(val[2 * idx + 1], val[2 * idx + 2]);
        }
    }
    T find(int l, int r) {
        T res = INF;
        l += n - 1; r += n - 1;
        while (l < r) {
            if (!(l & 1)) res = std::min(res, val[l]);
            if (!(r & 1)) res = std::min(res, val[r - 1]);
            l >>= 1;
            r = (r - 1) >> 1;
        }
        return res;
    }
};

// -------------8<------- end of library ---------8-------------------------
int main() {
    int n, q;
    std::cin >> n >> q;

    RangeMinimumQuery<int> rmq(n);
    for (int i = 0, com, x, y; i < q; ++i) {
        std::cin >> com >> x >> y;
        if (com == 0) rmq.update(x, y);
        else std::cout << rmq.find(x, y + 1) << '\n';
    }

    return 0;
}



Measured memory_bytes: 3880
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
#define U ((1<<n)-1)
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 18;
const llong INF = 1e17;
llong f[N+1][N+1][(1<<N)+3];
llong val[(1<<N)+3];
llong a[N+3];
int n;

void updmin(llong &x,llong y) {x = min(x,y);}

llong dfs(int l,int r,int sta)
{
	if(f[l][r][sta]<INF) {return f[l][r][sta];}
	if(r-l<=1) return f[l][r][sta]=0ll;
	for(int i=l+1; i<r; i++)
	{
		updmin(f[l][r][sta],dfs(l,i,((sta<<1)|1)&U)+dfs(i,r,(sta<<1)&U)+a[i]*val[sta]);
	}
//	printf("f[%d][%d][%d]=%lld\n",l,r,sta,f[l][r][sta]);
	return f[l][r][sta];
}

int main()
{
	scanf("%d",&n);
	for(int i=0; i<(1<<n)-1; i++)
	{
		int len = n; while(i&(1<<len-1)) {len--;} len--;
		llong x = 1ll,y = 1ll; for(int j=0; j<len; j++) i&(1<<j)?y+=x:x+=y; val[i] = x+y;
//		printf("val[%d]=%lld\n",i,val[i]);
	}
	for(int i=0; i<n; i++) scanf("%lld",&a[i]);
	memset(f,10,sizeof(f));
	printf("%lld\n",dfs(0,n-1,(1<<n)-2)+a[0]+a[n-1]);
	return 0;
}

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

int main() {
  int N,x;
  cin>>N;
  for (int i = 0; i < N; i++){
    int A,p;//pはAが何回2で割れるか
    cin>>A;
    p=0;
    while(A%2==0){
      p++;
      A=A/2;
    }
    if (i==0){x=p;}
    else{
      if(p<x){
        x=p;
      }
    }
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const int MOD = 1000000007;
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 a,b,c;
    cin >> a >> b >> c;
    int MAX, MIN;
    MAX = max({a,b,c});
    MIN = min({a,b,c});
    cout << MIN << " " << MAX << endl;
    // pair<int, int> p = minmax({a,b,c});
    // cout << p.first << " " << p.second << endl;

    return 0;
}


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

#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 1 << 21

//ダイクストラ法 優先度付きキューを用いた高速化
void dijkstra(vector<vector<pair<int, int> > > &graph, int n){

    priority_queue<pair<int, int> > PQ;
    vector<int> color(n, WHITE);
    vector<int> cost(n, INF);

    PQ.push(make_pair(0, 0));
    cost[0] = 0;
    color[0] = GRAY;

    while(!PQ.empty()){
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;    //現在地

        color[u] = BLACK;

        if(cost[u] < f.first * (-1)) continue;

        rep(i, graph[u].size()){
            int v = graph[u][i].first;
            
            if(color[v] == BLACK) continue;

            if(cost[v] > cost[u] + graph[u][i].second){
                cost[v] = cost[u] + graph[u][i].second;
                PQ.push(make_pair(cost[v]*(-1), v));
                color[v] = GRAY;
            }
        }
    }

    rep(i, n){
        cout << i << " " << cost[i] << endl;
    }
}

int main() {

    int n;
    cin >> n;
    vector<vector<pair<int, int> > > graph(n);
    int k, c, u , v;
    rep(i, n){
        cin >> u >> k; //u 頂点  k 隣接リストの個数
        rep(j, k){
            cin >> v >> c;      //隣接リストの番号 //隣接リストの重み
            graph[i].push_back(make_pair(v, c));
        }
    }

    dijkstra(graph, n);

    return 0;
} 


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

int main()
{
  int L, M, N;
  
  while (scanf("%d", &L), L){
    int sum = 0, reach;
    bool check = true;
    for (int i = 0; i < 12; i++){
      scanf("%d%d", &M, &N);
      sum += M - N;
      if (check && sum >= L){
        reach = i + 1;
        check = false;
      }
    }
    if (!check){
      printf("%d\n", reach);
    }
    else {
      printf("NA\n");
    }
  }

  return (0);
}

Measured memory_bytes: 1196