akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n,m,p1,p2,vis[200001];
vector<int> arr[200001];
int main() {
    cin>>n>>m;
    for (int i=0; i<m; i++) {
        cin>>p1>>p2; p1--; p2--;
        arr[p1].push_back(p2);
        arr[p2].push_back(p1);
    }
    queue<pair<int,int> > q;
    q.push({0,0});
    while (!q.empty()) {
        int cur=q.front().first,dis=q.front().second;
        q.pop();
        if (vis[cur]) continue;
        if (cur==n-1) {cout<<"POSSIBLE\n"; return 0;}
        if (dis==2) continue;
        vis[cur]=1;
        for (int i=0; i<arr[cur].size(); i++) {
            if (vis[arr[cur][i]]) continue;
            q.push({arr[cur][i],dis+1});
        }
    }
    cout<<"IMPOSSIBLE\n";
}

Measured memory_bytes: 16672
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;

using ll = long long;

typedef struct info {
    int id;
    ll y;
    ll juni;
} info;

int main()
{
    int n, m;
    cin >> n >> m;
    vector< vector<info> > v(n + 1);
    // 市の属する県をid順で覚えておく
    vector<int> o;
    for (int i = 0; i < m; i++) {
        ll p, y;
        cin >> p >> y;

        info tmp;
        tmp.id = i;
        tmp.y = y;
        v[p].push_back(tmp);

        o.push_back(p);
    }

    // yで並び替え
    for (int i = 1; i < n + 1; i++) {
        if (v[i].empty()) continue;
        sort(v[i].begin(), v[i].end(), [](info const& lhs, info const& rhs) {
                                           return lhs.y < rhs.y;
                                       });
    }

    // 順位を覚えておく
    for (int i = 1; i < n + 1; i++) {
        for (int j = 0; j < v[i].size(); j++) {
            v[i][j].juni = j + 1;
        }
    }

    // id逆順に並び替え
    for (int i = 1; i < n + 1; i++) {
        if (v[i].empty()) continue;
        sort(v[i].begin(), v[i].end(), [](info const& lhs, info const& rhs) {
                                           return lhs.id > rhs.id;
                                       });
    }

    for (int i = 0; i < o.size(); i++) {
        if (v[o[i]].empty()) continue;
        printf("%06d%06d\n", o[i], v[o[i]].back().juni);
        v[o[i]].pop_back();
    }

    return 0;
}


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

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		boolean[][] numbers = new boolean[4][13];
		
		for(int i = 0; i < n; i++){
			String mark = scanner.next();
			int card = scanner.nextInt();
			if(mark.equals("S")){
				numbers[0][card-1] = true;
			}else if(mark.equals("H")){
				numbers[1][card-1] = true;
			}else if(mark.equals("C")){
				numbers[2][card-1] = true;
			}else if(mark.equals("D")){
				numbers[3][card-1] = true;
			}
		}

		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 13; j++){
				if(numbers[i][j] == false){
					if(i==0){
						System.out.println("S " + (j + 1));
					}else if(i==1){
						System.out.println("H " + (j + 1));
					}else if(i==2){
						System.out.println("C " + (j + 1));
					}else if(i==3){
						System.out.println("D " + (j + 1));
					}
				}
			}
		}
	}

}

Measured memory_bytes: 26232
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int x[5];
    rep(i,5) {
        cin >> x[i];
    }
    rep(i,5) {
        if (x[i]==0) {
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3596
import java.util.*;

class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.next());
		
		long k = (long)(int)Math.sqrt(n);
		long mini = n;
		long mini_1 = 1;
		long mini_2 = n;
		
		
		for(long i = 1; i <= k; ++i) {
		    if(n % i == 0) {
		        long tmp = n / i;
		        long abs_val = Math.abs(tmp - i);
		        
		        if(mini > abs_val) {
		            mini = abs_val;
		            mini_1 = i;
		            mini_2 = n / i;
		        }
		        else  continue;
		    }
		    else continue;
		}
		
		System.out.println(mini_1 - 1 + mini_2 -1);
	}
}

Measured memory_bytes: 23636
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=2e5+7;

char s[N];
int cnt[26],n;

