akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

char ch[500005];
ll a[500005];

int main() {
	scanf("%s", ch);
	string s = ch;
	ll n = s.size();
	for (int i=0 ; i<s.size() ; i++) {
		if (s[i] == '<') {
			a[i+1] = a[i]+1;
			continue;
		}
		ll br = 0;
		int j = i;
		while (i<n and s[i] == '>') {
			br++;
			i++;
		}
		a[j] = max(a[j], br);
		a[j+1] = min(a[j]-1, br-1);
		for (int k=j+2 ; k<=i ; k++) a[k] = a[k-1]-1;
		i--;
	}
	ll sum = 0;
	for (int i=0 ; i<n+1 ; i++) {
		sum+=a[i];
	//	cout <<a[i]<<" ";
	}
	//cout <<endl;
	printf("%lld\n", sum);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[353535];

int main(){
  scanf("%d",&n);
  REP(i,3*n)scanf("%d",a+i);
  set<pii> h1,t1,t2;
  ll hv = 0, tv = 0;
  REP(i,n)h1.insert(pii(a[i],i)), hv += a[i];
  FOR(i,2*n,3*n)t1.insert(pii(-a[i],i)), tv -= a[i];

  FOR(i,n,2*n){
    pii po = pii(-a[i],i);
    if(po > *t1.begin()){
      // add
      t1.insert(po);
      tv += po.first;
      // get
      po = *t1.begin();
      // erase
      t1.erase(t1.begin());
      // down
      tv -= po.first;
      po.first *= -1;
      t2.insert(po);
    }else{
      // down
      po.first *= -1;
      t2.insert(po);
    }
  }
  ll ans = hv + tv;
  FOR(i,n,2*n){
    {
      pii po = pii(a[i],i);
      if(po > *h1.begin()){
        // add
        h1.insert(po);
        hv += po.first;
        // get
        po = *h1.begin();
        // erase
        h1.erase(h1.begin());
        // down
        hv -= po.first;
      }
    }
    {
      pii po = pii(-a[i],i);
      if(t1.count(po)){
        t1.erase(po);
        tv -= po.first;
        pii yo = *t2.begin();
        yo.first *= -1;
        tv += yo.first;
        t1.insert(yo);
        t2.erase(t2.begin());
      }else{
        t2.erase(pii(a[i],i));
      }
    }
    CHMAX(ans,hv+tv);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15488
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String a[] = new String[3];
    a = s.split("/",0);
    a[0] = "2018";
    String ans = String.join("/",a);
    System.out.println(ans);
  }
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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 main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if(s == u) a--;
  else b--;
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    vector<int> op;
    while(abs(n)){
        int s = (n%2+2)%2;
        op.push_back(s);
        n = -(n-s)/2;
    }
    for(int i=0; i<op.size(); i++){
        cout<<op[op.size()-i-1];
    }
    if(op.size()==0)cout<<0;
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

string f(int N) {
  switch (N) {
  case 2:
  case 4:
  case 5:
  case 7:
  case 9: return "hon";
  case 3: return "bon";
  }
  return "pon";
}

int main() {
  int N; cin>>N;
  cout << f(N%10) << endl;
  return 0;
}


Measured memory_bytes: 3132
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll calc(string S, ll K) {
  int N = S.size();
  ll res = 0;

  bool same = true;

  for (int i = 0; i < N; i++) same &= S[0] == S[i];

  if (same) return (ll)K * N / 2;

  for (int i = 0; i < N; i++) {
    if (S[i - 1] == S[i]) {
      S[i] = '#';
      res += K;
    }
  }

  if (*S.begin() == *S.rbegin()) {
    S[0] = '$';
    res += K - 1;
    debug(res);
  }

  return res;
}


int main() {
  string S;
  int N, K;

  cin >> S >> K;

  ll ans = calc(S, K);
  reverse(S.begin(), S.end());
  ans = min(ans, calc(S, K));

  cout << ans << endl;

  return 0;
}

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

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

#define endl "\n"
#define fi first
#define se second
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(c) c.begin(),c.end()
#define pii pair<int, int>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

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

template <typename T>
ostream &operator<<(ostream &out, set<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T>
ostream &operator<<(ostream &out, multiset<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T, typename V>
ostream &operator<<(ostream &out, map<T, V> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << "\n" << (i->first) <<  ":"  << (i->second);
    return out;
}

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

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

#define int ll

int solve() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}

int32_t main(){ _
    int t;
    // cin >> t;
    t = 1;
    while (t--) solve();
    return EXIT_SUCCESS;	
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;



void solve()
{
	int x, k, d;
	cin >> x >> k >> d;

	if ( x <  0 ) x *= -1;
	int e = min(k, x / d), ans , use;
	ans = x - e * d;
	int rem = k - e;
	if (rem % 2) ans -= d;

	cout << abs(ans) << endl;

}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





















Measured memory_bytes: 3640
import java.util.*;
import java.io.*;
import java.lang.*;

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

    int sLen = s.length();
    int tLen = t.length();
    int min = 1001;

    for (int i = 0; i <= sLen - tLen; i++) {
      int diff;
      try {
        // System.out.println(s.substring(j-i, j+tLen-i) + " vs " + t);
        diff = calculateDiff(s.substring(i, i+tLen), t);
        // System.out.println("diff : " + diff);
      } catch (StringIndexOutOfBoundsException e) {
        continue;
      }
      if (min > diff) {
        min = diff;
      }
    }
    if (min == 1001) {
      min = tLen;
    }

    PrintWriter out = new PrintWriter(System.out);
    out.println(min);
    out.flush();
  }

  public static int calculateDiff(String a, String b) {
    int count = 0;
    for (int i = 0; i < b.length(); i++) {
      if (!a.substring(i, i+1).equals(b.substring(i, i+1))) {
        count++;
      }
    }
    return count;
  }
}


Measured memory_bytes: 52884
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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



  ll a, b;
  cin >> a >> b >> m;
  vll v;
  RFOR(i, 1, max(a, b) + 1) {
    if (a%i == 0 && b%i == 0) v.pb(i);
  }
  cout << v[m - 1] << endl;



  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer 降順ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int n = Integer.parseInt(br.readLine());
        Integer [] al = inputvalInteger();
        Arrays.sort(al, Collections.reverseOrder());
        long ans = 0;
        for (int i=0; i<n; i++){
            ans += al[1+2*i];
        }

        System.out.println(ans);

    }

}



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

