akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

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

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

string s[105];
int cnt[10010][2];
int main() {
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; ++i) cin >> s[i];
	
	int numw = 0, nume = 0;
	for(int i=0; i<n; ++i) {
		for(int j=0; j<m; ++j) {
			if(s[j][i] == 'W') cnt[i][0]++, numw++;
			else cnt[i][1]++, nume++;
		}
	}
		
	int w = 0, e = 0;
	int ret = numw-w, idx = -1;
	for(int i=0; i<n; ++i) {
		w += cnt[i][0];
		e += cnt[i][1];
		// ????????\??£????????£??????e?????°?????? e
		// ????????\??£????????£??????w?????° ??? numw - w
		if( ret > e + numw - w) {
			ret = e + numw - w;
			idx = i;
		}		
	}
	cout << idx+1 << " " << idx+2 << endl;
}

Measured memory_bytes: 4688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

ll _n;
map<ll, bool> ma;
bool solve(ll k) {
    if(k==1)return false;
    ll n = _n;
    while (k <= n) {
        if (n % k == 0)n /= k;
        else n %= k;
    }
    return n == 1;
    if (n == 1/* && (!ma.count(k))*/)cout << k << "\n";
}

int main() {
    init();

    cin >> _n;
    ma[_n], ma[_n - 1];
    for (ll i = 2; i * i <= _n - 1; ++i) {
        if ((_n - 1) % i == 0) {
            ma[i];
            ma[(_n - 1) / i];
        }
    }
    for (ll i = 2; i * i <= _n; ++i) {
        if (_n % i == 0) {
            ma[i];
            ma[_n / i];
        }
    }
    int ans = 0;
    each(i, ma)if (solve(i.first))++ans;
    cout << ans << "\n";
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,cnt=0,ans=1;
  string s;
  cin>>n;
  while(n--){
    cin>>s;
    if(s=="A")cnt++;
    else{
      if(!cnt)ans=0;
      else cnt--;
    }
  }
  if(cnt)ans=0;
  if(ans)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){	
	int n,d;
	cin>>n>>d;
	vector<vector<int>>x(n,vector<int>(d));
	double sum;
	int ans=0;
	rep(i,n)rep(j,d)cin>>x[i][j];
	rep(i,n-1){
		for(int j=i+1;j<n;++j){
			sum=0;
			rep(k,d){
			sum+=pow(x[i][k]-x[j][k],2);
			}
			sum=pow(sum,0.5);
			if(sum==(int)sum)++ans;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
c=list(map(int,input().split()))
l=[]
for i in range(q):
  L,R=map(int,input().split())
  l.append([L,R,i])
l.sort(key=lambda x:x[1])

L=[-1]*(5*10**5+1)

class Bit:
  def __init__(self,n):
    self.size=n
    self.tree=[0]*(n + 1)
    self.depth=n.bit_length()

  def sum(self,i):
    s=0
    while i>0:
      s+=self.tree[i]
      i-=i&-i
    return s

  def add(self,i,x):
    while i<=self.size:
      self.tree[i]+=x
      i+=i&-i

BIT=Bit(n+1)

ans=[0]*q
ct=0
for i in range(q):
  while ct<=l[i][1]:
    if L[c[ct-1]-1]!=-1:
      BIT.add(L[c[ct-1]-1],-1)
    L[c[ct-1]-1]=ct+1
    BIT.add(ct+1,1)
    ct+=1
  ans[l[i][2]]=BIT.sum(l[i][1]+1)-BIT.sum(l[i][0])

for i in range(q):
  print(ans[i])

Measured memory_bytes: 181808
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))

typedef vector<int> Ivec;
typedef pair<int, int> Pos;

int main() {
	vector<pair<int,vector<int>>> graph;
	int v, e;
	scanf("%d %d", &v, &e);

	for (int i = 0; v > i; i++) {
		graph.push_back({i,vector<int>()});
	}
	for (int i = 0; e > i; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		graph[b].second.push_back(a);
	}
	while (v) {
		for (int i = 0; v > i; i++) {
			if (!graph[i].second.size()) {
				printf("%d\n", graph[i].first);
				int num = graph[i].first;
				graph.erase(graph.begin()+i);
				v--;
				for (int j = 0; v > j; j++) {
					auto itr = find(graph[j].second.begin(), graph[j].second.end(), num);
					if(itr != graph[j].second.end())
						graph[j].second.erase(itr);
				}
			}
		}
	}


	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    s=to_string(n);
    rep(i,Size(s)){
        cnt+=s[i]-'0';
    }
    if(n%cnt==0)Cout("Yes");
    else Cout("No");
    return 0;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int k, ans=0;
	string s;
	cin >>k;
	VI a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	
	
	cout <<a[k-1] <<"\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long n = scan.nextInt();
        long out = 1;
        for(int i = 1; i <= n; i++){
            out *= i;
            out %= 1000000007l;
        }
        System.out.println(out);
    }
}

