akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
         double area = r*r*Math.PI;
         double cir = 2*r*Math.PI;
        System.out.printf("%.5f ",area);
        System.out.printf("%.5f",cir);

        sc.close();
    }  
}


Measured memory_bytes: 28268
int main()
{
 int i,a,b;
 char op;
 for(i=0;;i++){
  scanf("%d %c %d", &a, &op, &b);
  if ( op == '+' ){
   printf("%d\n",a + b);
  } else if ( op == '-' ){
   printf("%d\n",a - b);
  } else if ( op == '*' ){
   printf("%d\n",a * b);
  } else if ( op == '/' ){
   printf("%d\n",a / b);
  } else if ( op == '?' )break;
  }return 0;
} 

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int a[200005];
int b[200005];

int main(){
    int n;
    cin >> n;
    for(int i=2;i<=n;i++) cin >> a[i];

    for(int i=2;i<=n;i++){
        b[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        cout << b[i] << endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void){

    int temprature;
    cin >> temprature;

    if(temprature >= 30) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <cassert>
#include <cstdio>
#include <cstring>

using namespace std;

//const char* INSERT       = "insert";
//const char* DELETE       = "delete";
//const char* DELETE_FIRST = "deleteFirst";
//const char* DELETE_LAST  = "deleteLast";

struct Node {
    int val;
    Node *next;
    Node *prev;
};

Node *head, *tail;

vector<Node*> cache;

int main(void) {

    int n;
    cin >> n;

    head = new Node;
    head->val = -1;

    tail = new Node;
    tail->val = -1;
    tail->next = head;
    tail->prev = head;

    head->next = tail;
    head->prev = tail;

    char command[12];
    for (int i = 0; i < n; ++i) {
        cin >> command;
        if (command[0] == 'i') {
//        if (strncmp(command, INSERT, 6) == 0) {
            int x;
            cin >> x;
            Node *newnode;
            if (cache.size() > 0) {
                newnode = cache.back();
                cache.pop_back();
            }
            else {
                newnode = new Node;
            }
            newnode->val = x;
            newnode->next = head->next;
            newnode->prev = head;
            head->next->prev = newnode;
            head->next = newnode;
        }
        else if (strlen(command) == 6) {
//        else if (strncmp(command, DELETE, 6) == 0) {
            int x;
            cin >> x;
            Node *node = head->next;
            while (node != tail) {
                if (node->val == x) {
                    node->next->prev = node->prev;
                    node->prev->next = node->next;
                    cache.push_back(node);
                    break;
                }
                node = node->next;
            }
        }
        else if (command[6] == 'F') {
//        else if (strncmp(command, DELETE_FIRST, 11) == 0) {
            Node *node = head->next;
            node->next->prev = head;
            head->next = node->next;
            cache.push_back(node);
        }
        else {
//        else if (strncmp(command, DELETE_LAST, 10) == 0) {
            Node *node = tail->prev;
            tail->prev = node->prev;
            node->prev->next = tail;
            cache.push_back(node);
        }
    }

    Node *node = head->next;
    if (node != tail) {
        printf("%d", node->val);
        node = node->next;
        while (node != tail) {
            printf(" %d", node->val);
            node = node->next;
        }
    }
    printf("\n");

    delete head;
    delete tail;

    return 0;
}

Measured memory_bytes: 41616
a = input()
count = 0
if len(a) > 3:
    for i in range(len(a)-2):
        if a[i] == a[i+1] or a[i] == a[i+2] or a[i+1] == a[i+2]:
            print(i+1,i+3)
            count += 1
            break
else:
    if a[0] == a[1]:
        print(1,2)
        count += 1
if count == 0:
    print(-1,-1)

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

int main(){
  long n,q;
  cin >> n;
  long a[n];
  long d[100005];
  rep(i,100005)d[i] = 0;
  long ans = 0;
  rep(i,n){
    cin >> a[i];
    d[a[i]]++;
    ans += a[i];
  }
  cin >> q;
  long b,c;
  rep(i,q){
    cin >> b >> c;
    ans += (c-b)*d[b];
    d[c] += d[b];
    d[b] = 0;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5168
#include<iostream>
#include <algorithm>
#include<queue>
using namespace std;


char s[200005];
int n, k, c;
int main() 
{
	cin >> n >> k >> c >> s;
	vector<int> l, r;
	int temp = 200005;
	for (int i = 0; i < n; i++)
	{
		if (l.size() == k)
			break;
		if (s[i] == 'o' && temp >= c)
		{
			l.push_back(i);
			temp = 0;
		}
		else
			temp++;
	}
	temp = 200005;
	for (int i = n - 1; i >= 0; i--)
	{
		if (r.size() == k)
			break;
		if (s[i] == 'o' && temp >= c)
		{
			r.push_back(i);
			temp = 0;
		}
		else
			temp++;
	}
	for (int i = 0; i < k; i++)
	{
		if (l[i] == r[k - i - 1])
			cout << l[i]+1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3444
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int calc(vi v){
    int ans = 0;
    for (int i = 0; i<v.size(); i++){
        ans += v[i];
        if (ans%10 != 0 and i!= v.size()-1) ans += (10-ans%10);
    }

    return ans;
}

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


    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;

    vi v = {a, b, c, d, e};

    int ans = 1000000;
    do {
        ans = min(ans, calc(v));
    } while (std::next_permutation(v.begin(), v.end()));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int dx[] = {-1,-1,-1,0,0,1,1,1};
int dy[] = {0,1,-1,1,-1,0,1,-1};
bool visited[100][100];
int w,h;
int f[100][100];
void dfs(int x,int y){
  visited[y][x] = true;
  for(int i=0;i<8;++i){
    int mx=x+dx[i];
    int my=y+dy[i];
    if(mx>=w||my>=h||mx<0||my<0) continue;
    if(visited[my][mx] || !f[my][mx]) continue;
    dfs(mx,my);
  }
}

int main(){
  while(cin>>w>>h,w||h){
    memset(visited,0,sizeof(visited));
    for(int i=0;i<h;++i)
      for(int j=0;j<w;++j) cin >> f[i][j];
    int cnt = 0;
    for(int i=0;i<h;++i)
      for(int j=0;j<w;++j){
	if(f[i][j]&&!visited[i][j]){
	  ++cnt;
	  dfs(j,i);
	}
      }
    cout << cnt << endl;
  }
  return 0;
}

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

using namespace std;

vector<vector<int>> floyd_warshall(const vector<vector<int>> &c)
{
	const int n = c.size();
	auto d = c;
	for (int k = 0; k < n; ++k) {
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	return d;
}

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<int>> c(10, vector<int>(10));
	for (auto &y : c) {
		for (auto &x : y) {
			cin >> x;
		}
	}

	auto b = floyd_warshall(c);

	int ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int A;
			cin >> A;
			if (A != -1) {
				ans += b[A][1];
			}
		}
	}
	cout << ans << endl;
}


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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            // string s = Console.ReadLine();

            // 整数の入力
            // long n = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            // string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            Code(inputLongArray);
        }

        public static void Code(long[] args)
        {
            var a = args[0];
            var b = args[1];
            var h = args[2];
            var m = args[3];
            float deg1 = h * 30f + (m / 60f) * 30f;
            float deg2 = m * 6f;
            float diff = deg1 < deg2 ? deg2 - deg1 : deg1 - deg2;

            double rad = diff * Math.PI / 180f;
            double result = a * a + b * b - 2 * a * b * Math.Cos(rad);

            Console.WriteLine(Math.Sqrt(result));
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28616
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> cnt(N+1, 0);
  FOR(i,0,N-1) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  FOR(i,1,N+1) {
    cout << cnt[i] << endl;
  }
}


Measured memory_bytes: 3984
#include<stdio.h>
int main()
{
  int n,debt=100000;
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      debt*=1.05;
      if(debt%1000!=0)
	{
	  debt/=1000;
	  debt*=1000;
	  debt+=1000;
	}
    }
  printf("%d\n",debt);
  return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    string N;
    cin >> N;
    char c = N[N.size()-1];
    if ((c == '2') || (c == '4') || (c == '5') || (c == '7') || (c == '9')) {
        cout << "hon" << endl;
    }
    else if ((c == '0') || (c == '1') || (c == '6') || (c == '8')) {
        cout << "pon" << endl;
    }
    else if ((c == '3')) {
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3628
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int main(){
  int x;
  cin >> x;
  for(int i=0,s=0;;++i,s+=i) {
    if(s>=x) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int input[210];

int _abs(int num)
{
	return (num < 0) ? -num : num;
}

int main()
{
	int N, L;
	int total = 0;

	scanf("%d %d", &N, &L);

	for (int i = 1; i <= N; ++i)
	{
		total += L + i - 1;
	}

	int ans_gap = 2147483647;
	int ans = -1;

	for (int i = 1; i <= N; ++i)
	{
		int num = L + i - 1;

		if (_abs(total - (total-num)) < ans_gap)
		{
			ans_gap = _abs(total - (total - num));
			ans = total - num;
		}
	}

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

	return 0;
}

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

long long basis[64][2];
long long A[205];
char S[205];
int basisSize[2] = {0, 0};

bool insertVector(long long mask, int mode, bool testing = false){
    for(int i = 61; i >= 0; i --){
        if((mask&(1LL<<i)) == 0){continue;}
        if(!basis[i][mode]){
            if(testing){return true;}
            basis[i][mode] = mask;
            basisSize[mode] ++;
            return true;
        }
        mask ^= basis[i][mode];
    }
    return false;
}

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

    while(t --){
        int n;
        scanf("%d", &n);

        memset(A, 0, sizeof(A));
        memset(basis, 0, sizeof(basis));
        memset(basisSize, 0, sizeof(basisSize));

        for(int i = 0; i < n; i ++){
            scanf("%lld", &A[i]);
        }

        scanf(" %s", S);

        int winner = 0;
        for(int i = n-1; i >= 0; i --){
            bool temp = insertVector(A[i], 0, false);
            if(temp == true && S[i] == '1'){
                winner = 1;
                break;
            }
        }

        printf("%d\n", winner);
    }
    return 0;
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 		String n = sc.next();
      String result = "";
      	if(n.length() == 1){
          result = getResult(n);
        }else if(n.length() == 2){
          result = getResult(n.substring(1,2));
        }else {
          result = getResult(n.substring(2,3));
        }
		System.out.println(result);
	}
  
  private static String getResult(String val){
    String result = "";
    switch(val){
      case "2":
      case "4":
      case "5":
      case "7":
      case "9":
        result = "hon";
        break;
      case "0":
      case "1":
      case "6":
      case "8":
        result = "pon";
        break;
      case "3":
        result = "bon";
        break;
    }
    return result;
  }
}



Measured memory_bytes: 35688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;


public class Main {
	public static final String EOF = System.lineSeparator();
	public static long l=0,l2=0;
	public static void main(String[] args) throws IOException {
		l = System.currentTimeMillis();
		new Main().exec();
		l2 = System.currentTimeMillis();
/*
		System.out.println((l2-l)+"msec");
//*/		
	}
	
	public void exec() throws IOException {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int H = in.nextInt();
		int W = in.nextInt();
		int N = in.nextInt();
		int[] A = in.nextInt(new int[N]);
		int[] B = new int[N];
		int ptrA = 0;
		int[][] HW = new int[H][W];
		for(int y=0; y<H; y++){
			int x = (y%2==0)?0:W-1;
			int dx = (y%2==0)?1:-1;
			while(0<=x && x<W){
				if(A[ptrA] <= B[ptrA])
					ptrA++;
				HW[y][x] = ptrA+1;
				B[ptrA]++;
				x += dx;
			}
		}
		for(int y=0; y<H; y++){
			out.print(HW[y][0]);
			for(int x=1; x<W; x++){
				out.print(" ");
				out.print(HW[y][x]);
			}
			out.println("");
		}
		out.flush();
	}
	
	
	
}


class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = 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) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			if(max>0) Arrays.fill(buf,0,max,(char)0);
			max = br.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		char 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: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b(m), c(m);
  vector<pair<int, int>> p;
  rep(i,m) {
    cin >> b[i] >> c[i];
    p.emplace_back(c[i], b[i]);
  }

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

  ll ans = 0;
  rep(i,n){
    if (p.empty()) {
      ans += a.back();
      a.pop_back();
      continue;
    }
    if (a.back() >= p.back().first){
      ans += a.back();
      a.pop_back();
    } else {
      ans += p.back().first;
      p.back().second--;
      if (p.back().second == 0) p.pop_back();
    }
  }

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


Measured memory_bytes: 5412
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int s=0;
	do{
		int a=n%10;
		if(a==9)
		s++;
		n=n/10;
	}while(n!=0);
	if(s==0)
	{
		cout<<"No";
	}
	else
	cout<<"Yes";
	return 0;
}

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

int main(){

    int x, y; cin >> x >> y;
    if(y>=2*x && y<=4*x && y%2==0) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3628
#include <stdio.h>

int main (void) {
  int n, a, b;
  int c, d, e, f, g=0;
  int s;
  scanf("%d%d%d", &n, &a, &b);



  int i, k=0;
  for (i=1;i<=n;i++) {
    //桁ごとに取り出す
    c=i%10;
    d=i%100/10;
    e=i%1000/100;
    f=i%10000/1000;
    g=i%100000/10000;
    int j=c+d+e+f+g;
    if (a <= j && j <= b)
      k += i;
  }

  printf("%d\n", k);
  
  return 0;
}


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


int main(){
	int e[4];
	cin >> e[0] >> e[1] >> e[2] >> e[3];
	sort(e,e+4);
	cout << (e[0] == e[1] && e[2] == e[3] ? "yes" : "no") << endl;	

	return 0;
}



Measured memory_bytes: 3160
def divisor(n):
    d = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            d.append(i)
            if i != n//i:
                d.append(n//i)
    return d

n = int(input())

ans = 10**12
for i in range(1,int(n**0.5)+1):
    if n%i == 0:
        ans = min(ans,i-1+n//i-1)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



string S;
//--------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;

    if (S.length() <= 3) printf("No\n");
    else {
        if (S.substr(0, 4) == "YAKI") printf("Yes\n");
        else printf("No\n");
    }
}

Measured memory_bytes: 256
def resolve_A():
    s1, s2 = input().split()
    n1, n2 = input().split()
    s = input()
    if s == s1:
        n1 = int(n1) - 1
    else:
        n2 = int(n2) - 1
    print(str(n1) + " " + str(n2))
resolve_A()

Measured memory_bytes: 2940
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 2e3 + 6, M = 1e9 + 7;
ll d[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, x, y;
    cin >> n >> x >> y;
    for (ll i = 1; i <= n; i++)
        for (ll j = i + 1; j <= n; j++)
            d[min({j - i, abs(i - x) + abs(j - y) + 1})]++;
    for (ll i = 1; i < n; i++)
        cout << d[i] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 200000;
int N;
ll A[Nmax];


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

	for(int i=0; i<N; i++) A[i] -= i+1;
	sort(A, A+N);

	ll x = 0;
	for(int i=0; i<N; i++){
		x += A[i]-A[0];
	}

	ll ans = x;
	for(int i=1; i<N; i++){
		x += i*(A[i]-A[i-1]) - (N-i)*(A[i]-A[i-1]);
		if(x < ans) ans = x;
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;
int a,b,c,n,cnt = 0;
int main(){
	scanf("%d%d%d%d",&a,&b,&c,&n);
	while (b <= a) {
		b *= 2;
		cnt++;
	}
	while (c <= b) {
		c *= 2;
		cnt++;
	}
	if (cnt <= n) {
		printf("Yes");
	}
	else
	printf("No");
    return 0;
}

Measured memory_bytes: 3824
#include<stdio.h>
int main()
{
  char a[100],b[100],i;
	int count=0;
		scanf("%s%s",a+1,b+1);
		for(i=1;i<=3;i++)
		{
			if(a[i]==b[i])
				count++;
		}
	printf("%d\n",count);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll M=1e9+7;
ll powe(ll a,ll b,ll c){
    if(b==0)
    return 1;
    if(b%2==0)
    {
        ll z=powe(a,b/2,c);
        return (z*z)%M;
    }
    else return (a*powe(a,b-1,c))%M;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k;
	cin>>n>>k;
	ll dp[k+1]={};
	ll i,j;
	ll sum=0,sum1=0;
	for(i=k;i>=1;i--){
		ll c0=0,c1=k/i;
		for(j=2*i;j<=k;j+=i)
			c0=(c0+dp[j])%M;
			ll z=(powe(c1,n,M)-c0+M)%M;
			//cout<<c0<<" "<<c1<<endl;
			sum=(sum+z*i)%M;
			dp[i]=z;


	}
	//for(i=1;i<=k;i++)
		//cout<<dp[i]<<" ";
	//cout<<endl;
	//cout<<sum<<endl;
	//sum=(sum+powe(k,n,M)-sum1+M)%M;
	cout<<sum%M;
	return 0;
} 

Measured memory_bytes: 4324
#include<bits/stdc++.h>
using namespace std;
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define f(i,a,n)        for(ll i=a;i<n;i++)
#define ve              vector
#define ss              second 
#define ff              first
#define pf              pop_front
#define pob             pop_back
#define psf             push_front
#define res(x)          cout<<x<<'\n'
#define read(t)         ll t;cin>>t

#define fast            ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
    

int main(){
    ll n;
    cin>>n;
    ll a[n];
    ll ans=0;
    f(i,0,n){
        cin>>a[i];
        ans=ans^a[i];
    }
    f(i,0,n){
        ll temp=ans^a[i];
        cout<<temp<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) 
{
 int n;
 cin >>n;
 if(n < 1200)
 {
   cout<<"ABC"<<endl;
 }
 else if(n < 2800)
 {
   cout<<"ARC"<<endl;
 }
 else
 {
   cout<<"AGC"<<endl;
 }
return 0;

}



Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  char a[10];
  int b, c, f;
  int ret;

  f=0;//for(f=0; f<10; ++f)  
  do
  {
    c=getchar();
    if( c==EOF )
    {
      a[f] = '\0';      
      break;
    }
    if( c>='0' && c<='9')
    {
      a[f] = c;
      ++f;
    }
  } while( f<sizeof(a) );
  //printf("%s", a);
  b = atoi(a);
  //printf("%d", b);

  for(f=1; f<=10000; ++f) 
  {
    if( f*f == b )
    {
      printf("Yes\n");
      break;
    }
    if( f*f > b )
    {
      printf("No\n");
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y, int p)
{
    int res = 1;

    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}

void solve()
{
int n;
cin>>n;
map<int,int>m;
while(n>0)
{
    m[n%10]++;
    n/=10;
}
if(m[7]>0)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;
}




signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
  solve();
}
}





Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  int N=s.size();
  s+='?';
  int ans=100;
  for(char i='a';i<='z';i++){
  int a=0;
    int b=0;
    for(int j=0;j<=N;j++)
      if(s.at(j)!=i && s.at(j)!='?')
        a++;
    else{
    if(b<a) b=a; a=0;
    }
  
     if(b<ans)
       ans=b;
  
  }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef double d;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    vector<string> v(n);
    for(auto &x:v)
    {
        cin>>x;
    }
    vector<vector<ll> > G(n,vector<ll>(m,0));
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            G[i][j]=(v[i][j]=='.')?1:0;
        }
    }
    for(ll i=1;i<n;i++)
    {
        if(G[i][0]==0){continue;}
        G[i][0] = (G[i-1][0])%M;
    }
    for(ll j=1;j<m;j++)
    {
        if(G[0][j]==0){continue;}
        G[0][j]=(G[0][j-1])%M;
    }
    for(ll i=1;i<n;i++)
    {
        for(ll j=1;j<m;j++)
        {
            if(G[i][j]==0){continue;}
            G[i][j] = (G[i-1][j]+G[i][j-1])%M;
        }
    }
    cout<<G[n-1][m-1];
    return 0;
}




Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1e9 + 7;
using namespace std;
int v[1001] = {};

int main()
{
    IOS
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> v[i];
    }
    int ans = 0;
    for(int i = 1;i <= n;)
    {
        int cnt = 1;
        while(i <= n && v[i] == v[i+1])
        {
            ++cnt;
            ++i;
        }
        ++i;
        ans += cnt/2;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
# 配るDP
N, A = map(int, input().split())
X = list(map(int, input().split()))

dp = [[[0 for _ in range(3010)] for __ in range(N+1)] for ___ in range(N+1)]

dp[0][0][0] = 1

for i in range(N):
    for j in range(N):
        for k in range(2500+1):
            if dp[i][j][k]:
                dp[i+1][j][k] += dp[i][j][k]
                dp[i+1][j+1][k+X[i]] += dp[i][j][k]

ans = 0
for n in range(1, N+1):
    ans += dp[N][n][n*A]

print(ans)


Measured memory_bytes: 79980
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
const bool DEBUG = false;
typedef long long int ll;
const ll INF = 876543210987654321;
const int MOD = 1000000007;
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;
//vector<vector<int>>(h, vector<int>(w, f));


int main() {
	ll q, h, s, d, n;

	cin >> q >> h >> s >> d;
	cin >> n;
	ll one, two;
	one = min(q * 4, h * 2);
	one = min(one, s);
	two = min(one * 2, d);
	ll ans = 0;
	ans = n / 2 * two;
	if (n % 2 == 1)ans += one;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] b = new int[n];
    for(int i=0;i<k;i++) {
      int d = sc.nextInt();
      int[] a = new int[d];
      for(int j=0;j<d;j++){
        a[j]  = sc.nextInt();
        int c = a[j];
		b[c-1] = 1;
      }      
    }
    int count = 0;
    for(int x=0;x<b.length;x++) {
      if(b[x]==0) {
      count = count + 1;
      }
    }
    System.out.println(count);
  }
}

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

int main() {
	string S, T, ans = "";
	static long long DP[3010][3010] = {}, len;
	cin >> S >> T;
	for (int i = 1; i <= S.size(); i++) {
		for (int j = 1; j <= T.size(); j++) {
			if (S[i - 1] == T[j - 1]) DP[i][j] = DP[i - 1][j - 1] + 1;
			else DP[i][j] = max(DP[i - 1][j], DP[i][j - 1]);
		}
	}
	int i = S.size(), j = T.size();
	len = DP[i][j];
	while (len > 0) {
		if (S[i - 1] == T[j - 1]) {
			ans = S[i - 1] + ans;
			len--;
			i--;
			j--;
		}
		else if (DP[i][j] == DP[i - 1][j]) i--;
		else j--;
	}
	cout << ans;
}

Measured memory_bytes: 70784
#include <iostream>
using namespace std;
int main() {
  int doll;
  bool test = false;
  cin >> doll;
  for(int i = 0; i <= doll / 4; i++) {
    for(int j = 0; j <= doll / 7; j++) {
      if(i * 4 + j * 7 == doll) test = true;
    }
  }
  if(test) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
 
const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;
 
string s,t;

int ans;

int main()
{
	cin >> s >> t;
	for (int i = 0;i < s.size();++i)
	{
		if (s[i] == t[i])
			ans++;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  int N, K;
  cin >> N >> K;
  ll result = 0;
  if(K % 2 == 0){
    set<int> s;
    for(int i = K/2; i <= N; i+= K){
      s.insert(i);      
    }
    ll num = s.size();
    result += num * num * num;
  }
  set<int> s;
  for(int i = K; i <= N; i+=K){
    s.insert(i);
  }
  ll num = s.size();
  result += num * num * num;
  cout << result << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int MAX_N = 1e5 + 5;
const int MAX_V = 2e9;

int n, c, d;
P seq[MAX_N];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d", &c, &d);
        seq[i] = make_pair(c+d, c-d);
    }
    sort(seq, seq+n);
    int cnt = 0;
    int cur = -MAX_V;
    for (int i = 0; i < n; i++)
    {
        if (cur <= seq[i].second)
        {
            cnt++;
            cur = seq[i].first;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  
  if(s == "SUN") cout << 7 << endl;
  else if(s == "MON") cout << 6 << endl;
  else if(s == "TUE") cout << 5 << endl;
  else if(s == "WED") cout << 4 << endl;
  else if(s == "THU") cout << 3 << endl;
  else if(s == "FRI") cout << 2 << endl;
  else if(s == "SAT") cout << 1 << endl;
  
}

Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
#define show(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

const int MN = 2020; //6;
using B = bitset<MN>;

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

    int n;
    cin >> n;
    V<B> win(n); 
    for (int j = 1; j < n; j++) {
        string s;
        cin >> s;
        for (int i = 0; i < j; i++) {
            if (s[i] == '0') {
                // i -> j
                win[i].set(j);
            } else {
                // j -> i
                win[j].set(i);
            }
        }
    }

    V<B> okL(n), okR(n);
    for (int i = 0; i < n; i++) {
        okL[i][i] = true;
        okR[i][i] = true;
    }
    for (int di = 1; di <= n; di++) {
        for (int l = 0; l + di <= n - 1; l++) {
            int r = l + di;

            okL[r][l] = (okR[l + 1] & okL[r] & win[l]).any();
            okR[l][r] = (okR[l] & okL[r - 1] & win[r]).any();
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (okR[0][i] && okL[n - 1][i]) {
            show(i);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    auto ans = make_vec<int>(4, 3, 10);
    rep(i, n) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--; c--;
        ans[a][b][c] += d;
    }
    rep(i, 4) {
        rep(j, 3) {
            cout << " ";
            rep(k, 10) {
                cout << ans[i][j][k] << (k == 9 ? '\n' : ' ');
            }
        }
        if (i != 3) cout << string(20, '#') << endl;
    }
}



Measured memory_bytes: 3184
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int c = 0;
        for (int i = 0; i < N; i++) {
            long n = sc.nextLong();
            while (n % 2 == 0) {
                n /= 2;
                c++;
            }
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 35984
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <utility>
#include <functional>

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i, n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)

using ll = long long;
using P = std::pair<int, int>;
using vi = std::vector<int>;
using namespace std;

constexpr int INF = 1000000000; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18
constexpr int MAX_N = 201;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, C;
	cin >> n >> C;
	vector<vi> d(C + 1, vi(C + 1));
	REP1(i, C) REP1(j, C) cin >> d[i][j];
	vector<vi> c(n, vi(n));
	REP(i, n) REP(j, n) cin >> c[i][j];
	vector<vi> col(3, vi(C + 1));
	REP(i, n + n - 1) {
		for (int j = max(i - n + 1, 0); j <= min(i, n - 1); ++j) {
			col[i % 3][c[j][i - j]]++;
		}
	}
	int ans = INF;
	for (int i = 1; i <= C; ++i) {
		for (int j = 1; j <= C; ++j) {
			if (i == j)continue;
			for (int k = 1; k <= C; ++k) {
				if (i == k || j == k) continue;
				int a = 0;
				REP(l, 3) {
					int co = (l % 3 == 0 ? i : (l % 3 == 1 ? j : k));
					for (int m = 1; m <= C; ++m) {
						a += d[m][co] * col[l][m];
					}
				}
				ans = min(ans, a);
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back


template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//


















int main(){
        int n;
        cin >> n;
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];

        vector<int> tmp;
        for(int i = n-1; i >= 0; i -= 2){
                if(i==0){
                        tmp.pb(i);
                        break;
                }
                tmp.pb(i);
                tmp.pb(i);
        }

        sort(all(a));
        sort(all(tmp));

        for(int i = 0; i < n; i++){
                if(a[i] != tmp[i]){
                        cout << 0 << endl;
                        return 0;
                }
        }
        int nn = n/2;
        Int ans = 1;
        for(int i = 0; i < nn; i++){
                ans *= 2;
                ans %= mod;
        }
        cout << ans << endl;
}



























Measured memory_bytes: 1276
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define N 10000000
#define L 1000000000

int cnt=0;
int a[N],w[N],r[N];

void merge(int A[],int left,int mid,int right){
	int n1 = mid-left;
	int n2 = right-mid;
	int i,j,k;
	for(i=0;i<n1;++i) w[i]=A[left+i];
	for(i=0;i<n2;++i) r[i]=A[mid+i];
	w[n1] = r[n2] = L;
	i=j=0;
	for(k=left;k<right;++k){
		cnt++;
		if(w[i]<=r[j]){
			A[k]=w[i];
			i++;
		}else{
			A[k]=r[j];
			j++;
		}
	}
}

void mergesort(int A[],int left,int right){
	
	if(left+1<right){
		
		int mid = (left+right)/2;
		mergesort(A,left,mid);
		mergesort(A,mid,right);
		merge(A,left,mid,right);
	}
}


int main(void){
    
	int n,i;

	scanf("%d",&n);
	for(i=0;i<n;++i){scanf("%d",&a[i]);}

	mergesort(a,0,n);
	for(i=0;i<n;++i){
		if(i!=0) {printf(" ");}
		printf("%d",a[i]);
	}
	
	printf("\n%d\n",cnt);
	return 0;
}



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

using namespace std;

int main(int argc, char const *argv[]) {
	int N,M;
	std::cin >> N >> M;
	int t1,t2;
	std::vector<int> a;
	std::vector<int> b;
	for (size_t i = 0; i < M; i++) {
		std::cin >> t1 >> t2;
		if (t1 == 1) {
			a.push_back(t2);
		}
		if (t2 == N) {
			b.push_back(t1);
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	bool flag = false;
	int i = 0;
	int j = 0;
	while (true) {
		if (i == a.size() || j == b.size()) {
			break;
		}
		if (a[i] == b[j]) {
			flag = true;
			break;
		}
		else if (a[i] > b[j]) {
			j++;
		}
		else if (a[i] < b[j]) {
			i++;
		}
	}

	if (flag) {
		std::cout << "POSSIBLE" << '\n';
	}
	else{
		std::cout << "IMPOSSIBLE" << '\n';
	}
	return 0;
}


Measured memory_bytes: 1276
import sys 
import numpy as np
import math 

readline = sys.stdin.readline 

ABHM = readline().split() 
A = float(ABHM[0])
B = float(ABHM[1])
H = float(ABHM[2])
M = float(ABHM[3])


alpha = H + M/60 if H != 12 else M/60
beta = M/5

theta = abs(alpha - beta) * np.pi / 6 

x = np.sqrt(A**2 + B**2 - 2*A*B*math.cos(theta))

print('{:.20f}'.format(x))


Measured memory_bytes: 27260
#include <iostream>
#include <vector>
using namespace std;
typedef unsigned long long LL;

int main()
{
    LL n,m,z = 1;
    bool flag = true;
    bool zeroFlag = false;
    vector<LL> vec;

    cin >> n;
    vec.resize(n);
    for (LL i = 0; i < n;i++)
    {
        cin >> m;
        vec[i] = m;
        if(m == 0)
            zeroFlag = true;
        if( flag )
        {
            z = z * m;
            if (((z-1) / (1000000000000000000)) >= 1)
            {
                flag = false;
            }
        }
    }
    if( zeroFlag )
        cout << 0 << endl;
    else if( flag )
        cout << z << endl;
    else
        cout << -1 << endl;
}

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

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

  int n,k;
  cin >> n >> k;

  vector<int> a(n);
  rep(i,n) cin >> a[i];

  sort(a.begin(),a.end());
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += a[i];
  }
  cout << sum << '\n';
}

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

int main () {
	int a,b,c,d,e;
	int Ms1,Ms2,total;	
	cin >> a >> b >> c >> d >> e;
	if(a>c&&b>c){
		Ms1=c;
	}else{if(a>b&&c>b){
		Ms1=b;
	}else{if(b>a&&c>a){
		Ms1=a;
		}
	}
}
	if(d>e){
		Ms2=e;
	}else{
		Ms2=d;
	}

	total=(Ms1+Ms2)-50;
	cout << total << '\n';

	return 0;
}	

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;
char mp[55][55];
int main()
{
	int h,w,num=0;
	scanf("%d %d",&h,&w);
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		cin>>mp[i][j];
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{	
		num=0;
			if(mp[i][j]=='.')
			{
				if(mp[i-1][j-1]=='#') num++;
				if(mp[i-1][j]=='#') num++;
				if(mp[i-1][j+1]=='#') num++;
				if(mp[i][j+1]=='#') num++;
				if(mp[i][j-1]=='#') num++;
				if(mp[i+1][j-1]=='#') num++;
				if(mp[i+1][j]=='#') num++;
				if(mp[i+1][j+1]=='#') num++;
				mp[i][j]=num+'0';
			}
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			printf("%c",mp[i][j]);
		}
		printf("\n");
	}
	return 0;
} 

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

map <string, int> memo;

int main(){
    int N;
    cin >> N;
    for (int i = 0; i < N; i++){
        string s;
        cin >> s;
        memo[s] += 1;
    }
    int maxv = 0;
    for (const auto& x : memo){
        int v = x.second;
        if (v > maxv){
            maxv = v;
        }
    }
    for (auto it = memo.begin(); it != memo.end(); it++){
        if (it ->second == maxv){
            cout << it->first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include <cstdio>
#include <cstring>
#include <algorithm>
namespace Useful_Helpers {
void Unused(...) {}
#ifndef DEBUG
  #define echo(...) Unused(__VA_ARGS__)
#else
  #define echo(...) fprintf(stderr, __VA_ARGS__)
#endif
#define Reps(var, init, delim, step) for (int var = (init); var <= (delim); var += (step))
#define Rep(var, init, delim) Reps(var, init, delim, 1)  //for (int var = init; var <= delim; ++var)
#define Repr(var, init, delim) Reps(var, init, delim, -1)  //for (int var = init; var >= delim; --var)
template<typename DstTy, typename SrcTy>
DstTy set(DstTy &dst, const SrcTy &src) { return dst = static_cast<DstTy>(src); }
//
typedef long long i64t;
typedef unsigned long long u64t;
typedef unsigned u32t;
typedef int i32t;
//
namespace IO_Helper {
template<typename Ty>
void read(Ty &var);  // Read a variable
//
#define ImplRead(type, fmt) \
    template<> void read<type>(type& i) { scanf(fmt, &i); }
ImplRead(int, "%d");
ImplRead(char, "%c");
ImplRead(long long, "%lld");
template<> void read<char*>(char *&i) { scanf("%s", i); }
template<int Size> void read(char (&i)[Size]) { scanf("%s", i); }
#undef ImplRead
//
struct IO {
private:
    void read() {}
public:
    template<typename Ty, typename ...Rest>
    void read(Ty &car, Rest& ...cdr) { IO_Helper::read(car); this->read(cdr...); }
    template<typename Ty, int Size>
    void read(Ty (&arr)[Size], int beg, int end) { Rep(i, beg, end) this->read(arr[i]); }
}io;
}  // End namespace IO_Helper
using IO_Helper::io;
} using namespace Useful_Helpers;

const int MaxN = int(3e5) + 7;
const i64t Mod = int(1e9) + 7;
const int Inf = 0x3f3f3f3f;
const i64t Inf64 = 0x3f3f3f3f3f3f3f3f;

int n;
int dir[MaxN];
int sum[MaxN];

i32t main()
{
    io.read(n);
    getchar();
    Rep(i, 1, n)
    {
        char c;
        io.read(c);
        if (c == 'W')
            dir[i] = -1;
        else
            dir[i] = 1;
        sum[i] = sum[i - 1] + dir[i];
    }
    int ans = Inf;
    Rep(i, 1, n)
        echo("%d(%d) ", sum[i], dir[i]);
    echo("\n");
    Rep(pos, 1, n)
    {
        echo("left: %d(%d), right: %d(%d)\n", pos - 1, sum[pos - 1], pos - n, sum[n] - sum[pos]);
        ans = std::min(ans, pos - 1 - sum[pos - 1] + (sum[n] - sum[pos]) - (pos - n));
    }
    printf("%d\n", ans / 2);
    return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]){
    cout << "YES"<<endl;
  }else{
    cout << "NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256