akhauriyash/Code-Regression huggingface dataset:
/*
.....   .   .   .   .
  .    . .   . .   . .
  .   .....   .   .....
  .  .     .  .  .     .
*/
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <iomanip>
#include <random>
#include <sstream>
 
using namespace std;

#define int long long
#define double long double
#define time time228
#define left left228
#define right right228

template<typename T> void uin(T &a, T b) {
    if (b < a) a = b;
}

template<typename T> void uax(T &a, T b) {
    if (b > a) a = b;
}

int cnt[100];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (char c : s) {
        ++cnt[c - 'a'];
    }
    int res = 1;
    for (int i = 0; i < 26; ++i) {
        res *= (cnt[i] + 1);
        res %= (1000 * 1000 * 1000 + 7);
    }
    cout << res - 1 << '\n';
    return 0;
}

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

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

  string s;
  cin >> s;
  int mn = 10000;
  for(int i = 0; i < s.size() - 2; i++) {
    int tmp = stoi(s.substr(i, 3));
    mn = min(mn, abs(tmp - 753));
  }
  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,a,b;
    std::deque<int> target;
    std::deque<int> score(0);
    cin>>n>>m;
    for (int i=0;i<m;i++) {
        cin>>a;
        target.emplace_back(a);
    }
    for (int j=0;j<m;j++) {
        int parent=target[j];
        for (int k=0;k<n;k++) {
            cin>>b;
            if (b==parent) {
                score[k]++;
            } else {
                score[parent-1]++;
            }
        }
    }
    for (int l=0;l<n;l++) {
        cout<<score[l]<<endl;
    }
}


Measured memory_bytes: 3112
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

