akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int m = Integer.parseInt(br.readLine());

		int[][] matrix = new int[n][n];
		for(int i = 0; i < n; i++){
			Arrays.fill(matrix[i], Integer.MAX_VALUE);
		}

		for(int i = 0; i < m; i++){
			String[] tmpArray = br.readLine().split(",");
			int a = Integer.parseInt(tmpArray[0])-1;
			int b = Integer.parseInt(tmpArray[1])-1;
			int c = Integer.parseInt(tmpArray[2]);
			int d = Integer.parseInt(tmpArray[3]);

			matrix[a][b] = c;
			matrix[b][a] = d;
			//System.out.println(i);
		}
//
//		for(int i = 0; i < n ; i++){
//			for(int j = 0; j < n; j++){
//				System.out.print(matrix[i][j]+" ");
//			}
//			System.out.println();
//		}

		//System.out.println("read");
		//System.out.println(br.readLine());
		String[] tmpArray = br.readLine().split(",");
		int start = Integer.parseInt(tmpArray[0])-1;
		int goal = Integer.parseInt(tmpArray[1])-1;
		int reward = Integer.parseInt(tmpArray[2]);
		int pay = Integer.parseInt(tmpArray[3]);

		//System.out.println("test");
		int[] go = singleSourceShortestDense(matrix, start);
		int[] back = singleSourceShortestDense(matrix, goal);
		//System.out.printf("%d %d %d %d\n", start, goal, reward, pay);
//
//		for(int i = 0; i < n ; i++){
//			System.out.println("go["+i+"] = " +go[i] + " back["+i+"] = "+ back[i]);
//		}

		System.out.println(reward - go[goal] - back[start] - pay);

	}

	static int[] singleSourceShortestDense(int[][] matrix, int s){
        int n = matrix[0].length;
        int[] dist = new int[n];
        Arrays.fill(dist, Integer.MAX_VALUE);
        boolean[] visited = new boolean[n];
        Arrays.fill(visited, false);

        dist[s] = 0;

        while(true){
        	//System.out.println("IN SSD");
            int u = -1;
            int sd = Integer.MAX_VALUE;

            for(int i = 0; i < n ; i++){
                if(!visited[i] && dist[i] < sd){
                    sd = dist[i];
                    u = i;
                }
            }

            if(u == -1){
                break;
            }

            visited[u] = true;
            for(int v = 0; v < n ; v++){
            	//System.out.println("v = "+v);
                int w = matrix[u][v];
                if(v == u) continue;

                long newLen = dist[u];
                newLen += w;
                //System.out.println("NEWLEN "+newLen);
                if(newLen < dist[v]){
                    dist[v] = (int)newLen;
                }
            }

        }

        return dist;
    }

}

Measured memory_bytes: 24228
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

K = int(input())

ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        tmp = gcd(a, b)
        for c in range(1,K+1):
            ans += gcd(tmp,c)

