akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int a[4];
char op[3] = "+-";
bool ok;
int k;
char maze[8];
bool judge[2];
void dfs(int step, int sum) {
	if (ok)
		return;
	if (step == 3) {
		if (sum == 7) {
			ok = true;
			for (int i = 0; i < 7; i++)
				cout << maze[i];
			cout << "=7" << endl;
		}
		return;
	}
	for (int i = 0; i < 2; i++) {
		if (op[i] == '+' && !judge[step]) {
			judge[step] = true;
			sum += a[step + 1];
			maze[k + 1] = '+';
			maze[k + 2] = a[step + 1] + '0';
			k += 2;
			dfs(step + 1, sum);
			judge[step] = false;
			k -= 2;
			sum -= a[step + 1];
		}
		if (op[i] == '-' && !judge[step]) {
			judge[step] = true;
			sum -= a[step + 1];
			maze[k + 1] = '-';
			maze[k + 2] = a[step + 1] + '0';
			k += 2;
			dfs(step + 1, sum);
			judge[step] = false;
			sum += a[step +  1];
			k -= 2;
		}
	}
}
int main()
{
	int n;
	while (cin >> n) {
		memset(judge, 0, sizeof(judge));
		ok = false;
		k = 0;
		a[0] = n / 1000;
		a[1] = n / 100 % 10;
		a[2] = n / 10 % 10;
		a[3] = n % 10;
		maze[0] = a[0] + '0';
		dfs(0, a[0]);
	}
	return 0;
}

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

