akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define max 100
struct Graph{
  int u,k;
};
struct Graph graph[max];
int g[max][max];
int result[max][max];
int main(){
  int num,i,j;
  scanf("%d",&num);
  //初期化
  for(i=0;i<num;i++){
    result[i][i]=0;
    graph[i].u=0;
    graph[i].k=0;
    g[i][i]=0;
  }
  
  for(i=1;i<num+1;i++){
    scanf("%d %d",&graph[i].u,&graph[i].k);
    for(j=1;j<(graph[i].k)+1;j++){
      scanf("%d",&g[i][j]);//一つしか入力できないのに二つやろうとしているためできない
      result[graph[i].u][g[i][j]]=1;
      }
  }
  //result[1][1]=2;
  //out
  for(i=1;i<num+1;i++){
    for(j=1;j<num;j++){   
      printf("%d ",result[i][j]);
      //printf("u,%d:k,%d\n",graph[i].u,graph[i].k);
      //printf("%d",result[i][j+1]);
    }
      printf("%d\n",result[i][num]);
  }
  
  
  return 0;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  long long x[m], len[m-1];
  for ( int i = 0; i < m; i++ ) { cin >> x[i]; }
  sort(x, x+m);
  for ( int i = 0; i < m-1; i++ ) {
    len[i] = x[i+1] - x[i];
  }
  sort(len, len+m-1, greater<int>());

  long long ans = 0;
  if ( n < m ) {
    long long not_visit = 0;
    for ( int i = 0; i < n-1; i++ ) {
      not_visit += len[i];
    }
    ans = (x[m-1]-x[0]) - not_visit;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5112
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const LL N = 3005;

LL ec = 0,hed[N] = {0},nxt[N << 1],to[N << 1];
void add_edge(LL f,LL t){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec;
}

LL dep[N],siz[N],l[N],r[N];
LL s[N],n; string t;
void dfs(LL u,LL f){
	LL sr = 0,id = 0;
	dep[u] = dep[f] + 1;
	if(s[u]) siz[u] = 1;
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		dfs(v,u);
		siz[u] += siz[v];
	}
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		l[v] += siz[v]; r[v] += siz[v];
		sr += r[v];
		if(l[v] > l[id]) id = v;
	}
	l[u] = max(0LL,l[id] + r[id] - sr); r[u] = sr;
}

LL solve(LL x){
	LL sum = 0; dep[0] = -1;
	for(LL i = 1;i <= n;i ++) l[i] = r[i] = siz[i] = 0;
	dfs(x,0);
	for(LL i = 1;i <= n;i ++) if(s[i]) sum += dep[i];
	if(l[x] == 0 && sum % 2 == 0) return sum / 2;
	return INF;
}

