akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
const int INF = 1e9;
const int MOD = 1e9+7;

vi connection;
vi uf;

int root(int x)
{
    if(uf[x] == x) return x;
    return uf[x] = root(uf[x]);
}

void unite(int x, int y)
{
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    uf[rx] = ry;
}

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

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int N, M, K; cin >> N >> M >> K;
    vector<set<int>> S(N);
    connection.resize(N);
    uf.resize(N); REP(i, N) uf[i] = i;
    REP(i, M)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        S[a].insert(b);
        S[b].insert(a);
        unite(a, b);
    }
    vi count(N);
    REP(i, N) root(i);
    REP(i, N) count[uf[i]]++;
    REP(i, N) connection[i] = count[uf[i]];
    REP(i, K)
    {
        int c, d; cin >> c >> d;
        c--; d--;
        if(same(c, d))
        {
            S[c].insert(d);
            S[d].insert(c);
        }
    }

    REP(i, N)
    {
        cout << max(0, connection[i]-1 - (int)S[i].size()) << " ";
    }
    cout << endl;

}

Measured memory_bytes: 26112
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 2e5+50;

int lastp[N],ok[N];

int main(){
	
	fastio;
	int n;
	cin >> n;
	vector<ii> vec(n);
	for(int i = 0; i < n; ++i){
		cin >> vec[i].fst >> vec[i].snd;
	}
	sort(vec.begin(),vec.end());

	ll dp[N], MOD = 998244353;
	dp[n] = 1;
	stack<ii> stk;
	stk.push(ii(n,2e9));
	for(int i = n-1; i >= 0; --i){
		while(stk.top().snd < vec[i].fst + vec[i].snd)
			stk.pop();
		int p = stk.top().fst;
		dp[i] = (dp[p]+dp[i+1]) % MOD;
		stk.push(ii(i,vec[i].fst));
	}

	cout << dp[0] << endl;

	return 0;
}


Measured memory_bytes: 4224
import java.io.*;
import java.util.*;
 
 
public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      
      // Start writing your solution here. -------------------------------------
     int n = sc.nextInt();
     int res = 0;
     res += n / 500 * 1000;
     n %= 500;
     res += n / 5 * 5;
     out.println(res);
      /*
      int n      = sc.nextInt();        // read input as integer
      long k     = sc.nextLong();       // read input as long
      double d   = sc.nextDouble();     // read input as double
      String str = sc.next();           // read input as String
      String s   = sc.nextLine();       // read whole line as String

      int result = 3*n;
      out.println(result);                    // print via PrintWriter
      */

      // Stop writing your solution here. -------------------------------------
      out.close();
   }

     

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;
      
   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
   //--------------------------------------------------------
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define b begin
#define e end
using namespace std;
int main()
{
    ll n,i,j;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n,greater<int>());
    ll s=a[0];
    for(i=1;i<(n/2);i++){
        s+=2*a[i];
    }
    if(n%2!=0)
    s+=a[n/2];
    cout<<s;
}

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

int main(){
    string s,t;
    while(cin >> s&&s!="."){
        cin >> t;
        vector<string> v1,u1,v2,u2;
        bool flag = 0;
        string tmp;
        for(int i=0;i<s.size();i++){
            if(s[i]=='"'&&!flag){
                v1.push_back(tmp);
                flag = 1;
                tmp.clear();
            }else if(s[i]=='"'&&flag){
                u1.push_back(tmp);
                flag = 0;
                tmp.clear();
            }else{
                tmp.push_back(s[i]);
            }
        }
        v1.push_back(tmp);
        string tmp2;
        flag = 0;
        for(int i=0;i<t.size();i++){
            if(t[i]=='"'&&!flag){
                v2.push_back(tmp2);
                flag = 1;
                tmp2.clear();
            }else if(t[i]=='"'&&flag){
                u2.push_back(tmp2);
                flag = 0;
                tmp2.clear();
            }else{
                tmp2.push_back(t[i]);
            }
        }
        v2.push_back(tmp2);
        
        if(v1.size()!=v2.size()||u1.size()!=u2.size()){
            cout << "DIFFERENT" << endl;
            continue;
        }
        flag =0;
        for(int i=0;i<v1.size();i++){
            if(v1[i]!=v2[i]){
                cout <<"DIFFERENT" << endl;
                flag = 1;
                break;
            }
        }
        if(flag)continue;
        int cnt = 0;
        for(int i=0;i<u1.size();i++){
            if(u1[i]!=u2[i]){
                cnt++;
            }
        }
        if(cnt==0){
            cout << "IDENTICAL" << endl;
        }else if(cnt==1){
            cout << "CLOSE" << endl;
        }else{
            cout << "DIFFERENT" << endl;
        }

        
    }
    return 0;
}


