akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
bool isPalindrome(string str) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = str.size() - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            //printf("%s is Not Palindrome", str); 
            return false; 
        } 
    } 
    //printf("%s is palindrome", str);
    return true; 
}
void solve()
{
	//Enter your code here Tanmay:)
	string s;
	cin>>s;
	bool a=isPalindrome(s);
	int size=s.size();
	string st1=s.substr(0,(size-1)/2);
	string st2=s.substr((size+3)/2-1,size-1);
	bool b=isPalindrome(st1);
	bool c=isPalindrome(st2);
	if(a&&b&&c)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
/*
int eulortotent(int n)
     {
    //Enter your code here Tanmay:)
    int total=n;
        for(int p=2;p*p<=n;p++)
        {
            if (n%p==0)
        {
            total /= p;
            total *= (p-1);
            while ( n % p == 0 ) 
                n /= p;
        }
    }

    if(n>1)
    {
        total/=n;
        total*=(n-1);
    }

  return total;
}
*/

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

#define ll long long

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

    ll int n,x,m,i,j;
    ll p,ans,result;
    ll c,f=INT_MIN,r;
    
    cin>>n>>x>>m;
    p=x;
    result=x;
    unordered_map<ll,ll>mp;
    
    mp[x]=1;
    
    for(i=2;i<=n;i++)
    {
        ans=(p*p)%m;
        if(mp[ans]!=0)
        {
            ll pp=mp[ans];
            ll cl=i-pp;
            ll du=i-1;
            ll rc=n-du;
            ll w=rc/cl;
            
            vector<ll>array;
            vector<ll>ps;
            
            for(j=pp;j<i;j++)
            {
                ll v=ans;
                array.push_back(v);
                ans=(ans*ans)%m;
            }
            
            ll pre=0;
            
            for(j=0;j<array.size();j++)
            {
                pre+=array[j];
                ps.push_back(pre);
            }
            
            result+=(w*ps[cl-1]);
            ll rm=rc%cl;
            if(rm!=0)
                result+=ps[rm-1];
            break;
        }
        if(ans==0)
        {
            f=0;
            break;
        }
        if(ans==1)
        {
            f=1;
            c=i;
            break;
        }
        result+=ans;
        p=ans;
        mp[ans]=i;
    }
    if(f==0)
    {
        cout<<result<<endl;
    }
    else if(f==1)
    {
        p=result;
        r=n-c+1;
        result+=r;
        cout<<result<<endl;
    }
    else{
        cout<<result<<endl;
    }

    
}

Measured memory_bytes: 6312
n,k = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
slist = ['']*k
for i in range(n):
    slist[i%k] += T[i]

ans = 0
for s in slist:
    dp = [[0,0,0]for i in range(len(s))]
    #dp[i][j] = 直前にｊを出したときの得点の最大値
    '''
    0..r
    1..s
    2..p
    '''
    dp[0][1] = S if s[0] == 'p' else 0
    dp[0][0] = R if s[0] == 's' else 0
    dp[0][2] = P if s[0] == 'r' else 0

    for i in range(1,len(s)):
        if s[i] == 'r':
            dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + P
            dp[i][1] = max(dp[i-1][0],dp[i-1][2])
            dp[i][0] = max(dp[i-1][1],dp[i-1][2])
        elif s[i] == 's':
            dp[i][0] = max(dp[i-1][2],dp[i-1][1]) + R
            dp[i][1] = max(dp[i-1][0],dp[i-1][2])
            dp[i][2] = max(dp[i-1][1],dp[i-1][0])
        else:
            dp[i][1] = max(dp[i-1][2],dp[i-1][0]) + S
            dp[i][0] = max(dp[i-1][1],dp[i-1][2])
            dp[i][2] = max(dp[i-1][1],dp[i-1][0])
    
    ans += max(dp[len(s)-1][0],dp[len(s)-1][1],dp[len(s)-1][2])
#print(slist)
print(ans)



Measured memory_bytes: 106184
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    set<ll> a;
    for(int i=0;i<n;++i){
        ll x; cin>>x;
        a.insert(x);
    }
    if(a.size()==n) cout<<"YES";
    else cout<<"NO";
}


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

int main() {
    int n;
    cin>>n;
    vector<int> p(n);
    int c=0;
    for(int i=0;i<n;i++){
        cin>>p.at(i);
    }
    for(int j=1;j<n-1;j++){
        if((p.at(j-1)<p.at(j)&&p.at(j)<p.at(j+1))||
           (p.at(j-1)>p.at(j)&&p.at(j)>p.at(j+1))){
               c+=1;
        }
    }
        cout<<c;
return 0;}
/*
g++ code.cpp
./a.out
*/

Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
minmoney=100000000000000000
money=0
for i in range(0,100001):
    money = 2*C*i+A*max(0,X-i)+B*max(0,Y-i)
    minmoney = min(minmoney,money)

