akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int N = 100005;

int a[N][2];
long long f[105][N];

int main() {
  int n, w;
  scanf("%d %d", &n, &w);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i][0], &a[i][1]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= w; j++) {
      if (j - a[i - 1][0] >= 0) {
        f[i][j] = max(f[i - 1][j], a[i - 1][1] + f[i - 1][j - a[i - 1][0]]);
      } else {
        f[i][j] = f[i - 1][j];
      }
    }
  }
  printf("%lld\n", f[n][w]);
  return 0;
}

Measured memory_bytes: 79360
def MAP(): return list(map(int,input().split()))

n,m = MAP()
lst = [MAP() for _ in range(n)]
lst = sorted(lst,key = lambda x:x[0])
q = 0
ans = 0

for i in lst:
    if q+i[1]<m:
        q+=i[1]
        ans+=i[0]*i[1]
    else:
        ans += (m-q)*i[0]
        break

print(ans)

Measured memory_bytes: 29800
function main()
	n = parse.(split(readline()))
	a = []
	for i in 1:n[1]
		c = split(readline(), "")
		for j in 1:length(c)
			if c[j] == "#"
				push!(a, c)
				break
			end
		end
	end
	flag = [0 for i in 1:n[2]]
	for i in 1:n[2]
		for j in 1:length(a)
			if a[j][i] == "#"
				flag[i] = 1
			end
		end
	end
	for i in 1:length(a)
		for j in 1:n[2]
			if flag[j] == 1
				print(a[i][j])
			end
		end
		println()
	end
end


main()


Measured memory_bytes: 181904
X = []
Y = []
for i in range(5):
    x = int(input())
    X.append(x)
    Y.append((10 - (x % 10)) % 10)