int main(){
	scanf("%s",s),n=strlen(s);
	rep0(i,n) ++cnt[s[i]-'a'];
	ll ans=1ll*n*(n-1)/2+1;
	rep0(i,26) ans-=1ll*cnt[i]*(cnt[i]-1)/2;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 998244353 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

const int MAX = 2000000 ;

//宣言するときはstaticをつけて静的変数にするかグローバル変数として宣言
//initのときに関数の種類を決定する（0:sum,1:min,2:max）
class SGT{
public :
	int n ;
	ll d ;
	ll num[MAX] ;
	int fan ;

	ll f(ll a,ll b){
		if(fan==0) return a+b ;
		else if(fan==1) return min(a,b) ;
		else if(fan==2) return max(a,b) ;
		else return d ;
	}

	void init(vector<ll> &a,int b){
		fan = b ;
		n = 1 ;
		if(fan==0||fan==2) d = -INF ;
		if(fan==1) d = INF ;
		while(a.size()>n) n *= 2 ;
		for(int i=0;i<n;i++){
			if(i<a.size()) num[n-1+i] = a.at(i) ;
			else num[n-1+i] = d ;
		}
		for(int i=n-2;i>=0;i--){
			num[i] = f(num[i*2+1],num[i*2+2]) ;
		}
	}

//	内容次第でwhile内の計算式を書き換える
	void update(int i,ll a){
		i += n-1 ;
		num[i] = a ;
		while(i>0){
			i = (i-1)/2 ;
			num[i] = f(num[i*2+1],num[i*2+2]) ;
		}
	}

	ll query(int a,int b,int l=0,int r=-1,int now=0){
		if(r==-1) r = n ;
//		cout << fan << " " << l << " " << r << " " << now << endl ;
		if(r<=a||b<=l) return d ;
		if(a<=l&&r<=b) return num[now] ;
		ll r1 = query(a,b,l,(l+r)/2,now*2+1) ;
		ll r2 = query(a,b,(l+r)/2,r,now*2+2) ;
		return f(r1,r2) ;
	}
};

int main(){
	ll n,k ;
	cin >> n >> k ;
	ll ans = n-k+1 ;
	set<int> s ;
	vll a(n),p={0} ;
	for(auto &i:a) cin >> i ;
	for(int i=1;i<n;i++) if(a.at(i-1)>a.at(i)) p.push_back(i) ;
	p.push_back(n) ;
//	for(auto i:p) cout << i << " " ; cout << endl ;
	for(int i=0;i+1<p.size();i++){
		for(int j=0;j<max(0LL,p.at(i+1)-p.at(i)-k+1);j++) s.insert(p.at(i)+j) ;
	}
//	cout << ans << endl ;
	if(s.size()>1) ans -= s.size()-1 ;
//	cout << ans << endl ;
	static SGT mn,mx ;
	mn.init(a,1) ;
	mx.init(a,2) ;
//	cout << ans << endl ;
	for(int i=0;i+k<n;i++) if(a.at(i)==mn.query(i,i+k)&&a.at(i+k)==mx.query(i+1,i+k+1)&&!s.count(i)) ans-- ;
	cout << ans << endl ;
}


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

using namespace std;

typedef long long LL;
typedef double LF;
typedef complex<LF> cd;

#define clr(x, y) memset(x, y, sizeof(x))
#define INF 0x7fffffff

const int MAXN = 2e5 + 15;

char ch[MAXN];
int n, nxt[MAXN], T;
LL l, r, f[MAXN][35];

inline int read(){
	int r = 0, z = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-') z = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9'){r = r * 10 + ch - '0'; ch = getchar();}
	return r * z;
}

LL ff(LL len, int c){
	if(len <= n) return f[len][c];
	if(len <= n * 2) return f[n][c] + f[len - n][c];
	LL f1 = f[n][c], f2 = f[n][c] + f[T][c], l1 = n, l2 = n + T;
	while(len > l1 + l2){
		LL t = f2;
		f2 += f1; f1 = t;
		t = l2; l2 += l1; l1 = t;
	}
	return f2 + ff(len - l2, c);
}

LL calc(LL len, int c){
	if(len <= n) return f[len][c];
	if(len <= n * 2) return f[n][c] + f[len - n][c];
	if(n % T == 0){
		LL tmp = (len - 1ll * n) / T * f[T][c] + f[n][c];
		len -= n; len %= T;
		return tmp + f[len][c];
	}
	return ff(len, c);
}

void work(){
	scanf("%s %lld %lld", ch + 1, &l, &r); n = strlen(ch + 1) / 2;
	for(int i = 1; i <= n; i ++){
		for(int j = 0; j < 26; j ++) f[i][j] = f[i - 1][j];
		f[i][ch[i] - 'a'] ++;
	} nxt[1] = 0;
	for(int i = 2, j = 0; i <= n; i ++){
		for(; j && ch[j + 1] != ch[i];) j = nxt[j];
		if(ch[j + 1] == ch[i]) j ++;
		nxt[i] = j;
	}
	T = n - nxt[n];
	for(int i = 0; i < 26; i ++) printf("%lld ", calc(r, i) - calc(l - 1, i));
}

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