print(minmoney)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int L;
    cin >> L;
    double ans;
    ans = L*L*L/27.0;
    printf("%6lf", ans);

}

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

const int N = 1e5 + 9;

vector< int > ar;

int main(){
    int n;
    cin >> n;
    for( int i = 0; i < n; i++ ) {
        int num;
        cin >> num;
        ar.push_back( num );
    }
    sort( ar.begin(), ar.end() );

    for( int i = ar[ 1 ]; i > 0; i-- ){
        int count = 0;

        for( int j = 0; j < ar.size(); j++ ){
            if( ar[ j ] % i != 0 )
                count++;
        }

        if( count < 2 ){
            cout << i;
            break;
        }
    }



    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}
 
ll nCr(ll n,ll r){
    if(r==1)return n;
    if(r==2)return n*(n-1)/2;
    return n*(n-1)*(n-2)/6;
}
 
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<ll>nums(N,0);
    rep(i,N)
    {
        cin >> A[i];
        nums[A[i]-1]++;
    }
    ll total = 0;
    rep(i, nums.size())
    {
        if( nums[i] > 1 ) total += nCr(nums[i],2);
    }
 
    rep(i,N)
    {
        ll ans = total;
        if( nums[A[i]-1]-1 > 1 )
        {
            ans -= nCr(nums[A[i]-1],2);
            ans += nCr(nums[A[i]-1]-1,2);
        }
        else ans -= nCr(nums[A[i]-1],2);
        cout << ans << endl;
    }
}


Measured memory_bytes: 4992
/*
 * ARC100_C.cpp
 *
 *  Created on: Jun 21, 2018
 *      Author: 13743
 */

#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

int n;
int a[10000];

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

	cin >> n;
	REP(i, n) {
		cin >> a[i];
	}

	int ans = 0;

	REP(i, n) {
		int x = a[i];
		while(x%2 == 0) {
			ans++;
			x /= 2;
		}
	}
	cout << ans << endl;
}





Measured memory_bytes: 256
while True:
    L = raw_input().split()

    a = int(L[0])
    o = (L[1])
    b = int(L[2])

    if o == "?":
         break
        
    elif o == "+":
        print a + b
    elif o == "-":
        print a - b
    elif o == "*":
        print a * b
    elif o == "/":
        print a/b

Measured memory_bytes: 6356
import java.util.Scanner;

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

    while (sc.hasNext()) {
      int sum = 0;
      int d = sc.nextInt();

      for (int i = 0, size = 600 / d; i < size; i++) {
        sum += f(i * d) * d;
      }

      System.out.println(sum);
    }
  }

  static int f(int x) {
    return x * x;
  }
}

Measured memory_bytes: 17168
/* Author : Prasuk Jain */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define int              long long int
#define ull              unsigned long long
#define ld               long double
#define fo(i, n)         for(int i=0; i<n; i++)
#define FOR(i, a, b)     for(int i=a; i<b; i++)
#define rfor(i, n)       for(int i=n-1; i>=0; i--)
#define RFOR(i, a, b)    for(int i=b-1; i>=a; i--)
#define tr(it, v)        for(auto it=a.begin(); it!=a.end(); it++)
#define vi               vector<int>
#define pii              pair<int,int>
#define mii              map<int,int>
#define pqb              priority_queue<int>
#define pqs              priority_queue<int,vi,greater<int>>
#define mp               make_pair
#define pb(x)            push_back(x)
#define hcf(x, y)        __gcd(x, y)
#define lcm(x, y)        boost::math::lcm(x,y)
#define setpre(x, y)     fixed << setprecision(y) << x
#define setbits(x)       __builtin_popcountll(x)
#define zerolead(x)      __builtin_clzll(x)
#define zerotrail(x)     __builtin_ctzll(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define PI               3.1415926535897932384626
const int mod = 1e9+7;
const int inf = 1e18;
int mpow(int base, int exp);
bool isprime(int num);
void prifact(int num);
 
//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//
 