idx = Y.index(max(Y))
y = X.pop(idx)
Y.pop(idx)
print(sum(X) + sum(Y) + y)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int x, n;
    cin >> x >> n;
    int p[n];
    bool f[200];
    rep(i, 0, 200) f[i] = true;
    rep(i, 0, n) {
        cin >> p[i];
        f[p[i]] = false;
    }
    int ans = 0;
    int mn = INF;
    for (int i = 199; i >= 0; i--) {
        if (!f[i]) continue;
        int d = abs(i - x);
        if (d <= mn) {
            mn = d;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
using namespace std;

int main(int argc, char** argv)
{
	for(int i=1; i<6; i++)
	{
		int x;
		scanf("%d", &x);
		if(x == 0)
		{
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}

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


pair<int, int> cntx[300000];
pair<int, int> cnty[300000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif

  int h, w, m;
  cin >> h >> w >> m;
  set<pair<int, int>> S;
  for (int i = 0; i < h; ++i) cntx[i].second = i;
  for (int i = 0; i < w; ++i) cnty[i].second = i;

  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    cntx[a].first += 1;
    cnty[b].first += 1;
    S.insert({a, b});
  }
  sort(cntx, cntx + h);
  reverse(cntx, cntx + h);
  sort(cnty, cnty + w);
  reverse(cnty, cnty + w);
  int ans = cntx[0].first + cnty[0].first - 1;
  for (int i = 0; i < h; ++i) {
    if (cntx[i].first != cntx[0].first) {
      break;
    }
    for (int j = 0; j < w; ++j) {
      if (cnty[j].first != cnty[0].first) break;
      if (!S.count({cntx[i].second, cnty[j].second})) {
        ++ans;
        break;
      }
    }
    if (ans == cntx[0].first + cnty[0].first) break;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 22268
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int n, m, a;

int main() {
    while (cin >> n >> m) {
        vint res;
        for (int i = 0; i < n; ++i) {
            int tmp = 0;
            for (int j = 0; j < m; ++j) {
                cin >> a; tmp += a;
            }
            res.PB(tmp);
        }
        sort(ALL(res));
        
        cout << res[res.size()-1] << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, A, B;
  bool judge = false;
  cin >> K >> A >> B;
  for(int i = 0; A+i <= B;i++){
    if ((A+i) % K == 0) judge = true;
  }
  if(judge) cout << "OK";
  else cout << "NG";
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int a, b;
/**********************************************/

int main(){
    cin >> a;
    cin >> b;
    cout << (int)((a+b)/2.0 + 0.5) << endl;
}


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

N = int(input())
S = input()

ans = S.count('R') * S.count('G') * S.count('B')

for i in range(len(S)):
    for d in range(len(S)):
        j = i + d
        k = j + d
        if k >= N:
            break

        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1

print(ans)


Measured memory_bytes: 9196
n,m,k=map(int,input().split())

par=[i for i in range(n)]
size=[1 for i in range(n)]


def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
def union(a,b):
  x=find(a)
  y=find(b)
  if x!=y:
    if size[x]<size[y]:
      par[x]=par[y]
      size[y]+=size[x]
    else: 
      par[y]=par[x]
      size[x]+=size[y]
  else:
    return

graph=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    union(a-1,b-1)
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

for i in range(k):
    a,b=map(int,input().split())
    if find(a-1)==find(b-1):
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)

ans=[]

for i in range(n):
    cnt=size[find(i)]
    xxx=list(set(graph[i]))
    cnt-=len(xxx)
    cnt-=1
    ans+=[str(cnt)]


print(' '.join(ans))

Measured memory_bytes: 111960
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

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

    long long n, k;
    cin>>n>>k;
    vector<long long>v(n+1), ans(n+1);
    v[0] = 1;
    for(int i=1;i<=n;i++)
        cin>>v[i];

    for(int i=1;i<=n;i++)
    {
        ans[i]+=v[i]+ans[i-1];
    }

    for(int i=k+1;i<=n;i++)
    {
        //cout<<ans[i]<<' ';
        if(ans[i]-ans[i-k] > ans[i-1] - ans[i-1-k])
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(auto& x : v) cin >> x;
    const auto v0 = v;

    for(int i = 0; i < n; ++i) v[i] -= i + 1;

    nth_element(begin(v), begin(v) + n/2, end(v));

    const int x = v[n/2];

    long long ret = 0;

    for(int i =0; i < n; ++i) ret += abs(v0[i] - x - i - 1);

    cout << ret << endl; }


Measured memory_bytes: 1792
package main

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

func main() {
	n := nextInt()
	vs := make([]int, n)
	for i := 0; i < n; i++ {
		vs[i] = nextInt()
	}

	os, es := make([]int, 0, n/2), make([]int, 0, n/2)
	for i, v := range vs {
		if i%2 == 0 {
			es = append(es, v)
		} else {
			os = append(os, v)
		}
	}

	oMap := count(os)
	eMap := count(es)

	oMaxVal, oMaxCnt := maxAndValue(oMap)
	eMaxVal, eMaxCnt := maxAndValue(eMap)

	if oMaxVal == eMaxVal {
		if oMaxCnt == eMaxCnt {
			oMap[oMaxVal] = 0
			_, oMaxCnt2 := maxAndValue(oMap)
			eMap[eMaxVal] = 0
			_, eMaxCnt2 := maxAndValue(eMap)
			if oMaxCnt2 > eMaxCnt2 {
				oMaxCnt = oMaxCnt2
			} else {
				eMaxCnt = eMaxCnt2
			}
		} else if oMaxCnt > eMaxCnt {
			eMap[eMaxVal] = 0
			eMaxVal, eMaxCnt = maxAndValue(eMap)
		} else {
			oMap[oMaxVal] = 0
			oMaxVal, oMaxCnt = maxAndValue(oMap)
		}
	}

	fmt.Println(n - (oMaxCnt + eMaxCnt))
}

func maxAndValue(cntMap map[int]int) (int, int) {
	var maxVal, maxCnt int
	for val, cnt := range cntMap {
		if max(maxCnt, cnt) == cnt {
			maxCnt = cnt
			maxVal = val
		}
	}

	return maxVal, maxCnt
}

func count(nums []int) map[int]int {
	cntMap := map[int]int{}
	for _, num := range nums {
		cntMap[num]++
	}

	return cntMap
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

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

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


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

int n;
string s,t;

int main()
{
	cin >> n;
	cin >> s >> t;


	for(int i = 0;i < n;i++)
	{
		string a = s.substr(i,n - i);
		string b = t.substr(0,n - i);

		if(a == b)
		{
			cout << i + n << endl;
			return 0;
		}
	}

	cout << n + n << endl;


}


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

#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define ff                  first
#define ss                  second
#define sf                  scanf
#define pf                  printf
#define SQR(x)              ((x)*(x))
#define loop(i, y)          for(int i=0; i<int(y); i++)
#define FOR(i, x, y)        for(int i=int(x); i<int(y); i++)
#define ROF(i, x, y)        for(int i=int(x); i>=int(y); i--)
#define all(c)              c.begin(), c.end()
#define sz(c)               int(c.size())
#define clr(x, y)           memset(x, y, sizeof(x))
#define si(x)               scanf("%d", &x)
#define sii(x, y)           scanf("%d %d", &x, &y)
#define siii(x, y, z)       scanf("%d %d %d", &x, &y, &z)
#define sl(x)               scanf("%lld", &x)
#define sll(x, y)           scanf("%lld %lld", &x, &y)
#define slll(x, y, z)       scanf("%lld %lld %lld", &x, &y, &z)

#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************

/// Constants
#define MAX                 200005
#define MOD                 1000000007
#define eps                 1e-9
#define INF                 0x3f3f3f3f3f3f3f3f // 4,557,430,888,798,830,399
#define inf                 0x3f3f3f3f // 1,061,109,567
#define PI                  acos(-1.0)  // 3.1415926535897932
#define VT                  int

#define MAXD 42

ll f(ll a){
    ll res = 0, seg_size = 2;
    FOR(i, 0, MAXD){
        ll phases = (a+1)/seg_size;
        ll cnt = phases * seg_size/2;
        ll x = (a+1)%seg_size;
        if(x > seg_size/2){
            cnt += x - seg_size/2;
        }
        if(cnt&1LL) res ^= (1LL<<i);
        seg_size*=2;
    }
    return res;
}

int main(){
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll a, b;
    while(sll(a, b) == 2){
        ll res = f(b) ^ f(a-1);
        printf("%lld\n", res);
    }
    

    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, M, K; cin >> N >> M >> K;
  ll A[N]; rep(i,N) cin >> A[i];
  ll B[M]; rep(i,M) cin >> B[i];
  ll sa[N+1] = {}; rep(i,N) sa[i+1] = sa[i] + A[i];
  ll sb[M+1] = {}; rep(i,M) sb[i+1] = sb[i] + B[i];

  ll result = 0;
  rep(i,N+1) {
    ll left = K - sa[i];
    if (left>=0) {
      ll pos = upper_bound(sb,sb+(M+1),left) - (sb+1);
      // cout << i << "-" << pos << endl;
      result = max(result, i+pos);
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 9872
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cin(string, s);
    For(i, s.size()){
        cout << (char)((s[i]-'A'+n) % 26 + 'A');
    }
    Cout();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct card{
    char suit ,value;
};
void bs(struct card a[],int n){
    for(int i=0;i<n;i++){
        for(int j=n-1;j>=i+1;j--){
            if(a[j].value<a[j-1].value){
                card t=a[j];a[j]=a[j-1];a[j-1]=t;
            }
        }
    }
}

void ss(struct card a[],int n){
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(a[j].value<a[minj].value)minj =j;
        }
            swap(a[i],a[minj]);

        }
    }
void print(struct card a[],int n){
    for(int i=0;i<n;i++){
        if(i)cout << " ";
        cout << a[i].suit<<a[i].value;
    }
    cout << endl;
}

bool stable(struct card c1[],struct card c2[],int n){
    for(int i=0;i<n;i++){
        if(c1[i].suit!=c2[i].suit)return false;
    }
    return true;
}
int main()
{
    int n;
    cin >>n;
    card c1[n],c2[n];
    for(int i=0;i<n;i++){
        cin >> c1[i].suit>>c1[i].value;
    }
    for(int i=0;i<n;i++)c2[i]=c1[i];
    bs(c1,n);
    ss(c2,n);
    print(c1,n);
    cout << "Stable"<<endl;
    print(c2,n);
    if(stable(c1,c2,n))cout << "Stable"<< endl;
    else cout << "Not stable"<< endl;
    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    vector<ll> cnt(n), sum(n+1);

    rep(i,n){
        ll B = b[i];
        ll ok = -1;
        ll ng = n;
        ll mid = (ok + ng)/2;
        while(ng - ok > 1){
            if(a[mid] < B) ok = mid;
            else ng = mid;
            mid = (ok + ng)/2;
        }
        cnt[i] = ok + 1;
    }

    rep(i,n) sum[i+1] = sum[i] + cnt[i];

    rep(i,n){
        ll C = c[i];
        ll ok = -1;
        ll ng = n;
        ll mid = (ok + ng)/2;
        while(ng - ok > 1){
            if(b[mid] < C) ok = mid;
            else ng = mid;
            mid = (ok + ng)/2;
        }
        ans += sum[ok + 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <iostream>
#include "vector"
#include "stack"
#include "utility"
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

int main() {
    IOS

    ll n;
    cin >> n;

    cout << n * n;

    return 0;
}

Measured memory_bytes: 764
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = read!(usize);
    let a: Vec<usize> = read!(usize; n);

    let mut sort_a = a.clone();
    sort_a.sort();

    // 数字jがインデックスiにある場合 pos[j] = i とする
    let mut pos_orig = HashMap::new();
    let mut pos_sort = HashMap::new();

    for i in 0..n {
        pos_orig.insert(a[i], i);
        pos_sort.insert(sort_a[i], i);
    }

    let mut count = 0;
    for v in &a {
        // ソート後の位置とソート前の位置の差が偶数である場合は操作2の繰り返しにより移動可能
        // 奇数である場合は操作2を繰り返したあと最後に1回だけ操作1をする必要がある
        // そして「位置の差が奇数である」ような数字は必ず偶数個あり、この個数を2nとすると、操作1をおこなう回数はnとなる
        if pos_orig.get(v).unwrap() % 2 == pos_sort.get(v).unwrap() % 2 {
            continue;
        } else {
            count += 1;
        }
    }

    println!("{}", count / 2);
}


Measured memory_bytes: 16344
N = int(input())

count = {
    'M' : 0,
    'A' : 0,
    'R' : 0,
    'C' : 0,
    'H' : 0,
}

for _ in range(N):
    s = input()
    if s[0] in count:
        count[s[0]] += 1

ans = 0
count = list(count.items())
for i in range(len(count)):
    for j in range(i + 1, len(count)):
        for k in range(j + 1, len(count)):
            ans += count[i][1] * count[j][1] * count[k][1]

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

vector<int> MakePrimeNumber(int);

int main(){
  int i, n;
  double sum;
  vector<int> data;

  data = MakePrimeNumber(110000);

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0, sum=0.0; i<n; ++i) sum += data[i];

    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(0);
    cout << sum << endl;
  }
  return 0;
}

vector<int> MakePrimeNumber(int n){
  int i, j, k;
  vector<int> data;

  data.push_back(2);
  data.push_back(3);
  for(i=5; i<=n; i+=2){
    for(j=1, k=0; data[j]<=sqrt(i); ++j){
      if(i%data[j] == 0){
        k = 1;
        break;
      }
    }
    if(k == 0) data.push_back(i);
  }
  return data;
}

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

int main(void)
{
	int a, b, c;
	char c1, c2;
	int tyocount = 0;
	int hishicount = 0;

	while(cin >> a >> c1 >> b >> c2 >> c)
	{
		if(a==b) hishicount++;
		if(a*a+b*b==c*c) tyocount++;
	}
	cout << tyocount << endl << hishicount << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  string s;
  cin >> s;
  unordered_map<string, int> map{{"SUN", 7}, {"MON", 6}, {"TUE", 5}, {"WED", 4}, {"THU", 3}, {"FRI", 2}, {"SAT", 1}, };
  cout << map[s] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
int A[N];
int main() {
	int n ;
	cin >> n;
	for(int i=1; i<=n; i++) scanf("%d",&A[i]);
	int Ans = 0;
	for(int i=1; i<=n; i++) {
		int now = i+1;
		while(now <= n && A[now] <= A[now-1]) now ++;
		now --;
		Ans = max(Ans,now-i+1);
		i = now;
	}
	Ans --;
	cout<<Ans;
	return 0;
}

Measured memory_bytes: 640
# abc113_b.py
# https://atcoder.jp/contests/abc113/tasks/abc113_b

# B - Palace /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点: 200点

# 問題文
# ある国で、宮殿を作ることになりました。
# この国では、標高が xメートルの地点での平均気温は T−x×0.006度です。
# 宮殿を建設する地点の候補は N個あり、地点 i の標高は Hiメートルです。
# joisinoお姫様は、これらの中から平均気温が A度に最も近い地点を選んで宮殿を建設するようにあなたに命じました。
# 宮殿を建設すべき地点の番号を出力してください。
# ただし、解は一意に定まることが保証されます。

# 制約
#     1≤N≤1000
#     0≤T≤50
#     −60≤A≤T
#     0≤Hi≤105
#     入力は全て整数
#     解は一意に定まる

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# T A
# H1 H2 ... HN

# 出力
# 宮殿を建設すべき地点の番号を出力せよ。

# 入力例 1
# 2
# 12 5
# 1000 2000

# 出力例 1
# 1

#     地点 1の平均気温は 12−1000×0.006=6度です。
#     地点 2の平均気温は 12−2000×0.006=0度です。

# よって、宮殿を建設すべき地点は地点 1となります。

# 入力例 2
# 3
# 21 -11
# 81234 94124 52141

# 出力例 2
# 3


def calculation(lines):
    N = int(lines[0])
    T, A = list(map(int, lines[1].split()))
    values = list(map(int, lines[2].split()))
    # n = lines[0]

    result = None
    id = None

    for i, value in enumerate(values):
        t = T - value * 0.006
        # print(t)
        dif = abs(A-t)
        if result is None:
            result = dif
            id = i
        elif result > dif:
            result = dif
            id = i

    return [id+1]



# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2', '12 5', '1000 2000']
        lines_export = [1]
    if pattern == 2:
        lines_input = ['3', '21 -11', '81234 94124 52141']
        lines_export = [3]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(3)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
struct UnionFind{
vector<int> par,depth,Size;
UnionFind(int n){
par.resize(n); depth.resize(n); Size.resize(n);
for(int i=0; i<n; i++){
par[i]=i;
depth[i]=0;
Size[i]=1;
}
}
int find(int x){
if(par[x]==x){
return x;
}
else{
return par[x]=find(par[x]);
}
}
bool same(int x, int y){
return find(x)==find(y);
}
void unite(int x, int y){
x=find(x); y=find(y);
if(x==y) return;
if(depth[x]<depth[y]) swap(x,y);
if(depth[x]==depth[y]) depth[x]++;
par[y]=x;
Size[x]+=Size[y];
}
int size(int x){
return Size[find(x)];
}
};
int main(){
    int n,m;cin >> n >> m;
    vector<int> x(m),y(m),z(m);
    for(int i=0;i<m;i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    int ans=0;
    int cnt=0;
    vector<int> ok(n+1);
    UnionFind uf(n+1);
    for(int i=0;i<m;i++){
        if(!uf.same(x[i],y[i])){
            uf.unite(x[i],y[i]);
        }
    }
    for(int i=1;i<=n;i++){
        int par=uf.find(i);
        if(ok[par]==0){
            ok[par]=uf.size(par);
            cnt+=ok[par];
            ans++;
        }
    }
    ans+=n-cnt;
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<ll> t(n), a(n);

  REP(i, n) { cin >> t[i]; }
  REP(i, n) { cin >> a[i]; }

  // 固定されている値
  vector<ll> checkt(n), checka(n);
  checkt[0] = t[0];
  checka[n - 1] = a[n - 1];

  FOR(i, 1, n) {
    if (t[i - 1] != t[i]) {
      checkt[i] = t[i];
    }
  }

  for (int i = n - 2; i >= 0; i--) {
    if (a[i + 1] != a[i]) {
      checka[i] = a[i];
    }
  }

  REP(i, n) {
    if (checkt[i] != 0 && checka[i] != 0 && checkt[i] != checka[i]) {
      cout << 0 << endl;
      return 0;
    }
    if (checkt[i] != 0 && a[i] < checkt[i]) {
      cout << 0 << endl;
      return 0;
    }
    if (checka[i] != 0 && t[i] < checka[i]) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  REP(i, n) {
    if (checkt[i] == 0 && checka[i] == 0) {
      ans = (ans * min(a[i], t[i])) % MOD;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3328
//Ojas Kumar Dubey //
// el_freki //
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll>
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int md=1000000007;
#define test int t;cin>>t;while(t--)
#define f(i,j,n) for(int i=j;i<n;i++)
#define r(i,j,n) for(int i=j-1;i>=n;i--)
#define min INT_MIN
#define max INT_MAX
#define all(container) container.begin() , container.end()
#define sz(container) (int)container.size()
#define pii pair <int , int>
#define pll pair <long long int , long long int>
#define setp(x) setprecision(x)
// ------------------------------------Template End------------------------------ //
int main()
{
	fast;
	int n;
	cin>>n;
	int b[n-1];
	for(int i=0;i<n-1;i++){
		cin>>b[i];
	}
	int a=b[0];
	for(int i=0;i<n-2;i++){
		if(b[i]<b[i+1])
			a+=b[i];
		else
			a+=b[i+1];
	}
	cout<<a+b[n-2];
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int a[101010],b[101010];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	long long sum=0;
	for(int i=1;i<=n;i++)
		sum+=b[i];
	for(int i=1;i<=n;i++)
		sum-=a[i];
	long long cnt=0;
	for(int i=1;i<=n;i++)
	if(b[i]>a[i])
		cnt+=(b[i]-a[i]+1)/2;
	 if(cnt<=sum)
	 	cout<<"Yes"<<endl;
	 else
	 	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*

val readInts: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }

fun main(args: Array<String>) {
    val (N, M) = readInts()
    val egs = Array(N){
        ArrayList<Int>(0)
    }
    repeat(M) {
        var (a, b) = readInts()
        a--; b--
        egs[a].add(b)
        egs[b].add(a)
    }

    var ans = 0
    var vis = BooleanArray(N){false}

    fun dfs(x:Int, px:Int=-1) {
        if (vis[x]) return
        vis[x] = true

        if (vis.filter{it}.size == N) ans++

        for(nx in egs[x]) {
            if (nx == px) continue
            dfs(nx, x)
        }

        vis[x] = false
    }

    dfs(0)

    println(ans)
}


Measured memory_bytes: 41148
#include<stdio.h>
int a;
int b;

int main(void){

	scanf("%d %d",&a,&b);
	if(a < b){
		printf("a < b\n");
	}else{
		if(a > b){
			printf("a > b\n");
		}else{
			if(a == b){
				printf("a == b\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define MN 100000
struct edge{int x,y,w;}e[MN+5];
bool cmp(const edge&a,const edge&b){return a.w<b.w;}
int a[MN+5],b[MN+5],f[MN+5];long long s[MN+5],ss[MN+5];
int gf(int k){return f[k]?f[k]=gf(f[k]):k;}
int main()
{
	int n,m,i;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)scanf("%d%d",&a[i],&b[i]),s[i]=max(a[i],b[i]),ss[i]=b[i];
	for(i=1;i<=m;++i)scanf("%d%d",&e[i].x,&e[i].y),e[i].w=max(a[e[i].x]-b[e[i].x],a[e[i].y]-b[e[i].y]);
	sort(e+1,e+m+1,cmp);
	for(i=1;i<=m;++i)if((e[i].x=gf(e[i].x))!=(e[i].y=gf(e[i].y)))
	{
		s[e[i].x]=min(max(s[e[i].x],1LL*e[i].w)+ss[e[i].y],max(s[e[i].y],1LL*e[i].w)+ss[e[i].x]);
		ss[e[i].x]+=ss[e[i].y];
		f[e[i].y]=e[i].x;
	}
	printf("%lld",s[gf(1)]);
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int n,k;
    cin>>n>>k;
    ll int a[n];
    ll int i,mx=INT_MIN;
    for(i=0;i<n;i++)
       {
             cin>>a[i];
             mx=max(a[i],mx);
         }
       //  for(i=0;i<n;i++)
         //   cout<<a[i]<<endl;
    ll int l=1,r=mx;
    ll int ans=mx;
    while(l<=r)
    {
        ll int mid=(l+r)/2;
       // cout<<mid<<endl;
        ll int val=0,tot=0;
        for(i=0;i<n;i++)
        {
            val=a[i]/mid;
         //   cout<<val<<endl;
            if(val*mid==a[i])
                tot+=val-1;
            else
                tot+=val;
        }
       // cout<<tot<<"djdj "<<mid<<" "<<k<<endl;
        if(tot>k)
        {
            l=mid+1;
        }
        else if(tot<=k)
        {
            r=mid-1;
            ans=min(mid,ans);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5112
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_


int main(void) {
	ULONG N;
	cin >> N;
	vector<ULONG> a(N);
	for (ULONG i = 0; i < N; i++) {
		cin >> a[i];
	}

	ULONG xor_ = 0;
	for (ULONG j = 1; j < N; j++) {
		xor_ = xor_ ^ a[j];
	}
	cout << xor_ << " ";

	for (ULONG i = 1; i < N; i++ ){
		xor_ = xor_ ^ a[i - 1];
		xor_ = xor_ ^ a[i];
		cout << xor_;
		if (i != N - 1) {
			cout << " ";
		}
	}

	cout << endl;
	


	return 0;
}

Measured memory_bytes: 4712
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int A;
double B;
int B_;
char B__[10];
char B_1[10];
signed main(){
    scanf("%lld %s",&A,B__);
    B_1[0]=B__[0];
    B_1[1]=B__[2];
    B_1[2]=B__[3];
    B_1[3]='\0';
    B_=atoi(B_1);
    //printf("%lld %lld\n",A,B_);
    int ans=(int)A*(int)B_/(int)100;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1732
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int h = scan.nextInt();
        int w = scan.nextInt();
        System.out.println((n - h + 1) * (n - w + 1));
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	bool ok = false;
	while(a > 0){
		int dig = a % 10;
		a /= 10;
		if(dig == 7)
			ok = true;
	}
	if(ok)
		puts("Yes");
	else
		puts("No");
}

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

using namespace std;

int N;
string s;
vector<string> res;

void dfs(int idx, bool bs[]) {
  if(idx == N) {
    res.push_back(s);
    return;
  }

  int c = s[idx] - 'a';

  if(!c || bs[c]) {
    dfs(idx + 1, bs);
  }

  if(c < 25 && !bs[c + 1]) {
    bs[c + 1] = 1;
    s[idx]++;
    dfs(idx + 1, bs);
    bs[c + 1] = 0;
    s[idx]--;
  }
}

int main() {

  while(cin >> s && s != "#") {
    N = s.size();
    res.clear();
    bool bs[26] = {};
    dfs(0, bs);
    sort(res.begin(), res.end());
    cout << res.size() << endl;
    if(res.size() <= 10) for(auto e: res) cout << e << endl;
    else {
      for(int i=0; i<5; i++) cout << res[i] << endl;
      for(int i=res.size() - 5; i<res.size(); i++) cout << res[i] << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 4176
import java.util.Scanner;


public class Main {
	static int N;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
			 N = sc.nextInt();
		sc.close();

		boolean t = false;
		int s = 0 ;
		for(int i = 2 ; i < 500 ; i++){
			if((i*(i-1))/2 == N){
				t = true;
				s = i;
				break;
			}
		}


		if(t){
			System.out.println("Yes");
			System.out.println(s);
			int C = (s*(s-1))/2;

			int[][] A = new int[s+1][C+1];
			int count = 1;

			for(int i = 1 ; i<=s ; i++){
				for(int j = i+1 ;j <=s ; j++){
				A[i][count] = count;
				A[j][count] = count;
				count++;
				}
			}
			String ans ="";
			for(int i = 1 ; i< s+1 ; i++){
				for(int j = 1 ;j <  C+1 ; j++){
					if(A[i][j] != 0){
						ans = ans + " " + Integer.toString(A[i][j]);
					}
				}
				System.out.println(s-1 + ans);
				ans = "";
			}
		}
		else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 532288
#include <iostream>
#include <queue>
#include <vector>

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(int argc, char const* argv[])
{
    int h, w;
    std::cin >> h >> w;

    auto queue = std::queue<std::pair<int, int>>();
    auto map = std::vector<std::vector<int>>(h, std::vector<int>(w, 0));

    auto stage = std::vector<std::string>(h);
    auto line_count = 0;
    for(auto &line: stage)
    {
        std::cin >> line;

        for(int i=0; i<w; ++i)
        {
            if(line[i] == '#')
            {
                queue.push(std::make_pair(line_count, i));
                map[line_count][i] = 1;
            }
        }
        line_count++;
    }

    auto cost_max = 1;
    while(!queue.empty())
    {
        auto current = queue.front();
        queue.pop();

        auto current_cost = map[current.first][current.second];

        for(int i=0; i<4; ++i)
        {
            auto next_x = current.first + dx[i];
            auto next_y = current.second + dy[i];

            if(next_x != -1 && next_x != h && next_y != -1 && next_y != w)
            {
                if(stage[next_x][next_y] == '.' && map[next_x][next_y] == 0)
                {
                    queue.push(std::make_pair(next_x, next_y));
                    map[next_x][next_y] = current_cost + 1;
                    cost_max = std::max(current_cost + 1, cost_max);
                }
            }
        }
    }

    std::cout << cost_max - 1 << std::endl;
}

Measured memory_bytes: 13456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

ll x[5];

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


Measured memory_bytes: 3568
import java.util.Scanner;


public class Main
{


	public static void main(String[] args) {
		int i,j;
		for(i=1;i<10;i++){
			for(j=1;j<10;j++){
				System.out.println(i+"x"+j+"="+i*j);
			}
		}
		
					
		}
	

}

Measured memory_bytes: 8992
import sys
input = sys.stdin.readline
from itertools import accumulate

def main():
    H,W,D = map(int,input().split())
    A = [None] * (H*W+1)
    for i in range(H):
        j = 1
        for x in input().split():
            A[int(x)] = [0,(i+1,j)]
            j += 1

    for i in range(1,H*W+1):
        if i <= D:
            continue
        A[i][0] += A[i-D][0]
        A[i][0] += abs(A[i][1][0] - A[i-D][1][0])
        A[i][0] += abs(A[i][1][1] - A[i-D][1][1])

    # クエリ
    Q = int(input())
    for _ in range(Q):
        L, R = map(int,input().split())

        print(A[R][0] - A[L][0])

if __name__ == "__main__":
    main()

Measured memory_bytes: 22812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
#define all(a) a.begin(), a.end()
#define mp(a, b) make_pair(a, b)

int INF = 100100100;
int MOD = 10e7+9;

int main(){
    int N;
    cin >> N;
    ll ans = 0;
    vector<ll> ch(N, 0);
    rep(i ,0, N){
        ll a;
        cin >> a;
        ch[i] = a;
    }
    sort(all(ch));
    reverse(all(ch));
    rep(i, 1, N){
        ans += ch[i/2];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4788
#![allow(bare_trait_objects)]
#![allow(unused_imports)]
#![allow(dead_code)]

use std::collections::{HashMap, HashSet};
use std::fmt::Debug;
use std::io::BufRead;
use std::io::Stdin;
use std::io::StdinLock;
use std::str::FromStr;

pub struct Scanner<'a> {
    // stdin: Stdin,
    buf_read: Box<BufRead + 'a>,
    tokens: Vec<String>,
}

impl<'a> Scanner<'a> {
    pub fn new(buf_read: StdinLock<'a>) -> Self {
        Scanner {
            buf_read: Box::new(buf_read),
            tokens: Vec::new(),
        }
    }

    // pub fn from_stdin() -> Self {
    //     let stdin = Box::leak(Box::new(std::io::stdin()));
    //     Self {
    //         buf_read: Box::new(stdin.lock()),
    //         tokens: Vec::new(),
    //     }
    // }

    pub fn next(&mut self) -> String {
        while self.tokens.is_empty() {
            let mut s = String::new();
            if self.buf_read.read_line(&mut s).is_err() {
                panic!()
            }
            self.tokens = s
                .split_whitespace()
                .filter(|s| !s.is_empty())
                .rev()
                .map(str::to_string)
                .collect();
        }
        self.tokens.pop().unwrap()
    }

    pub fn next_g<T: FromStr>(&mut self) -> T
    where
        T::Err: Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn usize(&mut self) -> usize {
        self.next_g()
    }

    pub fn i64(&mut self) -> i64 {
        self.next_g()
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let mut mp = HashMap::new();
    let n = sc.usize();
    let mut cnt1 = vec![0_i64; 200];
    let mut cnt2 = vec![0; 200];
    for _ in 0..n {
        let s = sc.next();
        if !mp.contains_key(&s) {
            let i = mp.len();
            mp.insert(s.clone(), i);
        }
        cnt1[*mp.get(&s).unwrap()] += 1;
    }

    let m = sc.usize();
    for _ in 0..m {
        let s = sc.next();
        if !mp.contains_key(&s) {
            let i = mp.len();
            mp.insert(s.clone(), i);
        }
        cnt2[*mp.get(&s).unwrap()] += 1;
    }
    let ans = (0..200).map(|i| cnt1[i] - cnt2[i]).max().unwrap();
    println!("{}", ans)
}


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

const int MOD = 1000000007;

ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    ll N;
    cin >> N;
    ll ans = pow_mod(10,N,MOD) - pow_mod(9,N,MOD)*2 + pow_mod(8,N,MOD);
    ans %= MOD;
    ans = (ans + MOD)%MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3544
import java.util.Scanner;

public class Main {
    public Main () {
        Scanner sc = new Scanner(System.in);
        int n = 3;

        int[][] a = new int[n][n];

        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                a[i][j] = sc.nextInt();


        int[] b1 = dif(a[0]);
        int[] b2 = dif(a[1]);
        int[] b3 = dif(a[2]);

        if (b1[0] == b2[0] && b1[1] == b2[1]
                && b2[0] == b3[0] && b2[1] == b3[1])
            System.out.println("Yes");
        else System.out.println("No");
    }

    private int[] dif(int a[]) {
        return new int[]{a[1] - a[0], a[2] - a[1]};
    }

    public static void main (String[] args) {
        new Main();
    }

}


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

using namespace std;

    int arr[3005][3005];

int main(){
    int i,j;
    stack<char> s;
    string sa,sb;
    cin >> sa >> sb;
    for(i=1;i<=sa.size();i++){
        for(j=1;j<=sb.size();j++){
            if(sa[i-1]==sb[j-1]) arr[i][j]=arr[i-1][j-1]+1;
            else arr[i][j]=max(arr[i][j-1],arr[i-1][j]);
        }
    }
    /*for(i=1;i<=sa.size();i++){
        for(j=1;j<=sb.size();j++){
            printf("%d ",arr[i][j]);
        }
        printf("\n");
    }*/
    i=sa.size();
    j=sb.size();
    if(arr[i][j]==0) printf(" ");
    else {while(arr[i][j]!=0){
        while(arr[i][j]==arr[i-1][j]) i--;
        while(arr[i][j]==arr[i][j-1]) j--;
        s.push(sa[i-1]);
        j--;
        i--;
    }
    while(!s.empty()){
        printf("%c",s.top());
        s.pop();
    }}
    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll Sn;
char S[1010101];
ll dp[1010101][3];
ll i, j, k;

int main(){
    scanf("%s", S);
    Sn = strlen(S);
    reverse(S, S + Sn);
    fornum(i,0,Sn+5){
        dp[i][0] = dp[i][1] = 1e9;
    }
    dp[0][0] = 0;
    fornum(i,0,Sn){
        ll sn = S[i] - '0';
        fornum(j,0,2){
            dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + j + sn);
            dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + 10 - j - sn);
        }
    }
    printf("%lld", min(dp[Sn][0], dp[Sn][1] + 1));
    return 0;
}

Measured memory_bytes: 24960