akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;
int ms[] = { 31,28,31,30,31,30,31,31,30,31,30,31};
const ll Kin = 1;
const ll Uinal = 20 * Kin;
const ll Tun = Uinal * 18;
const ll Katun = Tun * 20;
const ll Baktun = Katun * 20;

vector<string> split(string s){
    int x;
    vector<string> ret;
    s += '.';
    x = -1;
    REP(i,s.size()){
	if(s[i] == '.'){
	    ret.PB(s.substr(x+1,i-x-1));
	    x = i;
	}
    }
    return ret;
}

ll cg(string s){
    vector<string> d = split(s);
    if(d[0] == "2012"){
	return stoll(d[2]) - 21;
    }else{
	ll y = stoll(d[0]);
	ll m = stoll(d[1]);
	ll da = stoll(d[2]);
	ll ret = 0;
	ll ty = y - 1;
	ret = 10LL;
	ll a = (ty - 2012LL) * 365LL;
	if(a < 0) a = 0;
	ret += a;
	ret += ty / 4LL - ty / 100LL + ty / 400LL;
	ret -= 2012 / 4 - 2012 / 100 + 2012 / 400;
	REP(i,m-1){
	    if(i==1 && ( y%4==0 && (y%100!=0 || (y%100==0&&y%400==0)) ) ) {
		ret += 1;
	    }
	    ret += ms[i];
	}
	ret += da;
	return ret;
    }
    return 0;
}

ll cm(string s){
    vector<string> d = split(s);
    ll ret=0;
    ret += Baktun * stoi(d[0]);
    ret += Katun * stoi(d[1]);
    ret += Tun * stoi(d[2]);
    ret += Uinal * stoi(d[3]);
    ret += Kin * stoi(d[4]);
    return ret;
}

string mtog(string s){
    int num = cm(s);
    int y = 2012;
    int m = 12;
    int d = 21;
    if(num <= 10){
	return "2012.12." + to_string(d+num);
    }else{
	REP(i,num){
	    if(m == 12 && d == 31){
		y++;
		m = 1;
		d = 1;
	    }else if(m==2 && d == 28 &&  ( y%4==0 && (y%100!=0 || (y%100==0&&y%400==0)) ) ) d++;
	    else if(d >= ms[m-1]){
		m++;
		d = 1;
	    }else d++;
	}
	return to_string(y) + "." + to_string(m) + "." + to_string(d);
    }
    return "";
}

string gtom(string s){
    ll num = cg(s);
    ll days[5];
    days[0] = Baktun;
    days[1] = Katun;
    days[2] = Tun;
    days[3] = Uinal;
    days[4] = Kin;
    string ret = "";
    num = (num % (13*days[0]));
    REP(i,4){
	ret += to_string(num/days[i]) + ".";
	num %= days[i];
    }
    ret += to_string(num/days[4]);
    return ret;
}

int main(){
    while(true){
	string s;
	cin >> s;
	if(s == "#") break;
	int c = 0;
	REP(i,s.size()) if(s[i] == '.') c++;
	if(c == 2) cout << gtom(s) << endl;
	else if(c == 4) cout << mtog(s) << endl;;
    }
    return 0;
}

Measured memory_bytes: 3292
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  for(;;){
    int field[30][30]={0};
    if(scanf("%1d",&field[10][10]) == EOF) break;
    for(int i=0; i<8; i++){
      for(int j=0; j<8; j++){
	if(i == 0 && j == 0) continue;
	scanf("%1d",&field[10+i][10+j]);
      }
    }
    for(int i=0; i<8; i++){
      for(int j=0; j<8; j++){
	if(field[i+10][j+10] == 0) continue;
	if(field[i+11][j+10] == 1 && field[i+10][j+11] == 1 && field[i+11][j+11] == 1){cout <<"A"<<endl;goto flag;}
	if(field[i+11][j+10] == 1 && field[i+12][j+10] == 1 && field[i+13][j+10] == 1){cout <<"B"<<endl;goto flag;}
	if(field[i+10][j+11] == 1 && field[i+10][j+12] == 1 && field[i+10][j+13] == 1){cout <<"C"<<endl;goto flag;}
	if(field[i+11][j+10] == 1 && field[i+11][j+9] == 1 && field[i+12][j+9] == 1){cout <<"D"<<endl;goto flag;}
	if(field[i+10][j+11] == 1 && field[i+11][j+11] == 1 && field[i+11][j+12] == 1){cout <<"E"<<endl;goto flag;}
	if(field[i+11][j+10] == 1 && field[i+11][j+11] == 1 && field[i+12][j+11] == 1){cout <<"F"<<endl;goto flag;}
	if(field[i+10][j+11] == 1 && field[i+11][j+10] == 1 && field[i+11][j+9] == 1){cout <<"G"<<endl;goto flag;}
      }
    }
  flag:;
  }
  return 0;
}

Measured memory_bytes: 1200
N = int(input())
s= []
for i in range(N):
  s.append(input())

M = int(input())
t = []
for i in range(M):
  t.append(input())

