akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/4;
    public static final int inf = Integer.MAX_VALUE/4;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni(), Q = in.ni();
        long[][] map = new long[n][n];
        int l, r, p, q;
        for (int i = 0; i < m; i++) {
            l = in.ni()-1;
            r = in.ni()-1;
            map[l][r]++;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n-1; j++) {
                map[i][j+1] = map[i][j]+map[i][j+1];
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < Q; i++) {
            p = in.ni()-1;
            q = in.ni()-1;
            int ans = 0;
            for (int j = p; j <= q; j++) {
                ans += map[j][q];
            }
            sb.append(ans+"\n");
        }
        out.print(sb);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

long long calcGCD(long long x, long long y)
{
    if (x < y)
    {
        swap(x, y);
    }
    long long remainder = x % y;
    while (remainder != 0)
    {
        x = y;
        y = remainder;
        remainder = x % y;
    }
    return y;
}

long long calcMultiGCD(std::vector<long long> x)
{
    if (x.size() < 2)
    {
        if (x.size() == 1)
        {
            return x[0];
        }
        else
        {
            return 0;
        }
    }

    long long gcd = calcGCD(x[0], x[1]);
    for (long long i = 2; i < x.size(); i++)
    {
        gcd = calcGCD(gcd, x[i]);
    }
    return gcd;
}

long long calcLCM(long long x, long long y)
{
    if (x < y)
    {
        swap(x, y);
    }
    long long ret = x / calcGCD(x, y);
    return ret * y;
}

long long calcMultiLCM(std::vector<long long> x)
{
    if (x.size() < 2)
    {
        if (x.size() == 1)
        {
            return x[0];
        }
        else
        {
            return 0;
        }
    }

    long long lcm = calcLCM(x[0], x[1]);
    for (long long i = 2; i < x.size(); i++)
    {
        lcm = calcLCM(lcm, x[i]);
    }
    return lcm;
}

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

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

    cout << calcMultiLCM(T) << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n,0);
  int k;
  for (int i = 0; i < n; i++) {
    cin >> k;
    vec.at(i) += k;
  }
  int now = 1;
  for (int i = 0; i < n; i++) {
    if (now == 2) {
      cout << i << endl;
      break;
    }
    now = vec.at(now-1);
    if (i == n-1) {
      cout << -1 << endl;
    }
  }
}

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

#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())