int main() {
  int N; cin >> N;
  int a[N]; rep(i,0,N) cin >> a[i];
    
  sort(a,a+N);
  int ans =0;
  rep(i,0,N-1) {
    ans += a[i+1] - a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3492
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
int a[5];
int k;

int main(){
  REP(i,5){
    cin>>a[i];
  }
  cin>>k;

   
  if (a[4]-a[0]<=k) {
    cout<<"Yay!\n";
  } else {
    cout<<":(\n";
  }
  
  return 0;
}


Measured memory_bytes: 256
def magic_square(grid, n)
  x, y = n / 2, n / 2 + 1
  grid[y][x] = 1

  for i in 2..(n * n)
    y += 1
    x += 1

    done = false

    loop do
      if x >= n
        x = 0
      elsif x < 0
        x = n - 1
      end
      if y >= n
        y = 0
      end

      if x >= 0 && x < n && y >= 0 && y < n && grid[y][x] != 0
        y += 1
        x -= 1
      end

      break if done

      done = true
    end

    grid[y][x] = i

   end
  grid
end

while line = gets
  n = line.chomp.to_i
  break if n == 0

  grid = Array.new(n) { Array.new(n, 0) }
  answer = magic_square(grid, n)
  answer.each do |row|
    puts row.map { |n| sprintf('%4d', n) }.join
  end

end

Measured memory_bytes: 8760
/* 
 * Project: AtCoder Beginners Contest 173 B - Judge Status Summary
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/05
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;

int n;
string s;

int main() {

    cin >> n;
    int bin[4];
    memset(bin, 0, sizeof(bin));
    for (int i=0;i<n;i++) {
        cin >> s;
        if (s == "AC")
            bin[0]++;
        if (s == "WA")
            bin[1]++;
        if (s == "TLE")
            bin[2]++;
        if (s == "RE")
            bin[3]++;
    }

    cout << "AC x "  << bin[0] << "\n";
    cout << "WA x "  << bin[1] << "\n";
    cout << "TLE x " << bin[2] << "\n";
    cout << "RE x "  << bin[3] << "\n";

}

Measured memory_bytes: 3228
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string w, t;
	cin>>w;
	int count=0;
	while(true) {
		cin>>t;
		if(t=="END_OF_TEXT") break;
		for(int i=0; i<t.length(); ++i) {
			t[i]=tolower(t[i]);
		}
		if(w==t) ++count;
	}
	cout<<count<<'\n';
	return 0;
}



Measured memory_bytes: 3228
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String num = sc.next();
		String[] numArray = num.split("");
		Boolean isThere = false;

		for (int i = 0; i < numArray.length; i++) {
			if ("7".equals(numArray[i])) {
				isThere = true;
				break;
			}
		}
		if (isThere) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

void solve()
{
	ll X,K,D,res = 0;
	cin>>X>>K>>D;

	X = abs(X);

	if(X/D >= K)
		res = X - D*K;

	else
	{
		ll temp = X/D;
		K = K - temp;
		X = X - temp*D;

		if(K % 2)
			X = abs(X - D);
		res = X;
	}

	cout<<res<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	return 0;
} 

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
using namespace std;
#define LATTE 10000

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

void dfs(char fld[][8],int x,int y){
	int ny,nx;
	for(int i=0;i<4;i++){
		for(int j=1;j<=3;j++){
			ny = y+dy[i]*j;
			nx = x+dx[i]*j;
			if(ny<0 || 8<=ny || nx<0 || 8<=nx || fld[ny][nx]!='1') continue;
			fld[ny][nx]='0';
			dfs(fld,nx,ny);
		}
	}
}

int main(){
	int N;
	cin>>N;
	for(int tc=1;tc<=N;tc++){
		int X,Y;
		char fld[8][8];
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				cin>>fld[i][j];
			}
		}
		cin>>X>>Y;
		fld[--Y][--X]='0';
		dfs(fld,X,Y);
		printf("Data %d:\n",tc);
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				printf("%c",fld[i][j]);
			}puts("");
		}
	}
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x, y, res;
  cin>>x>>y;
  res = 0;
  if(x == 1)res += 300000;
  else if(x == 2)res += 200000;
  else if(x == 3)res += 100000;
  if(y == 1)res += 300000;
  else if(y == 2)res += 200000;
  else if(y == 3)res += 100000;
  if(x == 1 && y == 1)res += 400000;
  cout<<res<<endl;
  return 0;
}


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

class Score{
public:
    int num;
    int time;
    
    Score(){
        this->num = 0;
        this->time = 0;
    }
    
    Score(int num, int time){
        this->num = num;
        this->time = time;
    }
    
};

int main(int argc, const char * argv[]) {
    
    while (true) {
        int n;
        cin >> n;
        
        if(n==0){
            break;
        }
        
        Score max,pre,biri,boobie;
        
        for(int i=0;i<n;i++){
            int c1;
            cin >> c1;
            int sum = 0;
            for(int i=0;i<4;i++){
                int m, s;
                cin >> m >> s;
                sum+= 60*m + s;
            }
            
            if(max.time == 0 || max.time > sum){
                pre = max;
                max = Score(c1,sum);
            }
            else if(pre.time == 0 || pre.time > sum){
                if(biri.time == 0){
                    biri = pre;
                }
                else if(boobie.time == 0){
                    boobie = pre;
                }
                pre = Score(c1,sum);
            }
            else if(biri.time < sum){
                boobie = biri;
                biri = Score(c1,sum);
            }
            else if(boobie.time < sum){
                boobie = Score(c1,sum);
            }
            
        }
        
        cout << max.num << endl;
        cout << pre.num << endl;
        cout << boobie.num << endl;
        
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>

int main(){

	std::vector<int> vehicle_order;
	int input_data;

	while(std::cin >> input_data){
		if(input_data == 0){
			std::cout << vehicle_order.back() << std::endl;
			vehicle_order.pop_back();
		}else{
			vehicle_order.push_back(input_data);
	}
	}

	return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int N, ans; cin >> N;
    ans = 0;
    vector<int> H, Hdiff;
    for (int i = 0; i < N; i++)
    {
        int Hi; cin >> Hi;
        H.push_back(Hi);
    }
    for (int j = 0; j < N - 1; j++)
    {
        int diff = H[j] - H[j + 1];
        Hdiff.push_back(diff);
    }
    int tmp = 0;
    for (int j = 0; j < Hdiff.size(); j++)
    {
        if (Hdiff[j] >= 0)
        {
            tmp++;
            if (ans < tmp)
            {
                ans = tmp;
            }
        }
        else
        {
            if (ans < tmp)
            {
                ans = tmp;
            }
            tmp = 0;
        }
    }
    cout << ans << endl;
	return 0;
}

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

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

    int curr, tmp = -1, cnt = 0, max_c = 0;
    for (int i = 0; i < n; i++) {
        cin >> curr;
        if (curr <= tmp) {
            cnt++;
        } else {
            if (max_c < cnt) max_c = cnt;
            cnt = 0;
        }
        tmp = curr;
    }

    cout << max(max_c, cnt) << endl;

    return 0;
}


Measured memory_bytes: 3596
def main():
    def nCk(n, k, mod=10 ** 9 + 7):
        def xgcd(a, b):
            if b == 0:
                return (1, 0)
            x, y = xgcd(b, a % b)
            return (y, x - (a // b) * y)
        p, q = 1, 1
        for i in range(n - k + 1, n + 1):
            p = (p * i) % mod
        for i in range(2, k + 1):
            q = (q * i) % mod
        return p * (xgcd(q, mod)[0] % mod) % mod


    X, Y = map(int, input().split())

    b = (2 * X - Y) // 3
    a = (-X + 2 * Y) // 3

    if (X + Y) % 3 != 0 or a < 0 or b < 0:
        print(0)
    else:
        print(nCk(a + b, a))

main()


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

ll N,A,B;


int main(void) {
	
	cin >> N>>A>>B;
	ll u = max(A + B - N, ll(0));
	cout << min(A, B) << " " << min(u,N) << endl;

	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;

string AKI = "AKIHABARA";
bool solve(string s){
	int cnt = 0;
	for(auto c: s) cnt += (c == 'A');
	if(cnt >= 4 || s.length() > AKI.length()) return (s == AKI);
	bool ret = false;
	rep(i, s.length()+1){
		ret |= solve(s.substr(0,i) + "A" + s.substr(i));
	}
	return ret;
}

int main(){
	//ios_base::sync_with_stdio(false);
	int N;
	string s;

	cin >> s;

	bool ans = true;
	ans = solve(s);
	//int pos = 0;
	//for(auto c: s){
	//	if(AKI[pos] == c){
	//		pos++;
	//		continue;
	//	}else if(AKI[pos] == 'A'){
	//		pos++;
	//		if(AKI[pos] == c) pos++;
	//		else{
	//			ans = false;
	//			break;
	//		}
	//	}else{
	//		ans = false;
	//		break;
	//	}
	//}

	cout << (ans?"YES":"NO") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>
#include <sstream>
using namespace std;

vector<string> split(const string& s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

int main() {
	char c;
	cin >> c;
	if (isupper(c)) {
		cout << "A" << endl;
	}else{
		cout << "a" << endl;
	}

	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = int64_t;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];

ll powm(ll a, ll b, ll c) {
	if (b == 0)return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	}
	else return (a * powm(a, b - 1, c)) % c;
}

signed main(){
	IOS;
	ll n;
	cin >> n;
	vec<ll> a(n + 3,0),ans(n + 3,0);
	vec<vec<ll>> iti(n + 3);
	ll x;
	REP(i,n + 1){
		cin >> a[i];
		iti[a[i]].push_back(i);
		if(iti[a[i]].size() > 1)x = a[i];
	}
	vec<ll> combi(n + 3,0),inv(n + 3,0);
	combi[0] = 1,inv[0] = 1;
	for(ll i = 1;i <= n + 1;i++){
		combi[i] = combi[i - 1] * i;
		combi[i] %= MOD;
		inv[i] = powm(combi[i], MOD - 2,MOD) % MOD;
	}
	for(ll i = 1;i <= n + 1;i++){
		ans[i] = (((combi[n + 1] * inv[i]) % MOD) * inv[n + 1 - i]) % MOD;
	}
	ll unko = n - (iti[x][1] - iti[x][0]);
	for(ll i = 1;i <= unko && i <= n;i++){
		ans[i + 1] -= (((combi[unko] * inv[i]) % MOD) * inv[unko - i]) % MOD;
		ans[i + 1] += MOD;
		ans[i + 1] %= MOD;
	}
	ans[1]--;
	for(ll i = 1;i <= n + 1;i++){
		dump(ans[i]);
	}
}

Measured memory_bytes: 10880
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{

    public static final int FIRST_NUMBER = 0;
    public static final int SECOND_NUMBER = 1;

    public static void main(String[] args) throws NumberFormatException, IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	// ?¨?????????°
	int vertical = Integer.parseInt(br.readLine());

    // ???????????°	
	int horizontal = Integer.parseInt(br.readLine());

	List<int[]> changeRequests = new ArrayList<>();
	for (int i = 0; i < horizontal; i++) {
	    String[] changeRequestStr = br.readLine().split(",");
	    int[] changeRequest = new int[2];
	    changeRequest[FIRST_NUMBER] = Integer.parseInt(changeRequestStr[FIRST_NUMBER]);
	    changeRequest[SECOND_NUMBER] = Integer.parseInt(changeRequestStr[SECOND_NUMBER]);
	    changeRequests.add(changeRequest);
	}

	int[] outputArray = getDrawedArray(changeRequests, vertical, horizontal);

	for (int i = 1; i < outputArray.length; i++) {
	    System.out.println(outputArray[i]);
	}

    }

    /**
     *
     * @param changeRequests
     * @param vertical
     * @param horizontal
     */
    private static int[] getDrawedArray(List<int[]> changeRequests, int vertical, int horizontal) {
	int[] outputArray = new int[vertical + 1];
	for (int i = 1; i < outputArray.length; i++) {
	    outputArray[i] = i;
	}

	for (int[] changeRequest : changeRequests) {
	    int mediator = 0;
	    mediator = outputArray[changeRequest[FIRST_NUMBER]];
	    outputArray[changeRequest[FIRST_NUMBER]] = outputArray[changeRequest[SECOND_NUMBER]];
	    outputArray[changeRequest[SECOND_NUMBER]] = mediator;

	}

	return outputArray;

    }

}

Measured memory_bytes: 24388
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int d,s;
  while(cin >> d){
    s = 0;
    for(int i=0;i<600;i+=d){
      s += d*(i*i);
    }
    cout << s << endl;
  }
  
  return(0);
}



Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <unordered_map>
#include <set>