import collections
c_s = collections.Counter(s)
c_t = collections.Counter(t)

ans = 0
for k,v in c_s.items():
  ans = max((c_s[k]-c_t[k]),ans)

print(ans)

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <fstream>

using namespace std;

int dy[201];
int dx[201];
int dp[2][1<<12];
char field[101][101];
int dmg[201];
int stepDmg[2001];
int portions[101];
int inithp;
int maxhp;
int r,c;
int step;
int S,P,T;

const int INF=1000000000LL;

void input(){
	cin>>r>>c;
	for(int i=0;i<r;i++)for(int j=0;j<c;j++)cin>>field[i][j];
	cin>>T;
	for(int i=0;i<T;i++){
		char ch;
		int m;
		cin>>ch>>m;
		dmg[ch]=m;
	}
	cin>>S;
	int cx=0;
	int cy=0;
	for(int i=0;i<S;i++){
		char ch;
		int quan;
		cin>>ch>>quan;
		for(int j=0;j<quan;j++){
			int ny=cy+dy[ch];
			int nx=cx+dx[ch];
			stepDmg[step]=dmg[field[ny][nx]];
			step++;
			cx=nx;
			cy=ny;
		}
	}
	cin>>P;
	for(int i=0;i<P;i++)cin>>portions[i];
}

int main(){
	dy['U']=-1;
	dx['U']=0;
	dy['R']=0;
	dx['R']=1;
	dy['D']=1;
	dx['D']=0;
	dy['L']=0;
	dx['L']=-1;
	while(cin>>inithp>>maxhp&&(inithp|maxhp)){
		step=0;
		input();
		// startn_ÅÍ,cÁ½¨ð·×Äg¤
		for(int j=0;j<(1<<P);j++){
			int sum=0;
			for(int i=0;i<P;i++)if(!((j>>i)&1))sum+=portions[i];
			dp[0][j]=min(maxhp,sum+inithp);
		}
		for(int i=0;i<step;i++){
			int nxt=(i+1)%2;
			int cur=i%2;
			for(int j=(1<<P)-1;j>=0;j--){
				int res=-INF;
				int s=j;
				int pos=i;
				// Ü¾gpµÄ¢È¢portionðgp
				for(int k=0;k<P;k++)
					if(!((s>>k)&1)&&dp[nxt][s|(1<<k)]>0){
						res=max(res,min(dp[nxt][s|(1<<k)]+portions[k],maxhp));
					}
				// ÌêÖ
				res=max(res,dp[cur][s]-stepDmg[pos]);
				if(res<0)res=-INF;
				dp[nxt][s]=min(maxhp,res);
			}
		}
		bool ok=false;
		for(int j=0;j<(1<<P);j++)if(dp[step%2][j]>0)ok=true;
		if(ok)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 908
#include<cstdio>
#include<vector>
using namespace std;

void print(vector<vector<bool>>& A){
    if(A.size() == 0){
        printf("A is empty\n");
        return;
    }
    for(int i = 0; i < A.size(); i++){
        for(int j = 0; j < A[0].size(); j++){
            printf("%s", A[i][j]? "Q": ".");
        }
        printf("\n");
    }
}

bool isValid(vector<vector<bool>>& board, const int& r, const int& c){
    for(int i = 0; i < board.size(); i++){
        if(i != r && board[i][c]) return false;
    }
    for(int i = r-1, j = c-1; i >= 0 && j >= 0; i--, j--){
        if(board[i][j]) return false;
    }
    for(int i = r-1, j = c+1; i >= 0 && j < board[0].size(); i--, j++){
        if(board[i][j]) return false;
    }
    for(int i = r+1, j = c+1; i < board.size() && j < board[0].size(); i++, j++){
        if(board[i][j]) return false;
    }
    for(int i = r+1, j = c-1; i < board.size() && j >= 0; i++, j--){
        if(board[i][j]) return false;
    }
    return true;
}

void solve(vector<vector<bool>>& board, vector<bool> occupied, const int& r){
    if(r >= board.size()) {
        print(board);
        return;
    }
    if(occupied[r]){
        solve(board, occupied, r+1);
        return;
    }
    for(int c = 0; c < board[0].size(); c++){
        if(!board[r][c] && isValid(board, r, c)){
            board[r][c] = true;
            solve(board, occupied, r+1);
            board[r][c] = false;
        }
    }
}

int main(){
    vector<vector<bool>> board(8, vector<bool>(8, false));
    vector<bool> occupied (8, false);
    int n, x, y;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d %d", &x, &y);
        board[x][y] = true;
        occupied[x] = true;
    }
    solve(board, occupied, 0);
}



Measured memory_bytes: 2772
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>count(3);
  long long ans=1;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    bool b=false;
    int p=0;
    for(int j=0;j<3;j++){
      if(count[j]==a){
        p++;
        if(!b){
          count[j]++;
          b=true;
        }
      }
    }
    ans*=p;
    ans%=int(1e9+7);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#define MAX 500001
#define NIL NULL

struct node{
  int key;
  struct node *parent;
  struct node *left;
  struct node *right;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL) x=x->left;
  return x;
}


