akhauriyash/Code-Regression huggingface dataset:
class BinaryTree:
    def __init__(self, left, right, parent):
        self.left = left
        self.right = right
        self.parent = parent
        self.key = None
        self.root = False
        

def insert(T, z):
    global root
    
    y = -1
    try:
        x = root
    except:
        x = -1
        root = z
        T[z].root = True
    
    while x != -1:
        y = x
        if T[z].key < T[x].key:
            x = T[x].left
        else:
            x = T[x].right
    T[z].parent = y
    
    if y == -1:
        pass
    
    elif T[z].key < T[y].key:
        T[y].left = z
        
    else:
        T[y].right = z

def find(T, z, s):
    if s == -1:
        return [False, None]
        
    elif T[s].key == z:
        return [True, s]
        
    elif T[s].key < z:
        return find(T, z, T[s].right)
        
    else:
        return find(T, z, T[s].left)

def delete(T, z):
    global root
    z_has_left = T[z].left != -1
    z_has_right = T[z].right != -1
    
    
    if (not z_has_left) or (not z_has_right):
        y = z
    else:
        y = getsucsessor(T, z)


    if T[y].left != -1:
        x = T[y].left
    else:
        x = T[y].right
    
    if x != -1:
        T[x].parent = T[y].parent
    
    if T[y].root:
        T[x].root = True
        T[y].root = False
        root = x
    
    elif T[T[y].parent].left == y:
        T[T[y].parent].left = x
    else:
        T[T[y].parent].right = x
    
    T[z].key = T[y].key
    T[y] = BinaryTree(-1, -1, -1)

def getsucsessor(T, x):
    if T[x].right != -1:
        
        return getMinimum(T, T[x].right)
        
    else:
        y = T[x].parent
        while (y != -1) and (T[y].right == x):
            x = y
            y = T[y].parent
        return y

def getMinimum(T, x):
    while T[x].left != -1:
        x = T[x].left
    return x
        
    
def preParse(u):
    if u == -1:
        return 0
    print(" " + str(T[u].key), end="")
    preParse(T[u].left)
    preParse(T[u].right)

def inParse(u):
    if u == -1:
        return 0
    inParse(T[u].left)
    print(" " + str(T[u].key), end="")
    inParse(T[u].right)

m = int(input().rstrip())

z = 0
T = []
for _ in range(m):
    T.append(BinaryTree(-1, -1, -1))

for _ in range(m):
    command = input().rstrip()
    if command =="print":
        inParse(root)
        print()
        preParse(root)
        print()
    else:
        command, key = command.split(" ")
        key = int(key)
    
    
    if command == "insert":
        T[z].key = key
        insert(T, z)
        z += 1
        
    elif command == "find":
        if find(T, key, root)[0]:
            print("yes")
        else:
            print("no")
    
    elif command == "delete":
        x = find(T, key, root)[1]
        
        delete(T, x)
        




Measured memory_bytes: 118448
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<pair<int, int> > AB(M);
    int a, b;
    for (auto &ab : AB) {
        cin >> a >> b;
        ab = make_pair(a, b);
    }
    sort(AB.begin(), AB.end(), [](const pair<int, int> &a, const pair<int, int> &b) {
        return a.first > b.first;
    });
    set<int> S{AB[0].first};
    for (int i = 1; i < M; i++) {
        auto it = upper_bound(S.begin(), S.end(), AB[i].first);
        if (it != S.end() && AB[i].second <= *it) S.insert(AB[i].first);
    }
    printf("%d\n", (int)S.size());
    return 0;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;
const intt INF = 1e18 + 5;

intt n;
int a[N];

int main() {

	FAST;

	cin >> n;
	intt ans = INF;
	for (int i = 1; 1LL * i * i <= n; i ++) {
		if (n % i == 0) {
			ans = min(ans, i + n / i - 2);
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef pair<int, int> P;
struct edge{
    int to;
    int cost;
    edge(int to, int cost) : to(to), cost(cost){}
};
struct D{
    vector< vector<edge> > graph;
    vector<int> dist;

    void init(int size){
        dist.assign(size, 1e9);
        graph.assign(size, vector<edge>() );
    }

    void add_edge(int from, int to, int cost){
        graph[from].push_back(edge(to, cost));
    }

    void dijkstra(int from){
        priority_queue<P, vector<P>, greater<P> > q;
        dist[from] = 0;
        q.push(P(0, from));
        while(!q.empty()){
            P p = q.top();
            q.pop();
            int v = p.second;
            if(dist[v] < p.first)continue;
            for(int i = 0; i < graph[v].size(); i++){
                edge e = graph[v][i];
                if(dist[e.to] > dist[v] + e.cost){
                    dist[e.to] = dist[v] + e.cost;
                    q.push(P(dist[e.to], e.to));
                }
            }
        }
    }
};
int main(void){
    int n, ans = 0;
    string s[200];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s[i];
    }

    for(int st=0;st<n;st++){
        D d;
        d.init(n);
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(s[i][j] == '1'){
                    d.add_edge(i, j, 1);
                }
            }
        }
        d.dijkstra(st);
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(s[i][j] == '1' && d.dist[i] == d.dist[j]){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
        for(int i=0;i<n;i++){
            ans = max(ans, d.dist[i]);
        }
    }
    cout << ans+1 << endl;
}


Measured memory_bytes: 768
s = input()
s1, s2 = int(s[:2]), int(s[2:])

if 1 <= s1 <= 12 and 1 <= s2 <= 12:
    print("AMBIGUOUS")
elif 1 <= s1 <= 12:
    print("MMYY")
elif 1 <= s2 <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var s = Console.ReadLine().Trim();
            if (s == "-") goto readend;
            var n = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < n; i++)
            {
                var h = int.Parse(Console.ReadLine().Trim());
                s = s.Remove(0, h) + s.Substring(0, h);
            }
            Console.WriteLine(s);
        }
        readend:;
    }
}

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