int Count;

void BubbleSort(int A[],int N){
	bool flag=true;
	
	while(flag){
		flag=false;
		
		for(int j=N-1;j>=1;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				Count++;
				flag=true;
			}
		}
	}
}

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

	int A[100];
	for(int i=0;i<N;i++){
		cin>>A[i];
	}

	Count =0;
	
	BubbleSort(A,N);

	for(int i=0;i<N;i++){
		cout<<A[i];
	
		if(i<N-1){
			cout<<" ";
		}else{
			cout<<endl;
		}
	}
	cout<<Count<<endl;

	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    int ans = 0;
    for (int i = 1; i < N-1; i++)
    {
        int mx = max(a[i-1],max(a[i],a[i+1]));
        int mn = min(min(a[i-1],a[i]),a[i+1]);
        int sum = a[i-1] + a[i] + a[i+1];
        if(a[i] == sum - mx - mn) ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int x,y,z;
    int side=0,i=0;
    cin>>x>>y>>z;
while(1){
    side+=z;
    if(side>x) {
        i--;
        break;
    }
    side+=y;
    if(side>=x) break;
    i++;
}
    cout<<i<<endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 

const int MXN = 2e5 + 5;
//const int MXN = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;


int N, M, x, y, vis[100005], dp[100005];
vi adj[100005];

void dfs(int u){
    vis[u] = 1;
    for (int v : adj[u]){
        if (!vis[v]){
            dfs(v);
        }
        dp[u] = max(dp[u],dp[v]+1);
    }
}

int main(){ FAST
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");

    cin >> N >> M;
    F0R(i,M){
        cin >> x >> y;
        adj[x].pb(y);
    }
    int ans = 0;
    FOR(i,1,N+1){
        if (!vis[i]){
            dfs(i);
        }
    }
    FOR(i,1,N+1) ans=max(ans,dp[i]);
    finish(ans);

















	return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
int n,d;
int x[10][10];
int main()
{
	cin>>n>>d;
	for(int i=0;i<n;i++)
	for(int j=0;j<d;j++)
	cin>>x[i][j];
	int ans=0;
	for(int i=0;i<n;i++)
	for(int j=i+1;j<n;j++)
	{
		int sum=0;
		for(int k=0;k<d;k++)
		sum+=abs(x[i][k]-x[j][k])*abs(x[i][k]-x[j][k]);
		int z=sqrt(sum);
		if(z*z==sum)
		ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
def main():
    N = int(input())
    D = [int(d) for d in input().split()]
    M = int(input())
    T = [int(t) for t in input().split()]

    diff = defaultdict(int)

    for i in range(len(D)):
        diff[D[i]] += 1

    ok = True
    for i in range(len(T)):
        if diff[T[i]] >= 1:
            diff[T[i]] -= 1
        else:
            ok = False
            break

    if ok:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Measured memory_bytes: 41564
import itertools
import numpy as np

# H, W, K = 2, 3, 4
# ARR = [
#     "..#",
#     "###",
# ]
#
# H, W, K = 6, 6, 8
# ARR = [
#     "..##..",
#     ".#..#.",
#     "#....#",
#     "######",
#     "#....#",
#     "#....#"
# ]

H, W, K = map(int, input().split())
ARR2 = np.zeros((H, W))
for i in range(H):
    s = list(input())
    for j in range(W):
        if s[j] == ".":
            ARR2[i][j] == 0
        else:
            ARR2[i][j] = 1

# ARR2 = np.zeros((H, W))
# for i in range(H):
#     for j in range(W):
#         if ARR[i][j] == ".":
#             ARR2[i][j] == 0
#         else:
#             ARR2[i][j] = 1


def calclulate(h, w, k, arr):
    result = 0
    hIndex = [i for i in range(h)]
    wIndex = [i for i in range(w)]

    for hChooseNum in range(h + 1):
        for wChooseNum in range(w + 1):
            for m in itertools.combinations(hIndex, hChooseNum):
                for n in itertools.combinations(wIndex, wChooseNum):

                    tmpArr = arr.copy()

                    for _m in m:
                        tmpArr[_m, :] = 0
                    for _n in n:
                        tmpArr[:, _n] = 0

                    if np.sum(tmpArr == 1) == k:
                        result += 1
    print(result)


calclulate(H, W, K, ARR2)


Measured memory_bytes: 27224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int maxa = 0;
    rep(i,n) cin >> a[i],chmax(maxa,a[i]);
    maxa++;

    vector<int> prime(maxa+1);
    rep(i,maxa) prime[i] = i;
    for(int i=2;i*i <= maxa;i++)
        if(prime[i] == i)
            for(int j=2; i*j<=maxa; ++j)
                prime[i*j] = i;
    
    vector<bool> cnts(maxa+1,false);
    bool isFin = false;
    rep(i,n){
        int num = a[i];
        int bef = -1;
        while(num > 1){
            int tmp = prime[num];
            if(tmp != bef && cnts[tmp]){
                isFin = true;
                break;
            }
            cnts[tmp] = true;
            bef = tmp;
            num /= tmp;
            //cout << num << endl;
        }
        if(isFin) break;
        //cout << "i:" << i << endl;
    }
    int now = a[0];
    for(int i= 1;i < n;i++){
        now = gcd(now,a[i]);
    }
    if(!isFin) cout << "pairwise coprime" << endl;
    else if(now == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

Measured memory_bytes: 11116
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n; cin>>n;
	vector<int> a(n);
	cinf(n,a);
	map<int,int> mp;
	for(int i=0;i<n;i++){
		mp[a[i]]++;
	}
	int ans=0;
	for(auto p:mp){
		int x=p.first;
		int y=p.second;
		if(x>y)ans+=y;
		if(x<y)ans+=(y-x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5120
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	
	scanf("%d %d %d", &a, &b, &c);
	
	d = c - (a - b);
	if(d < 0){
		d = 0;
	}
	
	printf("%d", d);
	
	return 0;
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;



void solve()
{
	int x, k, d;
	cin >> x >> k >> d;

	if ( x <  0 ) x *= -1;

	int s = 0, e = min(k, x / d), ans , use;

	while ( s <= e )
	{
		int m = (s + e) / 2;
		int y = x - m * d;
		if ( y >= 0)
		{
			ans = x - m * d;
			use = m;
			s = m + 1;
		}
		else e = m  - 1;
	}

	int rem =  k - use;
	if (rem % 2) ans -= d;


	cout << abs(ans) << endl;

}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





















Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
typedef v(string) vs;

const string cs = "RGBY";

int main() {
  int h,w,d;
  scanf("%d%d%d",&h,&w,&d);
  vs ans(h,string(w,'.'));
  if (d&1) {
    rep(i,h)rep(j,w) ans[i][j] = cs[(i+j)%2];
  } else {
    int t = 1, x = d;
    while (x%2 == 0) x /= 2, t <<= 1;
    t >>= 1;
    rep(i,h)rep(j,w) {
      int x = i+j, y = i-j+h+w;
      x /= 2;
      y /= 2;
      x /= t;
      y /= t;
      x %= 2;
      y %= 2;
      ans[i][j] = cs[x*2+y];
    }
  }
  rep(i,h) cout<<ans[i]<<endl;
  return 0;
}






















Measured memory_bytes: 768
n,k=map(int,input().split())
arr=list(map(int,input().split()))
dp=[0]*(n)
dp[1]=abs(arr[1]-arr[0])
for i in range(2,n):
	mn=99999999999999
	for j in range(1,k+1):
		if i-j>=0 and mn>dp[i-j]+abs(arr[i]-arr[i-j]):
			mn=dp[i-j]+abs(arr[i]-arr[i-j])
	dp[i]=mn
# print(dp)
print(dp[n-1])


Measured memory_bytes: 52448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    ll n, m;
    cin >> n >> m;

    vvll task(m + 1);
    for (ll i = 0; i < n; i++)
    {
        ll a, b;
        cin >> a >> b;
        if (a <= m)
        {
            task[a].push_back(b);
        }
    }

    priority_queue<ll> q;
    ll ans = 0;
    for (ll i = 1; i <= m; i++)
    {
        // i日前にする仕事
        for (auto b : task[i])
        {
            q.push(b);
        }
        if (!q.empty())
        {
            ans += q.top();
            q.pop();
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5632
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b)
{
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll combination(ll n,ll r){
    ll sum=1;
    rrep(i,min(r,n-r)) (sum*=(n-i+1))%=mod;
    return sum;
}

//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,sum=0;
    cin>>n;
    vec<ll> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n) {
        if(a[i]==(i+1) && i!=(n-1)){
            swap(a[i],a[i+1]);
            sum++;
        }else if(i==n-1 && a[i]==(i+1)){
            swap(a[i],a[i-1]);
            sum++;
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int l = s.size();
	int l2 = (l - 1) / 2;
	for (int i = 0; i < l2; i++) {
		if (s[i] != s[l - 1 - i] || s[i] != s[l2 - 1 - i] || s[i] != s[l2 + 1 + i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

using namespace std;

using int64 = long long;

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(v1, v2));
    graph[v2].push_back(Edge(v2, v1));
  }
  return graph;
}

vector<vector<Edge>> ReadDirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge({v1, v2}));
  }
  return graph;
}

struct WeightedEdge {
  int from, to;
  int64 weight;
  WeightedEdge(int from, int to, int64 weight)
      : from(from), to(to), weight(weight) {}
};

// Verified: ABC126D
vector<vector<WeightedEdge>> ReadUndirectedWeightedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<WeightedEdge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    int64 weight;
    cin >> v1 >> v2 >> weight;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(WeightedEdge(v1, v2, weight));
    graph[v2].push_back(WeightedEdge(v2, v1, weight));
  }
  return graph;
}

vector<vector<WeightedEdge>> ReadDirectedWeightedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<WeightedEdge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    int64 weight;
    cin >> v1 >> v2 >> weight;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(WeightedEdge(v1, v2, weight));
  }
  return graph;
}

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

  int n;
  cin >> n;
  auto graph = ReadUndirectedGraph(n, n - 1, true);
  function<int(int, int)> dfs = [&](int v, int p) -> int {
    if (graph[v].size() == 0) return 0;
    int value = 0;
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      value ^= dfs(e.to, v) + 1;
    }
    return value;
  };
  int grundy = dfs(0, -1);
  if (grundy > 0) {
    cout << "Alice" << endl;
  } else {
    cout << "Bob" << endl;
  }
}

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

int main()
{
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n,d;
	cin>>n>>d;

	cout << int(n/(d+d+1)) + int(n%(d+d+1) != 0) << endl;	
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;
const int MAX = 35;
ll ans,dp[MAX];
int in;

void make(){
  dp[0] = 1;

  for(int i = 0; i <= 30; i++)
    for(int j = 1; j <= 3; j++)
      dp[i+j] += dp[i];

}

int main(){
  make();
  while(cin >> in && in) cout << dp[in]/3650+1<< endl;
  return 0;
}

Measured memory_bytes: 1156
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int[][] X = new int[N][D];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < D; j++) {
				X[i][j] = sc.nextInt();
			}
		}
		sc.close();

		int ans = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = i + 1; j < N; j++) {
				int tmp = 0;
				for (int k = 0; k < D; k++) {
					int m = (int) Math.pow(X[i][k] - X[j][k], 2);
					tmp += m;
				}
				if (isSquareNumber(tmp)) {
					ans++;
				}
			}
		}

		System.out.println(ans);
	}

	// 平方数かどうかを調べる。
	public static boolean isSquareNumber(int number) {
		double sqrtOfNumber = Math.sqrt(number);
		return (isInteger(sqrtOfNumber));
	}

	// 整数かどうかを調べる。
	public static boolean isInteger (double number) {
			return (number == Math.floor(number));
	}
}