Node treeSearch(Node x, int k){
  if(x==NIL||k==x->key)
    return x;
  if(k<x->key) return treeSearch(x->left,k);
  else return treeSearch(x->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  
  if(x->right!=NIL) return treeMinimum(x->right);

  y=x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
    return y;
  }
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL||z->right==NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent=y->parent;

  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right=x;

  if(y!=x) z->key=y->key;
}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;

  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;
}

void inorder(Node x){
  if(x!=NIL){
    inorder(x->left);
    printf(" %d",x->key);
    inorder(x->right);
  }
}

void preorder(Node x){
  if(x!=NIL){
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
}
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

dst = [[-1]*W for _ in range(H)]

from collections import deque
dq = deque([(sh, sw, 0)])
while dq:
    h, w, d = dq.popleft()
    if 0 <= h < H and 0 <= w < W and dst[h][w] < 0 and S[h][w] != '#':
        dst[h][w] = d
        for dh in range(-2, 3):
            for dw in range(-2, 3): # [dh,dw]:[-2,-2]~[2,2]
                if dh*dh + dw*dw == 1: dq.appendleft((h + dh, w + dw, d))
                elif dh*dh + dw*dw > 1: dq.append((h + dh, w + dw, d+1))

print(dst[eh][ew])


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

int main() {
    int p,q,r;
    cin >> p >> q >> r;
    cout << min({p+q,q+r,r+p}) << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m, k,p,q;
	char str[30],str2[15],str3[15];
	scanf("%lld%lld%lld%lld",&n,&m,&k,&p);
	if (n <= m) { printf("%lld", n*k); }else{printf("%lld",(n-m)*p+k*m); }
	
	
}


Measured memory_bytes: 128
#include<stdio.h>

int n,A[50];

int func(int cnt,int num){
  if(num==0) return 1;
  if(cnt>=n) return 0;
  int refunc=func(cnt+1,num) || func(cnt+1,num-A[cnt]);
}

int main(){
  int q,M,i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(func(0,M)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define mp make_pair

using namespace std;

typedef long long int64;
typedef vector<int> vi;
typedef pair<int, int> ii;

class TaskC {
 public:
  const int MODULO = 998244353;

  void solveOne(istream &in, ostream &out) {
    string s;
    in >> s;
    int k;
    in >> k;
    int n0 = 0;
    vector<int> pos;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == '1') {
        pos.push_back(n0);
      } else {
        ++n0;
      }
    }
    reverse(pos.begin(), pos.end());
    vector<vector<int>> ways(pos.size() + 1, vector<int>(pos.size() + 1));
    vector<vector<int>> nways(pos.size() + 1, vector<int>(pos.size() + 1));
    ways[0][0] = 1;
    int i = 0;
    for (int val = n0; val >= 0; --val) {
      int j = i;
      while (j < pos.size() && pos[j] == val) ++j;
      int cnt = j - i;

      for (int a = 0; a < nways.size(); ++a) {
        fill(all(nways[a]), 0);
      }
      for (int extra = 0; extra <= pos.size(); ++extra) {
        for (int changed = 0; changed <= pos.size(); ++changed) {
          int64 old = ways[extra][changed];
          if (old == 0) continue;
          for (int take = 0; take <= cnt + extra; ++take) {
            int nextra = cnt + extra - take;
            int nchanged = changed + max(0, cnt - take);
            int& val = nways[nextra][nchanged];
            val += old;
            if (val >= MODULO) val -= MODULO;
          }
        }
      }

      i = j;
      ways.swap(nways);
    }

    int64 sum = 0;
    for (int changed = 0; changed <= pos.size() && changed <= k; ++changed) {
      sum += ways[0][changed];
    }
    sum %= MODULO;
    out << sum << "\n";

  }

  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int it = 0; it < nt; ++it) {
      solveOne(in, out);
    }
  }
};


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


Measured memory_bytes: 3984
#include <iostream>

using namespace std;

int main()
{
    int A, B, a, b, x;
    cin >> A >> B;
    for (int i = 1; i <= 1009; i++){
        a = i * 0.08;
        b = i * 0.1;
        if (a == A && b == B) {
            x = i;  break;
        }
        else{
            x = -1; continue;
        }
    }
    cout << x;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
using namespace std;
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
const long long llim=1e18;
const int lim=1e8;
int ans,a[101];
bool s=false,w=false,e=false,n=false;
string st;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    // freopen("solution.in","r",stdin);
	//freopen("solution.out","w",stdout);
	cin>>st;
    for (int i=0;i<st.size();i++)
    {
        if(st[i]=='E') e=true;
        else if(st[i]=='S') s=true;
        else if(st[i]=='N') n=true;
        else w=true;
    }
    if (s==n && e==w) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        vector<vector<int>> d(n);
        for (int i = 0; i < n; ++i) {
            int m,t;
            cin>>m;
            for (int j = 0; j < m; ++j) {
                cin>>t;
                d[i].emplace_back(t);
            }
            sort(d[i].begin(),d[i].end());
        }
        int kn;
        cin>>kn;
        vector<int> k(kn);
        for (int i = 0; i < kn; ++i) {
            cin>>k[i];
        }
        sort(k.begin(),k.end());
        vector<int> susp;
        for (int i = 0; i < n; ++i) {
            int di=0,ki=0;
            int ands=0;
            while(di<d[i].size()&&ki<k.size()){
                if(d[i][di]==k[ki]){
                    ++ands;
                    ++di;
                    ++ki;
                }
                else if(d[i][di]<k[ki])++di;
                else ++ki;
            }
            if(ands==kn)susp.emplace_back(i+1);
        }
        if(susp.size()==1)cout<<susp[0]<<endl;
        else cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3184
#include<stdio.h>

int A[1000000],n;

int binarysearch(int key){
  int left=0;
  int right=n;
  int mid;
  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid]) return 1;
    if(key>A[mid]) left=mid+1;
    else if(key<A[mid]) right = mid;
  }
  return 0;
}