print(ans)

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;
int a[100000];
int b[100000];
int c[100000];
vector<pair<int, int>> v;
int x[300000];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	inc(i, n) { cin >> b[i]; }
	inc(i, n) { cin >> c[i]; }
	
	inc(i, n) {
		v.EB(a[i], -0);
		v.EB(b[i], -1);
		v.EB(c[i], -2);
	}
	
	sort(ALL(v));
	
	int aa = 0;
	inc(i, v.size()) {
		if(v[i].SE == -0) { aa++; }
		if(v[i].SE == -1) { x[i] = aa; }
	}
	
	LL ans = 0, s = 0;
	inc(i, v.size()) {
		s += x[i];
		if(v[i].SE == -2) { ans += s; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 7748
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
using namespace std;
const int N=1005;
const ll inf=1e18;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,-1,1};
const char ch[4]={'R','L','D','U'};
int n,x[N],y[N],odd,even,a[N];
int main(){
	scanf("%d",&n);
	rep (i,1,n){
		scanf("%d%d",&x[i],&y[i]);
		if ((x[i]+y[i])&1) odd++; else even++;
	}
	if (odd&&even) return puts("-1"),0;
	puts(even?"32":"31");
	for (int i=30;i+1;i--) printf("%d ",a[++*a]=(1<<i));
	if (even) a[++*a]=1,puts("1"); else puts("");
	rep (t,1,n){
		ll nx=0,ny=0,px,py,Min; int d;
		rep (i,1,*a){
			Min=inf;
			rep (k,0,3){
				px=nx+dx[k]*a[i],py=ny+dy[k]*a[i];
				if (abs(px-x[t])+abs(py-y[t])<Min) Min=abs(px-x[t])+abs(py-y[t]),d=k;
			}
			nx+=dx[d]*a[i],ny+=dy[d]*a[i];
			printf("%c",ch[d]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define N 100

int main() {
	static char s[N + 1];
	int n, i;
	long long k;

	scanf("%s%lld", s, &k);
	n = strlen(s);
	for (i = 0; i < n && s[i] == '1'; i++)
		k--;
	printf("%c\n", k <= 0 ? '1' : s[i]);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
int digits[10][10];

int first_num(int n){
	return n%10;
}

int last_num(int n){
	int prev_n = n;
	while(n){
		prev_n = n;
		n /= 10;
	}
	return prev_n;
}

void solve(){
	// digits[firstdi][lastdig];
	int n; cin >> n;
	forn(i,1,n+1){
		int fir = first_num(i);
		int las = last_num(i);
		++digits[fir][las];
	}
	ll ans = 0;
	forn(i,0,10){
		forn(j,0,10){
			ans += digits[i][j] * digits[j][i];
		}
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3648
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	length, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	array := strings.Split(sc.Text(), " ")

	counta := 0
	for i := 0; i < length; i++ {
		minIndex := i
		for j := i; j < length; j++ {
			val1, _ := strconv.Atoi(array[minIndex])
			val2, _ := strconv.Atoi(array[j])
			if val1 > val2 {
				minIndex = j
			}
		}

		if i != minIndex {
			counta++
			array[i], array[minIndex] = array[minIndex], array[i]

		}

	}

	fmt.Println(strings.Join(array, " "))
	fmt.Println(counta)
}



Measured memory_bytes: 1108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int,int> P;

int main(){
    ll x,y,a,b,c,ans;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a),q(b),r(c),qp,dp(c+10);
    rep(i,a)cin>>p[i];
    rep(i,b)cin>>q[i];
    rep(i,c)cin>>r[i];
    sort(p.begin(),p.end(),greater<ll>());
    sort(q.begin(),q.end(),greater<ll>());
    sort(r.begin(),r.end(),greater<ll>());
    rep(i,x){
        qp.push_back(p[i]);
    }
    rep(i,y){
        qp.push_back(q[i]);
    }
    rep(i,c)qp.push_back(r[i]);
    sort(qp.begin(),qp.end(),greater<ll>());
    rep(i,x+y){
        ans+=qp[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9584
import math
import itertools
n, m, q = map(int, input().split())

abcd = []
for i in range(q):
    abcd.append(list(map(int, input().split())))

l = []
for i in range(1, m+1):
    l.append(i)

a_list = list(itertools.combinations_with_replacement(l, n))


max = 0
for i in range(len(a_list)):
    sum = 0
    for j in range(len(abcd)):
        if(a_list[i][abcd[j][1]-1] - a_list[i][abcd[j][0]-1]) == abcd[j][2]:
            sum += abcd[j][3]
    if sum >= max:
        max = sum


print(max)

Measured memory_bytes: 84968
#include <iostream>
#include <string>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int sum = 0;
  rep(i, 0, n) {
    if(i < k) sum += x;
    else sum += y;
  }
  cout << sum << "\n";
}


Measured memory_bytes: 3640
import sys
sys.setrecursionlimit(2000000000)

N = int(input())
origin_list = [input().split() for _ in range(N)]
card_list = origin_list[:]
card_list2 = sorted(card_list[:], key=lambda x:x[1])

def partition(A, p, r):
    x = int(A[r][1])
    i = p - 1

    for j in range(p, r):
        if int(A[j][1]) <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1


def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q-1)
        quickSort(A, q+1, r)

quickSort(card_list, 0, len(card_list)-1)


if card_list == card_list2:
    print('Stable')
else:
    print('Not stable')

for item in card_list:
    print(*item)


Measured memory_bytes: 31568
#include <bits/stdc++.h>
#define ll long long
#define all(x) begin(x), end(x)
#define range(x) begin(x), begin(x)
#define what(x) cout << #x << ": " << x << '\n'
#define print(x) for (auto &el: x) cout << el << ' '; cout << '\n'
using namespace std;

template<typename S, typename T>
ostream& operator <<(ostream &os, pair<S, T> &m) { 
    os << '[' << m.first << " " << m.second << ']';
    return os;
}

int cnt(ll x) {
    int res = 0;
    while(x > 0) x /= 10, res ++;
    return res;
}

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

    int n;
    cin >> n;
    bool flag = true;
    unsigned ll res = 1;

    for (int i = 0; i < n; ++i) { 
        unsigned ll k;
        cin >> k;
        // if there is a zero in the list
        if (k == 0) {
            flag = true;
            res = 0;
            break;
        }
        // if the max number of digits in the multiplied value fits into the variable
        if (cnt(res) + cnt(k) <= 19) res *= k;
        // special case
        else if (cnt(res) + cnt(k) == 20 && res == 1000000000 && k == 1000000000) res *= k;
        else flag = false;
    }

    if (res > 1000000000000000000) flag = false;
    if (!flag) cout << -1 << endl;
    else cout << res << endl;

    return 0;
}


Measured memory_bytes: 3676
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);
switch ($n) {
    case $n === 1:
        echo 'Hello World';
        break;
    case $n === 2:
        echo $a + $b;
        break;
}


Measured memory_bytes: 15956
import java.io.IOException;
import java.util.Random;
import java.util.Scanner;
public class Main {
	static int[] dice;
	static int[] diceb;
	static int a;
	static int b;
	static int c;
	static int d;
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

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

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

		int a = diceb[0];
		int b = diceb[1];
		int count = 0;
		while(true) {
			diceRoll();
			count++;
			if(dice[0]==a && dice[1]==b || count==100) {
				break;
			}
		}

		if(dice[2]==diceb[2] && dice[3]==diceb[3] && dice[4]==diceb[4] && dice[5]==diceb[5]) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		sc.close();
	}

	public static void diceRoll() {
		Random rand = new Random();
		int num = rand.nextInt(4);
		if(num==0) {
			s();
		}else if(num==1) {
			n();
		}else if(num==2) {
			w();
		}else if(num==3){
			e();
		}
	}

	public static void s() {
		a = dice[0];
		b = dice[1];
		c = dice[4];
		d = dice[5];

		dice[0] = c;
		dice[1] = a;
		dice[4] = d;
		dice[5] = b;
	}

	public static void w() {
		a = dice[0];
		b = dice[2];
		c = dice[3];
		d = dice[5];

		dice[0] = b;
		dice[2] = d;
		dice[3] = a;
		dice[5] = c;
	}

	public static void e() {
		a = dice[0];
		b = dice[2];
		c = dice[3];
		d = dice[5];

		dice[0] = c;
		dice[2] = a;
		dice[3] = d;
		dice[5] = b;
	}

	public static void n() {
		a = dice[0];
		b = dice[1];
		c = dice[4];
		d = dice[5];

		dice[0] = b;
		dice[1] = d;
		dice[4] = a;
		dice[5] = c;
	}
}


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

#define rep(i,n)        for (i = 0; i < n; ++i) 
#define REP(i,k,n)      for (i = k; i <= n; ++i) 
#define REPR(i,k,n)     for (i = k; i >= n; --i) 
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

const int SIZE = 1e5;
int arr[SIZE];

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
	    freopen("in.txt", "r", stdin);
	    freopen("out.txt", "w", stdout);
	#endif
}


int main() { 

	c_p_c();
	
	int n, cnt = 0;
	cin >> n;
	set<string> has;
	while(n-->0){
		string s;
		cin >> s;
		has.insert(s);
	}
	
	cout << has.size() << endl;
	
	return 0; 
} 


Measured memory_bytes: 19172
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> num(n);
	vector<int> s(k);
	for (int i = 0; i < n; ++i)
		cin >> num[i];
	for (int i = 0;i+k-1 < n; ++i)
	{
		int x = abs(num[i+k-1]) + abs(num[i+k-1]-num[i]);
		int y = abs(num[i]) + abs(num[i+k-1]-num[i]);
		s[i] = (x<=y)?x:y;

	}
	int f = s[0];
	for (int i = 1;i+k-1 < n; ++i)
	{
		if(f > s[i])
			f = s[i];
	}
	cout << f << endl;
	return 0;
}

Measured memory_bytes: 1024
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	s := getString()
	l := len(s)

	v := make([]int, l)
	for i := 0; i < l; i++ {
		v[i] = int(s[i] - '0')
	}

	ans := 0
	pat := 1 << uint(l-1)
	for i := 0; i < pat; i++ {
		s := 0
		k := 0
		p := i
		for j := 0; j < l; j++ {
			s = s*10 + v[k]
			if p&1 == 1 {
				ans += s
				s = 0
			}
			k++
			p >>= 1
		}
		ans += s
	}

	out(ans)

}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (100010)
#define P ()
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,a[4][N],a1,b1,a2,b2;
struct BIT{
	int c[N];
	void add(int x){for(;x;x-=x&(-x))c[x]^=1;}
	int query(int x){int ans=0;for(;x<=n;x+=(x&(-x)))ans^=c[x];return ans;}
	void clear(){memset(c,0,sizeof(c));}
}T;
bool spj(){
	for(int i=1;i<=n;i++){
		if(a[3][i]+1==a[2][i]&&a[2][i]+1==a[1][i]){if(i&1)a2^=1;else b2^=1;}
		else if(!(a[1][i]+1==a[2][i]&&a[2][i]+1==a[3][i]))return 0;
		for(int j=1;j<=3;j++)if((i+j)&a[j][i]&1)return 0;
	}
	return 1;
}
int main(){
	read(n);
	for(int i=1;i<=3;i++)
	for(int j=1;j<=n;j++)read(a[i][j]);
	if(!spj())puts("No"),exit(0);
	for(int i=1;i<=n;i+=2){
		int x=min(a[1][i],a[3][i]);
//		cout<<T.query(x/6+1)<<endl;
		a1^=T.query(x/6+1),T.add(x/6+1);
	}
//	cout<<a1<<" "<<a2<<endl;
	T.clear(); 
	for(int i=2;i<=n;i+=2){
		int x=min(a[1][i],a[3][i]);
//		cout<<T.query(x/6+1)<<" faq"<<endl;
		b1^=T.query(x/6+1),T.add(x/6+1);
	}
//	cout<<b1<<" "<<b2<<endl;
	if(a1==b2&&b1==a2)puts("Yes");else puts("No");
}

Measured memory_bytes: 4224
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int64_t A[100010];
int64_t X[100010];
int64_t sum[100010];
int64_t sum2[2][100010];


int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	int32_t Q;
	in >> N >> Q;
	for (size_t i = 0; i < N; i++)
	{
		in >> A[i];
	}
	for (size_t i = 0; i < Q; i++)
	{
		in >> X[i];
	}


	for (size_t i = 1; i <= N; i++)
	{
		sum[i] = sum[i-1] + A[i-1];
		sum2[i & 1][i] = sum2[i & 1][i - 1] + A[i-1];
		sum2[(i + 1) & 1][i] = sum2[(i + 1) & 1][i - 1];
	}

	for (size_t QUERY = 0; QUERY < Q; QUERY++)
	{
		const auto& x = X[QUERY];

		auto x_index = std::lower_bound(A, A + N, x) - A;
		if (x_index >= N-1) {

			out << sum2[N & 1][N] << '\n';
			continue;
		}
		

		using BS_INT = int64_t;
		BS_INT ok_range = x_index-1, ng_range = N;
		while (std::abs(ok_range - ng_range) > 1) {
			BS_INT mid = (ok_range + ng_range) / 2;
			bool is_ok = false;

			auto diff = (A[mid] - x);
			auto min_index = std::lower_bound(A, A + N, x - diff) - A;
			auto eat_num = mid - min_index + 1;
			is_ok = (mid < N - eat_num);

			if (is_ok) {
				ok_range = mid;
			}
			else {
				ng_range = mid;
			}
		}
		++ok_range;//0->1

		auto eat_num = N - ok_range;
		auto next_eat = ok_range - eat_num;
		out << sum[N]-sum[ok_range] + sum2[next_eat&1][next_eat] << endl;

	}

	return 0;
}
#endif