Measured memory_bytes: 23764
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;

int n, a[200], sum = 10000000;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (int i = 0; i <= 100; ++i) {
		int sum1 = 0;
		for (int j = 1; j <= n; ++j) sum1 += (i - a[j]) * (i - a[j]);
		sum = min(sum1, sum);
		//cout << sum1 << endl;
	}
	cout << sum;
}

Measured memory_bytes: 888
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  ll a=0, ans=0;
  for(int i=0;i<S.size()-1;++i){
    if(S[i]=='A') a++;
    else if(S[i]=='B' && S[i+1]=='C'){
      ans += a;
      i++;
    }
    else a = 0;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 640
import java.util.Arrays;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long a = s.nextInt();
		s.nextLine();
		Hashtable<String, Long> map = new Hashtable<>();
		long count = 0;
		for (int i = 0; i < a; i++) {
			String string = sort(s.nextLine());
			if(!map.containsKey(string)) {
				map.put(string, 1L);
			}else {
				count+=map.get(string);
				map.put(string, map.get(string)+1);
			}
		}
		System.out.println(count);

	}
	public static String sort(String x) {
		char[] sar =x.toCharArray();
		Arrays.sort(sar);
		return new String(sar);
	}

}


Measured memory_bytes: 103552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC124_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int changeCount = 0;

            bool flagPrev = (s[0] == '1');

            for (int i = 1; i < s.Length; ++i)
            {
                bool flag = (s[i] == '1');

                if (flagPrev == flag)
                {
                    ++changeCount;
                    flag = !flag;
                }

                flagPrev = flag;
            }

            Console.WriteLine($"{changeCount}");
        }
    }
}


