akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

n, k = map(int, input().split())
A = list(map(int, input().split()))
S = [0] * (n + 1)
for i in range(n):
    S[i+1] = S[i] + A[i]

f = lambda n: (S[n] - n) % k
C = defaultdict(int)
ans = 0
for i in range(n):
    C[f(i)] += 1
    j = i - k + 1
    if 0 <= j:
        C[f(j)] -= 1
    ans += C[f(i+1)]
print(ans)

Measured memory_bytes: 111564
#include <iostream>
using namespace std;
long long gcd(long long a,long long b)
{
  long long r = a % b;
  if(r == 0) return b;
  return gcd(b,r);
}
long long lcm(long long a,long long b)
{
  long long g = a > b ? gcd(a,b) : gcd(b,a);
  return a / g * b;
}
int main()
{
  int a1,m1,a2,m2,a3,m3,x,y,z;
  long long i,a,b,c;
  for(;;){
    cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3;
    if(a1==0) break;
    x = y = z = 1;
    a = b = c = 0;
    i = 0;
    for(;;){
      if(a == 0) x = a1 * x % m1;
      if(b == 0) y = a2 * y % m2;
      if(c == 0) z = a3 * z % m3;
      i++;
      if(a == 0 && x == 1) a = i;
      if(b == 0 && y == 1) b = i;
      if(c == 0 && z == 1) c = i;
      if (a != 0 && b != 0 && c != 0){
	cout << lcm(a,lcm(b,c)) << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
/*
 *  stay hungry, stay foolish, stay home.
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define ml cout<<"\n"
#define tc(w) ll w;cin>>w;while(w--)

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define in insert
#define ff first
#define ss second
#define mod 1000000007

#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

ll lcm1(ll a,ll b){
	return (a*b)/(__gcd(a,b));
}
int main(){
	ios_base::sync_with_stdio(false);
     	cin.tie(NULL);
    	cout.tie(NULL);
    	string n;cin>>n;
    	ll p =n.size()-1;
    	if(n[p]=='2' || n[p]=='4' || n[p]=='5' || n[p]=='7' || n[p]=='9' ){
    		cout<<"hon"<<endl;
    	}
    	if(n[p]=='0' || n[p]=='1' || n[p]=='6' || n[p]=='8')
    		cout<<"pon"<<endl;

    	if(n[p]=='3'){
    		cout<<"bon"<<endl;
    	}
	return 0;
}


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

 
int main() {
  
  string board[50];
  int h,w;
  int dx[]={-1,-1,-1,0,0,1,1,1};
  int dy[]={-1,0,1,-1,1,-1,0,1};
  cin>>h>>w;
  
 
  
  for(int i=0;i<h;i++)
  {
     cin>>board[i];
  }
  
  
  for(int i=0;i<h;i++)
  {
  for(int j=0;j<w;j++)
    {
       if(board[i][j]=='.')
       {
          int sum=0;
          for(int k=0;k<8;k++)
          {
             int x = i+dx[k];
             int y = j+dy[k];
           
            if(x>=0 && x<h && y>=0 && y<w&& board[x][y]=='#')
              sum++;
                         
          }
         board[i][j]='0'+sum;
       }
    }
  }
 
     for(int i=0;i<h;i++)
     {
       cout<<board[i]<<endl;
     }
  
  return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

l = len(t)
same = 0
for i in range(len(s)-len(t)+1):
    count = 0
    for j in range(len(t)):
        if s[i+j] == t[j]:
            count += 1
    if count > same:
        same = count

print(len(t) - same)

Measured memory_bytes: 8912
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

   rep(i, s.size()){
       if(s[i] == 'a') continue;
       int cost = 'z'+1 - s[i];
       if(k >= cost){
            k -= cost;
            s[i] = 'a';
       }
   }
   for(int i=s.size()-1; i>=0; i--){
       if(s[i] != 'a'){
           s[i] += k;
           k =0;
           break;
       }
   }
   if(k != 0) s[s.size()-1] +=(k%26);
   cout << s << ln;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s.size() == 3) reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int total = 0;
    for (int i = 0; i < N; i++) {
      total += (sc.nextInt() - sc.nextInt()) * -1 + 1;
    }
    System.out.println(total);
  }
}

Measured memory_bytes: 26032
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100010;
const int N = 100010;

ll a[N],sa[N+1];

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() {
	int n,k;cin>>n>>k;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	if(k==1) {cout<<0<<endl;return 0;}
	sa[0]=0;
	rep(i,n) {sa[i+1]=sa[i]+a[i];sa[i+1]%=MOD;}
	COMinit();
	int r=1,l=1;
	ll ans=0;
	for(r=1;r<=n;r++){
		if(r-l+1<k) continue;
		ll c=COM(r-l-1,k-2)%MOD;
		ll m=(sa[n]-sa[r-1]-sa[n-r+1])%MOD;
		if(m<0) m+=MOD;
		ans+=c*m;
		ans%=MOD;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rg register
#define us unsigned
#define ll long long
#define ui <int>
#define pi <int, int>
#define tmpl template <typename typ>
#define oprt operator
#define sp putchar(32)
#define el putchar(10)
#define flin(x) freopen(x, "r", stdin)
#define flout(x) freopen(x, "w", stdout)
#define flio(x) flin(x".in"), flout(x".out")
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define itrt iterator
using namespace std;
tmpl inline bool up(typ &x, const typ &y) { return x < y ? x = y, 1 : 0; }
tmpl inline bool dn(typ &x, const typ &y) { return y < x ? x = y, 1 : 0; }
tmpl inline bool inr(const typ &x, const typ &l, const typ &r) { return !(x < l) && !(r < x); }
namespace orh {
inline void useios() { ios_base::sync_with_stdio(false); cin.tie(0); }
inline char rc() { rg char ch; while (!isgraph(ch = getchar())); return ch; }
tmpl typ ri() {
	rg typ x = 0; rg bool neg = false; rg char ch;
	while (!inr(ch = getchar(), '0', '9')) neg |= ch == '-';
	do x = (x << 1) + (x << 3) + (ch ^ 48); while (inr(ch = getchar(), '0', '9'));
	return neg ? -x : x;
}
tmpl typ ru() {
	rg typ x = 0; rg char ch;
	while (!inr(ch = getchar(), '0', '9'));
	do x = (x << 1) + (x << 3) + (ch ^ 48); while (inr(ch = getchar(), '0', '9'));
	return x;
}
tmpl void wi(rg typ x) {
	if (x < 0) { putchar('-'); x = -x; }
	static int sta[42]; rg int top = 0; rg typ t;
	do t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t; while (x);
	while (top) putchar(sta[--top] ^ 48);
}
tmpl void wu(rg typ x) {
	static int sta[42]; rg int top = 0; rg typ t;
	do t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t; while (x);
	while (top) putchar(sta[--top] ^ 48);
}
}

int h, a;

signed main() {
	cin >> h >> a;
	if (h % a == 0) cout << h / a << endl;
	else cout << h / a + 1 << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<pair<long long, long long>>>;

Graph g;
vector<long long> dist;

void dfs(long long cv, long long pv, long long d)
{
	dist[cv] = d;

	for (auto e : g[cv])
	{
		if (dist[e.first] != -1) continue;
		if (e.first == pv) continue;
		dfs(e.first, cv, d+e.second);
	}
}

int main(int argc, char **argv)
{
	long long n; cin >> n;
	vector<long long> u(n-1), v(n-1), w(n-1);
	for (long long i = 0; i < n-1; ++i) cin >> u[i] >> v[i] >> w[i];

	vector<long long> ans(n+1);
	g.resize(n+1); dist.resize(n+1, -1);
	for (long long i = 0; i < n-1; ++i)
	{
		g[u[i]].push_back(pair<long long, long long>(v[i], w[i]));
		g[v[i]].push_back(pair<long long, long long>(u[i], w[i]));
	}
	dfs(1, -1, 0);

	for (long long i = 1; i < n + 1; ++i) ans[i] = dist[i] % 2;

	for (long long i = 1; i < n + 1; ++i)
		std::cout << ans[i] << std::endl;
}

Measured memory_bytes: 12928
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
#define NL cout<<endl;
#define NNL cout<<endl<<endl;

int MAX = 1e+6+5;
int BIG = 1e+18+3;
int MOD = 1e+9+7;

signed main()
{
    IOS;
    int n,m; cin>>n>>m;
    if (n==m)
    cout<<"Yes"<<endl;
    else cout<<"No"<<endl;   
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
using namespace std;
using ll = long long;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = 1;
  if (a==b or b==c or c==a) {
    if (a==b and b==c) {
      ans = 1;
    } else {
      ans = 2;
    }
  } else {
    ans = 3;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
s=input().rstrip()
t=input().rstrip()
m=len(s)
D=[[] for i in range(26)]
for i in range(m):
    D[ord(s[i])-97].append(i)
import sys
import bisect
now=-1
ans=0
for i in t:
    if D[ord(i)-97]==[]:
        print(-1)
        sys.exit()
    p=bisect.bisect(D[ord(i)-97],now)
    if p==len(D[ord(i)-97]):
        ans+=m-1-now
        now=D[ord(i)-97][0]
        ans+=now+1
    else:
        ans+=D[ord(i)-97][p]-now
        now=D[ord(i)-97][p]
print(ans)
        


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

using namespace std;

#define repeat(i, start, end) for (int(i) = (start); (i) < (end); (i)++)
#define repeatR(i, end, start) for (int(i) = (end); (i) >= (start); i--)
#define times(n) for (int i = 0; i < n; i++)
#define len(ar) (sizeof(ar) / sizeof(ar[0]))

int main() {
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  repeat(x, 0, K + 1) {
    repeat(y, 0, K + 1) {
      int z = S - x - y;
      if (z >= 0 && z <= K) cnt++;
    }
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
       // System.out.println("0".compareTo("1"));
		ArrayDeque<String> queue1 = new ArrayDeque<String>();
		ArrayDeque<Integer> queue2 = new ArrayDeque<Integer>();
		
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int n=0,tam=0,i=0;
            boolean first=true;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	if(first){
            		n=Integer.parseInt(str[0]);
            		tam=Integer.parseInt(str[1]);
            		first=false;
            	}else{
            		queue1.add(str[0]);
            		queue2.add(Integer.parseInt(str[1]));
            		i++;
            		if(i==n){
            			break;
            		}
            	}           	
            }
            int store=0;
            while(!queue1.isEmpty()){
            	String str="";
            	while(true){
            		int a=queue2.poll();
            		str=queue1.poll();
            		if(a<=tam){
            			store+=a;
            			break;
            		}else{
            			store+=tam;
            			queue1.add(str);
            			queue2.add(a-tam);
            		}
            	}
            	System.out.println(str+" "+store);
            }
        }
	}


}

Measured memory_bytes: 61812
#include<iostream>
#include<cmath>
#include<vector>
#include<cstdlib>
#include<algorithm>
#define INF 1000000000

using namespace std;

void dijkstra(int);
vector<int>get_path(int);

int V,prev[1001];
double cost[1001][1001],d[1001];
bool used[1001];

int main(void){

  int b[1001],m,s,g;
  double x[1001],y[1001];
  while(cin >> V,V){
    for(int i=0;i<V;i++){
      cin >> b[i] >> x[i] >> y[i];
    }

    for(int i=0;i<=V;i++)
      for(int j=0;j<=V;j++)
	cost[i][j]=INF;

    for(int i=0;i<V;i++){
      for(int j=0;j<V;j++){
	if(i!=j){
	  double a=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
	  if(50.>=a)cost[b[i]][b[j]]=cost[b[j]][b[i]]=a;
	}
      }
    }
    
    cin >> m;
    for(int i=0;i<m;i++){
      cin>> s >> g;
      
	dijkstra(s);
	if(used[g]){
	  vector<int>p=get_path(g);
	  for(int j=0;j<p.size();j++){
	    cout << p[j];
	    if(j!=p.size()-1)cout <<" ";
	    else cout << endl;
	    
	  }
	}
	else cout << "NA" << endl; 
    }
  }
  
  return 0;
}

void dijkstra(int s){
  fill(d,d+V+1,INF);
  fill(used,used+V+1,false);
  fill(prev,prev+V+1,-1);
  d[s]=0;

  while(true){
    int v=-1;
    for(int u=1;u<=V;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }

    if(v==-1 || d[v]==INF)break;
    used[v]=true;

    for(int u=1;u<=V;u++){
      if(d[u]>d[v]+cost[v][u]){
	d[u]=d[v]+cost[v][u];
	prev[u]=v;
      }
    }
  }
}

vector<int>get_path(int t){
  vector<int>path;
  for(;t!=-1;t=prev[t])path.push_back(t);
  reverse(path.begin(),path.end());
  return path;
}

Measured memory_bytes: 0
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    ll N, M;
    cin >> N >> M;
    int num = max(N, M) - min(N, M);
    if (num > 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for (ll i = 1; i <= N; i++) {
        ans *= i;
        ans %= 1000000007;
    }
    for (ll i = 1; i <= M; i++) {
        ans *= i;
        ans %= 1000000007;
    }
    if (num == 0) {
        ans *= 2;
        ans %= 1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
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; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));

void insertionSort(vector<int>&A, int N){
    for(int i = 1; i <= N - 1; i++){
        for(int i = 0; i < N; i++){
            cout << A[i];
            if(i != N - 1) cout << ' ';
        }
        cout << endl;
        int v = A[i];
        int j = i - 1;
        while(j >= 0 and A[j] > v){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        
    }
    for(int i = 0; i < N; i++){
            cout << A[i];
            if(i != N - 1) cout << ' ';
        }
        cout << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);

    
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    insertionSort(A, N);
    
}



Measured memory_bytes: 3224
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstdlib>

using namespace std;

#define MAX 100

struct card {
  char c;
  int num;
};

bool isStable(struct card C1[], struct card C2[], int N) {
    for(int i = 0; i < N; i++){
        if(C1[i].c != C2[i].c)  return false;
    }
    return true;
}

void print(card C[], int N) {
    for(int i = 0; i < N; i++){
        if(i > 0)  cout << " ";
        cout << C[i].c << C[i].num;
    }
    cout << endl;
}

void Selection(card B[], int N) {
    for (int i = 0; i < N; i++) {
        int minj = i;
        for(int j = i; j < N; j++) {
            if(B[j].num < B[minj].num) minj = j;
        }
        card temp = B[i];
        B[i] = B[minj];
        B[minj] = temp;
    }
}

int main()
{
    card A[MAX];
    card B[MAX];
    int N;
    bool b_flag;

    cin >> N;
    for (int i = 0; i < N; i++) {
        scanf(" %c%d", &A[i].c, &A[i].num);
    }

    for (int i = 0; i < N; i++) {
        B[i] = A[i];
    }

    for (int i = 0; i < N; i++) {
        for(int j = N-1; j > i; j--){
            if(A[j].num < A[j-1].num){
                card temp = A[j];
                A[j] = A[j-1];
                A[j-1] = temp;
            }
        }
    }

    print(A, N);
    cout << "Stable" << endl;

    Selection(B, N);

    print(B, N);
    b_flag = isStable(A, B, N);
    if (b_flag != true) cout << "Not stable" << endl;
    else cout << "Stable" << endl;

    return 0;
}



Measured memory_bytes: 3256
package main

import "fmt"

func main() {
	var (
		k int
	)

	array := make([]int, 5)

	fmt.Scan(&array[0], &array[1], &array[2], &array[3], &array[4], &k)

	var isEnabed bool = true

	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			d := array[j] - array[i]
			if d > k {
				isEnabed = false
			}
		}	
	}

	if isEnabed {
		fmt.Print("Yay!")
	} else {
		fmt.Print(":(")
	}
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
	ll n;
	cin>>n;
	ll ans=(n)*(n-1)/2;
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const ll maxn = 105;
ll h[maxn];
ll n;
ll check()
{
	for(ll i = 0;i < n; ++i)
	{
		if(h[i])
		{
			return 1;
		}
	}
	return 0;
}
int main(int argc, char const *argv[])
{
	cin>>n;
	for(ll i = 0;i < n; ++i)
	{
		scanf("%lld",&h[i]);
	}
	ll ans = 0;
	while(check())
	{
		for(ll i = 0;i < n; ++i)
		{
			if(h[i])
			{
				for(ll j = i;j < n; ++j)
				{
					if(h[j])
					{
						h[j]--;
					}
					else
					{
						break;
					}
				}
				ans++;
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

namespace abc114_a
{
    class Program
    {
        public static string SevenFiveThree(int X)
        {
            if (X == 7 || X == 5 || X == 3) return "YES";
            else return "NO";
        }
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            Console.WriteLine(SevenFiveThree(X));

        }
    }
}


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

int main()
{
    long long int N,D,a,b,count=0;
    double x,y,z,p;

    cin>>N>>D;

    while(N--)
    {
        cin>>a>>b;

        x=(a*a)+(b*b);
        y=sqrt(x);

        if(y<=D)
            count++;
    }

    cout<<count<<endl;
    return 0;
}


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

int main() {
  vector<int> x(5,0);
  for (int i = 0; i < 5; i++)
  {
    cin >> x[i];
  }  

  for (int i = 0; i < 5; i++)
  {
    if (x[i] == 0) {
      cout << i + 1;
    }
  }

}

Measured memory_bytes: 3628
import math

a = list(map(int,input().split()))
A = a[0]
B = a[1]
H = a[2]
M = a[3]


theta = (30.0 * H + 0.5 * M) - (6.0 * M)

if theta > 180:
    theta = 360 - theta

x = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta * math.pi / 180))

print(x)


Measured memory_bytes: 9440
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func pow(a int, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 1 {
		return a * pow(a, p-1)
	} else {
		b := pow(a, p/2)
		return b * b
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	H, W, K := nextInt(), nextInt(), nextInt()
	black := make([][]bool, H)
	for i := 0; i < H; i++ {
		black[i] = make([]bool, W)
		s := next()
		for j := 0; j < W; j++ {
			if s[j] == '#' {
				black[i][j] = true
			}
		}
	}

	H_KOUHO := pow(2, H)
	W_KOUHO := pow(2, W)
	col_sum_each := make([][]int, H_KOUHO)

	for n := 0; n < H_KOUHO; n++ {
		r := n
		col_sum_each[n] = make([]int, W)
		for i := 0; i < H; i++ {
			if r%2 == 0 {
				for j := 0; j < W; j++ {
					if black[i][j] {
						col_sum_each[n][j]++
					}
				}
			}
			r = r / 2
		}
	}

	count := 0
	for n := 0; n < H_KOUHO; n++ {
		for m := 0; m < W_KOUHO; m++ {
			r := m
			sum := 0
			for j := 0; j < W; j++ {
				if r%2 == 0 {
					sum += col_sum_each[n][j]
				}
				r = r / 2
			}
			if sum == K {
				count++
			}
		}
	}

	fmt.Fprintf(out, "%d\n", count)
}


Measured memory_bytes: 1824
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int n,ans=1;
string s;
map<char,int>mp;
signed main(){
    cin>>n>>s;
    rep(i,n){
        mp[s[i]]++;
    }
    rep(i,26){
        char c='a'+i;
        ans*=mp[c]+1;
        ans%=mod;
    }
    cout<<ans-1<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int fun(int n)
{
	int m=n,cnt=0;
	while(n)
	{
		cnt++;
		n/=10;
	}
	return m/pow(10,cnt-1);
}
int main()
{
	int n,m;
	ll s[200010];
	int cnt=0,dp[100][100];
	s[0]=0;
	memset(dp,0,sizeof dp);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%10==0) 
		{
			s[i]=s[i-1];
			continue;
		}
		int x=fun(i),y=i%10;
	//	cout<<x<<' '<<y<<endl;
	//	dp[x][y]++;
		s[i]=s[i-1]+2*dp[y][x];
		if(x==y) s[i]++; 
		dp[x][y]++;
	}
	cout<<s[n];
	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3

'''
Author: andyli
Time: 2020-07-25 19:57:00
'''

import os
from io import BytesIO, IOBase
import sys


def main():
    a,b,c = map(int,input().split())

    k = int(input())

    for i in range(k):
        if b<=a: b *= 2
        else: c*=2
    print('Yes' if c>b>a else 'No')
    return


# region fastio
BUFSIZE = 1048576


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = 'x' in file.mode or 'r' not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b'\n') + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode('ascii'))
        self.read = lambda: self.buffer.read().decode('ascii')
        self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip('\r\n')

# endregion


if __name__ == '__main__':
    main()


Measured memory_bytes: 62632
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    int ans = 0;
    for (int ai : a) {
        while (ai % 2 == 0) {
            ans++;
            ai /= 2;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


int main()
{
	ll N, K;
	lls P;
	cin >> N >> K;
	cinv(P, N);

	ll same = 0;
	ll up = 0;
	ll syojun = 0;
	std::set<ll> valSet;

	//はじめのK個
	for (ll i = 0; i < K; i++) {
		valSet.insert(P[i]);

		if (i > 0) {
			if (P[i - 1] < P[i]) up++;
			else                 up = 0;
		}
	}
	if (up == K - 1) syojun++;

	for (ll i = K; i < N; i++) {

		//昇順の判定
		bool isSyojun;
		if (P[i - 1] < P[i]) up++;
		else                 up = 0;
		if (up >= K - 1) isSyojun = true;
		else             isSyojun = false;
		if (isSyojun) syojun++;

		//---- 一つ前と同じになるか判定
		if (!isSyojun) {
			//左端がminか判定
			ll leftVal = P[i - K];
			auto itL = valSet.begin();
			ll minValInSet = *itL;
			bool isLeft = false;
			if (leftVal == minValInSet) isLeft = true;

			//右端がmaxか判定
			ll rightVal = P[i];
			auto itR = valSet.end();
			itR--;
			ll maxValInSet = *itR;
			bool isRight = false;
			if (maxValInSet < rightVal) isRight = true;

			if (isLeft && isRight) same++;
		}

		//左端を削除
		auto it = valSet.find(P[i - K]);
		valSet.erase(it);

		//右端を追加
		valSet.insert(P[i]);
	}

	ll total = N - K + 1;
	ll answer;
	if (syojun == 0) {
		answer = total - same;
	}
	else {
		answer = total - same - (syojun - 1);
	}

	cout << answer << '\n';

	return 0;
}



Measured memory_bytes: 11136
n=int(input())
p=input()
q=input()

from itertools import permutations as per

i=0
for nn in per(map(str,range(1,n+1))):
    i+=1
    st=' '.join(nn)
    if p==st:a=i
    if q==st:b=i

print(abs(b-a))

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

#define FOR(i,n) for(int i=0;i<n;i++)
#define PRINT(a) cout<<a<<"\n"
 
int main(){

	int n,k,x,y,t=0;
	cin>>n>>k>>x>>y;

	FOR(i,n){
		if(i<k)t=t+x;
		else t=t+y;
	}

	PRINT(t);

	return 0;
}

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

#include <iostream>
#include <fstream>

#include <iostream>

class ADodecagon {
public:
	void solve(std::istream& in, std::ostream& out) {
      int r;
      in>>r;
      out<<r*r*3<<std::endl;
	}
};


int main() {
	ADodecagon solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str, T: str):
    a = 0
    for i in range(len(S)):
        a += (S[i]==T[i])*1
    print(len(S)-a)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
	int N,L;
	cin>>N>>L;
	vector<string> S;
	int i;
	string s;
	for (i=0;i<N;i++){
		cin>>s;
		S.push_back(s);
	}
	sort(S.begin(),S.end());
	s="";
	for (i=0;i<S.size();i++){
		s+=S[i];
	}
	cout<<s<<endl;
	return 0;
}

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

int n,tot,ans;
ll p[3333];
bool tag[3333];
ll a[111111],b[111111];
map<ll,int> m;

void init()
{
    for(int i=2; i<3333; i++)
    {
        if(!tag[i]) p[tot++]=i;
        for(int j=0; j<tot&&i*p[j]<3333; j++)
        {
            tag[i*p[j]]=1;
            if(i%p[j]==0) break;
        }
    }
}

void pre(int id)
{
    ll x=1,y=1;
    for(int i=0; p[i]*p[i]*p[i]<=a[id]; i++)
    {
        int cnt=0;
        while(a[id]%p[i]==0) cnt++,a[id]/=p[i];
        cnt%=3;
        if(cnt==1) x*=p[i],y*=p[i]*p[i];
        else if(cnt==2) x*=p[i]*p[i],y*=p[i];
    }
    if(a[id]!=1)
    {
        x*=a[id];
        ll sq=(ll)sqrt(a[id]);
        if(sq*sq==a[id]) y*=sq;
        else y*=a[id]*a[id];
    }
    a[id]=x,b[id]=y,m[x]++;
}

int main()
{
    init();
    cin>>n;
    for(int i=0; i<n; i++) cin>>a[i],pre(i);
    if(m[1]) ans++,m[1]=0;
    for(int i=0; i<n; i++) if(m[a[i]]) ans+=max(m[a[i]],m[b[i]]),m[a[i]]=m[b[i]]=0;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 14464
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) { cout << ", "; first = false; }
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n);
  for (lli i=0; i<n; ++i) cin >> v[i];
}


int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << ((b-a)%2==0 ? "Alice" : "Borys") << endl; 
  return 0;
}


Measured memory_bytes: 256
class Dice:
    def __init__(self,d1,d2,d3,d4,d5,d6):
        self.dice = [d1,d2,d3,d4,d5,d6]
    def turn(self,dir):
        if dir == 'S':
            self.dice = [self.dice[4],self.dice[0],self.dice[2],self.dice[3],self.dice[5],self.dice[1]]
        if dir == 'N':
            self.dice = [self.dice[1],self.dice[5],self.dice[2],self.dice[3],self.dice[0],self.dice[4]]
        if dir == 'W':
            self.dice = [self.dice[2],self.dice[1],self.dice[5],self.dice[0],self.dice[4],self.dice[3]]
        if dir == 'E':
            self.dice = [self.dice[3],self.dice[1],self.dice[0],self.dice[5],self.dice[4],self.dice[2]]


def check(m):
    for b in range(4):
        m.turn('N')
        if m.dice[0] == a[0] and m.dice[1] == a[1]:
            return(m.dice[2])

dice_num = input().split()
q = int(input())
conditions = []
for a in range(q):
    temp = input().split()
    conditions.append(temp)

init_Dice = Dice(dice_num[0],dice_num[1],dice_num[2],dice_num[3],dice_num[4],dice_num[5])

kaitou = []
for a in conditions:
    if check(init_Dice):
        print(check(init_Dice))
        continue
    init_Dice.turn('E')
    if check(init_Dice):
        print(check(init_Dice))
        continue
    init_Dice.turn('E')
    if check(init_Dice):
        print(check(init_Dice))
        continue
    init_Dice.turn('E')
    if check(init_Dice):
        print(check(init_Dice))
        continue

    init_Dice.turn('W')
    init_Dice.turn('N')
    init_Dice.turn('E')

    if check(init_Dice):
        print(check(init_Dice))
        continue
    init_Dice.turn('E')
    if check(init_Dice):
        print(check(init_Dice))
        continue
    init_Dice.turn('E')
    if check(init_Dice):
        print(check(init_Dice))
        continue
    init_Dice.turn('E')
    if check(init_Dice):
        print(check(init_Dice))
        continue



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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<VB> VVB;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define PF push_front
#define POB pop_back()
#define POF pop_front()
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = INT_MAX;
const LL LINF = LLONG_MAX;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

VI dx = {1,0,-1,0};
VI dy = {0,1,0,-1};

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  int N = SZ(s);
  
  deque<char> dq;
  
  REP(i,N){
    if(s.at(i) == 'B'){
      if(SZ(dq)) dq.POB;
      continue;
    }
    dq.PB(s.at(i));
  }
  
  while(SZ(dq)){
    char c;
    c = dq.front();
    cout << c;
    dq.POF;
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	void solve() {
		int n = sc.nextInt();
		int maxV = -1;
		int maxA = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int v = sc.nextInt();
			if (maxV < v) {
				maxV = v;
				maxA = a;
			} else if (maxV == v && maxA > a) {
				maxA = a;
			}
		}
		out.println(maxA + " " + maxV);
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 17048
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool b = (s[0] == s[1]) || (s[1] == s[2]) || (s[2] == s[3]);
    cout << (b ? "Bad" : "Good") << endl;
    return 0;
}



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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	if(n&1) {
		cout << (n/2+1)/(double)n;
	} else {
		cout << "0.5";
	}
}

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

int a,b,c;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>a>>b>>c;
	if(a+b < c)
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>

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

using namespace std;

int main() {
  while(1){
    int w,h;
    cin>>w>>h;
    if(!w)break;
    vector<string> t(h);
    REP(i,h)cin>>t[i];
    int si,sj;
    REP(i,h)REP(j,w){
      if(t[i][j] == '@'){
        si = i;
        sj = j;
      }
    }
    vector<vector<bool>> vis(h,vector<bool>(w,false));
    vis[si][sj] = true;
    queue<pair<int,int>> q;
    q.push(make_pair(si,sj));
    while(!q.empty()){
      auto p = q.front();q.pop();
      int i,j;
      tie(i,j) = p;
      int di[] = {1,0,-1,0};
      int dj[] = {0,1,0,-1};
      REP(k,4){
        int ni=i+di[k];
        int nj=j+dj[k];
        if(ni<0||ni>=h||nj<0|nj>=w)continue;
        if(t[ni][nj] == '#')continue;
        if(vis[ni][nj]) continue;
        q.push(make_pair(ni,nj));
        vis[ni][nj] = true;
      }
    }
    int cnt = 0;
    REP(i,h)REP(j,w){
      if(vis[i][j])++cnt;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

#define N 9
#define S 1000
#define K 100

static int64_t k_operafan[ N + 1 ][ S + 1 ][ K + 1 ];

int64_t
dpFSA (
  const int n,
  const int s,
  const int k
  )
{
  int i;

  if ( n <= 0 ) return ( s == 0 ? 1 : 0 );
  if ( s < 0 )  return ( 0 );
  if ( k > K )  return ( 0 );

  if ( ~k_operafan[ n ][ s ][ k ] ) ;
  else
  {
    k_operafan[ n ][ s ][ k ] = 0;

    for ( i = k; i <= 100; ++i )
    {
      k_operafan[ n ][ s ][ k ] += dpFSA ( n - 1, s - i, i + 1 );
    }
  }

  return ( k_operafan[ n ][ s ][ k ] );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  memset ( k_operafan, -1, sizeof ( k_operafan ) );

  for ( ; ; )
  {
    int n, s;

    scanf ( "%d%d", &n, &s );
    if ( n == 0 && s == 0 )
      break ;

    printf ( "%lld\n", dpFSA ( n, s, 0 ) );
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 8504
from collections import Counter
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def main():
    n, k, l = map(int, sys.stdin.buffer.readline().split())
    a = UnionFind(n)
    b = UnionFind(n)
    cnt = 0
    for x in sys.stdin.buffer.readlines():
        p, q = map(int, x.split())
        cnt += 1
        if cnt <= k:
            a.union(p-1, q-1)
        else:
            b.union(p-1, q-1)

    pairs = [(a._root(i), b._root(i)) for i in range(n)]
    d = Counter(pairs)
    ans = [d[x] for x in pairs]
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49484
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    W,H,N = map(int,input().split())
    lx,rx,ly,ry = 0,W,0,H
    for _ in range(N):
        x,y,a = map(int,input().split())
        if a == 1:
            lx = max(lx,x)
        elif a == 2:
            rx = min(rx,x)
        elif a == 3:
            ly = max(ly,y)
        else:
            ry = min(ry,y)
    ans = max(0,rx - lx) * max(0,ry - ly)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9160
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  priority_queue<int> que;
  rep(i,N){
    cin >> A[i];
    que.push(A[i]);
  }

  rep(j,M){
    int temp=que.top()/2;
    que.pop();
    que.push(temp);
  }

  ll ans=0;
  rep(i,N){
    ans+=que.top();
    que.pop();
  }

  printf("%lld\n", ans);
}


Measured memory_bytes: 1276