akhauriyash/Code-Regression huggingface dataset:
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}


signed main() {

    int s,w;cin >>s>>w;
    cout <<(s<=w?"unsafe":"safe")<<endl;
}

















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

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

    auto s1 = s.substr(0, (s.size() - 1) / 2);
    auto s2 = s.substr((s.size() + 3) / 2 - 1);
    reverse(s2.begin(), s2.end());

    auto s11 = s1.substr(0, (s1.size() + 1) / 2);
    auto s12 = s1.substr((s1.size() + 2) / 2 - 1);
    reverse(s12.begin(), s12.end());

    auto s21 = s2.substr(0, (s2.size() + 1) / 2);
    auto s22 = s2.substr((s2.size() + 2) / 2 - 1);
    reverse(s22.begin(), s22.end());

    cout << (s1 == s2 && s11 == s12 && s21 == s22 ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3604
#include <iostream>

int returnEra(int y,int m,int d)
{
    /*  pre-meiji:0
        meiji:1
        taisho:2
        showa:3
        heisei:4*/

    if (y > 1989) return 4;
    if (y ==1989){
        if (m > 1) return 4;
        if (m ==1 && d>=8) return 4;
    }

    if (y > 1926) return 3;
    if (y ==1926){
        if (m > 12) return 3;
        if (m ==12 && d >=25) return 3;
    }

    
    if (y > 1912) return 2;
    if (y ==1912){
        if (m > 7) return 2;
        if (m ==7 && d >=30) return 2;
    }

    
    if (y > 1868) return 1;
    if (y ==1868){
        if (m > 9) return 1;
        if (m ==9 && d >=8) return 1;
    }

    return 0;
}

int main()
{
    int y,m,d;
    int era;
    while (std::cin >> y >> m >> d) {
        //std::cin >> y >> m >> d;
        era=returnEra(y,m,d);

        if (era==0) std::cout << "pre-meiji\n";
        if (era==1) std::cout << "meiji " << (y-1867) << " " << m << " " << d << std::endl;
        if (era==2) std::cout << "taisho " << (y-1911) << " " << m << " " << d << std::endl;
        if (era==3) std::cout << "showa " << (y-1925) << " " << m << " " << d << std::endl;
        if (era==4) std::cout << "heisei " << (y-1988) << " " << m << " " << d << std::endl;
        //if(std::cin.fail())break;
    }
    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 
 
bool used[100][100];
bool v[100][100];
int xl,xr;
int h,w;
 
 
P rec(int x,int y,bool f,vector<string> s){
    used[y][x]=true;
    if(f){
        v[y][x]=true;
    }
    int r=2*x+1;
    int t=1;
    for (int i = 0; i < 4; i++) {
        int nx=x+dx[i],ny=y+dy[i];
        if(f){
            if(i==1){
                if(s[ny][nx]!=s[y][x]&&s[ny][nx]!='.'){
                    xl=min(xl,x);
                    xr=max(xr,x+1);
                }
            }
        }
        if(0<=nx&&nx<w&&0<=ny&&ny<h){
            if(s[ny][nx]=='.'||used[ny][nx]) continue;
            if(s[y][x]!=s[ny][nx]){
                if(i==3){
                    P p = rec(nx,ny,false,s);
                    r += p.fs;
                    t += p.sc;
                }
            }
            else{
                P p = rec(nx,ny,f,s);
                r += p.fs;
                t += p.sc;
            }
        }
    }
    return mp(r,t);
}
 
 
int main(){
    while(1){
        cin >> w >> h;
        if(!h&&!w) return 0;
        vector<string> s(h);
        memset(v,false,sizeof(v));
        for (int i = 0; i < h; i++) {
            cin >> s[i];
        }
        string k="";
        for (int i = 0; i < w; i++) {
            k.pb('#');
        }
        s.pb(k);
        bool flag=false;
        for (int i = h-1; i >= 0; i--) {
            for (int j = 0; j < w; j++) {
                memset(used,false,sizeof(used));
                if(s[i][j]=='.'||v[i][j]) continue;
                xl=100,xr=0;
                P p = rec(j,i,true,s);
                if(p.fs<=2*xl*p.sc||2*xr*p.sc<=p.fs) flag=true;
            }
        }
        if(flag) puts("UNSTABLE");
        else puts("STABLE");
    }
    return 0;
}



Measured memory_bytes: 3280
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll i,j,k,l,r,m,n,x,ans=0,sum=0;
        vector<pair<ll,pair<ll,ll>>> v;
        vector<pair<ll,ll>> a;
        cin>>n>>x;
        for(i=0;i<n;i++)
        {
            cin>>k>>l>>r;
            v.pb({k,{l,r}});
            m=(x-k)*r;
            m+=k*l;
            a.pb({m,i});
            sum+=k*l;
        }
        sort(all(a));
        for(i=n-1;i>=0;i--)
        {
            // cout<<a[i].S<<endl; 
            if(sum-v[a[i].S].F*v[a[i].S].S.F>=(x-v[a[i].S].F)*v[a[i].S].S.S)
            {
                ans+=x;
                sum=sum-v[a[i].S].F*v[a[i].S].S.F-(x-v[a[i].S].F)*v[a[i].S].S.S;
            }
            else
                break;
        }
        ll kk=hell;
        ll ind=i;
        if(ind!=-1)
        {
            for(i=ind;i>=0;i--)
            {
                kk=min(1.0*kk,ceil((1.0*sum)/v[a[i].S].S.F));
            }
            for(i=ind;i>=0;i--)
            {
                kk=min(1.0*kk,ceil((1.0*(sum+(v[a[i].S].S.S-v[a[i].S].S.F)*v[a[i].S].F))/v[a[i].S].S.S));
            }
            sum=sum-v[a[ind].S].F*v[a[ind].S].S.F-(x-v[a[ind].S].F)*v[a[ind].S].S.S;
            for(i=ind+1;i<n;i++)
            {
                ll p=sum+v[a[i].S].F*v[a[i].S].S.F+(x-v[a[i].S].F)*v[a[i].S].S.S;
                kk=min(1.0*kk,ceil((1.0*p)/v[a[i].S].S.F));
                kk=min(1.0*kk,ceil((1.0*(p+(v[a[i].S].S.S-v[a[i].S].S.F)*v[a[i].S].F))/v[a[i].S].S.S));
            }
        }
        if(kk==hell)
            kk=0;
        cout<<ans+kk;
    }
    return 0;
}