Measured memory_bytes: 13280
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main() {
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[0]<<" "<<a[1]<<" "<<a[2];
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N, K;
    cin >> N >> K;

    double ans = 0.0;
    for (int i = 1; i <= N; ++i) {
        int score = i;
        double res = 1.0 / N;
        while (score < K) {
            score *= 2;
            res /= 2.0;
        }
        ans += res;
    }

    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

 int n[1000];
 int x[1000];
 int a = 0;
 int b = 0;
 int c = 0;
 int i, j;

 while (a == 0)
{
     
  scanf("%d", &n[b]);
  scanf("%d", &x[b]);

 if(n[b] == 0 && x[b] == 0)
 {
  a = 1;
  }else
 {
   for (i = 1; i <= n[b]; i++)
{
  for (j = 1; j <= n[b]; j++)
 
{
  if( x[b] - i - j > 0 && i != j && x[b] -i -j <= n[b] && x[b] -i -j != i && x[b] -i -j != j)
   c++;


 }
 }
  printf("%d\n", c/6);
}

  b++;
 c = 0;
}



return 0;

}



 


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

const int N = 200000 + 10, M = 1e9 + 7;

int fac[N], inv[N];
int h, w, a, b;

int pm(int a, int n) {
  int r = 1;
  for (; n; n >>= 1) {
    if (n & 1) r = 1ll * r * a % M;
    a = 1ll * a * a % M;
  }
  return r;
}

