akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] p = new int[m];
        int[] y = new int[m];
        ArrayList<ArrayList<Integer>> pref = new ArrayList<ArrayList<Integer>>();
        for (int i = 0; i < n + 1; i++) pref.add(new ArrayList<Integer>());
        for (int i = 0; i < m; i++) {
            p[i] = sc.nextInt();
            y[i] = sc.nextInt();
            pref.get(p[i]).add(y[i]);
        }
        for (int i = 1; i <= n; i++) Collections.sort(pref.get(i));
        for (int i = 0; i < m; i++) {
            String s = String.valueOf(p[i]);
            while (s.length() < 6) s = "0" + s;
            System.out.print(s);
            int l = 0, r = pref.get(p[i]).size();
            while (r - l > 1) {
                int c = (l + r) / 2;
                int yc = pref.get(p[i]).get(c);
                if (yc == y[i]) { l = c; break;}
                if (yc > y[i]) r = c;
                else l = c + 1;
            }
            s = String.valueOf(l + 1);
            while (s.length() < 6) s = "0" + s;
            System.out.println(s);
        }
    }
}

Measured memory_bytes: 118948
n,k,*rsp=(gets+gets).split.map &:to_i
t=gets.chomp.chars.map{|c| "spr".index(c) }
prev=[3]*k
p t.reduce(0){|s,e|
  pe=prev.shift
  if pe==e
    prev.push(3)
  else
    s+=rsp[e]
    prev.push(e)
  end
  s
}


Measured memory_bytes: 11260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

struct edge {
	int from, to, weight;
};

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int L, n, m;
	int back_up_L;
	cin >> L;
	back_up_L = L;
	n = 0;
	while(L) {
		L >>= 1;
		n++;
	}
	n--;
	L = back_up_L;

	vector<edge> ret;
	rep(i,0,n) {
		ret.pb({i,i+1,1<<i});
		ret.pb({i,i+1,0});
	}
	int now = (1<<n);
	rep(i,0,n) {
		if(L & (1<<i)) {
			int j = (1<<(i+1))-1;
			int w = L & ~j;
			ret.pb({i,n,w});
		}
	}
	cout << n+1 << " " << ret.size() << endl;
	rep(i,0,sz(ret)) {
		edge e = ret[i];
		cout << e.from+1 << " " << e.to+1 << " " << e.weight << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()
    q = int(input())
    k = list(map(int, input().split()))
    for ki in k:
        ans = 0
        DMC = [0]*3
        for i in range(n):
            c = s[i]
            if c == "D":
                DMC[0] += 1
            elif c == "M":
                DMC[1] += 1
                DMC[2] += DMC[0]
            elif c == "C":
                ans += DMC[2]
            if i >= ki-1:
                j = i-ki+1
                if s[j] == "D":
                    DMC[0] -= 1
                    DMC[2] -= DMC[1]
                elif s[j] == "M":
                    DMC[1] -= 1
        print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 55804
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<(int)n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<=(int)n:i>=(int)n;k<n?i++:i--)
#define input(v,n) fo(i,n)cin>>v[i]
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pi;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667
const int inf = numeric_limits<int> :: max();
// ===================== MANASH =================== //

int n,m;

void test() {

    int happy = 0;
    cin >> n;
    happy += (n/500)*(1000);
    n %= 500;
    happy += (n/5)*5;
    cout << happy;
}

signed main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif

    int T = 1;
    //cin >> T;
    while(T--) {
        test();
        cout << "\n";
    }
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << 60 * (H2 - H1) + (M2 - M1) - K << endl;
}

Measured memory_bytes: 3568
def modpow(a, n, m):
    r = 1
    while n > 0:
        if n & 1:
            r = r*a % m
        a = a*a % m
        n >>= 1
    return r

N = int(input())
X = input()
d = sum([y == '1' for y in X])
A,B = 0,0
f = list([0 for _ in range(N+1)])

for i in range(N):
	if X[i] == '1':
		if not d==1:
			A += modpow(2, N-i-1, d-1)
		B += modpow(2, N-i-1, d+1)
	t,c = i+1,0
	for j in range(18):
		if t & 1<<j:
			c += 1
	f[t] = f[t%c]+1

for i in range(N):
	c = 0
	if X[i]=='1' and not d==1:
		c = f[(A-modpow(2,N-i-1,d-1))%(d-1)]+1
	elif X[i] == '0':
		c = f[(B+modpow(2,N-i-1,d+1))%(d+1)]+1
	print(c)

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