Measured memory_bytes: 6060
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
#define MAX_V 5000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

struct edge { ll to, cap, rev; };

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(ll from, ll to, ll cap) {
  G[from].push_back((edge) { to, cap, (ll) G[to].size() });
  G[to].push_back((edge) { from, cap, (ll) G[from].size() - 1 });
}

ll dfs(ll v, ll t, ll f) {
  if(v == t) return f;
  used[v] = true;
  REP(i, 0, G[v].size()) {
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0) {
      ll d = dfs(e.to, t, min(f, e.cap));
      if(d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

ll max_flow(ll s, ll t) {
  ll flow = 0;
  while(1) {
    memset(used, 0, sizeof(used));
    ll f = dfs(s, t, INF);
    if(f == 0) return flow;
    flow += f;
  }
}

bool dfs2(ll v, ll s, ll t) {
  if(v == t) return true;
  used[v] = true;
  bool ret = false;
  REP(i, 0, G[v].size()) {
    edge &e = G[v][i];
    if(v == s && e.to == t) continue;
    if(v == t && e.to == s) continue;
    if(!used[e.to] && e.cap > 0) ret = ret || dfs2(e.to, s, t);
  }
  return ret;
}

int main(void) {
  ll V, E;
  cin >> V >> E;
  REP(i, 0, E) {
    ll s, t, c;
    cin >> s >> t >> c;
    add_edge(s, t, c);
  }

  vector<pll> q;
  REP(i, 0, V) REP(j, 0, G[i].size()) if(G[i][j].cap == 1) q.push_back(pll(i, j));

  ll flow = max_flow(0, V - 1);

  bool f = false;
  REP(i, 0, q.size()) {
    ll s = q[i].first;
    ll t = G[s][q[i].second].to;
    memset(used, 0, sizeof(used));
    if(G[s][q[i].second].cap == 0 && !dfs2(s, s, t)) f = true;
  }

  ll ans = max(flow - f, 0LL);
  cout << (ans <= 10000 ? ans : -1) << endl;
}

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

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

	int N; cin >> N;
	long long T; cin >> T;
	long long t[210000];
	for (int i = 0; i < N; i++) {
		cin >> t[i];
	}
	long long sum = 0;
	long long z = t[0];
	long long a = t[0];
	for (int i = 1; i < N; i++) {
		if (z+T <= t[i]) {
			sum += z + T - a;
			a = t[i];
			z = t[i];
		}
		else {
			z = t[i];
		}
	}
	sum += z + T - a;
	cout << sum;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main() {
	int N = 0;
	cin >> N;
	int d[50];
	int ans = 0;

	for (int i = 0; i < N; ++i) {
		cin >> d[i];
	}

	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			ans += d[i] * d[j];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    vector<P> v;
    rep(i,n){
        v.push_back(make_pair(a[i],i+1));
    }
    sort(v.begin(),v.end());
    rep(i,n){
        cout << v[i].second << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2164
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
    	if(s[i]=='+'){
    		ans++;
    	}
    	else{
    		ans--;
    	}
    }
    cout<<ans;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int n;

double a[3005],dp[3005][3005],ans;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        for(int j=0;j<=i;j++){
            dp[i][j]=a[i]*dp[i-1][j-1]+(1.0-a[i])*dp[i-1][j];
        }
    }
    for(int i=n/2+1;i<=n;i++) ans+=dp[n][i];
    cout << fixed << setprecision(10) << ans;
}


Measured memory_bytes: 69120
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
//#define endl '\n'

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n){
        ll sum = 0;
        ll c = 0;
        REP(i, n) {
            ll x, y;
            cin >> x >> y;
            sum += x * y;
            c += y;
        }
        cout << c - 1 + (sum - 1) / 9 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::collections::BTreeSet;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

fn main(){
    let n = read_line().parse::<usize>().unwrap();
    let mut set : BTreeSet<i32> = BTreeSet::new();
    for _ in 0..n {
        let d = read_line().parse::<i32>().unwrap();
        set.insert(d);
    }

    println!("{}", set.len());
    

}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(a*b, c) << endl;
	return 0;
}

//Ctrl+Aを使わない


Measured memory_bytes: 256
def DrawRectangle(lst):
    drawn=["."*lst[1] for i in range(lst[0])]
    for i in range(lst[0]):
        drawn[i]="#"+drawn[i][1:-1]+"#"
    drawn[0]="#"*lst[1]
    drawn[-1]="#"*lst[1]
    for i in drawn:
        print(i)
    print("")

a=[]
while True:
    a.append(list(map(int,input().split(" "))))
    if a[-1]==[0,0]:
        a=a[:-1]
        break
for i in a:
    DrawRectangle(i)


Measured memory_bytes: 5624
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

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

	int arr[30];
	int i = 0;

	while (n)
	{
		arr[i++] = n % 26;
		n /= 26;
	}
	i--;

	for (int k = 0; k < i; k++)
	{
		if (arr[k] <= 0)
		{
			arr[k] += 26;
			arr[k + 1] -= 1;
		}
	}

	for (; i >= 0; i--)
	{
		if(arr[i] > 0)
			cout << (char)('a' + arr[i] - 1);
	}
}