Measured memory_bytes: 20948
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <algorithm>
using namespace std;
//方針：DP
int min(int p, int q){
	if (p < q) return p;
	return q;
}
int rss(int p, int q){
	return (p - q)*(p - q);
}
int limit(int i) {
	if (i > 255) return 255;
	if (i < 0) return 0;
	return i;
}
int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);
 
	vector< vector< int > > dp;
	vector<int> dpp;
	for (int i = 0; i < 20001; i++)
		dpp.push_back(1 << 30);
	for (int i = 0; i < 257; i++)
		dp.push_back(dpp);
 
	while (1){
		int N, M;
		vector<int> c, x;
		scanf("%d%d", &N, &M);
		if (N == 0 && M == 0) break;
		for (int i = 0; i < M; i++) {
			int tmp;
			scanf("%d",&tmp);
			c.push_back(tmp);
		}
		for (int i = 0; i < N; i++) {
			int tmp;
			scanf("%d",&tmp);
			x.push_back(tmp);
		}
		
		for (int i = 0; i < 256; i++)
			for (int j = 0; j < 20001; j++)
				dp[i][j] = 1 << 30;
  
		for (int i = 0; i < M; i++) {
			dp[limit(128 + c[i])][1] = rss(limit(128+c[i]), x[0]);
		}

		for (int i = 1; i < N; i++)
			for (int j = 0; j < M; j++)
				for(int k = 0; k < 256; k++)
					dp[limit(k + c[j])][i+1] = min( dp[k][i] + rss(limit(k+c[j]), x[i]) , dp[limit(k+c[j])][i+1]);

		int ans = 1 << 30;
		for (int i = 0; i < 256; i++)
			if (dp[i][N] < ans) ans = dp[i][N];
   
		cout << ans << endl;
 }
 
// while (1){}
 return 0;
}

Measured memory_bytes: 21588
import math

A, B = input().split()

A = int(A)
if '.' in B:
    B_a = int(B.split('.')[0])
    B_b_size = len(B.split('.')[1])
    B_b =  int(B.split('.')[1])
else:
    B_a = int(B)
    B_b_size = 0
    B_b = 0
if B_b_size == 0:
    ans = A * B_a
elif B_b_size == 1:
    ans_a = A * B_a
    ans_b = A * B_b 
    ans_b = ans_b // 10
    ans = ans_a + ans_b
else:
    ans_a = A * B_a
    ans_b = A * B_b 
    ans_b = ans_b // 100
    ans = ans_a + ans_b
print(ans)

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

int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i += 2)
  {
    if (s[i] != 'h' || s[i + 1] != 'i')
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
/*
 * 0614.cc: Railroad Trip
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_M = 100000;

/* typedef */

typedef long long ll;

/* global variables */

int ps[MAX_M], ts[MAX_N + 1];
ll as[MAX_N], bs[MAX_N], cs[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < m; i++) cin >> ps[i];
  for (int i = 0; i < n - 1; i++) cin >> as[i] >> bs[i] >> cs[i];

  for (int i = 0; i < m - 1; i++) {
    int p0 = ps[i], p1 = ps[i + 1];
    if (p0 > p1) swap(p0, p1);
    ts[p0]++;
    ts[p1]--;
  }

  ll sum = 0;
  int t = 0;

  for (int i = 0; i < n - 1; i++) {
    t += ts[i + 1];
    //printf("%d\n", t);
    sum += min(as[i] * t, bs[i] * t + cs[i]);
  }

  printf("%lld\n", sum);
  return 0;
}

Measured memory_bytes: 4280
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=2e5+10;

int a[maxn],b[maxn],difa[maxn],difb[maxn];
int n;
string sa="",sb="",s="";

vector <int> build_zfunction(string &s){
	vector <int> z(s.size(),0);
	z[0]=(int)s.size();
	int j=1;
	for(int i=1;i<(int)s.size();i++){
		int u=max(0,min(j+z[j]-i,z[i-j]));
		while(s[u]==s[i+u]) u++;
		z[i]=u;
		if(i+z[i]>=j+z[j]) j=i;
	}
	return z;
}

string getstr(int x){
	string res="";
	for(int i=1000000000;i>0;i/=10){
		res=res+char(x/i+'0');
		x%=i;
	}
	return res;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=0;i<n;i++) scanf("%d",&b[i]);
	for(int i=0;i<n;i++) difa[i]=a[(i+1)%n]^a[i];
	for(int i=0;i<n;i++) difb[i]=b[(i+1)%n]^b[i];
	for(int i=0;i<n;i++){
		sa+=getstr(difa[i]);
		sb+=getstr(difb[i]);
	}
	s=sb+'#'+sa+sa;