void coderprasukj(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
int32_t main() {
    //coderprasukj();
    int t, n, k, x, y;
    cin >> k;
    cin >> x >> y;
    int flag = 0;
    for(int i=1; i*k<=y; i++){
        if(i*k>=x && i*k<=y) {
            flag = 1;
            break;
        }
    }
    if(flag) cout << "OK\n";
    else cout << "NG\n";
    return 0;
}
 
//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//
 
int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((int)result * base) % mod;
        base = ((int)base * base) % mod;
        exp >>= 1;
    }
  return result;
}
 
bool isprime(int num) {
    if(num <= 1) return false;
    for(int i=2; i*i <= num; i++)
        if(num%i == 0) return false;
    return true;
}
 
void prifact(int num){
    for(int i=2; i<=num; i++)
    if(num%i == 0){
        int cnt = 0;
        while(num%i == 0)
        cnt++ , num /= i;
        cout << i << "^" << cnt << " ";
    }
    if(num > 1)
    cout << num << "^" << "1" << " ";
}


Measured memory_bytes: 3592
#include<cstdio>
#include<set>
#include<algorithm>
#include<iostream>
#define ll long long
#define inf 0x7fffffff
using namespace std;
const int maxn=1e5+10;
pair<int,int> b[maxn];
multiset<int> s;
ll sum()
{
	ll sum=0;
	for(__typeof(s.begin()) it=s.begin();it!=s.end();it++)
	{
		sum+=*it;
	}
	return sum;
}
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&y);
		s.insert(y);
	}
	for(i=0;i<m;i++)
	{
		scanf("%d%d",&b[i].second,&b[i].first);
		b[i].first=-b[i].first;
	}
	sort(b,b+m);
	for(i=0;i<m;i++)
	{
		b[i].first=-b[i].first;
	}
	for(i=0;i<m;i++)
	{
		for(j=0;j<b[i].second;j++)
		{
			if(*(s.begin())>=b[i].first)
			  break;
			s.erase(s.begin());
			s.insert(b[i].first);
			x++;
		}
	}
	printf("%lld",sum());
	return 0;
}

Measured memory_bytes: 5760
M=998244353;N=gets.to_i;v=$<.map{|e|Complex(*e.split.map(&:to_i))};h={};r=2**N%M-N-1;N.times{|i|(i+1...N).map{|j|h[x=[i,j]]||(j+1...N).map{|k|((v[j]-v[k]).conj*(v[i]-v[k])).imag.abs<1e-9&&x<<k}&&(l=x.size).times{|a|(a+1...l).map{|b|r=(r-2**(b+~a))%M;h[[x[a],x[b]]]=1}}}};p r

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

typedef long long ll;
typedef pair<ll,ll> edge;

string s;