int main(void) {
    
    int x,a,b;
    cin >> x >> a >> b;
    int tmp = x - a;
    while(tmp-b>=0){
        tmp -= b;
    }
    cout << tmp << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b;
	cin >> a >> b;
	if(a % b != 0)cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
import math

def multi_gcd(a,b,c):
    tmp = math.gcd(a, b)
    return math.gcd(tmp, c)

def get_now_ans(a, b, c):
    times = None
    if a == b == c:
        times = 1
    elif (a == b) or (b == c):
        times = 3
    else:
        times = 6
    return multi_gcd(a,b,c) * times

def calc_num(now_n):
    now_ans = 0
    a = now_n
    for b in range(1, now_n + 1):
        for c in range(1, now_n + 1):
            if c > b:
                continue
            else:
                now_ans += get_now_ans(a,b,c)
    return now_ans

K = int(input())

ans = 0
for i in range(1, K + 1):
    ans += calc_num(i)
print(ans)


Measured memory_bytes: 9216
def main():
    import sys
    N = int(sys.stdin.readline())
    L1 = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
    #print(L1)
    edge = [[] for _ in range(N+1)]
    for row in L1:
        for ele in row[2:]:
            edge[row[0]].append(ele)
            #edge[ele].append(row[0])

    #print(edge)
    sys.setrecursionlimit(1000)
    
    go = [-1 for _ in range(N+1)]
    go[0], go[1] =0, 1
    back = [-1 for _ in range(N+1)]
    
    d = [1]
    def dfs(p):
        if edge[p]:
            for c in edge[p]:
                if go[c]==-1:
                    d[0]+=1
                    go[c] = d[0]
                    dfs(c)
        
        #抜ける順
        d[0]+=1
        back[p] =d[0]
                
    dfs(1)
    for i in range(2, N+1):
        if go[i] ==-1:
            d[0]+=1
            go[i] = d[0]
            dfs(i)
    for i in range(1, N+1):
        print(i, go[i], back[i])




if __name__=='__main__':
    main()


Measured memory_bytes: 5664
// myfirstatcoder.cpp : アプリケーションのエントリ ポイントを定義します。

#include "bits/stdc++.h"
#define rep(i,cc,n) for(int i=cc;i<(n);++i)
#define drep(i,cc,n) for(int i=cc;i>(n);--i)
#define llrep(i,cc,n) for(long long i=cc;i<(n);++i)
using namespace std;
using ll = long long;

int main()
{
	string s, t;
	cin >> s >> t;
	int f = 0,i;
	for(i=0;i< s.length();++i)
	{
		if (s.at(i) != t.at(i))
			f = 1;
	}
	if (f == 1)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}

/*
ライブラリ
・string
・vector<int>
::::vector<vector<int>> A(N,vector<int>(M));
::::A[i][j] = i;
・map<string,int>

関数
・gcd(int, int) … 最大公約数 int
・find_string(str, str) … 文字列検索 bool
*/

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll n,k;cin>>n>>k;

	if(n>k){
		n%=k;
	}

	cout<<min(k-n,n)<<"\n";
	}

Measured memory_bytes: 256
#include<iostream>

int data[10][10];