//	cout<<sb<<endl<<sa<<endl<<s<<endl;
	vector<int> z=build_zfunction(s),ans;
	int k=0;
	for(int i=(int)sb.size()+1;i<z.size();){
		if(k>=n) break;
		if(z[i]==(int)sb.size()){
			ans.pb(k);
		}
	//	if(k==1) cout<<z[i]<<endl;
		i+=10; k++;
	}
	for(int i=0;i<ans.size();i++){
		int k=ans[i],x=a[i]^b[(i-k+n)%n];
		printf("%d %d\n",k,x);
	}
	return 0;
}


Measured memory_bytes: 42944
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
typedef long long ll;
typedef double dbl;
typedef long double ld;
const ld EPS=1e-9;
const ld PI=3.141592653589793;
const ll MOD = 1e9+7;
const int SQRT = 300;
const int LG=18;
const int FOURIER = (1<<LG);
////////////////
int dp[maxn][LG];
int x[maxn];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int  i=1; i<=n; ++i){
        cin>>x[i];
    }
    int L;
    cin>>L;
    int it=1;
    for(int i=1; i<=n; ++i){
        while(it<=n && x[it]-x[i]<=L){
            ++it;
        }
        dp[i][0]=it-1;
    }
    for(int step=1; step<LG; ++step){
        for(int i=1; i<=n; ++i){
            dp[i][step]=dp[dp[i][step-1]][step-1];
        }
    }
    int q;
    cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        if (a>b)
            swap(a,b);
        int ans=200000;
        int cur=0;
        for(int l=LG-1; l>=0; --l){
            if (dp[a][l]>=b){
                ans=min(ans,cur+(1<<l));
            }
            else{
                a=dp[a][l];
                cur+=(1<<l);
            }
        }
        cout<<ans<<"\n";
    }

}



Measured memory_bytes: 8320
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;


int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int Max = -inf;
    for(int i = 0; i <= m; i++){
        for(int j = 0; j <= m - i; j++){
            if(i + j > n)   continue;
            int c = m - i - j;
            priority_queue<int, vector<int>, greater<int>> Q;
            int ans = 0;
            for(int k = 1; k <= i; k++)
            {
                ans += a[k];
                if(a[k] < 0)    Q.push(a[k]);
            }
            for(int k = a.size()-1; k >= a.size()-j; k--){
                ans += a[k];
                if(a[k] < 0)    Q.push(a[k]);
            }
            while (c-- && !Q.empty())
            {
                ans -= Q.top();
                Q.pop();
            }
            Max = max(ans , Max);
        }
    }
    cout << Max << endl;
    return 0;
}

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

int main(){
    int k;
    cin >> k;
    int n = 7%k;
    if(!(k%2) || !(k%5)) cout << "-1" <<endl;
    else{
        for(int cnt=1;;){
            if(!n){
                cout << cnt << endl;
                break;
            }
            n = (n*10+7)%k;
            cnt++;
        }
    }
    return 0;
}

Measured memory_bytes: 3548
#include<stdio.h>
#include<stdlib.h>
 
struct node{

  struct node *right;
  struct node *left;
  struct node *parent;
  int key;

};

typedef struct node * Node;
#define NIL NULL
 
Node root;
 
void insert(int k){

  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}
 
void inorder(Node u){

  if(u->left != NIL) inorder(u->left);
  printf(" %d", u->key);
  if(u->right != NIL) inorder(u->right);

}
 