Measured memory_bytes: 5632
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int x;
    cin >> x;
    cout << 10 - x / 200 << endl;
}

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

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int a, b, c;

int main()
{
	scanf("%d%d%d", &a, &b, &c);
	
	if ((a == b) && (a != c)) {
		printf("Yes\n");
		return 0;
	}
	
	if ((a == c) && (a != b)) {
		printf("Yes\n");
		return 0;
	}
	
	if ((b == c) && (a != b)) {
		printf("Yes\n");
		return 0;
	}	
	
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
t=input()
result=''
for i in range(len(t)-1):
    if t[i]=='?':
        try:
            if result[i-1]=='P':
                result+='D'
            else:
                if t[i+1]=='P':
                    result+='D'
                else:
                    result+='P'
        except:
            if t[i+1]=='P':
                result+='D'
            else:
                result+='P'
    else:
        result+=t[i]
if t[len(t)-1]=='?' or  t[len(t)-1]=='D':
    print(result+'D')
else:
    print(result+'P')

Measured memory_bytes: 9480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>v[200005];
int dst[200005],vstd[200005];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int now=1;dst[1]=1;
	queue<int>q;
	q.push(now);
	while(q.size()){
		int node=q.front();
		q.pop();
		if(vstd[node])continue;
		vstd[node]=true;
		for(auto u:v[node]){
			if(!vstd[u]){
				dst[u]=dst[node]+1;
				q.push(u);
			}
		}
	}
	int mx=0;
	for(int i=1;i<=n;i++){
		if(dst[i]>mx){
			now=i;
			mx=dst[i];
		}
	}
	dst[now]=1;memset(vstd,0,sizeof vstd);
	q.push(now);
	while(q.size()){
		int node=q.front();
		q.pop();
		if(vstd[node])continue;
		vstd[node]=true;
		for(auto u:v[node]){
			if(!vstd[u]){
				dst[u]=dst[node]+1;
				q.push(u);
			}
		}
	}
	mx=0;
	for(int i=1;i<=n;i++){
		mx=max(mx,dst[i]);
	}
	if(mx%3!=2){
		cout<<"First";
	}else{
		cout<<"Second";
	}
	return 0;
}