int main(){
	int count=0,max=0;
	int x,y,size;
	char c;

	int dx_1[4]={0,-1,1,0},dy_1[4]={-1,0,0,1};
	int dx_2[8]={0,-1,1,-1,1,0,-1,1},dy_2[8]={-1,-1,-1,0,0,1,1,1};
	int dx_3[12]={0,-1,1,-1,1,-2,2,0,-1,1,0,0},dy_3[12]={-1,-1,-1,0,0,0,0,1,1,1,-2,2};
	
	while(std::cin>>x>>c>>y>>c>>size){
		data[y][x]++;
		if(size==1){
			for(int i=0;i<4;i++){
				int nx=x+dx_1[i],ny=y+dy_1[i];
				if(nx>=0&&nx<10&&ny>=0&&ny<10)data[ny][nx]++;
			}
		}else if(size==2){
			for(int i=0;i<8;i++){
				int nx=x+dx_2[i],ny=y+dy_2[i];
				if(nx>=0&&nx<10&&ny>=0&&ny<10)data[ny][nx]++;
			};
		}else if(size==3){
			for(int i=0;i<12;i++){
				int nx=x+dx_3[i],ny=y+dy_3[i];
				if(nx>=0&&nx<10&&ny>=0&&ny<10)data[ny][nx]++;
			}
		}
	}
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			max=std::max(max,data[i][j]);
			if(data[i][j]==0)count++;
		}
	}
	std::cout<<count<<std::endl;
	std::cout<<max<<std::endl;
	return 0;
}

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

using namespace std;

int main(){
    int n,m;
    cin>>n;
    vector<string> hoge(n);
    map<string,int> blue;
    map<string,int> red;
    
    for(int i=0;i<n;i++){
        cin>>hoge.at(i);
        string s=hoge.at(i);
        if(blue.count(s)) blue.at(s)++;
        else blue[s]=1;
        
        red[s]=0;
    }
    
    cin>>m;
    for(int i=0;i<m;i++){
        string s;
        cin>>s;
        if(red.count(s)) red.at(s)++;
        else red[s]=1;
        
        if(!blue.count(s)) blue[s]=0;
    }
    
    int ans=0;
    
    for(auto a:hoge){
        ans=max(ans,blue.at(a)-red.at(a));
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <climits>
#include <ctime>
#include <cmath>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

#define sz(x) (int)(x.size())

typedef long long ll;
typedef tuple<int, int, int> tri;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef __gnu_pbds::tree<
    int,
    __gnu_pbds::null_type,
    less<int>,
    __gnu_pbds::rb_tree_tag,
    __gnu_pbds::tree_order_statistics_node_update>
    ordered_set;

const ll MODULO = 1000000007;

void ftime()
{
#ifndef ONLINE_JUDGE
    cout << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
#endif
}

static int speed_increase = []() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    return 0;
}();

const ll limit = (int)1e6 + 1;
vll sieve(limit, 1);
void eratosthenes()
{
    for (ll i = 2; i < limit; i++)
    {
        if (sieve[i] == 1)
        {
            for (ll j = i * i; j < limit; j += i)
            {
                sieve[j] = i;
            }
        }
    }
}

vb done(1e6+1, false);
vi arr(1e6 + 1);
bool pairwise(int n)
{
    for(int i=n; i>0; --i) {
        if(arr[i] == 1)
            continue;
        while(sieve[arr[i]] != 1) {
            int p = sieve[arr[i]];
            if(done[p])
                return false;
            while(arr[i]%p == 0)
                arr[i] = arr[i]/p;
            done[p] = true;
        }
        if(arr[i] == 1)
            continue;
        if(done[arr[i]])
            return false;
        done[arr[i]] = true;
    }
    return true;
}

void solve()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> arr[i];
    }
    int x = arr[1];
    for (int i = 2; i <= n; ++i)
    {
        x = gcd(x, arr[i]);
    }
    if (pairwise(n))
        cout << "pairwise coprime\n";
    else if (x == 1)
        cout << "setwise coprime\n";
    else
        cout << "not coprime\n";
}

int main()
{
    eratosthenes();
    solve();
    // ftime();
    return 0;
}

Measured memory_bytes: 15004
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
for(int i=0; ;i++){
 int H=sc.nextInt();
int W=sc.nextInt();
if(H==0 && W==0)break;
for(int j=0;j<H;j++){
for(int k=0;k<W;k++){
System.out.print("#");
}
System.out.println("");
}
System.out.println("");
}
}
}



Measured memory_bytes: 34212
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        char[] s = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine()[0]).ToArray();
        long[] count = new char[] { 'M', 'A', 'R', 'C', 'H' }.Select(x => s.LongCount(y => y == x)).ToArray();
        long res = 0;
        for (int i = 0; i < 5; i++)
        {
            for (int j = i + 1; j < 5; j++)
            {
                for (int k = j + 1; k < 5; k++)
                {
                    res += count[i] * count[j] * count[k];
                }
            }
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 15968
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		//*
		m.input();
		m.solve();
		m.output();
		/*/
		m.debug();
		//*/
	}
	
	public void debug() {
	}
	
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String S = null;
	/*/
	InputUtil in = new InputUtil();
	//*/
	PrintWriter out = new PrintWriter(System.out);
	int N = 0;
	int[] A = null;
	int[] B = null;
	long cA = 0;
	long cB = 0;
	boolean ans = false;
	
	public void input() throws IOException {
		N = in.nextInt();
		A = in.nextInt(new int[N]);
		B = in.nextInt(new int[N]);
	}
	
	public void solve() throws IOException {
		for (int i=0; i<N; i++) {
			int abs = Math.abs(A[i]-B[i]);
			if (A[i]>B[i]) {
				cB += abs;
			} else if (A[i]<B[i]) {
				if (abs%2 == 0) {
					cA += abs/2;
				} else {
					cA += (abs+1)/2;
					cB += 1;
				}
			}
		}
		if (cB > cA) {
			ans = false;
		} else {
			ans = true;
		}
	}
	
	public void output() {
		out.println(ans ? "Yes" : "No");
		out.flush();
	}
}