void preorder(Node u){

  printf(" %d", u->key);
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);

}
 
 
int main(){

  int n, i, x;
  char com[20];
  scanf("%d", &n);
  root = NIL;
 
  for ( i = 0; i < n; i++ ){

    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;

}

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

void InputFrom(int *from, int num);
void InputTarget(int *target, int num);

int main(void)
{
    int i;

    int *from;
    int num_from;
    scanf("%d", &num_from);
    from = malloc(sizeof(int) * num_from);
    InputFrom(from, num_from);

    int *target;
    int num_target;
    scanf("%d", &num_target);
    target = malloc(sizeof(int) * num_target);
    InputTarget(target, num_target);

    int cnt = 0;
    for (i = 0; i < num_target; i++) {
        int first = 0, last = num_from;
        int mid;
        while (first <= last) {
            mid = (last + first) / 2;
            if (from[mid] < target[i]) {
                first = mid + 1;
            } else if (target[i] < from[mid]) {
                last = mid - 1;
            } else {
                cnt++;
                break;
            }
        }
    }

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

    return 0;
}

int cmp(const void *a, const void *b);

void InputFrom(int from[], int num)
{
    int i;

    for (i = 0; i < num; i++) {
        scanf("%d", from + i);
    }

    qsort((void *)from, num, sizeof(int), cmp);
}

int cmp(const void *a, const void *b)
{
    int diff = *(int *)a - *(int *)b;
    return diff;
}

void InputTarget(int target[], int num)
{
    int i;

    for (i = 0; i < num; i++) {
        scanf("%d", target + i);
    }
}

Measured memory_bytes: 720
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    string a,b;
    cin>>a>>b;
    int ans=1e9;
    rep(i,0,a.size()-b.size()){
        string t=a.substr(i,b.size());
        int cnt=0;
        rep(j,0,t.size()-1) cnt+=(t[j]!=b[j]);
        ans=min(ans,cnt);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
using namespace std;
typedef long long ll;
ll n;
int main(void){
    // Your code here!
    cin >> n;
    if (n % 2 == 0){
        cout << n * n / 4 << endl;
    } else {
        cout << n / 2 * (n / 2 + 1) << endl;
    }
}


Measured memory_bytes: 764
#include <stdio.h>

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a < b) {
        printf("a < b\n");
    } else if (a > b) {
        printf("a > b\n");
    } else {
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
全部素因数分解していくか
必要な積の素数はもってこれる。
あとは差分の和をとっていく

TLEか･･･。
10000*1000*10くらい
ぎりぎりだめか
エラトステネスの篩
最初に10^6までの素数配列を全部用意しておくわけか

全Map化したらめっちゃ遅くなったな･･･。もうわからん。
割るという行為をしたくないんだが。逆元とるしかないのか。


2  3  3  5  6 
2  6  6  30 30
15 10 10 6  5
1
3  2//既存3倍、あらたに6/3=2を追加
3  2  2//既存1倍、あらたに6/3
15 10 10 6//既存5倍、新たに30/5

2  6 10 15 
2  6 30 30
15 5 3  2
1
3  1//既存3倍、あらたに6/6(gcd)=1を追加
15 5 3//既存5倍(10/2 A/gcd)、あらたに30/10 lcm/A
lcmつかいたくない
毎回計算すんのかな

既存の倍数からあふれるやつは拾える。
6 10
5がわかる

どうしよう

lcm毎回とるとして、MODで割っちゃうと、逆元とる必要出てくる・・・。
毎回LCM出しなおすか
Least common multiple

なお遅くなってしまったな
るーとA回だけでansの処理どうやるんだ
逆元使うのかーーーー
a^(mod-2)が逆元？
それで-2してるのか
そんな簡単にだせるんかい
lcmだして、A[i]の逆元で割ればおしまいか
*/

vector<bool> is_prime(1e6+10,true);
vector<ll> P(0,0), inv(1e6+10,0);
ll MOD=1e9+7;

void Eratosthenes(const ll N){
  for(ll i=2; i<=N; i++){
    if(is_prime[i]){
      for(ll j=2*i; j<=N; j+=i) is_prime[j]=false;
      P.emplace_back(i);
    }
  }
}

ll modpow(ll a, ll n){
  if(n==0) return 1;
  if(n==1) return a%MOD;
  if(n%2==1) return (a*modpow(a,n-1))%MOD;
  else{
    ll t=modpow(a,n/2)%MOD;
    return (t*t)%MOD;
  }
}

int main(){
  Eratosthenes(1e6+1);
  ll N, oo=4e9, ans=0, lcm=1;
  cin>>N;
  vector<ll> A(N,0);
  map<ll,ll>M;//lcmの全要素いれる
  for(ll i=0; i<N; i++){//P:素数配列
    map<ll,ll> M2;
    cin>>A[i];
    ll a=A[i];
    for(ll j=0; a>=P[j]*P[j]; j++){
      while(a%P[j]==0){
        M2[P[j]]++;
        a/=P[j];
      }
    }
    if(a>1) M2[a]++;
    for(auto v:M2){
      ll v1=v.first, v2=v.second;
      M[v1]=max(M[v1],v2);
    }
  }
  //lcm
  for(auto v:M){
    ll v1=v.first, v2=v.second;
    (lcm*=modpow(v1,v2))%=MOD;
  }
  //ans+=lcm/A[i]
  for(ll i=0; i<N; i++) (ans+=(lcm*modpow(A[i],MOD-2))%MOD)%=MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 9460
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e9;


int main(){
    multiset<ll> d;
    int N,M;
    cin>>N>>M;
    for(int i=0;i<N;i++){
        ll x;
        cin>>x;
        d.insert(x);
    }

    for(int i=0;i<M;i++){
        auto itr=d.end();
        itr--;
        //cout<<*itr<<endl;
        ll x=*itr;

        
        x/=2;
        d.erase(itr);
        d.insert(x);
    }

    ll ans=0;
    for(auto itr=d.begin();itr!=d.end();itr++){
        ans+=*itr;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
def main():
    S = input()
    T = input()

    for i in range(len(S)):
        for j in range(len(S)):
            if S[(i + j) % len(S)] != T[j]:
                break
        else:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9056
#include<stdio.h>
#include<stdlib.h>
int add(int*,int,int,int);

int main(){
  int i,n,q,*A,b;

  scanf("%d",&n);

  A=(int *)malloc(n*sizeof(int));

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

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&b);
    
    if(add(A,b,n,0)==1)
      printf("yes\n");
    else printf("no\n");
  }

  
  free(A);
  return 0;
}

int add(int *A,int b,int n,int i){
  
  if(b == 0) return 1;
  if(i>=n) return 0;

  int num= add(A,b,n,i+1)||add(A,b-A[i],n,i+1);
  return num;
}
      



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

using namespace std;

typedef long long ll;

void solve() {
	ll n;	cin >> n;
	vector<ll> arr(n);

	for (int i = 0; i < n; i++)	cin >> arr[i];
	ll last = arr[n-1];	

	for (int i = n-2; i >= 0; i--) {
		if (arr[i] > last) {
			arr[i]--;
			if (arr[i] > last) {
				cout << "No\n";	return;
			}
		}
		last = arr[i];
	}

	cout << "Yes\n";	return;
}

int main() {
	ll t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] table = new int[2][m];
		int beginMax = 0;
		int endMin = Integer.MAX_VALUE;
		for(int i = 0; i < m; i++){
			int begin = sc.nextInt();
			int end = sc.nextInt();
			if(beginMax < begin)
				beginMax = begin;
			if(end < endMin)
				endMin = end;
		}
		if(beginMax > endMin)
			System.out.println(0);
		else
			System.out.println(endMin - beginMax+1);


	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 44868
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int k,x;
  cin >> k >> x;
  if(x <= 500*k) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc081/tasks/abc081_b

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

int main() {
    int N;
    cin >> skipws;
    cin >> N;
    vector<int64_t> values;
    uint64_t x;
    int min_count = INT32_MAX;
    for (int i=0; i<N; ++i) {
        cin >> x;
        int count = 0;
        while(x != 0 && (x & 1UL) == 0) {
            x >>= 1;
            ++count;
        }
        min_count = count < min_count ? count : min_count;
    }
    cout << min_count;
}


Measured memory_bytes: 256
/**
 * 	C++14 (GCC 5.4.1)
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;



int main(){
    int P,Q,R;
    cin >> P >> Q >> R;

    int PP = P + Q;
    int QQ = Q + R;
    int RR = R + P;
    cout << min(PP,min(QQ,RR)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int digit(int x) {
  // xの桁数を返す、0は一桁とする
  int res = 1;
  while (x >= 10) {
    res++;
    x /= 10;
  }
  return res;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<P> SC(M);
  rep(i, M) {
    cin >> SC[i].first >> SC[i].second;
  }
  // 0から順に探索
  for (int i = 0; i < 1000; i++) {
    if (N != digit(i)) continue;
    vector<int> num = {i % 10};
    int j = i;
    j /= 10;
    while (j) {
      num.push_back(j%10);
      j /= 10;
    }
    reverse(num.begin(), num.end());
    bool flag = true;
    rep(i, M) {
      if (num[SC[i].first-1] != SC[i].second)  flag = false;
    }
    if (flag) {
      cout << i << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
  return 0;
}

Measured memory_bytes: 3596
import itertools
n = int(input())
L = list(map(int,input().split()))

ans = 0
ans_l = []
for v in itertools.combinations(L,3):
    if v[0] != v[1] and v[0] != v[2] and v[1] != v[2]:
        if v[0] < v[1]+v[2] and v[1] < v[0]+v[2] and v[2] < v[0]+v[1]:
            ans += 1

print (ans)


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

using namespace std;

int from_to_sum(int start, int end){
  if(end % 2 == 0){
    return (start + end) * (end / 2);
  }else{
    return (start + end) * (end / 2) + (end / 2) + 1 ;
  }
}

int main(){
  int n, k;
  std::cin >> n >> k;

  vector<int> p(n);
  for(int idx = 0; idx < n; idx++) std::cin >> p[idx];

  vector<double> expected(1001);
  for(int kind = 1; kind <= 1000; kind++){
    expected[kind] = (1 + kind) / 2.0;
  }

  vector<double> cumulative_sum(n + 1, 0);
  for(int idx = 0; idx < n; idx++){
    cumulative_sum[idx + 1] = expected[p[idx]] + cumulative_sum[idx];
  }

  double ans = -1;
  for(int idx = 0; idx + k < cumulative_sum.size(); idx++){
    double val = cumulative_sum[idx + k] - cumulative_sum[idx]; 
    if(ans < val){
      ans = val;
    }
  }

  printf("%.12lf\n", ans);
  return 0;
}


Measured memory_bytes: 2560
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
for i in R(int(input())):
    b,f,r,v=map(int,input().split())
    l[b-1][f-1][r-1]+=v
for i in R(4):
    for k in l[i]:print("",*k)
    if i!=3:print("#"*20)

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

using namespace std;

typedef long long int64;

struct edge
{
  int to, cost;
};

int N, Q, K;
vector< edge > g[100000];
int64 v[100000];

void dfs(int idx, int par = -1)
{
  for(auto &e : g[idx]) {
    if(e.to == par) continue;
    v[e.to] = v[idx] + e.cost;
    dfs(e.to, idx);
  }
}

int main()
{
  cin >> N;
  for(int i = 1; i < N; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    g[a].emplace_back((edge) {b, c});
    g[b].emplace_back((edge) {a, c});
  }
  cin >> Q >> K;
  dfs(--K);
  while(Q--) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    cout << v[x] + v[y] << endl;
  }
}

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

int main(){
int N;
  string s;
  cin >> N >> s;
  int r,b;
  r = 0;
  b = 0;

  for(int i = 0;i < N;i++){
  if(s.at(i) == 'R'){
  r++;
  }
  else b++;
  }
  if(r > b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
    long long n,h,x,y;
    scanf("%lld",&n);
    h=sqrt(n);
    for(int i=h;i>0;i--){
        if(n%i==0){
            x=i;
            y=n/i;
            break;
        }
    }
    printf("%lld\n",x+y-2);
    return 0;
}


Measured memory_bytes: 128
#/*
	AUTHOR:shivam51
	IIESTS
*/
#include<bits/stdc++.h>
using namespace std;
//
typedef long long ll;
#define add accumulate
// #define ll long long int
#define ff first
#define ss second
// typedef second ss;
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) v.begin(), v.end()
#define rep(i,k,n) for(int i=k;i<n;i++)
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
const ll mod=1e9+7;
const ll MAX=3e6+10;
//
//
	void solve(){
		ll n,m;
		cin>>n>>m;
		string str[n];
		rep(i,0,n)	cin>>str[i];
		int l[n][m],r[n][m],u[n][m],d[n][m];
		rep(i,0,n)
			rep(j,0,m){
				if(str[i][j]=='#')
					l[i][j]=0;
				else if(j==0)
					l[i][j]=1;
				else
					l[i][j]=l[i][j-1]+1;
			}
		rep(i,0,n)
			for(int j=m-1;j>=0;j--){
				if(str[i][j]=='#')
					r[i][j]=0;
				else if(j==m-1)
					r[i][j]=1;
				else
					r[i][j]=r[i][j+1]+1;
			}
		rep(i,0,n)
			rep(j,0,m){
				if(str[i][j]=='#')
					u[i][j]=0;
				else if(i==0)
					u[i][j]=1;
				else
					u[i][j]=u[i-1][j]+1;
			}
		for(int i=n-1;i>=0;i--)
			rep(j,0,m){
				if(str[i][j]=='#')
					d[i][j]=0;
				else if(i==n-1)
					d[i][j]=1;
				else
					d[i][j]=d[i+1][j]+1;
			}
		int ans=0;
		rep(i,0,n)
			rep(j,0,m)
				ans=max(ans,l[i][j]+u[i][j]+d[i][j]+r[i][j]);
		cout<<ans-3;
	}
	int main(){ 
			 ll t;
			 // cin>>t;
			 t=1;
			 rep(i,1,t+1){
				// cout<<"Case #"<<i<<": ";
				 solve();
			 }
			 return 0;
	} 

Measured memory_bytes: 66816
#include <cstdio>
#include <climits>
using namespace std;

int main()
{
	int n;
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		
		int l_roote[16] = {a};
		int l = 0;
		if (a < 1 || a > 5){
			l = INT_MAX;
		}
		else {
			int p = a;
			int angle = -1;
			while (p != b){
				p += angle;
				
				if (p == -1){
					p = 1;
					angle = 1;
				}
				else if (p == 10){
					p = 5;
					angle = -1;
				}
				
				l_roote[++l] = p;
			}
		}
		
		int r_roote[16] = {a};
		int r = 0;
		
			int p = a;
			int angle = 1;
			while (p != b){
				p += angle;
				
				if (p == -1){
					p = 1;
					angle = 1;
				}
				else if (p == 10){
					p = 5;
					angle = -1;
				}
				
				r_roote[++r] = p;
			}
		
		if (l < r){
			for (int j = 0; j <= l; j++){
				if (j != 0){
					printf(" ");
				}
				printf("%d", l_roote[j]);
			}
		}
		else {
			for (int j = 0; j <= r; j++){
				if (j != 0){
					printf(" ");
				}
				printf("%d", r_roote[j]);
			}
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, 0, n) cin >> a[i];

  vector<P> vp;
  rep(i, 0, m) {
    int b, c;
    cin >> b >> c;
    vp.emplace_back(c, b);
  }

  sort(a.begin(), a.end());
  sort(vp.begin(), vp.end());

  ll ans = 0;
  rep(i, 0, n) {
    if (vp.empty() || vp.back().first <= a[i]) {
      ans += a[i];
      continue;
    }
    ans += vp.back().first;
    vp.back().second--;
    if (vp.back().second == 0) vp.pop_back();
  }

  cout << ans << endl;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll N, K;
    cin >> N >> K;

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

    ll mx = *max_element(A.begin(), A.end());
    ll g = 0;
    for (ll i = 0; i < N; i++) {
        g = __gcd(g, A[i]);
    }

    bool ok = true;
    if (mx < K) {
        ok = false;
    }

    if (K % g != 0) {
        ok = false;
    }

    cout << (ok ? "POSSIBLE\n" : "IMPOSSIBLE\n");

    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
from collections import deque
from math import inf


def input(): return sys.stdin.readline().strip()


def bfs(maze, Ch, Cw, Dh, Dw, H, W):
    visited = [[inf] * W for i in range(H)]
    queue = deque([[Ch, Cw]])
    visited[Ch][Cw] = 0

    dy_dx0 = [[0, 1], [1, 0], [0, -1], [-1, 0]]
    dy_dx1 = [[2, 2], [2, 1], [2, 0], [2, -1], [2, -2], [1, 2], [1, 1], [1, -1], [1, -2], [0, 2],
              [0, -2], [-1, 2], [-1, 1], [-1, -1], [-1, -2], [-2, 2], [-2, 1], [-2, 0], [-2, -1], [-2, -2]]

    while queue:
        y, x = queue.popleft()
        if [y, x] == [Dh, Dw]:
            break
        for j, k in dy_dx0:
            new_y, new_x = y + j, x + k
            if 0 <= new_y < H and 0 <= new_x < W and maze[new_y][new_x] == "." and visited[y][x] < visited[new_y][new_x]:
                visited[new_y][new_x] = visited[y][x]
                queue.appendleft([new_y, new_x])
        for j, k in dy_dx1:
            new_y, new_x = y + j, x + k
            if 0 <= new_y < H and 0 <= new_x < W and maze[new_y][new_x] == "." and visited[new_y][new_x] == inf:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
    return visited[Dh][Dw]


def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    maze = [input() for i in range(H)]

    dist = bfs(maze, Ch - 1, Cw - 1, Dh - 1, Dw - 1, H, W)

    print(dist if dist != inf else -1)


if __name__ == "__main__":
    main()


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

int main() {

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	long long n, d, i, c = 0;
	cin >> n >> d;

	long long t = d * d, a, b;
	for (i = 0 ; i < n ; i++)
	{
		cin >> a >> b;

		if (a * a + b * b <= t)
			c++;
	}

	cout << c;

	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
  int i, j, tmp;
  char a[100], b[100];
  scanf("%s %s", a, b);
  for( i = 0; i < strlen(a); i++){
    for( j = i + 1 ; j < strlen(a); j++){
      if( a[i] > a[j]){
        tmp = a[j];
        a[j] = a[i];
        a[i] = tmp;
      }
    }
  }
  for( i = 0; i < strlen(b); i++){
    for( j = i + 1 ; j < strlen(b); j++){
      if( b[i] < b[j]){
        tmp = b[j];
        b[j] = b[i];
        b[i] = tmp;
      }
    }
  }
  if( strcmp( a, b) < 0 ){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void darts();

int main()
{
  darts();
}


void darts()
{
  while (true)
  {
    int n, m;
    cin >> n >> m;

    // stop cond
    if (n == 0) break;

    vector<int> p(n);
    for (int i = 0; i < n; ++i) cin >> p[i];

    // 2 darts combination
    // p = q, 0, p + q
    vector<int> q = p;
    q.push_back(0);
    for (int i = 0; i < n; ++i)
    {
      for (int j = 0; j <= i; ++j)
      {
        q.push_back(p[i] + p[j]);
      }
    }

    sort(q.begin(), q.end());

    // q's size = 1 + n + n(n + 1) / 2
    //cout << q.size() << "\n";
    //for (auto x : q) cout << x << " ";

    int ret = 0;
    int j = q.size() - 1;
    //i:q linear scan
    for (int i = 0; i < q.size(); ++i)
    {
      if (q[i] > m) break;
      while (q[i] + q[j] > m) --j;
      ret = max(ret, q[i] + q[j]);
    }

    cout << ret << "\n";
  }
}


Measured memory_bytes: 6836
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	string x,y;
	int ans=0;
	
	cin>>x>>y;
	if(x<y)
	{
		cout<<"<"<<endl;
	}else if(x>y){
		cout<<">"<<endl;
	}else{
		cout<<"="<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations
import heapq
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
D = [[] for _ in range(N)]
inf = float("inf")
for i in range(N):
    for j in range(N):
        if i == j:
            D[i].append(0)
        else:
            D[i].append(inf)

for _ in range(M):
    a, b, c = map(int, input().split())
    D[a - 1][b - 1] = c
    D[b - 1][a - 1] = c


def WarshallFloyd(D):
    """
    >>> WarshallFloyd([[0, 1, 4], [1, 0, 1], [4, 1, 0]])
    [[0, 1, 2], [1, 0, 1], [2, 1, 0]]
    """
    for k in range(len(D)):
        for i in range(len(D)):
            for j in range(len(D)):
                D[i][j] = min(D[i][j], D[i][k] + D[k][j])
    return D


def _dijkstra(D, s, F):
    q = []
    heapq.heappush(q, (0, s))
    while len(q) != 0:
        cost, index = heapq.heappop(q)
        if F[s][index] < cost:
            continue
        for i in range(len(D)):
            if cost + D[index][i] < F[s][i]:
                F[s][i] = cost + D[index][i]
                heapq.heappush(q, (F[s][i], i))
    return F


def Dijkstra(D):
    F = [[inf] * len(D) for _ in range(len(D))]
    for i in range(len(D)):
        F[i][i] = 0
        F = _dijkstra(D, i, F)
    return F


#W = WarshallFloyd(D)
D = Dijkstra(D)
# print(W)
# print(D)
Min = inf
for e in permutations(r):
    s = 0
    for i in range(R - 1):
        s += D[e[i] - 1][e[i + 1] - 1]
    Min = min(s, Min)

print(Min)


Measured memory_bytes: 5716
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main() {
	long H;
  	long sum=0;
  	scanf("%ld", &H);
  	for(int i=0;H>0;i++){
    	H /= 2;
      	sum += pow(2, i);
    }
  	printf("%ld", sum);
}

Measured memory_bytes: 384
require 'pp'

a_n = gets.chomp!.split(" ").map(&:to_i)

min = 999999999
a_n.permutation do |x|
    y = (x[1] - x[0]).abs + (x[2] - x[1]).abs
    if y < min
        min = y
    end
end
 
puts min


Measured memory_bytes: 2044
#include <stdio.h>
 
int main(void){
 
  int a,b,c;
  int count = 0;
  int i;
 
  scanf("%d %d %d",&a,&b,&c);
  for(i = a;i <= b;i++){
    if(c % i == 0){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(ll i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 1e5+5;
string s;
vector<ll> v;
int n,k;

int main() {
  cin >> n >> k >> s;
  v.push_back(0);
  rep(i,n-1) {
    if(s[i] != s[i+1]) v.push_back(i+1);
  }
  v.push_back(n);
  if(2*k >= v.size()) {
    cout << n << endl;
    return 0;
  };
  ll result = 0;
  if(s[0] == '0') result = v[2*k];
  // cout << result << endl;
  if(s[n-1] == '0') result = max(result, v.back() - v[v.size() - 1 - 2 * k]);
  // cout << result << endl;
  for(int i=s[0] == '0' ? 1 : 0; i+2*k+1 < (s[n-1] == '0' ? v.size()-1 : v.size()); i+=2) {
    result = max(result, v[i+2*k+1] - v[i]);
    // cout << result << endl;
  }
  cout << result << endl;
}


Measured memory_bytes: 1528
#include <iostream>

int main() {
    int K;
    std::cin >> K;
    int m = 0;
    for (int i = 0; i < K; i++) {
        m = (m * 10 + 7 % K) % K;
        if (m == 0) {
            std::cout << i + 1 << std::endl;
            exit(0);
        }
    }
    std::cout << -1 << std::endl;
}

Measured memory_bytes: 3624
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    // #pragma GCC optimize("Ofast")
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define F first
    #define S second
    #define pb push_back
    #define mkp make_pair
    #define int long long
    #define ld long double

    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ D $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    void solve()
    {
        cin>>n;
        cout<<n+n*n+n*n*n<<endl;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          THE GAME STARTS HERE                             //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        
        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;

int main(){
	int n;
    cin>>n;
    vector<ll> a(n);
    REP(i,n){
        cin>>a[i];
    }
    ll ans=0;
    vector<ll> po(61);
    po[0]=1;
    REP(j,60){
        int cnt=0;
        po[j+1]=2*po[j];
        po[j+1]%=MOD;
        REP(i,n){
            if((a[i]>>j)&1){
                cnt++;
            }
        }
        ll tmp=po[j];
        tmp*=cnt;
        tmp%=MOD;
        tmp*=(n-cnt);
        tmp%=MOD;
        ans+=tmp;
        ans%=MOD;
    }
    OUT(ans);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define Senky_Bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    Senky_Bansal
    IIIT_ALLAHABAD
    ll h,w,h1,w1;
  cin>>h>>w>>h1>>w1;
  cout<<(h-h1)*(w-w1)<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
l=[0] * m
r=[0] * m
for i in range(m):
  l[i], r[i] = map(int, input().split())
l.sort()
r.sort()
if r[0] - l[m-1] + 1 > 0:
  print(r[0] - l[m-1] + 1)
else:
  print("0")

Measured memory_bytes: 46552
#include<iostream>

typedef long long ll; 
using namespace std;

int main(){
    ll w, h, x, y; cin >> w >> h >> x >> y;
    bool b = (w / 2.0 == x) && (h / 2.0 == y); 

    cout << w * h / 2.0 << ' ' << b;
}


Measured memory_bytes: 256