int main(){
    ll n = 0;
    cin >> n ;
    cin >> s;

    if( n%2 != 0){
        cout << "No" << endl;
        return 0;
    }
    for( ll i=0; i<n/2; i++){
        if( s[i] != s[i+n/2]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 200005
typedef pair<int,int> P;
int N,H,W;
int y[MAX],x[MAX];
char dir[MAX];
int cost[MAX];
int ans[MAX];
char str[100];
map<int, vector<P> > mp;

void calc(vector<P> v,int flag){
  int size=v.size();
  sort(v.begin(),v.end());
  queue<int> da[2];
  queue<int> db[2];
  for(int i=0;i<size;i++){
    int px=v[i].first;
    int id=v[i].second;
    int xa=px%2;
    int xb=(px+flag)%2;
    if(dir[id]=='S'){
      da[xa].push(id);
      ans[ da[xa].front() ]=cost[id];
      da[xa].pop();
    }else{
      da[xb].push(id);
      db[xb].push(cost[id]);
    }
  }
  for(int i=0;i<2;i++){
    while(!da[i].empty()){
      ans[ da[i].front() ]=db[i].front();
      da[i].pop();
      db[i].pop();      
    }
  }
}

void solve(){
  map<int, vector<P> > :: iterator it;
  for(it=mp.begin();it!=mp.end();it++)calc(it->second,it->first%2);
}

int main(){
  scanf("%d %d %d",&W,&H,&N);
  for(int i=0;i<N;i++){
    scanf("%d %d %s",&x[i],&y[i],str);
    dir[i]=str[0];
    cost[i]=(dir[i]=='S'?H-y[i]:W-x[i]);
    mp[ y[i]+x[i] ].push_back( P(x[i],i) );
  }
  solve();
  vector<P> vec(N);
  for(int i=0;i<N;i++)vec[i]=P( ans[i],i );
  sort(vec.begin(),vec.end());
  for(int i=0;i<N;i++)
    printf("%d\n",vec[i].second+1);
  return 0;
}

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

struct Point {
    double x,y;
};

void koch(int ,struct Point,struct Point);

int main(){
    struct Point a,b;
    int n;
    
    scanf("%d",&n);
    
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
    
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
    
    return 0;
}

void koch(int n,struct Point a,struct Point b){
    if(n==0) return;
    
    struct Point s,t,u;
    double th = M_PI*60.0/180.0;
    
    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
    
    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,b);
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define N 100005
using namespace std;

typedef pair<int,int> P;

vector<P> G[N];
bool used[N],used2[N];

map<int,int> cnt;
set<P> usedP;

void dfs(int x){
  
  if(used2[x])return;
  used2[x]=1;
  used[x]=1;
  
  for(int i=0;i<G[x].size();i++){

    int nx=G[x][i].first,cost=G[x][i].second;
    
    if(!usedP.count(P(min(x,nx),max(x,nx)))){
      usedP.insert(P(min(x,nx),max(x,nx)));
      if(cnt.count(cost))cnt[cost]++;
      else cnt[cost]=1;
    }

    dfs(nx);
    
  }
  
}

int main(){

  int n;
  
  while(1){
    
    cin>>n;
    if(!n)break;

    for(int i=0;i<n;i++)G[i].clear();
    
    for(int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;
      G[i].push_back(P(a,b));
      cin>>a>>b;
      G[i].push_back(P(a,b));
    }
    
    memset(used,0,sizeof(used));
    
    int ans=1;
    
    for(int i=0;i<n;i++){
      if(used[i])continue;
      
      memset(used2,0,sizeof(used2));
      cnt.clear();
      usedP.clear();
      
      dfs(i);
      
      if(cnt.size()){
	map<int,int>::iterator ite=cnt.end();
	ite--;
	ans=(ans*(*ite).second)%10007;
      }
      
    }
    
    cout<<ans<<endl;
  }
  
  return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int dp[n+1][n+1]; rep(i,n+1) rep(j,n+1) dp[i][j] = 0;
    for (int i = n-1; i >= 0; i--) {
        for (int j = n-1; j >= 0; j--) {
            if (s[i] == s[j]) {
                dp[i][j] = dp[i+1][j+1] + 1;
            }
        }
    }
    //rep(i,n) {rep(j,n) {printf("%d ", dp[i][j]);} printf("\n");}
    int ans = 0;
    rep(i,n) {
        rep(j,i) {
            int c = min(dp[i][j], i-j);
            ans = max(ans,c);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 101324
fun main(arr: Array<String>) {
    val (h,w) = readLine()!!.split(" ").map { it.toInt() }
    val map = (1..h).map { readLine()!! }
    val ans = map.indices.map { r -> map[r].indices.map { c-> mineCount(r,c,map) } }
    ans.forEach { println(it.joinToString("")) }
}

fun mineCount(r:Int, c:Int, map:List<String>):Char {
    if(map[r][c] == '#') {
        return '#'
    }
    var cnt = 0
    for(i in (r-1..r+1)) {
        if(i < 0) {
            continue
        }
        if(i > map.lastIndex) {
            continue
        }
        for(j in (c-1..c+1)) {
            if(j < 0) {
                continue
            }
            if(j > map[i].lastIndex) {
                continue
            }
            if(map[i][j] == '#') {
                cnt++
            }
        }
    }
    return cnt.toString()[0]
}

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

/* */

int main(){
    // 入力スタンダード
    int n,m; // n個の展望台、m本の道
    cin >> n >> m;

    // 入力スタンダード（複数指定）
    // **************************************
    vector<vector<int>> h(n,vector<int>(2));
    for(int i=0; i<n; i++) {
        cin >> h.at(i).at(0);
        h.at(i).at(1) = 1;
    }
    int sum = n;
    
    for(int i=0; i<m; i++) {
        int q, r;
        cin >> q >> r;
        if(h.at(q-1).at(0) > h.at(r-1).at(0)){
            if (h.at(r-1).at(1) == 1) {
                sum-- ;
                h.at(r-1).at(1) = 0;
            }
        }else if(h.at(q-1).at(0) < h.at(r-1).at(0)){
            if (h.at(q-1).at(1) == 1) {
                sum-- ;
                h.at(q-1).at(1) = 0;
            }
        }else{
            if (h.at(r-1).at(1) == 1) {
                sum-- ;
                h.at(r-1).at(1) = 0;
            }
            if (h.at(q-1).at(1) == 1) {
                sum-- ;
                h.at(q-1).at(1) = 0;
            }
        }
    }

    cout << sum <<endl;

    return 0;
}

Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()


#include <vector>
#include <set>
using namespace std;

struct union_find {
  vector<int> par;
  vector<int> rank;
  union_find(int n) : par(n) , rank(n) {
    for(int i = 0;i < n;i++) par[i] = i;
  }
  int root(int i) {
    return par[i] == i ? i : par[i] = root(par[i]);
  }
  pair<int,int> unite(int x,int y) {
    x = root(x);
    y = root(y);
    if(x == y) return pair<int,int>(-1,-1);
    if(rank[x] < rank[y]) {
      par[x] = y;
      return {y , x};
    }
    else {
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
      return {x,y};
    }
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  union_find uf(n + 1);
  for(int i = 0;i < m;i++) {
    int a,b,c;
    cin >> a >> b >> c;
    uf.unite(a, b);
  }
  int cnt = 0;
  for(int i = 1;i <=n ;i++) {
    if(uf.root(i) == i) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def calc(n, k):
    if n < 10**(k-1):
        ans = 0
    elif n == 0:
        ans=0
    else:
        ans = 0
        digits = int(math.log10(n))+1
        #Nより小さい桁数
        if k <= digits-1:
            for n_dig in range(k, digits):
                ans += 9 * combinations_count(n_dig-1,k-1) * (9**(k-1))
                #print(n_dig,tot)
        #Nと桁数が同じ
        top = n//10**(digits-1)
        ans += (top-1) * combinations_count(digits-1,k-1) * (9**(k-1))
        if k>1:
            ans += calc(n-top*10**(digits-1), k-1)
        elif k==1:
            ans += 1
    #print(n,k,ans)
    return ans
    

N = int(input())
K = int(input())

tot = calc(N,K)

print(tot)
    


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

long long N,A,B;

int main(){
	cin>>N>>A>>B;
	long long totalA=A*(N-1)+B,totalB=A+(N-1)*B;
	if((N==1&&A!=B)||A>B){
		cout<<0<<'\n';
	}else{
		cout<<totalB-totalA+1<<'\n';
	}
}

Measured memory_bytes: 3612
using System;
public class Hello{
    public static void Main(string[] args){
        // Your code here!
        
            int a,b,c;
            a = int.Parse(Console.ReadLine()); //標準入力
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            b = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
            c = int.Parse(str[1]);
            
            int x = 0;
            int y = 0;
            int z = 0;
            
            string[] str2 = Console.ReadLine().Split(' ');
            for (int i = 0; i< a; i++){
                int d = int.Parse(str2[i]);
                    if (d <= b){
                        x = x + 1;
                    }
                    else if (d <= c){
                        y = y + 1;
                    }
                    else {
                        z = z + 1;
                    }
                    
            }
            
            int iMin = System.Math.Min(x, y);
            int iMin2 = System.Math.Min(iMin, z);
            Console.WriteLine(iMin2);
            
    }
}


Measured memory_bytes: 11092
import scala.io.StdIn

object Main extends App {
  val s = StdIn.readLine
  val ans = {
    val len = s.length -2
    val sb = StringBuilder.newBuilder
    sb.append(s.charAt(0))
      .append(len)
      .append(s.charAt(s.length-1))
    sb.toString
  }
  println(ans)
}

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

int N;
int f(ll x, bool a, bool b, bool c) {
  if(x > N) return 0;
  int res = 0;
  if(a && b && c) res++;
  res += f(10*x + 3, 1, b, c);
  res += f(10*x + 5, a, 1, c);
  res += f(10*x + 7, a, b, 1);
  return res;
}

int main() {
  cin >> N;
  cout << f(0LL,0,0,0) << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

int d[N];
void save()
{
  for(int i=1;i<N;++i){
    for(int j=i;j<N;j+=i){
      d[j]+=1;
    }
  }
}

int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
        int n;
        Int(n);

        save();

        int res=0;
        for(int i=1;i<n;++i){
           int x = n-i;
          // error(x,d[x]);
           res+= d[x];
        }
        printf("%d\n", res);

        //printf("Case %d: ",++te);
    }

    //cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}






Measured memory_bytes: 7664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int ans1 = a.back(), ans2;
    int midl, midr;
    midl = midr = ans1 / 2;
    if (ans1 % 2) midr++;
    int difmin = INT_MAX;
    for (int i = 0; i < n - 1; i++) {
        if (difmin > abs(a[i] - midl)) {
            difmin = abs(a[i] - midl);
            ans2 = a[i];
        }
        if (difmin > abs(a[i] - midr)) {
            difmin = abs(a[i] - midr);
            ans2 = a[i];
        }
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

int main(){
    string S; cin >> S;
    ll r = 0, b = 0;
    rep(i, S.size()){
        if (S[i] == '0') ++r;
        else b++;
    }
    pt(min(r, b) * 2);
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    int p = 0;
    int ans = 0;
    for(int i = Math.min(a, b); i >= 1; i--) {
      if((a % i == 0) && (b % i == 0)) {
        p++;
        if(p == k) {
          ans = i;
          break;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22740
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int Q = sc.nextInt();

    int[] p = new int[N+1];
    for (int i = 0; i < Q; i++) {
      int A = sc.nextInt();
      p[A]++;
    }
    for (int i = 1; i <= N; i++) {
      System.out.println(p[i]-Q+K > 0 ? "Yes" : "No");
    }
  }
}

Measured memory_bytes: 61360
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

const int inf = 1e8;

int dist[100010][3] ;

int main(){
  
  int N,M; cin >> N >> M;
  
  vector<vector<int>> to(N);
  
  for(int i = 0; i < M; i++){
    int u,v; cin >> u >> v; u--; v--;
    to[u].push_back(v);}
  
  int start,goal; cin >> start >> goal; start--; goal--;
  
  for(int i = 0; i < 100010; i++){
    for(int j = 0; j < 3; j++){
      dist[i][j] = inf;}}
  
  queue<pair<int,int>> Q; Q.push(make_pair(start,0));
  dist[start][0] = 0;
  while(!Q.empty()){
    pair<int,int> p = Q.front(); Q.pop();
    int s = p.first; int t = p.second; //sがノード、tが３で割ったmod
    for(int i = 0; i < to[s].size(); i++){
      int r = to[s][i]; int nt = (t + 1) % 3; //pから繋がるノードを探索 
      if( dist[r][nt] != inf){ continue;}
      else{ dist[r][nt] = dist[s][t] + 1; Q.push(make_pair(r,nt));}}}
  
  int answer = dist[goal][0];
  if(answer == inf){ answer = -1;}
  else{ answer /= 3;}
cout << answer << endl; return 0;}
  

Measured memory_bytes: 6912
def main():
    N = int(input())
    from math import sqrt
    ans = 10**12
    for i in range(1, int(sqrt(N))+2):
        if N % i:
            continue
        j = N//i
        ans = min(ans, i+j-2)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
h, w = map(int, input().split())
s = [input() + '#' for _ in range(h)]
s.append('#' * (w + 1))
t = [[-1] * w for _ in range(h + 1)]
tstart = [-1] * (w + 1)
for i in range(h + 1):
  ystart = -1
  for j in range(w + 1):
    if s[i][j] == '#':
      if ystart != -1:
        for k in range(ystart, j):
          t[i][k] += j - ystart
        ystart = -1
      if tstart[j] != -1:
        for k in range(tstart[j], i):
          t[k][j] += i - tstart[j]
        tstart[j] = -1
    else:
      if ystart == -1:
        ystart = j
      if tstart[j] == -1:
        tstart[j] = i
print(max(map(max, t)))


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,K;
  cin>>N>>K;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a[i];
  vector<bool>dp(K+1);
  dp[0]=false;
  for(int i=1;i<=K;i++){
    bool no=true;
    bool ok=false;
    for(int j=0;j<N;j++){
      if(i-a[j]>=0){
        no=false;
        if(!dp[i-a[j]])ok=true;
      }
    }
    if(no)dp[i]=false;
    else if(ok)dp[i]=true;
  }
  if(dp[K])cout<<"First"<<endl;
  else cout<<"Second"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] registerdUsers = new String[256];
		String[] acsessUsers = new String[256];
		boolean isOpen = false;

		int n = scan.nextInt();
		for(int i = 0; i < n; i++) {
			registerdUsers[i] = scan.next();
		}

		int m = scan.nextInt();
		for(int i = 0; i < m; i++) {
			acsessUsers[i] = scan.next();
		}

		scan.close();
		boolean flag = false;

		for(int i = 0; i < m; i++) {
			for(int j = 0; j < n; j++) {
				if(acsessUsers[i].equals(registerdUsers[j])) {
					if(isOpen) {
						System.out.println("Closed by " + acsessUsers[i]);
						isOpen = false;
						flag = true;
						break;
					}else {
						System.out.println("Opened by " + acsessUsers[i]);
						isOpen = true;
						flag = true;
						break;
					}
				}
			}
			if(!flag) {
				System.out.println("Unknown " + acsessUsers[i]);
			}
			flag = false;
		}
	}
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define long long long
typedef pair < long , long > pii;

class XorSum {
    long mod = 1000000000 + 7;
    long mul = 500000004;
public:
	void solve(std::istream& in, std::ostream& out) {
	    unsigned long n;
	    in>>n;
	    unsigned long data[n];
	    for(int i=0;i<n;i++) in>>data[i];

	    pair<long,long> inf[65];

	    memset(inf , 0 , sizeof(inf));

	    for(int i=0;i<=61;i++){
	        for(int j=0;j<n;j++){
	            if(data[j] & (1LL<<i)) inf[i].first++;
	            else inf[i].second++;
	        }
	    }

	    long ans=0;
	    for(int i=0;i<n;i++){
	        for(int j=0;j<=61;j++){

	            if(data[i] & (1LL<<j)) ans+= (((1LL<<j) % mod) * (inf[j].second)) %mod;
	            else ans+= (((1LL<<j) % mod) * (inf[j].first)) %mod;

	            ans%=mod;
	        }
	    }
	    ans*=mul;
	    ans%=mod;
	    out<<ans<<"\n";

	}
};


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


Measured memory_bytes: 2560
x,y=map(int,input().split())
if y%2==1:
    print('No')
    exit(0)

if y<2*x or y>4*x:
    print('No')
    exit(0)
b=y-2*x
if b>2*x:
    print('No')
    exit(0)

print('Yes')

Measured memory_bytes: 61592
N,M = map(int,input().split())

xyz = []

for i in range(N):

    x,y,z = map(int,input().split())
    xyz.append([x,y,z])

ans = -1 * float("inf")

for bpm in range(2):

    for dpm in range(2):

        for fpm in range(2):


            if bpm == 0:
                bpm = -1
            if dpm == 0:
                dpm = -1
            if fpm == 0:
                fpm = -1

            lis = []

            for i in xyz:

                lis.append(i[0] * bpm + i[1] * dpm + i[2] * fpm)

            lis.sort()
            lis.reverse()

            now = 0
            for j in range(M):
                now += lis[j]

            ans = max(ans,now)

print (ans)

Measured memory_bytes: 39664
#include <stdio.h>

int main(){
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);
  
  int i;
  int syojikin=B;
  for(i=0; i<C; i++){
    syojikin -= A;
    if(syojikin < 0) break;
  }
  printf("%d",i);
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
	Character objChar1;
	
	String str;
	char c;
	int i,a;
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br = new BufferedReader(isr);
	str = br.readLine();
	
	

	for (i=0;i<str.length();i++){
		c=str.charAt(i);
		if(Character.isUpperCase(c)) {
			c=Character.toLowerCase(c);
		}else {
			c=Character.toUpperCase(c);
		}
		System.out.print(c);
		
	}
	System.out.println();
}
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	ll a, b;
	cin >> a >> b;
	if((a+b)%2==0) cout << (a+b)/2 << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int k;
  cin >> k;
  int now = 0;
  for (int i = 0; i < k; ++i) {
    now = (((now * 10) % k) + (7 % k)) % k;
    if (now == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector <int> a(n),b(n);
	vector < pair<int,int> > c(n);
	bool canDone = true;
	for ( int i = 0; i < n; ++i ) {
		cin >> a[i] >> b[i];
		c[i].second  = a[i];
		c[i].first   = b[i];
		if(a[i] > b[i]) canDone = false;
	}
	sort(c.begin(),c.end());
	int time = 0;
	for ( int i = 0; i < n - 1; ++i ) {
		time += c[i].second;
		if(c[i + 1].first - c[i + 1].second < time ) canDone = false;
	}
	if(canDone)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3328
// vim: set fdm=marker:
// {{{
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <utility>

using namespace std ;

typedef long long ll ;

// }}}

ll a[11111], b[11111];

int main()
{
    int N;
    cin >> N;
    for(int i = 0 ; i != N ; i++)
        scanf("%lld", a+i);
    for(int i = 0 ; i != N ; i++)
        scanf("%lld", b+i);
    ll sa = 0, sb = 0;
    for(int i = 0 ; i != N ; i++) {
        sa += a[i];
        sb += b[i];
    }
    ll nop = sb-sa;
    if(nop < 0)
        return 0*puts("No");
    ll need = 0;
    for(int i = 0 ; i != N ; i++) {
        if(a[i] < b[i])
            need += (b[i]-a[i]+1)/2;
    }
    if(need > nop)
        return 0*puts("No");
    puts("Yes");
    return 0;
}



Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
/////////////////// 
//

#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  float py = 6.283185307179586232/2.00;
  float a;
  cin >> a;
  a*=2.00000000000000000;
  cout << std::fixed << std::setprecision(15) << (a*py) << endl;
  return 0;
}







Measured memory_bytes: 3228
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

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


int main() {
    ll n, k;
    cin >> n >> k;
    ll x = n % k;
    cout << min(x, abs(x - k)) << endl;
    return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    a110(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}


fun a110(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val numList = args[0].split(" ").map { it.toInt() }.sortedDescending()
    println(numList[0] * 10 + numList[1] + numList[2])
}


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

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] x = new int[n];
        int[] y = new int[n];
        for(int i = 0; i < n; i++){
            x[i] = Integer.parseInt(sc.next());
            y[i] = x[i];
        }
        
        Arrays.sort(y);
        int y1 = y[n/2-1];
        int y2 = y[n/2];
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            if(x[i] <= y1){
                sb.append(y2).append(System.lineSeparator());
            }else{
                sb.append(y1).append(System.lineSeparator());
            }
        }
        
        System.out.print(sb);
    }
}

Measured memory_bytes: 59888
package main

import "fmt"

func nextString() string {
	var x string
	fmt.Scan(&x)
	return x
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var n, m int
	fmt.Scan(&n)

	dic := map[string]int{}

	for range make([]struct{}, n) {
		s := nextString()
		dic[s]++
	}

	fmt.Scan(&m)
	for range make([]struct{}, m) {
		s := nextString()
		dic[s]--
	}

	ans := 0
	for _, v := range dic {
		ans = max(ans, v)
	}

	fmt.Println(ans)
}


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

#include <bits/stdc++.h>
using namespace std;

struct uni
{
  vector<int> par;

  uni(int N) : par(N)
  {
    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);
    int ry = root(y);
    if (rx == ry)
      return;
    par[rx] = ry;
  }

  bool same(int x, int y)
  {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(){
  int n;cin>>n;
  uni tree(n);
  vector<bool> ans;
  int q;cin>>q;
  while (q--) {
    int com,x,y;cin>>com>>x>>y;
    if(com == 0) {
      tree.unite(x,y);
    }
    else if (com == 1) {
      ans.push_back(tree.same(x,y));
    }

  }

  for (auto && a : ans) {
    cout << a << endl;
  }
}



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

int main(){
  int D, G;
  cin >> D >> G;
  int problem_count[11];
  int bonus[11];
  int ans = 1e9;
  for(int i=0;i<D;i++){
    cin >> problem_count[i] >> bonus[i];
  }
  
  for(int i=0;i<(1<<D);i++){
    int prob_num = 0;
    int score = 0;
    int rest_max = -1;
    for(int j=0;j<D;j++){
      if((1 & i>>j) == 1){
        prob_num += problem_count[j];
        score += 100*(j+1)*problem_count[j] + bonus[j];
      }else{
        rest_max = j;
      }
    }
    if(score < G){
      int s1 = 100 * (rest_max + 1);
      int need = (G - score + s1 -1) / s1;
      if(need >= problem_count[rest_max]){
        continue; // kokoyori sita wo kesu -> min(prob_num, ans) monai
      }
      prob_num += need;
    }
    ans = std::min(prob_num, ans);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t;
    n=3;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    cout<<arr[0]+arr[1];
}

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


typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)


char IO;
inline ll rd(){
	ll s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}


const int N=1e5+10;

int n,m,k;
int a[N],b[N],w[N];
ll dis[N];


int main(){
	n=rd(),m=rd(),k=rd();
	rep(i,1,m) a[i]=rd(),b[i]=rd(),w[i]=rd()-k;
	rep(i,2,n) dis[i]=-1e15;
	int cnt=0,f=1;
	do {
		f=0;
		rep(i,1,m) if(dis[a[i]]>-1e12&&dis[b[i]]<dis[a[i]]+w[i]) dis[b[i]]=dis[a[i]]+w[i],f=1;
		cnt++;
	} while(cnt<=n+2&&f);
	if(dis[n]<-1e9) return puts("-1"),0;
	ll t=dis[n];
	rep(t,1,n) rep(i,1,m) if(dis[a[i]]>-1e9&&dis[b[i]]<dis[a[i]]+w[i]) dis[b[i]]=dis[a[i]]+w[i],f=1;
	if(dis[n]>t) return puts("-1"),0;
	printf("%lld\n",max(0ll,dis[n]));
}




Measured memory_bytes: 384