akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define eb emplace_back

typedef unsigned long long ll;
typedef long double ld;

bool sorted(const vector<int> &nums, int id1, int id2) {
	int last = 0;
	for (int i=0; i<(int)nums.size(); i++) {
		if (nums[i] < last) {
			return false;
		}
		last = nums[i];
	}
	return true;
}
		

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<int> nums(n);
	
	for (int &e : nums) {
		cin >> e;
	}
	
	bool pos = false;
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			swap(nums[i], nums[j]);
			pos |= sorted(nums, i, j);
			swap(nums[i], nums[j]);
		}
	}
	
	if (pos) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
				
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        // ABC150A - 500 Yen Coins
 
        Scanner sc = new Scanner(System.in);
 
        int k = sc.nextInt();
        int x = sc.nextInt();

        System.out.println(k * 500 < x ? "No" : "Yes");
    }
}

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

signed main(){
	int n;cin>>n;
	vector<int>a(n);
	for(auto&& w:a)cin>>w;
	int sm=0;
	for(int i=0;i<n;i++){
		int x=a[i];
		int y=a[x-1];
		if(i==y-1)sm++;
	}
	cout<<sm/2<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#define  go return 0
#define pb push_back
#include<utility>
#include <algorithm>
#include<iterator>
typedef long long ll;
typedef double db;
#define lp1(i, n)  for(int i=1; i<=(int)(n); ++i)
#define lp2(i, n)  for(int i=0; i<(int)(n-1); ++i)
#define lp3(j, n)  for(int j=1; j<=(int)(n); ++j)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
typedef vector<int> vi;
const int N=1e5+5;
int CDG(int n)
{
    int count=0;
    while(n!=0)
    {
        n/=10;
        count++;
    }
    return count;
}
int arr[N];
int main(){

    int n,ans=0;
    cin>>n;
    lp1(i,n)
    {
        if(CDG(i)%2!=0)
            ans++;
    }
    cout<<ans;

go;
}


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

int main() {
	string s;
	cin >> s;
	set<char> t;
	for (auto c : s) {
		t.insert(c);
	}
	cout << (t.count('N') == t.count('S') && t.count('W') == t.count('E') ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
import copy
# In=[list(map(int,i.split())) for i in Input.split('\n')]
# N=In[0][0]
# A=In[1]
N=int(input())
A=list(map(int,input().split()))
counter=[0 for i in range(N+1)]
ans2=[0 for i in range(N+1)]
B=[]
for i in A:
    counter[i]+=1
ans=[0 for i in range(N+1)]
for i,value in enumerate(counter):
    if value>0:
        ans[i]=(value*(value-1)//2)
        ans2[i]=((value-1)*(value-2)//2)
total=sum(ans)
for i in A:
    temp=total
    temp-=ans[i]
    temp+=ans2[i]
    print(temp)


Measured memory_bytes: 27036
N, K = map(int, input().split())
A = [[]]*K
d = [0]*K

for i in range(K):
    d[i] = int(input())
    A[i] = list(map(int, input().split()))

ans = [0]*N
for i in range(K):
    for j in A[i]:
        ans[j-1] += 1

print(ans.count(0))

Measured memory_bytes: 9092
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define LL long long
using namespace std;
const int maxn = 1e5+10;
const double pi=acos(-1.0);

LL read(){
	LL x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}
struct node{
    LL x,y;
    double ang;
    bool operator<(const node &a)const {return ang < a.ang;}
}a[maxn];

int main(){
    int n,i,p;
    LL sx=0,sy=0,ans=0;
    n=read();
    for(i=1;i<=n;i++){
		a[i].x=read();a[i].y=read();
		a[i].ang = atan2(a[i].y , a[i].x);
    }
	sort(a + 1 , a + n + 1);
    for(p=i=1;i<=n;i++){
        while(p < i + n && a[p].ang - a[i].ang < pi) sx += a[p].x , sy += a[p ++ ].y , ans = max(ans , sx * sx + sy * sy);
        sx -= a[i].x , sy -= a[i].y , ans = max(ans , sx * sx + sy * sy);;
        a[i + n].x = a[i].x , a[i + n].y = a[i].y , a[i + n].ang = a[i].ang + 2 * pi;
    }
    printf("%.11lf\n" ,sqrt(ans));
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
typedef double weight;
struct edge
{
	int to; weight cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
typedef vector<vector<edge>> Graph;
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

bool used[51][51][51][51];

int main()
{
	int h, w;
	while (cin >> w >> h, w)
	{
		vs fld1(h), fld2(h);
		REP(i, h) cin >> fld1[i] >> fld2[i];
		pii sa, sb, ga, gb;
		REP(i, h)REP(j, w)
		{
			if (fld1[i][j] == 'L') sa = pii(i, j);
			if (fld2[i][j] == 'R') sb = pii(i, j);
			if (fld1[i][j] == '%') ga = pii(i, j);
			if (fld2[i][j] == '%') gb = pii(i, j);
		}
		typedef pair<pii, pii> data;
//		set<data> st;
		queue<data> que;
		que.push(data(sa, sb));
		data goal = data(ga, gb);
		MS(used, false);
		while (que.size())
		{
			data tmp = que.front();
			que.pop();
			int lx = tmp.first.first, ly = tmp.first.second;
			int rx = tmp.second.first, ry = tmp.second.second;
			REP(i, 4)
			{
				int lnx = lx + dx[i], lny = ly + dy[i];
				int rnx = rx + dx[i], rny = ry - dy[i];
				if (!valid(lnx, lny, h, w) || fld1[lnx][lny]=='#')
				{
					lnx = lx, lny = ly;
				}				
				if (!valid(rnx, rny, h, w) || fld2[rnx][rny] == '#')
				{
					rnx = rx, rny = ry;
				}
				pii nl(lnx, lny), nr(rnx, rny);
				data next = data(nl, nr);
				if (next != goal && (nl == ga || nr == gb)) continue;
//				if (st.find(next) != st.end()) continue;
//				st.insert(next);
				if (used[lnx][lny][rnx][rny]) continue;
				used[lnx][lny][rnx][rny] = true;
				if (next == goal) goto end;
				que.push(next);
			}
		}
	end:;
//		if (st.find(goal) == st.end()) puts("No");
		if (used[ga.first][ga.second][gb.first][gb.second]) puts("Yes");
		else puts("No");
	}
	return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)

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

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    int n; cin >> n;
    vector<int> a(n); rep(i, n) cin >> a[i];
    ll ans = a[0]-1;
    int num = 2;
    for (int i = 1; i < n; ++i) {
        int p = a[i] / num;
        int q = a[i] % num;
        if (a[i] == num) {
            num++;
        } else if (q > 0) {
            ans += p;
        } else {
            ans += p-1;
        }
    }

    cout << ans << endl;

    return 0;
}


    


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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back

using namespace std;

typedef long long ll;

const int N = 1e3 + 5;

ll a, b, cura = 1, curb = 1, cnt;

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a >> b;
		cnt = max((cura + a - 1) / a, (curb + b - 1) / b);
		cura = cnt * a;
		curb = cnt * b;
	}
	cout << cura + curb << endl;
	return 0;
}



Measured memory_bytes: 256
N,K=map(int,input().split())
a=[int(input()) for i in range(N)]

a.sort()
ans=100000000000000000000000

for j in range(N-K+1):
    if a[j+K-1]-a[j]<ans:
        ans=a[j+K-1]-a[j]


print(ans)


Measured memory_bytes: 13380
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N,ans=0;
  cin >> N;
  vector<ll> D(13,0);
  rep(i,N){
    ll d;
    cin >> d;
    D.at(d)++;
  }
  rep(i,13){
    if(i==0){
      if(D.at(i)>0){
        cout << 0 << endl;
        return 0;
      }
    }else if(i==12){
      if(D.at(i)>1){
        cout << 0 << endl;
        return 0;
      }
    }else{
      if(D.at(i)>2){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  for (int tmp = 0; tmp < (1 << 11); tmp++) {
    bitset<11> s(tmp);
    vector<ll> A(24,0);
    A.at(0)=1;
    rep(i,12){
      if(i<11){
        if(D.at(i+1)==2){
          A.at(i+1)=1;
          A.at(23-i)=1;
        }else if(D.at(i+1)==1){
          if(s.test(i)){
            A.at(i+1)=1;
          }else{
            A.at(23-i)=1;
          }
        }
      }else{
        if(D.at(i+1)==1){
          A.at(i+1)=1;
        }
      }
    }
    ll x=INF,t=1;
    rep(i,24){
      if(A.at((i+1)%24)==1){
        x=min(x,t);
        t=1;
      }else{
        t++;
      }
    }
    ans=max(x,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3552
#include "stdio.h"

int n;
int a[100];
long long int dp[101][21] = {};//i番目までの数を使ってjをつくるパターン数


int main(){

	scanf("%d",&n);

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

	dp[1][a[0]] = 1;

	for(int i=2;i<=n;i++){
		for(int j=0;j<=20;j++){
			if(j+a[i-1]<=20){
				dp[i][j+a[i-1]] += dp[i-1][j];
			}
			if(j-a[i-1]>=0){
				dp[i][j-a[i-1]] += dp[i-1][j];
			}
		}
	}

	printf("%lld\n",dp[n-1][a[n-1]]);


	return 0;
}

Measured memory_bytes: 1044
=begin
  1, print,reverse,replace それぞれメソッドを作る
=end

def pri(str, a, b)
  puts str[a..b]
end

def rev(str, a, b)
  x = str.slice!(a..b)
  str.insert(a, x.reverse)
  return str
end

def rep(str,a, b, p)
  str.slice!(a..b)
  str.insert(a,p)
  return str
end

s = gets.chomp
n = gets.to_i
n.times do
  input = gets.chomp.split
  if input[0] == "print"
    pri(s, input[1].to_i, input[2].to_i)
  elsif input[0] == "reverse"
    rev(s, input[1].to_i, input[2].to_i)
  else
    rep(s, input[1].to_i, input[2].to_i, input[3])
  end
end


Measured memory_bytes: 6928
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i) // マクロ
using namespace std;                          // stdの省略
using pii = pair<int, int>;                   // pairの略記
using ll = long long;                         // long longの略記

int main(void)
{

    string s, t;
    cin >> s;
    cin >> t;

    int ans = -1;
    rep(i, s.size()-t.size()+1) {
        int cnt = 0;
        rep(j, t.size()) {
            if (s[i+j]==t[j]) cnt++;
        }
        ans = max(ans, cnt);
    }

    cout << t.size() - ans << endl;

    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] a = new int[3];
		a[0] = sc.nextInt();
		a[1] = sc.nextInt();
		a[2] = sc.nextInt();
		
		Arrays.sort(a);
		
		int max = 10 * a[2] + a[1] + a[0];
		
		System.out.println(max);
		
	}
}


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

#define INF 1E18



int main(){
    ll n,k,q;
    cin>>n>>k>>q;
    vector<ll> a(q);
    rep(i,q) cin>>a[i];

    vector<ll> score(n,0);

    rep(i,q){
       score[a[i]-1]++; 
    }

    rep(i,n){
        if(k -q + score[i] > 0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 2176
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int[] fpoint=new int[n];
		int[] tage=new int[m];
		int[][] who=new int[m][n];
		for(int i=0;i<m;i++){
			 tage[i]=sc.nextInt();
		}
		for(int j=0;j<m;j++){
			for(int i=0;i<n;i++){
				who[j][i]=sc.nextInt();
			}
		}
		sc.close();
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(tage[i]==who[i][j]){
					fpoint[j]++;
				}else{
					fpoint[tage[i]-1]++;
				}

			}
		}

		for(int i=0;i<n;i++){
			System.out.printf("%d\n", fpoint[i]);
			//System.out.printf("%d\n", n);
			}
		}

}

Measured memory_bytes: 39420
#include <bits/stdc++.h>
using namespace std;
#define benfero freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define mm ' '
#define nl '\n'
#define MOD 100000007
#define N 100005
typedef long long int ll;
int n, m;
vector<int>v[N];
int dp[N];
int mx=0;
int dfs(int node){
    if(dp[node]){//cout<<"nu noddayım coktan gelmisim dncem"<<node<<mm<<dp[node]<<endl;
    return dp[node];}
    int i;
    dp[node]=1;
    if(v[node].empty()){//cout<<"bu noddayım bir doncem "<<node<<endl;
    return dp[node];}
    int maxx=0;
    for(i=0;i<v[node].size();i++){
        //cout<<"bundan buna gidiyom "<<node<<mm<<v[node][i]<<endl;
        maxx=max(maxx,dfs(v[node][i]));
    }
    dp[node]+=maxx;
    return dp[node];
}
int main()
{
    //benfero
    cin>>n>>m;
    int a, b;
    while(m--){
        cin>>a>>b;
        v[a].push_back(b);
    }
    int i;
    for(i=1;i<=n;i++){
        if(!dp[i]){
            //cout<<"bu noddan dfse giriyom "<<i<<endl;
            //cout<<"sonucu = "<<dfs(i)<<endl;
            mx=max(dfs(i),mx);
        }
    }
    cout<<mx-1<<endl;
    return 0;
}


Measured memory_bytes: 8192
import java.util.HashSet;
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
    Scanner s = new Scanner(System.in);
    int num = s.nextInt();
    int count = 0 ;
    HashSet<String> set = new HashSet<>();
    for(int i = 0 ;i < num ; i++){
        String str = s.next();
        if(!set.contains(str)){
            set.add(str);
            count++;
        }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 77040
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

int main(int argc, char const *argv[]){ 
    ThunderClap;
    ll t = 1;
    cin>>t;
    cout<<(!t)<<"\n";
    return 0;
}


Measured memory_bytes: 3604
while True:
    try:
        n,x = map(int,input().split())
        if n == x == 0:
            break
        else:
            ans = []
            for i in range(1,n+1):
                for j in range(1,n+1):
                    for k in range(1,n+1):
                        if i + j + k == x:
                            if i != j and i != k and j != k:
                                ans.append([i,j,k])
                            
            print(int(len(ans) / 6))
            
    except:
        break


Measured memory_bytes: 6224
#include <cstdio>
#include <cstring>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

const int mx = 200000 + 5;
int n, m;
map<int, int>dn;

int main(){
    dn.clear();
    scanf("%d", &n);
    for(int i = 0, x; i < n; ++i){
        scanf("%d", &x);
        ++dn[x];
    }
    scanf("%d", &m);
    char p = 1;
    for(int i = 0, x; i < m; ++i){
        scanf("%d", &x);
        if(!dn[x]){
            p = 0;
            break;
        }
        --dn[x];
    }
    if(p){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int>u(n),m(n),l(n);
    for(int i=0;i<n;i++)cin>>u[i];
    for(int i=0;i<n;i++)cin>>m[i];
    for(int i=0;i<n;i++)cin>>l[i];
    ll count=0;
    sort(u.begin(),u.end());
    sort(m.begin(),m.end());
    sort(l.begin(),l.end());
    for (int i = 0; i < n; ++i) {
        count+= (lower_bound(u.begin(), u.end(), m[i]) - u.begin()) * (l.end() - upper_bound(l.begin(), l.end(), m[i]));
    }
    cout<<count;
}


Measured memory_bytes: 1408
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;


int main(){
	int N;
	cin>>N;
	REP(T,N){
		string str;
		cin>>str;
		set<string>res;
		FOR(i,1,SZ(str)){
			string s1=str.substr(0,i);
			string s2=str.substr(i);
			string s1r=s1,s2r=s2;
			reverse(s1r.begin(),s1r.end());
			reverse(s2r.begin(),s2r.end());
			res.insert(s1+s2);
			res.insert(s1+s2r);
			res.insert(s2+s1);
			res.insert(s2+s1r);
			res.insert(s1r+s2);
			res.insert(s1r+s2r);
			res.insert(s2r+s1);
			res.insert(s2r+s1r);
		}
		cout<<SZ(res)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1296
(let* ((x (read))
       (n (read))
       (list (loop for i from 0 to 101 collect i)))
  (loop repeat n do (setf list (remove (read) list)))
  (loop for last = 0 then i
        for i in list
        ;;do (print (list x last i))
        when (> i x)
        do (return
             (format t "~A~%" (if (< (- i x)
                                     (- x last))
                                  i
                                  last)))))

Measured memory_bytes: 24560
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void* a, const void* b){
  return *(int*)a - *(int*)b;
}
int main(void){
  int n; scanf("%d",&n);
  int d[n];
  for(int i=0;i<n;i++)
    scanf("%d", &d[i]);
  qsort(d,n,sizeof(int),compare_int);
  printf("%d",d[n/2]-d[n/2-1]);
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ff first
#define ss second
ll fact(ll n)
{
    if(n==0)
        return 1;
    return fact(n-1)*n;
}
double dist(pair<ll,ll> a , pair<ll,ll> b)
{
    return sqrt((a.ff-b.ff)*(a.ff-b.ff) + (a.ss-b.ss)*(a.ss-b.ss));
}
int main()
{
    ll n;
    cin >> n;
    double sum = 0;
    pair<ll,ll> a[n];
    for(ll i=0;i<n;i++)
    {
        cin >> a[i].first;
        cin >> a[i].second;
       
    }
    sort(a,a+n);
    int cnt = 0;
    do
    {
        cnt++;
        for(ll i=0;i<n-1;i++)
        {
            sum += dist(a[i],a[i+1]);
        }
        
    } while (next_permutation(a,a+n));
    
    // cout << sum << " " << fact(n)<<endl;
    double ans = sum/fact(n);
    printf("%0.12lf",ans);
    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
using namespace std;
int main()
{
 int N,M,i,k=0,sum=0;
 cin>>N>>M;
 int A[N+5];
 for(i=0;i<N;i++)
 {
  cin>>A[i];
  sum+=A[i];
 }
 for(i=0;i<N;i++)
 {
   if(A[i]*(4*M)>=sum)
   k++;
 }
 if(k>=M)
 cout<<"Yes";
 else
 cout<<"No";
 return 0;
}


Measured memory_bytes: 256
import math 
from collections import defaultdict as dd
def main():
    N, M = map(int, input().split())

    MAP = [[]*N for x in range(N)]
    E = []
    for m in range(M):
        a,b,c = map(int, input().split())
        MAP[a-1].append((b-1, c))
        E.append((a-1,b-1,c))

    dp = [-float('inf')]*N
    dp[0] = 0
    updated = set([0])
    for count in range(1, 2*N+1):  # N
        preupdated = list(updated)
        updated = set([])
        for a in preupdated:
            for b,c in MAP[a]:
                if max(dp[b], dp[b]) < dp[a] + c:
                    updated.add(b)
                    dp[b] = dp[a] + c
        if count == N-1:
            tmp = dp[N-1]

    # print(tmp, dp[N-1])
    if dp[N-1] == tmp:
        print(tmp)
    else:
        print('inf')


if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()



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

using ll = long long;

ll calc(ll H, ll W) {
    ll ans = (1LL << 50);
    // Hを3分割
    for (ll h1 = 1; h1 + 2 <= H; h1++) {
        ll h2 = (H - h1) / 2,
           h3 = H - h1 - h2;
        ll smax = max(h1 * W, max(h2 * W, h3 * W)),
           smin = min(h1 * W, min(h2 * W, h3 * W));
        ans = min(ans, smax - smin);
    }
    for (ll h1 = 1; h1 + 1 <= H; h1++) {
        ll h2 = H - h1,
           w2 = W / 2,
           w3 = W - w2;
        ll smax = max(h1 * W, max(h2 * w2, h2 * w3)),
           smin = min(h1 * W, min(h2 * w2, h2 * w3));
        ans = min(ans, smax - smin);
    }
    return ans;
}

int main() {
    ll H, W;
    cin >> H >> W;

    cout << min(calc(H, W), calc(W, H)) << endl;

    return 0;
}


Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!
 
/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
 
signed main()
{
    fast;
    ll n,i,j,ans=0,d=5;
    cin>>n;
    if(n&1){
        cout<<"0";
        return 0;
    }
    n /= 2;
    while(n>=d)
    {
        ans += n/d;
        d *= 5;
    }
    cout<<ans;
    
}

Measured memory_bytes: 256
def main(argv):
    w = argv[0]
    h = argv[1]
    x = argv[2]
    y = argv[3]
    r = argv[4]

    if 0 <= x - r  and x + r <= w and 0 <= y - r and y + r <= h:
        print('Yes')
    else:
        print('No')
        
if '__main__' == __name__:
    try:
        while True:
            main(list(map(int, input().strip().split(' '))))
    except EOFError:
        pass



Measured memory_bytes: 5604
#include<cstdio>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
void func(int);
int main(void)
{
	int i,j,x,y,flg;
	P pp[6];
	for(i=0;i<6;i++)	{
		scanf("%d %d",&x,&y);
		if(x>y)	swap(x,y);
		pp[i].first=x;	pp[i].second=y;
	}
	sort(pp,pp+6);
	flg=1;
	if(pp[0].first!=pp[1].first || pp[0].second!=pp[1].second)	flg=0;
	if(pp[2].first!=pp[3].first || pp[2].second!=pp[3].second)	flg=0;
	if(pp[4].first!=pp[5].first || pp[4].second!=pp[5].second)	flg=0;	
	if(pp[0].first!=pp[2].first || pp[0].second!=pp[4].first || pp[2].second!=pp[4].second)	flg=0;	
	if(flg==1)	printf("yes\n");
	else printf("no\n");
	return 0;
}


Measured memory_bytes: 2664
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, q, l, r;
    string s;
    cin >> n >> q >> s;
    vector<int>a(n);

    for(int i=1; i<s.size(); i++){
        if(s[i]=='C'&&s[i-1]=='A'){
            a[i] = a[i-1]+1;
        }else{
            a[i] = a[i-1];
        }
    }

    for(int i=0; i<q; i++){
        cin >> l >> r;
        l--; r--;
        cout << a[r]-a[l] << endl;
    }
    return 0;
}

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

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    if(a+b==0){
        cout << 0 << endl;
    }else{
        long long q,r;
        q =  n / (a + b);
        r = n % (a + b);
        cout << q * a + min(r, a) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 * n ????????´??°???????????°??? S ??¨???q ????????°????????´??°???????????°??? T ??????????????????T ?????????????????´??°????????§ S ?????????????????????????????° C ???????????????????????°????????????????????????????????????

??\???
???????????? n??????????????? S ?????¨??? n ????????´??°??????????????? q??????????????? T ?????¨??? q ????????´??°????????????????????????

??????
C ???????????????????????????????????????

??¶?´?
S ???????´???????????????´??????????????????
n???100,000
q???50,000
0???S???????´????10^9
0???T???????´????10^9
T ???????´???????????????°??????
??\?????? 1
5
1 2 3 4 5
3
3 4 1
????????? 1
3
??\?????? 2
3
1 2 3
1
5
????????? 2
0
 */

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

bool binarySearch(const std::vector<unsigned int>& Source, const unsigned int& Key) {
    unsigned int left = 0;
    unsigned int right = Source.size();
    unsigned int mid = 0;
    while (left < right) {
        mid = (left + right) / 2;
        if (Source[mid] == Key) {
            return true;
        } else if (Key < Source[mid]) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    return false;
}

int main(int argc, char const *argv[]) {
  std::vector<unsigned int> S;
  std::vector<unsigned int> T;
  std::string Param;
  std::istringstream iss;
  unsigned int n = 0;
  unsigned int q = 0;
  getline(std::cin, Param);
  iss.str(Param);
  iss >> n;
  iss.clear();
  getline(std::cin, Param);
  iss.str(Param);
  unsigned int Si;
  for (size_t i = 0; i < n; i++) {
    iss >> Si;
    S.push_back(Si);
  }
  iss.clear();
  getline(std::cin, Param);
  iss.str(Param);
  iss >> q;
  iss.clear();
  getline(std::cin, Param);
  iss.str(Param);
  unsigned int Ti;
  for (size_t i = 0; i < q; i++) {
    iss >> Ti;
    T.push_back(Ti);
  }

  unsigned short C = 0;
  for (const auto &e : T) {
    bool Result = binarySearch(S, e);
    if (Result) {
      C++;
    }
  }

  std::cout << C << std::endl;
  return 0;
}

Measured memory_bytes: 4860
n,k = map(int, input().split())
a = list(map(int, input().split()))
ans=[False]*(k+1)
ans[0]=False

for i in range(k+1):
    for num in a:
        if (i-num >=0) and (not ans[i-num]):
            ans[i]=True

if ans[-1]:
    print("First")
else:
    print("Second")

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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)
ll a[1000005],vis[1000005];
int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n,a=0,b=0,c=0,d=0;
        string s;
        cin>>n;
        while(n--)
        {
            cin>>s;
            if(s=="AC") a++;
            if(s=="WA") b++;
            if(s=="TLE") c++;
            if(s=="RE") d++;
        }
        cout<<"AC x "<<a;
        nl;
        cout<<"WA x "<<b;
        nl;
        cout<<"TLE x "<<c;
        nl;
        cout<<"RE x "<<d;
        nl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>

using namespace std;
typedef long long ll;

static const double pi = 3.141592653589793;

int main()
{
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	
	double radA = (2 * pi * H) / 12.0;
	double radB = (2 * pi * M) / 60.0;
	radA += radB / 12.0;
	
	double x1 = A * cos(radA);
	double y1 = A * sin(radA);
	double x2 = B * cos(radB);
	double y2 = B * sin(radB);
	
	double ans = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
	
	printf("%.12f\n", ans);
	
	return 0;
}

Measured memory_bytes: 4084
#include <iostream>
#include <string>

using namespace std;

int main(){
	int A, B;
	cin >> A >> B;

	int ans = 0, i = 0;

	while (i < 2) {
		if (A > B) {
			ans += A;
			A--;
		}
		else {
			ans += B;
			B--;
		}
		i++;
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

// 1文字のみから成る文字列か？
bool unique(string s)
{
  // 1文字なら ok
  int n = s.length();
  if (n < 2) return true;

  // 2文字目以降が、すべて s[0] と同じなら ok
  REP(i,1,n) {
    if (s[i] != s[0]) return false;
  }
  return true;
}

// s を文字 c だけから成る文字列に変える
// 操作回数を返す
int simulate(string s, char c)
{
  int cnt = 0;
  while (true) {
    if (unique(s)) break;
    int n = s.length();
    // s に操作を施した文字列
    // |t| = n-1
    string t = s.substr(0,n-1);
    REP(i,0,n-1) {
      // もし t[i] を c に変えられるなら
      if (s[i] == c || s[i+1] == c) t[i] = c;
      else t[i] = s[i];
    }
    s = t;
    ++cnt;
  }
  return cnt;
}

int main()
{
  string s;
  cin >> s;

  // 最小値
  int m = 1000;
  REP(i,0,26) {
    int k = simulate(s, 'a' + i);
    if (k < m) m = k;
  }

  cout << m << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include<stdio.h>
#include<functional>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
// int N, D, X[10][10];
int main() {
    int N;
    int D;
    // int ;
    cin >> N>>D;
    int ans;
    int b;
    int c;
    // rep(i, 0, N) rep(d, 0, D) cin >> X[i][d];
    // int all;
    b=N%(2*D+1);
    c=N/(2*D+1);
    if (b!=0){
        ans=int(c)+1;}
    else{
        ans=int(c);
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
def bingo(b):
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                B[i][j] = 1

def judge():
    for i in range(3):
        if B[i][0] and B[i][1] and B[i][2]:
            return True
        if B[0][i] and B[1][i] and B[2][i]:
            return True
    if B[0][0] and B[1][1] and B[2][2]:
            return True
    if B[0][2] and B[1][1] and B[2][0]:
            return True
    return False

A = [[int(i) for i in input().split()] for _ in range(3)]
B = [[0]*3 for _ in range(3)]
N = int(input())
for _ in range(N):
    b = int(input())
    bingo(b)
if judge():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<18, mod = 1e9 + 7;
int f[maxn];
void add(int p, int v) {
	for(; p < maxn; p+=p&-p) f[p]+=v;
}
int get(int p) {
	int r = 0;
	for(; p; p-=p&-p) r += f[p];
	return r;
}
vector<int> p[30];
int main() {
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	map<char, int> cnt, u;
	int odd = 0;
	for(auto i : s) cnt[i]++;
	for(auto i : cnt) odd += i.second&1;
	if(odd > 1) return cout << -1, 0;
	ll ans = 0;
	string t;
	for(auto i : s) {
		if(u[i] < cnt[i]/2) t += i, u[i]++;
	}
	for(auto i : cnt) if(i.second&1) t.pb(i.first);
	for(int i = t.size() - (2*t.size() != s.size()); i--;)
		t += t[i];
	for(int i = s.size(); i--;) p[s[i]-'a'].pb(i+1), add(i+1, 1);
	for(auto i : t) {
		int x = p[i-'a'].back();
		add(x, -1);
		ans += get(x);
		p[i-'a'].pop_back();
	}
	cout << ans;
	return 0;
}


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

int main(){
	string line;
	int a, b, c;
	int hishi=0, tyo=0;
	while(1){
		getline( cin, line );
		if( line.length() == 0 ){
			break;
		}
		sscanf( line.c_str(), "%d,%d,%d", &a, &b, &c );
		if( a==b ){
			hishi++;
		}else if( a*a + b*b == c*c ){
			tyo++;
		}
	}
	cout << tyo << endl;
	cout << hishi << endl;
	return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    keys = []
    for _ in range(M):
        a, _ = map(int, input().split())
        c = 0
        for i in list(map(int, input().split())):
            c += (1 << (i-1))
        keys.append((a, c))

    inf = float("inf")
    dp = [[inf]*(1 << N) for _ in range(M+1)]
    dp[0][0] = 0

    for i, (a, c) in enumerate(keys):
        for j in range(1 << N):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            dp[i+1][j | c] = min(dp[i+1][j | c], dp[i][j] + a)

    print(-1 if dp[-1][-1] == inf else dp[-1][-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 140636
N = int(input())
A = [int(i) for i in input().split()]
X1 = sum(A)
arr = [0]*N
for i in range(N):
  if i%2==1:
    X1 -= 2*A[i]
arr[0] = X1
for i in range(1, N):
  arr[i] = 2*A[i-1] - arr[i-1]
print(*arr)

Measured memory_bytes: 14092
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=sc.nextInt(),K=sc.nextInt();
		Long[] h=new Long[N];

		for(int i=0;i<N;i++) {
			h[i]=sc.nextLong();
		}
		Arrays.sort(h);

		long ans=0;

		for(int i=0;i<N-K;i++) {
			ans+=h[i];
		}
		System.out.println(ans);
	}
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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

ll n,q;
string s;
vector<pair<char,char>> a;

bool isOk(ll mid, bool flg){
  ll pos=mid;
  rep(i,q){
    char now=s[pos];
    char t=a[i].first, d=a[i].second;
    if(now==t){
      if(d=='R') pos++;
      else pos--;
    }
    // if(mid==0) cout<<d<<" "<<now<<" "<<pos<<endl;
    // cout<<111<<endl;
    if(flg){
      // cout<<222<<endl;
      if(pos>=n) return false;
      if(pos<0) return true;
    }else{
      if(pos>=n) return true;
      if(pos<0) return false;
    }
  }
  
  return false;
}


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>q;
  a.resize(q);
  cin>>s;
  rep(i,q){
    char t,d; cin>>t>>d;
    a[i]={t,d};
  }
  ll ans=0;
  ll ok=-1, ng=n;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    // cout<<isOk(mid,true)<<endl;
    if(isOk(mid,true)) ok=mid;
    else ng=mid;
  }
  ans+=ok+1;
  // cout<<ok<<endl;
  
  ok=n, ng=-1;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(isOk(mid,false)) ok=mid;
    else ng=mid;
  }
  ans+=n-ok;
  cout<<n-ans<<endl;
}

Measured memory_bytes: 1104
#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
  int n;
  cin >> n;
  int sum = 0;
  int c = n;
  while (c > 0) {
    int m = c % 10;
    sum += m;
    c /= 10;
  }
  if (n % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    bell=LI()
    print(sum(bell)-max(bell))
main()

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

namespace ABC116 {
	class ABC116_A {
		static void Main(string[] args) {
			var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var AB = input[0];
			var BC = input[1];
			Console.WriteLine(AB * BC / 2);
		}
	}
}


Measured memory_bytes: 13268
import java.util.Arrays;
import java.util.Scanner;
/**
 * 精進
 * @author linds_000
 *
 */
public class Main {

	public static void main(String[] args) {

		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		final long MOD = 1000000007L;
		boolean[] step = new boolean[n + 1];
		Arrays.fill(step, true);
		for (int i = 0; i < m; i++) {
			step[Integer.parseInt(sc.next())] = false;
		}

		long[] ans = new long[n + 1];

		ans[0] = 1L;
		for (int now = 0; now < n; now++) {
			for (int next = now + 1; next <= Integer.min(now + 2, n); next++) {
				if(step[next]) {
					ans[next] += ans[now];
					ans[next] %= MOD;
				}
			}
		}
		System.out.println(ans[n]);
	}

}


Measured memory_bytes: 46632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  double l;
  cin>>l;
  double v=pow(l/3,3);
  cout<<fixed<<setprecision(6)<<v;
  return 0;
}
  

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int N,M;
  cin>>N>>M;
  long long A,B,C;
  //数字、個数のペア
  vector<pair<long long,long long>> pairs;
  for(int i=0;i<N;i++){
    cin>>A;
    pairs.push_back(make_pair(A,1));
  }
  for(int j=0;j<M;j++){
    cin>>B>>C;
    pairs.push_back(make_pair(C,B));
  }
  long long ans=0;
  sort(pairs.begin(),pairs.end());
  long long counter=0;
  long long X,Y;
  for(int i=0;i<N;++i){
    X=pairs[N+M-1-i].first;
    Y=pairs[N+M-1-i].second;
    for(int j=0;j<Y;++j){
      ans+=X;
      counter+=1;
      if(counter==N){
        break;
      }
    }
    if(counter==N){
      break;
    }
  }
  cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 6256
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());
		
		long []a = new long [n];
		long []b = new long [n];
		
		for(int i = 0 ; i < n ;i++) {
			a[i] = Long.parseLong(sc.next());
			b[i] = Long.parseLong(sc.next());
			
		}		
		long ax = a[0];
		long bx = b[0];
		
		for(int i = 1 ;i < n ;i++) {
			if(ax <= a[i] && bx <= b[i]) {
				ax = a[i];
				bx = b[i];
			}
			else if(ax > a[i] || bx > b[i]) {
				long ta = (ax%a[i] == 0 ? ax/a[i] : (ax/a[i])+1);
				long tb =  (bx%b[i] == 0 ? bx/b[i] : (bx/b[i])+1);
				long t = Math.max(ta, tb);
				ax = t*a[i];
				bx = t*b[i];
			}
			
		}
	
		System.out.println(ax+bx);

		
	}
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k, n; cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = a[n-1] - a[0];
    for (int i = 1; i < n; i++) {
        ans = min(ans, k - (a[i] - a[i-1]));
    }
    cout << ans << "\n";
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
   
    while(true){
        ll h,w; cin>>h>>w;
        if(h==0&&w==0) break;
        vector<vector<char>> rect(h,vector<char>(w,'.'));
        
        rep(i,h)rep(j,w){
            if(i%2==0&&j%2==0) rect[i][j]='#';
            else if(i%2==1&&j%2==1) rect[i][j]='#';
        }

        rep(i,h)rep(j,w){
            cout<<rect[i][j];
            if(j==w-1) cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3160
#![allow(unused_imports, unused_macros, non_snake_case)]
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

//{{{ macros missing in 1.15.1
#[macro_use]
mod macros {
    macro_rules! eprint {
        ($($t:tt)*) => {{
            use ::std::io::Write;
            let _ = write!(::std::io::stderr(), $($t)*);
        }};
    }
    macro_rules! eprintln {
        () => { eprintln!(""); };
        ($($t:tt)*) => {{
            use ::std::io::Write;
            let _ = writeln!(::std::io::stderr(), $($t)*);
        }};
    }
    macro_rules! dbg {
        ($val:expr) => {
            match $val {
                tmp => {
                    eprintln!(
                        "[{}:{}] {} = {:#?}",
                        file!(),
                        line!(),
                        stringify!($val),
                        &tmp
                    );
                    tmp
                }
            }
        };
    }
}
//}}}

fn run() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    let n: usize = sc.read();
    let s = sc.read_chars();
    let mut lines = 0;
    let mut dp = vec![0; 2 * n + 1];
    let MOD = 1_000_000_007;
    dp[0] = 1;
    for i in 0..2 * n {
        let okc = match lines % 2 {
            0 => 'B',
            1 => 'W',
            _ => unreachable!(),
        };
        if okc != s[i] {
            if lines == 0 {
                break;
            }
            dp[i + 1] = (dp[i] * lines) % MOD;
            lines -= 1;
        } else {
            dp[i + 1] = dp[i];
            lines += 1;
        }
    }
    let mut fact = dp[2 * n];
    for i in 1..n + 1 {
        fact *= i;
        fact %= MOD;
    }
    if lines != 0 {
        fact = 0;
    }
    println!("{}", fact);
}

fn main() {
    std::thread::Builder::new()
        .name("run".to_string())
        .stack_size(1024 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap()
}

//{{{ Scanner
pub struct Scanner<R> {
    reader: R,
}

impl<R> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner { reader: r }
    }
}

fn is_whitespace(b: u8) -> bool {
    b == b' ' || b == b'\n' || b == b'\r' || b == b'\t'
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        let buf = std::io::Read::bytes(self.reader.by_ref())
            .map(|b| b.expect("Read failed"))
            .skip_while(|&b| is_whitespace(b))
            .take_while(|&b| !is_whitespace(b))
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error")
    }

    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
//}}}


Measured memory_bytes: 10620
package main

import (
	"fmt"
	"math"
)

func isPrime(N float64) bool {
	end := int(math.Sqrt(N) + 1)
	for i := 2; i < end; i++ {
		if int(N)%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	var N int
	fmt.Scan(&N)

	for n := N; n <= 100003; n++ {
		if isPrime(float64(n)) {
			fmt.Println(n)
			break
		}
	}
}


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

pairs = []

for _ in range(M):
  pairs.append([int(x) for x in input().split()])

pairs.sort(key = lambda x: x[1])

right_most = 0 # 最後に破壊されている場所（右のindex）

cnt = 0
for a,b in pairs:
  if a < right_most:
    continue
  cnt += 1
  right_most = b

print(cnt)

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

int main() {
    int n;
    cin >> n;
    string t[] = {"AC", "WA", "TLE", "RE"};
    int cnt[4] = {0};
    rep(i, n) {
        string s;
        cin >> s;

        rep(j, 4) {
            if (t[j] == s) {
                cnt[j]++;
                break;
            }
        }
    }

    rep(i, 4) {
        cout << t[i] << " x " << cnt[i] << endl;
    }

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second

int main(){
  ll a = 0, b = 0, c = 0;
  ll bxor = 0, axor = 0, ans;
  cin >> a;
  cin >> b;
  if(a!=0) c = a - 1;

  if(b%4==1) bxor = 1;
  else if(b%4==2) bxor = b+1;
  else if(b%4==3) bxor = 0;
  else bxor = b;

  if(c%4==1) axor = 1;
  else if(c%4==2) axor = c + 1;
  else if(c%4==3) axor = 0;
  else axor = c;
  ans = axor^bxor;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256