Measured memory_bytes: 31104
class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        while self.table[x] >= 0:
            x = self.table[x]
        return x

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] != self.table[s2]:
                if self.table[s1] < self.table[s2]:
                    self.table[s2] = s1
                else:
                    self.table[s1] = s2
            else:
                self.table[s1] += -1
                self.table[s2] = s1
        return


n, m = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(m)]

ans = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i != j:
            uf.union(edges[j][0]-1, edges[j][1]-1)
    c = 0
    for j in range(n):
        if j == uf.find(j):
            c += 1
    if c > 1:
        ans += 1

print(ans)


Measured memory_bytes: 42716
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n;
double p[3000];
double dp[3001][3001];

int main() {
    cin >> n;
    rep(i,n) cin >> p[i];
    dp[0][0] = 1.0;
    rep(i,n) {
        rep(j,n+1) {
            if (j == 0) dp[i+1][j] = dp[i][j] * (1.0-p[i]);
            else dp[i+1][j] = dp[i][j]*(1.0-p[i]) + dp[i][j-1]*p[i];
        }
    }
    double ans = 0;
    for (int i = n/2+1; i <= n; i++) ans += dp[n][i];
    printf("%.10f\n", ans);
}



Measured memory_bytes: 70656
def smaller(x, y):
	if x < y:
		return x
	return y

N = int(input())
A = list(map(int, input().split()))
min = 5000000000000000
for i in range(-100, 101):
	sum = 0
	for j in range(0, N):
		sum += (A[j]-i)**2
	min = smaller(min, sum)
print(min)

Measured memory_bytes: 39920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

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

  double ans = L*L*L/27.0;
  cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <cmath>

using namespace std;

const size_t N = 100000000 + 1;
bitset<N> sieve;

void eratosthenes() {
    for (int i = 2; i < N; ++i) {
        sieve[i] = true;
    }

    for (int i = 2; i < sqrt(N); ++i) {
        if (sieve[i]) {
            for (int j = 2; i * j < N; ++j) {
                sieve[i*j] = false;
            }
        }
    }
}

bool is_prime(int n) {
    return sieve[n];
}