Measured memory_bytes: 3092
import collections

def list_count(l):
    return collections.Counter(l)

n=int(input())
a=list(map(int,input().split()))

l=[i+a[i] for i in range(len(a))]
m=[i-a[i] for i in range(len(a))]

mlist=list_count(m)

mlist0=mlist[m[0]]
mlist[m[0]]=mlist0-1

ans=0
for i in range(len(l)-1):
    ansi=mlist.get(l[i], 0)
    ans+=ansi

    mlist[m[i]]=mlist[m[i]]-1

print(ans)


Measured memory_bytes: 50404
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

const LL  INF=1<<31;
const LL MOD=1000000007;



int main(){
    int x;
    cin>>x;
    int t=0;
    while(t*(1+t)/2<x){
        t++;
    }
    cout<<t<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>

typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

int saiki(string, int, int);

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

	string s,t;
    cin>>s;
    cin>>t;
    
    sort(all(s));
    sort(all(t),greater<int>());
    
    if(s<t)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 1000005

typedef struct pro{
   int u;
   char name[100];
 } p;

void enqueue(p );
p dequeue();
int min(int,int);
p q[LEN];

int head,tail,n;

int main(){
  int elaps = 0,h,i,r;
  p w;
  scanf("%d %d",&n,&r);
  for(i=1;i <= n;i++){
    scanf("%s %d",q[i].name,&q[i].u);
  }
  head=1;
  tail=n+1;
  while(head != tail){
    w = dequeue();
    h = min(r,w.u);
    w.u -= h;
    elaps += h;
    if(w.u > 0){
      enqueue(w);
    }
    else printf("%s %d\n",w.name,elaps);
  }
    return 0;
}
  void enqueue(p a){
    q[tail]=a;
    tail=(tail+1)%LEN;
  }
  p dequeue(){
    p x;
    x = q[head];
    head = (head+1)%LEN;
    return x;
  }
int min(int a,int b){return a < b ? a : b;}



Measured memory_bytes: 20932
n = int(input())
l = list(map(int, input().split()))
t1 = []
t2 = []
for i in range(n):
    t1.append(l[i] + i)
    t2.append(i - l[i])
count = {}
for i in t1: count[i] = 0
for i in t2: count[i] = 0
for i in t1: count[i] -= -1
ans = 0
for i in t2:
    if i > 0:
        if count[i] != 0:
            ans += count[i]
print(ans)

Measured memory_bytes: 66308
n,m=map(int,input().split())
hoge=0
if(abs(m-n)>1):
  print(0)
  exit()
elif(m==n):
  hoge=2
else:
  hoge=1
for i in range(n):
  hoge=hoge*(i+1)
  hoge=hoge%(10**9+7)
for i in range(m):
  hoge=hoge*(i+1)
  hoge=hoge%(10**9+7)
print(hoge)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int w,d;
	while(cin >> w >> d,w|d)
	{
		vector<int> hw(w);
		vector<int> hd(d);
		bool bd[d] = {};
		
		REP(i,w)
		{
			cin >> hw[i];
		}
		REP(i,d)
		{
			cin >> hd[i];
		}
		
		int ans = 0;
		
		REP(i,w)
		{
			pair<int,bool> p = MP(1000,0);
			int place = -1;
			REP(j,d)
			{
				if(hd[j] >= hw[i])
				{
					if(p > MP(hd[j],bd[j]))
					{
						place = j;
						p = MP(hd[j],bd[j]);
					}
				}
			}
			ans += hw[i];
			if(hd[place] == hw[i])bd[place] = true;
			//SHOW1d(bd,d);

		}
		//cout << ans << endl;
		REP(i,d)
		{
			if(bd[i])continue;
			int p = 1000;
			int place = -1;
			REP(j,w)
			{
				if(hw[j] >= hd[i])
				{
					if(p > hw[j])
					{
						p = hw[j];
					}
				}
			}
			ans += hd[i];
		}
		
		cout << ans << endl;
		
	}
		
	return 0;
}

