akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


ll digit(ll num){
	ll ret=0;
	string s=to_string(num);
	return s.length();
}
	
class Edge{
public:
	ll num;
	ll a;
	ll b;
	ll color=0;
	Edge(ll _num,ll _a,ll _b){
		num=_num;
		a=_a;
		b=_b;
	}
};
	
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll l,r;
	cin>>l>>r;
	if(r-l>=3000){
		cout<<0<<endl;
		return 0;
	}
	ll ans=INF;
	for(ll i=l;i<r;i++){
		for(ll j=i+1;j<=r;j++){
			ans=min(ans,(ll)(i*j)%2019);
		}
	}
	cout<<ans<<endl;
	//return 1;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
s = [int(x) for x in input().split()]

c = Counter(s)

c = sorted(c.items())

max1 = 0
max2 = 0
max3 = 0

for i in range(len(c)):
    if c[i][1] >= 2:
        if c[i][0] >= max2:
            if c[i][0] >= max1:
                max2 = max1
                max1 = c[i][0]
            else:
                max2 = c[i][0]

    if c[i][1] >= 4:
        max3 = c[i][0]

if max2 == 0:
    print("0")
else:
    print(max(max1*max2, max3**2))

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

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class FSugoroku {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        ll n,m;cin >> n >> m;
        string s;cin >> s;

        int i = n;
        vector<int> path;
        while(i > 0){
            bool ok = false;
            int l;
            for(int j = m;j >= 1;j--){
                if(i - j < 0)continue;
                if(s[i - j] == '0'){
                    path.pb(j);
                    l = j;
                    ok = true;
                    break;
                }
            }
            if(!ok){
                cout << -1 << endl;
                return;
            }else{
                i -= l;
                continue;
            }
        }

        reverse(all(path));
        rep(i,path.size()) cout << path[i] << " ";
        cout << endl;
    }
};

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


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

// <editor-fold>

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
// vector出力
template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}
// vector入力
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}
struct Pos {
  int x, y;
};
// 任意の個数の変数をスペース区切りで出力します
void dump() {
  cout << endl;
}
template <class Head, class... Tail>
void dump(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(Tail) != 0)
    cout << " ";
  dump(std::move(tail)...);
}
#define YES(n) printf("%s\n", ((n) ? "YES" : "NO"));
#define Yes(n) printf("%s\n", ((n) ? "Yes" : "No"));
#define yes(n) printf("%s\n", ((n) ? "yes" : "no"));

template <typename Head, typename Value>
auto vectors(const Head& head, const Value& v) {
  return vector<Value>(head, v);
}

template <typename Head, typename... Tail>
auto vectors(Head x, Tail... tail) {
  auto inner = vectors(tail...);
  return vector<decltype(inner)>(x, inner);
}
// </editor-fold>

