akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
        A[i]=(A[i]-1+K)%K;
    }
    vector<int> sum(N+1);
    sum[0]=0;
    rep(i,N) sum[i+1]=(sum[i]+A[i])%K;
    map<ll,ll> m;
    ll ans=0;
    rep(i,N+1){
        ++m[sum[i]];
        if (i-K>=0) --m[sum[i-K]];
        ans+=m[sum[i]]-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15104
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int N;
	cin >> N;
	int B[110];
	int sum=0;
	for(int i=0; i<N-1; i++){
		cin >> B[i];
	}
	
	for(int j=1; j<N-1; j++){
		sum = sum+min(B[j-1],B[j]);
	}
	
	int ans=0;
	
	ans = sum+B[0]+B[N-2];
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 200005
using namespace std;
int a[MAXN];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int last=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==last+1)
            last++;
    }
    if(last==0)
        cout<<-1;
    else
        cout<<n-last;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m;
int a[300010];
int main()
{
	int n, m;
	int gap = 1234567890;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		gap = min(gap, a[i]);
	}
	int dap = 0;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] == gap&&a[i+1]==gap)continue;
		if (a[i]==gap&&i == n)continue;
		int update = 0;
		for (int y = i; y <= i+m - 1; y++)
			if (a[y] == gap)update = 1;
		if(update)
		a[i + m - 1] = gap;
		i += (m-2);
		dap++;
	}
	printf("%d", dap);
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, A, B;
	string ans;

	cin >> N >> A >> B;

	if ((B - A) % 2 == 0) ans = "Alice";
	else ans = "Borys";

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import Control.Monad

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  ss <- replicateM h getLine
  let bs = [(x, y) | x <- [0..(w - 1)], y <- [0..(h - 1)], (ss !! y) !! x == '#']
  let solve x y = head . show . sum $ map (\n -> if abs (x - fst n) <= 1 && abs (y - snd n) <= 1 then 1 else 0) bs
  mapM_ putStrLn [[if (ss !! y) !! x == '#' then '#' else solve x y | x <- [0..(w - 1)]] | y <- [0..(h - 1)]]


Measured memory_bytes: 1148
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	// INFILE();
  ll a, b, x;
  cin >> a >> b >> x;

  // cout << (b / x) - ((a - ((a == 0) ? 0 : 1)) / x) + ((a == 0) ? 1 : 0) << endl;
	cout << (b / x) - (a / x) + ((a % x == 0) ? 1 : 0) << endl;
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;

  int i;long long  sum = 0;
    if(k>=n)
        cout<<"0"<<endl;
    else
    {
        int cnt = 0;
        int  a[n];
        for(i = 0;i < n;i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
        sort(a,a+n);
        for(i = n-1;cnt<k;i--,cnt++)
        {
            sum-=a[i];

        }
        cout<<sum<<endl;
    }

}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}

int N,Ma,Mb;
int dp[41][401][401];
int main()
{
	cin>>N>>Ma>>Mb;

	int a[N],b[N],c[N];

	REP(i,0,N){
		cin>>a[i]>>b[i]>>c[i];
	}
	

	REP(i,0,N+1){
		REP(j,0,401){
			REP(k,0,401){
				dp[i][j][k]=INF;
			}
		}
	}
	dp[0][0][0]=0;

	
	REP(i,0,N){
		REP(j,0,401){
			REP(k,0,401){
					if(dp[i][j][k]==INF) continue;
					dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]);
					dp[i+1][j+a[i]][k+b[i]]=min(dp[i][j][k]+c[i],dp[i+1][j+a[i]][k+b[i]]);
				}
			}
		}
	
	int ans=INF;
	REP(j,1,401){
				REP(k,1,401){
					
						if(k*Ma==j*Mb){
							ans=min(ans,dp[N][j][k]);
							break;
						}
				}
			}
	
	if(ans==INF){
		ans=-1;
	}
	cout<<ans<<endl;

	
	
	
	

	return 0;
}