int main(){
	ios::sync_with_stdio(false);
	LL u,v,ans = INF;
	cin >> n;
	cin >> t; for(LL i = 0;i < n;i ++) s[i + 1] = t[i] - '0';
	for(LL i = 1;i < n;i ++){
		cin >> u >> v;
		add_edge(u,v);
		add_edge(v,u);
	}
	for(LL i = 1;i <= n;i ++) ans = min(ans,solve(i));
	if(ans == INF) ans = -1;
	cout << ans << '\n';
	return 0;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X, A;
  cin >> X;
  if(X > 1799)A = 1;
  else if(X > 1599)A=2;
  else if(X > 1399)A=3;
  else if(X > 1199)A=4;
  else if(X > 999)A=5;
  else if(X > 799)A=6;
  else if(X > 599)A=7;
  else A=8;
  cout <<A<<endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	long long n,a,b,ans=0;
	cin>>n;
	while(n--){
		cin>>a>>b;
		ans+=b-a+1;
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;
int dx1[] = {-1, 0, 0, 1};
int dy1[] = {0, 1, -1, 0};
//マスの番号とワープ魔法の使用回数の組は構造体で表現
struct Node{
    int h;//上からh行目
    int w;//左からw列目
    int cost;//ワープ魔法の使用回数

    //優先度付きキューでは要素を昇順で取り出す
    //そのために演算子 > （大なり記号）をオーバーロードしておく
    bool operator>(const Node& other) const {
        return cost > other.cost;
    }
};

int main(){
    int h, w;
    cin >> h >> w;
    int ch, cw, dh, dw;
    cin >> ch >> cw;
    cin >> dh >> dw;
    vector<string> s(h);
    for(int i = 0; i < h; i++) cin >> s[i];
    //配列の添字が0から始まる環境に合わせて補正をかける
    ch--;
    cw--;
    dh--;
    dw--;

    //優先度付きキューでは要素を昇順で取り出すように指定する
    priority_queue<Node, vector<Node>, greater<Node>> Q;
    //訪問済みなら当該マスへ到達するためにワープ魔法を使用する回数の最小値が入る
    //未訪問なら-1が入る
    vector<vector<int>> ans(h, vector<int>(w, -1));

    //スタート地点の情報をQに投入
    Node start = {ch, cw, 0};
    Q.push(start);

    //Qから要素がなくなるまで頑張る
    while(Q.size()){
        //ノードを取り出す
        Node cur = Q.top();
        Q.pop();

        //訪問済みなら処理を打ち切り
        //未訪問ならワープ魔法の使用回数を記録して処理続行
        if(ans[cur.h][cur.w] != -1) continue;
        else ans[cur.h][cur.w] = cur.cost;
        

        //歩いていけるマスへ行く
        for(int i = 0; i < 4; i++){
            //歩いていけるマスの座標は(cur.h+dx1[i], cur.w+dy1[i])
            if(cur.h+dx1[i] >= 0 && cur.h+dx1[i] < h
            && cur.w+dy1[i] >= 0 && cur.w+dy1[i] < w
            && s[cur.h+dx1[i]][cur.w+dy1[i]] == '.'){
                //歩いていけるますならワープ回数は増えない
                Node next = {cur.h+dx1[i], cur.w+dy1[i], cur.cost};
                Q.push(next);
            }
        }

        //ワープ魔法でワープする
        for(int i = -2; i <= 2; i++){
            for(int j = -2; j <= 2; j++){
                //ワープで行けるマスの座標は
                //(cur.h+i, cur.w+j)
                if(cur.h+i >= 0 && cur.h+i < h
                && cur.w+j >= 0 && cur.w+j < w
                && s[cur.h+i][cur.w+j] == '.'){
                    //ワープするならワープ回数が増える
                    Node next = {cur.h+i, cur.w+j, cur.cost+1};
                    Q.push(next);
                }
            }
        }
    }

    //答えを出力
    cout << ans[dh][dw] << endl;
    return 0;
}

Measured memory_bytes: 12084
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 998244353;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	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; ++i) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	int p = 0;
	vector<int> cnt(n);
	for (int i = 0; i < n; ++i) {
		while (p < n && b[i] >= c[p]) {
			++p;
		}
		cnt[i] = n - p;
	}
	vector<ll> suf(n);
	suf[n - 1] = cnt[n - 1];
	for (int i = n - 2; i >= 0; --i) {
		suf[i] = suf[i + 1] + cnt[i];
	}
	p = 0;
	ll answer = 0;
	for (int i = 0; i < n; ++i) {
		while (p < n && a[i] >= b[p]) {
			++p;
		}
		answer += p == n ? 0 : suf[p];
	}
	cout << answer << '\n';
 	return 0;
}


Measured memory_bytes: 2560
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
    	int a=x.nextInt();
    	int b=x.nextInt();
    	if((a+b)%2!=0)
        {
          System.out.println("IMPOSSIBLE");
        }
    	else
    	{
          	System.out.println((a+b)/2);
        }
	}
}

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


int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	if (A < B && 2 * C <= A) {
		if (X > Y) {
			cout << 2 * X * C << endl;
		}
		else {
			cout << 2 * Y * C << endl;
		}
	}
	else if (A > B && 2 * C <= B) {
		if (X > Y) {
			cout << 2 * X * C << endl;
		}
		else {
			cout << 2 * Y * C << endl;
		}
	}
	else if (A + B <= C * 2) {
		cout << A * X + B * Y << endl;
	}
	else if(X > Y) {
		if (2 * C > A) {
			cout << 2 * Y * C + (X - Y) * A << endl;
		}
		else {
			cout << 2 * X * C << endl;
		}
	}
	else {
		if (2 * C > B) {
			cout << 2 * X * C + (Y - X) * B << endl;
		}
		else {
			cout << 2 * Y * C << endl;
		}
	}
}

Measured memory_bytes: 3196
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;

const int CN = 2e5 + 5;

int read(){
    int s = 0,ne = 1; char c = getchar();
    while(c < '0' || c > '9') ne = c == '-' ? -1 : 1, c = getchar();
    while(c >= '0' && c <= '9') s = (s << 1) + (s << 3) + c - '0', c = getchar();
    return s * ne;
}

int n, m, sz[CN];

class DSU {
  public: int fa[CN]; DSU() {for(int i = 0; i <= 200000; i++) fa[i] = i;}
    int fd(int x) {return fa[x] ^ x ? fa[x] = fd(fa[x]) : x;}
} D;

