akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
//////////////////

ll dp[2][5] , nxt[2][5];

void solve(){
  string S; cin >> S;
  int K; cin >> K;
  dp[0][0] = 1;
  while(!S.empty()){
    rep(i,2) rep(j,5) nxt[i][j] = 0;
    rep(f , 2) rep(k , K + 1) rep(c , 10){
      int nf = c > (S.back() - '0') ? 1 : c < (S.back() - '0') ? 0 : f;
      int nk = k + (c != 0);
      nxt[nf][nk] += dp[f][k];
    }  
    S.pop_back();
    swap(dp , nxt);
  }
  cout << dp[0][K] << '\n';
}


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

int main()
{
    int N, sum = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    for (int i = 1; i < N; i++)
    {
        sum += A[i];
    }
    if (A[0] < sum)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
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 area = a*b;
        int length = 2*a + 2*b;
        System.out.println(area+" "+length);
        sc.close();
    }
}


Measured memory_bytes: 26160
import itertools

N = int(input())
Xs = []
Ys = []
for i in range(N):
    x, y = map(int, input().split())
    Xs.append(x)
    Ys.append(y)

all_paths = list(itertools.permutations(range(N)))

dist = {}
for i in range(N):
    dist[i] = {}
    for h in range(N):
        if i == h:
            dist[i][h] = 0
        dist[i][h] = pow((Xs[i] - Xs[h]) * (Xs[i] - Xs[h]) + (Ys[i] - Ys[h]) * (Ys[i] - Ys[h]), 0.5)

whole = 0
for path in all_paths:
    for l, r in zip(path[:-1], path[1:]):
        whole += dist[l][r]

number = len(all_paths)
print(whole / number)



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

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}


int main(void){
    long long x,cnt=0;

    scanf("%lld",&x);

    cnt += 2*(x/11);
    x %= 11;
    if(x==0)
        cnt+=0;
    else if(x<= 6)
        cnt+=1;
    else
    {
        cnt+=2;
    }
    printf("%lld\n",cnt);
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

	int n;
	cin >> n;
	vi v(n);
	for(int i = 0; i < n; i++) cin >> v[i];
	sort(all(v));
	int l = v.back();
	int sum = 0;
	for(int i = 0; i < n - 1; i++){
		sum += v[i];
	}
	cout << (l < sum ? "Yes" : "No");
}

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