Measured memory_bytes: 17300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long long> vll;
const int mod = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll N,ans=1;
    cin>>N;
    for(ll i=1; i<=N;i++)
    {
        ans*=i;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
m = int(input().split(" ")[-1])
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
l = [list(map(int, input().split(" "))) for i in range(m)]
c = [a[t[0] - 1] + b[t[1] - 1] - t[2] for t in l]
print(min(min(c),min(a)+min(b)))

Measured memory_bytes: 42404
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
def main():
    N, M = map(int, input().split())
    w = [[0] * N for i in range(N)]
    l = []
    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        w[a][b] = w[b][a] = c
        l.append((a,b,c))
    G = csr_matrix(w)
    d = floyd_warshall(G, directed=False)
    r = 0
    for a, b, c in l:
        if d[a][b] != c:
            r += 1
    return r
print(main())


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

int n;
int h[200];

int dfs(int l,int r){//[l,r)
	if(l==r)return 0;
	int ans=0;
	int a=*min_element(h+l,h+r);
	ans+=a;
	for(int i=l;i<r;i++)h[i]-=a;
	int s=l;
	for(int i=l;i<r;i++){
		if(h[i]==0){
			ans+=dfs(s,i);
			s=i+1;
		}
	}
	ans+=dfs(s,r);
	return ans;
}
int main(){
	scanf("%d",&n);
	rep(i,n)scanf("%d",&h[i]);
	cout<<dfs(0,n)<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	int n; cin >> n;
	if (n == 3) printf("2 5 63");
	else if (n == 4) printf("2 5 20 63");
	else if (n == 5) printf("2 5 20 60 63");
	else {
		int sum = 0;
		set<int> ans;
		rep(i, 1, 30001) {
			if (i % 2 == 0 || i % 3 == 0) {
				ans.insert(i);
				sum += i;
			}
			if (ans.size() > n - 1) break;
		}
		sum %= 6;
		if (sum == 2) {
			ans.erase(ans.lower_bound(8));
			ans.insert((n / 4 + 1) * 6);
		}
		if (sum == 3) {
			ans.erase(ans.lower_bound(9));
			ans.insert((n / 4 + 1) * 6);
		}
		if (sum == 5) {
			ans.erase(ans.lower_bound(9));
			ans.insert((n / 4 + 1) * 6 - 2);
		}
		for (int a : ans) printf("%d ", a);
	}
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int hold[101];
int main() {
  int cnt = 0;
  int a, b, c, d; cin >> a >> b >> c >> d;
  for (int i = a; i < b; i++) hold[i]++;
  for (int i = c; i < d; i++) hold[i]++;
  for (int i = 0; i <= 100; i++) if (hold[i] == 2) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{
    int N, M;
    cin >> N >> M;
    int arr[M];
    int cnt = 0;
    for (int i = 0; i < M; i++)
    {
        cin >> arr[i];
        cnt += arr[i];
    }
    int days = N - cnt;
    if (days >= 0)
    {
        cout << days << endl;

    }
    else
        cout << -1 << endl;

    return 0;
}





Measured memory_bytes: 3672
n = int(input())
xs = [input() for i in range(n)]
m = int(input())
ys = [input() for i in range(m)]

ans = 0
for s in xs:
  sum = 0
  for t in xs:
    if s == t: sum += 1
  for t in ys:
    if s == t: sum -= 1
  ans = max(ans, sum)
print(ans)

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

const int MAX_N = 300005;
int vals[MAX_N];
int N, K;

template <typename T>
struct RangeTree {
  int N; std::vector<T> node_vals;
  T base_value;
  int ceil_pow_2(int v) { // Nearest power of two upper bound.
    int p; for (p = 1; p < v; p *= 2) {} return p;
  }
  RangeTree(int sz, T base) : base_value(base), N(ceil_pow_2(sz)) {
    node_vals.resize(2*N-1, base_value);
  }
  T combine(T a, T b) { return std::max(a, b); } // Could be min or +.
  T query(int l, int r, int nid, int nl, int nr) {
    if (l == nl && r == nr)
      return node_vals[nid];
    int mid = (nl+nr)/2; T result = base_value;
    if (l <= mid)
      result = combine(result, query(l, std::min(r, mid), 2*nid+1, nl, mid));
    if (r > mid)
      result = combine(result, query(std::max(l, mid+1), r, 2*nid+2, mid+1, nr));
    return result;
  }
  T query(int l, int r) { return query(l, r, 0, 0, N-1); }
  void update(int index, T value, int nid, int nl, int nr) {
    if (nl == nr) { node_vals[nid] = value; return; }
    int mid = (nl+nr)/2;
    if (index <= mid)   update(index, value, 2*nid+1, nl, mid);
    else        update(index, value, 2*nid+2, mid+1, nr);
    node_vals[nid] = combine(node_vals[2*nid+1], node_vals[2*nid+2]);
  }
  void update(int index, T value) { update(index, value, 0, 0, N-1); }
};

RangeTree<int> t(MAX_N, 0);


int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; ++i) {
    scanf("%d", vals + i);
  }
  for (int i = N - 1; i >= 0; --i) {
    int v = t.query(std::max(0, vals[i] - K), std::min(vals[i] + K, MAX_N)) + 1;
    t.update(vals[i], v);
  }
  printf("%d\n", t.query(0, MAX_N));
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s; cin >> s;
	for (int i = 0; i < s.length(); i++) s[i] = 9 - (s[i] - '1') + '0';
	cout << s << endl;
	return 0;
}



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

const int INF = 1001001001;
int main(){
  int N;
  int64_t x;
  cin>>N>>x;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  int64_t sum=0;
  for(int i=0;i<N;i++){
    sum+=a.at(i);
  }
  int count=0;
  if(x<sum){
    int i=0;
    while(x-a.at(i)>=0){
     x-=a.at(i);
     i++;
     count++;
    }
    cout<<count<<endl;
  }
  else if(x==sum){cout<<N<<endl;}
  else{cout<<N-1<<endl;}
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        string[] arr = Console.ReadLine().Split(' ');
        string one = arr[0];
        string two = arr[1];
        string three = arr[2];
        arr[0] = three;
        arr[1] = one;
        arr[2] = two;
        foreach (string i in arr)
        {
            Console.Write("{0} ", i);
        }



    }

  

 
   



}