int main()
{
    // freopen("_in.in", "r", stdin);
    n = read(), m = read();
    for(int i = 1; i <= n; i++) sz[i] = 1;
    while(m--){
        int u = read(), v = read();
        u = D.fd(u), v = D.fd(v);
        if(u ^ v){
            sz[u] += sz[v], sz[v] = 0;
            D.fa[v] = u;
        }
    }
    int mx = 0; for(int i = 1; i <= n; i++) mx = max(mx, sz[i]);
    printf("%d", mx);
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
	int n;
	cin >> n;

	vi a(n);
	rep(i, 0, n) cin >> a[i];

	int ans = a[0]-1, cur = 2;	
	rep(i, 1, n){
		if(a[i] == cur){
			cur++;
		}else{
			ans += (a[i] - 1) / cur;	
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string str,s;
    cin>>str>>s;
    ll i,ans=0;
    for(i=0;i<s.length();i++){
        if(s[i]==str[i])
            ans+=1;
    }
    cout<<ans<<endl;
    return 0;
}


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

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

	int cnt = 0;
	int len = S.length();
	for(int i = 0; i < len; i++)
	{
		if(i % 2 == S[i] - '0'){
			cnt++;
		}
	}

	cout << min(cnt, len - cnt) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int n,c,d[30][30],e[3][30],b=500000000;
    cin>>n>>c;
    for(int i=0;i<c;i++)for(int j=0;j<c;j++)cin>>d[i][j];
    for(int i=0;i<3;i++)for(int j=0;j<c;j++)e[i][j]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int a;
            cin>>a;
            a--;
            e[(i+j)%3][a]++;
        }
    }
    for(int i=0;i<c;i++){
        for(int j=0;j<c;j++){
            for(int k=0;k<c;k++){
                if(i!=j&&i!=k&&j!=k){
                    int a=0;
                    for(int l=0;l<c;l++){
                        a+=e[0][l]*d[l][i];
                        a+=e[1][l]*d[l][j];
                        a+=e[2][l]*d[l][k];
                    }
                    b=min(a,b);
                }
            }
        }
    }
    cout<<b<<endl;
}


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

#define N 100000
#define NIL -1

typedef struct t{
  int id;
  int parent;
  int degree;
  int depth;
  int child[2];
  int sibling;
  int height;
}Tree;

void depthcalculation(int, int);
void heightcalculation(int);
void Preorder(int);
void Inorder(int);
void Postorder(int);

Tree T[N];
int maxdepth = 0;

int main(){
  int treenum, i, id, j;
  
  scanf("%d", &treenum);
  
  //preparation
  for(i = 0; i < treenum; i++){
    T[i].parent = NIL;
    T[i].depth = 0;
    T[i].sibling = -1;
    T[i].height = 0;
    T[i].degree = 0;
  }
  
  //input
  for(i = 0; i < treenum; i++){
    scanf("%d", &id);
    T[id].id = id;
    
    for(j = 0; j < 2; j++){
      
      scanf("%d", &T[id].child[j]);
      
      if(T[id].child[j] != NIL){
	T[ T[id].child[j] ].parent = T[id].id;
	T[id].degree++;
      }
      
    }
   
      T[ T[id].child[0] ].sibling = T[id].child[1];
      T[ T[id].child[1] ].sibling = T[id].child[0];
    
  }
  
  //root search
  for(i = 0; i < treenum; i++){
    if(T[i].parent == NIL){
      break;
    }
  }
  
  depthcalculation(i, 0);
  heightcalculation(treenum);
  T[i].height = maxdepth;
  
  //output
  printf("Preorder\n");
  Preorder(i);
  printf("\n");
  printf("Inorder\n");
  Inorder(i);
  printf("\n");
  printf("Postorder\n");
  Postorder(i);
  printf("\n");
  
  return 0;
}

void depthcalculation(int t, int d){
  int i;

  T[t].depth = d;
  
  if(maxdepth < d){
    maxdepth = d;
  }
  
  for(i = 0; i < 2; i++){
    if(T[t].child[i] != NIL){
    depthcalculation(T[t].child[i], d+1);
    }
  }
  
}

void heightcalculation(int treenum){
  int i, h, id;

  for(i = 0; i < treenum; i++){
    if(T[i].degree == 0){
      h = 0;
      id = T[i].id;
      T[i].height = 0;
      
      while(1){
	id = T[id].parent;
	if(id == NIL){
	  break;
	}
	h++;

	if(T[id].height < h){
	  T[id].height = h;
	}
      }
      
    }
  }
}

void Preorder(int t){
    printf(" %d", T[t].id);
    if(T[t].child[0] != NIL){
      Preorder(T[t].child[0]);
    }
    if(T[t].child[1] != NIL){
      Preorder(T[t].child[1]);
    }
}

void Inorder(int t){

  if(T[t].child[0] != NIL){
    Inorder(T[t].child[0]);
  }
  printf(" %d", T[t].id);
  if(T[t].child[1] != NIL){
    Inorder(T[t].child[1]);
  }
}
void Postorder(int t){

  if(T[t].child[0] != NIL){
    Postorder(T[t].child[0]);
  }
  if(T[t].child[1] != NIL){
    Postorder(T[t].child[1]);
  }
  printf(" %d", T[t].id);
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int zao[200001],wan[200001];
int n,k,c;
string s;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>k>>c;
	cin>>s;
	int cnt=0;
	rep(i,n){
		if(s[i]=='o'){
			zao[cnt++]=i;
			if(cnt==k)
			break;
			i+=c;
		}
	}
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='o'){
			wan[--cnt]=i;
			if(!cnt)
			break;
			i-=c;
		}
	}
	rep(i,k)
	if(zao[i]==wan[i])
	cout<<zao[i]+1<<"\n";;
	re 0;
}


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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;


int main() {
	
	IO;
	
	string s;
	cin >> s;
	
	s[5] = s[13] = ' ';
	
	cout << s;
		
		
		

}



