akhauriyash/Code-Regression huggingface dataset:
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define trace(x) cerr << #x << " = " << x << endl
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define pi acos(-1)
#define en '\n'
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 3e3+123;
const ll MOD = 1e9+7;

template <class T> T power(T a,T b){a%=MOD;if(!a) return 0;T p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
template <class T> void print(vector<T> &v){for(T u:v){cout<<u<<" ";}cout<<endl;}
template <class T> T gcd(T a, T b){return (b!=0?gcd<T>(b,a%b):a);}
template <class T> T lcm(T a, T b){return (a/gcd<T>(a,b)*b);}

ll BS(ll l,ll r,ll a[],ll k){ll mid,i=-1;while(l<=r){mid=(l+r)>>1;if(a[mid]==k){return i=mid;/*r=mid-1;*/}if(a[mid]<k) l=mid+1;if(a[mid]>k) r=mid-1;}return i;}
ll dp[mx][mx];
ll LCS(ll i,ll j,string &s,string &w) // O(n^2)
{
    if(i==s.size() || j==w.size())  return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    ll ans = 0;
    if(s[i]==w[j]){
        ans = 1+LCS(i+1,j+1,s,w);
    }
    else
    {
        ll x = LCS(i+1,j,s,w);
        ll y = LCS(i,j+1,s,w);
        ans = max(x,y);
    }
    return dp[i][j] = ans;
}
void showLCS(string &s,string &w,ll len)
{
    ll i=0,j=0;
    string str;
    while(len>0)
    {
        if(s[i]==w[j])
        {
            str+=s[i];
            i++;
            j++;
            len--;
        }
        else if(dp[i+1][j]>dp[i][j+1])
            i++;
        else
            j++;
    }
    cout<<str<<endl;
}

ll lcs(string s,string w)
{
    int m = s.size();
    int n = w.size();
    for(int i=0;i<=m;i++)
        dp[i][n] = 0;
    for(int j=0;j<=n;j++)
        dp[m][j] = 0;
    for(int i=m-1;i>=0;i--){
        for(int j=n-1;j>=0;j--){
            if(s[i]==w[j])
                dp[i][j] = 1+dp[i+1][j+1];
            else
                dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
        }
    }
    return dp[0][0];
}
void showlcs(string s,string t)
{
    ll i = s.size()-1;
    ll j = t.size()-1;
    string str;
    while(i>=0 && j>=0)
    {
        if(s[i]==t[j]){
            str+=s[i];
            i--;  j--;
        }
        else if(dp[i-1][j] > dp[i][j-1] )
            i--;
        else
            j--;
    }
    reverse(all(str));
    cout<<str<<en;
}

int main()
{
    speed();
    ll a,i,j;
    string s,t;
    cin>>s>>t;

    mem(dp,-1);
    a = LCS(0,0,s,t);
    showLCS(s,t,a);

    /*
    cout<<lcs(s,t)<<en;
    a = lcs(s,t);
    showlcs(s,t);
    */

return 0;
}


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

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

void bfs(int now, int p, ll sum, vector<int> &ans,vector<vector<P>> &r){
    if(sum%2==0){
        ans[now] = 0;
    }else{
        ans[now] = 1;
    }

    if(r[now].size()==1&&r[now][0].first==p){
        return ;
    }else{
        for(int i = 0; i < r[now].size(); i++){
            if(r[now][i].first == p){
                continue;
            }else{
                bfs(r[now][i].first, now, sum + r[now][i].second, ans, r);
            }

        }
    }
    return ;

}


int main(){
    int n;
    cin >> n;
    vector<vector<P>> r(n);
    rep(i,n-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--;
        v--;
        r[u].push_back(P(v,w));
        r[v].push_back(P(u,w));
    }

    vector<int> ans(n);
    ans[0] = 0;
    bfs(0,-1,0,ans,r);

    rep(i,n){
        cout << ans[i] << endl;
    }


    return 0;
}  

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

using namespace std;
int n;
double solve(int i,int j,int k,vector<vector<vector<double> > >&dp){
   if(dp[i][j][k]!=-1.0)
      return dp[i][j][k];
   double ans=0;
   double e = 1.0*(n)/(1.0*(i+j+k));
   if(i){
      ans+=(solve(i-1,j,k,dp)+e)*((1.0*i)/(1.0*(i+j+k)));

   }
   if(j){
      ans+=(solve(i+1,j-1,k,dp)+e)*((1.0*j)/(1.0*(i+j+k)));

   }
   if(k){
      ans+=(solve(i,j+1,k-1,dp)+e)*((1.0*k)/(1.0*(i+j+k)));

   }
   dp[i][j][k]=ans;
   return ans;

}
int main()
{
   cin >>n;
   vector<vector<vector<double> > >dp;
   vector<vector<double> >temp(n+10,vector<double>(n+10,-1.0));
   for(int i=0;i<=n+9;++i)
    dp.push_back(temp);


 vector<int>s(4,0);
 int t;
 for(int i=0;i<n;++i){
   cin >>t;
   s[t]++;
 }
 dp[0][0][0]=0;
 double ans = solve(s[1],s[2],s[3],dp);
 cout << fixed<< setprecision(11) <<ans <<endl;
 return 0;

}

Measured memory_bytes: 241120
N = int(input())

#As = [int(elm) for elm in input().split(" ")]
As = []
minus_As = []
plus_As = []
minus_count = 0
plus_count = 0
for elm in input().split(" "):
    A = int(elm)
    if A >= 0:
        plus_As.append(A)
        plus_count += 1
    else:
        minus_As.append(A)
        minus_count += 1
    As.append(A)

cond1 = plus_count > 0
cond2 = minus_count > 0
# 両方
case1 = cond1 and cond2
# 全て非負の場合
case2 = cond1 and (not cond2)
# 全てマイナスの場合
case3 = (not cond1) and cond2

out_txts = []
if case1:
    max_val = max(plus_As)
    max_i = plus_As.index(max_val)

    mA = minus_As[0]
    for i, pA in enumerate(plus_As):
        if i == max_i:
            continue
        out_txts.append("%d %d" % (mA, pA))
        mA -= pA
    minus_As[0] = mA

    out = max_val
    for mA in minus_As:
        out_txt = "%d %d" % (out, mA)
        out_txts.append(out_txt)
        out -= mA
elif case2:
    max_val = max(plus_As)
    max_i = plus_As.index(max_val)
    del plus_As[max_i]

    min_val = min(plus_As)
    min_i = plus_As.index(min_val)
    del plus_As[min_i]

    minA = min_val
    for i, pA in enumerate(plus_As):
        #if i in [min_i, max_i]:
        #    continue
        out_txt = "%d %d" % (minA, pA)
        out_txts.append(out_txt)
        minA -= pA
    
    out_txt = "%d %d" % (max_val, minA)
    out_txts.append(out_txt)
    out = max_val - minA

else:
    max_val = max(minus_As)
    max_i = minus_As.index(max_val)
    del minus_As[max_i]

    out = max_val
    for i, mA in enumerate(minus_As):
        #if max_i == i:
        #    continue
        out_txt = "%d %d" % (out, mA)
        out_txts.append(out_txt)
        out -= mA

#print("case", case1, case2, case3)
print(out)
for out_txt in out_txts:
    print(out_txt)

Measured memory_bytes: 18056
from math import cos, sqrt, radians
A, B, H, M = map(int, input().split())
Md = M * 6
Hd = (H * 30) + ((M/60) * 30)
Cd = (Hd - Md)
As = A ** 2
Bs = B ** 2
D = 2 * A * B
X = sqrt(As + Bs - (D * cos(radians(Cd))))
print(X)

Measured memory_bytes: 9512
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from heapq import heapify,heappop,heappush
    n,m=map(int,input().split())
    A=[-a for a in map(int,input().split())]
    heapify(A)
    for _ in range(m):
        x=-heappop(A)
        heappush(A,-(x//2))
    print(-sum(A))
resolve()

Measured memory_bytes: 68352
#include<cstdio>
#include<algorithm>
const int N = 2e5+5;
struct Element{
    int value;
    int pre, next;
    Element():value(-1), pre(-1), next(-1){}
};
int a[N], f[N];
Element c[N];
Element d[N];

/*void delete(int u){
    int l = d[u].pre;
    int r = d[u].next;
    if(l!=-1) d[l].next = r;
    if(r!=-1) d[r].pre = l;    
}*/

int judge(long long u,long long k,int n){
    for(int i = n; i >= 1; i--){
        long long v = f[i];
        long long need = u/v;
        int j = n-i+1;
        if(need>=a[j]) continue;
        else {
            long long minus = a[j]-need;
            if(k<minus) return 0;
            else {
                k -= minus;
                continue;
            }
        }
    }
    return 1;
}

int main(){
    int n; long long k;
    scanf("%d%lld",&n,&k);
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);   
    for(int i = 1; i <= n; i++) scanf("%d",&f[i]);
    std::sort(a+1,a+1+n);
    std::sort(f+1,f+1+n);
    long long l = 0, r = 1e12+5;
    long long ans = -1;
    while(l<=r){
        long long m = (l+r)/2;
        if(judge(m,k,n)){
            ans = m;
            r = m-1;
        }
        else l = m+1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h> // {{{
// clang-format off
#pragma GCC optimize "O3,omit-frame-pointer,inline"
#pragma GCC target "tune=native"
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template<typename T>inline
#define USE2(T, U) template<typename T,typename U>inline
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

template<typename T>using duo=std::pair<T,T>;
template<typename T>using vec=std::vector<T>;
using ll=long long;
using pii=duo<int>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T=int)vec<T>in(int n,T a){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>()+a);return v;}
USE1(T)vec<std::pair<T,int>>enume(const vec<T>&x,int s=0){int N=x.size();vec<std::pair<T,int>>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() { //
  int N = in();
  auto A = in(N);
  int ans = inf;
  rep(i, -100, 101) {
    int cost = 0;
    for (int a : A) {
      cost += (a - i) * (a - i);
    }
    chmin(ans, cost);
  }
  pr(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const long long INFTY = long(1) << 60;

int main()
{
    long long N, a, b;
    cin >> N;

    for(a=1;a*a<=N;++a){    
    }

    long long ans = INFTY;
    for(int i=1;i<=a;++i){
        if(N % i != 0) continue;
        b = N / i;
        ans = ans > i + b - 2 ? i + b - 2 : ans;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
 
  int n,i,j;
  int count;
  while(1) {
    scanf("%d",&n);
 
    if(n == 0) break;
    count = 0;
    for(i=n+1;i<=2*n;i++) {
 
      for(j=2;j*j<=i;j++) {
    if(i % j ==0) break;
      }
 
      if(j*j >i) count++;
 
    }
 
    printf("%d\n",count);
 
 
  }
  return 0;
 
}

Measured memory_bytes: 600
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int k; cin >> k;
	int x; cin >> x;
	set<int> ans;
	int st = (x - k) + 1;
	int ed = x;
	rep (i, k) {
		for (int j = st; j <= ed; ++j) {
			ans.insert(j);
		}
		st++;
		ed++;
	}
	for (auto itr = ans.begin(); itr != ans.end(); ++itr) {
		cout << *itr << " "; 
	}
	cout << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    vector<vector<ll>> cnt(n,vector<ll>(26,0));
    string s;
    rep(i,n){
        cin>>s;
        rep(j,s.size()) cnt[i][s[j]-'a']++;
    }
    vector<ll> mincnt(26,0);
    rep(i,26){
        ll mn=50;
        rep(j,n){
            mn=min(mn,cnt[j][i]);
        }
        mincnt[i]=mn;
    }
    string ans="";
    rep(i,26){
        rep(j,mincnt[i]){
            ans.push_back('a'+i);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	int count = 0;
	for (int i = 0; i < h*w; i++) {
		char c;
		cin >> c;
		if (c == '#')count++;
	}
	cout << (count == h + w - 1 ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int n, y;
	scanf("%d %d", &n, &y);
	int s = 0;
	int flag = 0;
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= n; j++) {
			s = i * 10000 + j * 5000;
			if(i + j <= n && s + (n - i - j) * 1000 == y) {
				flag = 1;
				printf("%d %d %d\n", i, j, n - i - j);
				return 0;
			}
		}
	}
	if(flag == 0) printf("-1 -1 -1\n");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  
  int N; cin >> N;
  double xa, ya, xb, yb, ra, rb;
  while(N--) {
    cin >> xa >> ya >> ra;
    cin >> xb >> yb >> rb;
    double dist2 = pow(xb-xa, 2) + pow(yb-ya, 2);
    
    if(dist2 < pow(ra-rb, 2) && rb < ra) {
      cout << 2 << endl;
    }
    else if(dist2 < pow(ra-rb, 2) && ra < rb) {
      cout << -2 << endl;
    }
    else if(pow(ra+rb, 2) < dist2) {
      cout << 0 << endl;
    }
    else {
      cout << 1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
ll max(ll a,ll b){return a>b?a:b;}
int main() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{

  int num,i;

  int dig;

  int sum = 0;

  scanf("%d", &num);
  i = num;

  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  if(i%sum == 0){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define endl "\n";
#define ll long long 
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define satyam ios_base::sync_with_stdio(false);
#define mishra cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
	satyam mishra
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
	   int n,k;cin>>n>>k;
	   int h[n];
	   for(int i=0;i<n;i++)
	   {
	   	  cin>>h[i];
	   }
	   int arr[k+1][n];
	   for(int i=1;i<=k;i++)
	   {
	   	  arr[i][0]=0;
	   }
	   for(int i=1;i<=k;i++)
	   {
	   	for(int j=1;j<n;j++)
	   	{
	   		if(i==1)
	   		{
	   			arr[i][j]=arr[i][j-1]+abs(h[j]-h[j-1]);
	   		}
	   		else
	   		{
	   			if(i>j)
	   				arr[i][j]=arr[i-1][j];
	   			else
	   			{
	   				  int kk=i;
                      int mini=INT_MAX;
                      int jj=j;
                      while(kk--)
                      {
                      	if(arr[i][jj-i]+abs(h[j]-h[jj-i])<mini)
                      	{
                      		mini=arr[i][jj-i]+abs(h[j]-h[jj-i]);
                      	}
                      	jj++;
                      }
	   			     arr[i][j]=min(arr[i-1][j],mini);
	   			}
	   		}
	   		//cout<<arr[i][j]<<" ";
	   	}
	  // 	cout<<endl;
	   }
	   cout<<arr[k][n-1];
	}
}

Measured memory_bytes: 39680
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static int Main(string[] args) {
        string low = "abcdefghijklmnopqrstuvwxyz";
        string up =  "ABCDEFGHIJKLMNOPQRSTUVWXYZ";


        string v = Console.ReadLine();
        for (int i = 0; i < v.Length; i++) {
            string c = v.Substring(i, 1);

            if (low.Contains(c) == true) {
                Console.Write(c.ToUpper());
            }
            else if (up.Contains(c) == true) {
                Console.Write(c.ToLower());
            }
            else {
                Console.Write(c);
            }
        }
        Console.WriteLine(string.Empty);

        return 0;
    }
}



Measured memory_bytes: 15884
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#define PI acos(-1.0)
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(n + 1);
	for(int i = 1; i <= n; i++) cin >> a[i];
	vector<int> dp(n + 1,0);
	a[0] = a[1];
	for(int i = 2;i <= n;i++){
		dp[i] = min(dp[i-1]+fabs(a[i] - a[i - 1]),dp[i-2] + fabs(a[i] - a[i - 2]));
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 3956
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

map<char, int> cnt;

int main(){
	FIO
	
	double x1, y1, x2, y2;cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << setprecision(8) << hypot(x1 - x2, y1 - y2) << '\n';
	return 0;
}



Measured memory_bytes: 3340
#include <stdio.h>
#include <string.h>
int main()
{
  char n[102];
  scanf("%s", n);
  int k;
  scanf("%d", &k);
  int m = strlen(n);
  int ans;
  int i;
  int a, b;
  if (k == 1)
    ans = 9 * (m - 1) + (int)(n[0] - '0');

  else if (k == 2)
  {
    a = -1;
    for (i = 1; i < m; i++)
    {
      if (n[i] > '0')
      {
        a = i;
        break;
      }
    }
    ans = 81 * (m - 1) * (m - 2) / 2;
    ans += 9 * (m - 1) * (n[0] - '1');
    if (a > 0)
    {
      ans += n[a] - '0';
      ans += 9 * (m - a - 1);
    }
  }
  else
  {
    a = b = -1;
    for (i = 1; i < m; i++)
    {
      if (n[i] > '0')
      {
        if (a < 0)
          a = i;
        else if (b < 0)
          b = i;
      }
    }
    ans = 729 * (m - 1) * (m - 2) * (m - 3) / 6;
    ans += 81 * (m - 1) * (m - 2) / 2 * (n[0] - '1');
    if (a > 0)
    {
      ans += (n[a] - '1') * 9 * (m - a - 1);
      ans += 81 * (m - a - 1) * (m - a - 2) / 2;
      if (b > 0)
      {
        ans += n[b] - '0';
        ans += 9 * (m - b - 1);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i < x; ++i) {
		cout << i << " ";
	}
	for (int i = x; i <= k + x - 1; ++i) {
		cout << i << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdint>
#include <cstdlib>

std::int_fast32_t check_seat(const std::int_fast32_t i) {
  static std::int_fast32_t left_query_count = 20;
  if (left_query_count <= 0) std::exit(EXIT_FAILURE);

  std::cout << i << std::endl;
  std::string s;
  std::cin >> s;
  --left_query_count;

  if (s == "Male") return 0;
  else if (s == "Female") return 1;
  else if (s == "Vacant") std::exit(0);
  else std::exit(EXIT_FAILURE);
}

int main() {
  std::int_fast32_t n;
  std::cin >> n;

  std::int_fast32_t start = 0, end = n;
  std::int_fast32_t start_mf = check_seat(start);

  while (true) {
    const std::int_fast32_t distance = (end - start) / 2;
    const std::int_fast32_t center = start + distance;
    const std::int_fast32_t center_mf = check_seat(center);
    if ((distance % 2 == 0 && start_mf != center_mf) || (distance % 2 == 1 && start_mf == center_mf)) {
      // If any vacant seats do not exist in (start, center), the above condition cannot be satisfied.
      // Therefore, at least one vacant seats exist in (start, center).

      end = center;
    } else if ((distance % 2 == 0 && start_mf == center_mf) || (distance % 2 == 1 && start_mf != center_mf)) {
      // If any vacant seats do not exist in (center, end), the above condition cannot be satisfied.
      // Therefore, at least one vacant seats exist in (center, end).

      start = center;
      start_mf = center_mf;
    }
  }

  return EXIT_FAILURE;
}

Measured memory_bytes: 852
n = gets.to_i
S = gets.split.map(&:to_i).sort!
q = gets.to_i
T = gets.split.map(&:to_i).sort!

def binary_search(s, t)
  left, right = 0, s.size
  while left < right
    mid = (left + right) / 2
    if s[mid] == t
      return 1
    elsif s[mid] > t
      right = mid
    else
      left = mid + 1
    end
  end
  return 0
end

ans = 0
T.each{ | t | ans += binary_search(S, t) }
puts ans


Measured memory_bytes: 15788
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
 
#define rep(i,x) for(int i=0;i<x;++i)
 
struct edge{
    int from, to, cost;
    edge(int from, int to, int cost) : from(from), to(to), cost(cost) {};
};
 
vector<edge> edges;
 
const int MAX_N = 100000;
 
int N, M;
int dist[MAX_N];
 
bool bf(int s)
{
    rep(i, N) dist[i] = LLONG_MAX / 2;
    dist[s] = 0;
 
    rep(i, N) {
        for (edge& e : edges) {
            if (dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                if (i == N - 1 && e.to == N - 1) {
                    return true;
                }
            }
        }
    }
    
    return false;
}
 
signed main()
{
    cin >> N >> M;
 
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        edges.emplace_back(edge(a, b, -c));
    }
 
    if (bf(0)) {
        cout << "inf" << endl;
        return 0;
    }
 
    cout << -dist[N - 1] << endl;
}
 
 
 
 
 
 
 

Measured memory_bytes: 384
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
int n;

void test(int depth,double x1,double y1,double x2,double y2){
    double sin60=sqrt(3.0)/2.0;
    double cos60=0.5;

    double sx=(x1+x1+x2)/3.0;
    double sy=(y1+y1+y2)/3.0;
    double tx=(x1+x2+x2)/3.0;
    double ty=(y1+y2+y2)/3.0;

    double vx = tx-sx;
    double vy = ty-sy;
    double ux = sx + cos60*vx - sin60*vy;
    double uy = sy + sin60*vx + cos60*vy;

    if(depth>=n)return;

    test(depth+1,x1,y1,sx,sy); //depth++では実行できない
    printf("%.8f %.8f\n",sx,sy);
    test(depth+1,sx,sy,ux,uy);
    printf("%.8f %.8f\n",ux,uy); //depth++では実行できない
    test(depth+1,ux,uy,tx,ty);
    printf("%.8f %.8f\n",tx,ty); //depth++では実行できない
    test(depth+1,tx,ty,x2,y2);

}
int main(){
    cin>>n;
    printf("%.8f %.8f\n",0.0,0.0);
    test(0,0.0,0.0,100.0,0.0);
    printf("%.8f %.8f\n",100.0,0.0);

    return 0;
}


Measured memory_bytes: 3224
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

//わけわかめ
int P[100001];
bool dame[100001];
int Find(int A) {
	if (P[A] < 0) return A << 1;
	return P[A] = Find(P[A] >> 1) ^ (P[A] & 1);
}

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


	int N = getint(), M = getint();
	rep1(i, N) P[i] = -1;
	rep(i, M) {
		int a = Find(getint());
		int b = Find(getint());

		if (a >> 1 == b >> 1) {
			if (!((a ^ b) & 1)) dame[a >> 1] = true;
			continue;
		}

		if (P[a >> 1] > P[b >> 1]) swap(a, b);
		P[a >> 1] += P[b >> 1];
		dame[a >> 1] |= dame[b >> 1];
		P[b >> 1] = a ^ !(b & 1);
	}

	ll x = 0, y = 0, z = 0;
	rep1(i, N) {
		if (Find(i) >> 1 == i) {
			if (-P[i] > 1) {
				if (dame[i]) y++;
				else x++;
			}
			else z++;
		}
	}
	printf("%lld\n", x * x + (x + y) * (x + y) + 2 * N * z - z * z);

	Would you please return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <iostream>
#include <deque>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
string nodetype[3]={"root", "internal node", "leaf"};

struct tree{
	int parent, child, next;
};

int split(deque <int> &tokens,  string &text, char delim=' '){
	int start = 0, end = 0;
	string tmps;
	char *ends;
	tokens.clear();
	for (int i=0; i<(int)text.size(); i++)
		if (text[i] == delim){
		end = i;
		tmps = text.substr(start, end - start);
		tokens.push_back(strtol(tmps.c_str(),&ends,0));
		start = end + 1;
	}
	tmps = text.substr(start);
	tokens.push_back(strtol(tmps.c_str(),&ends,0));
	return 0;
}

int type(tree &node){
	int e;
	if (node.parent == -1) e = 0;
	else if (node.child == -1) e = 2;
	else e = 1;
	return e;
}

int depth(int e, vector <tree> &node){
	int tmp=node[e].parent, d;

	if (tmp == -1) d = 0;
	else d = depth(tmp, node) + 1;

	return d;
}

string children(int i, vector <tree> &node){
	stringstream ss;

	string str = "[";	
	int e = node[i].child;
	while (e!=-1){
		ss << e;
		if (str=="[") str +=  ss.str();
		else str += ", " + ss.str();
		ss.str("");
		e = node[e].next;
	}
	str += "]";

	return str;
}

int main(void){
	int n, e, tmp;
	string text;
	deque <int> buf;
	stringstream ss;

	cin >> n;
	getline(cin, text);
	vector <tree> node(n);

	for (int i=0; i<n; i++){
		node[i].parent = -1;
		node[i].child = -1;
		node[i].next = -1;
	}

	for (int i=0; i<n; i++){
		getline(cin, text);
		split(buf, text);

		e = buf[0];
		buf.pop_front();

		int nc= buf[0];
		buf.pop_front();

		if (nc != 0){
			for (int j=0; j<nc; j++){
				tmp = buf[j];
				if (j==0) node[e].child = tmp;
				else node[buf[j-1]].next = tmp;
				node[tmp].parent = e;
				}
		}
		buf.clear();
	}

	for (int i = 0; i<n; i++){
		ss.str("");
		ss << "node " << i <<": ";
		ss << "parent = " << node[i].parent << ", ";
		ss << "depth = " << depth(i, node) << ", ";
		e = type(node[i]);
		ss << nodetype[e] << ", ";
		ss << children(i, node);
		cout << ss.str() << endl;
	}

	return 0;
}

Measured memory_bytes: 5192
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<ll, ll> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("commandos.in", "r", stdin);*/
#endif
}
void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
	//File();
}
const double pi = acos(-1.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 1, 0, -1, 1, -1, -1, 1 };

ll dp[nn][4], n;
vector < pair<int, pair<int, int> > > arr;
ll solve(int idx, int cur)
{
	if (idx >= n)
		return 0;
	ll &ret = dp[idx][cur];
	if (~ret)
		return ret;
	if (cur == 3)
		ret = max({ ret, solve(idx + 1, 2) + arr[idx].second.second,
		solve(idx + 1, 1) + arr[idx].second.first,
		solve(idx + 1, 0) + arr[idx].first });
	if (cur == 2)
		ret = max({ ret, solve(idx + 1, 0) + arr[idx].first,
		solve(idx + 1, 1) + arr[idx].second.first });
	if (cur == 0)
		ret = max({ ret, solve(idx + 1, 1) + arr[idx].second.first,
		solve(idx + 1, 2) + arr[idx].second.second });
	if (cur == 1)
		ret = max({ret, solve(idx + 1, 2) + arr[idx].second.second,
		solve(idx + 1, 0) + arr[idx].first});
	return ret;
}
int main()
{
	fast();
	cin >> n;
	memset(dp, -1, sizeof dp);
	arr.resize(n + 1);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i].first >> arr[i].second.first >> arr[i].second.second;
	}
	cout << solve(0, 3) << endl;
	return 0;
}

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

bool isRight(char c){
    // string left  = "qwertasdfgzxcvb";
    string right = "yuiophjklnm";
    for(int i=0;i<int(right.size());i++){
        if(right[i] == c){
            return true;
        }
    }

    return false;
}

int main(){

    while(true){
        string s;
        cin >> s;
        if(s == "#"){
            break;
        }

        int count = 0;

        if(s.size() == 0){
            cout << 0 << endl;
            continue;
        }

        bool nowRight = isRight(s[0]);

        for(int i=0;i<int(s.size());i++){
            if((isRight(s[i]) && !nowRight) || (!isRight(s[i]) && nowRight)){
                count++;
            }
            nowRight = isRight(s[i]);
        }

        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  ll n;
  cin >> n;
  vector <ll> a;
  REP(i,n){
    ll b;
    cin >> b;
    a.pb(b);
  }
  sort(a.begin(),a.end());
  ll r[n] = {0};
  r[0] = a[0];
  for(int i = 1;i < n;i++){
    r[i] = r[i-1]+a[i];
  }
  ll p = -1;
  
  REP(i,n-1){
    if(2*r[i] < a[i+1])
      p = i;
  }
  
  if(p != -1){
    cout << n-p-1 << endl;
  }
  else 
    cout << n << endl;
  return 0;
}


Measured memory_bytes: 1908
#include<bits/stdc++.h>
 
typedef long long int ll;
 
using namespace std;
 
#define MOD (ll)1000000007
 
ll arr[1000000];
 
ll func(int p)
{
	ll ans = 1;
	if(p == 0) return 1;
	for(int i = 1; i <= p; i++)
	{
		ans = ((ans%MOD) * (2%MOD))%MOD;
	}
	return ans;
} 
 
int main(){
 
    ll n;
    cin >> n;
    for(ll i = 0; i < n; i++){
        cin >> arr[i];
    }
    ll sum = 0;
    for(ll i = 0; i < 64; i++){
        ll oc = 0, zc = 0;
        for(ll j = 0; j < n; j++){
            if(arr[j]%2 == 0){
                zc++;
            }
            else{
                oc++;
            }
            arr[j] /= 2;
        }
        ll idsum = ((zc%MOD)*(oc%MOD))%MOD;
        idsum  = ((idsum%MOD) * (func(i)%MOD))%MOD;
        sum = ((sum%MOD) + (idsum%MOD))%MOD;
    }
    cout << sum;
}

Measured memory_bytes: 4352
INF = 10 ** 20

def search(rest, now, goal, dp, edges):
  if now == goal:
    return 0
  if rest == ():
    return INF

  if (rest, now) in dp:
    return dp[(rest, now)]

  ret = INF
  for i, t in enumerate(rest):
    for dist, to in edges[now]:
      tmp = search(tuple(v for j, v in enumerate(rest) if i != j), to, goal, dp, edges) + dist / t
      if ret > tmp:
        ret = tmp
  dp[(rest, now)] = ret
  return ret

def main():
  while True:
    n, m, p, a, b = map(int, input().split())
    if n == 0:
      break
    a -= 1
    b -= 1
    tlst = list(map(int, input().split()))
    edges = [[] for _ in range(m)]
    for _ in range(p):
      x, y, z = map(int, input().split())
      x -= 1
      y -= 1
      edges[x].append((z, y))
      edges[y].append((z, x))
    tlst.sort()
    rest = tuple(tlst)
    dp = {}
    ans = search(rest, a, b, dp, edges)
    if ans == INF:
      print("Impossible")
    else:
      print(ans)
main()   


Measured memory_bytes: 7508
x,n=map(int, input().split())
if n == 0:
  print(x)
  exit()
p=list(map(int, input().split()))
all=set(range(0,102))
s_p=set(p)
kouho=sorted(all-s_p)

min_dis=201
for i in kouho:
  dis=abs(i-x)
  if min_dis > dis:
    min_i=i
    min_dis=dis
print(min_i)


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

int main() {
  int N;
  cin >> N;
  vector<string> blue(N);
  for (int i=0; i<N; i++){
    cin >> blue.at(i);
  }
  int M;
  cin >> M;
  vector<string> red(M);
  for (int i=0; i<M; i++){
    cin >> red.at(i);
  }
  int money =0;
  int n=0;
  for (int j=0; j<N; j++){
    int count =0;
    blue.at(0) = blue.at(n);
    for(int m=0; m<N; m++){
      if (blue.at(0) == blue.at(m)){
        count++;
        continue;
      }
      else
        continue;
    }
    for (int l=0; l<M; l++){
      if (blue.at(0) == red.at(l)){
        count--;
        continue;
      }
      else
        continue;
    }
    n++;
    if ((count > money)&&(n ==1)){
      money = count;
      continue;
    }
    else if((count > money)&&(n != 1)){
      money = count -1;
      continue;
    }
    else
      continue;
  }
  cout << money << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<ctime>
#include<climits>
#include<queue>
#include<fstream>
#include<deque>
#include<iomanip>
#include<list>
#include<sstream>
#include<string>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-10
#define F first
#define S second
#define all(n) n.begin(),n.end()
#define pb push_back
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define INF (1<<27)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
int N,M,r,q;
vector<P> info[10001];
//map<int,bool> Index;

int main(){

  while(true){
    cin >> N >> M;
    if(N+M == 0)break;
    rep(i,10000)
      info[i].clear();
    //Index.clear();
    stack<char> staq[M+1];

    cin >> r;
    rep(i,r){
      int t,n,m,s;
      cin >> t >> n >> m >> s;
      if(s == 1){
	if(staq[m].empty()){
	  info[m].pb(P(t,-1));
	  //Index[m] = true;
	 
	}
	staq[m].push('a');
      }
      else{
	//if(index[m]){
	assert(info[m].size()-1 >= 0);
	info[m][info[m].size()-1].S = max(info[m][info[m].size()-1].S,t);
	staq[m].pop();
	//Index[m] = false;
	//}
      }
    }
    //cout << "deg --------" << endl;

    //rep(i,M){
    //cout << "strudent is " << i+1 << endl;
    //rep(j,info[i+1].size()){
    //cout << info[i+1][j].F << " "  << info[i+1][j].S << endl;
    //}
    //}
    //cout << "M = " << M << endl;
    cin >> q;
    rep(i,q){
      int ts,te,m,total;
      cin >> ts >> te >> m;
      total = 0;
      //assert(!Index[m]);
      assert(staq[m].empty());
      //cout << "info[" << i << "].size = " << info[m].size() << endl;
      rep(j,info[m].size()){

	if(ts <= info[m][j].F && info[m][j].S <= te){
	  total += info[m][j].S - info[m][j].F;
	}
	else if(info[m][j].F <= ts && te <= info[m][j].S ){
	  total += te - ts;
	}
	else if(info[m][j].F <= ts && ts <= info[m][j].S && info[m][j].S <= te){
	  total += info[m][j].S - ts;
	}
	else if(ts <= info[m][j].F && info[m][j].F <= te && te <= info[m][j].S){
	  total += te - info[m][j].F;
	}
	else if((te < info[m][j].F) || (ts > info[m][j].S)){
	  //  cout << "MISS!" << endl;
	}
	else assert(false);
      }

      cout << total << endl;
    }


  }

return 0;
}

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

using namespace std;

int main(void){

  int N;
  cin >> N;

  int l, r;
  int answer = 0;
  for(int i = 0; i < N; ++i){
    cin >> l >> r;
    answer += r - l + 1;
  }
  
  cout << answer << endl;
  
  return 0;
}


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define test ll t; cin>>t; while(t--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
#define max 1000005
bool prime[max];
/*ull sieve()
{
	memset(prime,true,sizeof(prime));
	for(ull p=2;p*p<max;p++)
	{
		if(prime[p]==true){
			for(ull i=2*p;i<max;i+=p)
			{
				prime[i]=false;
			}
		}
	}
	prime[0]=0;
	prime[1]=0;
}*/
using namespace std;
signed main()
{
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0 && i%5==0 )
			continue;
		else if(i%3==0 && i%5!=0)
			continue;
		else if(i%3!=0 && i%5==0)
			continue;
		sum+=i;
	}
	cout<<sum<<endl;
}













Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
//#include <fstream>

using namespace std;

typedef pair<int, int> P;

const int M = 100000;

int prim (vector <vector <int> > t )
{
	int size = t.size();
	vector <int> cost (size, M ); 
	vector <bool> visit (size, false );
	vector <int> path (size, -1 );

	cost[0] = 0;
	int mincost = M;
	int i,p;

	do{
		mincost = M;
		for (i = 0; i < size; ++i){
			if (!visit[i] && mincost > cost[i] ){
				mincost = cost[i];
				p = i;
			} // end if
		} // end for

		visit[p] = true;
		
		for (i = 0; i < size; ++i){
		// m[huÉ×ÚµÄ¢ém[hÅ
		// Ü¾ÜÜêÄ¢È¢m[hÌRXgÌXV
			if (!visit[i] && t[p][i] < cost[i] ){
				cost[i] = t[p][i];
				path[i] = p;
			} // end if
		} // end for

	}while ((int)count (visit.begin(), visit.end(), true ) != size );

	set <P> bridge;

	for (i = size - 1; i > 0; --i){
		int n = i;
		while (n != -1){
			P b(i, path[i] );
			bridge.insert (b );
			n = path[n];
		} // end while
	} // end for

	int res = 0;
	set <P>::iterator it = bridge.begin();
	for (; it != bridge.end(); ++it){
		res += t[(*it).first][(*it).second];		
	} // end for

	return res;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.stellar", "r", stdin );

	string str = "";
	int n, m;

	while (getline (cin, str ) ){
		stringstream ssn(str);
		ssn >> n >> m;
		
		if (!n && !m ){
			break;
		} // end if

		vector <vector <int> > t (n, vector <int> (n, M ) );
 	
		for (int i = 0; i < m; ++i){
			int from, to, cost;
			getline (cin, str );
			stringstream ss(str);
			ss >> from >> to >> cost;
			t[from][to] = cost;
			t[to][from] = cost;
		} // end for
		
		int res = prim (t );
		cout << res << endl;	

	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //gp_hash_table

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back

ll choose2(ll x) { return (x * (x - 1)) / 2; }

ll n, m;

void solve() {
    cin >> n >> m;
    ll res = choose2(n) + choose2(m);
	cout << res << "\n";
}

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

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

int main()
{
    int a,b;cin>>a>>b;
    int t1,t2,f1,f2;
    t1=(int)(a/0.08+0.9);t2=(int)((b+0.99)/0.1);
    f1=(int)((a+0.99)/0.08);f2=(int)(b/0.1+0.9);
    if(t2>=t1&&f1>=f2) cout<<max(t1,f2)<<endl;
    else
    {
        cout<<"-1"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main (void) {
    char s[10];
    scanf("%s", s);

    int cnt = 0;

    for ( int i = 0; i < 4; i++ ) {
        for ( int j = i + 1; j < 4; j++ ) {
            if ( s[i] == s[j] ) cnt++;
        }
    }

    if ( cnt == 2 ) printf("Yes");
    else {
        printf("No");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define rep(i,m,n) for(int i=m;i<n;i++)
#define repr(i,n,m) for(int i=n;i>=m ;i--)
#define mod 1000000007
#define float long double
#define pb push_back
#define mp make_pair
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
using namespace std;
bool sortbysec(const pair<int,int> &a,
             const pair<int,int> &b)
{
   return (a.second < b.second);
}

bool sortinrev(const pair<int,int> &a,  
              const pair<int,int> &b)
{
      return (a.first > b.first);
}
void solve()
{
	int n,m;
	cin>>n>>m;
	int x=n%m;
	int y=abs(x-m);
	cout<<min(x,y);
}
signed main()
{
     // #ifndef ONLINE_JUDGE
     //    freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
     //     #endif 	
  int t=1;
  //cin>>t;
  while(t--){
  solve(); 
  cout<<"\n";
}
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
 return 0;
}  


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

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(NULL);
#define endl            "\n"
#define NUM             100005
typedef long long ll;

int a[NUM],dp[NUM],t;

int solve()
{
    dp[1] = abs(a[0]-a[1]);

    for(ll i=2;i<t;i++)
    {
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
        //cout<<dp[i]<<endl;
    }

    return dp[t-1];
}
int main()
{
    FastRead

    cin>>t;

    for(ll i=0; i<t; i++)
    {
        cin>>a[i];
    }

    cout<< solve();

}


Measured memory_bytes: 1024
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>	
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>	
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <cstdio>
#include <memory.h>

using namespace std;

int main(void)
{
	int n;
	long long c, a, b;
	vector <pair<long long int, long long int>> v;
	long long int A[100001] = { 0, };
	long long int B[100001] = { 0, };
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n >> c;

	for (int i = 0; i<n; i++)
	{
		cin >> a >> b;
		v.push_back(make_pair(a, b));
	}

	long long int res = 0;
	long long int sum = 0;

	for (int i = 0; i < n; i++)
	{
		sum += v[i].second;
		if (i == 0)
		{
			B[i] = sum - v[i].first;
		}
		else
		{
			B[i] = max(B[i - 1], sum - v[i].first);
		}
	}

	sum = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		sum += v[i].second;
		if (i == n - 1)
		{
			A[i] = sum - (c - v[i].first);
		}
		else
		{
			A[i] = max(A[i + 1], sum - (c - v[i].first));
		}
	}


	for (int i = 0; i<n; i++)
	{
		res = max(res, B[i]);
		if (i != n - 1)
		{
			res = max(res, B[i] - v[i].first + A[i + 1]);
		}
	}

	for (int i = n - 1; i >= 0; i--)
	{
		res = max(res, A[i]);
		if (i != 0)
		{
			res = max(res, A[i] - (c - v[i].first) + B[i - 1]);
		}
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl;
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
#define FOR(i, n) for(ll i = 0; i < n; i++)
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);    
    cin.tie(0);
    ll r;
    cin >> r;
    double ans = 2 * 3.1415926 * r;
    cout << ans << "\n";
}

Measured memory_bytes: 3804
import sys
import itertools

def resolve():
    input = sys.stdin.readline
    N=int(input().rstrip())
    P=list(map(int,input().rstrip().split()))
    Q=list(map(int,input().rstrip().split()))

    
    Num = list(itertools.permutations(range(1,N+1,1), N)) #順列列挙 5P3
    c=len(Num)

    for i in range(c):
        for n in range(N):
            if Num[i][n]==P[n]:
                continue
            else:
                break
        else:
            intP=i+1
    
    for i in range(c):
        for n in range(N):
            if Num[i][n]==Q[n]:
                continue
            else:
                break
        else:
            intQ=i+1

    print(abs(intP-intQ))

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
1 3 2
3 1 2"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1"""
        output = """17517"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """3
1 2 3
1 2 3"""
        output = """0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 58476