akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> H(N, vector<int>(3));
  for (int i = 0; i < N; i++) {
      cin >> H[i][0] >> H[i][1] >> H[i][2];
  }
  
  using p = pair<int, int>;
  int DP[N][3];
  DP[0][0] = H[0][0];
  DP[0][1] = H[0][1];
  DP[0][2] = H[0][2];
  for (int i = 1; i < N; i++) {
    DP[i][0] = max(DP[i-1][1], DP[i-1][2]) + H[i][0];
    DP[i][1] = max(DP[i-1][0], DP[i-1][2]) + H[i][1];
    DP[i][2] = max(DP[i-1][0], DP[i-1][1]) + H[i][2];
  }

  auto L = DP[N-1];
  int res = max(max(L[0], L[1]), L[2]);
  cout << res << endl;
}


Measured memory_bytes: 6912
#include<iostream>
#include<string>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    int k=0;
    string ans;
    for(int i=0;i<a.length();i++){
        ans+=a[i];
        if(b[i]!='\0')ans+=b[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int n;

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

    int n;
    cin >> n;
    vi a(n);
    for (int &x : a) cin >> x;
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] < a[i-1]) {
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+ 100;
int d[maxn];
vector<int> E[maxn];
int dis[maxn];
int n,m;
int main(){
    scanf("%d%d",&n,&m);
    for (int i=0;i<m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        E[x].push_back(y);
        d[y] ++;
    }
    queue<int> Q;
    int ans = 0;
    for (int i=1;i<=n;i++){
        if (d[i] == 0){
            Q.push(i);
        }
    }
    while (!Q.empty()){
        int head = Q.front();
        Q.pop();
        for (int v : E[head]){
            dis[v] = max(dis[v],dis[head] + 1);
            ans = max(ans,dis[v]);
            d[v] --;
            if (d[v] == 0){
                Q.push(v);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int a=S.size();
  for(int i=0;i<a;i++){
    for(int k=i+1;k<a;k++){
      if(S.at(i)==S.at(k)){
        cout << "no" << endl;
        goto as;
      }
    }
  }
  cout << "yes" << endl;
  as:
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		 int N = sc.nextInt();
		 if(0<N && N<=999) {
			  N = N % 10;
			 switch(N){
			 case 2:
			 case 4:
			 case 5:
			 case 7:
			 case 9:
				 System.out.println("hon");
				 break;
			 case 0:
			 case 1:
			 case 6:
			 case 8:
				 System.out.println("pon");
				 break;
			 case 3:
				 System.out.println("bon");
				 break;

			 }

			 sc.close();
		 }
	}
}


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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
    
divisors = make_divisors(N)

total = 0
for divisor in divisors:
    m = N//divisor-1
    if m > divisor:
        total += m
print(total)

Measured memory_bytes: 3268
#include<iostream>
#include<limits>
#include <string>
using namespace std;


int main()

{
	int k;
	string s;
	cin>>k;
  cin.ignore(numeric_limits<streamsize>::max(),'\n'); 
	getline(cin,s); 
	string s1="...";
	string s3,s4;
	

	int l=s.length();

	if(l==k)
	{
		cout<<s<<endl;
	}
	else
	{
		
	
if (s.size() > k) {
 s = s.substr(0, k) + "...";
}
cout << s << '\n';
}
return 0;
	
}

Measured memory_bytes: 3552
#!/usr/bin/env python3
import sys

# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    N = int(input())
    F = [ [int(x) for x in input().split()] for i in range(N)]
    P = [ [int(x) for x in input().split()] for i in range(N)]

    ans = -10000000000000000
    for i in range(1,1<<10):
        pf = 0
        for j in range(N):
            c = 0
            for k in range(10):
                if(i & (1<<k)):
                    if(F[j][k]):
                        c += 1
            pf += P[j][c]

        ans = max(ans, pf)
        

    print(ans)

    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
bool row[8];//yoko i
bool col[8];//tate j
bool dpos[14];// / x=i+j
bool dneg[14];// \ x=i-j+(N-1)
bool boad[8][8];
bool canput(int i,int j){
  if(row[i])return false;
  if(col[j])return false;
  if(dpos[i+j])return false;
  if(dneg[i-j+7])return false;
  return true;
}
void put(int i,int j,bool x){
  row[i]=x;
  col[j]=x;
  dpos[i+j]=x;
  dneg[i-j+(8-1)]=x;
  boad[i][j]=x;
}
void print(){
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      cout << (boad[i][j] ? 'Q':'.');
    }
    cout << endl;
  }
}
void dfs(int i){
  if(i==8){
    print();
    return;
  }
  if(row[i])dfs(i+1);
  for(int j=0;j<8;j++){
    if(canput(i,j)){
      put(i,j,1);
      dfs(i+1);
      put(i,j,0);
    }
  }
}
    

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    int I,J;
    cin >> I >> J;
    put(I,J,1);
  }
  dfs(0);
  return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

