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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

const ll MOD = 1e9 + 7;
ll N, A, B, C, D;
ll dp[1010][1010];


namespace tottori{
    // until C++17
    template <typename T, size_t N>
    constexpr size_t size(const T (&array)[N]){
        return N;
    }
};

template <typename T>
T expt(T a, T n, T mod = std::numeric_limits<T>::max()){
    T res = 1;
    while(n){
        if(n & 1){res = res * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <typename T>
T inverse(T n, T mod){
    return expt(n, mod-2, mod);
}

ll fact[3000], inv[3000];

// nPr
template <typename T>
T nPr(T n, T r, T mod = std::numeric_limits<T>::max()){
    if(n < r){return 0;}
    return fact[n] * inv[n-r] % mod;
}

// nCk
template <typename T>
T nCk(T n, T k, T mod = std::numeric_limits<T>::max()){
    if(n < k){return 0;}
    return fact[n] * inv[k] % mod * inv[n-k] % mod;
}

template <typename T>
T nHk(T n, T k, T mod = std::numeric_limits<T>::max()){
    if(n == 0 && k == 0){return 1;}
    return nCk(n+k-1, k);
}

void initFactAndInv(ll mod){
    fact[0] = 1;
    inv[0] = 1;
    
    for(int i=1;i<tottori::size(fact);i++){
        fact[i] = fact[i-1] * i % mod;
        inv[i] = inverse(fact[i], mod);
    }
}

ll rec(int n, int i){
    if(dp[n][i] != -1){return dp[n][i];}
    if(n == 0){return 1ll;}
    if(n < i || B < i){return 0ll;}
    
    ll res = rec(n, i+1);
    
    for(int j=C;j<=D;++j){
        if(i * j > n){break;}

        // printf("%d, %d, %d: %lld, %lld\n",
        //        n, i, j,
        //        rec(n-i*j, i+1),
        //        nPr(1ll * n, 1ll * i*j, MOD) * inverse(expt(fact[i], 1ll * j, MOD), MOD) % MOD * inverse(fact[j], MOD) % MOD * rec(n-i*j, i+1) % MOD);
        // printf("%d, %d, %d: (%lld, %lld, %lld)\n",
        //        n, i, j,
        //        nPr(1ll * n, 1ll * i*j, MOD),
        //        expt(fact[i], 1ll * j, MOD),
        //        fact[j]);
        res = (res + nPr(1ll * n, 1ll * i*j, MOD) * expt(inv[i], 1ll * j, MOD) % MOD * inv[j] % MOD * rec(n-i*j, i+1) % MOD) % MOD;
    }

    // printf("%d, %d: %lld\n", n, i, res);
    return dp[n][i] = res;
}

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

    initFactAndInv(MOD);
    
    std::cin >> N >> A >> B >> C >> D;

    memset(dp, -1ll, sizeof(dp));
    
    std::cout << rec(N, A) << std::endl;
}


Measured memory_bytes: 8448
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0141

"""
import sys
from sys import stdin
input = stdin.readline
from itertools import cycle


def guruguru(n):
    dirs = cycle([(0, -1), (1, 0), (0, 1), (-1, 0)]) #  x, y???????????? (???????????????????????????)

    M = [[' '] * n for _ in range(n)] #  ??????????????¨?????????????????§?????????
    cx = 0                      #  ??????????????°???
    cy = n - 1
    line = 0                    #  ???????????§??????????????????n??¨???????????°??????????????¨??????

    while line < n:
        line += 1
        dx, dy = dirs.__next__() #  ???????????????????????????????????????????????????
        while True:
            M[cy][cx] = '#'
            nx = cx + dx        #  ?¬???????????????¨???????????????
            ny = cy + dy
            nnx = nx + dx       #  ?¬?????¬???????????????¨???????????????
            nny = ny + dy

            if nx < 0 or nx >= n: #  ??????????????????????????????????????§???????????¢?????????
                break
            if ny < 0 or ny >= n:
                break
            if nny < 0 or nny >= n or nnx < 0 or nnx >= n:
                pass
            else:
                if M[nny][nnx] != ' ': #  ??????????????????????????????????????¢??????????????????????????£??????????????´??????????????¢?????????
                    break
            cx = nx
            cy = ny

    # ?????????????????????????????????
    for l in M:
        print(''.join(l))


def main(args):
    n = int(input())
    for i in range(n):
        size = int(input())
        guruguru(size)
        if i != (n - 1):        #  ????????\?????????????????????????????????????????\??????
            print()


if __name__ == '__main__':
    main(sys.argv[1:])
    

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

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

    int K;
    string S;
    cin >> K >> S;

    if (S.length() > K) {
        S = S.substr(0, K);
        S.append("...");
    }
    cout << S << endl;

    return 0;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int a[2][200];
int dp[2][200];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  for(int k=0;k<2;k++){
    for(int i=0;i<n;i++){
      cin>>a[k][i];
    }
  }
  for(int i=0;i<n;i++){
    dp[0][i+1] = a[0][i] + dp[0][i];
    dp[1][i+1] = max(dp[0][i+1]+a[1][i], dp[1][i] + a[1][i]);
  }

  cout<<dp[1][n]<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static long memo[][];
    public static int w[],v[];
    public static int n;

    public static long dp(int i,int rw){
        if(rw<0) return (long) -1e9;
        if(i==n) return 0;
        if(memo[i][rw] != -1) return memo[i][rw];
        return memo[i][rw] = Math.max(dp(i+1,rw),v[i] + dp(i+1,rw - w[i])); 
    }

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int s = sc.nextInt();
        w = new int[n];//////////////////////////
        v = new int[n];
        memo = new long[n+1][s+1];
        for(long x[] : memo)
            Arrays.fill(x,-1L);
        for(int i=0;i<n;i++){
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        System.out.println(dp(0,s)); 
    } 
}

Measured memory_bytes: 131512
import qualified Data.ByteString.Char8 as B
import           Data.Maybe            (fromJust)

readInts :: B.ByteString -> [Int]
readInts = map (fst . fromJust . B.readInt) . B.words

getInts :: IO [Int]
getInts = readInts <$> B.getLine

main :: IO ()
main = do
  n <- readLn
  as <- getInts
  putStrLn $ if solve n as then "APPROVED" else "DENIED"

solve :: Int -> [Int] -> Bool
solve _ as = all (\x -> x `mod` 3 == 0 || x `mod` 5 == 0) $ filter even as


Measured memory_bytes: 508
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  int N, M, T;
  int a[100];
  scanf("%d %d %d", &N, &M, &T);
  for (int i=0;i<N;i++) scanf("%d", &a[i]);
  int ans = T-M-min(M, T-a[N-1]);
  for (int i=1;i<N;i++) ans -= min(a[i]-a[i-1], 2*M);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 2740
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	vector<pair<int,int>> tasks;
	rep(i,n){
		int a,b;
		cin >> a >> b;
		tasks.emplace_back(b,a);
	}
	SORT(tasks);
	int time = 0;
	rep(i,n){
		time += tasks[i].second;
		if(time>tasks[i].first){
			out("No");
			return 0;
		}
	}
	out("Yes");
}




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

using namespace std;
#define BUF (100005)
#define ll long long 
#define INF 400000005

int n;
int k;
int x[BUF];

int main(void){
	cin >> n >> k;
 	for (int i =1;i<=n;++i){
	       	cin >> x[i];
	}

	int ans = INF;

	for(int i=1;i<=n-k+1;i++){
		int r = x[i];
		int l = x[i+k-1];
		int mn = INF;
		if(r==l) mn = r;
		else if(r<0 && l>0){
			mn = min(-2*r+l, -r+2*l);
		}else if(r>=0 && l>=0){
		    mn = l;
		}else if(r<=0 && l<=0){
			mn = -r;
		}
		ans = min(ans,mn);
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
class UnionFind:
    def __init__(self, n):
        self.setSize = [1] * n
        self.numSets = n
        self.rank = [0] * n
        self.p = [i for i in range(n)]
    def findSet(self, i):
        if self.p[i] == i:
            return i
        else:
            self.p[i] = self.findSet(self.p[i])
            return self.p[i]
    def isSameSet(self, i, j):
        return self.findSet(i) == self.findSet(j)
    def unionSet(self, i, j):
        if not self.isSameSet(i, j):
            self.numSets -= 1
            x = self.findSet(i)
            y = self.findSet(j)
            if self.rank[x] > self.rank[y]:
                self.p[y] = x
                self.setSize[x] += self.setSize[y]
            else:
                self.p[x] = y
                self.setSize[y] += self.setSize[x]
                if self.rank[x] == self.rank[y]:
                    self.rank[y] += 1
    def numDisjointSets(self):
        return self.numSets
    def sizeOfSet(self, i):
        return self.setSize[self.findSet(i)]

n, m = [int(i) for i in input().split()]
uf = UnionFind(n)
for i in range(m):
    a, b = [int(i)-1 for i in input().split()]
    uf.unionSet(a,b)
ans = 0
for i in range(n):
    ans = max(ans, uf.sizeOfSet(i))
print(ans)

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

int main(){

    int N, L;
    cin >> N >> L;
    map<string, int> dict;
    for (int i=0; i<N; i++){
        string buf;
        cin >> buf;
        dict[buf]++;
    }

    string ans = "";
    for (auto p: dict){
        auto key = p.first;
        auto value = p.second;
        ans += key;

        if (value != 1){
            for (int i=1; i<value; i++) ans += key;
        }
    }

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

Measured memory_bytes: 256
import java.util.*;

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

		int[] point = new int[5];
		
		int sum = 0;
		
		for(int i = 0; i < 5; i++) {
			point[i] = sc.nextInt();
			if(point[i] < 40) {
				point[i] = 40;
			}
			
			sum+=point[i];
		}
		
		int avg = sum / 5;
		
		System.out.println(avg);
	}
}

Measured memory_bytes: 26256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    int b=0;
    int c=1000;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    REP(i,n){
        b=max(a[i],b);
        c=min(a[i],c);
    }
    cout<<b-c;
    return 0;
}


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

int n;

int solve(){
	int ans = 0;
	while(n != 1){
		ans++;
		if(n%2){
			n *= 3;
			n++;
		}else
			n/=2;
	}
	return ans;
}

int main(){
	while(true){
		cin >> n;
		if(!n)
			return 0;
		cout << solve() << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
#define MOD 1000000007
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> l(n);
    rep(i,0,n)cin>>l[i];
    ll ans=0;
    sort(l.begin(),l.end());
    rep(i,0,n-2){
        rep(j,i+1,n-1){
            int sum=l[i]+l[j];
            rep(k,j+1,n){
                if(sum>l[k])ans++;
                else break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	string s;
	int k;
	cin>>k>>s;
	if(s.length()<=k)cout<<s;
	else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"...";
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

typedef double T;
typedef pair<int, int> P;

typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<T> VT; 
typedef vector<VT> VVT;
typedef vector<P> VP;

const ll MOD = 1e9+7;
const T EPS = 1e-7;

int main() {
    int n; 
    cin >> n;
    VI a(n);
    VL p(n+1, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        p[i+1] = p[i] + a[i];
    }

    ll ans = 0;
    int j = 0;
    ll cur = 0; 
    for (int i = 0; i < n; ++i) {
        cur = cur^a[i];
        while (cur != p[i+1] - p[j]) {
            ans += i-j;
            cur = cur^a[j];
            ++j;
        }
    }
    while (j != n)
        ans += n-(j++);
    cout << ans << "\n";
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstring> 
using namespace std;
typedef long long ll;
ll n, m, c[22], dp[50100];
const ll INF = 1000000000000000000;
int main(void){
    // Your code here!
    cin >> n >> m;
    for (ll i = 0; i <= n; i++) dp[i] = INF;
    dp[0] = 0;
    for (ll i = 0; i < m; i++) cin >> c[i];
    for (ll i = 1; i <= n; i++) {
        for (ll j = 0; j < m; j++) {
            if (c[j] > i) continue;
            dp[i] = min(dp[i], dp[i - c[j]] + 1);
        }
    }
    cout << dp[n] << endl;
}



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

using namespace std;

const int MAX_N = 10005;
const int INFTY = 1001001001;
typedef pair<int, int> P;

vector< vector< P > > adj(MAX_N);
vector<int> state(MAX_N, 0);
vector<int> dist(MAX_N, INFTY);
int n;

void djkstra(int node)
{
    priority_queue< P, vector<P>, greater<P> > Q;
    Q.push(P(0, node));
    dist[node] = 0;
    int v;

    while(!Q.empty()){
        P p = Q.top();
        Q.pop();
        node = p.second;

        state[node] = 1;

        //if(dist[node] < p.first) continue;

        for(int j=0;j<adj[node].size();++j){
            // node → jのコスト
            v = adj[node][j].first;
            if(state[v]) continue;
            if(dist[v] > dist[node] + adj[node][j].second){
                dist[v] = dist[node] + adj[node][j].second;
                Q.push(P(dist[v], v));
            }
        }
    }

    for(int i=0;i<n;++i){
        dist[i] = dist[i] == INFTY ? -1 : dist[i];
    }
}

int main()
{
    int u, k, v, c;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> u >> k;
        for(int j=0;j<k;++j){
            cin >> v >> c;
            adj[u].push_back(P(v, c));
        }
    }

    int node = 0;
    djkstra(node);
    for(int i=0;i<n;++i){
        cout << i << " " << dist[i] << endl;
    }
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define long long long
#define ull unsigned long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define upadj(i,adj) if (adj.size()>0) up(i,0,adj.size()-1)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define V vector
#define debug(X) cerr<< #X << "=" <<X << endl
#define debug2(X,Y)  cerr<< #X << "=" <<X << ", " << #Y << "=" <<Y << endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
const int N= 510;
int m,n,d;
void input()
{
    cin>>m>>n>>d;
}

void solve()
{
    up(i,1,m)
     {
     up(j,1,n)
     {
         int x= i-j+ 2*d*1000, y= i+j;
         if ((x/d)%2==0)
         {
            if ((y/d)%2==0) cout<<'R';
            else cout<<'B';
         }
         else
         {
            if ((y/d)%2==0) cout<<'Y';
            else cout<<'G';
         }
     };
     cout<<endl;
     }
}

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

    #ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
    #endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MAXN 2500
#define MAXM 5000
#define DEBUG true

struct Edge {
    int from, to, weight;
    Edge() {}
    Edge(int _from, int _to, int _weight): from(_from), to(_to), weight(_weight) {}
};

int N, M, P, dist[MAXN + 3];
bool visited[MAXN + 3];
Edge edges[MAXM + 3];
vector<int> adj[MAXN + 3];

bool checkReachability(int u, int target) {
    visited[u] = true;

    if (u == target)
        return true;

    bool result = false;
    for (auto v: adj[u]) {
        if (!visited[v])
            result |= checkReachability(v, target);
    }

    return result;
}

bool isReachable(int u, int v) {
    memset(visited, false, sizeof(visited));
    return checkReachability(u, v);
}

int main() {
    cin >> N >> M >> P;
    for (int i = 1; i <= M; i++) {
        int a, b, c;
        cin >> a >> b >> c;

        edges[i] = Edge(a, b, -(c - P));
        adj[a].push_back(b);
    }

    //Implement Bellman-Ford algorithm
    for (int i = 1; i <= N; i++)
        dist[i] = INF;

    dist[1] = 0;
    for (int rep = 1; rep < N; rep++) {
        for (int e = 1; e <= M; e++) {
            int u = edges[e].from, v = edges[e].to, w = edges[e].weight;
            if (dist[v] > dist[u] + w)
                dist[v] = dist[u] + w;
        }
    }

    //Check if there is negative cycle in path from 1 to N
    bool negativeCycleExist = false;
    for (int e = 1; e <= M; e++) {
        int u = edges[e].from, v = edges[e].to, w = edges[e].weight;
        if (dist[v] > dist[u] + w && isReachable(1, u) && isReachable(v, N)) {
            negativeCycleExist = true;
        }
    }

    if (negativeCycleExist)
        cout << -1 << endl;
    else
        cout << max(-dist[N], 0) << endl;
}


Measured memory_bytes: 512
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N, T;
  sc.scan(N, T);
  int[] c = new int[N];
  int[] t = new int[N];

  foreach (i; 0 .. N)
    sc.scan(c[i], t[i]);

  int minCost = c[0];
  int minT = t[0];

  foreach (i; 1 .. N) {
    if (t[i] <= T) {
      if (minCost > c[i]) {
        minCost = c[i];
        minT = t[i];
      }
    }
  }

  if (minT > T)
    writeln("TLE");
  else
    writeln(minCost);
}


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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int):
    if str(N)[0] == "7" or str(N)[1] == "7" or str(N)[2] == "7":
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
t=d=m = 0
gets.to_i.times {
  a = gets.split.map &:to_i
  a[t] -= d
  s,t = [0,1,2].sort_by{|i| a[i]+m}.pop 2
  m += a[t]
  d = a[t]-a[s]
}  
p m

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

int main()
{
    string s;
    cin >> s;
    int len = s.size();

    //a~zまでを検証
    int ans = 1000;
    for (int alfa = 0; alfa < 26; alfa++)
    {
        int i, j;
        string buf = "", ss = s;
        for (i = 0; i < len; i++)
        {
            for (j = 0; j < ss.size(); j++)
            {
                if(ss[j] != 'a' + alfa)break;
            }
            if(j == ss.size())break;
            for (j = 0; j < ss.size() - 1; j++)
            {
                if(ss[j] == 'a' + alfa || ss[j + 1] == 'a' + alfa)buf += 'a' + alfa;
                else buf += ss[j];
            }
            ss = buf;
            buf = "";
        }
        ans = min(ans, i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	ll x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	ll p[100010],q[100010],r[100010];
	FOR(i,a){
		cin >> p[i];
	}
	sort(p,p+a);
	reverse(p,p+a);

	FOR(i,b){
		cin >> q[i];
	}
	sort(q,q+b);
	reverse(q,q+b);

	FOR(i,c){
		cin >> r[i];
	}
	sort(r,r+c);
	reverse(r,r+c);

	priority_queue<int, vector<int>, greater<int>> v,vv; 
	FOR(i,x){
		v.push(p[i]);
	}
	FOR(i,y){
		vv.push(q[i]);
	}

	
	FOR(i,c){
		if(r[i]-v.top()<0 && r[i]-vv.top()<0)break;
		if(r[i]-v.top()>r[i]-vv.top()){
			v.pop();
			v.push(r[i]);
			continue;
		}else{
			vv.pop();
			vv.push(r[i]);
		}

	}

	ll sum=0;

	while(!v.empty()){
		sum+=v.top();
		v.pop();
	}

	while(!vv.empty()){
		sum+=vv.top();
		vv.pop();
	}

	cout<< sum << endl;

}

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

int n;
int abc[3];
int l[8];
int c[6][3] = {{0,1,2},{1,0,2},{1,2,0},{0,2,1},{2,0,1},{2,1,0}};
const int INF = 1e9;
int ans = INF;
void f(int i,int A, int B, int C, int AC, int BC, int CC) {
  if(i == n) {
    if(AC == -1 || BC == -1 || CC == -1) return;
    //  cout <<"A = "<<A<<"B = "<<B<<"C = "<<C<<endl;
   
    for(int j = 0; j < 6; j++) {
      int tmp = 0;
      tmp += abs(A - abc[c[j][0]]) + AC * 10;
      tmp += abs(B - abc[c[j][1]]) + BC * 10;
      tmp += abs(C - abc[c[j][2]]) + CC * 10;
        ans = min(ans,tmp);
    }
  
    return;
  }

  f(i+1,A+l[i],B,C,AC+1,BC,CC);
  f(i+1,A,B+l[i],C,AC,BC+1,CC);
  f(i+1,A,B,C+l[i],AC,BC,CC+1);
  f(i+1,A,B,C,AC,BC,CC);
  return;
}


int main() {
  cin >> n;
  for(int i = 0; i < 3; i++) cin >> abc[i];
  for(int i = 0; i < n; i++) cin >> l[i];

  f(0,0,0,0,-1,-1,-1);
  cout << ans << endl;
}

  
  
  


Measured memory_bytes: 256
import java.util.*;

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

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();

		int[] spots = new int[N + 2];
		spots[0] = spots[N + 1] = 0;
		long baseCost = 0;
		for (int i = 1; i <= N; i++) {
			spots[i] = sc.nextInt();
			baseCost += Math.abs(spots[i] - spots[i - 1]);
		}
		baseCost += Math.abs(spots[N]);

		for (int i = 1; i <= N; i++) {
			long delta = Math.abs(spots[i - 1] - spots[i + 1]) 
					- Math.abs(spots[i - 1] - spots[i])
					- Math.abs(spots[i] - spots[i + 1]);
			System.out.println(baseCost + delta);
		}
		sc.close();

	}

}

Measured memory_bytes: 66096
#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <unordered_set>
#include <deque>
#include <queue>
#include <iomanip>
#include <fstream>
#include <string>
#include <climits>
#include <sstream>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define vi vector<ll>
#define pii pair<int, int>
#define fi(n) for(ll i = 0; i < (n); i++)
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define RFOR(i, k, n) for(int i = (k); i >= (n); i--)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define umin(a, b) a = min(a, b)
#define umax(a, b) a = max((ll)a, (ll)b)

//const long long LINF = LLONG_MAX;
//const long long LINF = 1e14;
const int INF = 1e9 + 1;

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int k;
	cin >> k;
	vector<pair<char, int>> os(s.length());
	fi(s.length())
		os[i] = { s[i], i };
	sort(all(os));
	set<string> ss;
	char lc = '1';
	for (auto e : os)
	{
		if (ss.size() >= k && lc != e.first)
			break;
		string s1 = "";
		for (int i = e.second; i < s.length(); i++)
		{
			s1 += s[i];
			if (!ss.empty() && ss.size() >= k && s1 >= *ss.rbegin())
				break;
			ss.insert(s1);
		}
		while (ss.size() > k)
			ss.erase(*ss.rbegin());
		lc = e.first;
	}
	cout << *ss.rbegin() << endl;
	return 0;
}

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

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = -1e18;
    ans = max(ans, a*c);
    ans = max(ans, b*c);
    ans = max(ans, a*d);
    ans = max(ans, b*d);
    cout << ans << endl;
    return 0;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
// clang-format on
/* }}} */


signed main() 
{
  int x=in();
  int y=in();
  if(x%y==0) print(-1);
  else print(x);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  char c; cin >> c;
  if (c=='a' || c=='i' || c=='u' || c=='e' || c=='o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}


Measured memory_bytes: 256
import collections
N = int(input())
li = list(map(int, input().split()))
cnLi = collections.Counter(li)
CcnLi = [n*(n-1)//2 for n in cnLi.values()]
sumC = sum(CcnLi)
for k in range(N):
    print(sumC-cnLi[li[k]] + 1)

Measured memory_bytes: 90444
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000

//🔴

int prim(int v, vector<vector<pair<int, int> > > adjlist){

    priority_queue<pair<int, int> >  wait;    // first := 候補辺のコスト   second　:= 行先ノード
    vector<int> result(v, INF);               // 頂点iと木の間の最小コスト
    int ans = 0, size = 0;                    // 木のコスト　頂点数

    //初期条件
    result[0] = 0;
    wait.push(make_pair(0, 0));

    while(!wait.empty() && size < v){

        //候補辺のうち最小のものを取り出す
        int newpoint = wait.top().second;
        int newcost = -wait.top().first;
        wait.pop();

        if(result[newpoint] < newcost) continue;

        //出てきた頂点を木に追加
        ans += newcost;
        result[newpoint] = -INF;
        size++;

        // 新しい点から出ている辺をすべてなめる
        for(int i = 0; i < adjlist[newpoint].size(); i++){
            int nextpoint = adjlist[newpoint][i].second;
            int nextcost = adjlist[newpoint][i].first;
            //より木に近くなった頂点があれば,　そこへの枝をqueueに追加
            if(result[nextpoint] > nextcost){
                result[nextpoint] = nextcost;
                wait.push(make_pair(-nextcost, nextpoint));
            }
        }
    }

    return ans;
}


int main(){

    int V, E; cin >> V >> E;                          // V:= 頂点の数    E:= 辺の数 
    vector<vector<pair<int, int> > > adjlist(V);      //first := コスト　second := 行先

    //入力
    for(int i = 0; i < E; i++){
        int a, b, c; cin >> a >> b >> c;              // a ,b 間に コスト c の辺がある
        adjlist[a].push_back(make_pair(c, b));
        adjlist[b].push_back(make_pair(c, a));      
    }

    int ans = prim(V, adjlist);

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


Measured memory_bytes: 7772
#include <bits/stdc++.h>
using namespace std;
int main (){
	string a,b,c;
	cin>>a>>b>>c;
	if((a[a.length()-1]==b[0])&&(b[b.length()-1]==c[0]))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N, Y;
    cin >> N >> Y;

    int i, j, k;

    for (i = 0; i <= N; i++) {
        for (j = 0; j <= N - i; j++) {
            k = N - i - j;
            if (10000 * i + 5000 * j + 1000 * k == Y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;

}

Measured memory_bytes: 256
fn main() {
    let n: usize = readln();
    let a: Vec<i64> = readln();
    let mut first = None;
    let mut second = None;
    let mut ans = 1;
    for &x in &a {
        if let Some(f) = first {
            if let Some(s) = second {
                if (f <= s && s <= x) || (f >= s && s >= x) {
                    second = Some(x);
                } else {
                    ans += 1;
                    second = None;
                    first = Some(x);
                }
            } else {
                second = Some(x);
            }
        } else {
            first = Some(x);
        }
    }
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 6396
function main(input) {
  const args = input.split(' ').map(n => parseInt(n, 10));
  const x1 = args[0],
        y1 = args[1],
    	x2 = args[2],
        y2 = args[3],
        aoc_x = x2 - x1,
        aoc_y = y2 - y1;
  
  let x3, y3, x4, y4;
  
  x3 = x2 - (aoc_y);
  x4 = x3 - (aoc_x);
  y3 = y2 + (aoc_x);
  y4 = y3 - (aoc_y);
  
  let ans = x3 + ' ' + y3 + ' ' + x4 + ' ' + y4
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29816
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var min = int.MaxValue;
        for (int i = 2; i < s.Length; i++)
        {
            var n = int.Parse(s.Substring(i - 2, 3));
            min = Math.Min(min, Math.Abs(753 - n));
        }
        Console.WriteLine(min);
    }
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool bl = false;
  while (a > 0 && c > 0) {
    c = c - b;
    if (c <= 0) bl = true;
    a = a - d;
  }

  if (bl) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (mut a, mut b, mut c) = (v[0], v[1], v[2]);
    let mut ans = 0;
    while a % 2 != 1 && b % 2 != 1 && c % 2 != 1 {
        let half_a = a / 2;
        let half_b = b / 2;
        let half_c = c / 2;

        a = half_c + half_b;
        b = half_a + half_c;
        c = half_a + half_b;

        if a == b && b == c {
            println!("-1");
            return;
        }
        ans += 1;
    }
    println!("{:?}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define fori(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(n) fori(somethingStupid,1,(n))


using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

bool tests = false;


void solve(){
    int x, n; cin >> x >> n;
    vi a;
    rep(n){
        int temp; cin >> temp;
        a.push_back(temp);
    }
    int num = 0;
    while (true){
        auto it = find(all(a), x-num);
        if (it == a.end()){
            cout << x-num << endl;
            return;
        }
        it = find(all(a), x+num);
        if (it == a.end()){
            cout << x+num << endl;
            return;
        }
        num++;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    if (tests){
        cin >> t;
    }
    rep(t) solve();
    return 0;
}


Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))

trend = 0
cnt = 0
for i in range(1,n):
    if trend == 0:
        if a[i-1] == a[i]:
            pass
        elif a[i-1] < a[i]:
            trend = 1
        else:
            trend = -1
    elif trend == 1:
        if a[i-1] > a[i]:
            trend = 0
            cnt += 1
        else:
            pass
    else:
        if a[i-1] < a[i]:
            trend = 0
            cnt += 1
        else:
            pass

print(cnt+1)



Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define F first
#define S second
int N;
P H,D;
P C[22];
int K[22][22];
int dc[22];
int hc[22];
int deadK;

int getK(P a,P b){
  return (a.F - b.F)* (a.F - b.F) + (a.S - b.S)* (a.S - b.S);
}

int sumK(int a,int b){
  return a + b + 2*sqrt(a)*sqrt(b);
}

int solve(int id,int ky,int st){
  if( st == (1<<N)-1 ) return true;

  bool ret = true;
  int sum[22];
  for(int i=0;i<N;i++){
    if( st & (1<<i) ) continue;
    sum[i] = sumK(ky,K[id][i]);
    if( sum[i] >= dc[i] ) ret = false;
  }
  if( ret ){
    for(int i=0;i<N;i++){
      if( st & (1<<i) ) continue;
      if( sum[i] < dc[i] )
	if( solve(i,sum[i],st|(1<<i)) ) return true;
    }
  }
  return false;
}

int main(){
  while(1){
    cin >> N >> H.F >> H.S >> D.F >> D.S;
    if( !N && !H.F && !H.S && !D.F && !D.S ) break;
    for(int i=0;i<N;i++) cin >> C[i].F >> C[i].S;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
	K[i][j] = getK(C[i],C[j]);
    for(int i=0;i<N;i++){
      hc[i] = getK(C[i],H);
      dc[i] = getK(C[i],D);
    }
    bool res = true;
    for(int i=0;i<N;i++){
      if( hc[i] >= dc[i] ){
	res = false;
      }
    }
    if( res ) {
      res = false;
      for(int i=0;i<N;i++){
	if( hc[i] < dc[i] ){
	  if( solve(i,hc[i],(1<<i)) )  res = true;
	}
	if( res ) break;
      }
    }
    if( res ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 1152
def main():
    S = input()

    s = len(S)
    while s > 4:
        e = s
        for i in (5, 6, 7):
            s = e - i
            if S[s:e] in ('dream', 'dreamer', 'erase', 'eraser'):
                break
        else:
            print('NO')
            return
    print('YES')

main()


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

using namespace std;

int main(){
    
    int n;
    int flag=0;
    while(cin >> n && n)
    {
    	string str;
    	int a,b,c;
    	vector<string>list;
    	int num[1000]={};
    	int numberlist[1000]={};
    	int count=0;

    	while(n--)
    	{
    		cin >> str >> a >> b >> c;
    		num[count]=a*3+c;
    		numberlist[count]=count;
    		list.push_back(str);
    		count++;
    	}

    	for(int i=0;i<count;i++)
    	{
    		for(int j=i;j<count;j++)
    		{
    			if(num[i]<num[j])
    			{
    				swap(num[i],num[j]);
    				swap(list[i],list[j]);
    				swap(numberlist[i],numberlist[j]);
    			}
    		}
    	}
    	for(int i=0;i<count;i++)
    	{
    		for(int j=i;j<count;j++)
    		{
    			if( num[i]==num[j] && numberlist[i]>numberlist[j])
    			{
    				swap(num[i],num[j]);
    				swap(list[i],list[j]);
    				swap(numberlist[i],numberlist[j]);    			
    			}
    		}
    	}
    	if(flag)cout << endl;
    	for(int i=0;i<count;i++)
    	{
    		cout << list[i] << "," << num[i] << endl;
    	}
    	flag=1;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  char a[10];
  int b, c, f;
  int ret;

  f=0;//for(f=0; f<10; ++f)  
  do
  {
    c=getchar();
    if( c==EOF )
    {
      a[f] = '\0';      
      break;
    }
    if( c>='0' && c<='9')
    {
      a[f] = c;
      ++f;
    }
  } while( f<sizeof(a) );
  //printf("%s", a);
  b = atoi(a);
  //printf("%d", b);

  for(f=1; f<=10000; ++f) 
  {
    if( f*f == b )
    {
      printf("Yes\n");
      break;
    }
    if( f*f > b )
    {
      printf("No\n");
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int n,a,b,c,d,x,y;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	x=n/a;
	if(n%a!=0)	x=x+1;
	x=x*b;
	y=n/c;
	if(n%c!=0)	y=y+1;
	y=y*d;
	if(x<y)	printf("%d\n",x);
	else	printf("%d\n",y);
	return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


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

    string s;
    cin >> s;

    rep(i,n){
        if(i==k-1){
            s[i] = s[i] + 32;
        }
        cout << s[i];
    }
    
    cout << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
H,W = map(int,input().split())
masu = [list(input())for i in range(H)]
excludeC = []
excludeR = []
for i in range(H):
    if masu[i].count('.') == W:
        excludeR.append(i)

for i in range(W):
    isExclude = True
    for j in range(H):
      if masu[j][i] == '#':
            isExclude = False
            break
    if isExclude:
        excludeC.append(i)

for i in range(H):
    if i in excludeR:
        continue
    for j in range(W):
        if j in excludeC:
            continue
        print(masu[i][j],end='')
    print('')



Measured memory_bytes: 75136
#include <stdio.h>
#include <string.h>

int main(){

 char s[200];
 char p[200];
 char ss[200];

 scanf("%s",s);
 scanf("%s",p);
 strcat(ss,s);
 strcat(ss,s);

 if(strstr(ss,p))
  printf("Yes\n");
 else
  printf("No\n");

 return 0;
}

Measured memory_bytes: 532
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
--
local N = read.n()
local A = read.N(N)
A[N+1] = -9999
local m = 1000
local s = 0
local function buy(a)
    s = s + m // a
    m = m % a
end
local function sell(a)
    m = m + s * a
    s = 0
end
for i=1,N do
    if A[i+1] < A[i] then
        sell(A[i])
    elseif A[i+1] > A[i] then
        buy(A[i])
    end
end
print(m)

Measured memory_bytes: 2788
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007



void solver()
{
	ll n;
	cin>>n;
	
	v(ll) vec(n);
	m(ll,ll) oc;
	s(ll) s1;
	
	fe(x,vec)
	{
		cin>>x;
		s1.insert(x);
		oc[x]++;
	}
	
	ll ans=0;
	fe(x,s1)
	{
		ans += (oc[x]*(oc[x]-1))/2 ;
	}
	
	f(i,0,n-1)
	{
		ll x=vec[i];
		cout<< ans - (oc[x]*(oc[x]-1))/2  + ((oc[x]-1)*(oc[x]-2))/2 <<endl; 	
	}
		
}


signed main() 
{
	speed	
		
	ll q=1;	
	//cin>>q;	
	
	while(q--)	
	solver();	
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 17024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#define MOD 1000000007
#define pb push_back
using namespace std;

long long dp[110][100100];
long long prefix[110][100100];
long long a[3030];

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

	for (int i = 1; i <= n; i++) cin >> a[i];

	for (int i = 0; i <= n; i++) dp[i][0] = 1, prefix[i][0] = 1;
	for (int i = 0; i <= k; i++) prefix[0][i] = 1;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			if(j - a[i] - 1 >= 0) dp[i][j] = (dp[i][j] + (prefix[i - 1][j] + MOD - prefix[i - 1][j - a[i] - 1]) % MOD) % MOD;
			else dp[i][j] = (dp[i][j] + prefix[i - 1][j]) % MOD;
			prefix[i][j] = (prefix[i][j - 1] + dp[i][j]) % MOD;
		}
	}

	//for (int i = 0; i <= n; i++) {
	//	for (int j = 1; j <= k; j++) cout << dp[i][j] << " ";
	//	cout << endl;
	//}
	//cout << endl;

	//for (int i = 0; i <= n; i++) {
	//	for (int j = 1; j <= k; j++) cout << prefix[i][j] << " ";
	//	cout << endl;
	//}

	//cout << endl;
	cout << dp[n][k];
	return 0;
}

Measured memory_bytes: 160000