int main(){
  int i,q,k,sum=0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(binarysearch(k)) sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2144
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N + 1];
		A[N] = 1000001;
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		sc.close();

		boolean[] check = new boolean[1000001];
		Arrays.fill(check, true);
		int ans = 0;

		// 小さい順に見ていく
		for (int i = 0; i < N; i++) {
			if (A[i + 1] != A[i] && check[A[i]]) {
				ans++;
			}

			for (int j = A[i]; j <= A[N - 1]; j += A[i]) {
				check[j] = false;
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 60408
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

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

    int l[n];
    rep(i, n) { cin >> l[i]; }

    sort(l, l + n);

    ll sum = 0;
    rep(i, n) {
        int a = l[i];
        repd(j, i + 1, n) {
            int b = l[j];
            int l_index, r_index;
            l_index = upper_bound(l, l + n, b - a) - l;
            r_index = lower_bound(l, l + n, a + b) - l;
            int ans_temp = r_index - l_index;
            if (b - a < a && a < a + b) {
                ans_temp--;
            }
            if (b - a < b && b < a + b) {
                ans_temp--;
            }
            // cout << ans_temp << endl;
            sum += (max(ans_temp, 0));
        }
    }
    cout << sum / 3 << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=1e18;

struct UnionFindTree{
    vector<int> par,rank;
    UnionFindTree(int n):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]<rank[ry]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

int main(){
    string s;cin>>s;
    int k;cin>>k;
    int n=(int)s.size();
    set<string> ans;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k&&j<=n-i;j++){
            ans.insert(s.substr(i,j));
        }
    }
    auto it=ans.begin();
  for(int i=1;i<k;i++) it++;
    cout<<*it<<endl;
    return 0;
}

Measured memory_bytes: 4760
def main():
    N, M = map(int, input().split())
    known = [False] * N
    rel = [list() for _ in range(N)]
    
    for _ in range(M):
        x, y, z = list(map(int, input().split()))
        rel[x - 1].append(y - 1)
        rel[y - 1].append(x - 1)
    r = 0
    for i in range(N):
        if known[i]:
            continue
        known[i] = True
        r += 1
        cur = rel[i].copy()
        while cur:
            t = cur.pop()
            if not known[t]:
                cur.extend(rel[t])
                known[t] = True
    print(r)

main()


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