int main() {
    eratosthenes();

    int n;
    cin >> n;

    int count;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;

        if (is_prime(x)) {
            // cerr << "debug: " <<  x << endl;
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

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

int main(){
    long long ans=0,N;
    cin >> N;
    string S;
    cin >> S;
    for(int i=0;i<S.size();++i){
        if(S[i]!=S[i+1]) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int main() {
	int N, W; cin >> N >> W;
	vector< pair<int, int> > vii(N);
	REP(i, N)
		cin >> vii[i].second >> vii[i].first;

	int dp[10001] = {};
	FOR(i, 1, W+1) {
		REP(j, N) {
			if(i >= vii[j].first)
				dp[i] = max(dp[i], dp[i - vii[j].first] + vii[j].second);
			else
				dp[i] = max(dp[i], dp[i-1]);
		}
	}
//	REP(i, W+1) cout << dp[i] << ' ';
	cout << dp[W] << endl;
	return 0;
}

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

vector<string> make(string ss, string s) {
  vector<string> res;
  int n = ss.length();
  if (s[n] != 'z') {
    string tmp;
    tmp += s[n] + 1;
    res.push_back(ss + tmp);
  }
  string tmp;
  tmp += s[n];
  res.push_back(ss + tmp);
  return res;
}

bool comp(string ss, string s) {
  int n = ss.length();
  for (int i = 1; i < 26; i++) {
    for (int j = 0; j < n; j++) {
      if (ss[j] == 'a' + i) {
        ss[j] -= 1;
        break;
      }
    }
  }
  return ss == s.substr(0, n);
}

int main() {
  string s;
  while (cin >> s, s != "#") {
    int cnt = 0;
    deque<string> first, last, q;
    for (auto&& w : make("", s)) q.push_front(w);
    while (!q.empty()) {
      string ss = q.front();
      q.pop_front();
      if (!comp(ss, s)) continue;
      if (ss.length() == s.length()) {
        first.push_back(ss);
        last.push_back(ss);
        if (first.size() > 10) first.pop_back();
        if (last.size() > 5) last.pop_front();
        cnt++;
        continue;
      }
      for (auto&& w : make(ss, s)) q.push_front(w);
    }
    cout << cnt << endl;
    if (cnt > 10) {
      while (first.size() > 5) first.pop_back();
      while (!first.empty()) {
        string ans = first.front();
        first.pop_front();
        cout << ans << endl;
      }
      while (!last.empty()) {
        string ans = last.front();
        last.pop_front();
        cout << ans << endl;
      }
    } else {
      while (!first.empty()) {
        string ans = first.front();
        first.pop_front();
        cout << ans << endl;
      }
    }
  }
}



Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    int N ;cin >> N;
    vector<pair<string,pair<int,int>>> A;
    rep(i,N){
        string s;
        int a;
        cin >> s >> a;
        A.push_back({s,{-a,i+1}});
    }
    SORT(A);
    rep(i,N){
        cout << A[i].second.second << endl;
    }
}

Measured memory_bytes: 632
#include <iostream>
#include <vector>
#define eol '\n'
using namespace std;

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

  int* a = new int[3];
  cin >> a[0] >> a[1] >> a[2];

  int c5 = 0;
  int c7 = 0;

  for (int i = 0; i < 3; i++) {
    if (a[i] == 5) {
      c5++;
    } else if (a[i] == 7) {
      c7++;
    }
  }

  if (c5 == 2 && c7 == 1) {
    cout << "YES" << eol;
  } else {
    cout << "NO" << eol;
  }
  
  return 0;
}


Measured memory_bytes: 256
import scala.math

object Main extends App{
    def isPrime(n: Int): Boolean = {
        if(n == 2) true
        else if(n == 1 || n % 2 == 0) false
        else(3 to math.sqrt(n).toInt).forall(n % _ != 0)
    }

    var x = io.StdIn.readLine.toInt
    while(isPrime(x) == false) x += 1
    println(x)
}

Measured memory_bytes: 27300
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;
const double pi=3.141592653589793;


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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

ll COM(ll n, ll 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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100010],d,cnt=0;
    map<ll,ll> mp;
    cin>>n;
    rep(i,n+1){
        cin>>a[i];
        if(mp[a[i]]==0) mp[a[i]]++;
        else{
            d=a[i];
            cnt+=(n-i);
        }
    }
    rep(i,n+1){
        if(a[i]!=d) cnt++;
        else break;
    }
    COMinit();
    rep2(i,1,n+2){
        ll ans=COM(n+1,i)-COM(cnt,i-1);
        if(ans<0) ans+=MOD;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 20224
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;
//typedef __int64 LL;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
double pi=4*atan(1);

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)cout<<c<<"\n";
	else if(b==c)cout<<a<<"\n";
	else cout<<b<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int X;
    int N;
    cin >> X >> N;

    unordered_set <int> valSet;

    for (int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        valSet.insert(p);
    }

    int bestVal = -1000000;

    for (int v = X-2*N; v <= X+2*N; ++v) {
        if (valSet.count(v) != 0) {
            continue;
        }

        int diff = abs(v-X);

        if (diff < abs(bestVal-X)) {
            bestVal = v;
        }
    }

    cout << bestVal << endl;

    return 0;
}

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

signed main(void)
{
	int x, a, b;
	cin >> x >> a >> b;
	a *= -1;
	if (a + b <= 0)
		cout << "delicious" << endl;
	else if (a + b <= x)
		cout << "safe" << endl;
	else
		cout << "dangerous" << endl;
	return 0;
}


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

int main(void){
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  
  // 2K+1個の和が最大になればよさそう
  
  vector<int> q;
  int x = 1;
  int cnt = 0;
  for(int i=0; i<N; i++){
    if(S[i] == (char)('0'+x)) cnt++;
    else {
      q.push_back(cnt);
      x = 1-x;
      cnt = 1;
    }
  }
  if(cnt != 0) q.push_back(cnt);
  if(q.size()%2 == 0) q.push_back(0);
//  for(int i=0; i<q.size(); i++) cout << q[i] << endl;
  
  int qNum = q.size();
  int a[qNum+1];
  a[0] = 0;
  for(int i=0; i<qNum+1; i++) a[i+1] = a[i] + q[i];
//  for(int i=0; i<qNum + 1; i++) cout << a[i] << endl;

  int ans = 0;
  for(int i=0; i < qNum; i+=2){
    int left = i;
    int right = min(i+2*K+1, qNum);
    ans = max(ans, a[right] - a[left]);
//    cout << i << ", " << ans << endl;
  }
  cout << ans << endl;
  return 0;
  
  
}


Measured memory_bytes: 1272
def solve(string):
    n, k = map(int, string.split())
    c = (n - 1) * (n - 2) // 2
    if k > c:
        return "-1"
    ans = []
    for i in range(1, n):
        ans.append("{} {}".format(i, n))
    for i in range(1, n):
        for j in range(i + 1, n):
            if c - k == 0:
                break
            c -= 1
            ans.append("{} {}".format(i, j))
    return "{}\n".format(len(ans)) + "\n".join(ans)


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    string res = "yes";
    for (int i = 0; i < s.size(); i++) {
        for (int j = i + 1; j < s.size(); j++) {
            if (s[i] == s[j]) res = "no";
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define D 365
#define INF 1001001001
typedef long long ll;
ll calcSat(int *tmpt, int s[][26], int *c) {
	int last[26] = {0};
	ll tmpSat = 0;
	for (int i = 0; i < D; i++) {
		tmpSat += s[i][tmpt[i] - 1];
		last[tmpt[i] - 1] = i + 1;
		for (int j = 0; j < 26; j++) {
			tmpSat -= (c[j] * (i + 1 - last[j]));
		}
	}
	return tmpSat;
}
int main() {
	srand(629);
	scanf("%*d");
	int c[26], s[D][26];
	int t[D] = {0};
	ll bestSat = 0;
	for (int i = 0; i < 26; i++) {
		scanf("%d", &c[i]);
	}
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			scanf("%d", &s[i][j]);
		}
	}
	/**/
	for (int i = 0; i < D; i++) {
		scanf("%d", &t[i]);
	}
	int m;
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		int d, q;
		scanf("%d%d", &d, &q);
		t[d - 1] = q;
		ll tmpSat = calcSat(t, s, c);
		printf("%lld\n", tmpSat);
	}
	return 0;
}