// aを常に小さい値にする　大きい値にする
template<class T> void chmin(T &a, T b){
    if(a>b) {
        a = b;
    }
}
template<class T> void chmax(T &a, T b){ if(a<b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

// 最大公約数を求める GCD
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

/*
 *
 * 　操作は結局何をしているのか簡単に言い換えられるかかが大事！！
 *
 * マイナスが偶数個だったらマイナス全部消せる
   マイナスが奇数個だったらマイナスが 1 個だけ残る この際一番絶対値が小さいところにマイナスをつければ OK

 * */

int main() {

    int N;
    cin >> N;
    ll A[N];
    rep(i,N) cin >> A[i];

    int num_minus = 0;
    ll mi = 1LL<<60;
    ll sum = 0;

    rep(i,N){
        if(A[i] < 0){
            num_minus++;
        }
        chmin(mi, abs(A[i]));
        sum += abs(A[i]);
    }

    if (num_minus % 2 == 0) cout << sum << endl;
    else cout << sum - mi*2 << endl;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
int a, b, c, d;
/**********************************************/

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

    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var nl = CRL().ArrayInts();
        var n = nl[0];
        var l = nl[1];
        var strs = new List<string>();
        for (int i = 0; i < n; i++)
        {
            strs.Add(CRL());
        }

        strs.Sort();
        CWL(strs.Join());
    }
}

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this double d) => (int) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();

    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);

    public static long LCM(long a, long b) => a * b / GCD(a, b);

    //テンプレここまで
}

Measured memory_bytes: 13536
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define FOR(i,a,b) for(long long int i=a;i<b;i++)
#define sz(s) (long long int)(s).size()
#define pb push_back
#define mp make_pair
const ll inf = 1000000000;
const ll MOD = 1000000007;

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    cout.tie(NULL);
    register ll i,j,k,x,y,m,n,t,q,temp,sum=0,count=0,f=1;
    string s;
    cin>>s;
    if(s == "ABC"){
        cout<<"ARC";
    }else{
        cout<<"ABC";
    }
}    
    

Measured memory_bytes: 3580
N,M = map(int,input().split())
sets = []
for _ in range(N):
    sets.append(list(map(int,input().split())))
    