int main(void)
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ab;
  int ac;
  int bc;

  if(abs(a-b)<=d)
  {
    ab=1;
  }
  else
  {
    ab=0;
  }
  if(abs(b-c)<=d)
  {
    bc=1;
  }
  else
  {
    bc=0;
  }
  if((ab==1&&bc==1)||abs(a-c)<=d)
  {
    ac=1;
  }
  else
  {
    ac=0;
  }
  if(ac==1)
  {
  cout<<"Yes";
  }
  else
  {
  cout<<"No";
}
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;
    vector< vs32 > pos(10);
    rep (i, n)
    {
        char c;
        cin >> c;
        pos[c - '0'].push_back(i);
    }

    int ans = 0;
    rep (i, 10) rep (j, 10) rep (k, 10)
    {
        auto l = lower_bound(pos[i].begin(), pos[i].end(), 0);
        if (l == pos[i].end()) continue;
        auto m = upper_bound(pos[j].begin(), pos[j].end(), *l);
        if (m == pos[j].end()) continue;
        auto r = upper_bound(pos[k].begin(), pos[k].end(), *m);
        if (r == pos[k].end()) continue;
        ++ans;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
int n,mod,dp[6005][12005];
int solve(int len,int bal)
{
	if (!len)
	return (bal>=0 && bal%3==0);
	if (dp[len][bal+3*n]!=-1)
	return dp[len][bal+3*n];
	int ans=solve(len-1,bal+1);
	if (len>1)
	ans=(ans+1LL*(len-1)*solve(len-2,bal-1))%mod;
	if (len>2)
	ans=(ans+1LL*(len-1)*(len-2)*solve(len-3,bal))%mod;
	return dp[len][bal+3*n]=ans;
}
int main()
{
	cin >> n >> mod;
	memset(dp,-1,sizeof(dp));
	cout << solve(3*n,0);
}

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

int main() {
  long n,m,a,b,cou,ans;
  ans=0;
  cin>>n>>m;
  vector<long> takasa(n);
  for(long i=0; i<n; i++){
    cin>>takasa.at(i);
  }
  vector<vector<long>> vec(n,vector<long>(0));
  for(long i=0; i<m; i++){
    cin>>a>>b;
    vec.at(a-1).push_back(b-1);
    vec.at(b-1).push_back(a-1);
  }
  for(long i=0; i<n; i++){
    cou=0;
    for(long j=0; j<vec.at(i).size(); j++){
      if(takasa.at(i)<=takasa.at(vec.at(i).at(j))){
        cou=1;
      }
    }
    if(cou==0){
      ans++;
    }
  }
  cout<<ans;
}

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

int main()
{
    char c;
    cin >> c;
    if ((c == 'a') || (c == 'e') || (c == 'u') || (c == 'i') || (c == 'o'))
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

struct UF{
    const int node_num;
    vector<int> parent;
    vector<int> size;

    UF(int N) : node_num(N), parent(N), size(N, 1) {
        for(int i = 0; i < N; ++i) parent[i] = i;
    }

    //xの根を得る
    int root(int x){
        if(parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    //xが属する木とyが属する木を一つに合わせる
    void unite(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        if(root_x == root_y) return;
        parent[root_y] = root_x;
        size[root_x] += size[root_y];
    }

    //xとyが属する木が同じならtrueを返す
    bool same(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        return root_x == root_y;
    }

    //xと同じ木に属する要素の数を返す
    int same_size(int x){
        int root_x = root(x);
        return size[root_x];
    }
};

int main(){
    Stream io;
    
    char c;
    io.read(c);
    switch(c){
        case 'a':
        case 'i':
        case 'u':
        case 'e':
        case 'o':
        cout << "vowel";
        break;
        default:
        cout << "consonant";
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for i in range(N)]
sum_l = 0
for i in A:
    if D % i == 0:
        sum_l += D // i
    else:
        sum_l += D // i + 1
print(X + sum_l)


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        
        int max = Math.max( A, Math.max(B, C) );
        int sum = (int)Math.pow(2, K) * max;
        if( max == A) {
            sum += B + C;    
        } else if( max == B ) {
            sum += C + A;
        } else if( max == C ) {
            sum += A + B;
        }
        System.out.println( sum );
    }
}


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

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

  queue<ll> q;
  for (int i = 1; i <= 9; i++) q.push(i);
  ll x;
  while (k != 0) {
    x = q.front();
    q.pop();
    k--;

    for (int j = -1; j <= 1; j++) {
      int d = x % 10 + j;
      if (d < 0 || d > 9) continue;
      q.push(x * 10 + d);
    }
  }

  cout << x << endl;
  return 0;
}

Measured memory_bytes: 5132
#include <stdio.h>

int n, p;
int A[100];

long long dp[101][2];

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

  dp[0][0] = 1;
  for(i=0;i<n;i++){
    dp[i+1][A[i] % 2] = dp[i][A[i] % 2] + dp[i][0];
    dp[i+1][1 ^ (A[i] % 2)] += dp[i][1 ^ (A[i] % 2)] + dp[i][1];
  }

  printf("%lld\n", dp[n][p]);

  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, K: int, A: "List[int]"):
    print(math.ceil(1+(N-K)/(K-1)))
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 16492
n = int(input())
l4 = n//4
l7 = n//7
judge = False

for i in range(l4+1):
    for j in range(l7+1):
        sum = i * 4 + j * 7
        if n == sum:
            judge = True
            break


if judge:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include<stdio.h>
int main()
{

    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d = a/b;
    r = a%b;
    f = (double)a/b;
    printf("%d %d %f\n",d,r,f);


    return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int leap(int r, int d, int &x){
  x = r*x- d;
  return x;
}
int main(){
  int r, d, x;
  cin>> r >> d >> x;
  for(int i = 0;i<10;i++){
    cout<<leap(r,d,x)<<endl;
  }
}

Measured memory_bytes: 256
from collections import deque
K = int(input())
d={1:1}
q = deque()
q.append([1,1])

while q:
    a,c = q.popleft()
    a_ = (a*10)%K
    if(a_ not in d or c < d[a_]):
        d[a_]=c
        q.appendleft([a_,c])
    b_ = (a+1)%K
    if(b_ not in d or c < d[b_]):
        d[b_] = c+1
        q.append([b_,c+1])

print(d[0])
    


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

int main() {
  string s;
  cin >> s;
  if(s == "Rainy") cout << "Sunny" <<endl;
  if(s == "Sunny") cout << "Cloudy" << endl;
  if(s == "Cloudy") cout << "Rainy" << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int N = S.length();
		int mod = 13;
		int mod_num = 1_000_000_007;

		int[][] mod_table = new int[N][10];
		for (int j=0;j<10;j++) {
			mod_table[0][j] = j;
		}
		for (int i=0;i<N-1;i++) {
			for (int j=0;j<10;j++) {
				mod_table[i+1][j]=mod_table[i][j]*10%mod;
			}
		}

		int[] dp = new int[13];
		dp[0] = 1;
		for (int i=N-1;i>=0;i--) {
			int[] next_dp = new int[13];
			if (S.charAt(i) == '?') {
				for (int l=0;l<10;l++) {
					int k = l;
					for (int j=0;j<mod;j++) {
						next_dp[(mod_table[N-i-1][k] + j)%mod] += dp[j];
						next_dp[(mod_table[N-i-1][k] + j)%mod] %= mod_num;
					}
				}
			} else {
				int k = (int)S.charAt(i) - 48;
				for (int j=0;j<mod;j++) {
					next_dp[(mod_table[N-i-1][k] + j)%mod] += dp[j];
					next_dp[(mod_table[N-i-1][k] + j)%mod] %= mod_num;
				}
			}
			dp = next_dp;
		}
		// System.out.println(N);
		System.out.println(dp[5]);
		// System.out.println(Arrays.deepToString(mod_table));
	}
}

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

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

int main(){
  int A,B,K;
  cin >> A >> B >> K;

  int G= gcd(A,B);
  int cnt= 0;
  int ans;
  for(int d=G; d>0; d--){
    if(G%d==0){
      cnt++;
      if(cnt==K){
        ans= d;
        break;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<i32> = read_vec();
    let (a, b) = (v[0], v[1]);
    println!("{} {}", a * b, (a + b) * 2);
}



Measured memory_bytes: 5032
cin = open(0).read().strip().split('\n')
n, q = map(int, cin[0].split(' '))
ab = [tuple(map(int, a.split(' '))) for a in cin[1:n]]
px = [tuple(map(int, a.split(' '))) for a in cin[n:n+q]]

import sys
sys.setrecursionlimit(10**9)

def dfs(g, seen, idx):
    global score

    seen[idx] = True
    for i in g[idx]:
        if seen[i]: continue
        score[i] += score[idx]
        dfs(g, seen, i)

g = [[] for _ in range(n)]
for abi in ab:
    g[abi[0]-1].append(abi[1]-1)
    g[abi[1]-1].append(abi[0]-1)

score = [0]*n
for pxi in px:
    score[pxi[0]-1] += pxi[1]

seen = [False]*n
dfs(g, seen, 0)

print(' '.join(map(str, score)))

Measured memory_bytes: 309740
n = int(input())
h = list(map(int, input().split()))
dp = [float('inf') for i in range(n)]
dp[0] = 0

def chmin(a, b):
    if a > b:
        return b
    else:
        return a

for i in range(n-1):
    if i == 0:
        dp[i+1] = abs(h[i+1] - h[i])
    else:
        dp[i+1] = chmin(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
        dp[i+1] = chmin(dp[i+1], dp[i-1] + abs(h[i+1] - h[i-1]))
print(dp[n-1])

Measured memory_bytes: 13908
count = gets.chomp.to_i
numbers = gets.chomp.split
count.times do |i|
	numbers[i] = numbers[i].to_i
end
result = numbers[0] + numbers[count - 2]
(count - 1).times do |i|
	result += ([numbers[i], numbers[i + 1]]).min
end
puts result

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

int main(){
    string s,t;
    cin>>s>>t;
    int n = s.length();
    int m = t.length();

    vector<vector<int>>a(n+1,vector<int>(m+1));
    for(int i=1; i<=n ; ++i){
        for(int j=1; j<=m; ++j){
           if(s[i-1] == t[j-1])
                a[i][j] = a[i-1][j-1]+1;
           else
                a[i][j] = max(a[i-1][j],a[i][j-1]);
        }
    }

    string ans = "";
    int x = n, y = m;

    while(y!=0 && x!=0){
            if(a[x-1][y] == a[x][y])
             --x;
            else if(a[x][y-1] == a[x][y])
                --y;
            else{
                ans = t[y-1]+ans;
                --x;
                --y;
            }
    }
    cout<<ans;
}


Measured memory_bytes: 38928
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(m)]
 
l=10**(n-1)
if n==1:
    l=0
for i in range(l,10**n):
    s=str(i)
    for x,y in a:
        if s[x-1]!=str(y):
            break
    else:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3064
#define DEBUG 0

/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-3-30 21:02:20
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
string S;

int main()
{
  cin >> N >> S;
  int r = 0, b = 0;
  for (auto x : S)
  {
    if (x == 'R')
    {
      r++;
    }
    else
    {
      b++;
    }
  }
  if (r > b)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    A,B,C,K=map(int,input().split())
    if abs(B-A)>10**18:
        print('Unfair')
    else:
        if K%2==0:
            print(A-B)
        else:
            print(B-A)

resolve()

Measured memory_bytes: 38256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    int n, m, k;
    std::cin >> n >> m >> k;

    for (int x = 0; x <= m; x++) {
        for (int y = 0; y <= n; y++) {
            if (x * (n - y) + y * (m - x) == k) {
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "No" << std::endl;
}


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

    int main() {
    int N;
    cin >> N;
    long long int Lip = 2;
    long long int Li = 1;
    long long int tmp;
    if (N == 0) {
        cout << 2 << endl;
    }
    else if (N == 1) {
        cout << 1 << endl;
    }
    else {
        for (int i = 1; i < N; i++) {
        tmp = Lip + Li;
        Lip = Li;
        Li = tmp;
        }
        cout << Li << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
S_list = [input() for _ in range(N)]
cnt = 0


def count_symmetry(S_symmetry):
    for i in range(N):
        for j in range(i + 1, N):
            if S_symmetry[i][j] != S_symmetry[j][i]:
                return False
    return True


for k in range(N):
    S_symmetry = S_list[k:] + S_list[:k]
    if count_symmetry(S_symmetry):
        cnt += 1

print(cnt * N)


Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    string s;
    cin>>s;
    if(s=="SUN"){
        cout<<7<<endl;
    }else if(s=="MON"){
        cout<<6<<endl;
    }else if(s=="TUE"){
        cout<<5<<endl;
    }else if(s=="WED"){
        cout<<4<<endl;
    }else if(s=="THU"){
        cout<<3<<endl;
    }else if(s=="FRI"){
        cout<<2<<endl;
    }else{
        cout<<1<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
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;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N;
    vi a(N);
    cin >> a;
    ans = INF;
    FOR(i, -100, 101) {
        ll tmp = 0;
        REP(j, N) {
            tmp += (a[j] - i) * (a[j] - i);
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i < n;i++){
            a[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        for(int i = 0;i < q;i++){
            int b = sc.nextInt();
            int e = sc.nextInt();
            int tmp = 0;

            int l = 0;
            for(int j = b;j < b + ((e - b) / 2);j++){
                tmp = a[b + l];
                a[b + l] = a[(e - 1) - l];
                a[(e - 1) - l] = tmp;
                l++;
            }
        }

        for(int i = 0;i < n;i++){
            if(i != 0)  System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.println();
    }
}


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

using namespace std;

#define ll long long
#define ar array


ll n;


void solve(){
    
    cin >> n;


    
    
    string s;
    ll t;
    int max = 0;
    ll tmp = 26;
    ll z = 0;
    while (max < 11 && n > 0)
    {

        t = n % tmp;
        t = t / (tmp/26);

        if(t == 0) t = 26;

        //cout << "n : " << n << " tmp: " << tmp << " "<< t  << "char : " << char(t+'a'-1)<< endl;
        s += char(t+'a'-1);

        n = n-(t * (tmp/26)); 

        tmp = tmp*26;
    }
    

    reverse(s.begin(), s.end());
    cout << s << endl;

}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

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

int main(){
   string s;
   cin >> s;
   int ans = 0;
   for(int i=0;i<4;i++){
      if(s[i]=='+')ans++;
      else ans--;
   }
   cout << ans;
   return 0;
}

Measured memory_bytes: 256
import fractions
n,m=map(int,input().split())
lis  = list(map(int,input().split()))
#aそれぞれを2で割ったものを持っておく
div = []
for i in range(n):
    div.append(lis[i]//2)
#lisそれぞれの要素を2で割り切れる回数をすべて数える
L = []
for i in range(n):
    cnt = 0
    while lis[i] %2 ==0:
        lis[i] //= 2
        cnt += 1
    L.append(cnt)

bl = True
#重複要素を削除して要素数でLがすべて一緒か判断
def set_list(es):
    return len(list(set(es))) == 1

if set_list(L) != 1:
    print(0)
    exit()

#div内の最小子公倍数ansを求める

ans = div[0]
for i in range(1,n):
    ans =ans*div[i]//fractions.gcd(ans,div[i])

S = m//ans
if S %2 ==0:
    print(S//2)
else:
    print(S//2 +1)

Measured memory_bytes: 16316
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n;
  cin >> n;
  char tmp;
  set<char> st;
  rep (i, n) {
    cin >> tmp;
    st.insert(tmp);
  }
  if (st.size() == 3) P("Three");
  else P("Four");

  return 0;

}



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

int harf(long long H){
    return H/2;
}

int main()
{
    long long H;
    cin >> H;
    long long count = 0;
    while(H>1){
        H /= 2;
        count++;
    }
    long long ans = pow(2, count+1)-1;
    cout << ans << endl;
}

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll D = il();

  // cs[0] ~ cs[25] := 1日開催されなかった時の満足度の下がり方
  vector<ll> cs;
  rep(i, 26){
    cs.push_back(il());
  }

  // ss[d][i] := d 日目に i 番目のコンテストを開催した時の満足度上昇
  // d : 0 ~ 364 日目（0-indexed）
  vector<vector<ll> > ss(365, vector<ll>(26, 0));
  rep(d, 365){
    rep(i, 26){
      ss[d][i] = il();
    }
  } 



  // 開催するコンテスト 1-indexedになおして入れること
  vector<ll> anss(365, 0);

  // まずは毎日違うコンテストを順番に開催してみる
  rep(d, 365) anss[d] = d % 26 + 1;


  // 答えの出力（ここは変えなくていい）
  rep(d, 365) cout << anss[d] << endl;


  
}

Measured memory_bytes: 3780
import math
from fractions import Fraction as frac

MOD = 1000000007

def solve(case_no):
    n = int(input())
    a = list(map(int, input().split()))
    ps = [a[0]]
    for i in range(1, n):
        ps.append(ps[i - 1] + a[i])
    ans = 0
    for i in range(n - 2, -1, -1):
        ans += a[i + 1] * ps[i]
        ans %= MOD
    print(int(ans))

t = 1
# t = int(input())
for i in range(1, t + 1):
    solve(i)


Measured memory_bytes: 32816
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 500001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
ll C(ll n,ll r){
	if(r==0 || r==n) return 1;
	if(r==1) return n;
	return C(n-1,r-1)+C(n-1,r);
}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
int n,k;cin>>n>>k;
vl vec(n);
rep(i,0,n) cin>>vec[i];
if(k==1){
	cout<<"0";
	return;
}
Sort(vec);
vl fac(100001);
fac[0]=fac[1]=1;
for(int i=2;i<=100000;i++) fac[i]=fac[i-1]*i%mod,fac[i]%=mod;
ll ans=0;
for(int i=k-1;i<n;i++){
	ll mul=vec[i];
	mul=mul*fac[i]%mod;
	mul=mul*mi(fac[k-1],mod)%mod;
	mul=mul*mi(fac[i-k+1],mod)%mod;
	ans=ans+mul;
	ans%=mod;
}
//cout<<ans;
for(int i=0;i<=n-k;i++){
	ll mul=vec[i];
	mul=mul*fac[n-i-1]%mod;
	mul=mul*mi(fac[k-1],mod)%mod;
	mul=mul*mi(fac[n-i-k],mod)%mod;
	ans=ans-mul+mod;
	ans%=mod;
}
cout<<ans;
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}



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

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if(u==s) {
    a--;
  }
  else if(u==t) {
    b--;
  }
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    while(true){
        cin >> s;
        if (s == "0"){
            break;
        }
        int d = 0;
        for(int i=0;i<s.size();i++){
            int n=s[i]-48;
          
            d +=n;
        }
        cout << d << endl;
    }
    // Your code here!
    
}



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

int main() {
  int n;
  cin >> n;
  
  int count=0;
  
  for(int i=100*n; i <= 100*n+99; i++){
    if(i%108 == 0){
      count++;
    }
  }
  
  if(count > 0){
    if(100*n%108 == 0){
    	cout << n * 100 / 108 << endl;
    }
    else{
    	cout << (n * 100 / 108) + 1 << endl;
    }
  }
  
  else{
    cout << ":(" << endl;
  }
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  rep (i, W+2) {
  cout << "#";
  } 
  cout << endl;
  
  rep (i, H) {
  string s;
  cin >> s;
  cout << "#" << s << "#" << endl;
  }
  
  rep (i, W+2) {
  cout << "#";
  } 
  
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi a(n);
  int cnt = 0;
  REP(i, n) {
    cin >> a[i];

    cnt += (i % 2 == 0) && (a[i] % 2);
  }
  cout << cnt << endl;



}








Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s;
    cin >> s;
    int m = 0;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
            cnt++;
            if(i == s.size()-1)             m = max(m, cnt);
        }
        else{
            m = max(m, cnt);
            cnt = 0;
        }
    }
    cout << m;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define MOD 10007
using namespace std;

int main(){
	int n,sn[1000];
	int dp[1001][8] = {};
	string s;
	cin >> n >> s;
	for(int i = 0;i < n;i++){
		if(s[i] == 'J') sn[i] = 0;
		else if(s[i] == 'O') sn[i] = 1;
		else sn[i] = 2;
	}
	dp[0][1] = 1;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < 8;j++){
			if(j & (1 << sn[i - 1])){
				for(int k = 0;k < 8;k++){
					if(j & k) dp[i][j] = (dp[i][j] + dp[i - 1][k]) % MOD;
				}
			}
		}
	}
	int res = 0;
	for(int i = 0;i < 8;i++) res = (res + dp[n][i]) % MOD;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
int main(){
    char ch;
    int a[256]={0};
    while((ch=getchar())!=EOF) a[ch]++;
    for(int i=97;i<=122;i++)printf("%c : %d\n",i,a[i]+a[i-32]);
    return 0;
}



Measured memory_bytes: 3164
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    string S; cin >> S;
    S[3] = '8';
    cout << S << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	vector<int> d;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		d.push_back(tmp);
	}
	sort(d.begin(), d.end());
	n /= 2;
	cout << d[n] - d[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;
long long const inf = 1e18, linf = 2e9, mod = 1e9+7;
int const mxn = 4e5+10;
 
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}






int main(){
	string s;
	cin>>s;
	if (s.size()%2==1){
		cout<<"No";
		return 0;
	}
	int f = 0; 
	for (int i = 0  ; i <s.size();i+=2){
		if (s[i]=='h' and s[i+1] =='i')
			f++;
	}
	if (f==s.size()/2)
		cout<<"Yes";
	else
		cout<<"No";

}

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

int main(){
  int x,y;
  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    if(x <= y){
      cout << x << " " << y << endl;
    }else{
      cout << y << " " << x << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 2992
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var tmp = line[0].split(" ");
	var n_sqr = Number(tmp[0]);
	var n_tollgate = Number(tmp[1]);
	var start_sqr = Number(tmp[2]);
	var tollgates = line[1].split(" ");

	var n_r_gate = 0;
	var n_l_gate = 0;

	for(var i = 0; i < tollgates.length; i++){
		var tollgate = Number(tollgates[i]);
		if(start_sqr < tollgate) n_r_gate++;
		else n_l_gate++;
	}

	console.log(Math.min(n_r_gate, n_l_gate));

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
program ABC144D
    implicit none
    real::a,b,x
    read*,a,b,x

    if(x>=a*a*b/2)then
        print'(f0.10)',atan(2*(a*a*b-x)/(a*a*a))*180/3.14159265358
    else
        print'(f0.10)',atan(a*b*b/(2*x))*180/3.14159265358
    end if
end program ABC144D

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
unordered_map<string,ll>mp;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		mp[s]++;
	}
	ll ans=0;
	for(auto x:mp)
	 ans+=x.second*(x.second-1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define MAX_N_BIT 222222
long long bit[MAX_N_BIT + 1];
long long n = MAX_N_BIT;
long long sum(long long i)
{
    i++;
    long long s = 0;
    while (i > 0)
    {

        s += bit[i];
        i -= i & -i;
    }
    return s;
}
void add(long long i, long long x)
{
    i++;
    while (i <= n)
    {

        bit[i] += x;
        i += i & -i;
    }
}
int main()
{
    ll n, d, a;
    cin >> n >> d >> a;
    vl x(n), h(n);
    rp(i, 0, n) cin >> x[i] >> h[i];
    pair<ll, ll> pi[n];
    rp(i, 0, n) pi[i] = make_pair(x[i], (h[i] + a - 1) / a);
    sort(pi, pi + n);
    vl xx(n);
    rp(i, 0, n) xx[i] = pi[i].first;
    ll ans = 0;
    ll now[n + 1];
    za(n + 1, now);
    rp(i, 0, n)
    {
        if (sum(i) < pi[i].second)
        {
            ans += (pi[i].second - sum(i));
            ll tt = pi[i].second - sum(i);
            add(i, tt);
            ll k = upper_bound(be(xx), 2 * d + xx[i]) - xx.begin();
            add(k, -tt);
        }
        //ca(n, now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
import math
n,k=map(int,input().split())
i=1
sum=0.0
for i in range(1,n+1):
    # cnt=k/i
    temp=1/n
    cnt=i
    m=0
    while cnt < k:
        cnt*=2
        m+=1
    # m=math.log2(cnt)
    # m=m//1
    # m+=1
    # if i <= k:
    sum+=temp * (1/2)**m
    # print(1/n * (1/2)**m)
print(sum)


Measured memory_bytes: 2940
import sys
N,M=map(int, sys.stdin.readline().split())

par=[ i for i in range(N+1) ]
size=[ 1 for i in range(N+1) ]

#Union Find
def root(x):
    while par[x]!=x:
        x=par[x]
    return x

def same(x,y):
	return root(x)==root(y)

def unite(x,y):
    x=root(x)
    y=root(y)
    if x==y: return
    if size[y]<size[x]: x,y=y,x
    size[y]+=size[x]
    par[x]=y

def getsize(x):
	return size[root(x)]

for _ in range(M):
    a,b=map(int, sys.stdin.readline().split())
    unite(a,b)

s=set()
for i in range(1,N+1):
    s.add(root(i))

print len(s)-1


Measured memory_bytes: 83472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
#define rep(i, n) for(long long (i) = 0; (i) < (long long)(n); (i)++)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll i,n,m;cin>>n>>m;vll a(n);rep(i,n){cin>>a[i];}
  //caricurate
  ll ans=0;set<ll> hanno;map<ll,ll> aoi;
  rep(i,n-1){a[i+1]+=a[i];}rep(i,n){a[i]%=m;hanno.insert(a[i]);aoi[a[i]]++;}
  for(auto yukimura=hanno.begin();yukimura!=hanno.end();yukimura++){
    if(*yukimura)ans+=(aoi[*yukimura]*(aoi[*yukimura]-1))/2;
    else ans+=(aoi[*yukimura]*(aoi[*yukimura]+1))/2;
  }
  //output
  cout<<ans<<endl;
}

Measured memory_bytes: 7936