using ull = unsigned long long;

struct UnionFindWithSize {
  std::vector<size_t> par;
  std::unordered_map<size_t, ull> num_conn;

  UnionFindWithSize(size_t N) : par(), num_conn() {
    par.reserve(N);
    for (size_t i=0; i<N; i++) {
      par.push_back(i);
      num_conn.insert(std::make_pair(i, 1));
    }
  }

  size_t root(size_t x) {
    if (par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }

  bool same(size_t x, size_t y) {
    return root(x) == root(y);
  }

  ull size(size_t x) {
    return num_conn[root(x)];
  }

  void unite(size_t x, size_t y) {
    size_t root_x = root(x);
    size_t root_y = root(y);
    if (root_x == root_y) return;

    par[root_y] = root_x;
    num_conn[root_x] += num_conn[root_y];
    num_conn.erase(root_y);
  }
};


int main() {
  int N, M, K;
  std::cin >> N >> M >> K;

  UnionFindWithSize uf(N);
  std::vector<int> numFriends(N);

  for (int i=0; i<M; i++) {
    int A, B;
    std::cin >> A >> B;
    A--; B--;
    uf.unite(A, B);
    numFriends[A]++;
    numFriends[B]++;
  }

  std::vector<std::set<int>> blockers(N);

  for (int i=0; i<K; i++) {
    int C, D;
    std::cin >> C >> D;
    C--; D--;
    blockers[C].insert(D);
    blockers[D].insert(C);
  }

  for (int i=0; i<N; i++) {
    int ans=uf.size(i) - numFriends[i] - 1;
    for (auto b : blockers[i]) {
      if (uf.same(i, b)) ans--;
      if (ans < 0) break;
    }
    if (i>0) std::cout << ' ';
    std::cout << std::max(0, ans);
  }

  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 19748
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  bool n=false,w=false,s=false,e=false;
  for(int i=0; i<a.size(); i++){
    if(a.at(i) == 'N'){n=true;}
    if(a.at(i) == 'S'){s=true;}
    if(a.at(i) == 'W'){w=true;}
    if(a.at(i) == 'E'){e=true;}
  }
  if((n&&s&&!w&&!e)||(w&&e&&!n&&!s)||(n&&w&&e&&s)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
  

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

int main() {
    string s;  cin >> s;
    ll k = s.size() - 2;

    if(s[0] == s[s.size() - 1]) k--;
    if(k % 2 == 0) cout << "Second" << endl;
    else cout << "First" << endl;

    return 0;
}


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

int main(int argc, char const *argv[]) {
  int n, d, i, count=1, min, max;
  cin >> n >> d;
  max = d;
  min = 0;
  for (i = 1; i < n; i++) {
    if (i-d > max) {
      count++;
      min = i-d;
      max = i+d;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 200000
#define mod1 1000000007
#define mod2 1000000009
#define mod3 998244353
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
vector <ll> black(N+5,1),white(N+5,1);
vector <ll> G[N+5];
void dfs(ll node,ll parent)
{
	for(auto child:G[node])
	{
		if(child!=parent)
			dfs(child,node);
	}
	for(auto child:G[node])
	{
		if(child==parent)
			continue;
		black[node] = (black[node] * (white[child]))%mod1;
		white[node] = (white[node] * (black[child] 
			+ white[child]))%mod1;
	}
	return;
}
int main()
{
    IO
	clock_t begin = clock();
    ll n;
    cin>>n;
    for(ll i=1;i<n;i++)
    {
    	ll p,q;
    	cin>>p>>q;
    	G[p].push_back(q);
    	G[q].push_back(p);
    }
    dfs(1,0);
    cout<<(black[1] + white[1])%mod1<<endl;
    // cout<<double(clock() - begin)/CLOCKS_PER_SEC<<endl;
    return 0;
}

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

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define AI(a,size,n) array<int,size> a;REP(i,n){assert(0<scanf("%d",&a[i]));}
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  int ans = 0;
  vector<pair<int, int>> vp;
  priority_queue<int> pq;
  INT(n); INT(m);
  REP(n){INT(a); INT(b); vp.EB(a, b);}
  sort(vp.begin(), vp.end());
  auto it = vp.begin();
  REP(i, 1, m + 1){
    while(it != vp.end() && (*it).first == i){
      pq.push((*it).second);
      it++;
    }
    if (!pq.empty()){
      ans += pq.top();
      pq.pop();
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1908
/* 
 * Project: AtCoder Beginners Contest 168 B - ... (Triple Dots)
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/05/17
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;

string s;
int k;

void solve() {
    if (s.size() <= k)
        cout << s << "\n";
    else
        cout << s.erase(k,s.size()-1) << "...\n";
    
    return;
}

int main() {

    scanf("%d", &k);
    cin >> s;

    solve();

}

Measured memory_bytes: 3196
# https://stackoverflow.com/questions/15347174/python-finding-prime-factors
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors



N, P = [int(_) for _ in input().split()]


import collections
lst = prime_factors(P)
c = collections.Counter(lst)

result = 1
for k in c.keys():
    temp = c[k] // N
    if temp >= 1:
        result *= (k ** temp)

print(result)

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

using namespace std;

string s;

vector<int> g;

int main(){
	cin >> s;
	for(size_t i = 0; i < s.size(); ++i){
		if(s[i] == 'B'){
			if(g.size() != 0) g.pop_back();
			}
		else g.push_back(s[i] - '0');
		}
	for(size_t i = 0; i < g.size(); ++i){
		cout << g[i];
		}
	}


Measured memory_bytes: 256
import sys
N=int(input())
S=input()
T=input()
if S==T:
    print(N)
    sys.exit()
for i in range(N-1):
    #print(S[i+1:],T[:-i-1])
    if S[i+1:]==T[:-i-1]:
        print(N+i+1)
        sys.exit()
print(2*N)

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

int main() {
  int A,B;
  cin>>A>>B;
  
  if((A+B)==3){
    cout<<3<<endl;
  }
  else if((A+B)==4){
    cout<<2<<endl;
  }
  else if((A+B)==5){
    cout<<1<<endl;
  }
     
      
}


Measured memory_bytes: 256
/**
 * This line was copied from template
 * This is csol.cpp
 * 
 * @author: Nikolay Kalinin
 * @date: Sat, 16 Mar 2019 15:13:52 +0300
 */
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

#define popcount(x) __builtin_popcount(x)
const int maxn = 1<< 18;

int n, a, b;

vector<int> gen(int n, int a, int b)
{
    if (n == 1) return {a, b};
    int toxor = a;
    a ^= toxor;
    b ^= toxor;
    vector<int> ans;
    bool needswap = false;
    int bitneed, bithave;
    if (!(b & (1 << (n - 1))))
    {
        bithave = 0;
        while (!(b & (1 << bithave))) bithave++;
        bitneed = n - 1;
        needswap = true;
        b ^= ((1 << bithave) ^ (1 << bitneed));
    }
    ans = gen(n - 1, 0, (1 << (n - 2)));
    auto r = gen(n - 1, (1 << (n - 2)), b ^ (1 << (n - 1)));
    for (auto t : r) ans.pb(t ^ (1 << (n - 1)));
    if (needswap)
    {
        for (int &t : ans)
        {
            int have = (t >> bithave) & 1;
            int need = (t >> bitneed) & 1;
            if (have != need) t ^= ((1 << bithave) ^ (1 << bitneed));
        }
    }
    for (int &t : ans) t ^= toxor;
    return ans;
}

int main()
{
    cin >> n >> a >> b;
    if ((popcount(b) + popcount(a)) % 2 != 1)
    {
        printf("NO\n");
        return 0;
    }
    auto ans = gen(n, a, b);
    printf("YES\n");
    for (auto t : ans) printf("%d ", t);
    return 0;
}


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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sps << ' '
#define sp << ' ' << 
# define M_PI   3.14159265358979323846
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353

ll calc(ll i, ll l, ll r, vii &a, vvi &dp){
  ll ans = 0LL;
  if(i >= sz(a)) return 0; 

  if(l > r){
    return 0;
  }
  if(dp[l][r] != -1) return dp[l][r];

  dp[l][r] = max(calc(i + 1, l + 1, r, a, dp) + a[i].F*abs(a[i].S - l), calc(i + 1, l , r - 1, a, dp) + a[i].F*abs(a[i].S - r));

  return dp[l][r];
}

int main()
{
  boost;
  ll tt = 1, n, k, i, j;

  // cin >> tt;
  for(int _ = 1; _ <= tt; _++){
    // cout << "Case #" << _ << ": ";
    cin >> n;
    vii a(n);
    for(i = 0; i < n; i++){
      cin >> a[i].F;
      a[i].S = i;
    }

    sort(a.B, a.E, greater<pii>());
    vvi dp(n, vi(n, -1));
    cout << calc(0, 0, n - 1, a, dp) << nl;
  }

  return 0;
}

Measured memory_bytes: 34864
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld %lld",&n,&m);
  if(n==m/2){
    result = n;
  }else if(n<m/2){
    result = n;
    m -= n*2;
    result += (ll)floorl(m/4.0);
  }else{
    result = (ll)floorl(m/2);
  }
  printf("%lld\n",result);
  return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int main()
{
        int n,i,j,max,min;
        char tmp;
        char  str[8];
        scanf("%d\n",&n);
        while(n--){
        gets(str);
        for(i=0;i<8;i++){
                for(j=i+1;j<8;j++){
                        if(str[i]>str[j]){
                        tmp=str[i];
                        str[i]=str[j];
                        str[j]=tmp;
                        }
                }
        }
                min=atoi(str);
        for(i=0;i<8;i++){
                for(j=i+1;j<8;j++){
                        if(str[i]<str[j]){
                        tmp=str[i];
                        str[i]=str[j];
                        str[j]=tmp;
                        }
                }
        }
                max=atoi(str);
                printf("%d\n",max-min);
        }
        return 0;
}

Measured memory_bytes: 600
import  numpy as np

N,W = map(int, input().split())

INF = 1e100

dp = [INF] * (10 ** 5 + 1)
dp = np.array(dp)

dp[0] = 0

for i in range(N):
    w, v = map(int, input().split())
    dp[v:] = np.minimum(dp[:-v] + w , dp[v:])


for v,num in enumerate(dp):
    if num <= W:
        ans = v

print(ans)

Measured memory_bytes: 15692
#include<iostream>

using namespace std;

void setByte(bool *b, int n)
{
  static bool v[11][7] =
    {{0, 1, 1, 1, 1, 1, 1},
     {0, 0, 0, 0, 1, 1, 0},
     {1, 0, 1, 1, 0, 1, 1},
     {1, 0, 0, 1, 1, 1, 1},
     {1, 1, 0, 0, 1, 1, 0},
     {1, 1, 0, 1, 1, 0, 1},
     {1, 1, 1, 1, 1, 0, 1},
     {0, 1, 0, 0, 1, 1, 1},
     {1, 1, 1, 1, 1, 1, 1},
     {1, 1, 0, 1, 1, 1, 1},
     {0, 0, 0, 0, 0, 0, 0}};
  for(int i = 0; i < 7; i++)
    b[i] = v[n][i];
}

int main()
{
  bool state[7];
  bool b[7];
  int n;
  while(1)
  {
    setByte(state, 10);
    cin >> n;

    if(n == -1)
      break;

    for(int i = 0; i < n; i++)
    {
      int d;
      cin >> d;
      setByte(b, d);

      for(int j = 0; j < 7; j++)
      {
        state[j] = !(state[j] == b[j]);
        cout << state[j];
      }
      cout << endl;
      setByte(state, d);
    }
  }
}

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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    vector<long long> a(n);
    long long s = 0;
    for(i = 0;i < n;i++){
        cin >> a[i];
        s += a[i];
    }
    long long ans = s;
    long long p = 0;
    for(i = 0;i < n;i++){
        p += a[i];
        if(ans > abs(s-2*p)) ans = abs(s-2*p);
    }
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 1792
n = int(input())
f_min = len(str(n))
for i in range(2, int(n**0.5)+1):
    if n % i != 0:
        continue
    a = i
    b = int(n / a)
    f = max(len(str(a)), len(str(b)))
    f_min = min(f_min, f)

print(f_min)


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    string a, b, c;
    cin >> a >> b >> c;

    if(a.at(a.size()-1)==b.at(0)&&b.at(b.size()-1)==c.at(0)) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(x-a)<abs(x-b)) cout<<'A'<<endl;
  else cout<<'B'<<endl;
}

Measured memory_bytes: 256
a, b = map(int,input().split())
lst = []
for i in range(a):
  c = 0
  tmp = list(map(int, input().split()))
  for j in tmp:
    c += j
  tmp.append(c)
  lst.append(tmp)

last = []
for i in range(len(lst[0])):
  c = 0
  for ls in lst:
    c += ls[i]
  last.append(c)

lst.append(last)
for line in lst:
  print(' '.join(map(str, line)))


Measured memory_bytes: 5696
import java.util.Scanner;

public class Main {
  static final long MOD = 1_000_000_007;
  static int h, w, a, b;

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

    h = sc.nextInt();  w = sc.nextInt();
    a = sc.nextInt(); b = sc.nextInt();

    long[] xy = new long[w + h + 1];
    xy[0] = 1;
    for(int i = 1; i <= w + h; i++){
      xy[i] = (xy[i - 1] * (long)i) % MOD;
    }

    long[] xyr = new long[w + h + 1];
    for(int i = 0; i <= w + h; i++){
      long t = 1_000_000_005, tt = xy[i], ttt = 1;
      do{
        if((t & 1L) != 0){
          ttt = (ttt * tt) % MOD;
        }
        t >>= 1L;
        tt = (tt * tt) % MOD;
      }while(t != 0L);
      xyr[i] = ttt;
    }

    long[] ha = new long[w - b];
    for(int i = 0; i < ha.length; i++){
      ha[i] = (((xy[b + i + h - a - 1] * xyr[h - a - 1]) % MOD) * xyr[b + i]) % MOD;
    }

    long ans = 0;
    for(int i = 0; i < ha.length; i++){
      long tmp = (((xy[w - b - i - 1 + a - 1] * xyr[w - b - i - 1]) % MOD) * xyr[a - 1]) % MOD;
      ans = (ans + ((tmp * ha[i]) % MOD)) % MOD;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 13648
package main

import (
        "fmt"
        "sort"
)

type Entry struct {
        sid int
        num int
}

type List []Entry

func (l List) Len() int {
        return len(l)
}

func (l List) Swap(i, j int) {
        l[i], l[j] = l[j], l[i]
}
func (l List) Less(i, j int) bool {
        if l[i].sid == l[j].sid {
                return (l[i].num < l[j].num)
        } else {
                return (l[i].num < l[j].num)
        }
}

func main() {
        N := 0
        fmt.Scan(&N)
        l := List{}
        //      listA := []int{}
        //      mA := map[int]int{}
        for i := 0; i < N; i++ {
                A := 0
                fmt.Scan(&A)
                l = append(l, Entry{i + 1, A})
        }

        sort.Sort(l)
        for i := 0; i < N; i++ {
                fmt.Printf("%d ", l[i].sid)
        }

        //      for i := 1; i <= N; i++ {
        //              for j := 0; j < N; j++ {
        //                      if listA[j] == i {
        //                              //                              fmt.Printf("%d", j+1)
        //                              //result = append(result, j+1)
        //                              fmt.Printf("%d ", j+1)
        //                              continue
        //                      }
        //              }
        //      }
}

Measured memory_bytes: 7680
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;
int main(){
int N,M;
cin>>N>>M;

multimap<int,int>b;
rep(i,M){
int A,B;
cin>>A>>B;
b.insert(make_pair(B,A));
}

int ans=0;
auto iter=b.begin();
int broken=-1;//壊れた橋のもっとも東側にあるものの番号
while(iter!=b.end()){
    if(iter->second>broken){
    broken=iter->first-1;
    ans++;
    }
iter++;
}
cout<<ans<<endl;
 return 0;
}
/*
5 2
1 4
2 5

1

9 5
1 8
2 7
3 5
4 6
7 9

2

5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

4
*/

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

int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == s[k - 1]) cout << s[i];
    else cout << '*';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from collections import defaultdict
def resolve():
    n = int(input())
    A = list(map(int,input().split()))
    count = defaultdict(int)

    res = 0
    for i in range(n):
        res += count[i - A[i]]
        count[i + A[i]] += 1

    print(res)
resolve()

Measured memory_bytes: 137556
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,ss,sss;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n>>y;
    rep(i,n+1){
        rep(j,n+1){
            pos=10000*i+5000*j;
            if(pos>y)continue;
            a=(y-pos)/1000;
            if(i+j+a==n){
                cout<<i<<" "<<j<<" "<<a<<"\n";
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1\n";
    return 0;
}


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

using ld=long double;
const ld PI=acos(-1);

signed main(){
  ld a,b,h,m;cin>>a>>b>>h>>m;
  ld the=(m/60)*2*PI-((h*60+m)/720)*2*PI;
  ld ans=sqrt(a*a+b*b-2*a*b*cos(the));
  cout<<fixed<<setprecision(12)<<ans<<endl;
}


Measured memory_bytes: 4148
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

int main(){
    int N,M,C;
    cin >> N >> M >> C;

    int sum = 0;
    vector<int> B;

    for(int i = 0; i < M; i++){
        int b;
        cin >> b;

        B.push_back(b);
    }

    for(int i = 0; i < N; i++){
        int s = 0;
        for(int j = 0; j < M; j++){
            int a;
            cin >> a;

            s += a*B[j];
        }

        if(s + C > 0){
            sum++;
        }
    }

    cout << sum << endl;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  ll L0=2, L1=1, L;
  
  if(n==1){
    cout << L1 << endl;
  }else{
    rep(i,n-1){
      L = L1 + L0;
      L0 = L1;
      L1 = L;
    }

    cout << L << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(r: f64);
    puts!("{}\n", 2.0 * r * 3.14159265);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2288
H,W=map(int,input().split())
a=[list(input()) for _ in range(H)]
h=[]
for i in range(H):
  if a[i]==['.']*W:
    h.append(i)

w=[]
for i in range(W):
  flag=0
  for j in range(H):
    if a[j][i]=='#':
      flag=1
      break
  if flag==0:
    w.append(i)
  
ans=[]
for i in range(H):
  if i not in h:
    r=[]
    for j in range(W):
      if j not in w:
        r.append(a[i][j])
    ans.append(r)

for i in range(len(ans)):
  print("".join(ans[i]))

Measured memory_bytes: 9380
#include<stdio.h>
#include<string.h>
#define N_MAX 1000005
#define LENGS 12
#define NIL -1

char hash[N_MAX][LENGS];

int getint(char c)
{
  if(c == 'A') return 1;
  else if(c == 'C') return 2;
  else if(c == 'G') return 3;
  else if(c == 'T') return 4;
  else return 0;
}

long long getkey(char data[LENGS])
{
  long long sum=0, p=1;
  long long i;

  for(i=0; i<strlen(data); i++){
    sum+=p*getint(data[i]);
    p*=5;
  }
  return sum;
}

int h1(int key)
{
  return key % N_MAX;
}

int h2(int key)
{
  return 1+(key % (N_MAX-1));
}


void insert(char data[LENGS])
{
  long long h,key;
  long long i=0;

  key = getkey(data);

  for(i=0;;i++){
    //    printf("inert\n");
    h = (h1(key) + i*h2(key)) % N_MAX;
    if(strcmp(hash[h], data) == 0){
      break;
    }
    else if(strlen(hash[h]) == 0){
      strcpy(hash[h], data);
      break;
    }
  }
}

int find(char data[LENGS])
{
  long long key, h;
  long i=0;

  key = getkey(data);

  for(i=0;;i++){
    //  printf("find");
    h = (h1(key) + i*h2(key)) % N_MAX;
    if(strcmp(hash[h], data) == 0){
      return 1;
    }
    else if(strlen(hash[h]) == 0){
      return 0;
    }
  }
}

int main()
{
  int i;
  int n;
  char data[LENGS], cmnd[10];

  scanf("%d", &n);

  for(i=0; i<N_MAX; i++){
    hash[i][0] = '\0';
  }

  for(i=0; i<n; i++){
    scanf("%s %s", cmnd, data);

    if(cmnd[0] == 'i'){
      insert(data);
    }

    else{
      if(find(data)) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}

Measured memory_bytes: 12324
import math
n,d=(int(i) for i in input().split())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

count=0
for i in range(n):
  if math.sqrt(x[i]*x[i]+y[i]*y[i])<=d:
    count+=1
print(count)


Measured memory_bytes: 116736
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200005;
long long f[maxn], s[maxn];
long long ans;
int n, x;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
    	cin >> x;
        f[i] = f[i-1] + x;
        s[i] = s[i-1] ^ x;
    }
    int l = 1;
    ans = 0;
    for (int r = 1; r <= n; r++)
    {
        for(; f[r] - f[l-1] != (s[r] ^ s[l-1]); l++);
        ans += r - l + 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> cnt(3 * m);
	int ans = 0;
	rep(i, n - 1) {
		int x = a[i]; int y = a[i + 1];
		x--; y--;
		if (x > y) y += m;
		ans += y - x;
		cnt[x + 2]++; cnt[y + 1] += x - y; cnt[y + 2] += y - x - 1;
	}
	vector<int> sum1(3 * m), sum2(3 * m);
	sum1[0] = cnt[0]; sum2[0] = cnt[0];
	for (int i = 1; i < 3 * m; i++) sum1[i] = sum1[i - 1] + cnt[i];
	for (int i = 1; i < 3 * m; i++) sum2[i] = sum2[i - 1] + sum1[i];
	int res = 0;
	rep(i, m) chmax(res, sum2[i] + sum2[i + m] + sum2[i + 2 * m]);
	//rep(i, 3 * m) cout << sum2[i] << ' '; cout << endl;
	cout << ans - res << endl;
}

Measured memory_bytes: 8064
#include <stdio.h>

struct dice {
  int num[6 + 1];
  int top, n, e, w, s, bottom;
  int tmp;
};

void dice_init(struct dice *d);
void dice_move(struct dice *d, char move);

int main(int argc, char *argv[])
{
  struct dice d;
  dice_init(&d);
  int i;
  char move;

  for (i = 1; i <= 6; i++) scanf("%d", &(d.num[i]));

  while ((move = getchar()) != EOF) dice_move(&d, move);

  printf("%d\n", d.num[d.top]);

  return 0;
}

void dice_init(struct dice *d)
{
  d->top = 1;
  d->n = 5;
  d->e = 3;
  d->w = 4;
  d->s = 2;
  d->bottom = 6;
}

void dice_move(struct dice *d, char move)
{
  switch (move) {
  case 'N':
    d->tmp = d->top;
    d->top = d->s;
    d->s = d->bottom;
    d->bottom = d->n;
    d->n = d->tmp;
    break;

  case 'E':
    d->tmp = d->top;
    d->top = d->w;
    d->w = d->bottom;
    d->bottom = d->e;
    d->e = d->tmp;
    break;

  case 'W':
    d->tmp = d->top;
    d->top = d->e;
    d->e = d->bottom;
    d->bottom = d->w;
    d->w = d->tmp;
    break;

  case 'S':
    d->tmp = d->top;
    d->top = d->n;
    d->n = d->bottom;
    d->bottom = d->s;
    d->s = d->tmp;
    break;

  default:
    break;
  }
}

Measured memory_bytes: 600
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C&lang=jp
*/
#include<iostream>
#include<string>
using namespace std;

//最長共通部分列
int LCS(string x , string y){
  int x_len=x.size();
  int y_len=y.size();
  int dp[x_len+1][y_len+1];
  //初期化
  for(int i=0;i<=x_len;i++){
    for(int j=0;j<=y_len;j++){
      dp[i][j]=0;
    }
  }
  for(int i=0;i<x_len;i++){
    for(int j=0;j<y_len;j++){
      if(x[i]==y[j]){
        dp[i+1][j+1]=dp[i][j]+1;
      }else{
        dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
      }
    }
  }
  return dp[x_len][y_len];
}
int main(){
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    string str1,str2;
    cin>>str1>>str2;
    cout<<LCS(str1,str2)<<"\n";
  }
}



Measured memory_bytes: 6976