Measured memory_bytes: 2988
#include<iostream>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
char a[3];
for(int i=0;i<3;i++)
cin>>a[i];
sort(a,a+3);
if(a[0]=='a' && a[1]=='b' && a[2]=='c')
cout<<"Yes";
else
cout<<"No";
system("pause");
return 0;
}

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

int main() {
    int S=0,i=0;
    cin >> S;
    vector<int> x(1);
    x.at(0) = S;
    while(1){
        i++;
        if(x.at(i-1)%2 == 0){
            x.push_back(x.at(i-1)/2);
        }else{
            x.push_back(3*x.at(i-1)+1);
        }
        bool a = false;
        for(int m=0; m<x.size()-1; m++){
            if(x.at(m) == x.at(i))a=true;
        }
        if(a){
            break;
        }
    }
    cout << i+1 << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class BIT:
    def __init__(self, n):
        self.num = n
        self.dat = [0] * (self.num + 1)

    def add(self, i, x):
        i += 1
        while i <= self.num:
            self.dat[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        s = 0
        while i > 0:
            s += self.dat[i]
            i -= i & -i
        return s


n, q = LI()
ans = [0] * q
C = LI()
Q = [[] for _ in range(n)]
for i in range(q):
    l, r = LI()
    Q[l - 1] += [(False, i)]
    Q[r - 1] += [(True, i)]


last = [-1] * (n + 1)
DD = {}
bit = BIT(n + 1)
for i, c in enumerate(C):
    col = C[i]
    bit.add(i, 1)
    if last[col] != -1:
        bit.add(last[col], -1)
    last[col] = i
    for flg, qi in Q[i]:
        if flg:
            ans[qi] = bit.sum(i) - bit.sum(DD[qi] - 1)
        else:
            DD[qi] = i


#    print(q_now, "b")

print(*ans, sep="\n")


Measured memory_bytes: 297364
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
using namespace std;
typedef vector<int> vi;

//dp.
int main(){
	const int num[]={0,2,5,5,4,5,6,3,7,6};//数字iにnum[i]本必要.
	
	int n,m;
	cin>>n>>m;
	
	vi a(m);
	REP(i,m) cin>>a[i];
	
	vi dp(n+1,-1);//i本でdp[i]桁作る.
	dp[0]=0;//point.
	REP(i,n){
		if(dp[i]==-1) continue;
		REP(j,m){
			if(i+num[a[j]]<=n) dp[i+num[a[j]]]=max(dp[i+num[a[j]]],dp[i]+1);
		}
	}
	
	string ans="";//point.
	sort(ALL(a),greater<int>());//point.
	while(n>0){
		REP(i,m){
			if(n-num[a[i]]>=0){
				if(dp[n]==dp[n-num[a[i]]]+1){
					ans+='0'+a[i];
					n-=num[a[i]];
					break;//REP(i).
				}
			}
		}
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

ll mod = 1e9 + 7;

ll pow_mod(ll n, ll p)
{
    ll ret = 1;
    ll wk_n = n;
    ll wk_p = p;
    while (wk_p > 0)
    {
        if (wk_p % 2 == 0)
        {
            wk_n *= wk_n;
            wk_p /= 2;
            wk_n %= mod;
        }
        else
        {
            ret *= wk_n;
            wk_p--;
            ret %= mod;
        }
    }
    return ret;
}

ll cmb_mod(ll n, ll k)
{
    ll ret = 1;
    for (ll i = 1; i <= k; i++)
    {
        ret *= (n - i + 1);
        ret %= mod;
        ret *= pow_mod(i, mod - 2);
        ret %= mod;
        if (ret < 0)
        {
            ret += mod;
        }
    }
    return ret;
}

int main()
{
    ll n, m, k;
    cin >> n >> m >> k;

    ll x_sum = 0;
    ll nnmod = (n * n) % mod;
    for (ll i = 0; i < m; i++)
    {
        x_sum += i * (m - i);
        x_sum %= mod;
    }
    x_sum *= nnmod;
    x_sum %= mod;

    ll y_sum = 0;
    ll mmmod = (m * m) % mod;
    for (ll i = 0; i < n; i++)
    {
        y_sum += i * (n - i);
        y_sum %= mod;
    }
    y_sum *= mmmod;
    y_sum %= mod;

    ll c = cmb_mod(n * m - 2, k - 2);
    ll sum = x_sum + y_sum;
    sum *= c;
    sum %= mod;

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define SCIN(x) string x;cin>>x;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end());

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    CIN(n);
    V a(n);
    VECCIN(a);
    V b(n);
    REP(i,n)b[i]=(a[i]%2);
    int g=count(ALL(b),0);
    int k=count(ALL(b),1);
    YES(k%2==0);
    return 0;
}


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

using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;

int Calc(int N) {
	long long ans = 0;
	for(int s1=0;s1<=N;++s1)
	for(int s2=s1+1;s1+s2<=N;++s2)
	for(int n1=0;s1+s2+n1<=N;++n1)
	for(int n2=n1+1;s1+s2+n1+n2<=N;++n2)
	for(int u1=0;s1+s2+n1+n2+u1<=N;++u1)
	for(int u2=u1+1;s1+s2+n1+n2+u1+u2<=N;++u2)
	for(int k1=0;s1+s2+n1+n2+u1+u2+k1<=N;++k1)
	for(int k2=k1+1;s1+s2+n1+n2+u1+u2+k1+k2<=N;++k2)
	for(int e1=0;s1+s2+n1+n2+u1+u2+k1+k2+e1<=N;++e1)
	for(int e2=e1+1;s1+s2+n1+n2+u1+u2+k1+k2+e1+e2<=N;++e2)
		if(s1+s2+n1+n2+u1+u2+k1+k2+e1+e2<=N)
			(ans+=(s2-s1)*(n2-n1)*(u2-u1)*(k2-k1)*(e2-e1))%=mod;
	return ans;
}

int X[40];
int Y[40] = {0, 0, 0, 0, 1, 11, 71, 341, 1346, 4598, 14038, 39138, 101193, 245443, 563447, 1232837, 2585672, 5222552, 10198232, 19316488, 35588718, 63933498, 112225058, 192839398, 324900532, 537499132, 874246012, 399637805, 207858088, 434820093, 274485959, 780358, 996765147, 793168065, 118878018, 966647141, 677996797, 52230779, 485540255, 147468710};
int X1[20], X2[20], Y1[20], Y2[20];

ll PowMod(ll a, ll b, ll mod) {
	ll res = 1;
	while(b) {
		if(b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

ll Get_Inv(ll x) {return PowMod(x, mod - 2, mod);}
int Sub(int x,int y) {return x - y < 0 ? x - y + mod : x - y;}

int lagrange(int *X, int *Y, ll n, ll k) {
	ll res = 0, l;
	for(int i = 0;i < n; ++i) {
		l = 1;
		for(int j = 0;j < n; ++j) {
			if(i == j) continue;
			l = l * Sub(k, X[j]) % mod;
			l = l * Get_Inv(Sub(X[i], X[j])) % mod;
		}
		res = (res + l * Y[i] % mod) % mod;
	}
	return res;
}



int main() {
	// for(int i = 1;i <= 40; ++i)
	// 	cout << Calc(i) << ", ";
	for(int i = 1;i <= 20; ++i)
		X1[i - 1] = 2 * i - 1;
	for(int i = 1;i <= 20; ++i)
		X2[i - 1] = 2 * i;
	for(int i = 1;i <= 40; ++i) {
		if(i % 2 == 1) {
			Y1[i / 2] = Y[i - 1];
		} else {
			Y2[(i - 1) / 2] = Y[i - 1];
		}
	}
	int T, k; cin >> T;
	while(T--) {
		cin >> k;
		if(k % 2 == 1) 
			cout << lagrange(X1, Y1, 20, k) << endl;
		else 
			cout << lagrange(X2, Y2, 20, k) << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n,m,k = map(int,ipt().split())
    fl = [[] for i in range(n)]
    bl = [set() for i in range(n)]
    for i in range(m):
        a,b = map(int,ipt().split())
        fl[a-1].append(b-1)
        fl[b-1].append(a-1)
    for i in range(k):
        c,d = map(int,ipt().split())
        bl[c-1].add(d-1)
        bl[d-1].add(c-1)

    ans = [-1]*n
    al = [True]*n
    for i in range(n):
        if al[i]:
            q = [i]
            al[i] = False
            st = set([i])
            while q:
                qi = q.pop()
                for j in fl[qi]:
                    if al[j]:
                        st.add(j)
                        al[j] = False
                        q.append(j)
            lst = len(st)
            for j in st:
                tmp = lst-len(fl[j])-1
                for k in bl[j]:
                    if k in st:
                        tmp -= 1
                ans[j] = tmp

    print(" ".join(map(str,ans)))


    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 136468
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
 ll n,d;
 cin>>n>>d;
 ll x,y,c=0;
 while(n--)
 {
     cin>>x>>y;
     if(x*x+y*y<=d*d)c++;
 }
 cout<<c;
}

Measured memory_bytes: 3552
package main

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

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

func main() {
	n := loadint()
	y := loadint()
	a, b, c := -1, -1, -1
EXIT_LABEL:
	for i := 0; i <= n; i++ {
		for j := 0; j <= n-i; j++ {
			k := n - i - j
			if i*10000+j*5000+k*1000 == y {
				a, b, c = i, j, k
				break EXIT_LABEL
			}
		}
	}
	fmt.Println(a, b, c)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int x[MAXN], b[MAXN], n, y[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> x[i];
    FOR(i,1,n) y[i] = x[i];
    sort(y+1, y+n+1);
    FOR(i,1,n)
        if (x[i] > y[n/2]) cout << y[n/2] << "\n";
        else cout << y[n/2+1] << "\n";
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
long long int arr[10005];
int main()
{
    ll n;
    cin >> n;

    for(long long int i=1;i<=100;i++)
    {
        for(long long int j=1;j<=100;j++)
        {
            for(long long int k=1;k<=100;k++)
            {
                ll val=i*i+j*j+k*k+i*j+j*k+k*i;
                if(val<=n)
                {

                    arr[val]++;
                }

            }
        }

    }
    for(long long int i=1;i<=n;i++)
    {
        cout << arr[i]<<endl;
    }
}


Measured memory_bytes: 3548
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

int n;
vector<vector<int> > g;
ll ans;

int dfs(int par, int curr)
{
    int siz=(int)g[curr].size();
    int sum=0;
    vector<int> v;
    int i;
    for(i=0; i<siz; i++) {
        int next=g[curr][i];
        if(next==par) continue;
        int ret=dfs(curr, next);
        sum+=ret;
        v.push_back(ret);
    }
    v.push_back(n-sum-1);
    ll ans0=0;
    int siz0=(int)v.size();
    for(i=0; i<siz0; i++) {
        ll tmp=(1-minv(mpow(2, v[i]))+MOD)%MOD;
        tmp=tmp*minv(mpow(2,n-v[i]))%MOD;
        ans0=(ans0+tmp)%MOD;
    }
    ans0=(ans0+minv(mpow(2,n)))%MOD;
    ans0=(minv(2)-ans0+MOD)%MOD;
    ans=(ans+ans0)%MOD;

    sum++;
    return sum;
}
 
int main(int argc, char* argv[])
{
    scanf("%d", &n);
    g.resize(n);

    int i;
    for(i=0; i<n-1; i++) {
        int a,b;
        scanf("%d%d", &a, &b); a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ans=0;
    int ret=dfs(-1, 0);
    assert(ret==n);
    printf("%lld\n", ans);
 
    return 0;
}

Measured memory_bytes: 29184
#include<bits/stdc++.h>
#define int long long
using namespace std;
int wt[105];
int val[105];
int ans[105][100005];
int N,w;
int ks(int n,int c) {
    if (ans[n][c] != -1) return ans[n][c];
    if (n == 0 or c == 0) return 0;
    if(wt[n-1]>c)
        return ks(n-1,c);
    int a = ks(n - 1, c);
    int b = val[n - 1] + ks(n - 1, c - wt[n - 1]);
    ans[n][c] = max(a, b);
    return ans[n][c];
}
void solve() {
    cin >> N >> w;
    for (int i = 0; i < N; ++i) {
        cin >> wt[i] >> val[i];
    }
    for(int i=0;i<N+1;++i)
        for(int j=0;j<w+1;++j) ans[i][j]=-1;

    cout << ks(N, w);
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 82484
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
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>;
 
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

    long double l;
    cin>>l;
    l/=3;
    cout<<fixed<<setprecision(10)<<(l*l*l);

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, M; cin >> N >> M;
  vector<vector<int64_t>> xyzs(N, vector<int64_t>(3)); for (int i = 0; i < N; ++i) cin >> xyzs[i][0] >> xyzs[i][1] >> xyzs[i][2];
  vector<int64_t> ss(N);
  auto ans = 0LL;
  for (int i = 0; i < 8; ++i)
    {for (int j = 0; j < N; ++j)
      {auto s = 0LL; for (int k = 0; k < 3; ++k) s += (i >> k & 1 ? -1 : 1) * xyzs[j][k];
      ss[j] = s;}
    auto t = 0LL; sort(ss.rbegin(), ss.rend()); for (int j = 0; j < M; ++j) t += ss[j];
    ans = max(ans, t);}
  cout << ans << endl;}

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

int main()
{
	long long int N=100,X,interest,counter=0;
  	cin>>X;
  	while(N<X)
    {
    	interest=(N*1)/100;
      	N+=interest;
      	counter++;
    }

    cout<<counter<<endl;
	return 0;
}

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

int main()
{
	vector<string> v(8);
	while (cin >> v[0]) {
		for (int i = 1; i < 8; i++) {
			cin >> v[i];
		}
		int sx = 8, sy = 8, ex = 0, ey = 0;
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				if (v[i][j] == '1') {
					sx = min(sx, j);
					sy = min(sy, i);
					ex = max(ex, j);
					ey = max(ey, i);
				}
			}
		}
		if (sx == ex) {
			cout << 'B' << endl;
		}
		else if (sx + 3 == ex) {
			cout << 'C' << endl;
		}
		else if (sx + 1 == ex && sy + 1 == ey) {
			cout << 'A' << endl;
		}
		else if (sx + 1 == ex && v[sy][sx] == '0') {
			cout << 'D' << endl;
		}
		else if (sx + 1 == ex && v[sy][sx] == '1') {
			cout << 'F' << endl;
		}
		else if (sx + 2 == ex && v[sy][sx] == '0') {
			cout << 'G' << endl;
		}
		else if (sx + 2 == ex && v[sy][sx] == '1') {
			cout << 'E' << endl;
		}
	}
	return 0;
}

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

Measured memory_bytes: 40536
use std::collections::HashMap;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn usize() -> usize {
    read()
}

fn vec_usize(n: usize) -> Vec<usize> {
    let mut vec = Vec::new();
    for _ in 0..n {
        vec.push(usize())
    }
    vec
}

fn main() {
    let n = usize();
    let d_vec = vec_usize(n);
    let m = usize();
    let t_vec = vec_usize(m);
    let mut ds = HashMap::new();
    let mut ts = HashMap::new();
    for i in 0..n {
        *ds.entry(d_vec[i] + 1).or_insert(0) += 1;
    }
    for i in 0..m {
        *ts.entry(t_vec[i] + 1).or_insert(0) += 1;
    }
    for level in ts.keys() {
        if ts[level] > *ds.get(level).unwrap_or(&0) {
            println!("{}", "NO");
            return;
        }
    }
    println!("{}", "YES");
}


Measured memory_bytes: 25204
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	dn := make([]int, N)
	var ans int
	for i := range dn {
		dn[i] = nextInt()
	}
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			ans += dn[i] * dn[j]
		}
	}
	fmt.Println(ans)
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REPi(n) for(int i=0;i<n;i++)
#define REPj(n) for(int j=0;j<n;j++)

using namespace std;

int main(){
    unsigned long int h,w,ans;
    ans=0;
    cin >> h >> w;
    if(h==1||w==1){
        ans=1;
    }
    else{

    
    if(h%2==1){
        ans=w*(h-1)/2+((w+1)/2);
    }
    else{
        ans=w*h/2;
    }
    }
    
    cout << ans<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string.h>

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



void solve()
{
	long long N;
	cin >> N;
	long long A[5];
	for (int i = 0; i < 5; ++i)
	{
		cin >> A[i];
	}
	long long maxVal = 0;
	for (int i = 0; i < 5; ++i)
	{
		if (N % A[i] == 0)
		{
			maxVal = max(maxVal, N / A[i]);
		}
		else
		{
			maxVal = max(maxVal, N / A[i] + 1);
		}
	}
	cout << maxVal + 4 << endl;
}

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/













string S;
int N;
int dp[201010][3];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
	N = S.length();
	S += "####";

	rep(i, 0, N + 1) rep(pre, 0, 3) dp[i][pre] = -inf;
	dp[0][0] = 0;

	rep(i, 0, N) rep(pre, 0, 3) rep(d, 1, 3) if (0 <= dp[i][pre]) {
		if (pre == d) {
			if (d == 1) {
				if (S[i - 1] == S[i]) continue;
			}
			else {
				if (S[i - 2] == S[i] and S[i - 1] == S[i + 1]) continue;
			}
		}
		chmax(dp[i + d][d], dp[i][pre] + 1);
	}

	cout << max(dp[N][1], dp[N][2]) << endl;
}








Measured memory_bytes: 2964
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    s = S()
    t = S()

    lenth = 0

    for i in range(1,n+1):
        s_end = s[-i:]
        t_start = t[:i]

        if s_end == t_start:
            lenth = i
    
    ans = 2*n - lenth
    print(ans)
        
main()            


Measured memory_bytes: 9968
import sys

def calc(n):
    n2 = n & ~3
    for i in range(n2+1, n+1):
        n2 ^= i
    return n2

def solve(A,B):
    if A == 0:
        return calc(B)
    else:
        return calc(B) ^ calc(A-1)

def solve2(A,B):
    ans=A
    for i in range(A+1,B+1):
        ans ^= i
    return ans

A,B=map(int,sys.stdin.readline().rstrip().split())
print(solve(A,B))
#for i in range(100):
#    print(f'{0}-{i}={solve(0,i)}  {solve2(0,i)}')
#    print(f'{i}-{100}={solve(i,100)}  {solve2(i,100)}')

#10 1000000000000


Measured memory_bytes: 38384
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

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

int main() {
  int n;
  cin>>n;
  
  int a=n/100;
  int b=n%100;
  
  bool c=0,d=0;
  
  if(a>0 && a<13) c=true;
  if(b>0 && b<13) d=true;
  
  if(c==true && d==true) cout<<"AMBIGUOUS"<<endl;
  else if(c==true && d==false) cout<<"MMYY"<<endl;
  else if(c==false && d==true) cout<<"YYMM"<<endl;
  else cout<<"NA"<<endl;

  return 0;
}

Measured memory_bytes: 256