int C(int x, int y) {
  return 1ll * fac[x + y] * inv[x] % M * inv[y] % M;
}

void run() {
  std::cin >> h >> w >> a >> b;
  fac[0] = inv[0] = 1;
  for (int i = 1; i <= h + w; ++i) {
    fac[i] = 1ll * i * fac[i - 1] % M;
    inv[i] = pm(fac[i], M - 2);
  }
  int ret = 0;
  for (int i = 1; i <= h - a; ++i) {
    ret += 1ll * C(i - 1, b - 1) * C(w - b - 1, h - i) % M;
    ret %= M;
  }
  std::cout << ret << std::endl;
}

int main() {
  run();
  return 0;
}


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

int main() {
  int s;
  cin >> s;
  set<int> st;

  int n = s;
  int ans = 0;
  while (1) {
    if (st.count(n) == 0) {
      ans++;
      st.insert(n);
      if (n % 2 == 0) {
        n /= 2;
      } else {
        n = 3 * n + 1;
      }
    } else {
      cout << ans + 1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int H, N; cin >> H >> N;
	vector<pair<int, int>>AB(N);
	rep(i, N) {
		int a, b; cin >> a >> b;
		AB[i] = make_pair(a, b);
	}
	int ans = INF;
	vector<int>dp(H, INF);
	dp[0] = 0;
	rep(i, H) {
		if (dp[i] == INF)continue;
		rep(j, N) {
			int dmg = AB[j].first;
			int mp = AB[j].second;
			if (i + dmg >= H) {
				chmin(ans, dp[i] + mp);
			}
			else {
				chmin(dp[i + dmg], dp[i] + mp);
			}
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string s1,s2;
    cin>>s1>>s2;

    int len=s1.length();
    int count=0;

    for(int i=0;i<len;i++){
        if(s1[i]==s2[i])continue;
        else{
            s1[i]==s2[i];
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


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

bool check(string s);

int main() {
    string str;
    cin >> str;
    if(check(str) && check(str.substr(0, str.length() / 2)) && check(str.substr(str.length() / 2 + 1, str.length() / 2))) cout << "Yes" << endl;
    else cout << "No" << endl;
}

bool check(string s) {
    bool flag = true;
    rep(i, s.length()) {
        if(s.at(i) != s.at(s.length() - i - 1)) flag = false;
    }
    return flag;
}

Measured memory_bytes: 256
import math
N, K = map(int, input().split())

ans = 0
for i in range(1, K):
    if i > N:
        break
    x = math.ceil(math.log2(K/i))
    p = (1/2)**x
    ans += p

ans *= 1/N

if N >= K:
    ans += (N-K+1)/N

print("{:.10f}".format(ans))


Measured memory_bytes: 65128
class Node
  attr_reader :value

  def initialize(value)
    @value = value
    @left = nil
    @right = nil
  end

  def insert(value)
    if value < @value
      if @left
        @left.insert(value)
      else
        @left = Node.new(value)
      end
    else
      if @right
        @right.insert(value)
      else
        @right = Node.new(value)
      end
    end
  end

  def find(value)
    return true if value == @value

    if value < @value
      return !!@left && @left.find(value)
    else
      return !!@right && @right.find(value)
    end
  end

  def visit_inorder(&block)
    @left.visit_inorder(&block) if @left
    block.call(self) if block
    @right.visit_inorder(&block) if @right
  end

  def visit_preorder(&block)
    block.call(self) if block
    @left.visit_preorder(&block) if @left
    @right.visit_preorder(&block) if @right
  end
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i

  root = nil

  n.times do
    command = gets.chomp

    case command
    when /^insert\s+(-?\d+)/
      value = $1.to_i

      if root
        root.insert(value)
      else
        root = Node.new(value)
      end
    when /^find\s+(-?\d+)/
      value = $1.to_i

      if root
        if root.find(value)
          puts 'yes'
        else
          puts 'no'
        end
      else
        puts 'no'
      end
    when 'print'
      root.visit_inorder do |node|
        print " #{node.value}"
      end
      puts

      root.visit_preorder do |node|
        print " #{node.value}"
      end
      puts
    end
  end
end

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

using ll=long long; 

void solve(){
	int n,T;
	cin>>n>>T;
	vector<int> cost;
	int c,t;
	for(int i=0; i<n; i++){
		cin>>c>>t;
		if(t<=T){
			cost.push_back(c);
		}
	}
	if(cost.size()==0){
		cout<<"TLE"<<endl;
		return;
	}
	cout<<*min_element(cost.begin(), cost.end())<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;

/**
 * @author http://codeforces.com/blog/entry/18051
 */
class SegmentTree<T>{

	T	initv,array[];
	int	size;

	BinaryOperator<T> op;

	SegmentTree(int size,T initvalue,BinaryOperator<T> op){
		this.size=size;
		this.initv=initvalue;
		this.op=op;
		initArray();
	}
	@SuppressWarnings("unchecked")
	private void initArray(){
		array=(T[])new Object[size*2];
		Arrays.fill(array,initv);
	}

	void build_set(int i,T v){
		array[i+size]=v;
	}
	void build(){
		for(int i=size-1;i>0;--i)
			array[i]=op.apply(array[i*2],array[i*2|1]);
	}

	void update(int p,T value){
		for(array[p+=size]=value;p>1;p>>=1)
			array[p/2]=op.apply(array[p],array[p^1]);
	}

	T query(int lIn,int rEx){
		T res=initv;
		for(lIn+=size,rEx+=size;lIn<rEx;lIn/=2,rEx/=2){
			if((lIn&1)>0) res=op.apply(res,array[lIn++]);
			if((rEx&1)>0) res=op.apply(res,array[--rEx]);
		}
		return res;
	}
}

public class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		SegmentTree<Integer> t=new SegmentTree<>(s.nextInt(),Integer.MAX_VALUE,Math::min);
		for(int q=s.nextInt();q>0;--q){
			if(s.nextInt()==1)
				System.out.println(t.query(s.nextInt(),s.nextInt()+1));
			else
				t.update(s.nextInt(),s.nextInt());
		}
	}
}


Measured memory_bytes: 110860
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		
		String N = in.nextLine();
		if(N.contains("9")) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main(){
    const int mod=1000000007;
    string s;
    cin>>s;
    int n=s.size();
    long long dp[n+1][4]={};
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<4;j++){
            if(s[i]=='?')dp[i+1][j]+=(dp[i][j]*3)%mod;
            else dp[i+1][j]+=dp[i][j];
        }
        if(s[i]=='A' || s[i]=='?')dp[i+1][1]=(dp[i+1][1]+dp[i][0])%mod;
        if(s[i]=='B' || s[i]=='?')dp[i+1][2]=(dp[i+1][2]+dp[i][1])%mod;
        if(s[i]=='C' || s[i]=='?')dp[i+1][3]=(dp[i+1][3]+dp[i][2])%mod;
    }
    cout<<dp[n][3]<<endl;
    return 0;
}

Measured memory_bytes: 6900
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main()
{
	while (1)
	{
		string s;
		cin >> s;
		if (s == "0")break;
		vector<int>ab(2);
		for (int c = 1; c < s.length(); c++) {
			if (s[c] == 'A')ab[0]++;
			else ab[1]++;
		}
		if (ab[0] == 10&&ab[1]<10)cout << 11 << " " << ab[1] << endl;
		else if(ab[1]==10&&ab[0]<10) cout << ab[0] << " " << 11 << endl;
		else if (ab[0] > ab[1])cout << ab[0]+1 << " " << ab[1] << endl;
		else cout << ab[0] << " " << ab[1]+1 << endl;
	}
}

Measured memory_bytes: 3184