def mergesort(sets):
    if len(sets) == 1:
        return [sets[0]]
    else:
        leng = len(sets)
        sets1 = mergesort(sets[:leng//2])
        sets2 = mergesort(sets[leng//2:])
        return merge(sets1,sets2)

def merge(set1,set2):
    i=0
    j=0
    result = []
    for _ in range(len(set1)+len(set2)):
        if i<len(set1) and j<len(set2):
            if set1[i][0] >= set2[j][0]:
                result.append(set2[j])
                j += 1
            elif set2[j][0] > set1[i][0]:
                result.append(set1[i])
                i += 1
        elif i == len(set1):
            result.append(set2[j])
            j += 1
        elif j == len(set2):
            result.append(set1[i])
            i += 1
    return result

def minimummoney(m,sets):
    sets = mergesort(sets)
    rest = m
    cost = 0
    for i in range(len(sets)):
        if rest > sets[i][1]:
            cost += sets[i][0]*sets[i][1]
            rest -= sets[i][1]
            continue
        if 0 < rest and rest <= sets[i][1]:
            cost += rest * sets[i][0]
        break
    return cost

print(minimummoney(M,sets))

Measured memory_bytes: 29320
import java.util.Scanner;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    if(c>a+b&&4*a*b<(c-a-b)*(c-a-b)){
      System.out.print("Yes");
    } else {
      System.out.print("No");
    };
  }
}

Measured memory_bytes: 22996
import math
N = int(input())
n = 100

x = [None] * N
y = [None] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

ans = 0
for i in range(n):
    theta = (2 * math.pi / n) * i
    c = math.cos(theta)
    s = math.sin(theta)
    tmp_x = 0
    tmp_y = 0
    for j in range(N):
        if x[j] * c + y[j] * s > 0:
            tmp_x += x[j]
            tmp_y += y[j]
    if tmp_x**2 + tmp_y**2 > ans**2:
        ans = math.sqrt(tmp_x**2 + tmp_y**2)

print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  



int main(){
  int n;  cin >> n;
  map<int, int> odd, even;
  for(int i=0; i<n; i++){
    int x;  cin >> x;
    if(i%2==1) even[x] += 1;
    else odd[x] += 1;
  }
  

  int okey1, oc1=0, oc2=0; 
  int ekey1, ec1=0, ec2=0; 
  for(auto x: odd){
    if(oc1<x.second){
      oc2 = oc1;  
      oc1 = x.second; okey1 = x.first;
    }else if(oc2<x.second){
      oc2 = x.second; 
    }
  }
  for(auto x: even){
    if(ec1<x.second){
      ec2 = ec1;  
      ec1 = x.second; ekey1 = x.first;
    }else if(ec2<x.second){
      ec2 = x.second;
    }
  }
  ll ans = 0;
  if(okey1==ekey1){
    ans = n - max(oc1+ec2, oc2+ec1);
  }else ans = n - (ec1+oc1);

  cout << ans << endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
int main(void){
  long int n,b,r,k,s;
  scanf("%ld %ld %ld",&n,&b,&r);
  k=(n/(b+r))*b;
  s=n%(b+r);
  if(s<=b){printf("%ld",k+s);}
  else{printf("%ld",k+b);}
  return 0; }


Measured memory_bytes: 1728
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"


#define REP(i,n) for(int i=0;i<n;++i)

string T, P;
struct SuffixArray {
	struct SAComp {
		const int h; const vector<int> &g;
		SAComp(const int h_, const vector<int>&g_) : h(h_), g(g_) { ; }
		bool operator() (int a, int b) {
			return a == b ? false : g[a] != g[b] ? g[a] < g[b] : g[a + h] < g[b + h];
		}
	};

	static const int SIZE = 100000;
	int n;
	string str;
	vector<int> sa;
	vector<int> lcp;

	SuffixArray() { ; }
	SuffixArray(const string t) :str(t) {
		Init();
	}
	void Init() {
		n = str.size();
		buildSA();
		buildLCP();
	}

	// O(mlogn)

	////??????°????????????
	//int find(const string p) {
	//  int m = p.size();
	//  int left = 0;
	//  int right = n-m;
	//  while (left < right) {
	//      int mid = (left + right) / 2;
	//      if (str.substr(sa[mid],m)<p.substr(0,m)) { left = mid + 1; }
	//      else { right = mid; }
	//  }
	//  return str.substr(sa[left], m)== p.substr(0, m)? sa[left] : -1;
	//}
private:
	//O(nlog^2n)
	void buildSA() {
		sa = vector<int>(n + 1);
		vector<int>g(n + 1);
		vector<int>b(n + 1);
		REP(i, n + 1) { sa[i] = i; g[i] = str[i]; }
		b[0] = 0;
		b[n] = 0;
		SAComp f(0, g);
		sort(sa.begin(), sa.end(), SAComp(0, g));
		for (int h = 1; b[n] != n; h *= 2) {
			SAComp comp(h, g);
			sort(sa.begin(), sa.end(), comp);
			REP(i, n) b[i + 1] = b[i] + comp(sa[i], sa[i + 1]);
			REP(i, n + 1) g[sa[i]] = b[i];
		}
	}
	void buildLCP() {
		lcp = vector<int>(n + 1);
		int h = 0;
		vector<int>b(n + 1);
		REP(i, n + 1) { b[sa[i]] = i; }
		REP(i, n + 1) {
			if (b[i]) {
				for (int j = sa[b[i] - 1]; j + h < n && i + h < n && str[j + h] == str[i + h]; h++) { ; }
				lcp[b[i]] = h;
			}
			else {
				lcp[b[i]] = -1;
			}
			if (h > 0) { h--; }
		}
	}
};

int main() {
	cin >> T >> P;
	vector<int>newsa;
	{
		SuffixArray asa(T);
		vector<int>oldsa = asa.sa;
		for (auto s : oldsa) {
			newsa.push_back(s);
		}
	}

	int r, l;
	{
		int amin = -1;
		int amax = newsa.size();
		while (amin + 1 != amax) {
			int amid = (amin + amax) / 2;
			string ast = T.substr(newsa[amid], P.size());
			if (ast <= P)amin = amid;
			else amax = amid;
		}
		r = amax;
	}
	{
		int amin = -1;
		int amax = newsa.size();
		while (amin + 1 != amax) {
			int amid = (amin + amax) / 2;
			string ast = T.substr(newsa[amid], P.size());
			if (ast < P)amin = amid;
			else amax = amid;
		}
		l = amax;
	}
	vector<int>nums;
	for (int i = l; i < r; ++i) {
		nums.push_back(newsa[i]);
	}
	sort(nums.begin(), nums.end());
	for (auto n : nums) {
		printf("%d\n", n);
	}

	return 0;
}

Measured memory_bytes: 24660
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    unsigned int a,b,i,l,y1=0,y2=0,y3=1,y4=1,me;
    string s;
    cin>>a>>b;
    cin>>s;
    l=s.length();
    if (l==(a+b+1)) y1=1;
    if(s[a]=='-') y2=1;
    for(i=0;i<a;i++)
    {
        me=s[i];
        if(me<48||me>57) {y3=0; break;}
    }
     for(i=a+1;i<l;i++)
    {
        me=s[i];
        if(me<48||me>57) {y4=0; break;}
    }
    if(y1&&y2&&y3&&y4) cout<<"Yes";
else cout<<"No";
}

Measured memory_bytes: 256
def solve():
    A = [0]*N
    A[-1] = 10**6
    A[0] = 10**6
    for i in range(N-2,0,-1):
        A[i] = min(B[i], B[i-1])
#        print(i)
    A[-1] = B[-1]
    A[0] = B[0]
#    print(A)
    print(sum(A))

if __name__ == "__main__":
    N = int(input())
    B = list(map(int, input().split()))
    solve()  


Measured memory_bytes: 9060
/**
 * C - Welcome to AtCoder
 * https://atcoder.jp/contests/abc151/tasks/abc151_c
 **/
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int main() {
    int n, m; cin >> n >> m;
    map<int, map<string, int>> d;
    int c=0, p=0;
    for(int i=0; i<m; i++) {
        int pi;
        string si;
        cin >> pi >> si;
        if(si=="AC") {
            if(d[pi].count("AC")) {
                d[pi][si]++;
            } else {
                d[pi]["AC"] = 1;
            }
        } else {
            // WA
            if(d[pi]["AC"]==0) {
                if(d[pi].count("WA")) {
                    d[pi][si] += 1;
                } else {
                    d[pi][si] = 1;
                }
            }
        }
    }

    for(int i=1; i<n+1; i++) {
        if(d[i]["AC"]>=1) {
            c++;
            p += d[i]["WA"];
        }
    }

    cout << c << " " << p << endl;
    return 0;
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
#include <iomanip>
#define m 1000000007
using namespace std;
typedef long long ll;
vector<int> adj[1001];
int visited[1001]={0};

int main()
{
    ll n;
    cin>>n;
    double a[n],ans=0;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }

    for (int i = 0; i < n; ++i)
    {
        ans+=(1/a[i]);
    }
    cout<<setprecision(20)<<1/ans;
}


Measured memory_bytes: 256
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int n,b,f,r,v;
	int A[5][4][11]={};
	cin>>n;

	for (int i=0;i<n;i++){
		cin>>b>>f>>r>>v;
		A[b][f][r]+=v;
	}


	for (int b=1;b<=4;b++){
		if (b>1)cout<<"####################\n";
		for (int f=1;f<=3;f++){
			for (int r=1;r<=10;r++){
				cout<<" "<< A[b][f][r];
			}
			cout<<endl;

		}
	}


	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    int A,B,K;
    int count=0;
    cin >> A >> B >> K;
    for(int i=100;i>0;i--){
        if(A%i==0&&B%i==0){
            count++;
            if(count==K){
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N;
    int count;
    int ans = 0;
    int i, j;

    scanf("%d", &N);

    for(i=105; i<=N; i+=2){
        count = 0;
        for(j=1; j<=i; j++){
            if(i%j == 0){
                count += 1;
            }
        }
        if(count==8){
            ans += 1;
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	sort(s.begin(),s.end());
	if(s.size()==4&&s[0]==s[1]&&s[3]==s[2]&&s[0]!=s[3])
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll  longinf = 1LL<<60;
const int mod=1000000007;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
ll fact(ll x){
  if(x==0)
    return 1;
  else 
    return (x*fact(x-1))%mod;
  }
int main(){
  ll n,m;
  cin>>n>>m;
  ll ans=0;
  if(n==m)
    ans=(2*fact(n)*fact(m))%mod;
  if(n==m+1||n==m-1)
    ans=(fact(n)*fact(m))%mod;
  cout<<ans<<endl;
  return 0;
  }






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

void rotate(int& a, int&b, int&c, int&d){
  int aa = a;
  int bb = b;
  int cc = c;
  int dd = d;
  a = dd;
  b = aa;
  c = bb;
  d = cc;
};

int main(){
  char op[8];
  int num;
  int dice[6];
  int temp[4];
  int sum;

  while(cin >> num && num){
    dice[0] = 1;
    dice[1] = 6;
    dice[2] = 5;
    dice[3] = 3;
    dice[4] = 2;
    dice[5] = 4;
    sum = 1;
  for(; num; num--){
    cin >> op;
    if(!strcmp(op, "North")) rotate(dice[0], dice[2], dice[1], dice[4]);
    else if(!strcmp(op, "East")) rotate(dice[0], dice[3], dice[1], dice[5]);
    else if(!strcmp(op, "South")) rotate(dice[0], dice[4], dice[1], dice[2]);
    else if(!strcmp(op, "West")) rotate(dice[0], dice[5], dice[1], dice[3]);
    else if(!strcmp(op, "Right")) rotate(dice[2], dice[3], dice[4], dice[5]);
    else if(!strcmp(op, "Left")) rotate(dice[5], dice[4], dice[3], dice[2]);
    sum += dice[0];
  }
  cout << sum << "\n";
}

return 0;
}

Measured memory_bytes: 3068
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n"
using namespace std;
using ll=long long;
using ld=long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using vlll = vector<vector<vector<ll>>>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) {
            for (auto vvv : vv) cout << vvv << " ";
            cout << endl;
        }
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

dbg::Debug debug;

class ASheepAndWolves {
public:
	void solve(std::istream& in, std::ostream& out) {
		int s, w;
		in >> s >> w;

		if(w >= s) out << "unsafe" << enl;
		else out << "safe" << enl;
	}
};


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	ASheepAndWolves solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = Integer.parseInt(sc.next());
		int n = Integer.parseInt(sc.next());

		int[] house = new int[n];
		for (int i = 0; i < n; i++) {
			house[i] = Integer.parseInt(sc.next());
		}
		int[] area = new int[n];
		for (int i = 0; i < n; i++) {
			if (i == n - 1) {
				area[i] =  house[0]+k-house[i];
			} else {
				area[i] = house[i + 1] - house[i];
			}
		}
		Arrays.sort(area);
		int length = 0;
		for (int i = 0; i < n - 1; i++) {
			length += area[i];
		}
		System.out.println(length);

	}

}


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

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

    int count = 0;
    vector <char> ans(0);

    for(int i=0; i<s.size(); i++){
        if((s[i] == '1') || (s[i] == '0')){
            ans.push_back(s[i]);
            count ++;
        }
        else{
            if (count > 0){
                int size = ans.size();
                ans.resize(size-1);
                count --;
            }
        }
    } 
    rep(i,ans.size()){
        cout << ans[i];
    }
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

turn_no = 0
while True:
    if turn_no % 2 == 0:
        C -= B
        if C <= 0:
            print("Yes")
            break
    else:
        A -= D
        if A<= 0:
            print("No")
            break
    turn_no += 1

Measured memory_bytes: 9180
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) //cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
#define int long long
using pii = pair<int,int>;
signed main(){
    int n,k;
    cin >> n >> k;
    vector<pii>a;
    rep(i,n){
        int t,d;
        cin >> t >> d;
        a.emplace_back(d,t);
    }
    sort(a.rbegin(),a.rend());
    int ans = 0;
    set<int>st;
    priority_queue<int,vector<int>,greater<int>>b;
    priority_queue<int>c;
    rep(i,k){
        ans += a[i].first;
        if(st.count(a[i].second)){
            b.push(a[i].first);
        }
        st.insert(a[i].second);
    }
    int x = (int)st.size();
    int sum = ans;
    show(sum);
    ans += x*x;
    rep(i,n){
        if(i<k)continue;
        if(st.count(a[i].second)==0){
            c.push(a[i].first);
            st.insert(a[i].second);
        }
    }
//    cout << b.size() << " " << c.size() << endl;
    while(b.size() and c.size()){
        int K = b.top();
        show(K);
        b.pop();
        sum-=K;
        K = c.top();
        c.pop();
        sum += K;
        x++;
        int temp = sum+x*x;
        show(x);
        show(temp);
        ans = max(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6896
from sys import exit
EPS = 1e-6

#外積
def OuterProduct(one, two):
	tmp = one.conjugate() * two
	return tmp.imag

#内積
def InnerProduct(one, two):
	tmp = one.conjugate() * two
	return tmp.real

#点が線分上にあるか
def IsOnSegment(point, begin, end):
	if abs(OuterProduct(begin-point, end-point)) <= EPS and InnerProduct(begin-point, end-point) <= EPS:
		return True
	else:
		return False

#直線の交点，平行の場合はNoneを返す
def Crosspoint(a, b, c, d):
	if abs(OuterProduct(b-a, d-c)) <= EPS:
		return None
	else:
		u = OuterProduct(c-a, d-a) / OuterProduct(b-a, d-c)
		return (1-u)*a + u*b

n = int(input())
d = []
for _ in range(n):
	x, y = map(int, input().split())
	d.append(complex(x, y))

if n%2 == 1:
	print("NA")
	exit()

ok = True
ans = Crosspoint(d[0], d[n//2], d[1], d[n//2+1])
#print(ans)

for i in range(n//2):
	if IsOnSegment(ans, d[i], d[n//2+i]) == False or IsOnSegment(ans, d[i+1], d[(n//2+i+1)%n]) == False:
		ok = False
	if abs(ans - d[i]) != abs(ans - d[n//2+i]):
		ok = False
	if abs(ans - d[i+1]) != abs(ans - d[(n//2+i+1)%n]):
		ok = False

if ok:
	print(ans.real, ans.imag)
else:
	print("NA")


Measured memory_bytes: 5648
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

string s;
bool vis[26];
char k;

int main(){
    ios::sync_with_stdio(0);
    cin >> s;
    clean(vis,0);
    forn(i,(int)s.length()){
        vis[s[i]-'a'] = 1;
    }
    k = '#';
    forn(i,26){
        if(!vis[i]){
            k = i+'a';
            break;
        }
    }
    if(k == '#'){
        cout << "None\n";
    }else{
        cout << k << "\n";
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <cctype>

using namespace std;

typedef string::iterator si;

int expr(si& cur, si end);

int num(si& cur, si end){
    int ans = 0;
    while(cur != end && isdigit(*cur)){
        ans *= 10;
        ans += *cur-'0';
        cur++;
    }
    return ans;
}

int fact(si& cur, si end){
    int ans = 1;
    if(*cur == '('){
        cur++;
        ans *= expr(cur, end);
        cur++;
    } else {
        ans *= num(cur, end);
    }
    return ans;
}

int term(si& cur, si end){
    int ans = 1;
    char op = '*';
    while(1){
        int f = fact(cur,end);

        if(op == '*') ans *= f;
        else ans /= f;
        if(cur == end || *cur == ')' ||  (*cur != '*' && *cur != '/')) break;
        else op = *cur;
        cur++;
    }
    return ans;
}

int expr(si& cur, si end){
    int ans = 0;
    char op = '+';
    while(1){
        int t = term(cur, end);

        if(op == '+') ans += t;
        else ans -= t;

        if(cur == end || *cur == ')') break;
        else op = *cur;
        cur++;
    }
    return ans;
}




int main(){
    int n; cin>>n;
    while(n--){
        string s; cin>> s;
        si b = s.begin();
        cout << expr(b, s.end()-1) << endl;
    }
}

Measured memory_bytes: 1208
import fractions as fr
import itertools as it
import collections as col
import heapq as hq
import sys
sys.setrecursionlimit(10**9)

N=int(input())
W=list(map(int, input().split()))
ans=10**100
for T in range(1,N):
        S1=sum(W[:T])
        S2=sum(W[T:])
        ans = min(ans, abs(S1-S2))
print(ans)

Measured memory_bytes: 5688
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

while True:
    n,m = inpl()
    if m == 0:
        break
    else:
        aa = inpl()
        aa.sort()
        ans = -1
        for i in range(n):
            x = aa[i]
            for j in range(n):
                y = aa[j]
                if i == j or x+y > m:
                    continue
                ans = max(x+y,ans)
        if ans == -1:
            print('NONE')
        else:
            print(ans)



Measured memory_bytes: 7540
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>

using namespace std;

const int N=1010;

int a[N];

int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<k;i++)
    {
        ans+=a[i];
    }
    cout<<ans<<endl;






    return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, r;
  cin >> N >> A;
  
  r = N % 500;
  
  if (r > A) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class AtCoder157E
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        char[] s = Console.ReadLine().ToArray();

        BinaryIndexedTree[] counts = new BinaryIndexedTree[26];
        for (int i = 0; i < 26; i++)
        {
            counts[i] = new BinaryIndexedTree(n);
        }

        for (int i = 0; i < n; i++)
        {
            int num = StringToInt(s[i]);
            counts[num].Add(i + 1, 1);
        }

        int q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            int type = int.Parse(words[0]);
            if (type == 1)
            {
                int pos = int.Parse(words[1]);
                char beforeChar = s[pos - 1];
                int before = StringToInt(beforeChar);
                char afterChar = words[2][0];
                int after = StringToInt(afterChar);
                counts[before].Add(pos, -1);
                counts[after].Add(pos, 1);
                s[pos - 1] = afterChar;
            }
            else
            {
                int l = int.Parse(words[1]);
                int r = int.Parse(words[2]);
                int count = 0;
                for (int j = 0; j < 26; j++)
                {
                    if (counts[j].Sum(l, r) > 0)
                    {
                        count++;
                    }
                }
                Console.WriteLine(count);
            }
        }
    }

    private static int StringToInt(char c)
    {
        return c - 'a';
    }

    class BinaryIndexedTree
    {
        private readonly int n;
        private readonly int[] array;

        public BinaryIndexedTree(int n)
        {
            this.n = n;
            array = new int[n + 1];
        }

        public void Add(int index, int value)
        {
            while (index <= n)
            {
                array[index] += value;
                index += index & (-index);
            }
        }

        public int Sum(int l, int r)
        {
            return Sum(r) - Sum(l - 1);
        }

        public int Sum(int index)
        {
            int sum = 0;
            while (index > 0)
            {
                sum += array[index];
                index -= index & (-index);
            }
            return sum;
        }
    }
}

Measured memory_bytes: 68996
import math
S = input()
a = "01"*math.ceil(len(S))
b = "10"*math.ceil(len(S))
a_diff = 0
b_diff = 0
for i in range(len(S)):
    a_diff += a[i] != S[i] 
    b_diff += b[i] != S[i]
print(min(a_diff, b_diff))

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 + y1 - y2 << " " << y2 + x2 - x1 << " " << x1 + y1 - y2 << " " << y1 + x2 - x1 << endl;
}

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

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A > B + C)
    cout << 0 << endl;
  else
    cout << (B + C) - A << endl;
  return;
}

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: 256
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
    int n;
    cin>>n;
    cout<<"ABC"<<n<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
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; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int A, b, c, d;
    cin >> A >> b >> c >> d;
    cout << (d == 1) << endl;
}



Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n;

	std::cin >> n;

	std::cout << (n * (n + 1)) / 2 - n << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    string a, b;
    cin >> a >> b;
    a += b;
    int n = stoi(a);
    string ans = "No";
    for (int i = 1; i*i <= n; i++)
    {
        if (i * i == n) ans = "Yes";
    }
    cout << ans << endl;
}


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

using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int GCD (int a, int b) { return b ? GCD(b, a % b) : a; }

typedef long long ll;

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

    int cnt0 = std::count(S.cbegin(), S.cend(), '0');
    int cnt1 = std::count(S.cbegin(), S.cend(), '1');
    int ans = min(cnt0, cnt1) * 2;

    cout << ans << endl;

    return 0;
}


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

int main(){
  string s ; cin >> s ;
  bool ok = false ;
  if(s.at(0)==s.at(1)&&s.at(2)==s.at(3)&&s.at(0)!=s.at(2)) ok = true ;
  if(s.at(0)==s.at(2)&&s.at(1)==s.at(3)&&s.at(1)!=s.at(2)) ok = true ;
  if(s.at(0)==s.at(3)&&s.at(2)==s.at(1)&&s.at(0)!=s.at(2)) ok = true ;
  if(ok) cout << "Yes" << endl ;
  else cout << "No" << endl ;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)

	ans := 0
	tmp := 0
	for i := 0; i < n-1; i++ {
		ans++
		tmp += a[i]
		if tmp*2 < a[i+1] {
			ans = 0
		}
	}
	fmt.Println(ans + 1)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define SPEED cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false)
#define int long long

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

	if (k%2 == 0) cout << a - b;
	else cout << b - a;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int n, k;

    cin >> n >> k;

    int cnt = 0;

    for(int i=0; i<n; i++){
        int h;
        cin >> h;
        if(h>=k)
            cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 632
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stdint.h>

int64_t left[100005];
int64_t right[100005];
bool used[100005];

std::vector<int64_t> ls,rs;

int main(){
  int64_t N;
  scanf("%ld",&N);
  for(int64_t i=0;i<N;i++){
    scanf("%ld %ld",&left[i],&right[i]);
  }
  for(int64_t i=0;i<N+1;i++){
    ls.push_back(i);
    rs.push_back(i);
  }
  std::sort(ls.begin(),ls.end(),
	    [](int64_t i,int64_t j){return left[i]>left[j];});
  std::sort(rs.begin(),rs.end(),
	    [](int64_t i,int64_t j){return right[i]<right[j];});
  int64_t sum=0;
  for(int64_t i=0;i<=N;i++){
    if(left[ls[i]]>right[rs[i]]){
      sum+=2*(left[ls[i]]-right[rs[i]]);
    }
  }
  printf("%ld\n",sum);
  return 0;
}


Measured memory_bytes: 3572
n,m = map(int,input().split())
from collections import deque
r=[[] for i in range(n)]

for _ in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    r[a].append(b)
    r[b].append(a)

# dist =[-1]*n
# dist[0] = 0

q = deque([0])
prev=[-1] * n

while q:
    v = q.popleft()

    for j in r[v]:
        if prev[j]==-1:
            prev[j] = v
            q.append(j)
            # dist[j] = dist[v] + 1
            

for i in range(n):
    if i==0:
        print('Yes')
    else:
        print(prev[i]+1)


Measured memory_bytes: 34280
import java.util.*

fun main(args:Array<String>) {
    val sc = Scanner(System.`in`)

    val N:Int = sc.nextInt()
    if (N == 1) {
        println("Hello World")
        return
    }
    val A:Int = sc.nextInt()
    val B:Int = sc.nextInt()

    println(A + B)
}


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll q,l,r,n=100000,i,j,a[n];
	bool pr[n];
	fill(pr,pr+n,true);
	pr[1]=false;
	for (i=2;i<n;i++){
		if (pr[i]==true){
			for (j=i*i;j<n;j+=i){
				pr[j]=false;
			}
		}
	}
	a[1]=0;
	for (i=3;i<n;i+=2){
		if (pr[i]==true&&pr[(i+1)/2]==true){
			a[i]=a[i-2]+1;
		}
		else {
			a[i]=a[i-2];
		}
	}
	cin>>q;
	for (i=0;i<q;i++){
		cin>>l>>r;
		cout<<a[r]-a[l-2]<<"\n";
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    int n;
    for(int i=0;i<N;i++){
        cin >> a.at(i);
        n = a.at(i);
        b.at(n-1)=i+1;
    }
    for(int i=0;i<N;i++){
        if(i<N-1){
        cout << b.at(i) <<" ";
        }
        else{
            cout << b.at(i) << endl;
        }
    }
}


Measured memory_bytes: 1536
#include <cstdio>
int isused[35];

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

    for(int i=1;i<=n;i++){
        int k;
        scanf("%d",&k);
        for(int j=1;j<=k;j++){
            int num;
            scanf("%d",&num);
            isused[num]++;
        }
    }
    int ans=0;
    for(int i=1;i<=m;i++){
        if(isused[i]==n) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ul N;
  cin >> N;
  vector<ul> A(N, 0);
  map<int, int> mp;
  ul cnt = 0;
  REP(ii, N) { cin >> A[ii]; }
  REP(ii, N) {
    cnt += mp[ii + 1 - A[ii]];
    mp[A[ii] + ii + 1]++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 21868
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define pb() push_back()
#define mod 100000007
#define elif else if
#define str string
//main
signed main(){
  int N,M,O,P,Q,count=0,count2=0,count3=0;
  double D=0;
  int c='A'-'a';
  //char C;
  str S,T;
  cin>>N;
  D=N;
  N%2==1?cout<<(N/2+1)/D<<endl:cout<<N/2/D<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long ans;
  string s;
  cin >> s;
  ans=s.size()/2;
  while(ans!=s.size()) {
    if(s[ans]==s[s.size()-ans-1]&&(s[ans]==s[ans-1]||ans==s.size()/2)) {
      ans++;
    } else {
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3760
N = int(input())
def calcgcd(a, b):
  if a > b:
    a, b = b, a
  while a > 0:
    a, b = b%a, a
  return b
def calclcm(a, b):
  return a*b//calcgcd(a, b)
r = 1
for i in range(N):
  T = int(input())
  r = calclcm(r, T)
print(r)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	long int s;
	int n , i , j;
	scanf("%d" , &n);
	for(i=1;i<=n;i++){
		scanf("%ld" , &s);
		printf("Case %d:\n" , i);
		for(j=0;j<10;j++){
			s *= s;
			s %= (long int)1e6;
			s /= 100;
			printf("%ld\n" , s);
		}
	}
	return 0;
}

Measured memory_bytes: 0