Measured memory_bytes: 3200
#!/usr/bin/env python
# -*- coding: utf-8 -*-

k, n = map(int, input().split())
an = list(map(int, input().split()))

m = an[0] + (k - an[-1])
for i in range(1, n):
    d = abs(an[i] - an[i-1])
    m = max(m, d)

print(k-m)


Measured memory_bytes: 26444
N = int(input())
c = [0]*(N-1)
s = [0]*(N-1)
f = [0]*(N-1)
for i in range(N-1):
    c[i],s[i],f[i] = list(map(int,(input().split())))
for i in range(N):
    time = 0
    for j in range(i,N-1):
        if time < s[j]:
            time = s[j]
        time += (-time) % f[j]
        time += c[j]
    print(time)

    

Measured memory_bytes: 42092
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, k) = readIntegerList()
    val pList = readIntegerList().sorted()
    val ans = pList.take(k).sum()
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 40780
#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue<int, vector<int>, greater<int> > q;
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// vector<int>().swap(v);清空释放内存
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
#define ld long double
#define ull unsigned long long
#define db double
#define ll long long
const db eps=1e-7;
//const db pi=acos(-1);
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (ll i=be;i<=en;i++)
#define per(i,be,en) for (int i=en;i>=be;i--)
using namespace std;
const int N=1e5+7;

int tc,n,m,fl=0;

int main(){
    scanf("%d%d%d",&tc,&n,&m);
    if(n>m) swap(n,m);
    for(int i=1;i<=m;i++){
        if(i*tc>=n&&i*tc<=m){
            printf("OK\n");
            fl=1;
            break;
        }
    }
    if(fl==0) puts("NG");
    return 0;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}


void solve()
{
     int n;
     cin>>n;
     int a[n];
     int sum[n];
     memset(sum,0,sizeof(sum));
     rep(i,0,n)
     {
        cin>>a[i];
        a[i]=a[i]%MOD;
        if(i==0)
        {
            sum[i]=(a[i])%MOD;continue;
        }
        sum[i]=(a[i]%MOD+sum[i-1]%MOD)%MOD;
     }
     
     //cout<<endl;
     int ans=0;
     rep(i,0,n)
     {
        int sum1=(sum[n-1]-sum[i]);
        if(sum1<0)
            sum1=(sum1+MOD)%MOD;
        sum1=(sum1%MOD*a[i]%MOD)%MOD;
       ans=(ans%MOD+sum1%MOD)%MOD;
     }
     cout<<ans;


}

signed main()
{
        FIO
          
        
        int t=1;
        //cin>>t;
        while(t--)
        solve();
        cerr<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N;
	cin >> N;
	vector<int64_t> A(N);
	for (auto& ai : A)
		cin >> ai;
	sort(all(A));
	reverse(all(A));
	int64_t res = A[0];
	N-=2;
	int pos = 1;
	while(N>0)
	{ 
		if(N>=2)
			res += 2 * A[pos];
		else
			res += A[pos];
		N -= 2;
		pos++;
	}
	cout << res << endl;
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    int X,A,B; cin >>X>>A>>B;
    string ans;
    if (B <= A)
        ans = "delicious";
    else if (B <= A + X)
        ans = "safe";
    else
        ans = "dangerous";

    cout << ans << endl;
}