Measured memory_bytes: 1768
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

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


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

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

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

#endif

// main.cpp

int main() {
  i64 A, B, C;
  std::cin >> A >> B >> C;
  std::cout << std::max<i64>(C - (A - B), 0) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define read(x) scanf("%d",&x)
using namespace std;
bool check(int x) {
    if(x==111) return true;
    if(x==222) return true;
    if(x==333) return true;
    if(x==444) return true;
    if(x==555) return true;
    if(x==666) return true;
    if(x==777) return true;
    if(x==888) return true;
    if(x==999) return true;
    return false;
}
int main() {
    int a;
    cin>>a;
    for(int i=a;i<=999;i++) {
        if(check(i)) {
            cout<<i<<endl;
            break;
        }
    }
}


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

const int INF = 2147483647;

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(){

    string s,t; cin >> s >> t;
    int s_len = (int)s.length(); int t_len = (int)t.length();
    vector<vector<int>> dp(s_len+1, vector<int>(t_len+1,0));

    for(int i = 0; i < s_len; i++){
        for(int j = 0; j < t_len; j++){

            if(s[i]==t[j]){dp[i+1][j+1] = dp[i][j] + 1;}
            chmax(dp[i+1][j+1], dp[i+1][j]); chmax(dp[i+1][j+1], dp[i][j+1]);
            //cout << "dp[" << i+1 << "][" << j+1 << "] = " << dp[i+1][j+1] << " ";
        }
        //cout << endl;
    }

    string LCS = "";
    int i = s_len; int j = t_len;
    while(i>0 && j>0){

        if(s[i-1] == t[j-1]){LCS = s[i-1] + LCS; /*cout << "dp[" << i << "][" << j << "] " << LCS << endl;*/ i--; j--;}
        else if(dp[i][j] == dp[i-1][j]){i--;}
        else{j--;}
    }

    cout << LCS << endl;
}

Measured memory_bytes: 35584
#include<string>
#include<cstring>
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int a,b,c;
    double i;
    cin>>a>>b;
    if(b/100!=0) a=a*1000;
    else if(b/10!=0) a=a*100;
        else a=a*10;
    c=a+b;
    i=sqrt(c);
    c=(int)i;
    if(c==i) cout<<"Yes";
    else cout<<"No";
//    system("Pause");
    return 0;
}


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

