akhauriyash/Code-Regression huggingface dataset:
program hrn;
 var
  a:array[1..100]of longint;
  i,n,x,y:longint;
  procedure qsort(l,h:longint);
   var
    i,j,t,m:longint;
   begin
    i:=l; j:=h;
    m:=a[(i+j) div 2];
    repeat
     while a[i]<m do inc(i);
     while m<a[j] do dec(j);
     if i<=j then
      begin
       t:=a[i]; a[i]:=a[j]; a[j]:=t;
       inc(i); dec(j);
      end;
    until i>j;
    if i<h then qsort(i,h);
    if j>l then qsort(l,j);
   end;
 begin
  read(n);
  for i:=1 to n do read(a[i]);
  qsort(1,n);
  for i:=1 to n do
   if i mod 2=1 then x:=x+a[i]
                else y:=y+a[i];
  writeln(abs(x-y));
 end.


Measured memory_bytes: 128
import java.util.Scanner;

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

		int k = sc.nextInt();
		int x = sc.nextInt();

		for(int i = x - k+1; i <= k + x - 1; i++){
			System.out.print(i + " ");
		}

	}
}

Measured memory_bytes: 23252
#include <iostream>
using namespace std;
int main(){
string s;
cin >> s;
int ans;
if(s == "SUN")ans = 7;
else if(s == "MON")ans = 6;
else if(s == "TUE")ans = 5;
else if(s == "WED")ans = 4;
else if(s == "THU")ans = 3;
else if(s == "FRI")ans = 2;
else if(s == "SAT")ans = 1;
cout << ans << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// ------ Class ------ //
template <class T> class Graph2 {
public:
	// ------ Variables ------ //
	static const T INF = numeric_limits<T>::max();
	int V, E; vector<vector<pair<int, T> > > G;

	// ------ Constructors ------ //
	Graph2() : V(0), E(0), G(vector<vector<pair<int, T> > >()) {}
	Graph2(int v) : V(v), E(0), G(vector<vector<pair<int, T> > >(v)) {}
	Graph2(vector<vector<pair<int, T> > > g) : V(g.size()), G(g) { for (int i = 0; i < g.size(); i++) E += g[i].size(); }

	// ------ Basic Functions ------ //
	int size() { return V; }
	void add1(int v1, int v2, T w) { G[v1].push_back(make_pair(v2, w)); E++; }
	void add2(int v1, int v2, T w) { add1(v1, v2, w); add1(v2, v1, w); }

	// ------ Operators ------ //
	bool operator==(const Graph2& g) const { return G == g.G; }
	bool operator!=(const Graph2& g) const { return G != g.G; }
	vector<pair<int, T> > operator[](int x) { return G[x]; }

	// ------ Algorithms ------ //
	vector<T> dist(int s) {
		priority_queue<pair<T, int> > que; que.push(make_pair(0, s));
		vector<T> d(V, INF); d[s] = 0;
		while (!que.empty()) {
			pair<T, int> t = que.top(); que.pop();
			int u = t.second;
			for (int i = 0; i < G[u].size(); i++) {
				int v = G[u][i].first; T e = G[u][i].second;
				if (d[v] > d[u] + e) {
					d[v] = d[u] + e;
					que.push(make_pair(-d[v], v));
				}
			}
		}
		return d;
	}
};
// ------ Main ------ //
int V, E, r, s, t, w;
int main() {
	cin >> V >> E >> r;
	Graph2<int> G(V);
	for(int i = 0; i < E; i++) {
		cin >> s >> t >> w;
		G.add1(s, t, w);
	}
	vector<int> d = G.dist(r);
	for(int i = 0; i < V; i++) {
		if(d[i] != Graph2<int>::INF) cout << d[i] << endl;
		else cout << "INF" << endl;
	}
}

Measured memory_bytes: 12956
N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

All = sum(A)
A = sorted(A, reverse=True)

judge = 1/(4*M)
count = 0


for i in range(M):
  if A[i] < judge*All:
    count += 1
    break

if count == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
# https://atcoder.jp/contests/abc074/tasks/arc083_b

# 考えること
# 1, どうやったらu→vの最短経路を復元できるか？
# 2, そのような道路が存在しない場合とはどういうときか？

# 重要な考察
# 1, iを固定したとき、j=arg_j min D[i][j] はiと必ず隣接する
# 2, d(u,v)=d(u,i)+d(i,v) を満たすiは最短経路の中にある。


# minimum sppaning treeからスタートする発想は悪くなかったねぇ

# 解説見ました...

# 道路が存在しない場合の判別方法→隣接行列Aに対してワーシャルフロイドをして、隣接行列Bを作成
# B(u,v)<A(u,v)となるとき、理想の最短距離よりも短い最短距離が存在して矛盾が生じるので-1

# Aを全点間グラフとして、辺の削除を考える。
# あらゆる二点に関するminimumな経路は？u,i,vについて、d(u,v)<d(u,i)+d(i,v)ならば、辺を残さないと最小距離にならない.
# 逆にd(u,v)=d(u,i)+d(i,v)ならば、d(u,v)の方は取り除いても構わない  (d(u,v)>d(u,i)+d(i,v)の状況はワーシャルフロイドで取り除かれている)


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


N = read_a_int()
A = read_matrix(N)
from itertools import combinations
edge_rm = set()
for u, v in combinations(range(N), 2):
    for i in range(N):
        if i == u or i == v:
            continue
        a = A[u][i]
        b = A[i][v]
        c = A[u][v]
        # print(a, b, c)
        if c == a + b:
            # print(u, i, v, a, b, c)
            edge_rm.add((u, v) if u < v else(v, u))
        elif c > a + b:
            print(-1)
            exit()
# print(edge_rm)
ans_sum = 0
for a in A:
    for aa in a:
        ans_sum += aa
ans_sum //= 2
for u, v in edge_rm:
    ans_sum -= A[u][v]
print(ans_sum)


Measured memory_bytes: 47324
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000000
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t;
ll dp[51][2501];
int a,now;
ll ans;
int main()
{
    int i,j;
    dp[0][0]=1;
    scanf("%d%d",&n,&a);
    rep(i,1,n)
    {
        scanf("%d",&k);
        now+=k;
        for(j=i;j>=1;j--)
            for(t=now;t>=k;t--)
                dp[j][t]+=dp[j-1][t-k];
    }
    rep(i,1,n)ans+=dp[i][a*i];
    printf("%lld\n",ans);
    //system("Pause");
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>

struct city{
    int p,y,cnt,idx;
};
    
bool cityCmp(const city& a, const city& b) {
    return a.y < b.y;
}
bool cityCmp2(const city& a, const city& b) {
    return a.idx < b.idx;
}

using namespace std;

string tos(int n){
    string s=to_string(n);
    int size=s.size();
    for(int i=0;i<6-size;i++){
        s="0"+s;
    }
    return s;
}

int main() {
    vector<city> cities;
    int N,M,i,a,b;
    cin>>N>>M;
    for(i=0;i<M;i++){
        cin>>a>>b;
        city c;
        c.p=a;c.y=b;c.cnt=0;c.idx=i;
        cities.push_back(c);
    }
    sort(cities.begin(),cities.end(), cityCmp);
    int mp[100001]={0,};
    for(i=0;i<M;i++){
        cities[i].cnt=++mp[cities[i].p];
    }
    sort(cities.begin(),cities.end(), cityCmp2);
    for(i=0;i<M;i++){
        cout<<tos(cities[i].p)+tos(cities[i].cnt)<<endl;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
struct edge {
    int from, to, w;
};
vector<edge> edges;
ll dist[10000];
int main() {
    int n, m, p;
    cin >> n >> m >> p;
    edge temp;
    for(int i = 0; i < m; ++i) {
        cin >> temp.from >> temp.to >> temp.w;
        temp.w = -temp.w + p;
        edges.push_back(temp);
    }
    for(int i = 0; i < 10000; ++i) dist[i] = 0x3f3f3f3f;
    dist[1] = 0;
    bool negLoop = false;
    for(int i = 0; i < 2*n ; ++i) {
        for(int j = 0; j < edges.size(); ++j) {
            if(dist[edges[j].from] < 0x3f3f3f3f && dist[edges[j].from] + edges[j].w < dist[edges[j].to]) {
                dist[edges[j].to] = dist[edges[j].from] + edges[j].w;
                if(i >= n && edges[j].to == n) negLoop = true; 
            }
        }
    }
    if(negLoop || dist[n] == 0x3f3f3f3f) cout << -1 << endl;
    else cout << max(0ll, -dist[n]) << endl;
    return 0;
}

Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class BOneClue {
public:
    int K, X;
    vector<int> ans;

    void solve(std::istream& in, std::ostream& out) {
        in >> K >> X;
        for (int i = X - K + 1; i < X + K; ++i) {
            if (-1000000 <= i && i <= 1000000) ans.push_back(i);
        }
        for (int i = 0; i < ans.size(); i++) {
            if (i != ans.size() - 1) out << ans[i] << " ";
            if (i == ans.size() - 1) out << ans[i] << endl;
        }
    }
};


int main() {
    BOneClue solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main(){

	while(1){
		int x, y;
		cin>>x>>y;
		if(x == 0 && y == 0) break;		

		if(x > y) swap(x, y);
		cout<<x<<" "<<y<<endl;
	}

	return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PN printf("\n")
#define MODV 1000000007


typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
void addmod(int &a, ll b){a=(a+b); if(a>=MODV)a-=MODV;}
void mulmod(int &a, ll b){a=(a*b)%MODV;}
template<class T>bool domin(T &a, const T &b){return a>b?a=b,1:0;}
template<class T>bool domax(T &a, const T &b){return a<b?a=b,1:0;}
int gi(){int a;scanf("%d",&a);return a;}
ll gll(){ll a;scanf("%lld",&a);return a;}

typedef pair<ll,ll> pll;


int main() {
  ll k=gll();
  int n=50;
  vll a(50,49);
  ll inc=k/n;
  ll t=inc*n;
  for(int i=0;i<n;i++){
    a[i]+=t;
    a[i]-=(t-inc);
  }
  ll r=k%n;
  for(int i=0;i<n && r>0;i++){
    if(i<r){
      a[i]+=n;
      a[i]-=(r-1);
    }else{
      a[i]-=r;
    }
  }
  cout<<n<<endl;
  for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
  }
  cout<<endl;



  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

template<typename T>
struct LazySegTree {
	vector<T> node, lazy;
	vector<bool> done;
	int n;
	T init_val;
	
	LazySegTree(int _n, T init_val) : init_val(init_val) {
		n = 1;
		while (n < _n) n *= 2;
		node.resize(n * 2 - 1, init_val);
		lazy.resize(n * 2 - 1);
		done.resize(n * 2 - 1, true);
	}
	
	void eval(int k, int l, int r) {
		if (done[k]) return;
		node[k] = lazy[k];
		
		if (r - l > 1) {
			lazy[k * 2 + 1] = lazy[k]; done[k * 2 + 1] = false;
			lazy[k * 2 + 2] = lazy[k]; done[k * 2 + 2] = false;
		}
		done[k] = true;
	}
	
	void update(int a, int b, T x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		
		if (a >= r || b <= l) return;
		if (a <= l && r <= b) {
			lazy[k] = x; done[k] = false;
			eval(k, l, r);
		}
		else {
			update(a, b, x, k * 2 + 1, l, (l + r) / 2);
			update(a, b, x, k * 2 + 2, (l + r) / 2, r);
			node[k] = min(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	
	T query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		
		if (a >= r || b <= l) return init_val;
		if (a <= l && r <= b) return node[k];
		
		T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	
	LazySegTree<ll> st(n, (1ll<<31) - 1);
	
	while (q--) {
		int a, b, c, d;
		cin >> a >> b >> c;
		if (a == 0) {
			cin >> d;
			st.update(b, c + 1, d);
		}
		else {
			cout << st.query(b, c + 1) << endl;
		}
	}
	return 0;
}

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

int main(){
  string s,c,ans,a,b; a=""; b="";
  int q,t,f,m; m=0; //mが奇数なら反転状態

  cin>>s>>q;
  ans=s;
  
  rep(i,q){
    cin>>t;
    if(t==1){
      m++;    
    }
    else{
      cin>>f>>c;
      if((m+f)%2==1) a=c+a;
      else b=b+c;
    }

  }
  
  if(m%2==0) cout<<a<<ans<<b;
  

  
  else{
    int n=ans.length();
    ans=a+ans; ans=ans+b;
    reverse(ans.begin(), ans.end());
    cout<<ans;
  }

}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


int main(){

    int n;
    cin>>n;
    map<string,int>mp;
    rep(i,n){
        string s;
        cin>>s;
        auto it=mp.find(s);
        if(mp.find(s)==mp.end()){
            mp.emplace(s,1);
        }
        else{
            it->second++;
        }
    }
    auto iter=mp.begin();
    int ma=0;
    while(iter!=mp.end()){
        ma=max(ma,iter->second);
        iter++;
    }
    iter=mp.begin();
    while(iter!=mp.end()){
        if(iter->second==ma){
            cout<<iter->first<<endl;
        }
        iter++;
    }



    return 0;

}
/*


*/


Measured memory_bytes: 25216
import java.util.Scanner;

public class Main {
    //彼女と上野動物園デートして一緒にシロフクロウを眺めたい（彼女いない）
    final static int[] MtoD={0,31,29,31,30,31,30,31,31,30,31,30,31};
    final static String[] DtoS={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int M,D,sumD;
        while(true){
            M=sc.nextInt();
            D=sc.nextInt();
            if(M==0&&D==0)break;
            sumD=D+2;
            for(int i=1;i<M;i++){
                sumD+=MtoD[i];
            }
            System.out.println(DtoS[sumD%7]);
        }
    }
}

Measured memory_bytes: 17404
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, minus, plus;
  cin >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i < 0) minus++;
    else if (i > 0) plus++;
    else {
      cout << "Zero" << endl;
      return 0;
    }
  }
  if (minus % 2 == 0) cout << "Positive" << endl;
  else cout << "Negative" << endl;
}

Measured memory_bytes: 256
/**
* Think twice, code once.
* 1.integer overflow(maybe even long long overflow : (a+b >= c) -> (a >= c-b)
* 2.runtime error
* 3.boundary condition
* ---------------------------------------------------------------------------------------
* Author : zzy
* Date : 2020-03-28-20.56.15 Saturday
*/
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 maxn = (i64)1e5+1000;
i64 x, y, a, b, c, A[maxn], B[maxn], C[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> x >> y >> a >> b >> c;
    forn(i, a) cin >> A[i];
    forn(i, b) cin >> B[i];
    forn(i, c) cin >> C[i];
    sort(A, A+a, [&](i64 n1, i64 n2) {
            return n1>n2;
         });
    sort(B, B+b, [&](i64 n1, i64 n2) {
            return n1>n2;
         });
    multiset<i64> mts;
    i64 sum = 0;
    forn(i, x) {
        mts.insert(A[i]);
        sum += A[i];
    }
    forn(i, y) {
        mts.insert(B[i]);
        sum += B[i];
    }
    forn(i, c) {
        i64 num = *mts.begin();
        if (num < C[i]) {
            sum -= num;
            sum += C[i];
            mts.erase(mts.begin());
            mts.insert(C[i]);
        }
    }
    cout << sum << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 11008
N, M = map(int, input().split())
lst_AB = sorted([tuple(map(int, input().split())) for _ in range(N)])

ans = 0
for AB in lst_AB:
    A, B = AB[0], AB[1]
    if M >= B:
        ans += A*B
        M -= B
    else:
        ans += A*M
        M -= M
print(ans)


Measured memory_bytes: 17756
# ABC109c
from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
diff = []
for i in range(1, n+1):
    diff.append(x[i]-x[i-1])
# print(diff)


def gcds(*numbers):
    return reduce(gcd, numbers)


print(gcds(*diff))


Measured memory_bytes: 16276
#include<bits/stdc++.h>
using namespace std;
int dp[405][405];
int n,A,B,a[50],b[50],c[50],ans=1e9;
int main()
{
	for(int i=0;i<405;i++)for(int j=0;j<405;j++)dp[i][j]=1e9;
	cin>>n>>A>>B;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
	dp[0][0]=0;
	for(int i=0;i<n;i++)
		for(int x=400;x>=a[i];x--)
			for(int y=400;y>=b[i];y--)
				dp[x][y]=min(dp[x][y],dp[x-a[i]][y-b[i]]+c[i]);
	int x=A,y=B;
	while(x<=400&&y<=400)
	{
		ans=min(ans,dp[x][y]);
		x+=A;
		y+=B;
	}
	if(ans==1e9)cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 896
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		ArrayList<String> al = new ArrayList<String>();
		int a = sc.nextInt();
		for(int i = 0; i < a; i++) {
			al.add(sc.next());
		}
		ArrayList<String> al2 = new ArrayList<String>(new HashSet<>(al));
		System.out.println(al2.size());
	}
}

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

int main() {
  string S, S1, S2;
  int A, B;
  cin >> S;
  S1 = S.substr(0,2);
  S2 = S.substr(2,2);
  A = stoi(S1);
  B = stoi(S2);
  
  if (A <= 12 && A != 0 && B <= 12 && B != 0){
    cout << "AMBIGUOUS" << endl;
  }
  else if ((B > 12 || B ==0) && (A > 12 || A ==0)){
    cout << "NA" << endl;
  }
  else if (A > 12 || A ==0){
    cout << "YYMM" << endl;
  }
  else {
    cout << "MMYY" << endl;
  }
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
lst = list(map(int,input().split()))
c = Counter(lst)
res = 0
for k,v in c.items():
    if v >= 2:
        res += v*(v-1)//2
for x in lst:
    if c[x]<2:
        print(res)
    else:
        print(res - (c[x] - 1))

Measured memory_bytes: 26908
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int nmax = 2000;
vvll combi(nmax+1,vll(nmax+1,0));
void combination(){
    for(int i=1;i<=nmax;i++){
        combi[i][0]=1LL;
        for(int j=1;j<=i-1;j++){
            combi[i][j]=combi[i-1][j]+combi[i-1][j-1];
            combi[i][j]%=mod;
        }
        combi[i][i]=1LL;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    combination();
    for(int i=1;i<=k;i++){
        ll tmp=combi[n-k+1][i];
        ll tmp2=combi[k-1][i-1];
        if(k==1){
            tmp2=1;
        }
        tmp*=tmp2;
        tmp%=mod;
        cout << tmp << endl;
    }

    return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

template<typename T> bool chmin(T &a,const T b){if(a>b){a=b; return true;}return false;}
template<typename T> bool chmax(T &a,const T b){if(a<b){a=b; return true;}return false;}

int N;
vi bit;

int sum(int id){
    int res=0;
    while(id > 0){
        res+=bit[id];
        id-=(id&-id);
    }
    return res;
}

void add(int id, int x){
    while(id <= N){
        bit[id]+=x;
        id+=(id&-id);
    }
    return;
}

int main(){
    int Q; cin >> N >> Q;
    bit.assign(N+1, 0);
    vi c(N+1);
    for(int i=1; i<=N; i++) cin >> c[i];
    vi l(Q), r(Q);
    for(int i=0; i<Q; i++){
        cin >> l[i] >> r[i];
    }

    vi ids(Q);
    for(int i=0; i<Q; i++) ids[i]=i;
    sort(all(ids), [&](int i, int j){return r[i] < r[j];});

    vi pos(N+1, -1), ans(Q);
    int prev=0, cur=0;
    for(int i=0; i<Q; i++){
        cur=r[ids[i]];
        for(int j=prev+1; j<=cur; j++){
            if(pos[c[j]] != -1){
                add(pos[c[j]], -1);
            }
            pos[c[j]]=j;
            add(pos[c[j]], 1);
        }
        ans[ids[i]]=sum(r[ids[i]])-sum(l[ids[i]]-1);
        prev=cur;
    }
    
    for(auto &x : ans) cout << x << endl;
    return 0;
}

Measured memory_bytes: 17404
#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,len;
    char s[10000],b='Z';
    scanf("%d ",&n);
    gets(s);
    len=strlen(s);
    for(i=0;i<len;i++)
    {
        s[i]+=n;
        if(s[i]>=91)
            s[i]+=6;
        if(s[i]>='a'&&s[i]<='z')
            s[i]-=32;
    }

    puts(s);
    return 0;
}

Measured memory_bytes: 128
fn main() {
    let (a, _): (usize, usize) = readln();
    let s: String = readln();
    let vs = s.chars().enumerate().filter(|&(_, c)| !c.is_digit(10)).collect::<Vec<_>>();
    let ans = if vs.len() == 1 && vs[0].0 == a {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}

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

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


Measured memory_bytes: 4352
W, H, N = (int(i) for i in input().split())
p1 = [0,0]
p2 = [W,0]
p3 = [0,H]
p4 = [W,H]
for i in range(N):
    x, y, a = (int(i) for i in input().split())
    if a == 1:
        p1[0] = max(p1[0],x)
        p2[0] = max(p2[0],x)
        p3[0] = max(p3[0],x)
        p4[0] = max(p4[0],x)
    elif a == 2:
        p1[0] = min(p1[0],x)
        p2[0] = min(p2[0],x)
        p3[0] = min(p3[0],x)
        p4[0] = min(p4[0],x)
    elif a == 3:
        p1[1] = max(p1[1],y)
        p2[1] = max(p2[1],y)
        p3[1] = max(p3[1],y)
        p4[1] = max(p4[1],y)
    elif a == 4:
        p1[1] = min(p1[1],y)
        p2[1] = min(p2[1],y)
        p3[1] = min(p3[1],y)
        p4[1] = min(p4[1],y)
print(abs(p2[0]-p1[0]) * abs(p4[1]-p2[1]))

Measured memory_bytes: 38256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int N;
	cin >> N;
	
	for (int i = 0; i < N; i++) {
		int a[10];
		bool success = false;
		for (int j = 0; j < 10; j++) scanf("%d", &a[j]);
		int len = 1 << 10;
		for (int j = 0; j < len; j++) {
			vector<int> u;
			vector<int> v;
			for (int k = 0; k < 10; k++) {
				if (j >> k & 1) u.push_back(a[k]);
				else v.push_back(a[k]);
			}
			
			bool x = is_sorted(u.begin(), u.end());
			bool y = is_sorted(v.begin(), v.end());
			if (x && y) {
				printf("YES\n");
				success = true;
				break;
			}
		}
		
		if (!success) {
			printf("NO\n");
		}
	}
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

vector<int> v;

bool isOK(int index, int key) {
    if (v[index] >= key) return true;
    else return false;
}

int binary_search(int key) {
    int left = -1; 
    int right = (int)v.size(); 

    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key)) right = mid;
        else left = mid;
    }

    return right;
}

int main()
{
    int n;
    cin >> n;
    ll a_sum = 0, b_sum = 0;
    ll a[n],b[n];
    ll dif[n];

    for(int i = 0; i < n; i++){
        cin >> a[i];
        a_sum += a[i];
    }
    for(int i = 0; i < n; i++){
        cin >>  b[i];
        b_sum += b[i];
    }
    if(a_sum < b_sum){
        cout << -1 << endl;
    }else{
        vector<ll> plus;
        ll sum = 0;
        int ans = 0;
        for(int i = 0; i < n; i++){
            dif[i] = a[i] - b[i];
            if(dif[i] < 0){
                sum -= dif[i];
                ans++;
            }else if(dif[i] > 0){
                plus.push_back(dif[i]);
            }
        }
        bool all = true;
        for(int i = 0; i < n; i++){
            if(dif[i] < 0) all = false;
        }
        if(all) {
            cout << 0 << endl;
            return 0;
        }
        int s = plus.size();
        sort(plus.begin(),plus.end());
        for(int i = s-1; i >= 0; i--){
            if(sum <= 0){
                break;
            }else{
                sum-=plus[i];
                ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#define PI acos(-1)
#define fs first
#define sc second
#define MAX 0x3f3f3f3f
#define debug freopen("1.in","r",stdin),freopen("1.out","w",stdout);
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll k = 1e9 + 7;

ll N, res;
ll qpow(ll m, ll k, ll p){
    ll res = 1 % p;
    while (k){
        if (k&1) res = res * m % p;
        m = m * m % p;
        k >>= 1;
    }
    return res;
}
int main(){
    ios;
    cin >> N;
    res = ((qpow(10, N, k) % k + qpow(8, N, k) % k - (2 * (qpow(9, N, k) % k)) % k) + k) % k;
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n;
    cin >> n;
    vec a(n);
    loop(i, n) cin >> a[i];
    sort(all(a));
    map<ll, ll> count;
    map<ll, bool> ok;
    loop(i, n) count[a[i]]++;
    loop(i, n) ok[a[i]] = true; //初期化
    loop(i, 1000000)
    {
        ll now = i + 1;
        if (ok[now] == false)
            continue;
        ll cc = 2;
        while (now * cc <= 1000000)
        {
            ok[now * cc] = false;
            cc++;
        }
    }
    ll ans = 0;
    loop(i, n)
    {
        if (ok[a[i]] && count[a[i]] == 1)
        {
            ans++;
        }
    }
    putout(ans);
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  LL ki=0,gu=0;
  vector<LL> a(n);
  vector<bool> kiused(n,false),guused(n,false);
  bool neg=true;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(i%2){
      if(a[i]>=0){
        ki+=a[i];
        kiused[i]=true;
        neg=false;
      }
    }else{
      if(a[i]>=0){
        gu+=a[i];
        guused[i]=true;
        neg=false;
      }
    }
  }
  if(neg){
    LL mi=-1000000000;
    int pos;
    for(int i=0;i<n;i++){
      if(a[i]>mi){
        mi=a[i];
        pos=i;
      }
    }
    cout << mi << endl;
    cout << n-1 << endl;
    for(int i=n-1;i>pos;i--){
      cout << i+1 << endl;
    }
    for(int i=0;i<pos;i++){
      cout << 1 << endl;
    }
  }else{
    int count=0;
    int i,pre;
    if(ki>gu){
      cout << ki << endl;
      for(i=n-1;!kiused[i];i--) count++;
      pre=i;
      for(;i>=0;i--){
        if(kiused[i]){
          for(int j=(i+pre)/2;j>i;j--) count++;
          pre=i;
        }
      }
      for(int j=0;j<pre;j++) count++;
      cout << count << endl;
      for(i=n-1;!kiused[i];i--) cout << i+1 << endl;
      pre=i;
      for(;i>=0;i--){
        if(kiused[i]){
          for(int j=(i+pre)/2;j>i;j--) cout << j+1 << endl;
          pre=i;
        }
      }
      for(int j=0;j<pre;j++) cout << 1 << endl;
    }else{
      cout << gu << endl;
      for(i=n-1;!guused[i];i--) count++;
      pre=i;
      for(;i>=0;i--){
        if(guused[i]){
          for(int j=(i+pre)/2;j>i;j--) count++;
          pre=i;
        }
      }
      for(int j=0;j<pre;j++) count++;
      cout << count << endl;
      for(i=n-1;!guused[i];i--) cout << i+1 << endl;
      pre=i;
      for(;i>=0;i--){
        if(guused[i]){
          for(int j=(i+pre)/2;j>i;j--) cout << j+1 << endl;
          pre=i;
        }
      }
      for(int j=0;j<pre;j++) cout << 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long s = 0L;
        Map<Long, Integer> map = new HashMap<Long, Integer>();
        map.put(0L, 1);
        long ans = 0L;
        for (int i = 0; i < n; i++) {
            s += sc.nextLong();
            if(!map.containsKey(s)) map.put(s, 1);
            else map.put(s, map.get(s) + 1);
        }
        for(Entry<Long, Integer> e : map.entrySet()){
            if(1 < e.getValue()){
                ans += ((long)e.getValue() * (long)(e.getValue()-1)) / 2L;
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 100884
#include<stdio.h>
int min(int x,int y){
    return (x < y) ? x : y;
}
int main(void){
    int a,b,c,d,e;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    printf("%d\n",min(a,min(b,c))+min(d,e)-50);
    return 0;
} 

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

int main() {
    int n, y;
    cin >> n >> y;
    for(int i=0; i<n+1; i++){
        for(int j=0; i+j<n+1; j++){
            int sum = 10000*i + 5000*j + 1000*(n-i-j);
            if(sum == y){
                cout << i << ' ' << j << ' ' << n-i-j;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c, x = int(input()), int(input()), int(input()), int(input())
ans = 0
for i in range(a + 1):
    for f in range(b + 1):
        for j in range(c + 1):
            if 500 * i + 100 * f + 50 * j == x:
                ans += 1

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>

using namespace std;

int n, x;
int main(){
    cin >> n;
    for(int i = 3; i <= n; ++i){
        x = i;
        if(!(x % 3)){
            cout << " " << i;
        }else{
            do{
                if(x % 10 == 3) { cout << " " << i; break; }
                x /= 10;
            }while(x);
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
    int H,W,a,b;
    cin >> H >> W >> a >> b;
    cout << (H-a)*(W-b) << endl;
    return 0;
}

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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"

long double nn;

int main(){
	cin>>nn;
	long double sayi = (double)((double)nn*nn*nn/27.0);
	cout << setprecision(32) << sayi << endl;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
const ll mod = 1000000007;
const ll OO = (ll)1e18;
const int dx[] = { 0, 1, -1, 0 };
const int dy[] = { 1, 0, 0, -1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(ll base, ll power){
	if (power == 1) return base;
	if (power % 2 == 0) return fast_power((base*base), power / 2);
	else return(base*fast_power((base*base), power / 2));
}
//#pragma warning (disable : 4996)
void Qalbaz()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(2);
	
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int a, b;
	cin >> a >> b;
	char x;
	for (int i = 0; i < a; i++)
	{
		cin >> x;
		if (x >= '0' && x <= '9')
			continue;
		cout << "No";
		return 0;
	}
	cin >> x;
	if (x != '-')
	{
		cout << "No";
		return 0;
	}
	for (int i = 0; i < b; i++)
	{
		cin >> x;
		if (x >= '0' && x <= '9')
			continue;
		cout << "No";
		return 0;
	}
	cout << "Yes";
	return 0;
}

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

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

 int count=0;

for(int i=0;i<S.size()/2;i++){
 if(S.at(i)==S.at(S.size()-i-1)){
   continue;
 }

 else{
   count++;
 }
}

cout << count << endl;

}

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

int main()
{
	int N;
	std::vector<uint64_t> A;

	std::cin >> N;

	A.resize(N);
	uint64_t limit = std::pow(10, 18);
	uint64_t answer = 1;
	for (int i = 0; i < N; i++)
	{
		std::cin >> A[i];
		if (A[i] == 0)
		{
			std::cout << 0;
			return 0;
		}
	}
	
	for (int i = 0; i < N; i++)
	{
		if (answer <= (limit / A[i]))
		{
			answer *= A[i];
		}
		else
		{
			std::cout << -1;
			return 0;
		}
	}

	std::cout << answer;

	return 0;
}


Measured memory_bytes: 4056
unittest
{
	assert( [ "2 3", "abc", "arc" ].parse.expand.solve == "#####\n#abc#\n#arc#\n#####" );
	assert( [ "1 1", "z" ].parse.expand.solve == "###\n#z#\n###" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hw = input.front.split.to!( long[] );
	auto ass = new string[ hw[ 0 ] ];
	foreach( ref as; ass )
	{
		input.popFront;
		as = input.front.strip;
	}
	return tuple( ass );
}

auto solve( string[] ass )
{
	// 左右の枠を付ける
	foreach( ref as; ass )
	{
		as = "#" ~ as ~ "#";
	}
	
	// 上下の枠を付ける
	auto tb = '#'.repeat( ass[ 0 ].length ).to!string;
	ass = tb ~ ass ~ tb;
	
	return ass.join( "\n" );
}


Measured memory_bytes: 380
#include <iostream>
using namespace std;
int main(void) {
	int n;
	while(cin >> n, n) {
		int one, two;
		one = two = 0;
		for(int i = 0; i < n; i++) {
			int x;
			cin >> x;
			if(x >= 1) {
				if(x >= 2)
					two++;
				one++;
			}
		}
		if(two) {
			cout << one + 1 << endl;
		} else {
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 1160
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

#[fastout]
fn main() {
    input! {
        n: usize,
        xyu: [(isize, isize, char); n],
    }
    let mut xyu: Vec<(isize, isize, char)> = xyu.clone();

    let mut collision_time = 99999999;
    macro_rules! collision_check {
        ($main_coord:expr, $sub_coord:expr, $plus_dir:expr, $minus_dir:expr) => {
            xyu.sort_unstable_by_key(|&tr| ($sub_coord(tr), $main_coord(tr)));
            let mut nowsub = 0;
            let mut prevmain: Option<isize> = None;
            for &tr in &xyu {
                if nowsub != $sub_coord(tr) {
                    nowsub = $sub_coord(tr);
                    prevmain = None;
                }
                if tr.2 == $plus_dir {
                    prevmain = Some($main_coord(tr));
                } else if tr.2 == $minus_dir {
                    match prevmain {
                        None => {}
                        Some(mm) => {
                            let coltime = ($main_coord(tr) - mm) * 5;
                            collision_time = collision_time.min(coltime);
                        }
                    }
                    prevmain = None;
                }
            }
        };
    }
    let xclosure = |(x, y, u)| x;
    let yclosure = |(x, y, u)| y;
    let vclosure = |(x, y, u)| x + y;
    let wclosure = |(x, y, u)| x - y;

    collision_check!(yclosure, xclosure, 'U', 'D');
    collision_check!(xclosure, yclosure, 'R', 'L');
    collision_check!(vclosure, wclosure, 'U', 'L');
    collision_check!(wclosure, vclosure, 'R', 'U');
    collision_check!(vclosure, wclosure, 'R', 'D');
    collision_check!(wclosure, vclosure, 'D', 'L');
    if collision_time < 10000000 {
        println!("{}", collision_time);
    } else {
        println!("SAFE");
    }
}


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

int main(){
    vector<int> a(10000);
    for(int i = 0; i < a.size(); i++){
        cin >> a[i];
        if(a[i] == 0) break;
    }
    for(int i = 0; i < a.size(); i++){
        if(a[i] == 0) break;
        cout << "Case " << i + 1 << ": " << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<cstring>

using namespace std;
typedef long long ll; 
const ll N = 5005;
const ll mod = 1e9+7;  
ll n,k;
ll f[N],h[N],a[N],sum[N];

int main(){
//	memset(sum,0,sizeof(sum));
//	memset(f,0,sizeof(f));
//	memset(h,0,sizeof(h));
//	memset(a,0,sizeof(a));
	cin>>n>>k;
	for(ll i=1;i<=n;i++) cin>>a[i];
	for(ll i=1;i<=n;i++){
		for(ll j=i+1;j<=n;j++){
			if(a[i]>a[j]) h[i]++;
		}
		for(ll j=1;j<i;j++){
			if(a[i]>a[j]) f[i]++;
		} 
		sum[i]=f[i]+h[i];
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ans=((ans+(sum[i]*((k-1)*k/2%mod)%mod)%mod)%mod+h[i]*k)%mod;
	}
	cout<<ans%mod<<endl;
	
	return 0;
} 

Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
#include<set>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (c < a) {
		if (d <= a) {
			cout << 0 << endl;
		}
		else if (d <= b) {
			cout << d - a << endl;
		}
		else {
			cout << b - a << endl;
		}
	}
	else if (c < b) {
		if (d <= b) {
			cout << d - c << endl;
		}
		else {
			cout << b - c << endl;
		}
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    num, a, b = map(int, input().split())

    cockie = 1
    i = 0
    while i < num:
        if b - a > 2:
            if cockie >= a:
                if i <= num - 2:
                    cockie += (b - a) * ((num - i) // 2)
                    i += ((num - i) // 2) * 2
                else:
                    cockie += num - i
                    i += num - i
            else:
                i += a - cockie
                cockie += a - cockie
        else:
            cockie += num
            i += num

    print(cockie)





if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <stdio.h>
int isprime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0)  return 0;
    }
    return 1;
}

int main(){
    int n, p1 = 0,i;
    while (1) {
        scanf("%d", &n);
        if(n==0) break;
        for(i = n; i >=2; i--){
            if(isprime(i - 2)&& isprime(i)/*&&p1<i*/){
                printf("%d %d\n", i - 2, i);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1816
import numpy as np
h,w=map(int,input().split())
a=[list(map(int,input().replace(".","0").replace("#","1"))) for i in range(h)]
a=np.array(a)
c=np.sum(a,axis=1)
a=a[c!=0]
c=np.sum(a,axis=0)
a=a.T[c!=0].T
for i in a.tolist():
    tmp=list((map(lambda x:"." if x==0 else "#",i)))
    print("".join(tmp))
    

Measured memory_bytes: 12740
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
     
    public class Program
    {
        public void Proc() {
            Reader.IsDebug = false;
            int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();

            int rectWidth = inpt[0];

            int pos1 = Math.Min(inpt[1], inpt[2]);
            int pos2 = Math.Max(inpt[1], inpt[2]);

            int ans = Math.Max(0, pos2-(pos1+rectWidth));

            Console.WriteLine(ans);


        }

        public class Reader {
            public static bool IsDebug = true;
            private static System.IO.StringReader SReader;
            private static string InitText = @"


5 10 1




";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_parityll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   deque<char> dq;
   bool fr = 0;
   string s;
   cin>>s;
   
   rep(s.length())
        dq.pb(s[i]);
   ll q;
   cin>>q;
   ll n = s.length();
   
   while(q--)
   {
       ll t;
       cin>>t;
       
       if(t == 1)
       {
           fr^=1;
           continue;
       }
       ll f;
       n++;
       cin>>f;
       char c;
       cin>>c;
       if(f == 1)
       {
           if(fr == 0)
                dq.push_front(c);
           else dq.pb(c);        
       }
       
       else
       {
           if(fr == 0)
                dq.pb(c);
           else dq.push_front(c);        
       }
       
   }
   
   if(fr)
   {
       for(ll i=n-1;i>-1;i--)
            cout<<dq.at(i);
   }
   
   else
   {
       rep(n)
            cout<<dq.at(i);
   }
   
   
   
   return 0;        
}  
   

Measured memory_bytes: 976