Measured memory_bytes: 3640
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <set>
#include <map>
#include <utility>

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

  int res = 1;
  for (int i = 0; i < 3; ++i) res *= N;
  printf("%d\n", res);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
ll n,a;
signed main(){
	acc_io;
	cin>>n;
	map<int,int>mp;
	ll sa,wa;
	ll ans=0;
	rep(i,0,n){
		cin>>a;
		sa=i-a;
		ans+=mp[sa];
		wa=i+a;
		mp[wa]++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 20488
#include <cstdio>

using namespace std;

int cnt[69];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 60; ++i) {
    cnt[i] = 0;
  }
  const int mod = 1'000'000'007;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    long long x;
    scanf("%lld", &x);
    ans += x % mod * (n - 1) % mod;
    ans %= mod;
    for (int j = 0; j < 60; ++j) {
      if (x >> j & 1) {
        ++cnt[j];
      }
    }
  }
  for (int i = 0; i < 60; ++i) {
    long long pw = (1LL << (i + 1)) % mod;
    long long tot = (long long)cnt[i] * (cnt[i] - 1) / 2 % mod;
    ans -= pw * tot % mod;
    ans += mod;
    ans %= mod;
  }
  printf("%d\n", (int)ans);
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    k,x=INTM()
    if k*500>=x:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    ll n;
    int sum = 0;
    cin >> n;
    string s = to_string(n);
    for (int i = 0; i < s.length(); i++) {
        sum += (s[i]  - '0');
    }
    if (n % sum == 0) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N,0);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	sort(A.begin(),A.end());
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			for(int k=j+1;k<N;k++){
				if(A[k]<A[i]+A[j])ans++;
			}
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}

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