int main() {
    int n, i;
    cin >> n;
    int lst[n], ans[n];
    for(i = 0; i < n; i++){
        ans[i] = 0;
    }
    for(i = 1; i < n; i++){
        cin >> lst[i];
        ans[lst[i]-1]++;
    }
    for(i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
}

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

namespace OnlineJudge
{
    class ITP1_2_D
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            if (str.Length < 5)
                return;

            var w = int.Parse(str[0]);
            var h = int.Parse(str[1]);
            var x = int.Parse(str[2]);
            var y = int.Parse(str[3]);
            var r = int.Parse(str[4]);

            if(x-r >= 0 &&
                y-r >= 0 &&
                x+r <= w &&
                y+r <= h)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}

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

int twopow(int n)
{
	int ans = 1;
	for(int i=0;i<n;i++){
		ans *= 2;
	}
	return ans;
}

int main()
{
	int n;
	while(cin >> n){
		bool o[10] = {0};
		int mn=n;
		for(int i=0;i<10;i++){
			o[i] = (mn%2==1);
			mn/=2;
		}
		bool flag=false;
		for(int i=0;i<10;i++){
			if(o[i]==1){
				if(flag==true)
					cout << " ";
				flag = true;
				cout << twopow(i);
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

class Pair implements Comparable<Pair> {
    Node node;
    int frequency;

    Pair(Node node, int frequency) {
        this.node = node;
        this.frequency = frequency;
    }

    public int compareTo(Pair p) {
        return frequency - p.frequency;
    }
}

class Node {
    char c;
    Node parent;

    Node(char c) {
        this.c = c;
    }

    int depth() {
        if(parent == null) return 0;
        return parent.depth() + 1;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        String s = sc.next();
        int[] frequency = new int[26];
        for(int i = 0; i < s.length(); i++) {
            frequency[s.charAt(i) - 'a']++;
        }

        PriorityQueue<Pair> que = new PriorityQueue<>();
        Map<Character, Node> map = new HashMap<>();
        for(int i = 0; i < 26; i++) {
            int tmp = frequency[i];
            if(tmp > 0) {
                char c = (char)('a' + i);
                Node node = new Node(c);
                que.add(new Pair(node, tmp));
                map.put(c, node);
            }
        }

        while(que.size() > 1) {
            Pair p1 = que.poll();
            Pair p2 = que.poll();
            Node n1 = p1.node;
            Node n2 = p2.node;

            Node parent = new Node('.');
            n1.parent = parent;
            n2.parent = parent;
            int newFreq = p1.frequency + p2.frequency;
            que.add(new Pair(parent, newFreq));
        }

        int res = 0;
        for(int i = 0; i < 26; i++) {
            int tmp = frequency[i];
            if(tmp > 0) {
                char c = (char)('a' + i);
                res += tmp * (map.get(c).depth());
            }
        }

        System.out.println(map.size() > 1? res : s.length());
        
        sc.close();
    }
}



Measured memory_bytes: 29688
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var s []int
	var m, a2 float64
	for {
		fmt.Scan(&n)
		if n == 0 {
			break
		}
		s = make([]int, n)
		m = 0
		a2 = 0
		for i := 0; i < n; i++ {
			fmt.Scan(&s[i])
			m += float64(s[i])
		}
		m /= float64(n)
		for i := 0; i < n; i++ {
			a2 += math.Pow(float64(s[i])-m, 2)
		}
		a2 /= float64(n)
		fmt.Println(math.Sqrt(a2))
	}
	return
}



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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

ll dp[100010][13];

int main()
{
    string s; cin >> s;
    dp[0][0] = 1;
    int n = s.size();
    rep(i,n) rep(j,13){
        if(s[i] == '?'){
            rep(k,10){
                dp[i+1][(j*10+k)%13] += dp[i][j];
                dp[i+1][(j*10+k)%13] %= mod;
            }
        }else{
            int nd = s[i] - '0';
            dp[i+1][(j*10+nd)%13] += dp[i][j];
            dp[i+1][(j*10+nd)%13] %= mod;
        }
    }
    cout << dp[n][5] << endl;
}

Measured memory_bytes: 10624
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
int i,j,k,l;
static const int MAX_N=10e5;
int N;
long a,ans,sum=10e9,res;
int main(void){
	cin >> N;
	rep(i,0,N){
		cin >> a;
		ans+=abs(a);
		sum=min(sum,abs(a));
		if(a<0)
			res++;
	}
	if(res%2){
		puts(ans-sum*2);
	}else{
		puts(ans);
	}
	
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    ll a=0,b=0;
    VL arr,brr;
    fr(i,0,n)
    {
        ll x;
        cin>>x;
        arr.pb(x);
        a+=x;
    }
    fr(i,0,n)
    {
        ll x;
        cin>>x;
        brr.pb(x);
        b+=x;
    }
    if(b>=a)
    {
        ll k=abs(b-a);
        ll ar=0,br=0;
        fr(i,0,n)
        {
            if(arr[i]<brr[i])
            {
                ar+=(brr[i]-arr[i]+1)/2;
                if(brr[i]%2!=arr[i]%2)br++;
            }
            else
            {
                br+=(arr[i]-brr[i]);
            }
        }  
        if(ar>k||br>k)
            cout<<"No\n";
        else 
            cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3876
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
const int M = 80 * 160;
bool dp[80][80][M];

main(){
    int H,W;
    cin >> H >> W;
    int tableA[H][W], tableB[H][W];
    rep(i,0,H)rep(j,0,W)cin >> tableA[i][j];
    rep(i,0,H)rep(j,0,W)cin >> tableB[i][j];
    
    int dif = tableA[0][0] - tableB[0][0];
    dp[0][0][abs(dif)] = 1;

    rep(i,1,H){
        rep(k,0,M){
            if(!dp[i-1][0][k])continue;
            int dif = abs(tableA[i][0] - tableB[i][0]);
            dp[i][0][k+dif] = 1;
            dp[i][0][abs(k-dif)] = 1;
        }
    }
    rep(j,1,W){
        rep(k,0,M){
            if(!dp[0][j-1][k])continue;
            int dif = abs(tableA[0][j] - tableB[0][j]);
            dp[0][j][k+dif] = 1;
            dp[0][j][abs(k-dif)] = 1;
        }
    }
    rep(i,1,H)rep(j,1,W){
        rep(k,0,M){
            if(dp[i-1][j][k] || dp[i][j-1][k]){
                int dif = abs(tableA[i][j] - tableB[i][j]);
                dp[i][j][k+dif] = 1;
                dp[i][j][abs(k-dif)] = 1;
            }
        }
    }
    int mini = INF;
    rep(k,0,M){
        if(dp[H-1][W-1][k]){
            mini = min(mini, k);
            break;
        }
    }
    cout << mini << endl;

    
}

Measured memory_bytes: 79488
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <bitset>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define x  first
#define y  second
#define mp make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#ifndef ONLINE_JUDGE
	// #include "debug.h"
#else
// #define debug(...) 42
#endif

const int mxN=5e5+5;
const ld PI=acos(-1);
const int MD=1e9+9;


int main() {
	fast_cin();
	int t=1;
	// cin>>t;
	while(t--)
	{
		int x,ans;
		cin>>x;
		if(x>=400 && x<600) ans=8;
		if(x>=600 && x<800) ans=7;
		if(x>=800 && x<1000) ans=6;
		if(x>=1000 && x<1200) ans=5;
		if(x>=1200 && x<1400) ans=4;
		if(x>=1400 && x<1600) ans=3;
		if(x>=1600 && x<1800) ans=2;
		if(x>=1800 && x<2000) ans=1;
		cout<<ans;
	}
	return 0;	
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                int N = scan.nextInt();
                int K = scan.nextInt();

                int[] A = new int[N];
                int[] B;

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

                scan.close();

	                int log2N = 0;
	                int tempN = N;

	                while (tempN > 1) {
	                	tempN /= 2;
	                	log2N++;
	                }

                if (K >= log2N + 100) {

                	for (int k = 0; k < N; k++) {
                    	System.out.print(N + " ");
                    }

                    System.out.println();

                } else {

	                for (int j = 0; j < K; j++) {

	                	B = new int[N];

	                	for (int n1 = 0; n1 < N; n1++) {

	                		if (n1 - A[n1] > 0) {
	                			B[n1 - A[n1]]++;
	                		} else {
	                			B[0]++;
	                		}

	                		if (n1 + A[n1] + 1 < N) {
	                			B[n1 + A[n1] + 1]--;
	                		}

	                	}

	                	for (int n2 = 0; n2 < N-1; n2++) {
	                		B[n2+1] += B[n2];

	                	}

	                	A = B;

	                }

	                for (int k = 0; k < N; k++) {
	                	System.out.print(A[k] + " ");
	                }

	                System.out.println();

                }

        }

}

Measured memory_bytes: 62868
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>
 
int main(void)
{
    int64_t N;
    std::string S;
    std::cin >> N >> S;

    auto valid = [&](const std::string& key){
        int64_t index = 0;
        index = S.find_first_of(key.at(0), index);
        if (index == std::string::npos) return false;
        if (index+1 >= S.size()) return false;
        index = S.find_first_of(key.at(1), index+1);
        if (index == std::string::npos) return false;
        if (index+1 >= S.size()) return false;
        index = S.find_first_of(key.at(2), index+1);
        if (index == std::string::npos) return false;
        return true;
    };

    int64_t count = 0;
    for (int64_t i = 0; i <= 999; ++i) {
        std::stringstream ss;
        ss << std::setw(3) << std::setfill('0') << i;
        std::string key = ss.str();
        if (valid(key)) count++;
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  string str; cin >> str;
  sort(str.begin(), str.end());
  bool ans = false;
  if (str[0] == str[1] && str[1] != str[2] && str[2] == str[3]) {
    ans = true;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M;
vint G[111111];
bool vis[111111];
int ord[111111],low[111111];
vpint bridge;
void dfs(int v,int p,int &k){
    ord[v]=k++;
    low[v]=ord[v];
    vis[v]=true;
    for(auto u:G[v]){
        if(vis[u]){
            if(u!=p)chmin(low[v],ord[u]);
        }
        else{
            dfs(u,v,k);
            if(ord[v]<low[u])bridge.pb({min(v,u),max(v,u)});
            chmin(low[v],low[u]);
        }
    }
}

signed main(){
    cin>>N>>M;
    rep(i,M){
        int a,b;cin>>a>>b;
        G[a].pb(b);G[b].pb(a);
    }
    int k=0;dfs(0,-1,k);
    sort(all(bridge));
    rep(i,bridge.size())cout<<bridge[i].fi<<" "<<bridge[i].se<<endl;
}

Measured memory_bytes: 7992
#include<stdio.h>
int main()
{
	int k,s,x,y,z,c=0;

	scanf("%d%d",&k,&s);

	for(x=0;x<=k;x++)
		for(y=0;y<=k;y++){
			z=s-x-y;
			if(0<=z&&z<=k)
				c++;
		}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 1> { using type = vector<T>; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

struct Edge {
  int to, sum;
};

struct Var {
  int sign;
  ll C;
};

const ll INF = 1ll << 60;

int main() {
  int N, M;
  while (cin >> N >> M) {
    vec<Edge, 2> G(N);
    for (int i = 0; i < M; i++) {
      int a, b, s;
      cin >> a >> b >> s;
      --a;
      --b;
      G[a].push_back({b, s});
      G[b].push_back({a, s});
    }
    vector<bool> assign(N, false);
    vector<Var> vars(N);
    vars[0] = Var{1, 0};
    assign[0] = true;
    ll low = -INF, high = INF;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
      auto v = q.front();
      q.pop();
      auto cur = vars[v];
      for (auto& e : G[v]) {
        Var expected = {-cur.sign, e.sum - cur.C};
        if (!assign[e.to]) {
          vars[e.to] = expected;
          assign[e.to] = true;
          q.push(e.to);
        } else {
          auto actual = vars[e.to];
          if (expected.sign == actual.sign) {
            if (expected.C != actual.C) {
              low = INF;
              high = -INF;
            }
          } else {
            ll k = actual.sign - expected.sign;
            ll C = expected.C - actual.C;
            if (C % k != 0) {
              low = INF;
              high = -INF;
            } else {
              ll t = C / k;
              low = max(low, t);
              high = min(high, t);
            }
          }
        }
      }
    }
    for (auto v : vars) {
      if (v.sign > 0) {
        low = max(low, 1 - v.C);
      } else {
        high = min(high, v.C - 1);
      }
    }
    ll res = max(0ll, high - low + 1);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 8436
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Mar 22 21:00:14 JST 2020
 **/

signed main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    map<Int, Int> cnt;
    REP(i, n) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    Int ans = 0;
    for (auto& p : cnt) {
        ans += p.second * (p.second - 1) / 2;
    }
    REP(i, n) {
        Int tmp = ans - cnt[a[i]] * (cnt[a[i]] - 1) / 2 + (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
        cout << tmp << endl;
    }
}


Measured memory_bytes: 12032
n=int(input())
l=list(map(int,input().split()))
a=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            b=[l[i],l[j],l[k]]
            p,q,r=min(b),sum(b)-min(b)-max(b),max(b)
            a+=(len(set(b))==3)and (p+q>r)
print(a)

Measured memory_bytes: 9200
#include <stdio.h>

int main(void)
{
	int x=0,i;
	for(i = 0; i < 10000; ++i)
	{
		scanf("%d",&x);
		if(x==0)
		{
			break;
		}
		printf("Case %d: %d\n", i+1,x);
	}
	return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var S = new LinkedList<char>(Console.ReadLine());
            var Q = int.Parse(Console.ReadLine());
            var strs = new char[500000];
            var ltor = true;
            for(var i=0;i<Q;i++)
            {
                var ac = ReadLine().Split().ToArray();

                if(ac[0]=="1")
                {
                    ltor = !ltor;
                }
                else
                {
                    if(ltor)
                    {
                        if (ac[1] == "1")
                        {
                            S.AddFirst(ac[2][0]);
                        }
                        else
                        {
                            S.AddLast(ac[2][0]);
                        }
                    }
                    else
                    {
                        if (ac[1] != "1")
                        {
                            S.AddFirst(ac[2][0]);
                        }
                        else
                        {
                            S.AddLast(ac[2][0]);
                        }
                    }
                }
            }
                var ans = "";
            if(!ltor)
            {
                ans = string.Join("",S.Reverse());
            }
            else
            {
                ans = string.Join("", S);
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 36624