int ans;
int n,k,x,y;
int main(){
	cin>>n>>k>>x>>y;
	for(int i=1;i<=n;i++){
		if(i<=k)ans+=x;
		else ans+=y;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	long long int N;
	scanf("%lld", &N);

	long long int i, mod = 0;
	long long int ans = 1;

	
	for(i = 0; i < N; i++){
		
		mod = ans % 1000000007;
		ans = mod * ((i + 1) % 1000000007);
		
		while(ans >= 1000000007){
			ans = ans % 1000000007;

			if(ans < 1000000007){
				break;
			}
		}
	}	

	printf("%lld\n", ans);
	return 0;

}


Measured memory_bytes: 128
from bisect import bisect_left,bisect_right

a,b,q=map(int,input().split())
s=[-10**15]
s+=[int(input()) for _ in range(a)]
s+=[10**15]
t=[-10**15]
t+=[int(input()) for _ in range(b)]
t+=[10**15]
x=[int(input()) for _ in range(q)]
for i in range(q):
  sl=s[bisect_left(s,x[i])-1]
  sr=s[bisect_right(s,x[i])]
  tl=t[bisect_left(t,x[i])-1]
  tr=t[bisect_right(t,x[i])]
  ans1=max(x[i]-sl,x[i]-tl)
  ans2=max(sr-x[i],tr-x[i])
  ans3=(x[i]-sl)*2+(tr-x[i])
  ans4=(x[i]-tl)*2+(sr-x[i])
  ans5=(sr-x[i])*2+(x[i]-tl)
  ans6=(tr-x[i])*2+(x[i]-sl)
  print(min(ans1,ans2,ans3,ans4,ans5,ans6))

Measured memory_bytes: 16160
object Main {
  def main(args: Array[String]): Unit = {
    var num = io.StdIn.readLong

    var count       = 0
    val BASE_NUMBER = 26
    var chars       = ""

    while( num > BASE_NUMBER ) {
      num   -= 1.toLong
      chars = ( num%BASE_NUMBER + 97 ).toChar + chars
      num   /= BASE_NUMBER
    }
    
    chars = ( num + 96 ).toChar + chars
    println( chars )
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#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=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

const int INF=1e9;
const int MAX_V=114;

// d[i][j]: 辺e=(i, j)のコスト(存在しない場合はINF, d[i][i]=0)
// d[i][i]が負になる場合は負の閉路が存在
int d[MAX_V][MAX_V];
int V;

void warshall_floyd(){
	REP(k, V){
		REP(i, V){
			REP(j, V){
				d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, a[1333], b[1333], c[1333];
	cin>>n>>m;
	V=n;
	REP(i, n){
		REP(j, n){
			if(i!=j){
				d[i][j]=INF;
			}
		}
	}
	REP(i, m){
		cin>>a[i]>>b[i]>>c[i];
		--a[i];
		--b[i];
		d[a[i]][b[i]]=d[b[i]][a[i]]=c[i];
	}
	warshall_floyd();
	int ans=m;
	REP(i, m){
		bool ok=false;
		REP(j, n){
			if(d[j][a[i]]+c[i]==d[j][b[i]]){
				ok=true;
				break;
			}
		}
		if(ok){
			--ans;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 384
/*
“Yesterday is history, tomorrow is a mystery, today is a gift of God,
which is why we call it the present.” ― Bill Keane
*/
#include<bits/stdc++.h>
#define endl "\n"
#ifdef ONLINE_JUDGEsj
#define DEBUG(x)
#else
#define DEBUG(x) cout<<#x<<" : {"<<x<<"}"<<endl;
#endif
using namespace std;
typedef long long int lli;
constexpr int MAX=3e5;
inline lli add(lli a, lli b, int mod){
	lli x=a+b;
	if(x>=mod)
		x-=mod;
	return x; 
}
inline lli mul(lli a, lli b, int mod){
	return ((a%mod)*(b%mod))%mod;	
}
inline lli sub(lli a, lli b, int mod){
	lli x=a-b;
	if(x<0)
		x+=mod;
	return x;
}

lli powr(lli a, lli b, lli mod) {
	lli ans = 1;
	while(b) {
		if(b&1ll) ans*=a, ans%=mod;
		a*=a; a%=mod;
		b>>=1;
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int bitcnt=0;
	for(char c: s) if(c=='1') bitcnt++;
	lli u, v;
	u=v=0;
	for(int i=n-1; i>=0; --i){
		if(s[i]=='1'){
			u=add(u, powr(2,n-i-1,bitcnt+1), bitcnt+1);
			u=u%(bitcnt+1);
			if(bitcnt-1==0) continue;
			v=add(v, powr(2,n-i-1,bitcnt-1), bitcnt-1);
			v=v%(bitcnt-1);
		}	
	}
	
	int dp[MAX]={0};
	dp[1]=1;
	dp[2]=1;
	for(int i=3; i<MAX; ++i){
		dp[i]=1+dp[i%__builtin_popcount(i)];
	}
	lli res;
	for(int i=0; i<n; ++i){
		if(s[i]=='1'){
			if(bitcnt-1==0){
				cout<<0<<endl;
				continue;
			}
			res=sub(v,powr(2,n-i-1,bitcnt-1),bitcnt-1);
			cout<<1+dp[res%(bitcnt-1)]<<endl;
		}
		else{
			res=add(u,powr(2,n-i-1,bitcnt+1),bitcnt+1);	
			cout<<1+dp[res%(bitcnt+1)]<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4928
def resolve():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip())
    result = 1000 - n % 1000 if n % 1000 != 0 else 0
    print(result)



if __name__ == "__main__":
    resolve()


# を理解する。そうすると、明らかに制限時間内に実行が終わらないソースコードを出さなくなる。ちなみに、競プロでは 108108 ～ 109109 回程度のループが回せるといわれている。

Measured memory_bytes: 61652
import sys
N = int(sys.stdin.readline())
As = list(map(int, sys.stdin.readline().split()))
bs = []
for i, a in enumerate(As):
    bs.append(a-(i+1))
bs.sort()

cumsum = [0]
s = 0
for b in bs:
    s += b
    cumsum.append(s)

def func(j):
    b = -bs[j]

    s_l = cumsum[j+1] - cumsum[0] #seq[:j]
    s_r = cumsum[N] - cumsum[j+1] #seq[j:]

    res = abs(s_l+b*(j+1)) + abs(s_r+b*(N-(j+1)))
    return res

res = float('inf')
for j, b in enumerate(bs):
    res = min(res, func(j))
print(res)


Measured memory_bytes: 29472
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
dp=[1]*(n+1)
for i in a:
    dp[i]=0
    
k=10**9+7
for i in range(2,n+1):
    if dp[i]!=0:
        dp[i]=(dp[i-1]+dp[i-2])%k
        
print(dp[-1])


Measured memory_bytes: 50520
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;
const int MAX_V = 100005;

vector<int> G[MAX_V];
int oya[MAX_V];

int sanshoCnt[MAX_V];

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

  int n, m;
  cin >> n >> m;

  rep(i, n+m-1) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    sanshoCnt[b]++;
  }

  int root = -1;
  rep(i, n) {
    if (!sanshoCnt[i]) {
      root = i;
    }
  }

  queue<int> que;
  que.push(root);

  while (!que.empty()) {
    int v = que.front();
    que.pop();

    for (int nv : G[v]) {
        sanshoCnt[nv]--;
        if (!sanshoCnt[nv]) {
          oya[nv] = v+1;
          que.push(nv);
        }
    }
  }

  rep(i, n) {
    cout << oya[i] << endl;
  }
}

Measured memory_bytes: 7040
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int n,m,i,j,k,u,v;
long long a[100005],sum,ans,tmp;

int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
		if(a[i]>3*n)sum+=a[i]-3*n;
	}
	for(i=1;i<=n;++i)a[i]+=sum;
	ans=sum;
	for(i=1;i<=n;++i)
	if(a[i]>3*n)
	{
		tmp=(a[i]-3*n)/(n+1);
		if(tmp>sum)tmp=sum;
		a[i]-=(n+1)*tmp;
		sum-=tmp;
		if(a[i]>3*n&&sum)
		{
			a[i]-=n+1;
			--sum;
		}
	}
	ans-=sum;
	for(i=1;i<=n;++i)a[i]-=sum;
	for(;;)
	{
		u=1;
		for(i=2;i<=n;++i)
		if(a[i]>a[u])u=i;
		if(a[u]>=n)
		{
			++ans;
			a[u]-=n+1;
			for(i=1;i<=n;++i)++a[i];
		}else break;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long H = Long.parseLong(s.next());

        int n = (int) (Math.log(H) / Math.log(2));
        System.out.println((long) Math.pow(2, n) * 2 - 1);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, m;
vector<vector<i64>> g;

bool dfs(i64 u, i64 p, i64 a, i64 b) {
  cerr << u << endl;
  if (u == a) return true;
  if (u == b) return false;
  for (i64 v : g[u]) {
    if (v != p) {
      return dfs(v, u, a, b);
    }
  }
}

int main() {
  cin >> n >> m;
  init_n(g, n + 1);
  for (i64 i = 0; i < m; ++i) {
    i64 a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  bool d6 = false;
  vector<i64> d4;
  for (i64 u = 1; u <= n; ++u) {
    i64 deg = g[u].size();
    if (deg % 2 == 1) { cout << "No\n"; return 0; }
    if (deg >= 6) d6 = true;
    if (deg == 4) d4.push_back(u);
  }

  if (d6 || d4.size() >= 3) { cout << "Yes\n"; return 0; }
  if (d4.size() <= 1) { cout << "No\n"; return 0; }

  i64 a = d4[0], b = d4[1];
  for (i64 u : g[a]) {
    if (dfs(u, a, a, b)) { cout << "Yes\n"; return 0; }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 5760
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a , b) + min(c, d) << '\n';
	return 0; 
}


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

using namespace std;
typedef long long  ll;

int main() {
	ll N;
	cin >> N;
	vector<ll> x(N);
	vector<ll> y;
	for (ll i = 0; i < N; i++)
	{
		cin >> x[i];
	}
	y = x;
	sort(y.begin(), y.end());
	ll midl = y[N / 2 - 1], midr = y[N / 2];
	for (ll i = 0; i < N; i++)
	{
		if (x[i] <= midl) cout << midr << endl;
		else cout << midl << endl;
	}
	return 0;
}

Measured memory_bytes: 5376
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 n, k;
    cin >> n >> k;
    k = min(n, k);
    akari<i64> hs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> hs[i];
    }
    sort(hs.begin(), hs.end());
    i64 ans = accumulate(hs.begin(), hs.begin() + n - k, i64(0));
    cout << ans << endl;
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int ans = 100000000;

int main(){
    int N; cin >> N;
    map<string, int> red;
    rep(i,N){
        string s; cin >> s;
        red[s]++;
    }
    int M; cin >> M;
    map<string, int> blue;
    rep(i,M){
        string s; cin >> s;
        blue[s]++; 
    }
    int ans = 0;
    for(auto r : red){
        ans = max(ans, r.second-blue[r.first]);
    }

    cout << ans << endl;
}


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

const int MAX_N = 1<<17;

int n,dat[2*MAX_N-1];

//?????????
void init(int n_){
  //????´???°n???2???????????????
  n=1;
  while(n<n_)n*=2;
  for(int i=0;i<2*n-1;i++)dat[i]=INT_MAX;
}

void update(int a,int b,int k,int l,int r,int x){
  if(r<=a||b<=l)return;
  if(a<=l&&r<=b)dat[k]=x;
  else{
    if(dat[k]!=INT_MAX){
      dat[k*2+1]=dat[k];
      dat[k*2+2]=dat[k];
      dat[k]=INT_MAX;
    }
    update(a,b,k*2+1,l,(l+r)/2,x);
    update(a,b,k*2+2,(l+r)/2,r,x);
  }
}

int find(int a,int b,int k,int l,int r){
  if(r<=a||b<=l)return INT_MAX;
  if(a<=l&&r<=b)return dat[k];
  else{
    if(dat[k]!=INT_MAX){
      dat[k*2+1]=dat[k];
      dat[k*2+2]=dat[k];
      dat[k]=INT_MAX;
    }
    return min(find(a,b,k*2+1,l,(l+r)/2),find(a,b,k*2+2,(l+r)/2,r));
  }
}

int main(){
  int q;
  cin>>n>>q;
  
  init(n);
  int u,s,t,x;
  for(int i=0;i<q;i++){
    cin>>u;
    if(!u){
      cin>>s>>t>>x;
      update(s,t+1,0,0,n,x);
    }else{
      cin>>s;
      cout<<find(s,s+1,0,0,n)<<endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 4092
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 2e5 + 5;
const int MAXD = 10 + 5;
const int mod = 998244353;

int l[MAXN], r[MAXN];

ll f[MAXN], sum[MAXN];

int main(void)
{
	int n,d;
	scanf("%d%d",&n,&d);
	for(int i=1; i<=d; ++i)
		scanf("%d%d",&l[i],&r[i]);
	
	f[1] = sum[1] = 1;
	
	for(int i=2; i<=n; ++i)
	{
		for(int j=1; j<=d; ++j)
		{
			if(i - l[j] < 1) continue;
			
			f[i] = (f[i] + sum[i-l[j]] - sum[max(i-r[j],1)-1] + mod) %mod;
		}
		sum[i] = (sum[i-1] + f[i]) %mod;
	}
	printf("%lld",f[n]);
	return 0;
}

Measured memory_bytes: 4860
#ABC129B-Blance.py

#import list
from sys import stdin

input = stdin.readline

#constant
N = int(input())
W = list(map(int,input().split()))

#variable

#function

#class

#main function
def main():
    absDiff = [abs(sum(W[:i])-sum(W[i:])) for i in range(N)]
    print(min(absDiff))

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
  
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0;i<N;i++) {
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    
    int count=1;
    int point=0;
    for (int i=0;i<N;i++) {
        if(count%2 ==1) {
            point += a[i];
        }
        else {
            point -= a[i];
        }
        count++;
    }
    cout << point << endl;
    
   }

 

Measured memory_bytes: 3644
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=Integer.parseInt(sc.next());
int max=0;
for(int i=1;i<=Math.sqrt(n);i++){
max=Math.max(i*i,max);
}
System.out.println(max);
}}

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

int main(){
    string s;
    cin >> s;
    for(int i = 0;i < s.size();i ++){
        if(s.at(i)=='A'||s.at(i)=='C'||s.at(i)=='G'||s.at(i)=='T'){
            s.at(i) = '1';
        }else{
            s.at(i) = '0';
        }
    }

    int cnt=0, m=0;
    for(int i = 0;i < s.size();i ++){
        if(s.at(i) == '1'){
            cnt ++;
        }else{
            cnt = 0;
        }
        m = max(m,cnt);
    }

    cout << m << endl;
}

Measured memory_bytes: 256
a,b,c;main(n){
    char m[2][8]={"NO","YES"};
    for(scanf("%d",&n);n--;){
        scanf("%d %d %d",&a,&b,&c);
        a=!!(a*a+b*b-c*c)+!!(a*a-b*b+c*c)+!!(a*a-b*b-c*c)<3;
        printf("%s\n",m[a]);
    }
    return 0;
}

Measured memory_bytes: 580
n = gets.to_i
a = gets.split.map &:to_i

b = a.map.with_index{|v,i| i + 1 - v}.tally
c = a.map.with_index{|v,i| i + 1 + v}.tally

keys = b.keys & c.keys
ans = keys.map{|i|b[i] * c[i]}.sum
p ans

Measured memory_bytes: 53720
E = 10 ** -10
while True:
  try:
    xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split())
    vabx, vaby = xb - xa, yb - ya
    vcdx, vcdy = xd - xc, yd - yc
    print("YES" if abs(vabx * vcdx + vaby * vcdy) < E else "NO")
  except EOFError:
    break



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

#if 0
コメント
#endif

int t, n, k;
int x[100000+10], dif[100000+10];

int main(){
  cin >> t;

  for(int i=0; i<t; ++i){
    long long sum = 0;
    cin >> n >> k;

    for(int j=0; j<n; ++j) cin >> x[j];
    for(int k = 0; k+1 < n; ++k) dif[k] = x[k+1] - x[k];

    sort(dif,dif+n-1);
    //cout << "dif[0]: " << dif[0] << ", dif[-1]: " << dif[n-2] << endl;

    for(int l=0; l < max(0,(n-1-(k-1)));++l) sum += dif[l];

    cout << sum << endl;
  }
}



Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
  
int yukrid(int x, int y) {
  int Ma = max(x,y);
  int Mi = min(x,y);
  while (true) {
    if (Ma%Mi != 0) {
      int M=Ma%Mi;
      Ma=Mi;
      Mi=M;
    }
    else 
      break;
  }
  return Mi;
}

int main() {
  int K;
  cin >> K;
  int sum=0;
  
  for (int i=0; i<K ; i++) {
    int a=i+1;
    for (int i=0; i<K ; i++) {
      int b=i+1;
  
         for (int i=0; i<K ; i++) {
           sum += yukrid(yukrid(a, b), i+1);
         } 
    }
  } //aについてのfor終わり
  
  cout << sum << endl;

}


Measured memory_bytes: 3672
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  int a,b;
  cin>>a>>b;
  if(b%a==0){
    cout<<a+b<<endl;
  }else{
    cout<<b-a<<endl;
  }
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<bool>c(8,false);
	int gm=0;
	for(int i=0,t;i<n;++i){
		cin>>t;
		if(t>=3200)++gm;
		else if(t>=2800)c.at(0)=true;
		else if(t>=2400)c.at(1)=true;
		else if(t>=2000)c.at(2)=true;
		else if(t>=1600)c.at(3)=true;
		else if(t>=1200)c.at(4)=true;
		else if(t>=800)c.at(5)=true;
		else if(t>=400)c.at(6)=true;
		else c.at(7)=true;
	}
	int cl=count(c.begin(),c.end(),true);
	int mn,mx;
	if(cl==0&&gm>0)mn=1;
	else mn=cl;
	mx=cl+gm;
	cout<<mn<<" "s<<mx<<"\n"s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(i, a, b) for(int i=a; i<b; i++)
#define per(i, a, b) for(int i=b-1; i>=a; i--)
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;
char s[104];
int main(){
	scanf("%s",&s);
	int n=strlen(s);
	while(n--)cout<<"x";
	cout<<endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

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

  for (ll i = 0; i < (ll)str.size() - 1; i++) {
    if (str[i] == str[i + 1]) {
      printf("%lld %lld\n", i +1, i + 2);
      return 0;
    }
  }

  for (ll i = 0; i < (ll)str.size() - 2; i++) {
    if (str[i] == str[i + 2]) {
      printf("%lld %lld\n", i + 1, i + 3);
      return 0;
    }
  }

  puts("-1 -1");

  return 0;
}


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

int main(){
    long long N; cin >> N;
    long long sum_FB=0;
    for(int i=3; i<=N; i+=3){
        sum_FB+=i;
    }
    for(int i=5; i<=N; i+=5){
        sum_FB+=i;
    }
    for(int i=15; i<=N; i+=15){
        sum_FB-=i;
    }
    long long ans=N*(N+1)/2-sum_FB;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
import itertools

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

# abcd.sort(key=lambda x:x[3],reverse=True)
# for x in abcd:
#     print("")
#     for v in x:
#         print(v,end=" ")
arr = [i for i in range(1,m+1)]

ans = 0
for per in itertools.combinations_with_replacement(arr,n):

    tmp = 0
    for x in abcd:
        diff = per[x[1]-1] - per[x[0]-1]
        if(diff == x[2]):
            tmp += x[3]
    # print(per,end=" ")
    # print(tmp)
    ans = max(ans,tmp)

print(ans)


Measured memory_bytes: 9204
//21th centry Copyright by libra9z
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define reunique(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define sz(a) (int)a.size()
using ll=long long;
template<class T>ostream&operator,(ostream&os,const T&object){return os<<' '<<object;}
template<class T>istream&operator,(istream&os,T&object){return os>>object;}
const int inf=1e9;
const ll lnf=1e18;
const int mod=1e9+7;
int n,ans;
string s;
int main()
{
	cin>>n,s;
	for (int i=1;i<n;++i) ans+=s[i]=='E';
	int mn=ans;
	for (int i=1;i<n;++i)
	{
		ans-=s[i]=='E';
		ans+=s[i-1]=='W';
		mn=min(mn,ans);
	}
	cout<<mn<<endl;
	return 0;
}

Measured memory_bytes: 900
#define ENABLE_DEBUG 1
// hidden common codes{{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(lint ngtkana_is_a_genius=0; ngtkana_is_a_genius<(lint)k; ngtkana_is_a_genius++)
using lint=long long;
using ld=long double;
template<class T> using numr=std::numeric_limits<T>;
struct input_t {
    template<class T> operator T() {
        T t;
        std::cin>>t;
        return t;
    }
} input;
#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    lint n,m;std::cin>>n>>m;
    std::vector<lint>ckd(n);
    while(m--){
        lint d=input;
        while(d--){
            lint x=(lint)input-1;
            ckd.at(x)=true;
        }
    }
    std::cout<<std::count_if(ALL(ckd),[](lint x){return !x;})<<'\n';
}


Measured memory_bytes: 3664
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <fstream>
#include <bitset>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
const long long MOD = 1000000007LL;
const long long MAX = 500000LL;
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
int N;
string S;
bool is_ok(int l){
    for(int i=0;i < N-l+1; i++){
        string sub = S.substr(i,l);
        string sub2 = S.substr(i+l,N);
        if (sub2.find(sub) != string::npos){

            return true;
        }
    }
    return false    ;
}
int bis (int ok,int ng){
    while(abs(ok-ng) > 1){
        int mid = (ok+ng)>>1;
        if (is_ok(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}
int main()
{
	cin >> N;
    cin >> S;
    int ans = bis(0,N);
    cout << ans << endl;


}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,m,d,p,a,i;

	for( ; scanf("%d%d",&n,&m) , n|m ; printf("%d\n",a) ){
		a=0;
		int f[12]={0};
		for( i=n ; i-- ; f[p] += d )
			scanf("%d%d",&d,&p);
		for( i=10 ; i >= 0 ; i-- ){
			for( ; f[i] && m ; ){
				m--,
				f[i]--;
			}
			a += f[i] * i;
		}
	}
}

Measured memory_bytes: 768
//
//AtCoder Beginner Contest 163
//C - management
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define reAll(x) (x).rbegin(),(x).rend()
#define zero(a) memset(a, 0, sizeof(a))

using ll = long long;

int main()
{
    int n;

    cin >> n;

    int a[n];
    int ans[n];

    rep(i, n) ans[i] = 0;

    rep(i,n-1){
        cin >> a[i];
        ans[a[i]-1]++;
    }

    rep(i, n) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
int sign(int v){
	if(v < 0) return -1;
	return 1;
}
int main(){
	int k, x, y;
	cin >> k >> x >> y;
	int dx = sign(x), dy = sign(y);
	x = abs(x);
	y = abs(y);
	if((k % 2) == 0 && ((x + y) % 2)){
		cout << -1 << endl;
		return 0;
	}
	/**
	A = positive
	B = negative

	N*K = A + B
	A - B = X + Y

	A + B = N*K
	A - B = X + Y
	2 * A = N * K + X + Y
	A = (N * K + X + Y) / 2
	B = (N * K - X - Y) / 2
	  **/
	int n = 1;
	while(n * k < x + y || ((n * k - x - y) % 2) || ((n * k + x + y)%2)) n++;
	if(n == 1 && (x + y) != k) n++;
	while(n * k < x + y || ((n * k - x - y) % 2) || ((n * k + x + y)%2)) n++;
	int A = (n * k + x + y) / 2;
	int B = (n * k - x - y) / 2;
	int cx = 0, cy = 0;
	vector<pair<int,int> > ans;
	while(B >= k){
		if(abs(cx - x) < abs(cy - y)){
			cx -= k;
		} else {
			cy -= k;
		}
		B -= k;
		ans.push_back({cx, cy});
	}
	if(B){
		if(abs(cx - x) < abs(cy - y)){
			cx -= B;
			cy += k - B;
		} else {
			cy -= B;
			cx += k - B;
		}
		B = 0;
		ans.push_back({cx, cy});
	}
	while(x - cx >= k){
		cx += k;
		ans.push_back({cx, cy});
	}
	while(y - cy >= k){
		cy += k;
		ans.push_back({cx, cy});
	}
	if(x != cx && y != cy){
		cx = x;
		cy = y;
		ans.push_back({cx, cy});
	}
	cout << n << endl;
	for(auto e : ans) cout << e.first * dx << " " << e.second * dy << endl;
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n, m;
  cin >> n >> m;
  priority_queue<int> que;
  rep(i,n) {
    int a;
    cin >> a;
    que.push(a);
  }
  rep(i,m) {
    int x = que.top(); que.pop();
    x /= 2;
    que.push(x);
  }
  ll sum = 0;
  while(!que.empty()) {
    sum += que.top();
    que.pop();
  }
  cout << sum << endl;
}

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

main(){
  int count = 1;
  while(1){
      int x,y;
      cin >> x >> y;
      if((x == 0)&&(y == 0)) break;
      cout <<  min(x,y) <<" "<< max(x,y) << endl;
      count++;
  }
}



Measured memory_bytes: 3080
var first:array[0..10000]of longint;
    vis:array[0..10000]of boolean;
    too,nxt,val:array[0..200000]of longint;
    n,m,s,t,i,u,v,w,res,tot:longint;
    cnt:longint=1;
function max(a,b:longint):longint;inline;
begin
  if a>b then exit(a) else exit(b);
end;
function min(a,b:longint):longint;inline;
begin
  if a<b then exit(a) else exit(b);
end;
procedure adde(u,v,w:longint);
begin
  inc(cnt);
  too[cnt]:=v;
  val[cnt]:=w;
  nxt[cnt]:=first[u];
  first[u]:=cnt;
end;
function dfs(u,flow:longint):longint;
var p,v,res:longint;
begin
  if u=t then exit(flow);
  vis[u]:=true;
  p:=first[u];
  while p<>0 do
  begin
    v:=too[p];
    if (val[p]=0)or vis[v] then
    begin
      p:=nxt[p];
      continue;
    end;
    res:=0;
    res:=dfs(v,min(flow,val[p]));
    if res>0 then
    begin
      dec(val[p],res);
      inc(val[p xor 1],res);
      exit(res);
    end;
    p:=nxt[p];
  end;
  exit(0);
end;
var _a,_b:longint;
begin
  n:=4; //四个点
  m:=4; //四条边
  s:=1; //源点序号为1
  t:=4; //汇点序号为1
  readln(_a,_b);
  adde(1,2,_a);
  adde(2,1,0);
  adde(2,4,_a);
  adde(4,2,0);
  adde(1,3,_b);
  adde(3,1,0);
  adde(3,4,_b);
  adde(4,3,0);
  repeat
    fillchar(vis,sizeof(vis),0);
    res:=dfs(s,maxlongint);
    inc(tot,res);
  until res=0;
  if tot>=10 then 
    writeln('error')
  else
    writeln(tot);
end.

Measured memory_bytes: 128
#include <cstdio>

const int mod = 998244353;
const int MAXN = 10005;

template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

int f[MAXN][MAXN];
int fac[MAXN], ifac[MAXN];
char A[MAXN], B[MAXN];
int N;

int qkpow( int base, int indx )
{
	int ret = 1;
	while( indx )
	{
		if( indx & 1 ) ret = 1ll * ret * base % mod;
		base = 1ll * base * base % mod, indx >>= 1;
	}
	return ret;
}

void init( const int siz )
{
	fac[0] = 1;
	for( int i = 1 ; i <= siz ; i ++ ) fac[i] = 1ll * fac[i - 1] * i % mod;
	ifac[siz] = qkpow( fac[siz], mod - 2 );
	for( int i = siz - 1 ; ~ i ; i -- ) ifac[i] = 1ll * ifac[i + 1] * ( i + 1 ) % mod;
}

int C( const int n, const int m ) 
{ 
	if( n < m || n < 0 || m < 0 ) return 0;
	return 1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

void add( int &x, const int v ) { x = ( x + v >= mod ? x + v - mod : x + v ); }

int main()
{
	int S = 0, T = 0;
	scanf( "%s%s", A + 1, B + 1 );
	for( N = 1 ; A[N] ; N ++ )
	{
		int a = A[N] - '0', b = B[N] - '0';
		if( a && b ) S ++;
		if( a && ! b ) T ++;
	}
	init( N );
	f[0][0] = 1;
	for( int i = 0 ; i <= S ; i ++ )
		for( int j = 0 ; j <= T ; j ++ )
		{
			if( i ) add( f[i][j], 1ll * f[i - 1][j] * i % mod * j % mod );
			if( j ) add( f[i][j], 1ll * f[i][j - 1] * j % mod * j % mod );
		}
	int ans = 0;
	for( int i = 0 ; i <= S ; i ++ )
		add( ans, 1ll * C( S + T, i ) * C( S, i ) % mod * fac[i] % mod * fac[i] % mod * f[S - i][T] % mod );
	write( ans ), putchar( '\n' );
	return 0;
}

Measured memory_bytes: 71808
/*
*/
#include<bits/stdc++.h> 
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
//#define int long long 
#define LL long long 
#define rg register 
#define pt(x) printf("%d ", x);
#define Fin(x) {freopen(#x".in","r",stdin);}
#define Fout(x) {freopen(#x".out","w",stdout);}
using namespace std;
const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7;
const double eps = 1e-9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}

int N, a[MAXN];
main() {
	N = read();
	for(int i = 1; i <= N; i++) a[i] = read();
	sort(a + 1, a + N + 1); a[N] /= 2;
	LL sum = 0;
	for(int i = 1; i <= N; i++) sum += a[i];
	cout << sum;
    return 0;
}
/*

*/

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k;





//   a/b mod c
ll moddiv(ll a,ll b){
	ll x0=MOD,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%MOD;
      if (x2==1){
        ans=(n2+MOD)%MOD;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%MOD)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1) ans=ans*aa%MOD;
    aa=aa*aa%MOD;
    beki/=2;
    if (beki==0)break;
  }
  return ans;
}


int main(){
  ll ans=0;
  cin >> n ;
  vi x(n),sx(n);
  REP(i,n) cin>>x[i];
  REP(i,n){
    sx[i]=x[i+1]-x[i];
  }

  ll m=1;
  ll ii=1;
  for(int i=0;i<n-1;i++){
    ans+=sx[i]%MOD*m%MOD;
    //cout<<sx[i]%MOD*m%MOD<<endl;
    ans%=MOD;
    ii++;
    m=(m+moddiv(1LL,ii))%MOD;
  }

  REP(i,n-1){
    ans=ans*(i+1)%MOD;
  }

  cout<<ans<<endl;
  return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const LL MOD = 1000000007;

LL modpow(LL a, LL p) {
    if(p == 0) return 1LL;

    if(p % 2 == 0) {
        LL result = modpow(a, p / 2);
        return result * result % MOD;
    } else {
        return a * modpow(a, p - 1) % MOD;
    }
}

LL calc_c(LL n, LL k) {
    LL u = 1;
    LL l = 1;
    REP(i, k) {
        u = u * (n-i) % MOD;
        l = l * (k-i) % MOD;
    }

    LL inv = modpow(l, MOD-2);
    return u * inv % MOD;
}

void solve(long long N, long long M){
    LL ans = 1;
    for(LL i=2; i*i<=M; i++){
        LL cnt = 0;
        while(M % i == 0){
            cnt++;
            M /= i;
        }

        if(cnt != 0) {
            ans *= calc_c(cnt + N-1, N-1);
            ans %= MOD;
        }
    }

    if(M != 1){
        ans *= calc_c(N, N-1);
        ans %= MOD;
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int cmp_int(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void) {
  int x, n;
  scanf("%d %d", &x, &n);
  int num[n];
  if (!n) {
    printf("%d\n", x);
  } else {
    for (int i = 0; i < n; i++) {
      scanf(" %d", &num[i]);
    }

    qsort(num, n, sizeof(int), cmp_int);

    for (int i = 0; i < n; i++) {
      if (x < num[i]) {
        printf("%d\n", x);
        break;
      } else if (x > num[i]) {
        continue;
      } else if (x == num[i]) {
        int low = x - 1;
        int high = x + 1;

        for (int j = i - 1; j > -1; j--) {
          if (low != num[j]) {
            break;
          }
          low--;
        }

        for (int j = i + 1; j < n; j++) {
          if (high != num[j]) {
            break;
          }
          high++;
        }

        if ((x - low) > (high - x)) {
          printf("%d\n", high);
          break;
        } else {
          printf("%d\n", low);
          break;
        }
      }
    }
  }

  return 0;
}


Measured memory_bytes: 1736
//皆さん、第9回シンデレラガール総選挙は、トップでオンリーワンを目指す城ヶ崎美嘉に
//そしてボイスアイドルオーディションは、プログラミングが趣味の才女大石泉に、ぜひ投票をお願いします！
//#城ヶ崎美嘉を009のシンデレラに
//#大石泉の必勝プログラム
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int a[15][15];int c[15],s[15];
int main()
{
	int n,m,x,inf=1001001001,out=inf;cin>>n>>m>>x;
	rep(i,n){
		cin>>c[i];
		rep(j,m) cin>>a[i][j];
	}
	rep(i,(1<<n)){
		memset(s,0,sizeof(s));
		rep(j,n) rep(k,m){
			if(i&(1<<j)) s[k]+=a[j][k];
		}
		int sum=0,f=0;
		rep(j,n){
			if(i&(1<<j)) sum+=c[j];
		}
		rep(j,m){
			if(x>s[j]) f=1;
		}
		if(f<1) out=min(out,sum);
	}
	if(out<inf) cout<<out<<endl;
	else cout<<-1<<endl;
}


Measured memory_bytes: 3644
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;

namespace AOJ2
{
    class Program
    {

        static void Main(string[] args)
        {
            Dictionary<string, List<int>> dict = new Dictionary<string, List<int>>();

            string input;
            while ((input = Console.ReadLine()) != null)
            {
                string[] array = input.Split(' ');
                string word = array[0];
                int page = int.Parse(array[1]);

                if (!dict.ContainsKey(word))
                {
                    dict[word] = new List<int> { page };
                }
                else
                {
                    dict[word].Add(page);
                }
            }

            foreach (KeyValuePair<string, List<int>> pair in dict.OrderBy(s => s.Key))
            {
                Console.WriteLine(pair.Key);
                
                

                StringBuilder sb = new StringBuilder();
                foreach (int i in pair.Value.OrderBy(s => s))
                {
                    sb.Append(i);
                    sb.Append(" ");
                }
                sb.Length -= 1;

                Console.WriteLine(sb.ToString());
              
            }

        }


    }
}

Measured memory_bytes: 7028
#include <stdio.h>

int main(void){
long int sum=0;
  int n;
  scanf("%d", &n);
  for(int i=1;i<=n;i++){
  if(i%3!=0 && i%5!=0)
    sum+=i;
  }
  printf("%lld\n",sum);
  return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}

void pre(){


}

const int N = 3005;
ll dp[N][N];
int n,s;
int a[N];
ll store[N];

ll go(ll ind,ll s){
    if(s < 0)
        return 0;
    if(s==0){
        return store[ind];
    }
    if(ind > n)
        return 0;
    ll& ans = dp[ind][s];
    if(ans != -1)
        return ans;
    ans = 2*go(ind+1,s) + go(ind + 1 , s - a[ind]);
    ans %= mod;
    return ans;
}

void solve(){
    mod  = 998244353;
    cin >> n >> s;
    for(ll i=1;i<=n;i++){
        cin >> a[i];
    }
    for(ll i=0;i<n+2;i++){
        store[i] = fast(2,n-i+1);
    }
    memset(dp,-1,sizeof dp);
    ll ans = go(1,s);
    cout << ans << endl;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 74364
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll k;
  cin >> k;
  ll even = k/2;
  ll odd = (k+1)/2;
  cout << even*odd << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int x, y;
    while (true) {
        std::cin >> x >> y;
        if (x == 0 && y == 0) break;
        if (x < y) {
            std::cout << x << " " << y << std::endl;
        } else {
            std::cout << y << " " << x << std::endl;
        }
    }
    return 0;
}



Measured memory_bytes: 2960
#include "bits/stdc++.h"

using namespace std;

#define  f first
#define  lgn 25
#define  endl '\n'
#define  sc second
#define  N (int)2e5+5
#define  sz(x) x.size()
#define  ll long long int
#define  ld long double
#define  vi vector<int>
#define  vl vector<ll>
#define  vs vector<string>
#define  vc vector<char>
#define  mii map<int,int>
#define  mll map<ll,ll>
#define  pii pair<int,int>
#define  pll pair<ll,ll>
#define  vpll vector<pll>
#define  vpii vector<pii>
#define  test(x) while(x--)
#define  pb push_back
#define  eb emplace_back
#define  pq priority_queue
#define  mod 1000000007
#define  fo(i,a,n) for(int i=a;i<n;i++)
#define  rfo(i,n,a) for(int i=n;i>=a;i--)
#define  mst(a,v,n) fo(i,0,n) a[i]=v
#define  all(x) sort(begin(x),end(x))
#define  allr(x) sort(rbegin(x),rend(x))
#define  rev(x) reverse(begin(x),end(x))
#define  db(x) cout<<#x <<" : "<< x <<endl;
#define  tie ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

ll a[N],dp[N];
int n;
void go()
{
	cin>>n;
	memset(dp,0,sizeof dp);
	fo(i,0,n) cin>>a[i];
	ll ans=0;
	fo(i,0,n-1)
	{
		if(a[i]>=a[i+1]) dp[i]=dp[i-1]+1;
		else dp[i]=0;
		ans=max(dp[i],ans);
	}
	cout<<ans<<endl;
}

int32_t main()
{
	tie; int t=1; 
	// cin>>t;
	test(t) go();
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
	int n;
	cin>>n;
    double ans;
    if(n&1){
    	ans = (n+1)/2;
    } else{
    	ans = n/2;
    }
   // cout<<ans<<endl;
   ans = ans/n*1.0;
   cout<< fixed <<showpoint;
   cout<< setprecision(6);
   cout <<ans<<endl;

}

Measured memory_bytes: 3772