const int N = 2e5+10;
int n;
int a[N];
void solve(){
    cin >> n;
    for(int i=0;i<n;++i) {
        cin >> a[i];
    }
    long long ans=0;
    for(int i=1;i<n;++i) {
        if(a[i] < a[i-1])
            ans += a[i-1] - a[i] , a[i] = a[i-1];
    }
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


Measured memory_bytes: 4364
//Subhash Suman
//Date: 10/02/19 ; Day: Sunday ; Time: 18::03::06 
//Description : 

#include<bits/stdc++.h>
#define ll long long int
#define MAX INT_MAX
#define MIN INT_MIN
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>

using namespace std;
const int N = 1e5+5;
int dp[N],arr[N];
int n,k;


int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    cin>>n>>k;
    for(int i = 1; i <= n; i++){
        cin>>arr[i];
    }
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        dp[i] = INT_MAX;
    }
    for(int i = 2; i <= n; i++){
        for(int j = max(1,i-k); j < i; j++){
            dp[i] = min(dp[i],dp[j]+abs(arr[i]-arr[j]));
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

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

int main(){
  int X;
  cin >> X;
  if (X <= 599)
    cout << '8' << endl;
  else if (X <= 799)
    cout << '7' << endl;
  else if (X <= 999)
    cout << '6' << endl;
  else if (X <= 1199)
    cout << '5' << endl;
  else if (X <= 1399)
    cout << '4' << endl;
  else if (X <= 1599)
    cout << '3' << endl;
  else if (X <= 1799)
    cout << '2' << endl;
  else if (X <= 1999)
    cout << '1' << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner; 
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		for(int i = 0 ; i < str.length();i++){
			if(str.charAt(i)<68)
				System.out.print((char)(str.charAt(i)+23));
			else
				System.out.print((char)(str.charAt(i)-3));
		}
		System.out.println("");
	}
}

Measured memory_bytes: 17228
#include <stdio.h>

int main(void) {
  int H,W,i,j;
  while(1){
  scanf("%d %d",&H,&W);
  if(H==0&&W==0){
    break;
  }
  else{
    for(i=1;i<=H;i++){
      for(j=1;j<=W;j++){
        if(i!=1&&i!=H&&j!=1&&j!=W){
          printf(".");
        }
        else{
          printf("#");
        }
      }
      printf("\n");
    }
  }
  printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2068
#include <iostream>
#include <string>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;

int main()
{
  unordered_map<int, bool> S;
  int n, q, ans = 0;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int x;
    cin >> x;
    S[x] = true;
  }
  cin >> q;
  for (int i = 0; i < q; i++)
  {
    int x;
    cin >> x;
    if (S[x])
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

// 探索中にあたったノードの計算結果も記憶しておく
int memo[123456];
bool flag[123456];
vector<int> g[123456];

int solve( int i ){
	if( flag[i] ){
		return memo[i];
	}
	flag[i] = true;
	// ノードから出ている枝をすべて探索して経路の一番長いものを採用
	int res = 0;
	int sz = g[i].l_ength();
	for( int j = 0; j < sz; ++j ){
		res = max( res, solve(g[i][j])+1 );
	}
	return memo[i] = res;
}

int main(){
	int n, m; cin >> n >> m;
	for( int i = 0; i < m; ++i ){
		int x, y; cin >> x >> y;
		--x; --y;
		g[x].push_back(y);
	}
	for( int i = 0; i < n; ++i ){
		flag[i] = false;
	}
	int ans = 0;
	for( int i = 0; i < n; ++i ){
		ans = max( ans, solve(i) );
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF =ll(1e18) +5;

int main() {
    ll N;
    cin >> N;
    ll ma = -INF;
    ll mi = INF;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        ma = max(ma,A[i]);
        mi = min(mi,A[i]);
    }
    int maxlocation,minlocation;
    for(int i=0;i<N;i++){
        if(A[i] == ma){
            maxlocation=i;
        }
        if(A[i] == mi){
            minlocation =i;
        }
    }
    vector<pair<int,int>> ans;
    if(abs(ma) > abs(mi)){
        ans.emplace_back(maxlocation+1,1);
        ans.emplace_back(maxlocation+1,1);
        for(int i=1;i<N;i++){
            ans.emplace_back(i,i+1);
            ans.emplace_back(i,i+1);
        }
    }else{
        ans.emplace_back(minlocation+1,N);
        ans.emplace_back(minlocation+1,N);
        for(int i=N-2;i>=0;--i){
            ans.emplace_back(i+2,i+1);
            ans.emplace_back(i+2,i+1);
        }
    }
    cout << ans.size() << endl;
    for(auto P:ans){
        cout << P.first <<" "<< P.second << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$cards = explode(" ", fgets(STDIN));
$cards = array_map("trim", $cards);
$alice = 0;
$bob =0;
rsort($cards);
foreach ($cards as $key => $value) {
	$key %2 == 0 ? $alice += $value : $bob += $value;
}
echo $alice-$bob . "\n";
?>

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

using namespace std;

int h[100005];

int main(){
	int n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++)
		cin >> h[i];
	sort(h,h+n);
	int ans=1e9;
	for(int i=0;i+k-1<n;i++){
		ans = min(ans,h[i+k-1]-h[i]);
	}
	cout << ans;

}

Measured memory_bytes: 640
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfLong()
    val M = mutableMapOf<Long, Int>()
    A.sortedDescending().forEach { a ->
        M[a] = M.getOrElse(a, { 0 }) + 1
    }
    val F = M.filter { it.value >= 2 }.toList()
    val ans = when (F.size) {
        0 -> 0L
        1 -> if (F[0].second >= 4) F[0].first * F[0].first else 0L
        else -> F[0].first * F[if (F[0].second >= 4) 0 else 1].first
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 60600
s = [input() for i in range(3)]
p = [0,0,0]
c = 0

while True:
    if p[c]==len(s[c]):
        print(chr(ord('A')+c))
        break
    if s[c][p[c]]=='a':
        p[c]+=1
        c=0
    elif s[c][p[c]]=='b':
        p[c]+=1
        c=1
    elif s[c][p[c]]=='c':
        p[c]+=1
        c=2

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

int main() {
  int a, b;
  scanf("%d %d", &a, &b);

  int v = a * pow(10, to_string(b).length()) + b;
  bool found = false;
  for (int i = 0; i * i <= v; ++i)
    if (i * i == v)
      found = true;
  if (found)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#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 N;
  cin >> N;
  vector<int> W(N);
  int sum = 0;
  rep(i,N) {
    cin >> W[i];
    sum += W[i];
  }
  int temp_sum = 0;
  int ans = 999999;
  rep(i,N) {
    temp_sum += W[i];
    sum -= W[i];
    ans = min(ans, abs(temp_sum - sum));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3156
// g++ -std=c++14

//Difficulty according to solve count during contest:
//A B C D H F E I G K L M N P S O Q R J U Z Y X T V W

#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(c) (c.begin(),c.end())
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define inf 1000000000000000001

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll

int n, k;
vector<int> a;
vector<vector<int> > dp;
int func(int left, int turn){
  if(dp[left][turn] != -1)
    return dp[left][turn];
  if(turn == 0)
    dp[left][turn] = 0;
  else
    dp[left][turn] = 1;
  for(int i = 0; i < n; i++){
    if(left >= a[i]){
      int next = func(left - a[i], (turn + 1) % 2);
      if(turn == 0 and next == 1)
        dp[left][turn] = 1;
      if(turn == 1 and next == 0)
        dp[left][turn] = 0;
    }
  }
  return dp[left][turn];
}
int32_t main(){
  cin >> n >> k;
  a.resize(n);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  dp.resize(k + 1, vector<int>(2, -1));
  int ans = func(k, 0);
  if(ans == 0)
    cout << "Second\n";
  else
    cout << "First\n";
  return 0;
}


Measured memory_bytes: 14820
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    n, x = list(map(int, input().rstrip('\n').split()))
    xl = list(map(int, input().rstrip('\n').split()))
    xl.append(x)
    xl.sort()
    gcd = 0
    for i in range(1, len(xl)):
        gcd = fractions.gcd(gcd, xl[i] - xl[i-1])
    print(gcd)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 88396
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

using i64 = long long;

#define REP(i, n) for (int i = 0, i##_len = n; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)

const int is = 1 << 17;
char ib[is], *ip = ib + is, it;
inline char getc() {
	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }
	return *ip++;
}
inline i64 read() {
	i64 r = 0;
	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
	else while ((it = *ip++) & 16) r = r * 10 + it - '0';
	return r;
}

const int os = 1 << 17;
char ob[os], *op = ob, ot;
inline void putc(const char c) {
	*op++ = c;
	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }
}
// x shoud be greater than or equal to zero
inline void write(i64 x) {
	char d[20];
	int i = 0;
	while (true) {
		d[i] = x % 10 + 48;
		x /= 10;
		++i;
		if (x <= 0) break;
	}
	while (i--) {
		putc(d[i]);
	}
}

signed main() {
  i64 N = read();
  i64 M = read();
  vector<i64> A(N);
  REP(i, N) A[i] = read();
  sort(A.begin(), A.end());
  vector<i64> S(N + 1);
  REP(i, N) S[i + 1] = S[i] + A[i];
  i64 h_ng = 0;
  i64 h_ok = A[N - 1] * 2 + 1;
  i64 h = h_ok;
  while (h_ok > h_ng + 1) {
    h = h_ng + h_ok >> 1;
    i64 q = 0;
    i64 gt = 0;
    RREP(i, N) {
      while (gt < N && !(A[i] + A[gt] > h)) gt++;
      q += N - gt;
    }
    if (q <= M) {
      h_ok = h;
    } else {
      h_ng = h;
    }
  }
  h = h_ok;
  i64 s = 0;
  i64 q = 0;
  i64 gt = 0;
  RREP(i, N) {
    while (gt < N && !(A[i] + A[gt] > h)) gt++;
    q += N - gt;
    s += S[N] - S[gt] + A[i] * (N - gt);
  }
  write(s + (M - q) * h);
  fwrite_unlocked(ob, 1, op - ob, stdout);
}


Measured memory_bytes: 1920
/* 
 * Project: AtCoder Beginners Contest 145 A - Circle
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/09
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
using namespace std;

int r;

void solve() {

    printf("%d\n", r*r);

}

int main() {

    scanf("%d", &r);

    solve();

}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=5e5+100,mod=998244353;
ll power(ll n,ll k){
    if (k==0) return 1;
    if (k%2==1){
        ll x=power(n,k/2);
        return x*x%mod*n%mod;
    }
    ll x=power(n,k/2);
    return x*x%mod;
}
ll fac[N];
ll fm[N];
ll ent(ll k,ll n){
    if (k==0 || k==n) return 1;
    if (k<0 || k>n) return 0;
    return fac[n]*fm[k]%mod*fm[n-k]%mod;
}
int32_t main(){
    ll n,m;
    cin >> n >> m;
    fac[0]=1;
    for (int i=1;i<N;i++){
        fac[i]=fac[i-1]*i%mod;
        fm[i]=power(fac[i],mod-2);
    }
    ll ans=power(n+1,m)*power(m+1,n)%mod;
    for (int i=1;i<=min(m,n);i++){
        ll z=ent(i,m)*ent(i,n)%mod*fac[i]%mod*power(n+1,m-i)%mod*power(m+1,n-i)%mod;
        if (i%2) ans-=z;
        else ans+=z;
        ans+=mod;
        ans%=mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11416
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 2019;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  int N;
  cin>>N;
  vector<pair<string,int>> A;
  vector<pair<string,int>> B;
  rep(i,N){
    string a;
    int b;
    cin>>a>>b;
    A.push_back(make_pair(a,b));
    B.push_back(make_pair(a,-b));
  }
  
  sort(B.begin(),B.end());
  rep(i,N){
    B[i].second*=-1;
  }
  
  ll c[N];
  rep(i,N){
    rep(j,N){
      if(B[i]==A[j]) c[i]=j+1;
    }
  }
  
  rep(i,N){
    cout<<c[i]<<endl;
  }
}
    

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

int main()
{
    std::string S;
    std::cin >> S;

    int K;
    std::cin >> K;


    int L = S.size();

#if 1
    std::set<std::string> strs;
    for (int i = 0; i < L; ++i) {
        for (int j = 1; j <= std::min(5, L - i); ++j) {
            strs.insert(S.substr(i, j));
        }
    }

    auto itr = strs.begin();
    for (size_t i = 0; i < K-1; ++i) {
        itr++;
    }
    std::cout << *itr << std::endl;
    return 0;
#endif

    #if 0
    std::set<char> ones;
    for (size_t i = 0; i < L; ++i) {
        cerr << S[i];
        one.insert(S[i]);
    }

    std::string one = *ones.begin();

    // 2番目は一番目の次があればそのなかで最小。なければ2番目の文字
    std::set<std::string> twos;
    for (size_t i = 0; i < L-1; ++i) {
        if (S[i] == one) {
            two.insert(S.substr(i, 2));
        }
    }

    std::string two = *twos.begin();


    std::set<char> one;
    for (size_t i = 0; i < L; ++i) {
        cerr << S[i];
        one.insert(S[i]);
    }

    if (one.size() <= K) {
        auto itr = one.begin();
        for (size_t i = 0; i < K-1; ++i) {
            itr++;
        }
        std::cout << *itr << std::endl;
        return 0;
    }

    K -= L;

    std::set<char> one;
    for (size_t i = 0; i < L; ++i) {
        cerr << S[i];
        one.insert(S[i]);
    }


    //std::cout << N << std::endl;

    return 0;
    #endif
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
// const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  i64 h;
  cin >> h;
  i64 ans = 0, cnt = 1;
  while(h > 0) {
    ans += cnt;
    h /= 2;
    cnt *= 2;
  }
  cout << ans << endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

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


int w,h;
int visited[110][11];
char board[110][11];

using tii=tuple<int,int>;
const tii failed=make_tuple(-1,0);

int cur_comp=1;

tii rec(int sh,int sw){
	cur_comp++;

	tii ret=make_tuple(0,0); // fail

	int prv_comp=0; 
	if(sh!=h-1) prv_comp=visited[sh+1][sw];
	int left=sw,right=sw;
	
	queue<int> q;
	q.push(sh);q.push(sw);
	visited[sh][sw]=cur_comp;

	while(!q.empty()){
		int ch=q.front();q.pop();
		int cw=q.front();q.pop();

		get<0>(ret)+=cw,get<1>(ret)++;

		rep(i,4){
			int nh=ch+dx[i];
			int nw=cw+dy[i];
			if(nh<0||h<=nh) continue;
			if(nw<0||w<=nw) continue;
			if(board[ch][cw]!=board[nh][nw]) continue;
			if(visited[nh][nw]!=-1) continue;
			visited[nh][nw]=cur_comp;
			q.push(nh);q.push(nw);
		}		
	}



	rep(i,h)rep(j,w){
		if(visited[i][j]!=visited[sh][sw]) continue;
		if(i==h-1 || visited[i+1][j]==prv_comp) chmin(left,j),chmax(right,j);

		if(i-1>=0 && board[i-1][j]!='.' && board[i-1][j]!=board[i][j] && visited[i-1][j]==-1){
			tii cur=rec(i-1,j);
			if(get<0>(cur)==-1) return failed;
			get<0>(ret)+=get<0>(cur),get<1>(ret)+=get<1>(cur);
		}
	}

	right++;
	// while(left>0 && board[sh][left]==board[sh][left-1] && (sh==h-1 || board[sh+1][left-1]!='.')) left--;
	// while(right<w && board[sh][right-1]==board[sh][right] && (sh==h-1 || board[sh+1][right]!='.')) right++;


	//cout << left << " " <<  1.0*(get<0>(ret)+0.5*get<1>(ret))/(get<1>(ret)) << " " << right << endl;

	//cout << 2*left*get<1>(ret) << " " <<  1.0*(get<0>(ret)+0.5*get<1>(ret)) << " " << 2*right*get<1>(ret) << endl;

	if(2*get<0>(ret)+get<1>(ret)<=2*left*get<1>(ret)) return failed;
	if(2*right*get<1>(ret)<=2*get<0>(ret)+get<1>(ret)) return failed;
	return ret;
}

int main(void){
	while(cin >> w >> h,w){
		rep(i,110)rep(j,11) board[i][j]='.',visited[i][j]=-1;
		cur_comp=1;
		rep(i,h)rep(j,w) cin >> board[i][j];

		tii ret;
		rep(j,w) if(board[h-1][j]!='.'){
			ret=rec(h-1,j);
			break;
		}

		if(get<0>(ret)!=-1)
			puts("STABLE");
		else
			puts("UNSTABLE");
	}

	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 1;

int main() {
  int a, b, c;
  cin >> a >> b; c = b - a;
  cout << c*(c-1)/2-a << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int A, B;
    cin >> A >> B;
    cout << max(0, A - 2 * B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    int n,x;
    cin>>n>>x;
    ll l[110];
  	l[0]=0;
    for(int i=1;i<n+1;i++)cin>>l[i];
    int i=0;
    int d=0;
    for(;i<n+1;i++){
        d+=l[i];
        if(d>x){
            break;
        }
    }
    cout<<i<<endl;
}

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

int main()
{
    ll x, m = 100;
    int out=1;
    cin >> x;

    while(1)
    {
        m = m + (m * 0.01);

        if (m >= x) {
            cout << out << endl;
            return 0;
        }

        ++out;
    }
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int mas[10][10]={{0}};
void dot(int x,int y){
  if(x>=0&&y>=0&&x<=9&&y<=9) mas[y][x]++;
}
void small(int x,int y){
  dot(x,y);
  dot(x+1,y);
  dot(x,y+1);
  dot(x-1,y);
  dot(x,y-1);
}
void mid(int x,int y){
  small(x,y);
  dot(x+1,y+1);
  dot(x-1,y-1);
  dot(x+1,y-1);
  dot(x-1,y+1);
}
void big(int x,int y){
  mid(x,y);
  dot(x+2,y);
  dot(x-2,y);
  dot(x,y+2);
  dot(x,y-2);
}
int main(){
  int count=0,max=0,x,y,size;
  char a,b;
  while(cin>>x>>a>>y>>b>>size){
    if(size==1) small(x,y);
    else if(size==2) mid(x,y);
    else big(x,y);
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(mas[i][j]==0) count++;
      if(mas[i][j]>max) max = mas[i][j];
    }
  }
  cout << count << endl << max << endl;
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int[] d;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        d = new int[N];
        for (int i = 0; i < N; i++) {
        	this.d[i] = sc.nextInt();
        }
    }
    
    //解答処理
    private int solve() {
        int total = 0;
        
        for (int i = 0; i < N-1; i++) {
        	for (int j = i+1; j < N; j++) {
        		total += d[i] * d[j];
        	}
        }
        
        return total;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35628
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main (){
	int a,suzi,X[4][14]={{}};
	char moyo;
	cin >> a;
	while(a--){
		cin>>moyo>>suzi;
		switch(moyo){
		case 'S':X[0][suzi]=1;break;
		case 'H':X[1][suzi]=1;break;
		case 'C':X[2][suzi]=1;break;
		case 'D':X[3][suzi]=1;break;
		}
	}
	for(int s=0;s<4;s++){
		for(int y=1;y<14;y++){
			if(X[s][y]==0){
				switch(s){
				case 0:cout<<"S "<< y <<endl;	break;
				case 1:cout<<"H "<< y <<endl;	break;
				case 2:cout<<"C "<< y <<endl;	break;
				case 3:cout<<"D "<< y <<endl;	break;
				}
			}
		}
	}
return 0;
}

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

int main()
{
   int n;cin>>n;
   int a[n][3];
  for(int i=0;i<n;i++)
   cin>>a[i][0]>>a[i][1]>>a[i][2];
  int dp[n][3];
  dp[0][0]=a[0][0];
  dp[0][1]=a[0][1];
  dp[0][2]=a[0][2];
 for(int i=1;i<n;i++)
 {
  dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
  dp[i][1]=a[i][1]+max(dp[i-1][2],dp[i-1][0]); 
  dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]); 
   
   
 }
  
  int c=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
  cout<<c;
  
  
   
  
 return 0;

}

Measured memory_bytes: 2560
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=sorted([A[i]-B[i]for i in range(N)])
if sum(C)<0:
    print(-1)
else:
    D=[i for i in C if i<0]
    m=sum(D)
    i=0
    while m<0:
        m+=C[N-i-1]
        i+=1
    print(len(D)+i)


Measured memory_bytes: 95308
#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>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }


int main() {
	int N;
	cin >> N;
	mint dp[101][4][4][4];
	
	for (int n = 0;n<4;++n) {
		for (int m = 0;m<4;++m) {
			for (int l = 0;l<4;++l) {
				dp[3][n][m][l] = 1;
			}
		}
	}
	dp[3][0][2][1] = 0;
	dp[3][0][1][2] = 0;
	dp[3][2][0][1] = 0;
	dp[0][3][3][3] = 1;
	for (int k = 3;k<=N-1;++k) {
		for (int n = 0; n < 4; ++n) {
			for (int m = 0; m < 4; ++m) {
				for (int l = 0; l < 4; ++l) {
					for (int r = 0;r<4;++r) {
						if (0 == m && 2 == l&&1==r) {
							continue;
						}
						if (0 ==m && 1 ==l && 2 ==r) {
							continue;
						}
						if (2 == m&& 0==l&&1 ==r) {
							continue;
						}	
						if (0 == n && 2 == l && 1 == r) {
							continue;
						}	
						if (0 == n && 2 == m && 1 == r) {
							continue;
						}
						dp[k + 1][m][l][r] += dp[k][n][m][l];
					}
				}
			}
		}
	}


	mint ans = 0; 
	for (int n = 0; n < 4; ++n) {
		for (int m = 0; m < 4; ++m) {
			for (int l = 0; l < 4; ++l) {
				ans += dp[N][n][m][l];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#define int long long

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
string s;
/**********************************************/

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

    cin >> s;
    int ans = 700;
    REP(i, 3) if(s[i] == 'o') ans += 100;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<int>a(n);
    vector<int>b(m);
    rep(i,n)cin>>a[i];
    rep(i,m)cin>>b[i];
    int q=m;
    ll t=0;
    int ans=0;
    rep(i,m)t+=b[i];
    rep(i,n+1){
        while(t>k&&q>0){
            q--;
            t-=b[q];
        }
        if(t>k)break;
    ans=max(i+q,ans);
    if(i==n)break;
    t+=a[i];
    }
cout<<ans;
return 0;
}

Measured memory_bytes: 4400
#include <iostream>
#include <string>
#include <algorithm>
#define ll long long int
using namespace std;

int main()
{
  ll n;
  cin >> n;
  ll count = 0, step = 0, x = 1;
  while (n > 0)
  {
    n = n / 2;
    count = count + (x << step);
    step++;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256