int main() {
    int n;
    cin >> n;
    double ans;
    for (int i = 1; i <= n; ++i) {
        if ( i%2 == 1 ) {
            ans++;
        }
    }
    cout << ans/n << endl;
    return 0;
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
	NodePointer cur = nil->next;
	while(cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
	if(t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void delete(int key){
	deleteNode(listSearch(key));
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 32932
#include<cstdio>
#include<queue>
using namespace std;
const int maxn=200000,inf=0x3f3f3f3f;
int n,a[maxn+10];
struct mindata{
    int id,v;
    mindata(int id=0,int v=inf):
        id(id),v(v){}
};
mindata operator+(const mindata &a,const mindata &b){
    if(a.v<b.v) return mindata(a.id,a.v);
    else return mindata(b.id,b.v);
}
mindata c[maxn*5+10][3]; int sz;
void buildtree(){
    for(sz=1;sz<=n+1;sz<<=1);
    for(int i=sz+1;i<=sz+n;++i){
        scanf("%d",&a[i-sz]);
        for(int j=0;j<=1;++j) if(((i-sz)&1)==j)
            c[i][j]=mindata(i-sz,a[i-sz]);
        else c[i][j]=mindata();
        c[i][2]=mindata(i-sz,a[i-sz]);
    }
    for(int i=sz-1;i;--i)
        for(int j=0;j<=2;++j)
            c[i][j]=c[i<<1][j]+c[i<<1|1][j];
}
mindata query(int l,int r,int d){
    mindata ans;
    for(l+=sz-1,r+=sz+1;l^r^1;l>>=1,r>>=1){
        if(~l&1) ans=ans+c[l^1][d];
        if(r&1) ans=ans+c[r^1][d];
    }
    return ans;
}
struct heapnode{
    int l,r,x,y;
    heapnode(int l,int r):
        l(l),r(r){
            mindata v=query(l,r-1,l&1);
            x=v.id; y=query(v.id+1,r,~v.id&1).id;
        }
    bool operator<(const heapnode &t)const{
        if(a[x]!=a[t.x]) return a[x]>a[t.x];
        return a[y]>a[t.y];
    }
};
priority_queue<heapnode> heap;
int main(){
    scanf("%d",&n); buildtree();
    heap.push(heapnode(1,n));
    for(int i=1;i<=n>>1;++i){
        heapnode x=heap.top(); heap.pop();
        printf("%d %d ",a[x.x],a[x.y]);
        if(x.l<x.x) heap.push(heapnode(x.l,x.x-1));
        if(x.x<x.y-1) heap.push(heapnode(x.x+1,x.y-1));
        if(x.y<x.r) heap.push(heapnode(x.y+1,x.r));
    }
    return 0;
}

Measured memory_bytes: 26484
function main() {
  var
  romanTable = {
    'I': 1,
    'V': 5,
    'X': 10,
    'L': 50,
    'C': 100,
    'D': 500,
    'M': 1000,
  };
  function roman(str) {
    var
    i, c,
    res = 0,
    len = str.length,
    back = Infinity;
    for(i = 0; i < len; i++) {
      c = str.charAt(i);
      res += romanTable[c];
      if(romanTable[c] > back) {
        res -= back*2;
      }
      back = romanTable[c];
    }
    return res;
  }
  
  input.forEach(function(line) {
    if(line.trim() === '') return;
    console.log(roman(line.trim()));
  });
  
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 7912
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>















const int N=310;
ll n,u,v,w,d[N][N];
ll res;
vector<pair<int,pair<int,int>>>e;









void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)cin>>w;
		for(int j=i+1;j<=n;j++)
		{
			cin>>w;
			e.pb(mp(w,mp(i,j)));
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			d[i][j]=-1;
		}
		d[i][i]=0;
	}
	sort(e.begin(),e.end());
	res=0;
	for(int i=0;i<e.size();i++)
	{
		w=e[i].first;
		u=e[i].second.first;
		v=e[i].second.second;
		if(d[u][v]==-1||d[u][v]>w)
		{
			d[u][v]=w;
			d[v][u]=w;
			for(int j=1;j<=n;j++)
			{
				for(int k=1;k<=n;k++)
				{
					if(d[j][u]!=-1&&d[k][v]!=-1)
					{
						if(d[j][k]==-1||d[j][u]+d[k][v]+w<d[j][k])
						{
							d[j][k]=d[j][u]+d[k][v]+w;
						}
					}
					if(d[j][v]!=-1&&d[k][u]!=-1)
					{
						if(d[j][k]==-1||d[j][v]+d[k][u]+w<d[j][k])
						{
							d[j][k]=d[j][v]+d[k][u]+w;
						}
					}
				}
			}
			res+=w;
		}
		else if(d[u][v]<w)
		{
			cout<<"-1\n";
			return;
		}
	}
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 1656
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;


int main() {
	speed;
	ll L, R;
	cin >> L >> R;
	int ans = 2018;
	ffor(i, L, R) {
		ffor(j, (L + 1), (R + 1)) {
			int sum = i * j % 2019;
			ans = min(ans, sum);
			if (ans == 0)break;
		}
		if (ans == 0)break;
	}
	cout << ans;
	ed;
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define rep(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
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; }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
inline double comb(int n, int r) {if (n == 0) { return 0; }if (r == 0) { return 1; }if (r == 1) { return n; }if (n == r) { return 1; }if (r > n / 2) { r = n / 2; }double result = 1;for (double i = 1; i <= r; i++) {result *= (n - i + 1) / i;}return(result);}
vector<pair<long long, long long> > prime_factorize(long long n) {vector<pair<long long, long long> > res;for (long long p = 2; p * p <= n; ++p) {if (n % p != 0) continue;int num = 0;while (n % p == 0) { ++num; n /= p; }res.push_back(make_pair(p, num));}if (n != 1) res.push_back(make_pair(n, 1));return res;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(15);
   int N;
   cin >> N;
   if(N <1200){
       cout << "ABC" << endl;
   }
   else if (N<2800){
       cout << "ARC" << endl;
   }
   else{
       cout << "AGC" << endl;
   }
}



Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>

using namespace std;

long long str_to_int(string str){
  long long ret=0;
  for(int i=0;i<str.length();i++){
    ret *= 10;
    ret += str[i] - '0';
  }
  return ret;
}

int main(){
  stack<long long> s;
  string tmp;
  while(cin >> tmp){
    if(tmp == "+"){
      long long sm=0;
      sm += s.top();s.pop();
      sm += s.top();s.pop();
      s.push(sm);
    }
    else if(tmp == "-"){
      long long sm=0;
      sm -= s.top();s.pop();
      sm += s.top();s.pop();
      s.push(sm);
    }
    else if(tmp == "*"){
      long long mu=1;
      mu *= s.top();s.pop();
      mu *= s.top();s.pop();
      s.push(mu);
    }
    else{
      s.push(str_to_int(tmp));
    }
  }
  cout << s.top() << endl;
}



Measured memory_bytes: 3172
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
   int k,x;
   cin >> k >> x;
   if(500 * k >= x){
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;

signed main(){
    int n,m; cin>>n>>m;
    vector<P> ba(m);
    rep(i,m) cin>>ba.at(i).S>>ba.at(i).F;
    sort(all(ba));
    int bri=-1,ans=0;
    rep(i,m){
        if(ba.at(i).S>bri){
            ans++;
            bri=ba.at(i).F-1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void){
	std::ios_base::sync_with_stdio();

	string inp;
	int As,Bs;

	while(1){
		cin>>inp;
		if(inp=="0") break;
		As=0,Bs=0;
		for(int i=1;i<inp.length();i++){
			if(inp[i]=='A') As++;
			else Bs++;
		}
		if(max(As,Bs)==As) As++;
		else Bs++;
		cout<<As<<" "<<Bs<<endl;
	}

	return 0;
}

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

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> v(N), w(N);
  for (int i = 0; i < N; ++i)
    cin >> v[i] >> w[i];
  vector<vector<int>> dp(N + 1, vector<int>(W + 1));
  for (int i = 0; i < N; ++i) {
    for (int sum_w = 0; sum_w <= W; ++sum_w) {
      if (sum_w - w[i] >= 0)
        dp[i + 1][sum_w] = max(dp[i][sum_w - w[i]] + v[i], dp[i + 1][sum_w]);
      dp[i + 1][sum_w] = max(dp[i][sum_w], dp[i + 1][sum_w]);
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 6772
#include <stdio.h>

int main(void){
  int n,a;
  int rect1,rect2;
  scanf("%d",&n);
  scanf("%d",&a);

  rect1 = n*n;

  if(a>rect1){
    rect2=0;
  }else{
    rect2 = rect1 -a;
  }

  printf("%d",rect2);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>

using namespace std;

bool is_prime(int n){
	for(int i=2; i<(int)sqrt(n); i++){
    	if(n%i == 0){
        	return false;
        }
    }
  	return true;
}

int main(){
  int n;
  cin >> n;
  int i = n;
  while(!is_prime(i)){
    i++;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(a+b,max(a-b, a*b));
}

Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN));
  $s = explode(" ",trim(fgets(STDIN)));
  $kind = [];
  for($i=0; $i<$n; $i++){
    $kind[] = $s[$i];
  }
  $k = count(array_unique($kind));
  if($k==3){
    echo "Three\n";
  }else{
    echo "Four\n";
  }

Measured memory_bytes: 4732
n = gets.to_i

a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

ans = b[a[0] - 1]

ans += (1...n).inject(0) do |r, i|
  if a[i] == a[i - 1] + 1
    r + b[a[i] - 1] + c[a[i] - 1 - 1]
  else
    r + b[a[i] - 1]
  end
end

puts ans

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

using namespace std;

typedef long long LL;

int N;
int v[405];
LL dp[405][405];
LL sz[405][405];

int main()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
    {
        cin >> v[i];
        sz[i][i] = v[i];
        for(int j = i - 1; j >= 1; j--)
            sz[j][i] = sz[j + 1][i] + v[j];
    }

    for(int l = 2; l <= N; l++)
        for(int st = 1, dr = l; dr <= N; st++, dr++)
        {
            dp[st][dr] = 1LL << 60;
            for(int mij = st; mij < dr; mij++)
                dp[st][dr] = min(dp[st][dr], dp[st][mij] + dp[mij + 1][dr] + sz[st][dr]);
        }

    cout << dp[1][N] << '\n';

    exit(0);
}

Measured memory_bytes: 2816
/*
 ALLAH is Almighty....
*/
#include <bits/stdc++.h>

#define ll  long long
using namespace std;

const ll mx = 10e5 + 9;
ll n, k, weight;
ll w[ mx ], v[ mx ];
ll dp[ 101 ][ mx ];

ll calculation( ll item, ll need )
{
    if ( dp[ item ][ need ] != -1 )
        return dp[ item ][ need ];

    if ( item == n )
        return 0;

    ll t1, t2;
    t1 = t2 = 0;
    if ( need - w[ item ] >= 0 )
        t1 = v[ item ] + calculation( item + 1, need - w[ item ] );
    t2 = calculation( item + 1, need );

    return dp[ item ][ need ] = max( t1, t2 );
}

void solve( )
{
    cin >> n >> weight;
    for ( ll i = 0; i < n; ++i )
        cin >> w[ i ] >> v[ i ];

    for ( ll i = 0; i < 101; ++i )
        for ( ll j = 0; j < mx; ++j )
            dp[ i ][ j ] = -1;

    cout << calculation( 0, weight ) << "\n";
}

int main()         // Md. Inzamam-ul Haque
{
    solve();
}



Measured memory_bytes: 792648
#include <stdio.h>
#define N 10000
#define Q 500

main(){
  int n, q, c, i, j;
  int s[N], t[Q];

  scanf("%d", &n);

  for( i = 0; i < n; i++){
    scanf("%d", &s[i]);
  }

  scanf("%d", &q);

  for( j = 0; j < q; j++){
  scanf("%d", &t[j]);
  }

  c = 0;
  for( i = 0; i < q; i++){
    for( j = 0; j < n; j++){
      if( s[j] == t[i] ){
	c++;
	break;
      }
    }
  }

  printf("%d\n", c);

  return 0;

}

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

max_val = abs(a[0] - a[1])
for i in range(len(a)):
    for j in range(i, len(a)):
        if abs(a[i] - a[j]) > max_val:
            max_val = abs(a[i] - a[j])
print(max_val)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int Mod=998244353,N=2e5+5;
const int INF=0x3f3f3f3f;
LL f[N],a[20],b[20],c[20];
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;++i){
		cin>>a[i]>>b[i]; 
	}
	f[1]=1;
	for(int i=2;i<=n;++i){
		for(int j=0;j<m;++j){
			c[j]+=(i-a[j]>=1 ? f[i-a[j]] : 0) - (i-b[j]-1>=1 ? f[i-b[j]-1] : 0);
			f[i]=(f[i]+c[j])%Mod;
		}
	}
	cout<<f[n]<<endl;
	return 0;
}


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

int main()
{
    map<ll,ll> counts;
    ll elsecount = 0;
    ll N;
    cin >> N;
    for(ll i = 0; i < N; i++)
    {
        ll tmp;
        cin >> tmp;
        if(tmp < 3200)counts[tmp/400]++;
        else elsecount++;
    }
    
    ll count = 0;
    for(auto e:counts)
    {
        count++;
    }

    if(elsecount == 0 && count != 0)
    {
        cout << count << ' ' << count << endl;
    }
    else if(elsecount != 0 && count == 0)
    {
        cout << 1 << ' ' << count + elsecount << endl;
    }
    else 
    {
        cout << count << ' ' << count + elsecount << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N, D = gets.split.map(&:to_i)
positions = N.times.map { gets.split.map(&:to_i) }

counter = 0
N.times do |i|
  ((i + 1)..(N - 1)).each do |j|
    sum = 0
    D.times do |index|
      sum += (positions[i][index] - positions[j][index]) ** 2
    end
    counter += 1 if (sum ** (1/2.0)).to_i ** 2 == sum
  end
end
puts counter

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

int main(){

    int n,a,b;
    cin >> n >> a >> b;

    cout << min(b,a*n)  << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		System.out.println(""+a.charAt(0)+ b.charAt(1) +c.charAt(2));
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void permutation(String q, String ans) { //Call permutation(String, "",) from outside
		if (q.length() <= 1)
			System.out.println(ans + q); //Fill in processing
		else
			for (int i = 0; i < q.length(); i++)
				permutation(q.substring(0, i) + q.substring(i + 1), ans + q.charAt(i));
	}

	public static void combination(String q, String ans, int k) { //Call combination(String, "", n) from outside (nCr)
		if (ans.length() == k)
			System.out.println(ans); //Fill in processing
		else
			while (q.length() > 0) {
				combination(q.substring(1), ans + q.charAt(0), k);
				q = q.substring(1);
			}
	}

	long combination(int n, int r, int m) { //nCr mod m
		long[][] Combination = new long[n + 1][n + 1];
		for (int i = 0; i <= n; i++) {
			Combination[i][0] = 1;
			for (int j = 1; j <= i; j++)
				Combination[i][j] = (Combination[i - 1][j - 1] + Combination[i - 1][j]) % m;
		}
		return Combination[n][r];
	}

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

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

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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int a,b;
int main() {
    cin >> a >> b;
    if(a>=13) cout << b << endl;
    else if(a>=6) cout << b/2<< endl;
    else cout << 0<< endl;

}

Measured memory_bytes: 256
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
xyc = [list(map(int,input().split())) for i in range(m)]

a_m = min(a)
b_m = min(b)
ans = a_m + b_m

for i in range(m):
    a_i = xyc[i][0] - 1
    b_i = xyc[i][1] - 1
    c_i = xyc[i][2]
    pri = a[a_i] + b[b_i] - c_i
    ans = min(ans,pri)

print(ans)
    

Measured memory_bytes: 38564
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		
		if(N % 2 == 0)
			System.out.println(N);
		else
			System.out.println(N*2);
	}
}


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


int main(void){
  int N,K;
  scanf("%d%d",&N, &K);

  int *h;

  h = calloc(N, sizeof(int));
  
  int i;
  
  for (i = 1; i <= N; i++) {
    scanf("%d", &h[i]);
  }
  int ans = 0;

  for (i = 1; i <= N; i++) {
    if (h[i] >= K) {
      ans++;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  ll n,m,c[10000]={};
  ll a[10000],b[10000];
  cin>>n>>m;
  for(ll i=1;i<=m;i++){
    cin>>a[i]>>b[i];
  }
  for(ll i=1;i<=m;i++){
    c[a[i]]++;
    c[b[i]]++;
  }
  for(ll i=1;i<=n;i++){
    cout<<c[i]<<"\n";
  }
  return(0);
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef unsigned int uint;

inline char nc(){
  static char buf[100000],*p1=buf,*p2=buf;
  return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline void read(int &x){
  char c=nc(),b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}

const int N=200005;
const uint seed=233333;
struct abcd{
  uint a,b;
  abcd(uint a=1,uint b=0):a(a),b(b) { }
  bool one() { return a==1 && b==0; }
  void add(abcd B){
    uint _a=a,_b=b;
    a=B.a*_a; b=B.a*_b+B.b;
  }
}T[N<<2];

inline void modify(int x,int l,int r,int ql,int qr,abcd t){
  if (ql<=l && r<=qr){
    T[x].add(t);
    return;
  }
  if (!T[x].one())
    T[x<<1].add(T[x]),T[x<<1|1].add(T[x]),T[x]=abcd();
  int mid=(l+r)>>1;
  if (ql<=mid) modify(x<<1,l,mid,ql,qr,t);
  if (qr>mid) modify(x<<1|1,mid+1,r,ql,qr,t);
}
uint Hash[N];
inline void query(int x,int l,int r){
  if (l==r){
    Hash[l]=T[x].b;
    return;
  }
  if (!T[x].one())
    T[x<<1].add(T[x]),T[x<<1|1].add(T[x]),T[x]=abcd();
  int mid=(l+r)>>1;
  query(x<<1,l,mid);
  query(x<<1|1,mid+1,r);
}

int n,K;

int main(){
  int T,l,r,x;
  read(n); read(K);
  read(T);
  while (T--){
    read(l); read(r); read(x);
    modify(1,1,n,l,r,abcd(seed,x));
  }
  query(1,1,n);
  uint h=0;
  for (int i=1;i<=K;i++) h=h*seed+i;
  int ans=0;
  for (int i=1;i<=n;i++)
    if (Hash[i]==h)
      ans++;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 9812
#bit全探索

n,m,x=map(int,input().split())
c=[]
a=[]
for i in range(n):
  l=list(map(int,input().split()))
  c.append(l[0])
  a.append(l[1:])

min_cost=float('inf')
for i in range(2**n):
  flag=True
  cost_total=0
  a_total=[0]*m
  for j in range(n):
    if (i>>j)&1:
      cost_total+=c[j]
      for k in range(m):
        a_total[k]+=a[j][k]
  for s in range(m):
    if a_total[s]<x:flag=False
  if flag:
    min_cost=min(min_cost,cost_total)
  
if min_cost==float('inf'):
  print(-1)
else:
  print(min_cost)

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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 int MAX = 2005;

vvl dp(MAX, vl(MAX, 0ll));

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

  int n;
  cin >> n;
  vl a(n);
  rep(i, 0, n) {
    cin >> a[i];
  }

  vpl p;
  rep(i, 0, n) {
    p.eb(a[i], i);
  }

  sort(All(p));
  reverse(All(p));

  rep(i, 0, n) {
    int pi = p[i].second;
    rep(l, 0, i+1) {
      int r = i - l;
      chmax(dp[i+1][l+1], dp[i][l]+(ll)(pi-l)*a[pi]); // 左におく
      chmax(dp[i+1][l], dp[i][l]+(ll)((n-r-1)-pi)*a[pi]); // 右におく
    }
  }

  ll ans = 0;
  rep(i, 0, n+1) chmax(ans, dp[n][i]);
  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 35204
#include <iostream>
#include <vector>
using namespace  std;
int main(){
    int N,K; cin>>N>>K;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin>>A[i];
    K--;
    N--;
    if(N%K) cout << N/K + 1 << endl;
    else cout << N/K << endl;
    return 0;
}

Measured memory_bytes: 640
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

ans = 0

tmp_max = 0
for i in range(N):
    if tmp_max > A[i]:
        ans += tmp_max - A[i]
    else:
        tmp_max = A[i]
print(ans)


Measured memory_bytes: 32920
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)







int main(){
	ll n, q;
	string s;
	cin >> n >> q >> s;
	vector<char> t(q), d(q);
	REP(i, q) {
		cin >> t[i] >> d[i];
	}

	ll l1 = -1, r1 = n;
	while (r1 - l1 > 1) {
		ll c = (l1 + r1) / 2;
		ll now = c;
		bool f = false;
		REP(i, q) {
			if (s[now] == t[i]) {
				if (d[i] == 'L') now--;
				else now++;
			}
			if (now >= n) break;
			if (now < 0) {
				f = true;
				break;
			}
		}
		((f) ? l1 : r1) = c;
	}

	ll l2 = -1, r2 = n;
	while (r2 - l2 > 1) {
		ll c = (l2 + r2) / 2;
		ll now = c;
		bool f = false;
		REP(i, q) {
			if (s[now] == t[i]) {
				if (d[i] == 'L') now--;
				else now++;
			}
			if (now < 0) break;
			if (now >= n) {
				f = true;
				break;
			}
		}
		((f) ? r2 : l2) = c;
	}
	cout << n - (r1 + (n - r2)) << endl;
}

Measured memory_bytes: 900
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

cnt = [0 for _ in range(100005)]
for i in range(N):
    cnt[A[i]] += 1

sumA = sum(A)

# print(sumA)

Q = int(input())
for _ in range(Q):
    b, c = map(int, input().split())
    
    if cnt[b]:
        sumA += (c-b)*cnt[b]
        cnt[c] += cnt[b]
        cnt[b] = 0
    print(sumA)


Measured memory_bytes: 21292
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC099
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> list = new List<string>();
            while (true)
            {
                string line = Console.ReadLine();
                if (line == null) break;
                list.Add(line);
            }


            List<int> aa = new List<int>();
            foreach (var item in list.Select((Value, Index) => new { Value, Index }))
            {
                if (item.Index!=0)
                {
                    var ss = item.Value.Split(' ');
                    foreach (var x in ss)
	                 {
		                aa.Add(int.Parse(x));
	                 }
                    
                }         
            }

            var linq = aa.OrderByDescending(z => z);
            int[] result = new int[2];
            result[0] = linq.First();
            result[1] = linq.Last();

            Console.WriteLine(result[0] - result[1]);
        }
    }
}


Measured memory_bytes: 11348
n = int(input())
A= list(map(int, input().split()))

mod = 10**9+7

class combinationmod():
  def __init__(self,MAX, mod):
    self.mod =mod
    self.fac=[0]*(MAX+1)
    self.finv=[0]*(MAX+1)
    self.inv=[0]*(MAX+1)
    self.fac[0]=self.fac[1]=1
    self.finv[0]=self.finv[1]=1
    self.inv[1]=1
    for i in range(2,MAX+1):
      self.fac[i] = self.fac[i-1]*i%self.mod
      self.inv[i] = (-self.inv[mod%i]*(mod//i))%self.mod
      self.finv[i] = self.finv[i-1]* self.inv[i] %self.mod

  def nCk(self,n,k):
    if n<k or n<0 or k<0:
      return 0
    return self.fac[n]*(self.finv[k]*self.finv[n-k]%self.mod)%self.mod
  
memo={}
for i, a in enumerate(A):
  if a in memo:
    L = memo[a]
    R = len(A) - i-1
    break
  else:
    memo[a] = i
    
c = combinationmod(n+1,mod)
for k in range(1,n+2):
  print((c.nCk(n+1,k) - c.nCk(L+R,k-1))%mod)


Measured memory_bytes: 29340
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X): 
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))

Measured memory_bytes: 38384
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>m>>n;
	vs in(100);
	rep(i,100)if(i<50)in[i]=string(100,'.');
	else in[i]=string(100,'#');
	
	n--;m--;
	int a=0,b=0;
	while(n){
		n--;
		in[a*2][b*2]='#';
		b++;
		if(b==50){
			b=0;
			a++;
		}
	}
	a=b=0;
	while(m){
		m--;
		in[100-1-a*2][b*2]='.';
		b++;
		if(b==50){
			b=0;
			a++;
		}
	}
	cout<<"100 100"<<endl;
	rep(i,100)cout<<in[i]<<endl;
}






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

int main() {
    int N;
    string str;

    map<string, int> gacha;

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

    cout << gacha.size() << endl;

    return 0;
}


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

int main() {
	int num, a[32] = {};
	
	for (int i = 0; i < 28; i++) {
		cin >> num;
		a[num] = 1;
	}
	for (int i = 1; i <= 30; i++) {
		if (!a[i])cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
import sys
input = sys.stdin.readline

"""
n-増大列、m-減少列まで　-> 長さ nm 以下であることを示す。帰納法。
(n+1)m + 1 項があるとする。(n+2増大 or m+1減少)の存在をいう。
A：左 nm 項 B：右 m+1 項
Aに1項加えると、(n+1,m+1)のどちらかができる。(n+1)-増大ができるとしてよい。
Bの各項 b に対して、bで終わる(n+1)-増大列が存在する。
Bの中に2-増大列があれば(n+2)増大列ができる。そうでなければBが(m+1)-減少列なのでよい

"""

N,A,B = map(int,input().split())

if A+B-1 > N:
    print(-1)
    exit()
if A*B < N:
    print(-1)
    exit()

# 減少列をA個並べる

if B == 1:
    size = [1] * A
else:
    q,r = divmod(N-A,B-1)
    if q < A:
        size = [B] * q + [1+r] + [1] * (A-q-1)
    else:
        size = [B] * A

answer = []
start = 1
for s in size:
    end = start + s
    answer += list(range(end-1, start-1, -1))
    start = end
print(*answer)

Measured memory_bytes: 23124
local mmi, mma = math.min, math.max

n = io.read("*n")
local curmax = 0
local curlen = 0
local t = {}
local function dump()
  for i = 1, n do
    io.write(string.char(t[i] + 96))
  end
  io.write("\n")
end

local function dfs()
  if curlen == n then
    dump()
  else
    curlen = curlen + 1
    local premax = curmax
    for i = 1, curmax + 1 do
      t[curlen] = i
      curmax = mma(i, premax)
      dfs()
      curmax = premax
    end
    curlen = curlen - 1
  end
end
dfs()


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


using namespace std;

int main(void) {
	int N;
	int odd = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if (A % 2) odd++;
	}
	if (odd % 2) cout << "NO" << endl;
	else cout << "YES" << endl;

	system("pause");
	return 0;
}


Measured memory_bytes: 504
n=int(input())

r=list(map(int,input().split()))
dic={}

for index,value in enumerate(r):
  dic[value]=index+1
  
#print(dic)
s=""
for v in range(n):
  s+=" "+str(dic[v+1])
  
if s[:1]==" ":
  s=s[1:]
print(s)

Measured memory_bytes: 19704
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();

  println!("{}", max(a + b, max(a * b, a - b)));
}



Measured memory_bytes: 4352
#include <iostream>
#include <vector>
using namespace std;
#define ll long long int

int main()
{
	int n;

	cin >> n;
	if (n % 1000 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 1000 - (n % 1000) << endl;
	}

	return 0;
}



Measured memory_bytes: 3596
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<deque>
using namespace std;
typedef long long ll;
ll n;
deque<int>x,y;
int t=2;
int main()
{
    scanf("%lld",&n);
    n++;
    int cnt=0;
    int f=0;
    while(1ll<<(f+1)<=n)
        f++;
    for(int i=f-1;i>=0;i--){
            t++;
            cnt+=2;
            x.push_front(t);
            y.push_front(t);
        if(n&1ll<<i){
            t++;
            cnt+=2;
            x.push_front(t);
            y.push_back(t);
        }
    }
    printf("%d\n",cnt);
    while(!x.empty()){
        printf("%d ",x.front());
        x.pop_front();
    }
    while(!y.empty()){
        printf("%d ",y.front());
        y.pop_front();
    }
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    while(1){
        int H,W;
        cin>>H>>W;
        if(H==0&&W==0) break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout<<'#';
            }
            cout<<endl;
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3092
#include<stdio.h>
int main(void)
{
	int h,m,s,S;
	scanf("%d",&S);

	h=S/3600;
	m=S%3600/60;
	s=S%3600%60;

	printf("%d:%d:%d\n",h,m,s);

	return 0;
}



Measured memory_bytes: 2080
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, x;
  scanf("%d", &n);
  map<int, int> A;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    A[x]++;
  }
  int ret = 0, cnt = 0;
  for (auto& it : A) {
    if (it.second > 2) {
      ret += (it.second - 1) / 2;
      it.second = (it.second - 1) % 2 + 1;
    }
    if (it.second > 1) ++cnt;
  }
  ret += (cnt + 1) / 2;
  printf("%d\n", n - 2 * ret);
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "0" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll n,m,d; cin>>n>>m>>d;
    ld ans;
    if(d==0){
        ans=(ld)1*(m-1)/n;
    }
    else{
        ans=(ld)2*(n-d)*(m-1)/n/n;
    }
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	lli n,x,t;
	cin>>n>>x>>t;
	if(n%x==0)	
		cout<<t*(n/x);
	else
		cout<<t*(n/x+1);
	return 0;
}


Measured memory_bytes: 3576
import Data.List
import Control.Monad
import Debug.Trace

main :: IO ()
main = do
  [n,_] <- map read.words <$> getLine
  xs <- replicateM n $ do
    (_:ls) <- map read.words <$> getLine
    return ls
  if n == 1 then print $ length $ head xs
  else print $ length $ foldl1' intersect (xs :: [[Int]])


Measured memory_bytes: 1148
n = gets.to_i
min = last = gets.to_i
profits = []
(n-1).times{
  current = gets.to_i
  profits<<(current-last) if (profits.bsearch{|i| i >= 0} == nil)
  profits<<(current-min) if (current > last)
  min = current if (current < min)
  last = current
}
puts profits.max

Measured memory_bytes: 9708
// Problem : B - Mix Juice
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	vi a(n);
	REP(i, n) cin >> a[i];
	int sum = 0;
	sort(a.begin(), a.end());
	REP(i, k) sum += a[i];
	cout << sum;
	return 0;
}
 


Measured memory_bytes: 3676
#include "bits/stdc++.h"
using namespace std;
int Array[200005];

int main(){
    int K , N , i , Num , Ans;
    scanf( "%d%d%d" , &K , &N , &Num );
    Array[1] = 0;

    for( i = 2 ; i <= N ; ++i ){
        scanf( "%d" , Array + i );
        Array[i] -= Num;
    }

    Ans = Array[N];
    
    for( i = 2 ; i <= N ; ++i )
        Ans = min( Ans , K - ( Array[i] - Array[i - 1] ) );

    printf( "%d\n" , Ans );
    return 0;
}

Measured memory_bytes: 1024
import sys
import numpy as np

n,m = map(int, input().split())

val = [-1]*n

#print(val)

for i in range(m):
  a,b = map(int, input().split())
  if val[a-1]==-1:
    val[a-1] =b
  elif val[a-1]==b:
    continue
  else:
    print(-1)
    sys.exit()

    
if n==1:
  if val[0]==-1:
    val[0]=0
elif n!=1:
  if val[0]==-1:
    val[0]=1
  elif val[0]==0:
    print(-1)
    sys.exit()

for i in range(1,n):
  if val[i]==-1:
    val[i]=0
print(*val, sep="")

Measured memory_bytes: 12392
// B - Buffet
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n - 1; i++) cin >> c[i];

	long long sum = 0;
	for (int i = 0; i < n; i++) {
		sum += b[a[i] - 1];
		if (i > 0 && a[i] == a[i - 1] + 1) sum += c[a[i - 1] - 1];
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9 + 7);

string s;
int main(void) {
	cin >> s;
	int n = s.size();
	if (s[n-1] == 's')
		s += "es";
	else
		s += "s";
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  map<ll,ll> a;
  for(int i = 0;i < n;i++){
    ll diff = 0;
    cin >> diff;
    a[diff]++;
  }
  ll m = 0;
  cin >> m;
  map<ll,ll> b;
  for(int i = 0;i < m;i++){
    ll diff = 0;
    cin >> diff;
    b[diff]++;
  }
  bool can = true;
  for(auto i:b){
    if(i.second > a[i.first])can = false;
  }
  if(can)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 25216