//*
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }
 
	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}
 
	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}
}
//*/


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
# define pi acos(-1)
main()
{

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

    long long i,j,k,l,m,n,o,p;
     char s[10000];
     while(cin>>p>>s){
            l=strlen(s);
        l=strlen(s);
     if(l<=p){
        for(i=0;i<l;i++)cout<<s[i];
     }
     else{
        for(i=0;i<p;i++)cout<<s[i];
       cout<<"...";
     }
     cout<<endl;
     }
    return 0;

}


Measured memory_bytes: 3660
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

lli N, A, B, C, a[10];
lli ans = INF;

void dfs(lli idx, lli sa, lli sb, lli sc, lli na, lli nb, lli nc) {
    if (idx > N) {
        if (na > 0 and nb > 0 and nc > 0) {
            lli cost = abs(sa - A) + abs(sb - B) + abs(sc - C);
            cost += (na + nb + nc - 3) * 10;
            ans = min(cost, ans);
        }
        return;
    }
    dfs(idx + 1, sa + a[idx], sb, sc, na + 1, nb, nc);
    dfs(idx + 1, sa, sb + a[idx], sc, na, nb + 1, nc);
    dfs(idx + 1, sa, sb, sc + a[idx], na, nb, nc + 1);
    dfs(idx + 1, sa, sb, sc, na, nb, nc);

}

void solve() {
    cin >> N >> A >> B >> C;
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
    }
    dfs(1, 0, 0, 0, 0, 0, 0);
    cout << ans << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
struct Vector2D {
	double x;
	double y;
};

struct Vector2D sub_vector(struct Vector2D *a, struct Vector2D *b)
{
	struct Vector2D ret;
	ret.x = b->x - a->x;
	ret.y = b->y - a->y;
	return ret;
};