Measured memory_bytes: 25984
import itertools
import math
n = int(input())
x,y = [0]*n,[0]*n
for i in range(n):
  x[i],y[i] = map(int,input().split())
lis = [x for x in range(n)]
permutation_lis = itertools.permutations(lis)
ans = 0
div = math.factorial(n)
def eucleid_dist(a,b):
  return  math.sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)
for path in permutation_lis:
  dist = 0
  for i in range(n-1):
    a = (x[path[i+1]],y[path[i+1]])
    b = (x[path[i]],y[path[i]])
    dist += eucleid_dist(a,b)
  ans += dist/div
print(ans)


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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    long long a;

    cin >> a;

    long long b;

    cin >> b;

    if(a>b) {

        cout << "safe" << '\n';

    } else {

        cout << "unsafe" << '\n';

    }

    return 0;

}



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

int main(){
    int n;
    cin >> n;
    vector < int > a(n);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        if(i % 2 != 0 && x % 2 != 0) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int d[512][512];
int main() {
  int N, M, Q, L, R, p, q;
  cin >> N >> M >> Q;
  for (int i=0; i<M; i++) {
    cin >> L >> R;
    d[1][R]++;
    d[L+1][R]--;
  }
  for (int j=1; j<=N; j++) {
    for (int i=1; i<=N; i++) {
      d[i][j] += d[i-1][j];
      d[i][j] += d[i][j-1];
      d[i][j] -= d[i-1][j-1];
    }
  }
  for (int i=0; i<Q; i++) {
    cin >> p >> q;
    cout << d[p][q] << endl;
  }
}

Measured memory_bytes: 1920
// AtCoder Beginner Contest 129 - Problem B: Balance (https://atcoder.jp/contests/abc129/tasks/abc129_b)
#include <bits/stdc++.h>

using namespace std;

int solve(int N, const vector<int>& xs)
{
    int a = 0, b = 0;

    for (int i = 0; i < N; ++i)
        b += xs[i];

    int ans = b, L = 0;

    while (L < N)
    {
        int R = L;

        while (R < N and xs[R] == xs[L])
        {
            a += xs[R];
            b -= xs[R];
            ++R;
        }

        ans = min(ans, abs(b - a));
        L = R;
    }
 
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = solve(N, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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



int main() {
	ll n;
	cin >> n;
	int even = 0, odd = 0;

	rep(i, n) {
		ll x;
		cin >> x;
		if (x % 2 == 0) even++;
		else odd++;
	}

	if (odd % 2 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<list>
#define PB push_back
#define rep(i,x) for(int i=0;i<x;i++)
using namespace std;
int main(){
    int n,m;
    while(cin>>n>>m,n||m){
        vector<vector<int> >H(n+1);
        list<int>L1,L2;
        int a,b;
        while(m--){
            cin>>a>>b;
            H[a].PB(b);
            H[b].PB(a);
        }
        rep(i,H[1].size())L1.PB(H[1][i]);
        list<int>::iterator ite=L1.begin();
        for(;ite!=L1.end();ite++){
            rep(i,H[*ite].size()){
                L2.PB(H[*ite][i]);
            }
        }
        L1.sort();L2.sort();
        L1.merge(L2);
        L1.unique();
        int ans=L1.size();
        if(ans>0)ans--;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1408
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			PriorityQueue<Integer> Q=new PriorityQueue<Integer>(Collections.reverseOrder());
			
			while(sc.hasNext()) {
				String str=sc.next();
				if(str.equals("end")) {
					break;
				}
				if(str.equals("insert")) {
					int value=sc.nextInt();
					Q.add(value);
				}
				else {
					System.out.println(Q.poll());
				}
			}
			

		}
	}
}



Measured memory_bytes: 579524
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

const int maxn = 8 + 2;
char s[maxn][maxn];

int n, m;

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  return 1;
}

void solve() {
  int x = 0, y = 0;
  for (; x + y < n + m - 2;) {
    if (s[x][y] != '#') {
      printf("Impossible\n");
      return;
    }
    if (x < n && s[x + 1][y] == '#') {
      x += 1;
      continue;
    }
    if (y < m && s[x][y + 1] == '#') {
      y += 1;
      continue;
    }
    printf("Impossible\n");
    return;
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += count(s[i], s[i] + m, '#');
  }
  if (cnt != n + m - 1) {
    printf("Impossible\n");
    return;
  }
  printf("Possible\n");
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main() {


string s;

cin>>s;

for(int i=0;i<3;i++) {
	if(s[i]=='7'){
		cout<<"Yes";
		return 0;
	}
}

cout<<"No";
	return 0;
}

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

int main(){
    map<string, int> M;
    int N;
    cin >> N;
    M["AC"] = M["WA"] = M["TLE"] = M["RE"] = 0;
    while(N--){
        string str; cin >> str;
        ++M[str];
    }
    cout << "AC x " << M["AC"] << endl;
    cout << "WA x " << M["WA"] << endl;
    cout << "TLE x " << M["TLE"] << endl;
    cout << "RE x " << M["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vl vec(n);
    REP(i,n){
        cin>>vec[i];
    }
    ll dp[n][n];
    REP(i,n){
        REP(j,n){
            dp[i][j]=LINF;
        }
        dp[i][i]=0;
    }
    REP(len,n){
        REP(i,n){
            int j=i+len;
            if(j>=n){
                break;
            }
            ll sum=0;
            FOR(k,i,j+1){
                sum+=vec[k];
            }
            FOR(k,i,j){
                chmin(dp[i][j],dp[i][k]+dp[k+1][j]+sum);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int m,n,q,A[20];
int ans(int x,int y){
  if(x==0)return 0;
  if(y>=n)return 1;
  if(ans(x,y+1)==0 || ans(x-A[y],y+1)==0)return 0;
  else return 1;
}
 
main(){ 
  cin>>n; 
  for(int i=0;i<n;i++)cin>>A[i];
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>m;
    if(ans(m,0)==0)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
}

Measured memory_bytes: 1152
#include <iostream>
#include <cmath>
using namespace std;
int main() {
  int n;
  cin >> n;
  
  int max_profit = - 2 * pow(10,9);
  int min_price;
  cin >> min_price;
  
  int Rt;
  for (int t = 1; t < n; t++){
      cin >> Rt;
      if(max_profit < Rt - min_price) max_profit = Rt - min_price; 
      if(min_price > Rt) min_price = Rt;
  }

  cout << max_profit << endl;
  return 0;
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    bool dp[k+1];
    memset(dp,false,sizeof dp);

    for(int i=0;i<=k;i++)
    {
        for(auto p:arr)
        {
             if((i>=p) && (dp[i-p]==false))
                 dp[i]=true;
        }
    }
    if(dp[k]==false)
        cout<<"Second"<<endl;
    else
        cout<<"First"<<endl;
    return 0;
}


Measured memory_bytes: 3772
n, m = [int(i) for i in input().split()]

l = sorted([int(i) for i in input().split()])

d_l = []
if n >= m:
  print(0)
else:
  for i in range(m-1):
    delta = l[i+1] - l[i]
    d_l.append(delta) 
  d_l = sorted(d_l, reverse=True)
  print(sum(d_l[n-1:]))

Measured memory_bytes: 13840
#include<bits/stdc++.h>
using namespace std;
long long calc(long long n,long long m){
	if(m < 2 * n)
		return m/2;
	m -= 2 * n;
	return n + m / 4;
}
int main(){
	long long n,m;
	cin>>n>>m;
	cout<<calc(n,m)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    map<ll, ll> l, r;
    rep(i, n)
    {
        l[i + a[i]]++;
        r[i - a[i]]++;
    }

    ll ans = 0;
    rep(i, n)
    {
        ans += l[i] * r[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 46620
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum[200000], ans, dp[40000],a[1000][1000],b[200000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<LL>vec;
vector<edge>ed;
vector<LL>v;
map<LL,LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
			ans+=(i + 1)*(h - i)*(j + 1)*(w - j)*a[i][j];
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 7076
import java.math.BigDecimal;
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double x = scan.nextDouble();
        double y = scan.nextDouble();
        double x2 = scan.nextDouble();
        double y2 =  scan.nextDouble();
        double result = Math.sqrt(((x - x2) *(x - x2)) + ((y - y2) * (y - y2)));
        if(BigDecimal.valueOf(result).scale() > 8) {
            System.out.printf("%.8f", result);
        }
        else{
            System.out.print(result);
        }
        System.out.println();
    }
}


Measured memory_bytes: 28256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll N=500001;
int n,q,c[N],l[N],r[N],a[N],b[N],ans[N];
vector<pair<int,int> > x[N];

void add(int x,int v){
  for(int i=x;i<=n;i+=i&(-i))
    b[i]+=v;
}

int sum(int x){
  int v=0;
  for(int i=x;i>0;i-=i&(-i))v+=b[i];
  return v;
}

int main(){
  ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
  cin>>n>>q;
  for(int i=1;i<=n;i++)cin>>c[i];
  for(int i=1;i<=q;i++){
    cin>>l[i]>>r[i];
    x[r[i]].emplace_back(l[i],i);
  }
  for(int i=1;i<=n;i++){
    if(a[c[i]])add(a[c[i]],-1);
    a[c[i]]=i;
    add(i,1);
    for(auto [d,e]:x[i])ans[e]=sum(i)-sum(d-1);
  }
  for(int i=1;i<=q;i++)cout<<ans[i]<<'\n';
  return 0;
}

Measured memory_bytes: 37148
#include<bits/stdc++.h>
//#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;
ll *arr=new ll[10000000+100];
//bool isprime[100000000];
/*bool isprime(int n)
{
    if(n<=1) return false;
    else if(n==2) return true;
    else if(n%2==0) return false;
    else
        return true;
}
void sieve(int n)
{
    for(int i=0;i<=n;i++) isprime[i]=true;
    for(int i=2;i*i<=n;i++)
    {
        if(isprime[i])
        {
            for(int j=i*i;j<=n;j=j+i)
            {
                isprime[j]=false;

            }
        }
    }

} */
void SOD(int n)
{
    //int *arr=new int[n+1];


    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j=j+i)
        {
            arr[j]=arr[j]+1;
        }
    }
    //return arr[n];
}

int main()
{
    SOD(10000000);
   // int t;
    //cin>>t;
    //while(t--)
   // {
        ll n;
        cin>>n;
        ll sum=0;
        //int res=SOD(n);
       // for(int i=0;i<=n;i++) cout<<isprime[i]<<" ";
    //cout<<endl;
       // cout<<"res: "<<isprime[n]<<endl;
      // cout<<arr[n]-n<<endl;
     // int res=arr[n];
      for(ll i=1;i<=n;i++)
      {
          ll temp=i*arr[i];
         sum=sum+temp;//((ll)(i*arr[i]));
      }
      cout<<sum<<endl;
   // }



    return 0;
}


Measured memory_bytes: 81732
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
//max_element


signed main()
{
	int N, M;
	cin >> N >> M;

	int ml = INT_MIN;
	int mr = INT_MAX;
	REP(i, M)
	{
		int l, r;
		cin >> l >> r;
		ml = max(ml, l);
		mr = min(mr, r);
	}
	cout << (max(-1LL, mr - ml) + 1) << endl;
}



Measured memory_bytes: 3096
// #pragma GCC optimize("Ofast,unroll-all-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define all(v) v.begin(), v.end()
#define len(v) ((int)(v).size())
#define pb push_back
#define kek pop_back
#define pii pair<int, int>
#define mp make_pair
// #define int ll

#define debug(x) cout << #x << " = " << x << endl;

const int INF = (is_same<int, ll>::value ? 1e18 + 666 : 1e9 + 666);

// const int MEM_SIZE = 1e8;
// char mem[MEM_SIZE];
// int cur_mem_ptr = 0;

// void* operator new(size_t n) {
//     cur_mem_ptr += n;
//     return mem + cur_mem_ptr - n;
// }

// void operator delete(void*) noexcept {}
// void operator delete(void*, size_t) noexcept {}

template<class t1, class t2>
bool cmin(t1 &a, const t2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class t1, class t2>
bool cmax(t1 &a, const t2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#ifndef LOCAL
void UseFiles(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
#else
void UseFiles(const string&) {}
#endif

void run();

signed main() {
    // UseFiles("squads");
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
}

void run() {
    int a, b;
    cin >> a >> b;
    if (a <= b) {
        cout << "un";
    }
    cout << "safe" << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
#define f first
#define s second
typedef pair<int,int> pii;
const int N=1e5+5;
const int mod=998244353;
const ll inf=1e18+7;
int n,w[105],W;ll v[105],dp[N];
int main()
{
    scanf("%d%d",&n,&W);
    forn(i,1,n){
        scanf("%d%d",&w[i],&v[i]);
        ford(j,W,w[i]+1){
            if(dp[j-w[i]]){
                dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
            }
        }
        dp[w[i]]=max(dp[w[i]],v[i]);
    }
    ll mx=0;
    forn(i,1,W){
        mx=max(mx,dp[i]);
        //printf("dp[%d]:%lld\n",i,dp[i]);
    }
    printf("%lld\n",mx);
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	int k[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	scanf("%d",&n);
	printf("%d",k[n-1]);
	return 0;
} 

Measured memory_bytes: 128
N = int(input())
ans = 1000000000001

for i in range(int(N**0.5)):
  if N % (i+1) == 0:
    A = N / (i+1)
    B = (i+1)
    if A + B - 2 < ans:
      ans = int(A + B - 2)
print(ans)

Measured memory_bytes: 3060
def papers_please():
    # 入力
    N = int(input())
    A = list(map(int, input().split()))
    # 処理
    for one_num in A:
        # 偶数
        if one_num % 2 == 0:
            # 3 or 5 で割り切れる
            if one_num % 3 == 0 or one_num % 5 == 0:
                pass
            # 割り切れない
            else:
                return 'DENIED'
        # 奇数
        else:
            pass
    # 3 or 5 で割り切れない偶数がない場合
    return 'APPROVED'

result = papers_please()
print(result)

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

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n) rep(j, d) cin >> x[i][j];
  int ans = 0;
  rep(i, n) rep(j, i) {
    int temp = 0;
    rep(k, d) {
      int y = x[i][k] - x[j][k];
      temp += y * y;
    }
    int r = sqrt(temp) + 0.5;
    if (r*r == temp) ans++;
  }
  cout << ans << '\n';
  return 0;
}

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

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

	int houses[4][3][10] = {};
	for( int i = 0; i < n; ++i ) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;

		houses[b-1][f-1][r-1] += v;
	}

	for( int i = 0; i < 4; ++i ) {
		for( int j = 0; j < 3; ++j ) {
			for( int k = 0; k < 10; ++k ) {
				cout << ' ' << houses[i][j][k];
			}

			cout << endl;
		}

		if( i < 3 ) {
			cout << "####################" << endl;
		}
	}
}



Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll a[40];
    a[0]=1;a[1]=1;a[2]=2;
    rep(i,30)a[i+3]=a[i+2]+a[i+1]+a[i];
    int n;
    while(cin>>n,n!=0){
        cout<<(a[n]+3649)/3650<<endl;
    }
    return 0;
}



Measured memory_bytes: 3108
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	double a;
	cin >> a;
	cout << fixed << setprecision(15) <<8*atan(1)*a;
}













Measured memory_bytes: 3804
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>


#define DEBUG 1
#define OUT


#if DEBUG
    #define LOG(...) {printf(__VA_ARGS__); printf("\n");}
    #define print_int_array(arr, n) {\
                for (int k = 0; k < n; ++k) {\
                    std::cout << std::setw(2) << arr[k] << " ";\
                }\
                    std::cout << "\n";\
                }
#else
    #define LOG(...) {}
    #define print_int_array(arr, n) {}
#endif




int main(int argc, char** argv)
{
    int n, W;
    std::cin >> n >> W;

    int w[n+1], v[n+1];

    for (int i = 1; i <= n; ++i) {
        std::cin >> w[i] >> v[i];
    }

    long long dp[n+1][W+1];
    for (int i = 0; i <= W; ++i) dp[0][i] = 0;
    for (int i = 1; i <= n; ++i) dp[i][0] = 0;

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= W; ++j) {
            if (w[i] <= j) {
                dp[i][j] = std::max(v[i] + dp[i-1][j - w[i]], dp[i-1][j]);
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    std::cout << dp[n][W];




    return 0;
}

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

using namespace std;

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

typedef pair<int, int> pii;
typedef vector<pii> vp;

int main() {
	while (true) {
		int n, m;
		cin >> n;
		if (n == 0) break;
		cin >> m;
		
		vector<vp> g(n);
		REP(i, m) {
			int a, b, c;
			scanf("%d,%d,%d", &a, &b, &c);
			g[a].push_back(pii(c / 100, b));
			g[b].push_back(pii(c / 100, a));
		}
	
		priority_queue<pii, vector<pii>, greater<pii> > qu;
		vector<bool> used(n);
		int ans = 0;
		
		qu.push(pii(0, 0));
		while (! qu.empty()) {
			int cost = qu.top().first;
			int pos = qu.top().second;
			qu.pop();
			
			if (used[pos]) continue;
			used[pos] = true;
			
			ans += cost;
			
			REP(i, g[pos].size()) {
				qu.push(pii(g[pos][i].first, g[pos][i].second));
			}
		}
		
		cout << ans - (n-1) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1540
using System;
using System.Linq;

namespace ABC072
{
    class D
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] P = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int res = 0;
            for (int i = 0; i < N; i++)
            {
                if (P[i] == i + 1)
                {
                    if (i < N - 1)
                    {
                        int tmp = P[i + 1];
                        P[i + 1] = P[i];
                        P[i] = tmp;
                    }
                    res++;
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 18016
function main(input) {

  let list = input.split("\n")[1].split(' ').map(x => parseInt(x));
  console.log(list.join(" "));
  for (let i = 1; i < list.length; i++) {
    let v = list[i];
    let j = i - 1;

    while (j >= 0 && list[j] > v) {
      list[j + 1] = list[j];
      j--;
    }
    list[j + 1] = v;
    console.log(list.join(" "));
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 17160
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int s;
    cin >> s;
    int a[1000000];
    a[0] = s;
    for (int i = 0; i < 1000000; i++) {
        if (a[i] % 2 == 0) {
            a[i + 1] = a[i] / 2;
        } else {
            a[i + 1] = 3 * a[i] + 1;
        }
        if (a[i] == 4 || a[i] == 2 || a[i] == 1) {
            cout << i + 4 << endl;
            return 0;
        }
    }
	return 0;
}

Measured memory_bytes: 256
my ($n, $m) = split(/\s+/, <>);
my $b = $n-1; $b=2 if $n==4;
for my $a (1..$m) {
    print $a, " ", $b--, "\n";
    if ($n%2==0 && $a==int(($n-1)/4)) { $b--; }
}


Measured memory_bytes: 4876
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;
int inf=1<<29;
long long llinf=1ll<<60;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp(*(char **)a,*(char **)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp(*(char **)b,*(char **)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int a=in();
    print(a%2?a*2:a);
    return 0;
}	

Measured memory_bytes: 128
// https://qiita.com/e869120/items/eb50fdaece12be418faa

#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll start;
    vector<ll> a(n-1);
    rep(i, n) {
        if (i == 0) cin >> start;
        else cin >> a[i-1];
    }

    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll res = LINF;
    for (int bit = 0; bit < (1 << n - 1); ++bit) {
        ll maxh = start;
        ll sum = 0;
        ll cnt = 1;
        for (int i = 0; i < n - 1; i++) {
            if (bit & (1 << i)) {
                cnt++;
                if (a[i] <= maxh) {
                    sum += maxh - a[i] + 1;
                    maxh += 1;
                }
                else {
                    sum += 1;
                    maxh = a[i] + 1;
                }
            }
            else {
                if (a[i] > maxh) {
                    cnt++;
                    maxh = a[i];
                }
            }
        }
        if (cnt >= k) chmin(res, sum);
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
H[1000010][27];h;
char*s,T[1200010],*S[200010]={T};
U[1200010];n,k;
i,j;
main(){
  for(;~scanf("%s",S[n]);S[++n]=s+1)
    for(k=0,s=S[n];*s;++s)
      U[s-T]=k|=1<<(*s-=96);
  for(i=0;i<2;++i)
    for(k=0,s=S[n];s-->=S[1];k=(H[k][*s]=*s?H[k][*s]?:++h:!!k)*!!*s)
      for(j=0;++j<i*27;)
        n-=U[s-T]>>j&1&&H[H[k][j]][0];
  printf("%d",1-n);

  // printf("\n");
  // for(k=0;k<=h;++k) {
  //   printf("%d\t", k);
  //   for(n=0;n<=26;n==3?n+=20:++n) printf("%8x ", H[k][n]);
  //   printf("\n");
  // }

}

// printf("%d\n", __builtin_popcount(123));

// for(s=S[1]-1;s<S[n];++s)
  // printf("<%c>(%x) ",*s+!!*s*96,U[s-*S]);


/*
H[1000010][27];h;
char*s,T[1200010],*S[200010]={T};
n,k;
main(){
  for(;~scanf("%s",S[n]);)
    S[++n]=S[n]+strlen(S[n])+1;
  for(s=S[n];s-->S[1];)
    k=*s?H[k][*s-=96]=H[k][*s]?:++h:0;
  for(k=0,s=S[1];s<S[n];++s){
    k=*s?k|1<<*s:0;
    printf("<%c>%d(%x) ",*s+!!*s*96,1<<*s,k);
  }
}
*/

Measured memory_bytes: 111908
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll a,b,c;cin>>a>>b>>c;
	if((a==b && b!=c) || (a==c && b!=c)||(c==b && b!=a)) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 256
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n;
    while(cin>>n) printf("%d\n",n*n*n);
	return 0;
}


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

string city_ID(int i, int num) {
  string s1 = to_string(i);
  string s2 = to_string(num);
  
  while (s1.size() < 6) {
    s1 = '0' + s1;
  }
  while (s2.size() < 6) {
    s2 = '0' + s2;
  }
  
  return s1 + s2;
}

int main() {
  int N, M;
  cin >> N >> M;
  using city = pair<int, int>; // (Yi, i)の順
  using province = priority_queue<city, vector<city>, greater<city>>;
  vector<province> Pro(N + 1); // 県の番号iを1~Nとするため
          
  int P, Y;
  for (int i = 1; i <= M; i++) {
    cin >> P >> Y;
    Pro.at(P).push(city(Y, i));
  }
  
  vector<string> city_num(M + 1); // city_num[i]に市iの識別番号を入れる
  
  for (int i = 1; i <= N; i++) { // iは県の番号
    int j; // jは市の番号
    int num = 1; // 市jが何番目に生まれたか
    while(!Pro.at(i).empty()) {
      j = Pro.at(i).top().second; // jは市の番号
      city_num.at(j) = city_ID(i, num);
      Pro.at(i).pop();
      num++;
    }
  }
  
  for (int i = 1; i <= M; i++) {
    cout << city_num.at(i) << endl;
  }
}

Measured memory_bytes: 13184
#include <stdio.h>
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,m[N][N],color[N],d[N],f[N],time;

void visit(int u)
{
int v;
  color[u]=GRAY;
  d[u]=++time;
  for(v=0;v<n;v++){
    if(m[u][v]==0) continue;
    if(color[v]==WHITE){
        visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++time;
}

void dfs(void)
{
int u;
  for(u=0;u<n;u++) color[u]=WHITE;
  time=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE) visit(u);
  }
  for(u=0;u<n;u++){
      printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
   int i,j,u,k,num;
   scanf("%d",&n);

    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            m[i][j]=0;
        }
    }

    for(i=0;i<n;i++){
      scanf("%d %d",&u,&k);
      u--;
      for(j=0;j<k;j++){
      scanf("%d",&num);
      num--;
      m[u][num]=1;
      }
    }
    dfs();

    return 0;
}




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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n;
    cin >> n;

    for (ll i_h = 1; i_h <= 3500; i_h++) {
        for (ll i_n = 1; i_n <= 3500; i_n++) {

            double i_w = (double)(i_h*i_n*n) / (double)(4*i_h*i_n - n*i_n - n*i_h);
            if (i_w < 0 || i_w > 3500) continue;

            if (ceil(i_w) == floor(i_w)) {
                cout << fixed << i_h << " " << i_n << " " << (ll)i_w << endl;
                exit(EXIT_SUCCESS);
            }
        }
    }
}



Measured memory_bytes: 256
x, k, d = map(int, input().split())

if abs(x) >= k * abs(d):
  print(min(abs(x - k * d),abs(x + k * d)))
else:
  n = abs(x) // abs(d)
  if (k - n) % 2 == 1:
    n += 1
  print(min(abs(x - n * d),abs(x + n * d)))

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

const int maxN = 100005;
const int oo=1e9+7;
int dp[maxN][4];
int a[maxN][4];
int n;

int main()
{
    //freopen("Vacation.inp","r",stdin);
    //freopen("Vacation.out","w",stdout);

    cin >> n;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=3; j++){
            cin >> a[i][j];
            dp[i][j]=-oo;
        }

    for (int j=1; j<=3; j++)
        dp[0][j]=0;

    //Tinh bang phuong an dp[i][j]
    for (int i=1; i<=n; i++){
        for (int j=1; j<=3; j++){
            if (j==1)
                dp[i][j]=max(a[i][j]+dp[i-1][2], a[i][j]+dp[i-1][3]);
            if (j==2)
                dp[i][j]=max(a[i][j]+dp[i-1][1], a[i][j]+dp[i-1][3]);
            if (j==3)
                dp[i][j]=max(a[i][j]+dp[i-1][2], a[i][j]+dp[i-1][1]);
        }
    }
    cout << max(dp[n][1],max(dp[n][2],dp[n][3]));
    return 0;
}


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

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

int main(void) {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> a(m);
	vector<int> num(100);
	REP(i, m) {
		cin >> a[i];
		num[a[i] - 1]++;
	}
	int cnt1, cnt2;
	cnt1 = cnt2 = 0;
	REP(i, m) {
		if (a[i] < x)cnt1++;
		if (a[i] > x)cnt2++;
		if (i == n)break;
	}
	cout << min(cnt1, cnt2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int a[2]={0};
  for(int i=0;i<3;i++)
  {
    a[s[i]-'A']++;
  }
  if(a[0]==3||a[1]==3)
  {
    cout<<"No\n";
  }
  else
  {
    cout<<"Yes\n";
  }
}

Measured memory_bytes: 256