int main(){
    int n,q;
    cin >> n;
    vector<long long>s(100009);
    rep(i,n){
        int a;
        cin >>a;
        s[a]++;
    }
    cin >> q;
    ll sum = 0;
    rep(i,100009){
        sum += i*s[i];
    }

    rep(i,q){
        int b,c;
        cin >> b >> c;
        sum -= b*s[b];
        sum -= c*s[c];
        s[c]+=s[b];
        s[b] =0;
        sum+=b*s[b];
        sum+=c*s[c];
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 4004
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*

*/

ll n,x,h[100],p[100];

ll f(ll d,ll l){
	if(d==0)return 0;
	if(l==0)return 1;
	ll ans=0;
	if(d-2>=h[l-1]*2){
		ans+=p[l];
	}else if(d-1>=h[l-1]){
		ans+=p[l-1];
		if(d-2>=h[l-1]){
			ans++;
			ans+=f(d-h[l-1]-2,l-1);
		}
	}else{
		ans+=f(d-1,l-1);
	}
	return ans;
}

int main(void){
	h[0]=1;
	p[0]=1;
	reg(i,1,50){
		h[i]=2*h[i-1]+3;
		p[i]=2*p[i-1]+1;
	}
	cin>>n>>x;
	cout<<f(x,n)<<endl;
	return 0;
}

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

int main(void)
{
    long long L, R, d;
    cin >> L >> R >> d;

    long long ans = 0;
    for (long long i = L; i <= R; i++)
    {
        if (i % d == 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(void) {

    string S[3];
    int pos[3];
    for (int i = 0; i < 3; i++) {
        cin >> S[i];
        pos[i] = 0;
    }

    int flag;
    int now = 0;
    while (1) {
        flag = -1;
        for (int i = 0; i < 3; i++) {
            if (pos[i] > S[i].size()) flag = i;
        }
        if (flag >= 0) break;

        // cout << "now: " << now << endl;
        char next_char = S[now][pos[now]];
        pos[now]++;
        now = next_char - 'a';
    }

    cout << char(flag+'A') << endl;

    return 0;
}

Measured memory_bytes: 256
def ask(X,Y):
 cost=[0]
 for j in Y:
  for i in range(len(cost)-1,-1,-1):
   a=X.find(j,cost[i])+1
   if a:
    if i+1<len(cost):
     cost[i+1]=min(cost[i+1],a)
    else:
     cost.append(a)
 return len(cost)-1
 


q=int(input())
Z=[]
for p in range(q):
 X=input()
 Y=input()
 z=ask(X,Y)
 Z.append(z)

for p in range(q):
 print(Z[p])



Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
typedef long long LL;
LL i,j,k,n,m;
LL mod=1000000007;
string s;

int main() {
  cin >> s;
  cin >> k;
  i=0;
  string sub = s.substr(i,1);
  while(sub=="1" && k!=1 && i<k - 1) {
    ++i;
    sub = s.substr(i,1);
  }
  cout << sub << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
    #include <stdlib.h>
     
    int main() {
      
      int num = 0;
      int start = 0;
      int finish = 0;
      int total = 0;
      
      scanf("%d", &num);
      
      for(int i = 0; i < num; i++) {
        scanf("%d %d", &start, &finish);
        
        total += (finish - start)+1; 
      }
      
      printf("%d", total);
      
      return 0;
    }

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

int main(){

	int p[8];
	while(cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]){
		int c[8];
		c[0] = 4;
		c[1] = 1;
		c[2] = 4;
		c[3] = 1;
		c[4] = 2;
		c[5] = 1;
		c[6] = 2;
		c[7] = 1;

		
		int minLeft = 100000000;
		int minV[8];
		for(int i = 0; i < 8; i++){
			int left = 0;
			for(int j = 0; j < 9; j++){
				left += max(p[j]-c[j],0);
			}
			if(minLeft > left){
				minLeft = left;
				for(int k = 0; k < 8; k++){
					minV[k] = c[k];
				}
			}
			else if(minLeft == left){
				// ツ青ョツ青板氾、ツ較ツづーツ行ツつ、
				int mul = 10000000;
				int it = 0;
				for(int k = 0; k < 8; k++){
					it += minV[k]*mul;
					mul /= 10;
				}
				int it2 = 0;
				mul = 10000000;
				for(int k = 0; k < 8; k++){
					it2 += c[k]*mul;
					mul /= 10;
				}
				if(it2 < it){
					for(int k = 0; k < 8; k++){
						minV[k] = c[k];
					}
				}
			}

			// ツバツッツフツァツづーツつクツづァツつキ
			int tmp = c[0];
			for(int i = 0; i < 7; i++){
				c[i] = c[i+1];
			}
			c[7] = tmp;
		}
		for(int i = 0; i < 8; i++){
			cout << minV[i];
			if(i == 7)
				cout << endl;
			else
				cout << " ";
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n,l1,l2,ans=2147483647;
char s[105],t[105];
bool check(int l)
{
	for(register int i=l1-l+1,j=1,k=1;k<=l;++k,++i,++j)
	if(s[i]!=t[j])return 0;
	return 1;
}
int main()
{
	scanf("%d%s%s",&n,s+1,t+1);
	l1=strlen(s+1);l2=strlen(t+1);
	for(register int l=0;l1+l2-l>=n&&l<=l1&&l<=l2;++l)
	if(check(l))ans=min(ans,l1+l2-l);
	return printf("%d\n",ans)&0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int main()
{
    vi v(3, 0);
    scanf("%d %d %d", &v[0], &v[1], &v[2]);
    sort(all(v));
    printf("%d\n", v[2] * 10 + v[1] + v[0]);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main(){
  ll a;
  long double b;
  cin>>a;
  cin>>b;
  long double ans=(long double)( a*b) ;
  ll bns = floor(ans) ;
  cout<<bns<<endl ;
    return 0;
  }

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int C = 26;
const int N = 2e5 + 7;
int cnt[C];
vector <int> p[C];
int f[N];
void add(int i) {
    for (; i < N; i |= (i + 1)) ++f[i];
}   
int get(int i) {
    int ans = 0;
    for (; i >= 0; i = (i & (i + 1)) - 1) ans += f[i];
    return ans;
}   
int get(int l, int r) {
    if (r < l) return 0;
    return get(r) - get(l - 1);
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    string s;
    cin >> s;
    for (char c : s) ++cnt[c - 'a'];
    int t = 0;
    for (int i = 0; i < C; ++i) {
        t += cnt[i] & 1;
    }   
    if (t > 1) {
        cout << "-1\n";
        exit(0);
    }
    int n = s.size();
    for (int i = 0; i < n; ++i) {
        p[s[i] - 'a'].push_back(i);
    }   
    vector <pair <int, int> > a;
    for (int i = 0; i < C; ++i) {
        int m = p[i].size() >> 1;
        for (int j = 0; j < m; ++j) {
            a.push_back({p[i][j], p[i][p[i].size() - 1 - j]});
        }   
    }   
    sort(a.begin(), a.end());
    int ans = 0;
    if (t) {
        int pm = -1;
        for (int i = 0; i < C; ++i) {
            if (p[i].size() & 1) {
                pm = p[i][p[i].size() >> 1];
                break;
            }   
        }   
        for (auto e : a) {
            ans += pm < e.first || pm > e.second;
        }   
    }
    for (auto e : a) {
        ans += get(e.first + 1, e.second - 1);
        ans += get(0, e.first - 1) << 1;
        add(e.second);
    }   
    cout << ans << '\n';
}   

Measured memory_bytes: 6408
#include <iostream>
using namespace std;
 
int main(){
    int card[4][13];
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            card[i][j]=0;
        }
    }
    int n;
    cin >> n;
    for(int h=0;h<n;h++){
        int num;
        char mar;
        cin >> mar >> num;
        if(mar == 'S'){card[0][num-1]=1;}
        if(mar == 'H'){card[1][num-1]=1;}
        if(mar == 'C'){card[2][num-1]=1;}
        if(mar == 'D'){card[3][num-1]=1;}
    }
        for(int i=0;i<4;i++){
            for(int j=0;j<13;j++){
                if(card[i][j] == 0){
                    if(i == 0){cout<< "S " << j+1 <<endl;}
                    if(i == 1){cout<< "H " << j+1 <<endl;}
                    if(i == 2){cout<< "C " << j+1 <<endl;}
                    if(i == 3){cout<< "D " << j+1 <<endl;}
                }
            }
        }
    }



Measured memory_bytes: 3072
#include <tuple>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bucnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl;

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int dist[110][110][21];
int cost[110][21];

vint q[21];
vint r[21];

int getcost(int d, int c) {
	int ret = 0;
	int i = 0;
	int s = 0;
	while (i < q[c].size() && q[c][i] <= d) {
		ret += r[c][i] * (q[c][i] - s);
		s = q[c][i];
		i++;
	}
	ret += r[c][i] * (d - s);
	return ret;
}

int main() {
	while (true) {
		int n, m, c, s, g;	scanf("%d %d %d %d %d", &n, &m, &c, &s, &g);
		s--;	g--;
		if (n == 0)	break;
		rep(i, c)	rep(j, n)	rep(k, n)	dist[j][k][i] = (j == k ? 0 : mod);
		rep(i, m) {
			int x, y, k, d; scanf("%d %d %d %d", &x, &y, &d, &k);
			k--;	x--;	y--;
			dist[x][y][k] = min(dist[x][y][k], d);
			dist[y][x][k] = min(dist[y][x][k], d);
		}
		//???????????????????????????
		rep(i, c)	rep(j, n)	rep(k, n)	rep(l, n) {
			dist[k][l][i] = min(dist[k][l][i], dist[k][j][i] + dist[j][l][i]);
		}
		vint p(c,0);
		rep(i, c)	scanf("%d", &p[i]);
		rep(i, c) {
			q[i].clear();	r[i].clear();
			srep(j, 1, p[i]) {
				int _q;	scanf("%d", &_q);
				q[i].push_back(_q);
			}
			rep(j, p[i]) {
				int _r;	scanf("%d", &_r);
				r[i].push_back(_r);
			}
		}
		//dist????????¢????????¨?????????
		rep(i, n)	rep(j, n)	rep(k, c) {
			if (dist[i][j][k] != mod) {
				dist[i][j][k] = getcost(dist[i][j][k], k);
			}
		}
		rep(i, n)	rep(j, c)	cost[i][j] = mod;
		rep(j, c)	cost[s][j] = 0;
		priority_queue<tuple<int,int,int>> pq;
		rep(i, c) 	rep(j, n) {
			if (dist[s][j][i] != mod) {
				cost[j][i] = dist[s][j][i];
				pq.push(mt(-cost[j][i], i, j));
			}
		}
		while (!pq.empty()) {
			int used = 0, d = 0, pos = 0;
			tie(d, used, pos) = pq.top();	pq.pop();
			d *= -1;
			if (d > cost[pos][used])	continue;
			rep(i, c) {
				if (i == used)	continue;
				rep(j, n) {
					if (dist[pos][j][i] == mod)	continue;
					if (cost[j][i] > d + dist[pos][j][i]) {
						cost[j][i] = d + dist[pos][j][i];
						pq.push(mt(-cost[j][i], i, j));
					}
				}
			}
		}
		int ret = mod;
		rep(i, c)	ret = min(ret, cost[g][i]);
		printf("%d\n", (ret == mod ? -1 : ret));
	}
	return 0;
}

Measured memory_bytes: 5504
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 100005
#define M 200005
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define FJ(i,a,b) for(int i=a;i<b;++i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _q fd[rt]
#define _l fd[rt << 1]
#define _r fd[rt << 1 | 1]
#define MID int mid=((l+r)>>1)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define zero(x) (((x)>0?(x):-(x))<EPS)
#define PB push_back
#define SZ size
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define MP make_pair
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
using namespace std;
const int MOD=1000000007;
const double PI=acos(-1.0);
const double EPS=1e-8;
inline void II(int &n){char ch=getchar();n=0;bool t=0;
for(;ch<'0';ch=getchar())if(ch=='-')t=1;
for(;ch>='0';n=n*10+ch-'0',ch=getchar());if(t)n=-n;}
int a[N * 3];
int n;
int main(){
    //IN;
    SC(n);
    FF(i, 1, n*3)II(a[i]);
    sort(a + 1, a + 1 + n * 3);
    LL ans = 0;
    for(int i = n * 3 - 1; i > n; i -= 2)ans += a[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int n = S.size();
  string ans = "yes";
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(S[i] == S[j]){
        ans = "no";
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let a: u32 = sc.read();
    let b: u32 = sc.read();
    if a + b == 15 {
        println!("{}", "+");
    } else if a * b == 15 {
        println!("{}", "*");
    } else {
        println!("{}", "x");
    }
}

Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  deque<char> dq;
  REP(i, N){
    dq.emplace_back(S[i]);
  }
  bool turn = true; // 正順ならtrue, 逆順ならfalse
  int Q; cin >> Q;
  REP(i, Q){
    int T; cin >> T;
    if(T == 1){
      if(turn){
        turn = false;
      }else{
        turn = true;
      }
    }else{
      int F; cin >> F;
      char C; cin >> C;
      if(F == 1 && turn || F == 2 && !turn){ // frontに追加する
        dq.emplace_front(C);
      }else{ // backに追加する
        dq.emplace_back(C);
      }
    }
  }
  if(turn){ // 正順なので頭から取り出す
    while(!dq.empty()){
      cout << dq.front();
      dq.pop_front();
    }
    cout << endl;
  }else{ // 逆順なので後ろから取り出す
    while(!dq.empty()){
      cout << dq.back();
      dq.pop_back();
    }
    cout << endl;
  }
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	int r;
	cin>>r;
	double ans;
	ans=2*PI*r;
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3800
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long d = sc.nextLong();
        long x = 0;
        long y = 0;

        long count = 0;

        for(long i = 0; i < n; i++){
            x = sc.nextLong();
            y = sc.nextLong();
            if((x * x) + (y * y) <= d * d){
                count++;
            }
        }
        sc.close();

        System.out.println(count);
    }
}

Measured memory_bytes: 59200
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

const int INF = 2000000000;

int main(){
  int n;
  cin >> n;
  vector<int> seq(n);
  rep(i, n) cin >> seq[i];
  vector<int> dp(n);
  rep(i, n) dp[i] = INF;
  rep(i, n){
    int index = lower_bound(dp.begin(), dp.end(), seq[i]) - dp.begin();
    dp[index] = seq[i];
  }
  int ans = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  string S;
  cin>>S;
  int L=0,R=S.size()-1;
  int ans=0;
  while(L<R){
    if(S[L]==S[R]){
      L++;R--;
    }else if(S[L]=='x'){
      ans++;
      L++;
    }else if(S[R]=='x'){
      ans++;
      R--;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<map>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=(x);i<=(y);i++)
using namespace std;
const int maxn=200000+5;
int n,m,a[maxn];
vector<int>l[maxn],r[maxn];
map<int,int>edl[maxn],edr[maxn];
int gor(int now,int j){
	if(r[j].empty())return j;
	auto it=upper_bound(r[j].begin(),r[j].end(),now);
	if(it==r[j].begin())return j;
	it--;now=*it;
	if(edr[j].count(now))return edr[j][now];
	return edr[j][now]=gor(now,j+1);
}
int gol(int now,int j){
	if(l[j].empty())return j;
	auto it=upper_bound(l[j].begin(),l[j].end(),now);
	if(it==l[j].begin())return j;
	it--;now=*it;
	if(edl[j].count(now))return edl[j][now];
	return edl[j][now]=gol(now,j-1);
}
int main(){
    scanf("%d%d",&n,&m);
	int x,y;
	rep(i,1,m)scanf("%d%d",&x,&y),r[y].push_back(x),l[y+1].push_back(x);
	rep(i,1,n)sort(l[i].begin(),l[i].end()),sort(r[i].begin(),r[i].end());
	rep(i,1,n){
		int j;a[i]++;
		j=gor(1e9,i);
		a[i]+=j-i;
		j=gol(1e9,i);
		a[i]+=i-j;
	}
	rep(i,1,n-1)printf("%d ",a[i]);
	printf("%d\n",a[n]);
	return 0;
}


Measured memory_bytes: 55048
N = int(input())
TXY = [(0,0,0)]
for i in range(N):
    TXY.append(tuple(map(int, input().split())))

def judge(N:int, TXY:tuple) -> bool:
    for i in range(N):
        delta_t = TXY[i+1][0] - TXY[i][0]
        delta_x = abs(TXY[i+1][1] - TXY[i][1])
        delta_y = abs(TXY[i+1][2] - TXY[i][2])
        
        if (delta_t%2 != (delta_x+delta_y)%2)\
          or (delta_t < (delta_x+delta_y)):
            return False
        
    return True

if judge(N,TXY):
    print("Yes")
else:
    print("No")


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

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

int main() {
  int N,K;
  cin >> N >> K;
  double ans=0;
  for(int i=1;i<=N;i++){
    double tmp=1;
    int k=i;
    while(k < K){
      tmp = tmp/2.0;
      k *= 2;
    }
    ans += tmp;
  }
  printf("%.10f\n",ans/(double)N);
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }
template<class T> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a == 1){ return a; } else{ return a * fact(a - 1); } }

int main(){
    ll N;
    vector<double> v;
    cin >> N;
    rep(i, 0, N){
        double temp;
        cin >> temp;
        v.push_back(temp);
    }
    sort(begin(v), end(v));
    double ans = v[0];
    rep(i, 1, N){
        ans = (ans + v[i]) / 2;
    }
    cout << ans << endl;
    
    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
      cout << "Left" << endl;
  }

  else if (A + B == C + D) {
      cout << "Balanced" << endl;
  }

  else if (A + B < C + D) {
      cout << "Right" << endl;
  }
}

Measured memory_bytes: 3604
#include <math.h>
#include <stdio.h>

int ispower(int n) {
	int a, b;

	for (a = 1; a < 50; a++)
		for (b = 2; b < 50; b++)
			if (pow(a, b) == n)
				return 1;
	return 0;
}

int main() {
	int x, n, max;

	scanf("%d", &x);
	max = 0;
	for (n = 1; n <= x; n++)
		if (ispower(n) && max < n)
			max = n;
	printf("%d\n", max);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;


int32_t main() 
{
 
  ios::sync_with_stdio(0); 
  cin.tie(0); cout.tie(0);
 
  int n;
  cin >> n;

  if(n < 2) return cout << 0, 0;

  int ten = 1LL, nine = 1LL, eight = 1LL;

  for(int i = 1; i <= n; i++){
     ten *= 10;
     ten %= mod;
     nine *= 9;
     nine %= mod;
     eight *= 8;
     eight %= mod;
  }

  int ans = (ten - 2 * nine + mod) % mod;
  ans = (ans + eight + mod) % mod;

  cout << ans;

  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
  int n,i,j;
  cin >> n;
  for(i=1;i<=9;i++){
    for(j=1;j<=9;j++){
      if(n==i*j){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ss string 
int main()

{ 
	int m;
	cin >> m;
	int rem=m%1000;
	if(rem==0)
	{
		cout << 0;
	}
	else
	{
		cout << 1000-rem;
	}
	
}
      


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<queue>
#include<string.h>
#include<algorithm>
#include<stack>
#include<set>

using namespace std;

typedef pair<int,int>P;

int DYX[4][2]{{-1,0},{1,0},{0,-1},{0,1}};

int H,W;
int ans=0;
string graph[1000];
int seen[1000][1000];
queue<P> que;

void bfs();

int main(){
  cin>>H>>W;
  for (int h = 0; h < H; h++) {
    cin>>graph[h];
    for (int w = 0; w < W; w++) {
      seen[h][w]=-1;
      if(graph[h][w]=='#'){
        que.push(P(h,w));
        seen[h][w]=0;
      }
    }
  }
  bfs();
  cout<<ans<<"\n";
  return 0;

}
void bfs(){
  while(que.size()){
    P next=que.front();que.pop();
    int y=next.first,x=next.second;
    for(auto dyx :DYX) {
      int ny=y+dyx[0],nx=x+dyx[1];
      if(0<=ny&&ny<H&&0<=nx&&nx<W&&graph[ny][nx]!='#'&&seen[ny][nx]==-1){
        seen[ny][nx]=seen[y][x]+1;
        ans=max(seen[ny][nx],ans);
        que.push(P(ny,nx));
      }
    }
  }
  return;
}

Measured memory_bytes: 13456
s = input()
n = len(s)
cond1 = s == s[::-1]
s2 = s[0:(n-1)//2]
cond2 = s2 == s2[::-1]
s3 = s[(n+3)//2 - 1:]
cond3 = s3 == s3[::-1]
print('Yes' if cond1 and cond2 and cond3 else 'No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
char a[10005], b[10005], c[10005];
int n, cnt[100005], s;
int main(){
	scanf("%d", &n);
	scanf("%s %s %s", a + 1, b + 1, c + 1);
	for(int i = 1; i <= n; i ++){
		cnt[a[i]] ++; s ++;
		if(!cnt[b[i]]) cnt[b[i]] ++ , s ++;
		if(!cnt[c[i]]) cnt[c[i]] ++ , s ++;
		cnt[a[i]] = cnt[b[i]] = cnt[c[i]] = 0;
		s -= 1;
	}
	printf("%d", s);
	return 0;
}


Measured memory_bytes: 384