int main() {
  int n, m;
  cin >> n >> m;
  int a, b;
  vector<vector<int> > v(n, vector<int>());
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  bool can = false;
  for (int i = 0; i < v[0].size(); i++) {
    int now = v[0][i];
    if (count(v[now].begin(), v[now].end(), n - 1)) can = true;
  }
  cout << (can ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 12016
a,b,c,x,y = map(int,input().split())

#貪欲で全てのケースを用意する。

ans = 0

ans += a*x + b*y

if x <= y:
    s = x*c*2
    m = (y-x)*b
    ans = min(ans,s+m)
else:
    s = y*c*2
    m = (x-y)*a
    ans = min(ans,s+m)

ans = min(ans,max(x,y)*c*2)

print(ans)

Measured memory_bytes: 38256
N = int(input())
a = 0

if N>=100:
    a = N % 100
    if N >= 10:
        a = a % 10
elif N >= 10:
    a = N % 10
else:
    a = N

if a == 0:
    print("pon")
elif a == 1:
    print("pon")
elif a == 6:
    print("pon")
elif a == 8:
    print("pon")
elif a == 3:
    print("bon")
else:
    print ("hon")

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

int main() {
  int N;
  cin >> N;
  
  bool flag=0;
  
  for(int i = 0; i<N ;i++){
    string S;
    cin>>S;

    if (S=="Y"){
      cout<<"Four"<<endl;
      flag=1;
      break;
    }
  }
  if (flag==0){
    cout<<"Three"<<endl;
  }
  

  // ここにプログラムを追記
}


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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    REP(i, H) { cin >> S[i]; }

    int ans = 0;
    vector<vector<int>> h(H, vector<int>(W, 0)), v(H, vector<int>(W, 0));
    REP(i, H) {
        int j = 0;
        int count = 0;
        while (j <= W) {
            if (j == W || S[i][j] == '#') {
                REP(k, count) { h[i][j - k - 1] = count; }
                count = 0;
            } else {
                count++;
            }
            j++;
        }
    }
    REP(j, W) {
        int i = 0;
        int count = 0;
        while (i <= H) {
            if (i == H || S[i][j] == '#') {
                REP(k, count) ans = max(h[i - k - 1][j] + count - 1, ans);
                count = 0;
            } else {
                count++;
            }
            i++;
        }
    }
    cout << ans << "\n";
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string x;
  cin >> x;
  if (s == x)
    cout << a - 1 << " " << b << endl;
  else
    cout << a << " " << b - 1 << endl;
}


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

using namespace std;

int main(void) {
    int k, a, b;
    cin >> k >> a >> b;

    int n = 1;
    while(n*k <= b) {
        n++;
    }

    cout << ((n-1)*k >= a ? "OK" : "NG") << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<llint, llint>Pii;
typedef pair<double, double>Pdd;

#define pi 3.141592653589793)
#define mod 1000000007

int main() {
	int n;
	cin >> n;
	vector<int>x(n);
	for (int i = 0; i < n; i++)cin >> x[i];
	vector<int>a = x;
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		int res;
		if (a[n / 2 - 1] < x[i])res = a[n / 2 - 1];
		else if (a[n / 2 - 1] == x[i])res = a[n / 2];
		else if (a[n / 2] > x[i])res = a[n / 2];
		else if (a[n / 2] == x[i])res = a[n / 2 - 1];
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main(){

	double x1,y1,x2,y2,xq,yq;
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)){
		double vx = x2-x1;
		double vy = y2-y1;
		double lb=-10000000.0;
		double ub=10000000.0;
		double cx,cy,vqx,vqy,md;
		for(int i=0;i < 100; i++){
			md = (lb+ub)/2.0;
			cx = x1 + vx*md;
			cy = y1 + vy*md;
			vqx = cx - xq;
			vqy = cy - yq;
			double slope = vx * vqx + vy* vqy;
			if(slope < 0){
				lb = md;
			}
			else if(slope>0){
				ub = md;
			}
			if(abs(slope) < 10e-9){
				printf("%f %f\n",2.0*cx-xq,2.0*cy-yq);
				break;
			}
		}
	}
}

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

int n;
vector<int> h;

int main(){
	cin >> n;
  	for(int i=0;i<n;i++){
      	int x;
      	cin >>x;
    	h.push_back(x);
    }
  
/*  	int ans=0;
	int active=0;
  	for(int i=0;i<n;i++){
    	if(active>=h[i]){
        	active=h[i];
        }else{
        	ans+=h[i]-active;
          	active =h[i];
       	}
    }
  cout <<ans <<endl;
	*/
  	int v=0;
  	int E=0;
  	for(int i=0;i<n;i++){
    	v+=h[i];
    }
  	for(int i=1;i<n;i++){
    	E+=min(h[i-1],h[i]);
    }
  	cout <<v-E;
  	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<ll,ll>

using namespace std;
typedef long long ll;



int main(void) {
	int n, k; cin >> n >> k;
	vint a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	ll ans = 0;
	for (int i = k; i < n; i++) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
int main()
{
	int n,i,j,t;
	cin>>n;
	if(n%2==0) cout<<n/2;
	else cout<<n/2+1; 
 } 

Measured memory_bytes: 256
import numpy as np

N, M, K = map(int, input().split())

LR = np.zeros(shape=(N + 1, N + 1), dtype=np.int32)
for _ in range(M):
    L, R = map(int, input().split())
    LR[L, R] += 1

np.cumsum(LR, axis=0, out=LR)
np.cumsum(LR, axis=1, out=LR)

P, Q = np.array([input().split() for _ in range(K)], dtype=np.int32).T

P -= 1
ans = LR[Q, Q] - LR[P, Q] - LR[Q, P] + LR[P, P]
print(*ans, sep='\n')


Measured memory_bytes: 45828
S = input()
SL = [int(i) for i in S]
SL.append("A")
keepcount = "start"
count = 0
for i in SL:
        if keepcount == "start":
                keepcount = i
        elif keepcount == i:
                keepcount = i^1
                count += 1
        else:
                keepcount = i

print(count)

Measured memory_bytes: 3956
#include<stdio.h>

int main(void) {
	int A, B;
	scanf("%d %d", &A, &B);
	if (A >= 13) {
		printf("%d",B);
	}
	else if (A <= 12 && A >= 6) {
		printf("%d",B / 2);
	}
	else {
		puts("0");
	}

	return 0;
}

Measured memory_bytes: 128
/*
 1?2?3 % 13 =
(10000 % 13
+ ?000 % 13
+  200 % 13
+   ?0 % 13
+    3 % 13) % 13
 */

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

constexpr int MOD = 1e9 + 7;

constexpr int N = 13;

ll dp[2][N];

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

  int mul = 1;
  bool flip{false};
  dp[!flip][0] = 1;

  for (int i = S.length()-1; i >= 0; --i) {
    if (S[i] == '?') {
      for (int k{}; k < 10; ++k) {
        for (int j{}; j < N; ++j) {
          dp[flip][(k * mul + j) % N] += dp[!flip][j];
          dp[flip][(k * mul + j) % N] %= MOD;
        }
      }
    } else {
      int k = S[i] & 0xF;
      for (int j{}; j < N; ++j) {
        dp[flip][(k * mul + j) % N] += dp[!flip][j];
        dp[flip][(k * mul + j) % N] %= MOD;
      }
    }
    mul *= 10;
    mul %= N;
    flip = !flip;
    fill_n(dp[flip], N, 0);
  }
  cout << dp[!flip][5] << endl;
  return 0;
}


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

int main(){
    LL d, g;
    cin >> d >> g;
    const LL D = d, G = g;
    vector<LL> p(D+1), c(D+1);
    for(LL i = 1;i < D+1;i++){
        cin >> p[i] >> c[i];
    }
    LL ans = 1000;
    for(LL i = 0;i < 1<<D;i++){
        LL score = 0;
        LL num = 0;
        for(LL j = 0;j < D;j++){
            if(i&(1<<j)){
                score += p[j+1]*(j+1)*100+c[j+1];
                num += p[j+1];
            }
        }
        for(LL j = D-1;j >= 0;j--){
            if(num >= ans || score >= G)    break;
            if(!(i&(1<<j))){
                for(LL k = 1;k <= p[j+1];k++){
                    score += (j+1)*100;
                    num++;
                    if(num >= ans || score >= G){
                        j = D;
                        break;
                    }
                }
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
t=input()

count=0

if s==t:
  count=1

  
for i in range(len(s)):
  s = s[len(s)-1] + s[:len(s)-1]
  if s==t:
    count=1

    
if count==1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b,c;cin>>a>>b>>c;
  string ans="No";
  if(c>=a&&c<=b)ans="Yes";
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <utility>

int main(int argc, char *argv[]){
    int N;
    std::cin >> N;
    std::map<std::string, std::vector<std::pair<int,int> > >R;
    std::string S;
    int P;
    for(int i=1; i<=N; ++i){
        std::cin >> S >> P;
        R[S].emplace_back(std::pair<int,int>(i,P));
    }

    for(auto &S : R){
        auto s = S.second;
        std::sort(s.begin(),s.end(),[](auto &a, auto &b){return a.second > b.second;});
        for(auto &r : s){
            std::cout << r.first << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n, Y,y,b;cin >> n >> Y;
	b = n;y = Y / 1000;n -= y;n *= -1;
	for(int x = 0;x <= n;x++) {
		if ((n - 9 * x) % 4 == 0) {
			y = (n - 9 * x) / 4;
			if (y < 0 || b - x - y < 0) continue;
			cout << x << " " << y << " " << b - x - y << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n;
  int i,j,k;
  cin >> n;
  int s[105]={},r[105]={};
  P p[105];
  for(i=0;i<105;i++){
    p[i].first=0;
    p[i].second=i;
  }
  
  int a,b,c,d;
  for(i=0;i<n*(n-1)/2;i++){
    cin >> a >> b >> c >> d;
    if(c==d){
      p[a].first++;
      p[b].first++;
    }
    if(c<d){
      p[b].first+=3;
    }
    if(c>d){
      p[a].first+=3;
    }
  } 

  //  for(i=1;i<=n;i++) cout << p[i].first << endl;
  sort(p,p+105,greater<P>());
  k=1;
  for(i=0;i<105;i++){
    r[p[i].second]=k;
    j=1;
    while(i<105-1){
      if(p[i].first==p[i+1].first){
	i++;
	j++;
	r[p[i].second]=k;
	continue;
      }
      break;
    }
    k+=j;
  }
  for(i=1;i<=n;i++){
    cout << r[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
n = int(input())
arms = []
for _ in range(n):
  x, l = map(int, input().split())
  arms.append((x-l, x+l))
arms.sort(key=lambda x:x[1])

tmpx = arms[0][1]
ans = 1
for i in range(1, len(arms)):
  if tmpx <= arms[i][0]:
    ans += 1
    tmpx = arms[i][1]

print(ans)




Measured memory_bytes: 23948
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
const int INF = 1e9;
const double pi = acos(-1.0);
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    string t; cin >> t;
    rep(i,t.size())cout << ((t[i]=='?')?'D':t[i]);
    cout << endl;

    return 0;
}  

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

int main()
{
    string str;
    char ans[15];
    cin>>str;
    int cnt = 0;
    for(int i=0; i<str.length(); i++){
        if(str[i]=='B'){
            if(cnt!=0) cnt--;
            continue;
        }
        ans[cnt++] = str[i];
    }
    ans[cnt] = '\0';
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -10010
#define bql 2147483647
#define ll long long
#define maxn 100010
using namespace std;
int main(){
	fast;
	ll n,ans=0;
	cin>>n;
	int a[n+2];
	for(int i=1;i<=n+1;i++)cin>>a[i];
	int b[n+1];
	for(int i=1;i<=n;i++)cin>>b[i];
	for(int i=1;i<=n;i++){
		for(int j=i;j<=i+1;j++){
			if(b[i]!=0&&b[i]>=a[j]){
				b[i]-=a[j];
				ans+=a[j];
				a[j]=0;
			}
			else if(b[i]!=0&&b[i]<a[j]){
				ans+=b[i];
				a[j]-=b[i];
				b[i]=0;
			}
			else{}
		}
	}
	cout<<ans<<endl;
	return 0;
}/*『你强归你强，我用不示弱』*/


Measured memory_bytes: 1024
N, Y = gets.split.map(&:to_i)

YY = (Y - 1000 * N) / 1000
# 9 a + 4 b = YY
# a + b <= N

answer = false
for x in 0..N
    for y in 0..(N-x)
        if 9 * x + 4 * y == YY
            z = N - x - y
            print [x,y,z].join(" ")
            exit
        end
    end
end
print "-1 -1 -1"

Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] pos = new int[n];//pos[数字]=n番目

        for(int i = 0; i < n; i++) {//pはi個目にある
            int p = sc.nextInt()-1;
            pos[p] = i;
        }

        int ans = 0;
        boolean isUpping = true;
        int count = 0;
        for(int i = 0; i < n-1; i++) {
            int num = i;
            int next = i+1;
            if(isUpping) {
                if(pos[num] < pos[next]) {
                    count++;
                    ans = Math.max(ans, count);
                } else {
                    isUpping = false;
                    ans = Math.max(ans, count);
                    count = 1;
                }
            } else {
                if(pos[num] > pos[next]) {
                } else {
                    isUpping = true;
                    count = 1;
                }
            }
        }
//        System.out.println(Arrays.toString(pos));
//        System.out.println(ans+1);
        System.out.println(n-ans-1);
    }
}

Measured memory_bytes: 67816
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

bool dfs(ll keta, ll top, ll &total, vector<char> &chars, ll K) {
    if (total > K) {
        return true;
    }

    if (keta == -1) {
        total++;
        if (total == K) {
            for (ll s = chars.size() - 1; s >= 0; s--) {
                print0(chars[s]);
            }
            print();
            return true;
        }
        return false;
    }
    bool done = false;
    if (top > 0) {
        chars[keta] = (char)top + '0' - 1;
        done = done || dfs(keta - 1, top - 1, total, chars, K);
    }
    chars[keta] = (char)top + '0';
    done = done || dfs(keta - 1, top, total, chars, K);
    if (top < 9) {
        chars[keta] = (char)top + '0' + 1;
        done = done || dfs(keta - 1, top + 1, total, chars, K);
    }
    return done;
}
int main() {
    ll K;
    cin >> K;
    ll pretotal = 9;
    if (K <= 9) {
        print(K);
        return 0;
    }
    for (ll tketa = 2; true; tketa++) {
        vector<char> chars(tketa);
        for (ll ttop = 1; ttop <= 9; ttop++) {
            chars[tketa - 1] = ttop + '0';
            bool done = dfs(tketa - 2, ttop, pretotal, chars, K);
            if (done) {
                return 0;
            }
        }
    }
}


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

using namespace std;

const int maxn = 2e5 + 7;
multiset<int> st;
int n, m, a[maxn];
pair<int, int> p[maxn];

int mx[maxn], mn[maxn], Min = 1e9, Max;
bool d2[maxn];
int32_t main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
   cin >> n;
   for(int i = 1; i <= n; i++)
   {
      int x, y;
      cin >> x >> y;
      if(x > y) swap(x, y);
      p[i] = {x, y};
      Min = min({Min, x, y});
      Max = max({Max, x, y});
      st.insert(x);
   }
   int Min1 = 1e9, Max1 = 0, ans;
   for(int i = 1; i <= n; i++)
   {
      Max1 = max(Max1, p[i].first);
      Min1 = min(Min1, p[i].second);
   }
   ans = (Max1 - Min) * (Max - Min1);
   sort(p + 1, p + n + 1);
   ans = min(ans, (*st.rbegin() - *st.begin()) * (Max - Min));
   for(int i = 1; i <= n; i++)
   {
      st.erase(st.find(p[i].first));
      st.insert(p[i].second);
      ans = min(ans, (*st.rbegin() - *st.begin()) * (Max - Min));
   }
   cout << ans;
}

Measured memory_bytes: 14080
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def f(S, res, d, c):
    if c == 0:
        return S, res
    
    if c % 2 == 1:
        S += d
        res += 1
        if S >= 10:
            S -= 9
            res += 1
        
    t = d * 2
    res += c // 2
    if t >= 10:
        t -= 9
        res += c // 2
    return f(S, res, t, c // 2)


def main():
    M = int(input())
    S = 0
    res = -1
    for _ in range(M):
        d, c = read_values()
        S, res = f(S, res, d, c)
    
    print(res)


if __name__ == "__main__":
    main()


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

unsigned long long A[100005];

int main()
{
    int K;
    unsigned long long tmp;
    scanf("%d", &K);
    for (int i=0; i<K; i++){
        scanf("%d", &A[i]);
    }
    unsigned long long L=2, R=2;
    for (int i=K-1; i>=0; i--){
        tmp = ((L + (A[i] - 1))/A[i]) * A[i];
        if (tmp >= L && tmp <= R){
            L = tmp;
            R = (R / A[i]) * A[i] + A[i] - 1;
        }
        else{
            printf("-1\n");
            return 0;
        }
    }
    printf("%lld %lld\n", L, R);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
inline int Log2(ll x) {int k; for(k=0; x>0; ++k) x>>=1; return k;} // number of binary digits
template<typename T> inline int count_between(vector<T>& a, T l, T r) {
  return lower_bound(all(a), r) - lower_bound(all(a), l); // [l, r)
}
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;


int main() {
  int n; cin >> n;
  vector<tuple<ld, ll, ll>> xy;
  rep(i, n) {
    int x, y; cin >> x >> y;
    if (x==0 && y==0) continue;
    xy.push_back(make_tuple(atan2(x, y), x, y));
  }
  sort(all(xy));
  n = xy.size();
  

  vector<pair<ll, ll>> s(n+1);
  rep(i, n) {
    s[i+1].fst += s[i].fst + get<1>(xy[i]);
    s[i+1].snd += s[i].snd + get<2>(xy[i]);
  }

  ll ans = 0;
  rep(j, n+1) rep(i, j+1) {
    ll sx = s[j].fst - s[i].fst;
    ll sy = s[j].snd - s[i].snd;
    chmax(ans, sx*sx + sy*sy);
    sx = s[n].fst - sx;
    sy = s[n].snd - sy;
    chmax(ans, sx*sx + sy*sy);
  }

  cout << setprecision(12);
  cout << sqrt(ans) << endl;
  return 0;
}


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


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class ARounding {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int x,a;
        cin >> x >> a;
        if (x < a){
            cout << 0 << endl;
        }else {
            cout << 10 << endl;
        }
	}
};


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


Measured memory_bytes: 256
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val k = readInt
  val Array(a, b) = readInts

  var res = "NG"
  for (i <- a to b) {
    if (i % k == 0) {
      res = "OK"
    }
  }

  println(res)
}

trait StdInHelper {
  def readInts = readLine.split(" ").map(_.toInt)
  def readLongs = readLine.split(" ").map(_.toLong)
}


Measured memory_bytes: 54832
#include <bits/stdc++.h>
using namespace std; 
int main() {
 int A,B;
  cin >> A >> B;
 if(13 <= A){
   cout << B;
 }else if(6 <= A && A<= 12) {
   cout << B/2;
 }else if(A <= 5){
   cout << 0;
 }
  }

Measured memory_bytes: 384
import java.util.Scanner;

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

		String result = "";
		for(int i=0;i<N;i++) {
			result = result + "ACL";
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 27052
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)

int main()
{
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<x+k;i++){
        cout<<i;
        if(i==x+k-1)cout<<endl;
        else cout<<" ";
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define int long long

signed main() {
  int n, m, l, y, x, ns1[100][100], ns2[100][100], im, a;
  scanf("%lld%lld%lld", &n, &m, &l);
  for(y = 0; y < n; ++y) for(x = 0; x < m; ++x) scanf("%lld", &ns1[y][x]);
  for(y = 0; y < m; ++y) for(x = 0; x < l; ++x) scanf("%lld", &ns2[y][x]);
  for(y = 0; y < n; ++y) for(x = 0; x < l; ++x) {
    a = 0;
    for(im = 0; im < m; ++im) a += ns1[y][im] * ns2[im][x];
    printf("%lld%s", a, (x == l - 1 ? "\n" : " "));
  }
  return 0;
}

Measured memory_bytes: 756
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
void solve(int n,int k)
{
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];     
    }

    int dp[n+1];
    
    dp[1]=0;
    
    for(int i=2;i<=n;i++)
    {
        dp[i]=INT_MAX;
    }
    
    for(int i=2;i<=n;i++)
    {
        for(int j=i-1;j>=max(1,i-k);j--)
        {
            dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
        }
    }
    cout<<dp[n]<<endl;
    return ;

}

int main() 
{
    int n,k;
    cin>>n>>k;
    solve(n,k);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
long long x(long long a,long long b){
  long long k=1;
  long long c=0;
  while(k<=max(a,b)){
    if((a/k)%2!=(b/k)%2) c+=k;
    k=k*2;
  }
  return c;
}
int main(){
  long long N;
  cin>>N;
  string answer;
  while(N>0){
    N--;
    long long x=N%26;
    if(x==0) answer+='a';
    if(x==1) answer+='b';
    if(x==2) answer+='c';
    if(x==3) answer+='d';
    if(x==4) answer+='e';
    if(x==5) answer+='f';
    if(x==6) answer+='g';
    if(x==7) answer+='h';
    if(x==8) answer+='i';
    if(x==9) answer+='j';
    if(x==10) answer+='k';
    if(x==11) answer+='l';
    if(x==12) answer+='m';
    if(x==13) answer+="n";
    if(x==14) answer+='o';
    if(x==15) answer+='p';
    if(x==16) answer+='q';
    if(x==17) answer+='r';
    if(x==18) answer+='s';
    if(x==19) answer+='t';
    if(x==20) answer+='u';
    if(x==21) answer+='v';
    if(x==22) answer+='w';
    if(x==23) answer+='x';
    if(x==24) answer+='y';
    if(x==25) answer+='z';
    N=N/26;
  }
  reverse(answer.begin(),answer.end());
  cout<<answer<<endl;
  
  
  return 0;
}

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

int main()
{
	char S[15], T[15], U[15];
	int A, B;
	
	scanf ("%s %s", S, T);
	scanf ("%d %d", &A, &B);
	scanf ("%s", U);
	
	(strcmp (S,U) == 0) ? A-- : B--;
	printf ("%d %d", A, B);
	
	return 0;	
}

Measured memory_bytes: 3180
#include <iostream>
#include <string>
using namespace std;
int main()
{
    long n , resultgolden=0;
    cin >> n;
    while (n > 4){
        if (n >=500){
            n-=500;
            resultgolden+=1000;
        }
        else {
            n-=5;
            resultgolden+=5;
        }
    }
    cout << resultgolden;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,m,a[35]={0},i,j,k;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		k=0;
		scanf("%d",&k);
		for(j=0;j<k;j++){
			int ab;
			scanf("%d",&ab);
			a[ab]++;
		}
	}
	int ans=0;
	for(i=1;i<=m;i++){
		if(a[i]==n)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define REP(x,b) for(int x=0;x<b;x++)
#define FORSIZE(x,A) for(int x=0;x<A.size();x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define SORT(x) sort(x.begin(),x.end())
#define RSORT(x) sort(x.rbegin(),x.rend())
#define rsort(x,n) sort(x, x+n, greater<int>())
#define REV(x) reverse(x.begin(),x.end())
using namespace std;
typedef long long ll;
inline int toInt(std::string s) {int v; std::istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {std::ostringstream sout;sout<<x;return sout.str();}

int main( int argc, const char* argv[] )
{
    string line;
    int a, b;
    while (cin >> a >> b) {
        cout << toString(a+b).size() << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

using Graph = vector<vector<int>>;

vector<int> color;

bool dfs(Graph &G, int v, int c) {
    color[v] = c;
    for(auto next_to : G[v]) {
        if(color[next_to] == c) return false;
        if(color[next_to] == 0 && !dfs(G, next_to, -c)) return false;
    }
    return true;
}

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

    ll N, M;
    cin >> N >> M;
    Graph G(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ll B = 0, W = 0;
    color.assign(N, 0);

    if(dfs(G, 0, 1)) {
        rep(i, N) {
            if(color[i] == 1) {
                B++;
            } else if(color[i] == -1) {
                W++;
            }
        }
        cout << B * W - M << endl;
    } else {
        cout << ((N * (N - 1)) / 2) - M << endl;
    }
}


Measured memory_bytes: 6528
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;


signed main() {
  ios::sync_with_stdio(false);
  int n, K;
  cin >> n >> K;
  vector<ll> h(n+1);
  REP(i, n) cin >> h[i+1];
  vector<vector<ll>> dp(n+1, vector<ll>(n+1, inf));
  dp[0][0] = 0;
  REP(i, n+1) {
    REP(j ,n) {
      REP_FROM(k, i+1, n+1) {
        dp[k][j+1] = min(dp[k][j+1], dp[i][j] + max(0ll, h[k] - h[i]));
      }
    }
  }
  ll ans = inf;
  REP(i, n+1) ans = min(ans, dp[i][n-K]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
#define int ll
#define MOD ll(1e9+7)
vector<ll> memo(2e6+1e5, -1);

int binpow(int a, int b){
	int res = 1;
	while(b){
		if(b % 2)
			res = res * a;
		a *= a;
		b >>= 1;
	}
	return res;
}

ll dp(vector<vector<int>> &v, int mmask, int i){
	if(i == v.size())
		return 1;
	if(memo[mmask] != -1)
		return memo[mmask];
	memo[mmask] = 0;
	for(int e : v[i]){
		if(mmask & binpow(2, e)){
			memo[mmask] = (memo[mmask] + dp(v, mmask & (binpow(2, 21)-1-binpow(2, e)), i+1)) % MOD;
		}
	}
	return memo[mmask];
}

signed main() { 
	cin.tie(0);
	cin.sync_with_stdio();
	int n; 
	cin>>n;
	vector<vector<int>> v(n);
	for(int i = 0; i <n; i++){
		for(int j = 0; j < n; j++){
			int a;
			cin>>a;
			if(a)
				v[i].push_back(j);
		}
	}
	cout<<dp(v, binpow(2, 21)-1, 0);
	
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0;i<n;i++) {
    cin >> a[i];
  }
  int ans = INF,memo;
  FOR(i,-100,101) {
    memo = 0;
    REP(j,n) {
      memo += (a[j]-i)*(a[j]-i);
    }
    ans = min(ans,memo);
  }
  if (ans == INF) {
    ans = 0;
  }
  cout << ans;
}

Measured memory_bytes: 256
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if len(set([l[i], l[j], l[k]])) != 3:
                continue
            if l[i] + l[j] > l[k]:
                ans += 1
print(ans)


Measured memory_bytes: 68156
#include<iostream>
#include<iomanip>  
using namespace std;
struct player{
  int id;
  double time;
};
player pk[4];
player ph[2];
void top4(player a){
  if(a.time<pk[3].time||pk[3].time==0) pk[3] = a;
}
void top3(player a){
  top4(a);
  if(a.time<pk[2].time||pk[2].time==0){
    pk[3] = pk[2];
    pk[2] = a;
  }
}
void top2(player a){
  top3(a);
  if(a.time<pk[1].time||pk[1].time==0){
    pk[2] = pk[1];
    pk[1] = a;
  }
}
void top(player a){
  top2(a);
  if(a.time<pk[0].time||pk[0].time==0){
    pk[1] = pk[0];
    pk[0] = a;
  }
}
void phtop2(player a){
  if(a.time<ph[1].time||ph[1].time==0) ph[1] = a;
}
void phtop(player a){
  phtop2(a);
  if(a.time<ph[0].time||ph[0].time==0){
    ph[1] = ph[0];
    ph[0] = a;
  }
}
int main(){
  player p;
  for(int i=0;i<2;i++){
      ph[i].id = 0;
      ph[i].time = 0;
  }
  for(int i=0;i<3;i++){
    for(int i=0;i<4;i++){
      pk[i].id = 0;
      pk[i].time = 0;
    }
    for(int j=0;j<8;j++){
      cin >> p.id >> p.time;
      top(p);
    }
    cout << pk[0].id << ' ';
    cout << fixed << setprecision(2) << pk[0].time << endl;
    cout << pk[1].id << ' ';
    cout << fixed << setprecision(2) << pk[1].time << endl;
    phtop(pk[2]);
    phtop(pk[3]);
  }
  cout << ph[0].id << ' ';
  cout << fixed << setprecision(2) << ph[0].time << endl;
  cout << ph[1].id << ' ';
  cout << fixed << setprecision(2) << ph[1].time << endl;
  return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
#define int long long
const int MOD=1e9+7;
using pii=std::pair<int,int>;
using namespace std;

string s;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    int n = s.length();
    int good = 1;
    for(int i = 0; i < n; i++)
        if(s[i] != s[n - 1 - i])
            good = 0;
    for(int i = 0; i < n / 2; i++)
        if(s[i] != s[n / 2 - 1 - i])
            good = 0;
    reverse(s.begin(), s.end());
    for(int i = 0; i < n / 2; i++)
        if(s[i] != s[n / 2 - 1 - i])
            good = 0;
    if(good)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n;
  int b, f, r, v;
  int i, j, k;

  int tenants[4][3][10] = {{{}}};

  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    tenants[b-1][f-1][r-1] += v;
  }

  for(i = 0; i < 4; ++i) {
    for(j = 0; j < 3; ++j) {
      for(k = 0; k < 10; ++k) {
	printf(" %d", tenants[i][j][k]);
      }
      printf("\n");
    }
    if(i != 3) printf("####################\n");
  }

  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
    cin >> a >> b >> c;
  vector<int> v{a,b,c};
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
  
  cout << v.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1000000007;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX

void solve(){
    ll n,m;
    cin >> n >> m;
    vv64 v(n);
    ll a[m];
    ll p[m];
    forn(i,m){
    	ll s;
    	cin >> s;
    	forn(j,s){
    		ll t1;
    		cin >> t1;
    		v[t1-1].pb(i);
    		// v[i].pb(t1-1);
    	}
    }
    forn(i,m) cin >> p[i];
    // forn(i,m) cout << p[i] << " ";
    // cout << ln;
    // forn(i,n){
    // 	cout << i << " ";
    // 	forn(j,(ll)v[i].size()){
    // 		cout << v[i][j] << " ";
    // 	}
    // 	cout << ln;
    // }
    ll ans=0;
    forn(i,(1<<n)){
    	forn(j,m) a[j]=0;
    	// cout << "done" << ln;
    	forn(j,n){
    		if((i>>j) & 1){
    			forn(k,(ll)v[j].size()){
    				a[v[j][k]]=a[v[j][k]]^1;
    			}
    		}
    	}
    	// cout << "done1" << ln;
    	bool bo=true;
    	forn(j,m){
    		if(a[j]!=p[j]) bo=false;
    	}
    	// cout << "done2" << ln;
    	// cout << ans << ln;
    	if(bo) ans++;
    }
    cout << ans << ln;
}


int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		sc.close();
		if(a.equals("H")) {
			if(b.equals("H")) {
				System.out.println("H");
			}else {
				System.out.println("D");
			}
		}else {
			if(b.equals("H")) {
				System.out.println("D");
			}else {
				System.out.println("H");
			}
		}
	}
}

Measured memory_bytes: 21588