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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  int x[3];

  forn(i,3) cin >> x[i];

  sort(x,x+3);

  cout << x[0] + x[1] << endl;

  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);
		String s = sc.next();
		if (s.charAt(s.length()-1)=='s') {
			System.out.println(s+"es");
		} else {
			System.out.println(s+"s");
		}
	}

}

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

  int n,m,num[100],g,get[100],blank,i,j;

  while(1){

  scanf("%d %d",&n,&m);
  if(n == 0) break;

  for(i = 0; i < m; i++){

    num[i]=i+1;
    get[i]=0;

  }

  for(j = 0; j < n; j++){

    for(i = 0; i < m; i++){

      scanf("%d",&g);
      get[i] += g;

    }

  }

  for(j = 0; j < m-1; j++){

    for(i = 0; i < m-1; i++){

      if(get[i] < get[i+1]){

	blank=get[i];
	get[i]=get[i+1];
	get[i+1]=blank;

	blank=num[i];
        num[i]=num[i+1];
        num[i+1]=blank;

      }

    }

  }

  printf("%d",num[0]);
  for(i = 1; i < m; i++) printf(" %d",num[i]);
  printf("\n");

  }

  return 0;

}

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

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	int nmax = A[N - 1];
	vector<pair<int, int>>P;
	for (int i = 0; i < N - 1; ++i) {
		P.push_back(make_pair(max(A[i], nmax - A[i]), A[i]));
	}
	sort(P.begin(), P.end());
	cout << nmax << " " << P[0].second << endl;
	return 0;
}


Measured memory_bytes: 4716
# AGC068
# 方針：１より多い枚数を数える。偶数に切り上げて全体から引く
n = gets.to_i
a = gets.split.map &:to_i

cnt = Hash.new(0)
n.times do |i|
  cnt[a[i]] += 1
end

sum = 0
cnt.values.each do |v|
  sum += v - 1
end

sum += 1 if sum.odd?
ans = n - sum
puts ans

Measured memory_bytes: 15364
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h: usize = iterator.next().unwrap().parse().unwrap();
    let w: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();
    let mut ichigo: Vec<bool> = Vec::new();
    let mut map: Vec<Vec<char>> = Vec::new();
    for _ in 0..h {
        let line: &str = iterator.next().unwrap();
        ichigo.push(line.contains('#'));
        map.push(line.chars().collect());
    }

    let mut result: Vec<Vec<usize>> = vec![vec![0; w]; h];
    let mut p = 1;
    for i in 0..h {
        if !ichigo[i] {
            continue;
        }
        let mut first = true;
        for j in 0..w {
            if map[i][j] == '#' {
                if first {
                    first = false;
                } else {
                    p += 1;
                }
            }
            result[i][j] = p;
        }
        p += 1;
    }
    for i in 1..h {
        if result[i][0] != 0 {
            continue;
        }
        if result[i - 1][0] == 0 {
            continue;
        }
        for j in 0..w {
            result[i][j] = result[i - 1][j];
        }
    }
    for i in (0..(h - 1)).rev() {
        if result[i][0] != 0 {
            continue;
        }
        if result[i + 1][0] == 0 {
            continue;
        }
        for j in 0..w {
            result[i][j] = result[i + 1][j];
        }
    }

    let mut ans = String::new();
    for row in result {
        let mut line = String::new();
        for c in row {
            line.push_str(&format!("{} ", c));
        }
        ans.push_str(&format!("{}\n", line.trim()));
    }
    return ans.trim().to_string();
}


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

int main(){

    string s;
    int n ,q;

    cin >> n;
    cin >> q;
    cin >> s;

    vector<int> v(n);
    for(int i = 1; i < n; i++){
        if(s[i-1] == 'A' && s[i] == 'C'){
            v[i] = v[i-1] + 1;
        }
        else{
            v[i] = v[i-1];
        }
    }


    int l,r;
    for(int i = 0; i < q; i++){
        cin >> l;
        cin >> r;
        cout << v[r-1] - v[l-1] << endl;
    }

}