int main(void)
{
	struct Vector2D a, b, c, d;
	struct Vector2D vecAB, vecBC, vecCD, vecDA;
	double c1, c2, c3, c4;

	while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&a.x,&a.y, &b.x, &b.y, &c.x, &c.y, &d.x, &d.y) != EOF) {
		vecAB = sub_vector(&a,&b);
		vecBC = sub_vector(&b,&c);
		vecCD = sub_vector(&c,&d);
		vecDA = sub_vector(&d, &a);

		c1 = vecAB.x * vecBC.y - vecAB.y * vecBC.x;
		c2 = vecBC.x * vecCD.y - vecBC.y * vecCD.x;
		c3 = vecCD.x * vecDA.y - vecCD.y * vecDA.x;
		c4 = vecDA.x * vecAB.y - vecDA.y * vecAB.x;

		if ((c1 > 0 && c2 > 0 && c3 > 0 && c4 > 0)|| (c1 < 0 && c2 < 0 && c3 < 0 && c4 < 0))
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	string s;

	cin>>s;

	if(s.size()%2!=0)cout<<"No"<<endl;
	else{
		REP(i,0,s.size()/2){
			if(s.at(i*2)!='h' || s.at(i*2+1)!='i'){
				cout<<"No"<<endl;
				return 0;
			}
		}
		cout<<"Yes"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
// In the Name of Allah
// Ya Ali

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define F first
#define S second
#define all( x ) x.begin() , x.end()
#define pb push_back
#define mp make_pair

const int maxn = 2e5 + 10 ;
const int mod = 998244353 ;
const int INF = 1e18 ;

int n , ans = 0 ;
vector< int > v1 , v2 ;

signed main()
{
 ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

 cin >> n ;
 for(int i = 1 ; i <= n ; i ++){
   int a , b ;
   cin >> a >> b ;
   v1.pb( a );
   v2.pb( b );
 }

 sort( all( v1 ) ) ;
 sort( all( v2 ) ) ;

 if( n%2 == 0 ){
   cout << (v2[ (n/2) -1] + v2[ n/2 ] ) - (v1[ (n/2) - 1 ] + v1[ n/2 ]) + 1 ;
 }
 else{
   cout << v2[ n/2 ] - v1[ n/2 ] + 1 ;
 }

    return 0;
}


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

int s[111111];
int main() {
	int n;
	cin >> n;
	long m = 0;
	for (int i = 0; i < n; i++)
		scanf("%d", s + i);
	for (int d = 1; d < n; d++) {
		long t = 0;
		for (int j = d; j < ((n - 1) % d ? n - d : n - 1 - j); j += d)
			t += s[j] + s[n - 1 - j], m = max(m, t);
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//https://www.nayuki.io/page/next-lexicographical-permutation-algorithm
fn next_permutation<T : Ord + Copy>(v: &mut Vec<T>) {  
  //find longest non-increasing suffix
  //後ろから見て，次に下がるところまで
  
  let vlen = v.len();
  let mut prev = *v.last().unwrap();
  let mut i = vlen as i32 - 2;
  let mut pivoto = None;
  loop {
    if i < 0 {
      pivoto = None;
      break;
    }
    
    if v[i as usize] < prev {
      //前回より小さい値 => ここが探した点！
      pivoto = Some(i);
      break;
    }
    
    prev = v[i as usize];
    i -= 1;
  };
  
  match pivoto {
    None => {
      //最後なので，単にソート
      v.sort();
    }
    Some(pivot) => {
      //find rightmost successor to pivot in the suffix
      let mut i = vlen as i32 - 1;
      let succ;
      loop {
        assert!(i >= 0);
        
        if v[i as usize] > v[pivot as usize] {
          succ = i;
          break;
        }
        
        i -= 1;
      };
      
      v.swap(succ as usize, pivot as usize);
      
      v[pivot as usize + 1..vlen as usize].sort();
    }
  }
}

fn main() {
  let n : i32 = read();
  let mut v = Vec::<i32>::new();
  let mut xs = Vec::<i32>::new();
  let mut ys = Vec::<i32>::new();
  let mut rep_count = 1;
  for i in 0..n {
    v.push(i);
    xs.push(read());
    ys.push(read());
    rep_count *= i + 1;
  }
  
  let mut avg: f64 = 0.0;
  
  for _i in 0..rep_count {
    for j in 0..n-1 {
      let xt = (xs[v[j as usize + 1] as usize] - xs[v[j as usize] as usize]) as f64;
      let yt = (ys[v[j as usize + 1] as usize] - ys[v[j as usize] as usize]) as f64;
      
      avg += (xt * xt + yt * yt).sqrt();
    }
    
    next_permutation(&mut v);
  }
  
  let res = avg / rep_count as f64;
  println!("{:.10}", res);
  
}


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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;

int main(){
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	int g=0,n,k,a[100];
	cin>>n>>k;
	rep(i,n){
		cin>>a[i];
		a[i]=-a[i];
	}
	sort(a+1,a+n+1);
	rep(i,k){
		g-=a[i];
	}
	cout<<g;
	return 0;
}

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

int main(void)
{
	int n, alice, bob;
	vector<int> a;

	cin >> n;
	a.resize(n);
	rep(i, n) cin >> a[i];
	sort(a.rbegin(), a.rend());
	alice = 0;
	bob = 0;
	rep(i, n)
	{
		if (i % 2 == 0)
			alice += a.at(i);
		else
			bob += a.at(i);
	}
	cout << alice - bob << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vector<type> 
#define all(c) (c.begin(),c.end())


/*##################################################################################*/

/*
int prime[1000000] = {0} ;
void calculateprime()
{
    //calculating primes
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; (ll)i*i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            for(ll j = i*i ; j <= 1000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}
*/

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        int n;cin>>n;
        ll sum = 0 ;
        for(int i = 1 ; i<= n ; i++)
        {
            if(i % 3 != 0 and i % 5 != 0)
            {
                sum += i ;
            }
        }
        cout<<sum;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

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

int main(){
    int n, q;
    cin >> n;
    string s;
    cin >> s;
    cin >> q;
    vector<int> wa(n);
    wa[0] = 0;
    FOR(i, 1, n){
        if(s[i] == 'M') wa[i] = wa[i - 1] + 1;
        else wa[i] = wa[i - 1];
    }
    vector<ll> cwa(n);
    vector<ll> ccount(n);
    REP(i, n){
        if(i < 2){
            cwa[i] = ccount[i] = 0;
        }
        if(s[i] == 'C'){
            cwa[i] = cwa[i - 1] + wa[i - 1];
            ccount[i] = ccount[i - 1] + 1;
        }else{
            cwa[i] = cwa[i - 1];
            ccount[i] = ccount[i - 1];
        }
    }
    REP(i, q){
        int k;
        cin >> k;
        ll ans = 0;
        REP(i, n - 2){
            if(s[i] == 'D'){
                ans += cwa[min(i + k - 1, n - 1)] - cwa[i] - wa[i] * (ccount[min(i + k - 1, n - 1)] - ccount[i]);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 20868
open System

let readInts () = stdin.ReadLine().Split(' ') |> Array.map int64
let uncurry f (a,b) = f a b

let args = readInts()
let k, n = args.[0], int args.[1]
let a = readInts()
let b = Array.append (Array.tail a) [|a.[0]+k|]
let m = Array.map2 (-) b a |> Array.max
printfn "%d" (k - m)

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

//Quality Checking
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int k = sc.nextInt()+sc.nextInt()+sc.nextInt();
			if(k==0)break;
			int n = sc.nextInt();
			int[] a = new int[k+1];
			Arrays.fill(a, 2);
			int[][] b = new int[n][4];
			for(int i=0;i<n;i++){
				for(int j=0;j<4;j++){
					b[i][j] = sc.nextInt();
				}
				if(b[i][3]==1){
					for(int j=0;j<3;j++)a[b[i][j]] = 1;
				}
			}
			for(int i=0;i<n;i++){
				if(b[i][3]==1)continue;
				int c = 0;
				for(int j=0;j<3;j++)c+=a[b[i][j]]==1?1:0;
				if(c==2){
					for(int j=0;j<3;j++)if(a[b[i][j]]!=1)a[b[i][j]]=0;
				}
			}
			for(int i=1;i<=k;i++)System.out.println(a[i]);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main(){
    int in_num;
    char num_s8[12];
    while(1){
        cin  >> in_num;
        if(in_num == 0){
            break;
        }
        snprintf(num_s8, sizeof(num_s8), "%o", in_num);
        for(int i=0; i<strlen(num_s8); i++){
            if(num_s8[i] == '4'){
                num_s8[i] = '5';
            }
            
            else if(num_s8[i] == '5'){
                num_s8[i] = '7';
            }
            
            else if(num_s8[i] == '6'){
                num_s8[i] = '8';
            }
            else if(num_s8[i] == '7'){
                num_s8[i] = '9';
            }
            
        }
        printf("%s\n", num_s8);
    }
   
    return 0;
}

Measured memory_bytes: 1156
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;



int main() {
	//fios;
	ll n, q;
	cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	unordered_map<ll, ll> mp;
	for(auto& x: a) cin >> x, sum += x, mp[x]++;

	cin >> q;
	ll b, c;
	// vector<pair<ll, int>> bc(q);
	for(int i = 0; i < q; i++) {
		// cin >> bc[i].first >> bc[i].second;
		cin >> b >> c;
		if(mp.find(b) != mp.end()) {
			sum -= b * mp[b];
			sum += c * mp[b];
			mp[c] += mp[b];
			mp.erase(b);
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 7432
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int *t = new int[n];
	for (int i = 0; i < n; i++)cin >> t[i];
	int m;
	cin >> m;
	int *p = new int[m];
	int *x = new int[m];
	for (int i = 0; i < m; i++)cin >> p[i] >> x[i];

	for (int i = 0; i < m; i++) {
		int S = 0;
		for (int j = 0; j < n; j++) {
			if ((p[i]-1) == j)S += x[i];
			else S += t[j];
		}
		cout << S << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        R: usize, C: usize, K: usize,
        yxv: [(usize, usize, i64); K],
    }

    let mut items = vec![vec![0; C+1]; R+1];
    for (y, x, v) in yxv {
        items[y][x] = v;
    }

    let mut dp = vec![vec![vec![0; 5]; C+1]; R+1];
    for y in 1..R+1 {
        for x in 1..C+1 {
            let from_above = *dp[y-1][x].iter().max().unwrap();
            dp[y][x][0] = max(dp[y][x][0], from_above);
            dp[y][x][1] = max(dp[y][x][1], from_above + items[y][x]);
            for k in 0..=3 {
                let from_left = dp[y][x-1][k];
                dp[y][x][k] = max(dp[y][x][k], from_left);
                dp[y][x][k+1] = max(dp[y][x][k+1], from_left + items[y][x]);
            }
            dp[y][x][4] = 0;
        }
    }
    let ans = dp[R][C].iter().max().unwrap();
    println!("{}", ans);

}


Measured memory_bytes: 708776
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main() {
	long long d, t, s;
	cin >> d >> t >> s;

	if (d - t * s > 0)cout << "No" << endl;
	else cout << "Yes" << endl;
}



Measured memory_bytes: 3672
#include <map>
#include <iostream>

using namespace std;

int main() {
    map<string, int> m;
    m["RRR"] = 3;
    m["RRS"] = 2;
    m["RSR"] = 1;
    m["RSS"] = 1;
    m["SRR"] = 2;
    m["SRS"] = 1;
    m["SSR"] = 1;
    m["SSS"] = 0;
    string s;
    cin >> s;
    cout << m[s] << endl;
}

Measured memory_bytes: 3612
def kmpTable(w):
    lw = len(w)
    nx = [-1] * (lw + 1)
    j = -1
    for i in xrange(lw):
        while j >= 0 and w[i] != w[j]:
            j = nx[j]
        j += 1
        nx[i + 1] = j
    return nx

def kmpSearch(s, w):
    ls = len(s)
    start = 0
    w_idx = 0
    ret = []
    nx = kmpTable(w)
    while start + w_idx < ls:
        if s[start + w_idx] == w[w_idx]:
            w_idx += 1
            if w_idx == len(w):
                ret.append(start)
                start = start + w_idx - nx[w_idx]
                w_idx = nx[w_idx]
        else:
            if w_idx == 0:
                 start += 1
            else:
                start = start + w_idx - nx[w_idx]
                w_idx = nx[w_idx]
    return ret
    
T = raw_input()
P = raw_input()
ans = kmpSearch(T, P)
for i in ans:
    print(i)

Measured memory_bytes: 38992
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
//#define ABS(a) (a>0?(a):(-a))
double ABS(double a)
{
  return (a>=0?(a):(-a));
}

int main(void)
{
  long N,T,A;
  long h;
  double t;
  double def[1000];
  long i;
  double min=1000;
  long min_idx;

  scanf("%ld %ld %ld",&N,&T,&A);
  for(i=0;i<N;i++){
    scanf("%ld",&h);
    t = T - h*0.006;
    def[i] = ABS(t-A);
    if(min>def[i]){
      min = def[i];
      min_idx = i;
    }
  }

  printf("%ld",min_idx+1);
  return 0;
}


Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	ans := 0
	for i := 0; i < n; i++ {
		for a := ri(); a&1 == 0; a >>= 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
-- Multi lines of lists
import Data.Traversable
import Data.List

main = do
  t <- read <$> getLine
  ps <- for [1..t] $ \x -> do
    (\xs -> (read $ xs!!0, xs!!1)) . words <$> getLine
  putStrLn . show $ solve ps

solve :: [(Double, String)] -> Double
solve [] = 0
solve ((x,c):xs) = case c of
  "JPY" -> x + (solve xs)
  "BTC" -> 380000.0 * x + (solve xs)


Measured memory_bytes: 636
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
ans = 0
lst = [False] * n
for i in range(n):
  if i < k or t[i] != t[i-k] or not lst[i-k]:
    ans += p if t[i] == 'r' else r if t[i] == 's' else s
    lst[i] = True
print(ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    if(s[0] != s[1] || s[1] != s[2] || s[2] != s[0]) Yes();
    else No();
}

Measured memory_bytes: 256
N = int(input())
symb = None
hints = []

for _ in range(N):
  hint = tuple(map(int, input().split()))
  if symb is None and hint[2]!=0:
    symb = hint
  else:
    hints.append(hint)


Hs = dict()
for i in range(0, 101):
  flag = False
  for j in range(0, 101):
    cand = symb[2] + abs(i-symb[0]) + abs(j-symb[1])
    contradict = False
    for x, y, h in hints:
      if max(cand - abs(x-i) - abs(y-j), 0) != h:
        contradict = True
        break
    if not contradict:
      flag = True
      print(i, j, cand)
      break
  if flag:
    break

      


Measured memory_bytes: 3064
S = input()

if S == 'SUN':
    answer = 7
elif S == 'MON':
    answer = 6
elif S == 'TUE':
    answer = 5
elif S == 'WED':
    answer = 4
elif S == 'THU':
    answer = 3
elif S == 'FRI':
    answer = 2
elif S == 'SAT':
    answer = 1
else:
    answer = '入力間違い【SUN】【MON】【TUE】【WED】【THU】【FRI】【SAT】を入力'

print(answer)


Measured memory_bytes: 8948
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char a[50];
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    a[k-1] = a[k-1] + 32;
    for(int i=0;i<n;i++)
        cout<<a[i];
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    long long N, Y;
 
    cin >> N >> Y;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            if(Y - i * 1000 - j * 5000 == (N - i - j) * 10000 && (N - i - j) >= 0){
                cout << (N - i - j) << ' ' << j << ' ' << i;
                return 0;
            }
        }
    }   
    
    cout << "-1 -1 -1" << endl;
    return 0;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j <= i + k; j++)
        {
            if (j < n)
            {
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
            }
        }
    }
    cout << dp[n - 1];
}

Measured memory_bytes: 4020
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: ident) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let (n, a, b): (usize, usize, usize) = parse!(it, 3);
    let c = n / (a + b);
    let r = n % (a + b);
    if r < a {
        println!("{}", c * a + r);
    } else {
        println!("{}", (c + 1) * a);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking 
#define fi first
#define se second
#define BG begin
#define ED end

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2

#define INF (1ll<<60)
using namespace std;
int n,a[200005];
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]),a[i]-=i;
	sort(a+1,a+n+1);
	ll ans=0; int md=(1+n)/2;
	For(i,1,n) ans+=abs(a[i]-a[md]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

string s;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	if(s.back() == 's') s += "es";
	else s += "s";
	
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 3640
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		long[] a = new long[n];
		long[] suml = new long[n];
		long[] sumr = new long[n];
		
		long curs = 0;
		for(int i = 0; i < n; i++)
		{
			a[i] = sc.nextLong();
			curs+=a[i];
			suml[i] = curs;
		}
		curs = 0;
		for(int i = n-1; i >= 0; i--)
		{
			curs+=a[i];
			sumr[i] = curs;
		}
		
		long score = 0;
		//try take l, r, rest is putting back
		for(int l = 0; l <= n; l++) //take up to n from left
			for(int r = 0; l+r <= k && l+r<=n; r++)
			{
				long toss = k - (l+r);
				long cur = 0;
				if(l>0)cur+=suml[l-1];
				if(r>0)cur+=sumr[n-r];
				
				PriorityQueue<Long> neg = new PriorityQueue<>();
				
				for(int i = 0; i < l; i++)
				{
					if(a[i] < 0)neg.add(a[i]);
				}
				for(int i = 0; i < r; i++)
				{
					int id = n-1-i;
					if(a[id] < 0)neg.add(a[id]);
				}
				
				for(int i = 0; i < toss && !neg.isEmpty(); i++)
				{
					long trash = neg.poll();
					cur -=trash;
				}
				score = Math.max(score, cur);
				
				
			}
		System.out.println(score);
	}

}


Measured memory_bytes: 24276
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll n,x=1e9+7,b=0,ans=0;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  REP(j,1, n){

      b+=a[j-1];

    b%=x;
    ans+=b*a[j]%x;
  }
  cout << ans%x << endl;
  return 0;
}


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

int md = 1e9 + 7;
map<int, int> p;

int pw(int x, int p) {
	if (!p)return 1;
	int t = pw(x, p >> 1);
	t = (ll)t * t % md;
	if (p & 1)t = (ll)t * x % md;
	return t;
}

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 1; i * i <= n; ++i)if (n % i == 0)p[i], p[n / i];
	for (map<int, int>::iterator it = p.begin(); it != p.end(); ++it) {
		it->second = pw(k, it->first + 1 >> 1);
		if (it->first == 1)continue;
		for (int i = 1; i * i <= it->first; ++i)if (it->first % i == 0) {
			it->second += md - p[i];
			if (it->second >= md)it->second -= md;
			if (it->first / i != i && i != 1) {
				it->second += md - p[it->first / i];
				if (it->second >= md)it->second -= md;
			}
		}
	}
	int an = 0;
	for (map<int, int>::iterator it = p.begin(); it != p.end(); ++it) {
		an += (ll)it->second * (it->first & 1 ? it->first : it->first >> 1) % md;
		if (an >= md)an -= md;
	}
	printf("%d\n", an);
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	string S;
	cin >> S;
	char c = S[0];
	int ans = 0;
	for (int i = 1; i < S.size(); i++) {
		if (S[i] != c) {
			c = S[i];
			ans++;
		}
	}

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

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
#include <numeric>
using namespace std;

int main(){
    vector<string> ss;
    string s;
    int n;
    int flag = 1;
    
    cin >> n;
    int i, j;
    char tmp;
    cin >> s;
    ss.push_back(s);
    tmp = s[s.size()-1];
    for(i = 1; i < n; i++){
        cin >> s;
        if(tmp != s[0]){
            flag = 0;
        }
        tmp = s[s.size()-1];
        for(j = 0; j < ss.size(); j++){
            if(ss[j]==s){
                flag = 0;
            }
        }
        ss.push_back(s);
    }
    
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import sys
n=int(input())
a=[[[0 for i in range(10)] for i in range(3)] for i in range(4)]
for i in range(n):
    w=input().split()
    b=(int(w[0]))
    f=(int(w[1]))
    r=(int(w[2]))
    v=(int(w[3]))
    a[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(3):
        for k in range(10):
            sys.stdout.write(" {0}".format(a[i][j][k]))
        sys.stdout.write("\n")
    if (i!=3):
        for x in range(20):
            sys.stdout.write("#")
        sys.stdout.write("\n")

Measured memory_bytes: 5628
import java.util.Scanner;

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

        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int c = stdIn.nextInt();
        int d = stdIn.nextInt();

        if (c >= b || a >= d)
            System.out.println(0);
        else if ((a <= c && b >= d) || (c <= a && d >= b))
            System.out.println((b - a) < (d - c) ? b - a : d - c);
        else
            System.out.println((b > c && c >= a) ? b - c : d - a);

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	int a, b, c;
	a = A + B;
	b = A - B;
	c = A * B;

	cout << max(max(a, b), c) << endl;
}

Measured memory_bytes: 3580