akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, K, Q;
  std::cin >> N >> K >> Q;
  std::vector<i64> A;
  tools::read(A, Q);
  std::transform(A.begin(), A.end(), A.begin(), [](const i64& A_i) { return A_i - 1; });

  std::vector<i64> wins(N, 0);
  for (const i64& A_i : A) {
    ++wins[A_i];
  }

  for (const i64& win : wins) {
    std::cout << (K - (Q - win) > 0 ? "Yes" : "No") << std::endl;
  }
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef	long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef pair<ll, pll> plll;
typedef vector<pair<int, pii>> viii;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tc int tt;cin>>tt;while(tt--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fio ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define RED "\033[31m"
#define GREEN "\033[32m"
#define RESET "\033[0m"
#define sleep for (int i = 1, a;i < 100000000;i++, a = a * a)
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ranked_pairset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_map;

int main() {
	fio;
	int n;
	cin >> n;
	vl a(n);
	for (int i = 0;i < n;i++)
		cin >> a[i];
	ll s = accumulate(all(a), 0LL) % mod;
	s *= s;
	for (int i = 0;i < n;i++)
		s = (s - a[i] * a[i] % mod + mod) % mod;
	s = s * ((mod + 1) / 2) % mod;
	cout << s << '\n';
}


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

int main() {
  int n;cin>>n;
  vector<vector<vector<int>>> v(4,vector<vector<int>>(3,vector<int>(10,0)));
  for(int i=0;i<n;i++){
    int b,f,r,k;
    cin>>b>>f>>r>>k;
    v[b-1][f-1][r-1]+=k;
  }
  rep(i,4){
    rep(j,3){
      rep(k,10){
        cout<<" "<<v[i][j][k];
        if(k==9)cout<<endl;
        if(i<3&&j==2&&k==9) cout<<"####################"<<endl;
      }
    }
  }
}


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

int main(){
	string ans="Yes";
	
	string s;
	cin >> s;
	int n=s.length();
	rep(i,n){
		int count=0;
		rep(j,n){
			if(s[i] == s[j]) count++;
		}
		if(count != 2) ans = "No";
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> iii;
typedef vector<iii> viii;

#define umap unordered_map
#define uset unordered_set
#define pb push_back
#define LSOne(x) (x & (-x))
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

const int iinf = 1e9+7;
const ll inf = 1e18+7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n; cin >> n;
    vi v(n);
    for (auto& i : v) cin >> i;
    vector<vll> dp(n+1, vll(n+1,0));
    for (int i = n-1; i >= 0; --i)
        for (int j = i; j < n; ++j) {
            if (i == j) {
                dp[i][j] = v[i];
            } else {
                dp[i][j] = max(v[i] - dp[i+1][j],v[j] - dp[i][j-1]);
            }
        }
    cout << dp[0][n-1] << endl;
}


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

int main(){
  int h, w; cin >> h >> w;

  string grid[h][w];
  char l; int c;
  for(int y=0; y<h; y++){
    for(int x=0; x<w; x++){
      cin >> grid[y][x];
      if(grid[y][x] == "snuke"){
        l = x + 'A'; 
        c = y + 1;
      }
    }
  }

  cout << l << c << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define DEBUG if(1)
#define MAX INT_MAX
#define MAXLL INT_MAX
#define MAXU ULLONG_MAX
#define MIN -2000000
#define endl "\n"
#define INF INT_MAX
#define MOD 1000000007
#define s(n) scanf("%d", &n)
#define ss(a,b) scanf("%d %d",&a,&b)
#define pb push_back
#define mp make_pair
#define M_PI 3.14159265358979323846
#define sz(a) int(a.size())
#define lli long long int
#define rep(i,a,n) for (int i=a;i<n;i++)
#define ler(a,n,vec) for(int i=0;i<n;i++)s(a), vec.pb(a)
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> ii;
#define DEBUG if(1)
#define F first
#define S second
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int ddx[] = {1, 0};
int ddy[] = {1, 1};
#define MAXN 200010
#define MAXL 20
 
int n;
vector<lli> vec;
 
lli pd[MAXN][2];
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 
  cin >> n;
  for(int i=0;i<n;i++){
  	int a;
  	cin >> a;
  	vec.pb(a);
  }
 
  for(int i=0;i<=n;i++) for(int j=0;j<=2;j++) pd[i][j] = INT_MAX;
 
  pd[1][1] = abs(vec[1] - vec[0]);
	pd[2][2] = abs(vec[2] - vec[0]);
 
  // for(int i=1;i<sz(vec);i++){
 
  // 	pd[i+1][1] = min(pd[i+1][1], pd[i][1] + abs(vec[i] - vec[i+1]));
  // 	pd[i+1][1] = min(pd[i+1][1], pd[i][2] + abs(vec[i] - vec[i+1]));
  // 	pd[i+2][2] = min(pd[i+2][2], pd[i][2] + abs(vec[i] - vec[i+2]));
  // 	pd[i+2][2] = min(pd[i+2][2], pd[i][1] + abs(vec[i] - vec[i+2]));
 
  // }

  for(int i=1;i<sz(vec);i++){
  	for(int j=1;j<=2;j++){
  		for(int k=1;k<=2;k++){
  			pd[i+j][j] = min(pd[i+j][j], pd[i][k] + abs(vec[i] - vec[i+j]));
  		}
  	}
  }
 
 // for(int i=0;i<sz(vec);i++){
  //	for(int j=1;j<=2;j++) cout << pd[i][j] << " ";
  	//	cout << endl;
  //}
 
  cout << min(pd[n-1][1], pd[n-1][2]);
 
  return 0;
}

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

int comp(const void *n1, const void *n2)
{
  int *a= n1, *b = n2; 
  if(*a < *b)
    return -1;
  else if(*a == *b)
    return 0;
  else
    return 1;
}


int main(void)
{
  int n,m,l[100000],r[100000];
  int buttom=0,top=0,frag=0;
  int i,sum;
  
  scanf("%d %d",&n, &m);
  for(i = 0; i < m; i++)
    scanf("%d %d",l+i, r+i);
  
  qsort(l, m, sizeof(int), comp);
  qsort(r, m, sizeof(int), comp);
  
  sum = r[0] - l[m-1] + 1;
  if(sum > 0)
  	printf("%d\n",sum);  
  else
    printf("0\n");
  return 0;
}
        

Measured memory_bytes: 1396
#include<bits/stdc++.h>
#define f first
#define s second
#define endl "\n"
#define M 1000000007
#define pb push_back
#define pf push_front
#define eb emplace_back
#define MM_PI 3.14159265358979323846
#define TEST_CASE int t;cin>>t;while(t--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
//template<typename T> T pow(T a, T b, long long m) {T ans = 1; while (b > 0) { if (b % 2 == 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans % m; }
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
const int maxn = 1e5 + 10;

void solve() {
	ll n;
	cin >> n;
	vll arr(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	vll dp(n);
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
	}
	cout << dp[n - 1] << endl;
}
int main() {

//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
	//IOS
	//make();
	//TEST_CASE
	solve();
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    int n,i,j,x,m,q;
    bool dp[21][2001]={};
    dp[0][0]=true;
    cin>>n;
    
    for(i=1;i<=n;i++){
        cin>>x;
        for(j=0;j<2002;j++){
            if(dp[i-1][j]){
                dp[i][j]=true;
            }
            else if(j-x>=0){
                dp[i][j]=dp[i-1][j-x];
            }
        }
    }
    
    cin>>q;
    for(i=0;i<q;i++){
        cin>>m;
        if(dp[n][m]){
            cout<<"yes"<<endl;
        }
        else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3148
W, H, N = map(int, input().split())

X = Y = 0

for i in range(0, N):
    x, y, a = map(int, input().split())

    if a == 1:
        X = max(X, x)
    elif a == 2:
        W = min(W, x)
    elif a == 3:
        Y = max(Y, y)
    else:
        H = min(H, y)

print(max(W-X, 0)*max(H-Y, 0))


Measured memory_bytes: 9140
s = input()

n = len(s)

ans = 0

s1 = s[:int((n - 1) / 2)]
s2 = s[int((n + 3) / 2) - 1:]

s5 = s[::-1]

s3 = s1[::-1]
s4 = s2[::-1]

#print(s5, s3, s4)
if s1 == s3:
    ans += 1

if s2 == s4:
    ans += 1

if s == s5:
    ans += 1

if ans == 3:
    print('Yes')
else:
    print('No')


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

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

	int x = max(A, B);
	int y = min(A, B);
	
	int ans = x + y;
	if (x - y > 1)
		ans = x + (x - 1);

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
if a[0]!=0:print(0)
else:
  a.sort()
  mod=998244353
  if n==1:print(1)
  elif a[1]==0:print(0)
  else:
    li=[]
    ans=1
    a+=[a[-1]+1]
    check=0
    for i in range(1,n):
      if abs(a[i]-a[i+1])>=2:print(0);exit()
      if a[i]!=a[i+1]:
        if li==[]:
          li.append(i)
          check=i
        else:
          li.append(i-check)
          check=i
    for i in range(len(li)-1):
      ans=ans*(li[i]**li[i+1])
      ans%=mod
    print(ans%mod)


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

int main(){

  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int count = 0;
  
  for(int a = 0; a <= A; a++){
    for(int b = 0; b <= B; b++){
      for(int c = 0; c <= C; c++){
        if(X == 500 * a + 100 * b + 50 * c){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        sc.close();

        // ref. http://drken1215.hatenablog.com/entry/2018/09/02/011000
        long[] num = new long[k];
        for (int i = 1; i <= n; i++) {
            num[i % k]++;
        }
        long ans = 0;
        for (int a = 0; a < k; a++) {
            int b = (k - a) % k;
            int c = (k - a) % k;
            if ((b + c) % k != 0) {
                continue;
            }
            ans += num[a] * num[b] * num[c];
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 22736
#include<bits/stdc++.h>
#define N 158
using namespace std;
int vi[N*2],d1[N],mo,dp[N][N][2],n,k,ans;
void add(int &x,int y){x+=y;if (x>=mo)x-=mo;}
void get1(int x,int y){
	d1[0]=1;
	for (int i=1;i<=x+1;i++)
		for (int j=max(0,i-y);j<i;j++)add(d1[i],d1[j]);
	cout<<1ll*d1[x/2+1]*d1[(x+1)/2+1]%mo<<endl;
}
int main(){
	cin>>n>>k>>mo;
	if (k%2==0)get1(n,k/2+1);
	else{
		for (int i=1;i<=n+k+1;i++)
			if(i%2==0){if(i<k+2)vi[i]=0;else vi[i]=1;}else{if(i>n)vi[i]=0;else vi[i]=1;}
		dp[0][0][0]=1;
		for (int i=1;i<=(n+k)/2+1;i++){
			for (int l=0;l<i;l++)
			for (int p=0;p<=k;p++)
			if (dp[l][p][0]){
				int nl,np;
				for (int t1=0;t1<=vi[i*2-1];t1++)
				for (int t2=0;t2<=vi[i*2];t2++){
					if (t2&&p==1)continue;
					if (t1)nl=l+1;else nl=0;
					if (!t2)np=0;
					if (t1&&t2){if (l>=k)continue;if(!p)np=k-l;else np=p-1;}
					if (!t1&&t2){if(!p)np=0;else np=p-1;}
					add(dp[nl][np][1],dp[l][p][0]);
				}
			}
			for (int l=0;l<=i;l++)
			for (int p=0;p<=k;p++){
				dp[l][p][0]=dp[l][p][1],dp[l][p][1]=0;
				if (i==(n+k)/2+1)add(ans,dp[l][p][0]);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
long m,n,a,b,c;
long val[105];
long v[105][105];
int getans(){
	int ans,i,j,k,r,s1,s2;
	long a[105];
	long mark[105];
	long w[105];
	memset(w,0,sizeof(w));
	if (n==2){
		return val[0];
	}
	a[0]=0;
	for (i=0;i<n;i++)
	  mark[i]=1;
	ans=val[a[0]];
	for (i=1;i<=n-1;i++){
    r=0;
    mark[a[0]]=2;
	  for (j=0;j<n;j++){
			if (mark[j]==1)
			  w[j]=v[a[0]][j];
		}
		while (true){
			k=-1;
			for (j=0;j<n;j++){
				if (mark[j]==1 &&(k==-1 || w[j]>w[k]))
			  	k=j;
			}
			if (k==-1)
			  break;
	    r++;
	    a[r]=k;
	    ans=ans<val[k]?ans:val[k];
	    mark[k]=2;
	    for (j=0;j<n;j++){
    		if (mark[j]==1)
    		  w[j]+=v[j][k];
    	}
		}
		s1=a[r-1];s2=a[r];
		val[s1]+=val[s2];
		val[s1]-=v[s1][s2]*2;
		mark[s2]=3;
		for (j=0;j<n;j++){
			if (mark[j]!=3){
				v[s1][j]=v[j][s1]=v[s1][j]+v[j][s2];
        mark[j]=1;
			}
	  }
		v[s1][s2]=v[s2][s1]=0;
	}
	return ans;
}
int main(){
  while (scanf("%d %d",&n,&m)==2){
  	int nowans=0;
		if (n==0)
  	  return 0;
  	memset(val,0,sizeof(val));
  	memset(v,0,sizeof(v));
		  for (int j=0;j<m;j++){
  			scanf("%d %d %d",&a,&b,&c);
  			if (c<=0)
  			  nowans+=c;
			  else{
	  			v[a][b]=v[b][a]=v[a][b]+c;
  				val[a]+=c;
  				val[b]+=c;
			  }
			}
		printf("%d\n",nowans+getans());
	}
}

Measured memory_bytes: 0
ans = [0,0,0,0]
N = int(input())
for i in range(N):
    S = input()
    if S == "AC":
        ans[0] += 1
    if S == "WA":
        ans[1] += 1
    if S == "TLE":
        ans[2] += 1
    if S == "RE":
        ans[3] += 1
print("AC x "+str(ans[0]))
print("WA x "+str(ans[1]))
print("TLE x "+str(ans[2]))
print("RE x "+str(ans[3]))

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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  
  vector<vector<int>> C(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < N; k++) {
        if (A.at(i).at(j) == B.at(k)) {
          C.at(i).at(j) = 1;
        }
      }
    }
  }
  
  string ans = "No";
  for (int i = 0; i < 3; i++) {
    if (C.at(i).at(0) + C.at(i).at(1) + C.at(i).at(2) == 3) {
      ans = "Yes";
    }
  }
  for (int j = 0; j < 3; j++) {
    if (C.at(0).at(j) + C.at(1).at(j) + C.at(2).at(j) == 3) {
      ans = "Yes";
    }
  }
  if (C.at(0).at(0) + C.at(1).at(1) + C.at(2).at(2) == 3) {
    ans = "Yes";
  }
  if (C.at(0).at(2) + C.at(1).at(1) + C.at(2).at(0) == 3) {
    ans = "Yes";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a=0;
		int next, count=0;

		for(int i=0; i<n;i++) {
			next=sc.nextInt();
			if(a==next) {
				count++;
				a=0;
			}
			else {
				a=next;
			}
		}

		System.out.print(count);

	}

}


Measured memory_bytes: 23764
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 1000000007;
int n, m,c,k; 
int main() {
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    sort(ALL(t)); int sum =1,f = 0;
    rep(i, n) {
        if (i - f + 1 > c || t[i] - t[f] > k) {
            sum++; f = i;
        }
    }
    cout << sum  << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f(x,n) for (int i=x;i<n;i++)

int main()
{
  int n;
  cin>>n;
  int a[n+1][4];
  for (int i=1;i<=n;i++)
  {
    for (int j=1;j<=3;j++)
    {
      cin>>a[i][j];
    }
  }
  for (int i=1;i<=n-1;i++)
  {
    for(int j=1;j<=3;j++)
    {
      int x=a[i+1][j];
      for (int k=1;k<=3;k++)
      {
        if(k!=j)
        {
        a[i+1][j]=max(a[i][k]+x,a[i+1][j]);
        }
      }
    }
  }
int ans=0;
for (int i=1;i<=3;i++)
 ans=max(a[n][i],ans);
 cout<<ans;
  return 0;
}

Measured memory_bytes: 5188
import Foundation

func readInts() -> [Int]{
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let xn = readInts()
    let exclusionInts = readInts()
    
    // 空であれば与えられた整数が解
    if exclusionInts.isEmpty{
        print(xn[0])
        return
    }
    for i in 0...100{
        if !exclusionInts.contains(xn[0]-i){
            print(xn[0]-i)
            return
        }
        if !exclusionInts.contains(xn[0]+i){
            print(xn[0]+i)
            return
        }
    }
}

main()



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

int main() {
  int a,b;
  cin>>a>>b;
  if(a==1) a=14;
  if(b==1) b=14;
  if(a==b) cout<<"Draw"<<endl;
  else if(a<b) cout<<"Bob"<<endl;
  else cout<<"Alice"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int res = 0;
    for(int i = 0; i<=300;i++) {
        int h,w;
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        for(int k = 0; k < h; k++) {
            for(int j = 0; j < w; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3096
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;
 
int N;
int P[200000];

int ans = 0;
 
void solve(){
	int minimum = P[0];//随時更新していく
	for(int i=0;i<N;i++){
		if(minimum>=P[i]){
			minimum = P[i];
			ans++;
		}
	}
}
 
int main(){
	cin>>N;
	for(int i=0;i<N;i++) cin>>P[i];

	solve();

	cout<<ans;
	return 0;
}

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

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin>>n;
	double ans = 0;	
	for(int i = 0; i < n; i++){
		string s;
		double a;
		cin>> a>> s;
		if(s=="BTC"){
			ans += a*380000;
		}else ans+=a;
	}
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int[] a={sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
    int m=0;
    for(int i=0;i<5;i++){
      m+=(a[i]+9)/10*10;
    }
    int n=0;
    for(int i=0;i<5;i++){
      n=Math.max(10-((a[i]+9)%10),n);
    }
    System.out.println(m-n+1);
  }
}

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

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

  ll N; cin >> N;
  ll ans = 0;
  if (N % 1000 !=0) {
    ans = 1000 - (N % 1000);
  }
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3648
from collections import Counter
import numpy as np

N = int(input())
A = np.array(input().split(), dtype=np.int64)

c = Counter(A.cumsum())
c[0] += 1 # np.cumsum(), 0start では無い為 0を加える
ans = sum(v*(v-1)//2 for v in c.values())
print(ans)

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

using namespace std;

typedef vector< vector<int> > VVI;

struct edge {
	int to, cost;
	edge(int t, int c) :to(t), cost(c) {}
};
typedef pair<int, int> P; // firstは最短距離, secondは頂点の番号

const int INF = (1e9);

void wFloyd ( VVI &v )
{
	int len = v.size();

	for (int k = 0; k < len; ++k)
	{
		for (int i = 0; i < len; ++i)
		{
			for (int j = 0; j < len; ++j)
			{
				v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
			}
		}
	}
}

int dijkstra ( int s, int e, int size, vector< vector<edge> > &graph )
{
	priority_queue< P, vector<P>, greater<P> > que;
	vector<int> cost(size, INF);

	cost[s] = 0;
	que.push(P(0, s));

	while (!que.empty())
	{
		P p = que.top(); que.pop();
		int v = p.second;

		if (cost[v] < p.first) continue;

		for (int i = 0, ilen = graph[v].size(); i < ilen; ++i)
		{
			edge e = graph[v][i];
			if (cost[e.to] > (cost[v] + e.cost))
			{
				cost[e.to] = cost[v] + e.cost;
				que.push(P(cost[e.to], e.to));
			}
		}
	}

	return cost[e];
}

int main ( void )
{
	int n, k;

	while (cin >> n >> k, (n | k))
	{
		//VVI v(n, vector<int>(n, INF));
		vector< vector<edge> > v(n);

		for (int i = 0; i < k; ++i)
		{
			int x;

			cin >> x;

			if (x)
			{
				int c, d, e;

				cin >> c >> d >> e;

				--c; --d;

				v[c].push_back(edge(d, e));
				v[d].push_back(edge(c, e));
				
				//if ((v[c][d] > e) || (v[d][c] > e))
				//{
				//	v[c][d] = v[d][c] = e;
				//	wFloyd(v);
				//}
			}
			else
			{
				int a, b;

				cin >> a >> b;

				--a; --b;

				int cost = dijkstra(a, b, n, v);

				if (cost == INF)
				{
					cout << -1 << endl;
				}
				else
				{
					cout << cost << endl;
				}

				//if (v[a][b] == INF)
				//{
				//	cout << -1 << endl;
				//}
				//else
				//{
				//	cout << v[a][b] << endl;
				//}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1232
a, b = map(int, input().split())
c = 0
for i in range(a, b + 1):
    s = str(i)
    for j in range((len(s) + 1 )// 2):
        if s[j] != s[- 1 - j]:
            break
    else:
        c += 1
print(c)

Measured memory_bytes: 3060
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string line = " 3";
        for (int i = 4; i <= n; i++)
        {
            if (i % 3 == 0)
            {
                line = line + " " + i.ToString();
            }
            else if(INCLUDE3(i))
            {
                line = line + " " + i.ToString();
            }
        }
        Console.WriteLine(line);
        Console.ReadLine();
    }
    static bool INCLUDE3(int i)
    {
        while (true)
        {
            int divide = i / 10;
            if (i % 10 == 3)
            {
                return true;
            }
            else if (divide < 1)
            {
                return false;
            }
            else
            {
                i = divide;
            }
        }        
    }
}

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

int N,M;
int fid[500][500];
bool use[500] = {0};
int ans = 500;

void solve()
{
    for(int i = 1; i <= M + 1; i++)
    {
        if(i == M + 1)return;
        if(!use[i])break;
    }
    int sum[500] = {0};
    for(int i = 0; i < N; i++)
    {
        int mem;
        for(int j = M - 1; j >= 0; j--)
        {
            if(!use[fid[i][j]])mem = fid[i][j];
        }
        sum[mem]++;
    }
    int MAX = 0,res;
    for(int i = 1; i <= M; i++)
    {
        if(sum[i] > MAX)
        {
            MAX = sum[i];
            res = i;
        }
    }
    ans = min(ans,MAX);
    use[res] = true;
    solve();
    return;
}

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            scanf("%d",&fid[i][j]);
        }
    }
    solve();
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int x,y;
	cin >> x >> y;
	cout << x + y / 2 << endl;
}

Measured memory_bytes: 256
N = gets.to_s

def fil(l)
    l.include?(3) and l.include?(5) and l.include?(7)
end

a = 3
list = []

while a <= N.size
    list = list + [7,5,3].repeated_permutation(a).to_a.select{|x| fil(x)}
    a = a + 1
end

list2 = list.map{|x| x.join("").to_i}
list3 = list2.select{|x| x <= N.to_i}
p list3.size

Measured memory_bytes: 19864
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, int > Pi;
typedef pair< int, Pi > Pii;
const static int dy[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const static int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main()
{
  int H, W;
  char S[1000][1000];

  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    cin >> S[i];
  }

  queue< Pii > Que;
  int ret = 0;

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(S[i][j] == '.') Que.push(Pii(0, Pi(j, i)));
      else S[i][j] -= '0';
    }
  }
  while(!Que.empty()) {
    Pii& p = Que.front();
    ret = max(ret, p.first);
    for(int i = 0; i < 8; i++) {
      int ny = p.second.second + dy[i];
      int nx = p.second.first  + dx[i];
      if(ny >= 0 && ny < H && nx >= 0 && nx < W && S[ny][nx] != '.') {
        --S[ny][nx];
        if(S[ny][nx] == 0) {
          Que.push(Pii(p.first + 1, Pi(nx, ny)));
        }
      }
    }
    Que.pop();
  }
  cout << ret << endl;
  return(0);
}

Measured memory_bytes: 2472
#include<cstdio>
#include<algorithm>
#include<iostream>
#define maxn 200+1       
using namespace std;
int n,a[maxn],ans;      
int main()
{
    scanf("%d",&n);
    int md=n<<1;                //右移一位，相当于2*n。
    for(int i=1;i<=md;++i)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+md);           //对a数组排序。
    for(int i=1;i<=md;i+=2)
    { 
        ans+=a[i];             //当两数差最小时，ans才会最大，所以隔一个加一次。
    }
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

char s[200005];
int n;
int a[200005];

int main(){
	int i;
	scanf("%s",s + 1);
	n = strlen(s + 1);
	int len = 0;
	for(i = 1;i <= n;i++){
		if(s[i] == 'A')a[++len] = 1;
		else if(s[i] == 'B'){
			if(s[i+1] != 'C')a[++len] = 0;
			else continue;
		}
		else{
			if(s[i-1] == 'B')a[++len] = 2;
			else a[++len] = 0;
		}
	}
//for(i = 1;i <= len;i++)cout<<a[i];
//cout<<endl;
	long long ans = 0;
	int cur = 0,num = 0;
	for(i = 1;i <= len;i++){
		if(a[i] == 0){
			cur = 0;
			num = 0;
			continue;
		}
		else{
			cur++;
			if(a[i] == 2){
				num++;
				ans += 1ll * (cur - num);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
} 

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

int main() {
    int a, b;

    cin >> a >> b;

    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
def solve(ar_w,ar_v,n,w):
    dp = [[0] * (w+1) for _ in range(n+1)]

    for i in range(1,n+1):
        for j in range(0,w+1):
            dp[i][j] = max(dp[i][j],dp[i-1][j])
            if j-ar_w[i] >= 0:
                dp[i][j] = max(dp[i][j], dp[i-1][j-ar_w[i]] + ar_v[i])


    print(dp[n][w])


if __name__ == '__main__':
    n,w = map(int,input().split())
    ar_w = [0]
    ar_v = [0]
    for i in range(n):
        a,b = map(int,input().split())
        ar_w.append(a)
        ar_v.append(b)

    solve(ar_w,ar_v,n,w)

Measured memory_bytes: 149816
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 1030000;

    void solve() {
      ll n, k;
      cin >> n >> k;
      ll sum = 0;
      repA(i, k+1, n){
      //cout << (i-k)*(n/i) << " " << max(0ll, n%i - k + 1) << endl;
        sum+= max(0ll, i-k)*(n/i);
        sum+=max(0ll, n%i - k + 1);
        !k ? --sum:0;
      }
      cout << sum << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

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

void func(int y,int x){
  grid[y][x]='0';
  for(int i=0;i<4;i++)
    for(int j=1;j<4;j++)
      if(x+dx[i]*j<8 && y+dy[i]*j<8 && 
	 x+dx[i]*j>=0 && y+dy[i]*j>=0 && 
	 grid[y+dy[i]*j][x+dx[i]*j]=='1'){
	func(y+dy[i]*j,x+dx[i]*j);
	grid[y+dy[i]*j][x+dx[i]*j]='0';
      }
}

int main(void){
  int n,sx,sy;

  cin >> n;

  for(int t=1;t<=n;t++){
    for(int i=0;i<8;i++)cin >> grid[i];
    cin >> sx >> sy;
    func(--sy,--sx);
    cout << "Data " << t <<':'<<endl;
    for(int i=0;i<8;i++)cout << grid[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  int ans=int(n/1.08);
  if(int(ans*1.08)==n){
  	cout<<ans<<endl;
  }else if(int(++ans*1.08)==n){
  	cout<<ans<<endl;
  }else{
  	cout<<":("<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N, M; cin >> N >> M;
    vll H(N+1);
    for(int i=1; i<N+1; i++){
        cin >> H[i];
    }
    vvll e(N+1, vll(0));
    for(int i=0; i<M; i++){
        ll a, b; cin >> a >> b;
        e[a].emplace_back(b); e[b].emplace_back(a);
    }
    ll c= 0;
    for(int i=1; i<N+1; i++){
        ll h = H[i];
        bool m = true;
        for(auto x: e[i]){
            if(H[x] >= h){
                m = false;
            }
        }
        if(m){
            c++;
        }
    }
    cout << c;
}

Measured memory_bytes: 9856
s = list(input())
t = list(input())

sd = ""
td = ""

for i in range(len(s)):
    a = 0
    for j in range(len(s)):
        if s[j] < s[a]:
            a = j
    sd = sd + s.pop(a)

for i in range(len(t)):
    a = 0
    for j in range(len(t)):
        if t[a] < t[j]:
            a = j
    td = td + t.pop(a)

if sd < td:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
import sys

A, B, K = map(int, input().split())

if K > B-A:
    for i in range(A, B+1):
        print(i)
    sys.exit()

ans = set()
for i in range(A, A+K):
    ans.add(i)
for i in range(B-K+1, B+1):
    ans.add(i)
    
ans = list(ans)
ans.sort()

for i in ans:
    print(i)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> v;
    v.push_back(-a[0]);
    Rep(i, 1, n)
    {
        int pos = upper_bound(all(v), -a[i]) - v.begin();
        if (pos == v.size())
            v.push_back(-a[i]);
        else
            v[pos] = -a[i];
    }
    cout << v.size() << endl;
}

Measured memory_bytes: 2168
n,m=map(int,input().split())
broken=[]
for i in range(m):
  broken.append(int(input()))
b=set(broken)
l=[1]
for j in range(1,n+1):
  if j in b:
    l.append(0)
  elif j==1:
    l.append(1)
  else:
    l.append(l[j-2]+l[j-1])
print(l[n]%(10**9+7))

Measured memory_bytes: 460020
def main():

    H, W = map(int, input().split())
    A = []
    for _ in range(H): A.append(input())

    ans = 0
    visited = set()
    for i in range(H):
        for j in range(W):
            if (i, j) not in visited:
                visited.add((i, j))
                b, w = 0, 0
                if A[i][j] == "#":
                    b += 1
                    c = "."
                else:
                    w += 1
                    c = "#"
                cur = [[i, j]]
                while cur:
                    temp = []
                    for k1, l1 in cur:
                        for dk, dl in [[1,0],[-1,0],[0,1],[0,-1]]:
                            k, l = k1+dk, l1+dl
                            if 0<=k<H and 0<=l<W and (k,l) not in visited and A[k][l] == c:
                                visited.add((k,l))
                                temp.append([k, l])

                    if c == "#":
                        b += len(temp)
                        c = "."
                    else:
                        w += len(temp)
                        c = "#"
                    cur = temp
                ans += b*w
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 57180
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll x;
    cin>>x;
    ll m1 = x/500LL;
    x-= m1*500L;
    ll m2 = x/5;
    ll res = m1*1000L + m2*5LL;
    cout<<res;
	return 0;
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int MOD=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}


int n,m,up,c[13],a[13][13],ans=inf;

int main() {
	string s,t;
	int k;
	cin>>k>>s;
	int l=s.length();
	if(k<l){
		rep(i,0,k)t+=s[i];
		//print(t);
		rep(i,k,k+3)t+='.';
	}else{
		t=s;
	}
	print(t);






}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> a;
    map<int,int> mp;
    for(int i=1;i<n;++i){
        int val;
        cin>>val;
        mp[val]++;
    }
    for(int i=1;i<=n;++i)
        cout<<mp[i]<<'\n';
    return 0;

}

Measured memory_bytes: 12996
N, K = map(int, input().split())

h = list(map(int, input().split()))

dp = [N * (10**4)]*N
dp[0] = 0


for i in range(N-1):
    for j in range(1, K+1):
        if i + j < N:
            dp[i+j] = min(dp[i] + abs(h[i+j] - h[i]), dp[i+j])
print(dp[N-1])


Measured memory_bytes: 52592
// A - Poor
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c; cin>>a>>b>>c;
	set<int> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout<< (s.size()==2? "Yes":"No") <<endl;
}

Measured memory_bytes: 256
import sys
from math import sqrt
input = sys.stdin.readline
N = int(input())
p = []
for _ in range(N):
  p.append(list(map(int, input().split())))
def dist(x1, y1, x2, y2):
  return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
res = 0
vis = set()
c = 0
def fact(n):
  r = 1
  for i in range(1, n + 1):
    r *= i
  return r
def dfs(n):
  global vis
  global res
  global c
  for x in range(N):
    if x in vis: continue
    vis.add(x)
    res += dist(p[n][0], p[n][1], p[x][0], p[x][1]) * fact(N - len(vis))
    dfs(x)
    vis.discard(x)
  if len(vis) == N: c += 1

for y in range(N):
  vis.add(y)
  dfs(y)
  vis.discard(y)


print(res / c)

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

int main()
{
    int N;
    cin >> N;
    int can = 0;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==N) can = 1;
        }
    }
    if(can==1) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

Measured memory_bytes: 3636
w, h, n = map(int, input().split())

l = 0
r = w
d = 0
u = h

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1: l = max(l, x)
    if a == 2: r = min(r, x)
    if a == 3: d = max(d, y)
    if a == 4: u = min(u, y)

ans = max(0, r - l) * max(0, u - d)

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		scan.useDelimiter(",|//s|\n");
		int w = Integer.parseInt(scan.next());
		int n = Integer.parseInt(scan.next());
		int[] number = new int[w];
		for( int i = 0; i < w; i++){
			number[i] = i+1;
		}
		for( int i = 0; i < n; i++ ){
			int a = Integer.parseInt(scan.next()) - 1;
			int b = Integer.parseInt(scan.next()) - 1;
			int temp = number[a];
			number[a] = number[b];
			number[b] = temp;
		}
		for( int i = 0; i < w; i++ ){
			System.out.println(number[i]);
		}
		return;
	}
}

Measured memory_bytes: 17216
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	
    	Dice d = new Dice();
        Scanner sc = new Scanner(System.in);
        int i, top, frnt;
        
        for(i = 0; i < 6; i++) {
        	d.x[i] = sc.nextInt();
        }
        int n = sc.nextInt();
        
        for(i = 0; i < n; i++) {
        	top = sc.nextInt();
        	frnt = sc.nextInt();
        	int rslt = solve(top, frnt, d.x);
        	System.out.println(rslt);
        }
    }
    
    public static int solve(int a, int b, int dice[]) {
    	int ans = -1;
    	if(a == dice[0] || a == dice[5])
    		if(b == dice[1]) 
    			ans = dice[2];
    		else if(b == dice[2]) 
    			ans = dice[4];
    		else if(b == dice[4]) 
    			ans = dice[3];
    		else
    			ans = dice[1];
    	else if(a == dice[1] || a == dice[4])
    		if(b == dice[2])
    			ans = dice[0];
    		else if(b == dice[0])
    			ans = dice[3];
    		else if(b == dice[3])
    			ans = dice[5];
    		else
    			ans = dice[2];
    	else if(a == dice[2] || a == dice[3])
    		if(b == dice[0])
    			ans = dice[1];
    		else if(b == dice[1])
    			ans = dice[5];
    		else if(b == dice[5])
    			ans = dice[4];
    		else
    			ans = dice[0];
    	
    	if(a == dice[5])
    		ans = dice[0] + dice[5] - ans;
    	else if(a == dice[4])
    		ans = dice[0] + dice[5] - ans;
    	else if(a == dice[3])
    		ans = dice[0] + dice[5] - ans;
    	
    	return ans;
    }
}


class Dice{
	public int x[] = new int[6];
	int tmp1, tmp2;
	
	public void roll(char direction) {
		switch(direction) {
		case 'E':
			tmp1 = x[0];
    		x[0] = x[3];
    		tmp2 = x[2];
    		x[2] = tmp1;
    		tmp1 = x[5];
    		x[5] = tmp2;
    		x[3] = tmp1;
    		return;
    		
		case 'S':
			tmp1 = x[0];
    		x[0] = x[4];
    		tmp2 = x[1];
    		x[1] = tmp1;
    		tmp1 = x[5];
    		x[5] = tmp2;
    		x[4] = tmp1;
    		return;
		
		case 'W':
			tmp1 = x[0];
    		x[0] = x[2];
    		tmp2 = x[3];
    		x[3] = tmp1;
    		tmp1 = x[5];
    		x[5] = tmp2;
    		x[2] = tmp1;
    		return;
    		
		case 'N':
			tmp1 = x[0];
    		x[0] = x[1];
    		tmp2 = x[4];
    		x[4] = tmp1;
    		tmp1 = x[5];
    		x[5] = tmp2;
    		x[1] = tmp1;
    		return;
		}
	}
}



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

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

    m = n;
    while(m){
        s += m % 10;
        m /= 10;
    }
    cout << (n % s == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>

using namespace std;

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

ll arr[100010] = {};

ll func(ll a) {
	return (a + 1)*a / 2;
}


int main() {

	string str;
	cin >> str;

	ll arr['z' - 'a' + 1] = {};

	for (int i = 0; i < str.size(); i++) {
		arr[str[i] - 'a']++;
	}

	ll ans = func(str.size()-1);

	for (int i = 'a'; i <= 'z'; i++) {
		ans -= func(arr[i - 'a']-1);
	}

	cout << ans+1 << endl;
}



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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    string s;
    cin >> s;
    Yes(s.substr(0, 4) == "YAKI");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 1e6+6;
int cnt[N];
int a[N];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    long long ans = 0;
    for(int i=0;i<N;i++){
        long long trt = cnt[i];
        if(cnt[i]==0)continue;
        trt = (trt)*(trt-1)/2ll;
        ans+=trt;
    }
    for(int i=0;i<n;i++){
        cout<<max(0ll,ans-cnt[a[i]]+1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector <int> v[200000];
int memo[200000];
int ans;
void dfs(int x){
    if(memo[x]!=-1)return;
    int y=0;
    for(int i=0;i<v[x].size();i++){
        int node=v[x][i];
        dfs(node);
        y=max(memo[node],y);
    }
    y+=1;
    memo[x]=y;
    ans=max(ans,y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    while(m--){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }
    for(int i=1;i<=n;i++)memo[i]=-1;
    ans=0;
    for(int i=1;i<=n;i++){
        dfs(i);
    }
    cout<<ans-1;
    return 0;
}

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

int main(){
	while(1){
		int n, m;
		int r[501][501]={0}; //relationship
		int invite[501]={0};
		
		scanf(" %d %d", &n, &m);
		if(n==0) break;
		for(int i=0; i<m; ++i){
			int a, b;
			scanf(" %d %d", &a, &b);	
			r[a][b]=r[b][a]=1;	
		}
		
		int ans=0;
		for(int i=2; i<=n; ++i){
			if(r[1][i]==1){	
				
				if(invite[i]==0){
					invite[i]=1;
					++ans; //友達を招待
				}
				
				for(int j=2; j<=n; ++j){
					if(r[i][j]==1 && invite[j]==0){	
						invite[j]=1;
						++ans; //友達の友達を招待
					}
				}
			}
		}
		printf("%d\n", ans);
		
	}
	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
int main()
{
    long long sum,n,m;
    scanf("%lld%lld",&n,&m);
    if(n==1)
    {
        if(m==1)
            printf("1\n");
        else
            printf("%lld\n",m-2);
    }
    else if(m==1)
    {
        printf("%lld\n",n-2);
    }
    else
    {
        sum=n*m;
        sum-=(n+m-2)*2;
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
n = int(input())
import heapq
big_list = list(map(int,input().split()))
small_list = []
heapq.heapify(big_list)
heapq.heapify(small_list)
while len(big_list) > n//2:
  heapq.heappush(small_list,heapq.heappop(big_list)*(-1))

b = heapq.heappop(big_list)
s = heapq.heappop(small_list)
if b == -s:
  print(0)
elif b + s > 0:
  print(b+s)

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

using namespace std;
using ii = pair<int, int>;
using ll = long long;

int const NMAX = 1e5 + 11;

int        n;
ll         dist[NMAX];
vector<ii> g[NMAX];

void dfs(int u, int p = -1, ll d = 0)
{
    dist[u] = d;
    for (auto [v, c] : g[u])
        if (v != p)
            dfs(v, u, d + c);
}

int main(void)
{
    int q, k, u, v, c;
    cin >> n;
    for (int i = 0; i < n - 1; ++i)
    {
        cin >> u >> v >> c, u--, v--;
        g[u].emplace_back(v, c);
        g[v].emplace_back(u, c);
    }

    cin >> q >> k, k--;

    dfs(k);
    while (q--)
    {
        cin >> u >> v, u--, v--;
        cout << dist[u] + dist[v] << endl;
    }

    return 0;
}


Measured memory_bytes: 14492