bool is_prime(int64_t x) {
  for(int64_t i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}

int main()
{
  ll n,k;
  string s;
  cin >> n >> s >> k;
  rep(i,n){
    if(s[k-1]==s[i])printf("%c",s[i]);
    else printf("*");
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()




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

	int N;
	int L[100];
	cin >> N;
	rep(i, N)cin >> L[i];
	sort(L, L + N);

	int ans = 0;
	rep(k,N)rep(j,k)rep(i,j) {
		if (L[k] < L[i] + L[j] && L[i] != L[j] && L[j] != L[k]) {
			ans++;
		}
	}

	cout << ans << endl;




	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define endl "\n"
#define ll long long
#define N ((int)(1e5 + 5))
#define MAX ((int)(1e9 + 5))
#define MOD ((int)(7901 + 0))


using namespace std;


/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/



int main()
{
    int t;
    t = 1;
    while(t--){
        int arr[5][5];
        for(int i = 1 ; i<4 ; i++){
            for(int j = 1 ; j<4 ; j++) cin>>arr[i][j];
        }
        int b[5] , a[5];
        a[1] = 0;
        for(int i = 1 ; i<4 ; i++) b[i] = arr[1][i] - a[1];
        for(int i = 2 ; i<4 ; i++){
            a[i] = arr[i][1] - b[1];
            for(int j = 2 ; j<4 ; j++){
                if( a[i] + b[j] != arr[i][j] ){
                    cout<<"No\n";
                    return 0;
                }
            }
        }
        cout<<"Yes\n";
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll N,M,V,P;
vector<ll> A;

bool judge(ll tar){
  tar--;
  if(A[tar]+M<A[P-1]) return false;
  if((P-1)+(N-(tar+1))>=V-1) return true;

  ll ok=A[P-1]+M,ng=A[P-1]-1;
  ll num=V-1-(P-1+N-(tar+1));
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    ll res=0;
    bool under=false;
    for(int i=P-1;i<tar;i++){
      if(A[i]>mid) under=true;
    }
    if(under){
      ng=mid;
      continue;
    }

    for(int i=P-1;i<tar;i++) res+=min(M,mid-A[i]);
    if(res>=M*num) ok=mid;
    else ng=mid;
  }
  if(ok<=A[tar]+M) return true;
  else return false;
}

int main(){
  cin>>N>>M>>V>>P;
  A.resize(N);
  rep(i,N) cin>>A[i];

  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());

  ll ok=P,ng=N+1;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(judge(mid)) ok=mid;
    else ng=mid;
  }

  cout<<ok<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100001;

int n, m, out[N], vis[N];
vector <int> v[N];
set <pair <int, int> > edges;

void flip(int x, int y){
    if(edges.count(make_pair(x, y))){
        edges.erase(make_pair(x, y));
        edges.insert(make_pair(y, x));
    }
    else if(edges.count(make_pair(y, x))){
        edges.erase(make_pair(y, x));
        edges.insert(make_pair(x, y));
    }
    else assert(false);
    out[x] ^= 1;
    out[y] ^= 1;
}
int dfs(int node){
    vis[node] = 1;
    for(auto &i : v[node]){
        if(vis[i]) continue;
        int cur = dfs(i);
        if(cur % 2) flip(node, i);
    }
    return out[node];
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 0 ; i < m ; i++){
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
        out[x] ^= 1;
        edges.insert(make_pair(x, y));
    }
    if(m % 2) finish(-1);
    dfs(1);
    for(auto &i : edges){
        cout << i.first << " " << i.second << endl;
    }
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
ll a[100005];
int main() {
	std::cin >> n;

	int num = 0;
	for (int i = 0; i < n; ++i) {
		std::cin >> a[i];
		if (a[i] < 0)
			++num;
		a[i] = std::abs(a[i]);
	}

	ll ans = 0;
	if (num % 2 == 0) {
		for (int i = 0; i < n; ++i)
			ans += a[i];
	}
	else {
		std::sort(a, a + n);
		ans = -a[0];
		for (int i = 1; i < n; ++i)
			ans += a[i];
	}

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


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

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

    int n;
    ll k;
    cin >> n >> k;

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

    sort(A, A+n);

    ll g = A[0];
    for (int i = 1; i < n; i++) {
        g = gcd(g, A[i]);
    }

    if (k <= A[n-1] && k % g == 0) {
        cout << "POSSIBLE\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mid ((s + e) / 2)
#define makefast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define comp(x, y) (lower_bound(vec.begin(), vec.end(), make_pair(x, y)) - vec.begin())
#define lc (v * 2)
#define rc (v * 2 + 1)
long long M = 1e9 + 7;
//>>>>>>>>>>>>>>>>>>>

const int N = 2e5 + 7;

map <int, int> mp;
vector <int> ad[N];
int dif[N], m;
int n, a[N], b[N];
int com;
bool mrk[N];

void dfs(int v) {
	mrk[v] = 1;
	for (auto u: ad[v])
		if (!mrk[u])
			dfs(u);
}
int cnt[N];
int main() {
	makefast;
	cin >> n;
	int x = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		x ^= a[i];
	}
	int res = 0;
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
		if (!mp[b[i]]) {
			m++;
			mp[b[i]] = m;
		}
		if (!mp[a[i]]) {
			m++;
			mp[a[i]] = m;
		}
		a[i] = mp[a[i]];
		b[i] = mp[b[i]];
		cnt[a[i]]++;
		cnt[b[i]]--;
		if (a[i] != b[i]) {
			res++;
			dif[b[i]]++;
			dif[a[i]]--;
			ad[b[i]].push_back(a[i]);
			ad[a[i]].push_back(b[i]);
		}
	}
	if (res == 0) {
		cout << 0;
		return 0;
	}
	if (!mp[x]) {
		m++;
		mp[x] = m;
	}
	x = mp[x];
	cnt[x]++;
	int d = 0;
	for (int i = 1; i <= m; i++) {
		if (dif[i] > 0)
			d = 1;
		if (cnt[i] < 0) {
			cout << -1;
			return 0;	
		}
		if (!mrk[i] && (ad[i].size() || x == i)) {
			dfs(i);
			com++;
		}
	}
	if (!d) {
		cout << res + com - 1;
	}
	else {
		if (dif[x] > 0) {
			cout << res + com - 1;
		}
	}
}



Measured memory_bytes: 20892
import math

N, D = map(int, input().split())

space = []
count = 0

for i in range(N):
    space.append(list(map(int, input().split())))

for i in range(N):
    for j in range(i+1, N):
        if i != j:
            num = 0
            for k in range(D):
                num += (space[i][k] - space[j][k])**2
            num = math.sqrt(num)
            if int(num) - num == 0:
                count += 1

print(count)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

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

  int state = 0;
  ll p = a[0];
  ll pos = 1;
  ll ans = 1;
  while(pos<n){
    if(a[pos]>p){
      if(state >= 0) state = 1;
      else{
        ans++;
        state = 0;
      }
    }else if(a[pos]<p){
      if(state <=0 ) state = -1;
      else{
        ans++;
        state = 0;
      }
    }
    p = a[pos];
    pos++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;
int ans;

const int mod = 1000000007;
int cost[101][2];
int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS

    int x,y;
    cin >> x >> y;


    int ans = 1; 


    while(x <= y)
    {
        x *= 2;
        if(x <= y)ans++;     
    }


    cout << ans;










    return 0; 
}


Measured memory_bytes: 3652
// A. 

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	string n;
	cin >> n;
	int prev = 0, cnt = 0;
	bool ans = false;
	for (char c : n) {
		if (prev == c) {
			if (++cnt >= 3) {
				ans = true;
			}
		} else {
			cnt = 1;
		}
		prev = c;
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
seed_seq seq{
        (uint64_t) chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count(),
        (uint64_t) __builtin_ia32_rdtsc(),
        (uint64_t) (uintptr_t) make_unique<char>().get()
};
mt19937 rng(seq);
int rnd(int l, int r) {return l + rng() % (r - l + 1);}
#define int long long
#define For(a, b, c) for(int a = b; a <= c; ++a)
#define Ford(a, b, c) for(int a = b; a >= c; --a)
#define Fv(a, b) for(auto &a : b)
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define vt vector<int>
#define vpi vector<pair<int, int>>
#define all(a) a.begin(), a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define vt vector<int>
#define vpi vector<pair<int, int>>
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define fixa(a) for(auto &i : a) cerr << i << ' '; cerr << '\n';
#define fixn(a, l, r) For(i, l, r) cerr << a[i]; cerr << '\n';
#define debug(x) cerr << #x << ' ' << x << '\n'
#define inp(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define fasty ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define fix(i) cerr << i << '\n';
#define task "npairs"
main(){
    int m,n;
    cin>>m>>n;
    if(m>9||n>9)cout<<-1;
    else cout<<m*n;
}


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

int main() {
    while(true) {
        int x, y, s;
        cin >> x >> y >> s;
        if(x == 0) break;
        int ans = 0;
        for(int x0 = 1; x0 < s; x0++) {
            for(int y0 = 1; y0 < s; y0++) {
                int newx = x0 * (100 + x) / 100;
                int newy = y0 * (100 + x) / 100;
                if(newx + newy != s) continue;
                int newsum = x0 * (100 + y) / 100 +y0 * (100 + y) / 100;
                ans = max(ans, newsum);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2988
def max(a, b)
  if a.nil?
    b
  else
    (a > b) ? a : b
  end
end

def min(a, b)
  if a.nil?
    b
  else
    (a < b) ? a : b
  end
end

n = gets.to_i

data = Array.new
for i in 1..n do
  data[i-1] = gets.to_i
end

mn = data[0]
for i in 1..n-1 do
  mx = max(mx, data[i]-mn)
  mn = min(mn, data[i])
end

puts mx

Measured memory_bytes: 10512
#include <bits/stdc++.h>
#define pii pair<int, int>;
#define ss second
#define ff first
#define all(x) ((x).begin(), (x).end())

using namespace std;
using ll = long long;

const int mod = 1e9 + 7;
const ll oo = 1 << 31;

int main(void){
    string s;
    int n;
    cin >> n; 
    cin >> s;
    if (n&1) cout << "No" << endl;
    else {
        bool possible = true;
        for (int i=0; i<n/2; i++){
            if (s[i] != s[i + n/2]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double W,H,x,y,area;
  cin >> W >> H >> x >> y;
  area = W * H /2.0;
  if(x == W/2 && y== H/2)
    cout << area << ' ' << 1 << endl;
  else
    cout << area << ' ' << 0 << endl;
}

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

int main(){
    int n; cin >> n;
    for(int i=1; i<=n; i++){
        if(i%3 == 0){
            cout << " " << i;
        }else{
            int x = i;
            while(x){
                if(x%10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3092
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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 COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll tmp1=Svec(v)-v[0];
  ll tmp2=v[0];
  ll ans=abs(tmp1-tmp2);
  Rep(i,n-1){
    tmp2+=v[i];
    tmp1-=v[i];
    chmin(ans,abs(tmp1-tmp2));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>


// calculate x%m for x "properly" for all x
long long int mod(long long int x, long long int m);

// calculate inverse of x in mod m
// if there is inverse of x   : return (inverse of x)
// if there is no inverse of x: return 0
long long int mod_inverse(long long int x, long long int m);

// calculate inverse of x in mod m for PRIME m
long long int mod_inverse_Fermat(long long int x, long long int m);

// calculate x^n mod m
long long int fast_power(long long int x, long long int n, long long int m);

// extended euclid gojjohou
long long int euclid_extended(long long int a, long long int b, long long int &x, long long int &y);

long long int MOD = 1e9 + 7;


int main(){

  long long int n, a, b, tmp1, tmp2, tmp3;
  scanf("%lld%lld%lld", &n, &a, &b);

  long long int total = fast_power(2, n, MOD)-1;
  long long int nCa, nCb;
  tmp1 = tmp2 = 1;
  for(long long int i = 1; i <= a; i++){
    tmp1 *= n+1-i;
    tmp2 *= i;
    tmp1 = (tmp1+MOD)%MOD;
    tmp2 = (tmp2+MOD)%MOD;
  }
  nCa = tmp1 * mod_inverse(tmp2, MOD);
  nCa = mod(nCa, MOD);

  tmp1 = tmp2 = 1;
  for(long long int i = 1; i <= b; i++){
    tmp1 *= n+1-i;
    tmp2 *= i;
    tmp1 = (tmp1+MOD)%MOD;
    tmp2 = (tmp2+MOD)%MOD;
  }
  nCb = tmp1 * mod_inverse(tmp2, MOD);
  nCb = mod(nCb, MOD);

  long long int ans = mod(total - nCa - nCb, MOD);

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;



  
}



long long int mod(long long int x, long long int m){
  if(x>0){
    return x%m;
  }
  else if(x==0){
    return 0;
  }
  else if((-x)%m == 0){
    return 0;
  }
  else{
    return m - (-x)%m;
  }
}


long long int euclid_extended(long long int a, long long int b, long long int &x, long long int &y){
  long long int d = a;
  if(b != 0){
    d = euclid_extended(b, a%b, y, x);
    y -= (a/b)*x;
  }
  else{
    x = 1;
    y = 0;
  }
  
  return d;
}

long long int mod_inverse(long long int x, long long int m){
  long long int tmp, x_inv, gcd_xm;
  gcd_xm = euclid_extended(x, m, x_inv, tmp);
  // if the inverse is calculate properly
  if(gcd_xm == 1){
    return mod(x_inv, m);
  }
  else{
    //std::cerr << "Error in mod_inverse: there is no inverse of x in mod m" << std::endl;
    return 0;
  }
}

long long int mod_inverse_Fermat(long long int x, long long int m){
  return fast_power(x, m-2, m);
}

long long int fast_power(long long int x, long long int n, long long int m){
  long long int ans = 1;
  
  while(n > 0){
    if(n&1){
      ans = ans * x;
      ans = mod(ans, m);
    }
    x = x*x;
    x = mod(x, m);
    n = n>>1;
  }
  
  return ans;
}


Measured memory_bytes: 256
m = gets.split.map(&:to_i)[1]
array = gets.split.map(&:to_i)

total = array.inject(&:+)
thur = total * (1.0 / (4 * m))
rest = array.select {|a| a >= thur}
puts((rest.count >= m) ? 'Yes' : 'No')

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin >> h.at(i);
  }
  sort(h.begin(),h.end());
  int answer = h.at(K-1)-h.at(0);
  for(int i=0;i<N+1-K;i++){
    answer = min(answer,(h.at(K-1+i)-h.at(i)));
  }
  cout << answer << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> s(n);
    int res = 0;
    for(int i = 0; i < n; i++) {
        cin >> s[i];
        res += s[i];
    }

    if(res % 10 != 0) {
        cout << res << endl;
        return 0;
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
        int temp = res - s[i];
        if(temp % 10 != 0) ans = max(ans, temp);
    }

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


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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

bool is_runrun(int64_t i) {
    string s = to_string(i);
    vector<int> ns;
    for (auto c : s) { ns.push_back(c - '0'); }
    for (int i = 1; i < ns.size(); ++i) {
        if (abs(ns[i] - ns[i - 1]) > 1) { return false; }
    }
    return true;
}

int main() {
    int K;
    cin >> K;
    vector<vector<int64_t>> dp(1, vector<int64_t>(10, 1));
    while (true) {
        const vector<int64_t>& old_dp = dp.back();
        int64_t sum = 0;
        for (int i = 1; i <= 9; ++i) { sum += old_dp[i]; }
        // cout << K << " " << sum << endl;
        if (sum >= K) { break; }
        K -= sum;

        vector<int64_t> new_dp(old_dp.begin(), old_dp.end());
        for (int i = 0; i <= 9; ++i) {
            if (i >= 1) {
                new_dp[i] += old_dp[i - 1];
            }
            if (i <= 8) {
                new_dp[i] += old_dp[i + 1];
            }
        }
        dp.push_back(new_dp);
    }
    // for (const auto& d : dp) {
    //     for (const auto& n : d) {
    //         cout << n << " ";
    //     }
    //     cout << endl;
    // }
    vector<int> res;
    int start = 1, end = 9;
    for (int i = dp.size() - 1; i >= 0; --i) {
        int64_t ts = 0;
        for (int j = start; j <= end; ++j) {
            ts += dp[i][j];
            if (ts >= K) {
                K -= ts - dp[i][j];
                res.push_back(j);
                start = max(0, j - 1); end = min(9, j + 1);
                break;
            }
        }
        // res.push_back(9);
        // start = 8; end = 9;
    }
    for (const auto r : res) {
        cout << r;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    int a[3];
    a[0] = 300000;
    a[1]= 200000;
    a[2] = 100000;
    cin >> x >> y;
    if (x == 1 && y == 1) cout << 2 * a[0] + 400000 << endl;
    else{
        int ans = 0;
        if(x < 4) ans = a[x- 1];
        else ans = 0;
        int ans_0 = 0;
        if(y < 4) ans_0 = a[y - 1];
        else ans_0 = 0;
        cout << ans + ans_0 <<endl;
    }

}

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int sum = r * 100 + g * 10 + b;
  if (sum % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 2020;

int V[MAX][MAX];
int EX[MAX][MAX];
int EY[MAX][MAX];
char S[MAX][MAX];

int getS(int x1, int y1, int x2, int y2, int a[][MAX])
{
	int res = a[x2][y2];
	if (x1) res -= a[x1-1][y2];
	if (y1) res -= a[x2][y1 - 1];
	if (x1 && y1) res += a[x1-1][y1-1];
	return res;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n, m, q;
	scanf("%d%d%d", &n, &m, &q);
	FOR (i, 0, n)
	{
		scanf("%s", S[i]);
		FOR (j, 0, m)
		{
			S[i][j] -= '0';
		}
	}

	FOR (i, 0, n)
	{
		FOR (j, 0, m)
		{
			V[i][j] += S[i][j];
			if (i) V[i][j] += V[i-1][j];
			if (j) V[i][j] += V[i][j-1];
			if (i && j) V[i][j] -= V[i-1][j-1];

			if (i) EX[i][j] += S[i][j] & S[i-1][j];
			if (j) EY[i][j] += S[i][j] & S[i][j-1];

			if (i) EX[i][j] += EX[i-1][j];
			if (j) EX[i][j] += EX[i][j-1];
			if (i && j) EX[i][j] -= EX[i-1][j-1];

			if (i) EY[i][j] += EY[i-1][j];
			if (j) EY[i][j] += EY[i][j-1];
			if (i && j) EY[i][j] -= EY[i-1][j-1];
		}
	}

	FOR (i, 0, q)
	{
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		x1--;
		y1--;
		x2--;
		y2--;

		int v = getS(x1, y1, x2, y2, V);
		int ex = getS(x1 + 1, y1, x2, y2, EX);
		int ey = getS(x1, y1 + 1, x2, y2, EY);

		int e = ex + ey;

		int cnt = v - e;
		printf("%d\n", cnt);

	}

}


Measured memory_bytes: 53504
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 26 22:45:33 2019

@author: Yamazaki Kenichi
"""

N = int(input())
A = list(map(int,input().split()))

counta = 0
flg = 1
while flg == 1:
    flg = 0
    for j in range(N-1):
        if A[j] > A[j+1]:
            temp = A[j]
            A[j] = A[j+1]
            A[j+1] = temp
            flg = 1
            counta += 1
print(' '.join(map(str,A)))
print(counta)


Measured memory_bytes: 5608
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define popcnt(n) __builtin_popcount(n)
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


const int NMAX=1000001;


signed main() {
    ll n;
    cin >> n;
    
    ll r = 0;
    
    rrep(i, 1e6) {
        rrep(j, 1e6/i) {
            if (i * j < n) r++;
        }
    }
    
    mes(r);
 
    
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int a[5],i,max=99999,maxl=99999;
	for(i=0;i<5;i++){
		cin>>a[i];
	}
	for(i=0;i<3;i++){
		if(max>a[i])max=a[i];
	}
	for(i=3;i<5;i++){
		if(maxl>a[i])maxl=a[i];
	}
	cout<<max+maxl-50<<endl;
}

Measured memory_bytes: 3100
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tolower(c) char(c+0x20)
#define toupper(c) char(c-0x20)
#define chartoll(c) ll(c) - ll('0')

const ll MAX_N = 200000;

int main(void){
    ll N;
    ll A[MAX_N];
    ll r[MAX_N+1],l[MAX_N+1];
    
    cin >> N;
    r[0] = 0;
    l[0] = 0;
    rep(i, N) cin >> A[i];
    rep(i, N){
        l[i+1] = max(l[i],A[i]);
        r[i+1] = max(r[i],A[N - 1 - i]);
    }

    rep(i, N) cout << max(l[i], r[N - i - 1]) << endl;

    return 0;
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(2e6) + 17;

ll A, B, C, K;

bool read() {
    if (!(cin >> A >> B >> C >> K))
        return false;

    return true;
}

void solve() {
    cout << (A - B) * (K % 2 ? -1 : 1) << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



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

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

 int main() {
   int N, M;

   cin >> N >> M;
   vector<bool> s(N + 1, true);

   rep(i, M) {
     int tmp;
     cin >> tmp;
     s.at(tmp) = false;
   }

   vector<int> dp(N + 1, 0);

   dp.at(0) = 1;
   if (s.at(1)) dp.at(1) = 1;

   for (int i = 2; i <= N; i++) {
     if (s.at(i - 1)) dp.at(i) += dp.at(i - 1);
     if (s.at(i - 2)) dp.at(i) += dp.at(i - 2);
     dp.at(i) %= 1000000007;
   }
   cout << dp.at(N) << endl;
 }


Measured memory_bytes: 640
import Data.List
import Data.Maybe

countPower :: Int -> Int -> (Int, Int)
countPower c n = if n `mod` c /= 0 then (n, 0)
                 else (m, 1 + cp)
  where (m, cp) = countPower c (n `div` c)

        
pfact :: Int -> [(Int, Int)]
pfact n = pfact0 n [2..]  []
  where
    pfact0 :: Int -> [Int] -> [(Int, Int)] -> [(Int, Int)]
    pfact0 n (c : cands) pans =
      let (rem, power) = countPower c n
          nextCands = filter (\x -> x `mod` c /= 0) cands
      in if power >= 1 then pfact0 rem nextCands ((c, power) : pans)
         else if c * c <= n then pfact0 rem nextCands pans
              else if n == 1 then reverse pans
                   else reverse ((n,1) : pans)

divisors :: Int -> [Int]
divisors n = sort (divis0 (pfact n))
  where
    divis0 [] = [1]
    divis0 ((p,r) : prs) =
      concatMap (\x -> map (* x) (divis0 prs)) (take (r + 1) (iterate (* p) 1))

qcOddM :: Int -> [Int]
qcOddM n = head (mapMaybe f [1..])
  where
    f :: Int -> Maybe [Int]
    f r = let (x, y) = (4 * r, n * r) in do
      as <- selSum 3 x (reverse (divisors y))
      return (map (div y) as)


-- Find k members from ys s.t. the sum equals to x.
-- ys are in descending order.
selSum :: Int -> Int -> [Int] -> Maybe [Int]
selSum k x ys
  | k == 0 && x == 0 = Just []
  | k == 0           = Nothing
  | otherwise        = let ys1 = dropWhile (> x) ys in
      case ys1 of
        [] -> Nothing
        (y:ys2) -> case selSum (k - 1) (x - y) ys1 of
          Just as -> Just (y:as)
          Nothing -> selSum k x ys2

qcBody :: Int -> [Int]
qcBody n | n `mod` 2 == 0 = let k = n `div` 2 in [k, 2*k, 2*k]
         | otherwise = qcOddM n

main :: IO ()
main = do
  line <- getLine
  let n = read line :: Int
  putStrLn (concat (intersperse " " (map show (qcBody n))))


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

int V[110][10010]; // V[i][c] 品物iまでの世界でコスト制限cでの価値最大値

int main() {
  int N, M;
  cin >> N >> M;
  int v[110];
  int w[110];
  for (auto i=0; i<N; i++) {
    cin >> v[i] >> w[i];
  }
  for (auto j=0; j<=M; j++) {
    if (j < w[0]) {
      V[0][j] = 0;
    } else {
      V[0][j] = v[0];
    }
  }
  for (auto i=1; i<N; i++) {
    for (auto j=0; j<=M; j++) {
      if (j - w[i] >= 0) {
        V[i][j] = max(V[i-1][j], V[i-1][j-w[i]] + v[i]);
      } else {
        V[i][j] = V[i-1][j];
      }
    }
  }
  cout << V[N-1][M] << endl;
}

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

int main() {
    int N, K, x, y;
    cin >> N >> K;
    vector<pair<int,int>> G;
    REP(i,N){
        cin >> x >> y;
        G.push_back(make_pair(x,y));
    }
    ll ans = 4e18+1;
    REP(p,N){
        REP(q,N){
            REP(r,N){
                REP(s,N){
                    ll ue = max(G[p].second,G[q].second);
                    ll shita = min(G[p].second,G[q].second);
                    ll hidari = min(G[r].first,G[s].first);
                    ll migi = max(G[r].first,G[s].first);
                    int t = 0;
                    REP(k,N){
                        if ((G[k].second<=ue)&&(shita<=G[k].second)&&(G[k].first<=migi)&&(hidari<=G[k].first)) t++;
                    }
                    if (t>=K){
                        ans = min(ans,(ue-shita)*(migi-hidari));
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,p[10],j;
	for(i=0;i<10;i++){
		scanf("%d",&p[i]);
	}
	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(p[i]<p[j]){
				int t=p[i];
				p[i]=p[j];
				p[j]=t;
			}
		}
	}
	for(i=0;i<3;i++){
		printf("%d\n",p[i]);
	}
	return 0;
}

Measured memory_bytes: 1816
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    N %= 10;
    if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
        cout << "hon" << endl;
    } else if (N == 3) {
        cout << "bon" << endl;
    } else {
        cout << "pon" << endl;
    }
}


Measured memory_bytes: 3636
def solve():
  ans = 0
  N, x = map(int, input().split())
  A = [0]+list(map(int, input().split()))
  for i in range(1,N+1):
    if A[i]+A[i-1]>x:
      ans += A[i]+A[i-1]-x
      A[i] = x - A[i-1]
  return ans
print(solve())

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    int N, K;
    cin >> N >> K;
    COMinit();

    for(int i=0; i<K; i++){
        ll tmp = 0;
        ll tmp2 = 0;
        tmp = COM(N-K+1, i+1) % MOD;
        tmp2 = COM(K-1, i) % MOD;
        cout << tmp * tmp2 % MOD << endl;
    }

}


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

int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int d[8];
	for(int i = 0;i<3;i++){
		if(a[i] == 5)d[5]++;
		if(a[i] == 7)d[7]++;
	}
	
	if(d[5] == 2 && d[7] == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h> 

#define N 100

#define TEN 10
#define BIG 20
#define SMALL 19
#define YEAR 195
#define YEAR3 200

int convert(int y,int m,int d){
    int day=0;
    int i;

    for(i=1;i<y;i++){
        if(i%3==0){
            day += YEAR3;
        } else {
            day += YEAR;
        }
    }

    if(y%3==0){
        day += BIG * (m-1);
    } else {
        for(i=1;i<m;i++){
            if(i%2==0){
                day += SMALL;
            } else {
                day += BIG;
            }
        }
    }

    day += d;
    return day;
}

int main(void){
    int n;
    int ymd[N][4]={{}};
    int daymil;

    daymil = convert(1000,1,1);

    scanf("%d",&n);

    int i;
    for(i=0;i<n;i++){
        scanf("%d%d%d",&ymd[i][0],&ymd[i][1],&ymd[i][2]);
        ymd[i][3] = daymil;
        ymd[i][3] -= convert(ymd[i][0],ymd[i][1],ymd[i][2]);
        printf("%d\n",ymd[i][3]);
    }

    return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>
#define MAX 100

int main (){
	int i,n;
	int fib[MAX];
	
	scanf ("%d", &n);
	
	fib[0] = 1;
	fib[1] = 1;
	for (i = 2; i <=n; i++){
		fib[i] = fib[i-1] + fib[i - 2]; 
	}
	printf("%d\n",fib[n]);
	
	return 0;
}


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

int check(int a)
{
    int sum=0,b=a;
    if(b%2==1) return 0;
    while(a%2==0)
    {
        a/=2;
        sum++;
    }
    return sum;
}
int main()
{
    int n,a,i,mx=100000;
    cin>>n;
    for(i=0;i<n;++i)
    {
        cin>>a;
        mx=min(mx,check(a));
    }
    cout<<mx<<endl;

}


Measured memory_bytes: 256