Measured memory_bytes: 256
a, b,c = gets.chomp.split(" ").map(&:to_i)
k = gets.chomp.to_i
cost = 0
until b > a
    b = b * 2
    cost += 1
end
until c > b
    c = c * 2
    cost += 1
end
if cost > k
    puts "No"
else
    puts "Yes"
end

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

int main() {
  int n;
  cin >> n;
  vector<int> A(n),B(n);
  rep(i,n) {
    cin >> A[i];
    B[A[i]-1] = i + 1;
  }
  rep(i,n) {
    if( i ) printf(" ");
    cout << B[i];
  } puts("");
  compute();
  return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include<math.h>
#include<bitset>
#include<string>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include <iomanip>
using namespace std;

int main()
{
    int n; cin>>n;
    int a[n],ans[n];
    for(int i=0;i<n;i++)cin>>a[i];
    
    for(int i=0;i<n;i++){
        ans[a[i]-1]=i+1;
    }
    if(n!=1){
        cout<<ans[0];
        for(int i=1;i<n-1;i++)cout<<" "<<ans[i];
        cout<<" "<<ans[n-1]<<endl;
    }else cout<<1<<endl;
    
    return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

set<pii> g[MAXN];
set<int> st;

map<int, int> cnt;

vi vv;

void solve(){
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, 0, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].insert(mp(b, 2 * i));
		g[b].insert(mp(a, 2 * i + 1));
	}
	int cnt4 = 0;
	REPN(i, 1, n) {
		if (SZ(g[i]) % 2 == 1) {
			printf("No\n");
			return;
		}
		if (SZ(g[i]) >= 4) {
			cnt4++;
		}
	}
	if (m <= n + 1) {
		printf("No\n");
		return;
	}
	/*if (m == n + 2 && cnt4 == 2) {
		printf("No\n");
		return;
	}*/
	REPN(i, 1, n) {
		if (SZ(g[i]) == 2) {
			st.insert(i);
		}
	}
	while(!st.empty()) {
		int a = *st.begin();
		st.erase(a);
		pii pp0 = *g[a].begin();
		g[a].erase(pp0);
		pii pp1 = *g[a].begin();
		g[a].erase(pp1);
		g[pp0._1].erase(mp(a, pp0._2 ^ 1));
		g[pp0._1].insert(mp(pp1._1, pp0._2 ^ 1));
		g[pp1._1].erase(mp(a, pp1._2 ^ 1));
		g[pp1._1].insert(mp(pp0._1, pp0._2));
	}
	REPN(i, 1, n) {
		if (SZ(g[i]) > 0) {
			vv.pb(i);
		}
	}
	if (SZ(vv) == 1 && SZ(g[vv[0]]) < 6) {
		printf("No\n");
		return;
	}
	if (SZ(vv) == 2 && SZ(g[vv[0]]) == 4 && SZ(g[vv[1]]) == 4) {
		int fl = 0;
		REP(i, 0, 2) {
			FA(it, g[vv[i]]) {
				if (it->_1 == vv[i]) {
					fl = 1;
				}
			}
		}
		if (!fl) {
			printf("No\n");
			return;
		}
	}
	printf("Yes\n");
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll func(ll X) {
	ll res = 0;
	if (X % 4 == 1 || X % 4 == 2) res = 1;
	for (int i = 59; i > 0; i--) if (X >> i & 1) {
		if ((X - (1ll<<i) + 1) % 2) {
			res |= 1ll<<i;
			X -= 1ll<<i;
		}
	}
	return res;
}

int main() {
	ll A, B;
	cin >> A >> B;
	
	
	ll ans = 0;
	if (A == 0) ans = func(B);
	else ans = func(B) ^ func(A - 1);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
//#define anjn
//      Anjan Agarwala - anjn98

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, 
                  tree_order_statistics_node_update> ordered_set;

//ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

#define PR(x) cout<<#x<<": "<<x<<"\n";
#define PR1(x,y) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"  |  "<<#z<<": "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define PB              push_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007


const int N=1e5+99;

vector<int> gy[N],gx[N],gg[N];
ll sz=0,mx=0,cs=0;

bool vis[N];
set<int> xx;

void dfs(int v)
{
    sz++;   
    xx.insert(v);
    cs+=(ll)gx[v].size();
    vis[v]=1;
    trav(x,gg[v])
        if(!vis[x])
            dfs(x);
}



int32_t main() 
{
    IO
    

    

    int n; cin>>n;

    fr(n)
    {
        int x,y;
        cin>>x>>y;
        gy[y].PB(x);
        gx[x].PB(y);
    }
    ll cnt=0;
    fr(N)
    {
        if(gy[i].size()<=1)
            continue;


        for(int j=0;j<gy[i].size()-1;j++)
            gg[gy[i][j]].push_back(gy[i][j+1]),
            gg[gy[i][j+1]].push_back(gy[i][j]);
    }

    ll ans=0;

    for(int i=1;i<N;i++)
    {
        if(gg[i].size()==0) continue;
        sz=cs=0;
        xx.clear();
        if(!vis[i])
            dfs(i);
        set<int> yy;
        trav(x,xx)
        {
            trav(y1,gx[x]) yy.insert(y1);
        }
        ll ta=yy.size();
        ta=ta*sz;
        ta-=cs;
        ans+=ta;

    }
    cout<<ans<<endl;


}




 



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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k,x;
    cin >> n>> m >> x;
    ll c[n];
    ll a[n][m];
    for(i=0;i<n;i++){
        cin >> c[i];
        for(j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    ll ret = INF;
    for(i=0;i<1<<n;i++){
        ll cost = 0;
        ll und[m]={};
        for(j=0;j<n;j++){
            if(i>>j &1){
                cost+=c[j];
                for(k=0;k<m;k++){
                    und[k]+=a[j][k];
                }
            }
        }
        ll cnt=0;
        for(j=0;j<m;j++){
            if(und[j]>=x)cnt++;
        }
        if(cnt==m)ret = min(ret,cost);
    }
    if(ret==INF){
        cout << -1 << endl;
    }else 
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, k, s;
    while (cin >> n >> k >> s && n){
        int comb = (1 << k) - 1;
        int ans = 0;
        while (comb < (1 << n)){
            int p = 0;
            REP(i,n){
                if ((comb >> i) & 1) p += i + 1;
            }
            if (p == s) ans++;
            int x = comb & -comb, y = comb + x;
            comb = ((comb & ~y) / x >> 1) | y;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3036
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        s: i32,
        w: i32,
    }
    if s <= w {
        println!("unsafe");
    } else {
        println!("safe");
    }
}


Measured memory_bytes: 2124
W, H, N = map(int, input().split())
XYA = [list(map(int, input().split())) for _ in range(N)]

x_min = max((xya[0] for xya in XYA if xya[2] == 1), default=0)
x_max = min((xya[0] for xya in XYA if xya[2] == 2), default=W)
y_min = max((xya[1] for xya in XYA if xya[2] == 3), default=0)
y_max = min((xya[1] for xya in XYA if xya[2] == 4), default=H)
print(max(x_max - x_min, 0) * max(y_max - y_min, 0))


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


void solve() {
  string s;
  cin >> s;
  sort(ALL(s));
  if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

long long modpow(long long x,long long n,long long mod)
{
  if(n==0)return 1;
  long long res=modpow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  ll mod= 998244353;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int sa=0;
  rep(i,n)sa+=a[i];
  int l=sa/2;
  vector<ll>dp(l+1,0LL);
  dp[0]=1;
  rep(i,n)
  {
    for(int j=l-a[i];j>=0;j--)
    {
      if(dp[j]==0)continue;
      dp[j+a[i]]+=dp[j]*2;
      dp[j+a[i]]%=mod;
    }
  }
  ll res=modpow(3,n,mod);
  rep(i,l+1)dp[i]=dp[i]*3;
  for(auto i:dp)res+=3*mod-i;
  res%=mod;
  if(!(sa&1))
  {
    fill(all(dp),0LL);
    dp[0]=1;
    rep(i,n)
    {
      for(int j=l-a[i];j>=0;j--)
      {
        if(dp[j]==0)continue;
        dp[j+a[i]]+=dp[j];
        if(dp[j+a[i]]>=mod)dp[j+a[i]]-=mod;
      }
    }
    res+=dp.back()*3;
  }
  cout<<res%mod<<endl;


  return 0;

}


Measured memory_bytes: 768
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


n, m,c = map(int, input().split())
b = list( map(int, input().split()))
ans = 0
for i in range(n):
    a = list( map(int, input().split()))
    tmp = 0
    for j in range(m):
        tmp += b[j]*a[j]
    if tmp + c > 0:
        ans+=1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

class SegmentTree {
private:
    std::size_t n;
    std::vector<long long> data;
private:
    static std::size_t arrangeSize(std::size_t n) {
        std::size_t m = 1;
        while(m < n) m *= 2;
        return m;
    }
    long long queryImpl(int a, int b, int i, int l, int r, long long defaultValue) const noexcept {
        if(r <= a || b <= l) return defaultValue;

        if(a <= l && r <= b) return data[i];
        else {
            long long left = queryImpl(a, b, 2 * i + 1, l, (l + r) / 2, defaultValue);
            long long right = queryImpl(a, b, 2 * i + 2, (l + r) / 2, r, defaultValue);
            return std::min(left, right);
        }
    }
public:
    SegmentTree(std::size_t n, long long defaultValue = std::numeric_limits<long long>::max())
            :n(arrangeSize(n)), data(2 * arrangeSize(n) - 1, defaultValue){}
    void update(std::size_t m, long long val) noexcept {
        int cur = m + n - 1;
        data[cur] = val;
        while(0 < cur) {
            int p = (cur - 1) / 2;
            data[p] = std::min(data[2 * p + 1], data[2 * p + 2]);
            cur = p;
        }
    }
    long long query(int a, int b, long long defaultValue = std::numeric_limits<long long>::max()) const noexcept {
        return queryImpl(a, b, 0, 0, n, defaultValue);
    }
};

int main() {
    int n, q;
    std::cin >> n >> q;
    SegmentTree segmentTree(n, 2147483647);
    while(q--) {
        int c, x, y;
        std::cin >> c >> x >> y;
        if(c == 0) {
            segmentTree.update(x, y);
        } else {
            std::cout << segmentTree.query(x, y + 1, 2147483647) << "\n";
        }
    }
    std::cout << std::flush;

    return 0;
}



Measured memory_bytes: 4900
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int A[]=new int [N];
		A[0]=0;
		int B[]=new int [N];
		for(int i=1;i<N;i++){
			A[i] =scan.nextInt();
		}
		for(int i=1;i<N;i++){
			B[A[i]-1]+=1;
		}
		for(int i=0;i<N;i++){
			System.out.println(B[i]);
		}

	}

}


Measured memory_bytes: 62864
#include <iostream>
#include <vector>

using namespace std;

using ll = long long;

template <typename T>
T sq(T a) {
    return a * a;
}

vector<int> path[100010];
int d[100010];

// vを含む連結成分に奇数長の閉路が含まれるか
bool dfs(int v) {
    bool ret = false;

    for (int sv : path[v]) {
        if (d[sv] < 0) {
            d[sv] = d[v] + 1;
            ret = dfs(sv) || ret;
        } else if ((d[v] - d[sv]) % 2 == 0) {
            // 奇数長閉路判定
            ret = true;
        }
    }

    return ret;
}

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

    for (int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        path[u].push_back(v);
        path[v].push_back(u);
    }

    ll single = 0, odd = 0, even = 0;
    // single = 頂点数1の連結成分(孤立点)の数
    // odd = 奇数長の閉路をもつ連結成分の数
    // even = それ以外の連結成分の数

    fill(d, d + N, -1);

    for (int v = 0; v < N; ++v) {
        if (d[v] >= 0) continue;

        d[v] = 0;
        if (path[v].empty()) {
            ++single;
        } else {
            if (dfs(v)) {
                ++odd;
            } else {
                ++even;
            }
        }
    }

    cout << sq(N) - sq(N - single) + sq(even + odd) + sq(even) << endl;
    return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,s[100000],a,ans1,ans2,cnt,cn;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a;
        cnt=0;
        while(a){
            s[cnt]+=(1&a);
            a=(a>>1);
            cnt++;
        }
        cn=max(cnt,cn);
    }
    //cout<<cn<<endl;
    cnt=0;
    while(k>0||cn>0){
        cn--;
        if(k==0){
            ans1+=s[cnt]*(1LL<<cnt);
            cnt++;
            //cout<<ans1<<ans2<<endl;
            continue;
        }
        /*
        if(k==1){
            ans2+=s[cnt]*(1LL<<cnt);
            ans1+=max(s[cnt],n-s[cnt])*(1LL<<cnt);
            cnt++;
            k=k>>1LL;
            continue;
        }*/
        if(!(k&1)){
            //cout<<s[cnt]<<endl;
            ans1+=s[cnt]*(1LL<<cnt);
            ans2+=max(s[cnt],n-s[cnt])*(1LL<<cnt);
            k=k>>1LL;
            cnt++;
        }
        else{
            ans1=max(ans1+(n-s[cnt])*(1LL<<cnt),ans2+s[cnt]*(1LL<<cnt));
            ans2+=max(s[cnt],n-s[cnt])*(1LL<<cnt);
            k=k>>1LL;
            cnt++;
        }
        //cout<<ans1<<ans2<<endl;
    }
    cout<<ans1<<endl;
    //for(int i=0;i<3;i++)cout<<s[i]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long Res;
int X, Y;
void XuLy(int A)
{
    if (A == 1)
        Res += 300000;
    else if (A == 2)
        Res += 200000;
    else if (A == 3)
        Res += 100000;
}
int main()
{
    //freopen("Test.INP","r",stdin);
    //freopen("Test.OUT","w",stdout);
    cin >> X >> Y;
    XuLy(X);
    XuLy(Y);
    if (X == Y && X == 1)
        Res += 400000;
    cout << Res;
    return 0;
}


Measured memory_bytes: 256
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y

n = ini()
a = inl()
ans = 1
lim = 10 ** 18
for i in a:
        ans *= i
        if ans > lim:
                ans = -1
                break
if min(a) == 0:
        ans = 0
print(ans)


Measured memory_bytes: 87552
import sys
readline = sys.stdin.readline

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    ans = 10 ** 7
    for i in range(min(A), max(A)+1):
        c = sum([(a-i)**2 for a in A])
        ans = min(ans, c)
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define bg begin()
#define end end()
#define sz size()
#define vi vector<int>
#define vl vector<long long int>
int main(){
	fast;
	int x,n;
	cin>>x>>n;
	if(n==0)
		{
			cout<<x;
			return 0;
		}
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	set<int> s;
	for(int i=0;i<n;i++)
		s.insert(arr[i]);
	int size=s.size(),old,val1,val2;
	old=size;
	s.insert(x);
	size=s.size();
	if(old!=size)
		{
			cout<<x;
			return 0;
		}
	val1=x+1;
	val2=x-1;
	while(1){
		old=size;
		s.insert(val2);
		size=s.size();
		if(old==size)
		{
			val2--;
		}
		else
		{
			cout<<val2;
			return 0;
		}
		old=size;
		s.insert(val1);
		size=s.size();
		if(old==size)
		{
			val1++;
		}
				else
		{
			cout<<val1;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
//define
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define elif else if
//vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
//queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
//mapdefine
#define mint map<int>
#define mc map<char>
//pairdefine
#define pint pair<int,int>
#define pis pair<int,str>
#define pic pair<int,char>
#define pci pair<char,int>
#define mod 100000007
//main
signed main(){
  int D,N,M,O,P,count=0,count2=mod,count3=0,stack=0;
  str S,T;
  double l,s;
  cin>>N>>M;
  vint a(N);
  if(N%(M*2+1)>=1)cout<<N/(M*2+1)+1;
  else cout<<N/(M*2+1)<<endl;
}


Measured memory_bytes: 256
// Vivek Rai
// Blazer_007

#include<bits/stdc++.h>
using namespace std;

#define fastio    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl      '\n'

typedef long long int ll;
const int hell = 1e9 + 7 ;

signed main() {

    fastio

    int s , w;
    cin >> s >> w;

    if(w >= s)
    	cout << "unsafe";
    else
    	cout << "safe";

    return 0;
}

Measured memory_bytes: 3632
N=int(input())
A=input()
B=input()
C=input()


M=0
for i in range(N):
    a=len(set([A[i],B[i],C[i]]))
    if a==2:
        M+=1
    elif a==1:
        M+=0
    elif a==3:
        M+=2
print(M)

Measured memory_bytes: 9204
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define pause system("pause")


signed main() {
	int K,N;
	string S;
	string SK;
	cin >> K >> S;
	N = S.size();
	if (N <= K){
		cout << S << endl;
}
	else {
		REP(i, K) {
			SK+= S.at(i);
		}
		cout << SK << "..." << endl;
	}
	pause;
}

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



int main(void)
{
    int x;
    cin >> x;
    switch(x){
        case 3:
        case 5:
        case 7:
            cout << "YES" << endl;
            break;
        default:
            cout << "NO" << endl;
            break;
    }
    return 0;
}

Measured memory_bytes: 256
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(
            think(4, [[1, 3], [2, 4]]),
            2
        )

    def test_2(self):
        self.assertEqual(
            think(10, [[3, 6], [5, 7], [6, 9]]),
            1
        )

    def test_3(self):
        self.assertEqual(
            think(100000, [[1, 100000]]),
            100000
        )


def solve():
    n, list_of_l_and_r = read()
    result = think(n, list_of_l_and_r)
    write(result)


def read():
    n, m = read_int(2)
    list_of_l_and_r = []
    for _ in range(m):
        list_of_l_and_r.append(read_int(2))
    return n, list_of_l_and_r


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, list_of_l_and_r):
    left = 1
    right = n
    for l, r in list_of_l_and_r:
        if right < l or r < left:
            return 0
        left = max(l, left)
        right = min(r, right)
    return right - left + 1


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 22672
n, m = map(int, input().split())
L, R = [], []
for _ in range(m):
    li, ri = map(int, input().split())
    L.append(li)
    R.append(ri)

# ans = 0

# for i in range(1, n+1):
#     flag = True
#     for li, ri in zip(L, R):
#         if not (i >= li and i <= ri):
#             flag = False
#             break
#     if flag:
#         ans += 1

# print(ans)

ans = min(min(R), n) - min(max(L), n) +1
if ans < 0:
        ans = 0
print(ans)


Measured memory_bytes: 10996
#include<iostream>
#include<vector>
#include<algorithm>
int main(void) {
	int n, q;
	std::cin >> n;
	if (n == 0) { std::cout << 0 << std::endl; return 0; }
	std::vector<long>S(n);
	for (int i = 0; i < n; ++i) {
		std::cin >> S[i];
	}
	std::sort(S.begin(), S.end());
	std::cin >> q;
	if (q == 0) { std::cout << 0 << std::endl; return 0; }
	std::vector<long>T(q);
	for (int i = 0; i < q; ++i) {
		std::cin >> T[i];
	}
	std::sort(T.begin(), T.end());
	int cnt = 0;
	for (int i = 0; i < q; ++i) {
		std::vector<long>::iterator itr= std::find(S.begin(),S.end(), T[i]);
		if (std::binary_search(itr, S.end(), T[i]))
		{
			cnt++;
			itr++;
		}
	}
	std::cout << cnt << std::endl;
	//	system("pause");
	return 0;
}

Measured memory_bytes: 3152
def gcd(n,m):
  if n<m:
    n,m=m,n
  if n%m:
    return gcd(m,n%m)
  else:
    return m

n=int(input())
t=[int(input()) for i in range(n)]
now=t[0]
for i in t[1:]:
  now=now*i//gcd(i,now)
print(now)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

vector<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(){
	ll n; cin >> n;
	comInit();
	vl a(n); rep(i,n) cin >> a[i];
	ll ans = 0;
	ll now = 0;
	rep(i,n-1){
		now += fac[n-1]*inv[i+1]%mod;
		//cout << now << endl;
		ans += (a[i+1]-a[i])%mod*now%mod;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 13056
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;

int k;
int rotates[10];
int ans;
string s,t;

int toRotateCount(int idx) { // ???????????????idx
    int a = ((s[idx] - '0') + rotates[idx]) % 10;
    int b = t[idx] - '0';

    if (a > b) {
        return 10+b - a;
    } else {
        return b - a;
    }
}


void solve(int idx, int rcnt) { // idx = ???

    if (idx == k) {
        ans = rcnt;
        return;
    }
    if (rcnt >= ans) return; // ?????????

    // idx????????????????????????????????????????????????????????????
    int cnt = toRotateCount(idx);

    /*
    printf("\trotates"); for (int i=0; i<k; ++i) printf("\t%3d", i); cout << endl;
    printf("\t       "); for (int i=0; i<k; ++i) printf("\t%3d", rotates[i]); cout << endl;
    printf("\tdial"); for (int i=0; i<k; ++i) printf("\t%3d", ((s[i] - '0') + rotates[i]) % 10); cout << endl;
    printf("\tgoal"); for (int i=0; i<k; ++i) printf("\t%3d", t[i] - '0'); cout << endl;
    printf("i:%d\trotate-cnt:%d\tcost:%d\trcnt:%d\n", idx, cnt, (cnt ? 1 : 0),rcnt);
    cout << endl;
    */

    int ret = k;
    for (int i=k-idx; i>0; i--) {
        for (int j=0; j<i; ++j) {
            rotates[idx + j] += cnt;
        }

        solve(idx + 1, rcnt + (cnt > 0 ? 1 : 0));

        for (int j=0; j<i; ++j) {
            rotates[idx + j] -= cnt;
        }
    }
}

int main() {
    while (cin >> k, k) {
        cin >> s >> t;

        ans = k;
        for (int i=0; i<k; ++i) rotates[i] = 0;

        solve(0, 0);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3056
using System;
using System.Collections.Generic;
using System.Linq;
class Program
    {
        static void Main(string[] args)
        {
            //W H x y
            var Array = Console.ReadLine().Split().Select(z => long.Parse(z)).ToArray();
            long W = Array[0];
            long H = Array[1];
            long x = Array[2];
            long y = Array[3];
            int Result = 0;
          	double Area=(double)W*H/2;
            if (x*2 == W && y*2 == H )
                Result = 1;
            Console.WriteLine($"{Area} {Result}");
        }
    }

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    long double L,ans;
    cin >>L;
    ans = L*L*L/27.0;

    cout << fixed << setprecision(15) << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double 
#define vpi vector<pair <int, int> >
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pair<ll, ll> >
#define pb push_back
#define mp make_pair
#define all(p) (p).begin(), (p).end()
#define fi first
#define se second
#define mem(a) memset((a), 0 , sizeof((a)))
#define mod 1e9+7
#define inf 100000000007
#define N 100002
int isp[N] = {};

int main(){
	ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
	int n, ma=0, a;
	mem(isp);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		isp[a]++;
		isp[a+1]++;
		if(a != 0)
			isp[a-1]++;
		ma = max(ma, a);
	}

	// for(int i=0;i<=ma;++i){
	// 	cout<<"isp["<<i<<"] : "<<isp[i]<<"\n";
	// }

	int ans = 0;
	for (int i = 0; i <= ma; ++i) {
		ans = max(ans, isp[i]);
		//cout<<ans<<"\n";
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 640