Measured memory_bytes: 1408
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if (500 * i) + (100 * j) + (50 * k) == x:
                count += 1

print(count)

Measured memory_bytes: 3060
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

int main(int argc, char **argv)
{
	int N, M;
	scanf("%d%d", &N, &M);
	static int P[100001];
	int ac = 0, wa = 0;
	for (int i = 0; i < M; i++) {
		int p;
		char S[5];
		scanf("%d %s", &p, S);
		if (P[p] == -1)
			continue;
		if (S[0] == 'A') {
			++ac;
			wa += P[p];
			P[p] = -1;
		} else {
			P[p]++;
		}
	}
	printf("%d %d\n", ac, wa);
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  ll a,b,c;
  cin>>a>>b>>c;
  if(c-a-b>=0){
    if(4*a*b<(c-a-b)*(c-a-b))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  vi a(10), b(10);
  rep(i, 10) cin >> a[i];
  rep(i, 10) cin >> b[i];
  sort(rall(a)), sort(rall(b));
  cout << a[0] + a[1] + a[2] << ' ' << b[0] + b[1] + b[2] << endl;
}

Measured memory_bytes: 3092
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func nextLine() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	return sc.Text()
}

func main() {
	line := nextLine()
	texts := strings.Split(line, " ")
	r, _ := strconv.Atoi(texts[0])
	D, _ := strconv.Atoi(texts[1])
	x_2000, _ := strconv.Atoi(texts[2])

	x := x_2000
	for i := 0; i < 10; i++ {
		x = r*x - D
		fmt.Println(x)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

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

	bool f[4] = {};
	for (int i = 0; i < s.length(); i++) {
		switch (s[i]) {
		case 'N':
			f[0] = true;
			break;
		case 'S':
			f[1] = true;
			break;
		case 'E':
			f[2] = true;
			break;
		case 'W':
			f[3] = true;
			break;
		}
	}
	if (f[0] != f[1] || f[2] != f[3]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;


    class MainClass
    {
    public static void Main(string[] args)
    {
        string[] input1 = Console.ReadLine().Split(' ');

        int N = int.Parse(input1[0]);

        int M = int.Parse(input1[1]);

        string[] input2= Console.ReadLine().Split(' ');

        int[] A = new int[M];

        int sum = 0;
        for (int i = 0; i <= M - 1; i++)
        {
            A[i] = int.Parse(input2[i]);
            sum += A[i];
        }

        int result = N - sum;

        if (result < 0)
        {
            result = -1;
        }


        Console.WriteLine(result);
    }
}

Measured memory_bytes: 19284
#include <stdio.h>

int main(void)
{
  int n;
  int is_prime[999999];
  int i, j, cnt;

  is_prime[0] = 0;
  is_prime[1] = 0;
  for (i =2 ; i < 999999; i++) {
    is_prime[i] = 1;
  }

  while (scanf("%d", &n) != EOF) {
    cnt = 0;
    for (i = 2; i <= n; i++) {
      if (is_prime[i]) {
        cnt++;
        for (j = 2 * i; j <= n; j += i) {
          is_prime[j] = 0;
        }
      }
    }
    printf("%d\n", cnt);
  }

  return 0;
}

Measured memory_bytes: 4500
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

long long int pow2(long long int num){
	if(num == 0){
		return 1;
	}
	return 2 * pow2(num - 1);
}

int main(){
	
	int N, P;
	
	cin >> N >> P;
	
	bool flag = true;
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		if(num % 2 != 0){
			flag = false;
		}
	}
	
	long long int ans = 0;
	
	if(flag && P == 0){
		ans = pow2(N);
	}else if(flag){
		ans = 0;
	}else{
		ans = pow2(N - 1);
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] l = new int[N];
        for (int i = 0; i < l.length; ++i) {
            l[i] = sc.nextInt();
        }

        System.out.println(solve(l, K));

        sc.close();
    }

    static int solve(int[] l, int K) {
        return Arrays.stream(l).sorted().skip(l.length - K).sum();
    }
}

Measured memory_bytes: 29140
#include<stdio.h>
int main(){
  int n,a,b,cnt=0;
  scanf("%d",&n);
  for(a=1; a<=9; a++){
    for(b=1; b<=9; b++){
      if(a*b==n){
        cnt++;
      }
    }
  }
  if(cnt==0){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 128
m = 998244353
inv2 = (m + 1) / 2
n, s = gets.split.map(&:to_i)
dp = [0] * (s + 1)
dp[0] = 1
p2 = 1
gets.split.map(&:to_i).each{|a|
	p2 = p2 * 2 % m
	s.downto(a){|i|
		dp[i] = (dp[i] + dp[i - a] * inv2) % m
	}
}
puts dp[s] * p2 % m


Measured memory_bytes: 14376
import numpy as np

N, S = map(int, input().split())
A = tuple(map(int, input().split()))
MOD = 998244353

dp = np.zeros((N + 1, S + 1), dtype=np.int64)
dp[0][0] = 1
for i in range(N):
    dp[i + 1] = dp[i] * 2
    dp[i + 1, A[i]:] += dp[i, :-A[i]]
    dp[i + 1] %= MOD

print(dp[N][S])


Measured memory_bytes: 97240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  rep(i, n) a[i]--;
  vector<int> b(n);
  cin >> b;
  vector<int> c(n - 1);
  cin >> c;

  int ans = 0;
  rep(i, n) {
    ans += b[a[i]];
    if (i && a[i - 1] + 1 == a[i]) ans += c[a[i - 1]];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
import collections
import bisect

n, m = map(int, input().split())

s = [[int(_) for _ in input().split() ] for _ in range(m)]
a = collections.defaultdict(list)

for x,y in sorted(s):
    a[x]+=[y]
for x,y in s:
    z = bisect.bisect(a[x],y)
    print("%06d%06d"%(x,z))


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

#define lson rt << 1
#define rson rt << 1 | 1
#define mid ((l + r) >> 1)
#define Lson l, mid, lson
#define Rson mid + 1, r, rson
const int MAXN = 2500;
using pa = pair<int, int>;
using ll = long long;
const int MOD = 1e9 + 7;
ll dp[MAXN];
void init() {
    dp[0] = dp[1] = dp[2] = 1;
    for (int i = 3; i < MAXN; i++) {
        dp[i] = dp[i - 1] + dp[i - 3];
        dp[i] %= MOD;
    }
}

int main() {
    init();
    int n;
    cin >> n;
    if (n < 3) cout << 0 << endl;
    else cout << dp[n-3] << endl;
}


Measured memory_bytes: 3588
# -*- coding: utf-8 -*-
from collections import defaultdict
from pprint import pprint as pp
N = int(input())
abn = [list(map(int, input().split())) for _ in range(N-1)]

graph = defaultdict(lambda: defaultdict(int))

for a,b in abn:
    graph[a-1][b-1] = 1
    graph[b-1][a-1] = 1

# pp(graph)

def dist(x):
    que = [(x,0)]
    distance = [-1 for _ in range(N)]
    distance[x] = 0

    while len(que) > 0:
        i,tmpdist = que.pop(0)        

        for next in [k for k,v in  graph[i].items() if v == 1]:
            if distance[next] == -1:
                distance[next] = tmpdist + 1
                que.append((next, tmpdist + 1))

    return distance

distF = dist(0)
# pp(distF)
distS = dist(N-1)
# pp(distS)

Fcnt = 0
Scnt = 0
for f,s in zip(distF,distS):
    if f > s:
        Scnt += 1
    else:
        Fcnt += 1

if Fcnt > Scnt:
    print("Fennec")
else:
    print("Snuke")


Measured memory_bytes: 82140
#include<stdio.h>

int main() {
  int size;
  scanf("%d", &size);
  
  int ansCnt = 0;
  int JudSize;
  int MaxSize = 0;
  int i;
  for(i = 0; i < size; i ++){
    scanf("%d", &JudSize);

    if(MaxSize <= JudSize){
      ansCnt ++;
      MaxSize = JudSize;
    }
  }
  printf("%d", ansCnt);
  
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  const int MOD = 1'000'000'007;
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, 0, N) cin >> A[i];
  sort(all(A));

  int cnt = 1;
  if (N%2 == 1) {
    A.insert(A.begin(), 0);
    cnt = 0;
  }
  bool valid = true;
  for (int i=0; i<(int)A.size(); i+=2, cnt+=2) {
    if (A[i] != cnt || A[i+1] != cnt) {
      valid = false;
      break;
    }
  }
  if (!valid) {
    cout << 0 << endl;
    return;
  }

  int ans = 1;
  rep(i, 0, N/2) {
    ans = ans * 2 % MOD;
  }

  cout << ans << endl;
}

Measured memory_bytes: 896
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if ((a+b) % 3 == 0) {
			System.out.println("Possible");
		} else if (a % 3 == 0) {
			System.out.println("Possible");
		} else if (b % 3 == 0) {
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
		
		sc.close();
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int N, ans = 0;
string str;
map<string, int> mp;

int main(){
    cin >> N;
    while(N--){ cin >> str; mp[str] = 1;}
    for(auto i = mp.begin(); i != mp.end(); ++i) ans += i->second;
    cout << ans << endl;
    return 0;  
}

Measured memory_bytes: 19252
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
 
#define fr first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forln(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = 3.14159265358979323846264;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

random_device rd;
mt19937 SuperRandom(rd());



signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	ld l;
	cin >> l;
	ld ans = pow (l / 3.0, 3);
	cout << ans;







}

Measured memory_bytes: 384
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long a, b, c, k;
    scan(a, b, c, k);
    if (k % 2 == 0)
    {
        writeln(a - b);
    }
    else
    {
        writeln(b - a);
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pair<int,int> >
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pair<ll,ll> >
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

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

void solve()
{
    string s,r;
    cin>>s>>r;
    for(int i=0;i<sz(s);i++) {
        if(s[i]!=r[i]) {
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
}

int main()
{
    fastio;
    int t;
    
    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

bool isOk(string s)
{
    REP(i, s.size())
    {
        string swapS;
        REP(j, s.size())
        {
            if (j == i && j + 1 < s.size())
            {
                swapS += s[j + 1];
                swapS += s[j];
                j++;
            }
            else
            {
                swapS += s[j];
            }
        }
        REP(j, s.size() - 2)
        {
            string checkS = swapS.substr(j, 3);
            if (checkS == "AGC")
            {
                return false;
            }
        }
    }
    
    return true;
}

int main()
{
    ll N;
    cin >> N;
    vector<string> s = {"A", "C", "G", "T"};
    ll size = s.size();
    vector<string> last3vec;
    REP(i, size)
    {
        REP(j, size)
        {
            REP(k, size)
            {
                string t;
                t = s[i] + s[j] + s[k];
                if (t != "AGC" && t != "ACG" && t != "GAC")
                {
                    last3vec.push_back(t);
                }
            }
        }
    }

    map<string, ll> dp[N + 1];
    for (ll i = 3; i <= N; ++i)
    {
        REPV(it, last3vec)
        {
            if (i == 3)
            {               
                dp[i][*it] = 1;
            }
            else
            {
                dp[i][*it] = 0;
            }
        }
    }

    for (ll i = 4; i <= N; ++i)
    {
        REPV(it, last3vec)
        {
            REP(j, size)
            {
                string last4 = *it + s[j];
                if (isOk(last4))
                {
                    dp[i][last4.substr(1, 3)] += dp[i - 1][*it];
                    dp[i][last4.substr(1, 3)] = dp[i][last4.substr(1, 3)] % MOD;
                }
            }
        }
    }

    ll ans = 0;
    REPV(it, last3vec)
    {
        ans += dp[N][*it];
        ans = ans % MOD;
    }

    cout << ans << endl;
}


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

int main() {
    string S;
    cin>>S;
    int tmp;
    int ans = 1000;
    for(int i=0;i<S.size()-2;++i){
        tmp = stoi(S.substr(i, 3));
        if(ans > abs(753 - tmp))ans = abs(753 - tmp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N, D = map(int, input().split())
X = [0]*N
Y = [0]*N
for i in range(N):
    X[i], Y[i] = map(int, input().split())

def Main(N, D, X, Y):
    ans = 0
    for i in range(N):
        if X[i]**2+Y[i]**2 <= D**2:
            ans += 1
    return ans

print(Main(N, D, X, Y))
    


Measured memory_bytes: 24612
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
class Main{
    public static void main(String args[]){
	try{
	    int x[] = new int[10];
	    int a[] = {0,0,0};
	    int temp;
	    InputStreamReader is = new InputStreamReader(System.in);
	    BufferedReader br = new BufferedReader(is);
	    for(int i=0;i<10;i++){
		x[i] = Integer.parseInt(br.readLine());
		if(a[0] < x[i]){
		    temp = a[0];
		    a[0] = x[i];
		    x[i] = temp;
		}
		if(a[1] < x[i]){
		    temp = a[1];
		    a[1] = x[i];
		    x[i] = temp;
		}
		if(a[2] < x[i]){
		    temp = a[2];
		    a[2] = x[i];
		    x[i] = temp;
		}
	    }
	    System.out.println(a[0]);
	    System.out.println(a[1]);
	    System.out.println(a[2]);
	}
	catch(Exception e){
	    System.out.printf("error");
	}
    }
}

Measured memory_bytes: 16872
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
typedef pair<int,int> pi;
#define FAST ios_base::sync_with_stdio(0);
const int maxn = 100010;
 
string S;
int main() {
	cin >> S;
	int n = S.length();
	int ans1 =n,ans2 = n;
	S = '0' + S;
	for (int i =1;i<=n;i++) {
		int res;
		res = max(max(i-1,n-i), min(i,n-i+1));
		if (S[i] == '1') {
			//~ cout << i << " " << res << "\n";
			ans1 = min(ans1,res);
		} else {
			ans2 = min(ans2,res);
		}
	}
	cout << max(ans1,ans2);
}


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

int main (){
  int i,a,b,x;
  for( i = 1; i <= 4; i++ ){
  cin >> a >> b;
  if( a==1 ) x=b*6000;
  else if( a==2 ) x=b*4000;
  else if( a==3 ) x=b*3000;
  else if( a==4 ) x=b*2000;
  cout << x <<endl;
  }
  return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int H,W,N;
	cin >> H >> W >> N;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	vector<int> cnt(H * W);
	int count = 0;
	for(int i = 0;i < N;i++) {
		for(int j = 0;j < vec.at(i);j++) {
			cnt.at(count + j) = i + 1;
		}
		count += vec.at(i);
	}
	vector<vector<int>> ret(H,vector<int>(W));
	count = 0;
	for(int i = 0;i < H;i++) {
		if(i % 2 == 0) {
			for(int j = 0;j < W;j++) {
				ret.at(i).at(j) = cnt.at(count);
              	count++;
			}
		}
		else {
			for(int j = W - 1;j >= 0;j--) {
				ret.at(i).at(j) = cnt.at(count);
              	count++;
			}
		}
	}
	for(int i = 0;i < H;i++) {
		for(int j = 0;j < W;j++) {
			cout << ret.at(i).at(j);
			if(j == W - 1) {
				cout << endl;
			}
			else {
				cout << " ";
			}
		}
	}
}

Measured memory_bytes: 512
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000


P,Q,R = map(int,input().split())
a = [P,Q,R]
a.sort()
print(a[0]+a[1])


Measured memory_bytes: 7868
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin >> a;
  cin >> b;
  int count = 0;
  
  for(int i = 0;i<a.size();i++){
    if(a.at(i) != b.at(i)){
      count++;
    }
  }
  
  cout << count << endl; 
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    string s;
    cin >> s;
    string t = {"keyence"};
    int flag = 0,l = 0,r = 0;
    for(int i = 0; i < t.length(); i++){
        if(s[i] == t[i]) r++;
        else break;
        //cout << i << endl;
    }
    for(int i = 0; i < t.length(); i++){
        if(s[s.length()-1-i] == t[t.length()-1-i]) l++;
        else break;
        //cout << i << endl;
    }
    if(l+r >= 7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

void Main() {
  int S, W;
  cin >> S >> W;

  if (W >= S) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 3652
#include <stdio.h>

double aveTmp(int t,int x)
{
	return t-0.006*x;
}

double myabs(double a,double b)
{
	if (a<b) return b-a;
	else return a-b;
}

int main(void)
{
	int n,i,minNum;
	int t,h;
	double a,tmp,min=9999999;
	scanf("%d",&n);
	scanf("%d %lf",&t,&a);

	for (i=0;i<n;i++) {
		scanf("%d",&h);
		tmp = aveTmp(t,h);
		tmp = myabs(a,tmp);
		if (min > tmp) {
			min = tmp;
			minNum = i;
		}
	}
	printf("%d\n",minNum+1);

	return 0;
}


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

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

    vector<int> a(N);
    rep(i, N) {
        cin >> a.at(i);
    }

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

    int ans = 0;
    rep(i, N) {
        if (i % 2 == 0) {
            ans += a.at(i);
        } else {
            ans -= a.at(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- encoding: UTF-8 -*-
s = input()
 
dic = {}
 
for i in range(4) :
    a = s[i]
    if not (a in dic) :
        dic[a]=0
    dic[a] = dic[a] +1

result = "No"

count =0
for val in dic.values():
    if val == 2 :
        count = count +1

if count == 2:
    print("Yes")
else :
    print("No")
    

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;

    int i = S.length() - T.length();
    bool match;

    for (; i >= 0; i--) {
        match = true;
        for (int j = 0; j < T.length(); j++) {
            if (S[i + j] != '?' && S[i + j] != T[j]) {
                match = false;
                break;
            }
        }
        if (match) break;
    }

    char ans[51];
    if (match) {
        for (int j = 0; j < S.length(); j++) {
            if (S[j] == '?') {
                ans[j] = 'a';
            } else {
                ans[j] = S[j];
            }
        }
        for (int j = 0; j < T.length(); j++) {
            ans[i + j] = T[j];
        }
        ans[S.length()] = '\0';
    } else {
        strcpy(ans, "UNRESTORABLE");
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
let () =
  let open Stack in
  let s = create () in
  let l = Str.split (Str.regexp " ") (read_line ()) in
  let doit = function
    | "+" -> let x = pop s and y = pop s in push (y + x) s
    | "-" -> let x = pop s and y = pop s in push (y - x) s
    | "*" -> let x = pop s and y = pop s in push (y * x) s
    | n -> push (int_of_string n) s
  in
  List.iter doit l;
  Printf.printf "%d\n" (pop s)

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

struct UnionFind
{
    vector<int> par;
    UnionFind(int n=0) : par(n, -1) {}
    int find(int x)
    {
        if(par.at(x) < 0) return x;
        return par.at(x) = find(par.at(x)); 
    }
    bool unite(int x, int y)
    {
        int rx = find(x);
        int ry = find(y);
        if(rx == ry) return false;
        if(par.at(rx) > par.at(ry)) swap(rx, ry);
        par.at(rx) += par.at(ry);
        par.at(ry) = rx;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -par.at(find(x));}
};

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;

    UnionFind uf(N);
    for(int i=0; i<M; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
    }

    int ans = 0;
    for(int i=0; i<N; i++)
    {
        chmax(ans, uf.size(i));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3988
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int ans = 0;
    string s;
    cin >> s;

    if (s == "RRR")
    {
        cout << 3 << endl;
    }
    else if (s == "RSR" || s == "SSR" || s == "SRS" || s == "RSS")
    {
        cout << 1 << endl;
    }
    else if (s == "RRS" || s == "SRR")
    {
        cout << 2 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3600
#include<stdio.h>
int main(){
  int N,i,j4=0,j2=0,x;
  scanf("%d", &N);
  for(i=0;i<N;i++){
    scanf("%d",&x);

    if(x%4==0){
      j4++;
    }
    else if(x%2==0){
      j2++;
    }
  }
  if(j2==0){
    if(N-j2-j4-1<=j4){
      printf("Yes");
    }
    else{
      printf("No");
    }
  }
  else{
    if(N-j2-j4<=j4){
      printf("Yes");
    }
    else{
      printf("No");
    }
  }
  return 0;
}


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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
//------------------------------------------------------

string ask(int q) {
    cout << q << endl;
    string s;
    cin >> s;
    if (s == "Vacant") exit(0);
    return s;
}

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

    int n;
    cin >> n;
    string s0 = ask(0);
    ask(n - 1);
    int lo = 0, hi = n - 1;
    int mi = (lo + hi) / 2;
    while (1) {
        if ((s0 == ask(mi)) ^ (mi % 2 == 0)) hi = mi - 1;
        else lo = mi + 1;
        mi = (lo + hi) / 2;
    }
    return 0;
}



Measured memory_bytes: 852
n = int(input());
x = 0;
y = 0;
for i in range(0,n):
    a,b = map(str,input().split());
    if a > b:
        x += 3;
    elif a < b:
        y += 3;
    else:
        x += 1;
        y += 1;

print(x,y);


Measured memory_bytes: 5600
def ceil(x, y):
    return (x - 1) // y + 1


n = int(input())
ta = [map(int, input().split()) for _ in range(n)]

votes = [1, 1]

for t, a in ta:
    mul = max(ceil(votes[0], t), ceil(votes[1], a))
    votes = [t * mul, a * mul]

ans = sum(votes)
print(ans)


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if((i+j)&1^1){
                v[i][j] = 1;
            }
        }
    }
    vector<pair<int, int>> ans;
    for (int i = 1; i < n; i += 6) {
        for (int j = 0; j < n; j += 2) {
            if(!v[i][j]){
                v[i][j] = 1;
                ans.emplace_back(i, j);
            }
        }
    }
    for (int i = 4; i < n; i += 6) {
        for (int j = 1; j < n; j += 2) {
            if(!v[i][j]){
                v[i][j] = 1;
                ans.emplace_back(i, j);
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        if(!v[i][0]){
            v[i][0] = 1;
            ans.emplace_back(i, 0);
        }
        if(!v[n-1][i]){
            v[n-1][i] = 1;
            ans.emplace_back(n-1, i);
        }
        if(!v[i][n-1]){
            v[i][n-1] = 1;
            ans.emplace_back(i, n-1);
        }
    }
    cout << ans.size() << "\n";
    for (auto &&k : ans) {
        printf("%d %d\n", k.first, k.second);
    }
    return 0;
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
 ll n; cin>>n;
 ll sum = 0;
 rep1(i,n) if(i%3!=0&&i%5!=0)sum +=i;
 cout<<sum<<endl;
}

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

int main() {
  string s;
  cin >> s;
  vector<int> cnt(2, 0);
  rep(i,s.size()) {
    cnt[s.at(i)-'0']++;
  }
  cout << 2*min(cnt[0], cnt[1]) << endl;
  return 0;
}


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


using namespace std;


const int N = 100100;

long long v[N], iv[N];
int crive[N];
vector <long long> prime;
map <long long, int> cnt;

int main() {
	int n;
	scanf("%d", &n);


	for (int i = 0; i < n; ++i) {
		scanf("%lld", &v[i]);
	}
	for (int i = 2; i < 100010; ++i) {
		crive[i] = 1;
	}
	for (int i = 2; i < 100010; ++i) {	
		if(crive[i] == 1){
			for (int j = 2*i; j < 100010; j += i) {
				crive[j] = 0;
			}
		}
	}
	for (int i  = 2; i <= 2200; ++i) {
		if (crive[i]) {
			prime.push_back(i);
		}
	}

	for (int i = 0; i < n; ++i) {
		long long tmp = v[i];
		iv[i] = 1;

		for (long long p: prime) {
			long long p3 = p * p * p;
			while(v[i] % p3 == 0){
				v[i] /= p3;
				tmp /= p3;
			}
			if(v[i] % (p*p) == 0) {
				iv[i] *= p;
			}
			else if(v[i] % (p) == 0) {
				iv[i] *= p*p;
			}
			while(tmp % p == 0) tmp /= p;
		}
		long long sq = (int) sqrt((double) tmp);
		if(sq * sq == tmp) iv[i] *= sq;
		else iv[i] *= tmp*tmp;
		if(cnt.find(v[i]) == cnt.end()){
			cnt[v[i]] = 1;
		}
		else{
			cnt[v[i]]++;
		}
	}

	bool isone = false;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (v[i] == 1) isone = true;
		if (v[i] >= 2) {
			ans += max(cnt[v[i]], cnt[iv[i]]);
			cnt[v[i]] = 0;
			cnt[iv[i]] = 0;
		}	
	}

	printf("%d\n", ans+isone);

}

Measured memory_bytes: 14720
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int D,T,S;
    cin >> D >> T >> S;
    int TT = D/S;
    if(D%S!=0) TT = D/S+1;

    if(TT<=T) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// 出力
		if(a == 0) {
          System.out.println("1");
        } else {
          System.out.println("0");

          
        }
	}
}

Measured memory_bytes: 35616
using System;

namespace MyProgram{
    class AtCoder{
        static void Main(string[] args){
            long N = long.Parse(Console.ReadLine());
            long[] A = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            long[] B = new long[N];
            for(var i=0;i<N;i++){
                B[A[i]-1] = i+1;
            }
            for(var i=0;i<N;i++){
                Console.Write(B[i]+" ");
            }
        }
    }
}

Measured memory_bytes: 25688
use std::cmp::max;
use proconio::input;

fn main() {
	input!(n: usize, a: [(i64, i64, i64); n]);

	let mut dp = vec![(0, 0, 0)];
	for i in 0..n {
		dp.push((
			a[i].0 + max(dp[i].1, dp[i].2),
			a[i].1 + max(dp[i].2, dp[i].0),
			a[i].2 + max(dp[i].0, dp[i].1)));
	}

	println!("{}", max(dp[n].0, max(dp[n].1, dp[n].2)));
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;
 
  int sz;
  vector< Monoid > seg;
 
  const F f;
  const Monoid M1;
 
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
 
  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }
 
  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
 
  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};


signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    llong x;
    cin >> N >> x;
    SegmentTree<llong> seg(2 * N, [](llong a, llong b) {return min(a, b); }, LONG_MAX);
    rep(i, N) {
        llong a;
        cin >> a;
        seg.set(i, a);
        seg.set(i + N, a);
    }

    seg.build();
    priority_queue<llong, vector<llong>, greater<llong> > PQ;
    rep(k, N) {
        llong ans = k * x;
        rep(i, N) {
            ans += seg.query(N + i - k, N + i + 1);
        }
        PQ.push(ans);
    }

    cout << PQ.top() << endl;

    return 0;
}

Measured memory_bytes: 384
import java.io.*;
public class Main {
	public static void main(String... args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";
		double x[] = new double[20];
		double y[] = new double[20];
		int i = 0;
		while ((line = br.readLine() ) != null){
			String numbers[] = line.split(",");
			x[i] = Double.parseDouble(numbers[0])-x[0];
			y[i] = Double.parseDouble(numbers[1])-y[0];				
			i++;
		}
		double area = 0;
		for (int k = 1; k<i; k++){
			area += x[k]*y[k+1]-x[k+1]*y[k];
		}
		System.out.println(Math.abs(area*0.5));
	}
}

Measured memory_bytes: 24288
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  int n;
  cin >> n;
  vi t(n);
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int p, x;
    cin >> p >> x;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (i == p - 1) {
        ans += x;
      } else {
        ans += t[i];
      }
    }
    D(ans);
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;

    vvc ans(h+2, vc(w+2, '#'));
    rep(i, h) rep(j, w) cin >> ans[i+1][j+1];
    rep(i, h+2) {
        rep(j, w+2) {
            cout << ans[i][j];
        } 
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char a[114514];gets(a);
    for(int i=0;i<3;i++){
        if(a[i]=='1'){printf("%d",9);}else if(a[i]=='9'){printf("%d",1);}else{printf("%d",a[i]);}
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128