Measured memory_bytes: 17484
#include <stdio.h>

int main(void)
{
    char b[1];
    
    scanf("%s", &b);
    // A と T、C と G がそれぞれ対
    // 塩基 b と対になる塩基を表す文字を出力するプログラム
    if ( b[0] == 'A')
    {
        printf("T\n");    
    }
    else if ( b[0] == 'T')
    {
        printf("A\n");            
    }
    else if ( b[0] == 'C')
    {
        printf("G\n");            
    }
    else if ( b[0] == 'G')
    {
        printf("C\n");            
    }

    return 0;
}

Measured memory_bytes: 128
using static System.Console;
using System.Linq;
using System;

class Program
{
    static void Main(string[] args)
    {
        var side = ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = side[0];
        var b = side[1];
        var c = side[2];
        var d = side[3];
        WriteLine(Math.Max(a * b, c * d));
    }
}

Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

vi DY(int x, int y) {
    return (abs(x) % 2) ? vi{1, 1, 0, -1, 0, 1, 0} : vi{1, 0, -1, -1, -1, 0, 0};
}

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

    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    int n;
    cin >> n;
    set<Pii> st_forbidden;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        st_forbidden.emplace(x, y);
    }
    int lx, ly;
    cin >> lx >> ly;

    using State = tuple<int, int, int, int>; // cost, x, y, t % 6
    const int m = 6;
    map<TUPLE, int> d; // d[(x, y, t)] = c
    priority_queue<State, vector<State>, greater<State>> pq;
    d[TUPLE(sx, sy, 0)] = 0;
    pq.push(State(0, sx, sy, 0));

    while (!pq.empty()) {
        int c, x, y, t;
        tie(c, x, y, t) = pq.top(); pq.pop();
        // output(c, x, y, t);
        // assert(abs(x) <= lx && abs(y) <= ly);
        if (x == gx && y == gy) {
            cout << c << endl;
            return 0;
        }
        if (d[TUPLE(x, y, t)] < c) continue;
        vi dx{0, 1, 1, 0, -1, -1, 0};
        vi dy = DY(x, y);
        rep(k, m + 1) {
            int nx = x + dx[k], ny = y + dy[k], nt = (t + 1) % m;
            if (abs(nx) <= lx && abs(ny) <= ly && !st_forbidden.count(Pii(nx, ny))) {
                int rem = abs(x) * abs(y) * t % m;
                // output(rem, k);
                int nc = c + (rem != k);
                if (!d.count(TUPLE(nx, ny, nt)) || d[TUPLE(nx, ny, nt)] > nc) {
                    d[TUPLE(nx, ny, nt)] = nc;
                    pq.emplace(nc, nx, ny, nt);
                }
            }
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 21616
#
# abc067 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """6
1 2 3 4 5 6"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
10 -10"""
        output = """20"""
        self.assertIO(input, output)


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

    ans = float("inf")
    S = sum(A)
    T = []
    T.append(A[0])
    for i in range(1, N-1):
        T.append(T[i-1]+A[i])
    for t in T:
        ans = min(ans, abs(S-2*t))

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int h, w;
    cin >> h >> w;
    vector<int> dx = {0, 0, 1, 1, 1, -1, -1, -1};
    vector<int> dy = {1, -1, 1, 0, -1, 1, 0, -1};
    vector<string> s(h);
    for(auto& x : s)
        cin >> x;
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            int c = 0;
            for(int k = 0; k < 8; ++k){
                int ii = i + dx[k];
                int jj = j + dy[k];
                if(ii < 0 || jj < 0 || ii >= h || jj >= w)
                    continue;
                c += (s[ii][jj] == '#');
            }
            if(s[i][j] == '#')
                cout << '#';
            else
                cout << c;
        }
        cout << endl;
    }
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long X){
    REP2(i, -300, 300) {
        REP2(j, -300, 300) {
            LL ii = (LL)i * (LL)i * (LL)i * (LL)i * (LL)i;
            LL jj = (LL)j * (LL)j * (LL)j * (LL)j * (LL)j;

            if(ii - jj == X) {
                cout << i << " " << j << endl;
                return;
            }
        }
    }
}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll X;
  cin >> X;
  ll ans = 0;
  ans += (X/500)*1000;
  ans += ((X%500)/5)*5;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ll a,b,k;
  cin >> a >> b >> k;

  ll A, B;
  A = a - k;
  B = b;
    
  if (a + b <= k){
    A = 0;
    B = 0;
  } else if (a >= k){
    A = a - k;
    B = b;
  } else {
    A = 0;
    B = b - (k - a);
  }
  cout << A << " " << B;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n, x, t;
    cin >> n >> x >> t;
    ll ans = (n + x - 1) / x;
    ans *= t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    a, b = map(int, input().split())
    if a >= 13:
        print(b)
    elif 6 <= a <= 12:
        print(b // 2)
    elif a <= 5:
        print(0)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38324
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll A,B,C,N,M,K,X,Y;
string S;
vector<ll> vec;

void solve() {
	cin >> N;
	vec.resize(N);
	rep(i, N) cin >> vec[i];

	int ans = 0;

	rep(i, N - 2) {
		if (vec[i+1] > vec[i] && vec[i+1] < vec[i+2]) {
			ans++;
			continue;
		}
		if (vec[i + 1] < vec[i] && vec[i + 1] > vec[i+2]) {
			ans++;
			continue;
		}
	}

	cout << ans;
}

int main() {
	solve();
	cout << endl;
	return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

ll dp[51][4];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,p;
  cin >> n >> p;
  vector<ll> v(n);
  bool f = false;
  rep(i,n){
    cin >> v[i];
    f |= v[i] % 2;
  }
  ll ans = 1;
  REP(i,0,n){
    ans *= 2;
  }
  if(f){
    if(n != 1)
      cout << ans / 2<< endl;
    else
      cout << (v[0] % 2 == p) << endl;
  }
  else{
    if(p)
      cout << 0 << endl;
    else
      std::cout << ans << std::endl;
  }
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int d[N];
  for(int i = 0; i < N; i++) cin >> d[i];

  sort(d, d + N);

  cout << d[N / 2] - d[N / 2 - 1] << endl;
  return 0;
}


Measured memory_bytes: 640
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }

using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e5+2;
const ll mod = 1e9+7;



void solve(){
	ll l,r;
	cin >> l >> r;
	r = min(r,l+2019);
	ll minn = 1e9+2;
	for(ll i = l; i < r; i++){
		for(ll j = i+1; j <= r; j++){
			if((i*j)%2019 < minn)
			minn = (i*j)%2019;
		}
	}
	cout << minn << endl;
}



int main(){ 
	speedhack()
	// int it; cin >> it;
	int it = 1;
	do(it);
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,raw_input().split())
g=[[] for i in range(2*10**5+1)]
for i in range(m):
	a,b=map(int,raw_input().split())
	g[a].append(b)
	g[b].append(a)
for i in g[1]:
	for j in g[i]:
		if j==n:
			print "POSSIBLE"
			exit(0)
print "IMPOSSIBLE"

Measured memory_bytes: 66460
import sys
from collections import Counter
from itertools import accumulate
n = int(input())
x_ls = [int(i) for i in sys.stdin.readline().split()]
sorted_x_ls = sorted(x_ls)
ct = Counter(x_ls)
acc = dict()
_sum = 0
for k, v in sorted(ct.items(), key=lambda x:x[0]):
    _sum += v
    acc[k] = _sum

for i, x in enumerate(x_ls):
    if acc[x] <= n // 2:
        print(sorted_x_ls[n // 2])
    else:
        print(sorted_x_ls[n // 2 - 1])

Measured memory_bytes: 121036
#include <stdio.h>

int main(){
    char buf[100];
    scanf("%s",buf);
    int cnt[256]={};
    for(int i=0;buf[i];i++){
        cnt[(unsigned int)buf[i]]++;
    }
    if(cnt['a']==1 && cnt['b']==1 && cnt['c']==1)puts("Yes");
    else puts("No");
    return 0;
}

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

using namespace std;

int main() {

	string s1,s2;

	cin >> s1 >> s2;

	long a, b;

	cin >> a >> b;

	string u;

	cin >> u;

	cout << (s1 == u ? a - 1 : a) << " "  << (s2 == u ? b - 1 : b) << endl;


	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    double a[8],b[8],kq=0;
    int n;
    cin>>n;
    for(int i=0;i<n;++i)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<n-1;++i)
    {
        for(int j=i+1;j<n;++j)
        {
            kq+=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]));
        }
    }
    kq=kq*2/n;
    cout<<setprecision(8)<<fixed;
    cout<<kq;
    return 0;
}


Measured memory_bytes: 256