akhauriyash/Code-Regression huggingface dataset:
n,m=map(int,input().split())
map1=[[float('inf')]*n for i in range(n)]
map2=[[float('inf')]*n for i in range(n)]
for i in range(n):
    map1[i][i]=0
    map2[i][i]=0
for i in range(m):
    a,b,c=map(int,input().split())
    map1[a-1][b-1]=c
    map1[b-1][a-1]=c
    map2[a-1][b-1]=c
    map2[b-1][a-1]=c

#Warshall_Floyd法
for k in range(n):
    for i in range(n):
        for j in range(n):
            map1[i][j]=min(map1[i][j],map1[i][k]+map1[k][j])
ans=0
for i in range(n):
    for j in range(n):
        if map2[i][j]!=float('inf') and map2[i][j]!=map1[i][j]:
            ans+=1
print(int(ans/2))

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int a,b,c,s;
int main(){
	cin>>a>>b>>c;
	int d=max(max(a,b),c);
	d=d*3;
	d-=a;
	d-=b;
	d-=c;
	if(d%2==0)
	s=d/2;
	else
	s=(d+3)/2;
	cout<<s;
 } 

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    string a,b;
    cin>>a>>b;
    if(a==b) cout<<"EQUAL"<<endl;
    else if(a.size()>b.size()||a.size()==b.size()&&a>b) cout<<"GREATER"<<endl;
    else cout<<"LESS"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    string S1, S2;
    rep(i, A) S1 += '0';
    rep(i, W - A) S1 += '1';
    rep(i, A) S2 += '1';
    rep(i, W - A) S2 += '0';
    rep(i, B) {
        cout << S1 << endl;
        cout << S2 << endl;
    }
    rep(i, H - B * 2) {
        cout << S2 << endl;
    }

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(void)
{
    int ans=0, n, d[1000]={0}, l[1000], x, i;
    cin >> n >> x;
    for(i=0;i<n;i++){
        cin >> l[i];
    }
    for(i=0;i<=n;i++){
        if(i==0) d[i]=0;
        else d[i]=d[i-1]+l[i-1];
        if(d[i]<=x){
            ans++;
        }
    }
    cout << ans <<endl;
    return 0;
}


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

int main() {
  int q;
  scanf("%d", &q);
  for(int o = 1, x, y; o <= q; ++o) {
    scanf("%d%d", &x, &y);
    if(x == y) {
      printf("%d\n", 2 * (x - 1));
    } else {
      if(x > y) swap(x, y);
      ll pos = 1ll * x * y, gg = sqrtl(pos - 1);
      ll ans = 2 * gg - 1;
      if((pos - 1) / gg == gg) {
        ans--;
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}

/*
8
1 4
10 5
3 3
4 11
8 9
22 40
8 36
314159265 358979323

1
12
4
11
14
57
31
671644785

*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Scanner s = new Scanner(System.in);
        
        int longestWait = 10;
        int wait = 0;
        
        for (int i = 0; i < 5; i ++) {
            int in = s.nextInt();
            wait += 10 * (int) Math.ceil((double) in / 10);
            if (in % 10 < longestWait && in % 10 != 0)
                longestWait = in % 10;
        }
        
        System.out.println(wait - 10 + longestWait);
        
    }
    
}


Measured memory_bytes: 19796
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 


#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)1e5+5

void solve(){
    ll m, d;
    cin>>m>>d;
    ll ans = 0;
    for(ll i=1; i<=m; i++){
        for(ll j=1; j<=d; j++){
            ll d1 = j%10;
            ll d2 = (j-j%10)/10;

            if(d1>=2 && d2>=2 && d1*d2 == i){
                ans++;
            }
        }
    }
    print(ans);
}

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

    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
   
}



Measured memory_bytes: 256
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libnum {{{*/
void amax(N, Args...)(ref N x, Args y) {
  x = x.max(y);
}
void amin(N, Args...)(ref N x, Args y) {
  x = x.min(y);
}
auto maxE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amax(y);
  return x;
}
auto minE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amin(y);
  return x;
}
/*}}}*/


/+---test
2 3 3
---+/
/+---test
500000000000 500000000000 1000000000000
---+/

void main(string[] args) {
  long A, B, K;
  readf(" %d %d %d ", &A, &B, &K);

  if (A >= K) {
    A -= K;
  } else {
    B -= K - A;
    A = 0;
  }
  A.amax(0);
  B.amax(0);
  "%d %d".writefln(A, B);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S;
	bool ans = true;
	cin >> S;
	rep(i, 3) if (S[i] == S[i + 1]) ans = false;
	if (ans) cout << "Good" << endl;
	else cout << "Bad" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

long long gcd(long long A, long long B) {
  if (B == 0) return A;
  return gcd(B, A % B);
}

int main() {
  long A, B;
  cin >> A >> B;

  long C = gcd(A, B);

  // cout << C << endl;

  int count = 1;
  for (int i = 2; i < sqrt(C) + 1; i++) {
    if (C % i == 0) {
      count += 1;
      while (C % i == 0) C /= i;
    }
  }

  if (C > 1) count += 1;

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
// Problem : B - Popular Vote
// Contest : AtCoder Beginner Contest 161
// URL : https://atcoder.jp/contests/abc161/tasks/abc161_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;
int arr[maxN], sum;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	REP(i, n) {cin >> arr[i]; sum += arr[i]; }
	sort(arr, arr + n, greater<int>());
	ld p = sum * 1.0 / (4 * m);
	REP(i, m) {
		//cout << arr[i] << " " << sum / (4 * m) << endl;
		if (arr[i] < p) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}
 


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

struct UnionFind
{
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]); 
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return sizes[find(x)];
  }
};

int main(){
    ll n; cin>>n;
    ll m; cin>>m;
    UnionFind uf(n);
    int a[m],b[m];
    rep(i,m){
         cin>>a[i]>>b[i];
         a[i]--;b[i]--;
    }  
    
    ll ans[m+1]={0};
    for(int i=0;i<m;i++){
            if(uf.same(a[m-1-i],b[m-1-i])){
                ans[i+1]=ans[i];
            }
            else{
              ans[i+1]=ans[i]+uf.size(a[m-1-i])*uf.size(b[m-1-i]);
              uf.unite(a[m-1-i],b[m-1-i]);
            }
    }
    
    rep(i,m) cout<<n*(n-1)/2-ans[m-1-i]<<endl;
    
}

Measured memory_bytes: 3712
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int check(LL start, LL end, LL base) {
  if (end < base/2) return 0;

  start = std::max(start, base/2);
  return std::abs((end - start + 1)%2);
}

int main() {
  LL A, B; std::cin >> A >> B;

  LL out = 0;
  LL a = A%4;
  LL b = B%4;
  if (b<a) b += 4;
  switch((b-a)%4) {
    case 0:
      out = a%2;
      break;
    case 1:
      out = 1;
      break;
    case 2:
      out = !(a%2);
      break;
    default:
      break;
  }

  LL ans = 0;
  LL k = 4;

  while(k<=B*2) {
    LL a = A % k;
    LL b = B % k;

    if (a < b) {
      if (check(a, b, k)) out += k/2;
    } else {
      int c1 = check(a, k-1, k);
      int c2 = check(0, b, k);
      if (c1^c2) out += k/2;
    }
    k *= 2;
  }
  std::cout << out << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include <vector>
int main(){
   long long int a,b;
   cin>>a>>b;
   long long int x=a*b;
   long long int tmp,r;
   if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
    long long int ans=x/b;
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#!/mnt/c/Users/moiki/bash/env/bin/python
H,W,K = list(map(int, input().split() ))
mod = int(1e9+7) 
# mod = 1000000007



def disp(dp):
    for i in range(H+1):
        print(i, end=" ")
        for j in range(W):
            print(dp[i][j],end=", ")
        print("")


dp = [[0] * W for h in range(H+1)]
dp[0][0] = 1

# disp(dp)

for i in range(H):
    for j in range(W):
        # disp(dp)
        for k in range((1<<W-1) ):
            # print("k = {}".format(bin(k)))
            ok = True
            for l in range(W-1):
                if (k&(1<<l)!=0) and (k&(1<<(l+1))!=0):
                    ok = False
            
            if ok:
                if j>0 and k&(1<<(j-1)): # to left
                    dp[i+1][j-1] += dp[i][j]
                    dp[i+1][j-1] %= mod
                    dp[i+1][j-1] = int(dp[i+1][j-1])

                elif j<W and k&(1<<(j)):   # to right
                    dp[i+1][j+1] += dp[i][j]
                    dp[i+1][j+1] %= mod
                    dp[i+1][j+1] = int(dp[i+1][j+1])
                else:
                    dp[i+1][j] += dp[i][j]
                    dp[i+1][j] %= mod
                    dp[i+1][j] = int(dp[i+1][j])
                # print("OK")
                
            else:
                continue

       

# print("last disp")
# disp(dp)
print(dp[H][K-1] % mod)
# print(mod)
# print(1000000007)

Measured memory_bytes: 3188
// AOJ CGL_7_E Cross Points of Circles
// 2018.5.3 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct { double x, y; } PP;
typedef struct { double x, y, r; } C;

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF 1e8
#define EPS 1e-8
#define EQ(a,b)		(fabs((a)-(b))<EPS)

int dcmp(double x) { if (fabs(x) < EPS) return 0; return x <= 0 ? -1 : 1; }
PP vset(double x, double y) { PP r; r.x = x, r.y = y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
double vabs(PP a) { return hypot(a.x, a.y); }
double dist(PP p1, PP p2) {	return vabs(vsub(p1, p2)); }


int cmp(PP *a, PP *b)
{
	if (EQ(a->x, b->x)) return dcmp(a->y - b->y);
	return dcmp(a->x - b->x);
}

/* return
   4: if they do not cross (there are 4 common tangent lines), 
   3: if they are circumscribed (there are 3 common tangent lines), 
   2: if they intersect (there are 2 common tangent lines), 
   1: if a circle is inscribed in another (there are 1 common tangent line), 
   0: if a circle includes another (there is no common tangent line). 
*/
int intersectCC(C c1, C c2, PP *p1, PP *p2)
{
	double x1 = c1.x, y1 = c1.y, r1 = c1.r;
	double x2 = c2.x, y2 = c2.y, r2 = c2.r;
	double d = hypot(x1-x2, y1-y2);
	double w, n, x, y, p, q;
	double u, v;

	u = r1+r2, v = fabs(r1-r2);

	if (!EQ(d, u) && d >= u)   return 0;  // return 4;
	if (!EQ(d, v) && d <= v)   return 0;

	w = ((r1*r1 - r2*r2)/d + d) / 2;
	n = sqrt(r1*r1 - w*w);
	x = x1 + (x2-x1)*w / d;
	y = y1 + (y2-y1)*w / d;
	p = (y2-y1)*n / d;
	q = (x2-x1)*n / d;

	p1->x = x+p, p2->x = x-p;
	p1->y = y-q; p2->y = y+q;
	if (EQ(d, u))				return 1;   // return 3;
	if (EQ(d, v))				return 1;
	return 2;
}

int main()
{
	int i;
	C c1, c2;
	PP p[2];

	c1.x = in(), c1.y = in(), c1.r = in();
	c2.x = in(), c2.y = in(), c2.r = in();
	intersectCC(c1, c2, p, p+1);
	qsort(p, 2, sizeof(PP), cmp);
	for (i = 0; i < 2; i++) {
		printf("%.10lf %.10lf", p[i].x, p[i].y);
		putchar(' ');
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 2120
#include<cstdio>
#include<cstdlib>
#include<cstring>

typedef struct Node *PtrToNode;
typedef PtrToNode List;
typedef PtrToNode Position;
struct Node{
	int num;
	Position Next;
	Position Before;
};

void Insert(List L,int e)
{
	Position Current;
	Current=(Position)malloc(sizeof(struct Node));
	Current->num=e;
	if(L->Next==L)
	{
		Current->Next=L;
		Current->Before=L;
		L->Before=Current;
		L->Next=Current;
	}
	else
	{
		Current->Next=L->Next;
		Current->Before=L;
		L->Next->Before=Current;
		L->Next=Current;
	}
}

void Delete(List L,int x)
{
	Position TmpCell=L;
	while((TmpCell->Next)!=L)
	{
		Position Current=TmpCell->Next;
		if((Current->num)==x)
		{
			TmpCell->Next=Current->Next;
			Current->Next->Before=TmpCell;
			break;
		}
		TmpCell=Current;
	}
}

void deleteFirst(List L)
{
	if(L->Next!=L)
	{
		Position Current=L->Next;
		L->Next=Current->Next;
		Current->Next->Before=L;
	}
}

void deleteLast(List L)
{
	L->Before->Before->Next=L;
	L->Before=L->Before->Before;
}

void printList(List L)
{
	Position TmpCell=L;
	while(TmpCell->Next!=L)
	{
		Position Current=TmpCell->Next;
		printf("%d",Current->num);
		if(Current->Next!=L)
			printf(" ");
		TmpCell=Current;
	}
	printf("\n");
}
int main()
{
	int n;
	scanf("%d",&n);
	char op[15];
	int e;
	List L=(Position)malloc(sizeof(struct Node));
	L->num=-1;
	L->Next=L;
	L->Before=L;
	for(int i=0;i<n;i++)
	{
		scanf("%s",op);
		if(strcmp(op,"insert")==0)
		{
			scanf("%d",&e);
			Insert(L,e);
		}
		else if(strcmp(op,"delete")==0)
		{
			scanf("%d",&e);
			Delete(L,e);
		}
		else if(strcmp(op,"deleteFirst")==0)deleteFirst(L);
		else if(strcmp(op,"deleteLast")==0)deleteLast(L);
	}
	printList(L);
	return 0;
}

Measured memory_bytes: 37000
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	string S;
	cin>>S;
	int l=sz(S);
	if(S[0]==S[l-1])l++;
	if(l%2==0)cout<<"Second"<<endl;
	else cout<<"First"<<endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iterator>
#include <cstdio>
#include <vector>
using namespace std;

const int MAXN = 100000 + 10;

inline int myAbs(int x)
{
	if(x > 0)
		return x;
	return -x;
}

int ans = 0x7FFFFFFF;
int N, K;
int zeropos = -1;
vector <int> x;

int main(int argc, char * argv[])
{
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);

	cin >> N >> K ;

	for(int i = 0; i < N; i++)
	{
		int t;
		cin >> t ;

		if(zeropos < 0 && t >= 0)
		{
			zeropos = x.size();
			if(t)
				x.push_back(0),	K++;
		}
		x.push_back(t);
	}

	if(zeropos < 0)
	{
		zeropos = x.size();
		x.push_back(0), K++;
	}

//	copy(x.begin(), x.end(), ostream_iterator <int> (cerr, " "));

	for(int i = 0; i < x.size(); i++)
	{
		if(i <= zeropos && i + K - 1 < x.size() && i + K - 1 >= zeropos)
		{
//			if(ans > myAbs(x[i]) * 2 + myAbs(x[i + K - 1]))
//					cerr << "Changing answer to : " << myAbs(x[i]) * 2 + myAbs(x[i + K - 1]) << " " << i << " " << i + K - 1 << endl ;
			ans = min(ans, myAbs(x[i]) * 2 + myAbs(x[i + K - 1]));
//			cerr << "Selecting 1 : " << i << " " << i + K - 1 << endl ;
		}
		if(i >= zeropos && i - K + 1 >= 0 && i - K + 1 <= zeropos)
		{
			ans = min(ans, myAbs(x[i]) * 2 + myAbs(x[i - K + 1]));
//			cerr << "Selecting 2 : " << i << " " << i - K + 1 << endl ;
		}
	}


	cout << ans << endl ;

	return 0;
}


Measured memory_bytes: 892
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	string s;
	cin >> s;
	for(auto x: s)
		if(x=='7')
			return cout << "Yes", 0;
	cout << "No";


	return 0;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {
	static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] arr = new int[n + 1];
		HashSet<Integer> set = new HashSet<>();
		for (int i = 0; i < m; i ++) {
			set.add(sc.nextInt());
		}
		arr[0] = 1;
		if (set.contains(1)) {
			arr[1] = 0;
		} else {
			arr[1] = 1;
		}
		for (int i = 2; i <= n; i++) {
			if (set.contains(i)) {
				arr[i] = 0;
			} else {
				int x = arr[i - 2] + arr[i - 1];
				x %= MOD;
				arr[i] = x;
			}
		}
		System.out.println(arr[n]);
	}
}


Measured memory_bytes: 63260
#include <iostream>

using namespace std;

int main(void) {
	//中間試験の点数 m、期末試験の点数 f、再試験の点数 r
	int m, f, r;
	cin >> m >> f >> r;

	while (m != -1 || f != -1 || r != -1)
	{
		if (m == -1 || f == -1)
		{
			cout << "F" << endl;
		}
		else if (80 <= m + f)
		{
			cout << "A" << endl;
		}
		else if (65 <= m + f)
		{
			cout << "B" << endl;
		}
		else if (50 <= m + f)
		{
			cout << "C" << endl;
		}
		else if (30 <= m + f)
		{
			if (50 <= r)
			{
				cout << "C" << endl;
			}
			else
			{
				cout << "D" << endl;
			}
		}
		else
		{
			cout << "F" << endl;
		}
		cin >> m >> f >> r;
	}
	return 0;
}


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

int main() {

  int N;
  int secsum=0;

  cin >> N;
  vector<string> sing(N);
  vector<int> sec(N);

  for(int i=0; i < N; i++){
    cin >> sing.at(i) >> sec.at(i);
  }

  string X;
  cin >> X;

  for(int j=0; j<N; j++){
    if(sing.at(j)==X){
      for(int h=j+1;h<N;h++){
        secsum+=sec.at(h);
      }
    }
  }

  cout << secsum <<endl;
}


Measured memory_bytes: 256
/**
*   @Author : MeGaCrazy
*   @InitTime : Sat Dec 29 14:33:29 2018
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
  int n;
  scanf("%d",&n);    
  int s=0;
  vector<int>v;

  for(int i=0;i<n;i++){
  	int a;
  	scanf("%d",&a);
  	v.push_back(a);
  }
  int ans=2e9;
  for(int i=-200;i<=200;i++){
        int cur=0;
  	for(int j=0;j<n;j++){
  	   cur+=(i-v[j])*(i-v[j]);
  	}
  	ans=min(cur,ans);
  }
  printf("%d",ans);




}

Measured memory_bytes: 256
#define s(a,b) (t=a,a=b,b=t)
f(int*a){*a=(*a&7)<<4|*a>>4;}char p[9],m;q,a,b,c,t,r;main(n){while(scanf("%d",&n),n){r=1,a=22,b=37,c=52;while(n--){scanf("%s",p);m=*p-76;if(m%6==0){s(b,c);q=m>0?f(&c):f(&b);}else if(1<m&&m<8){s(a,b);q=m^7?f(&b):f(&a);}else{s(a,c);q=m>0?f(&c):f(&a);}r+=a>>4;}printf("%d\n",r);}}

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

int main(){
	int n;
	string s;
	cin >> n >> s;
	int cnt=n;

	int sumW[n];
	int sum=0;
	for(int i=0; i<n; ++i){
		if(s[i]=='W') ++sum;
		sumW[i]=sum;
	}
	cout << endl;

	int sumE[n];
	sum=0;
	for(int i=0; i<n; ++i){
		if(s[i]=='E') ++sum;
		sumE[i]=sum;
	}
	cout << endl;

	int final_sum;

	final_sum = sumE[n-1]-sumE[0];
	if(final_sum < cnt) cnt=final_sum; 

	for(int i=1; i<n; ++i){
		final_sum = sumW[i-1]+sumE[n-1]-sumE[i];
		if(final_sum < cnt) cnt=final_sum; 
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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(){
  int H,W,K;
  cin >> H >> W >> K;
  vector<vector<int>> dp(H+1,vector<int> (W,0));
  dp[0][0] = 1;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      for(int k=0; k<(1<<(W-1)); k++){
        bool ok = true;
        for(int l=0; l<W-2; l++){
          if(((k>>l) & 1) && ((k>>(l+1)) & 1)){
            ok = false;
          }
        }
        if(ok){
          if(j>=1 && ((k>>(j-1)) & 1)){
            dp[i+1][j-1] += dp[i][j];
            dp[i+1][j-1] %= mod;
          }else if(W-2>=j && ((k>>j) & 1)){
            dp[i+1][j+1] += dp[i][j];
            dp[i+1][j+1] %= mod;
          }else{
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
          }
        }
      }
    }
  }
  cout << dp[H][K-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define pi 3.14159265
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll, ll> pll;
const ll M=1e9+7;
ll inf=1e18;
int main()
{
    int n,k;
    cin>>n>>k;
    vector <int> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<k;i++)
        sum+=v[i];
    cout<<sum;
}


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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define all(a) a.begin(),a.end()
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;

int main(){
    int k,s;
    cin >> k >> s;
    int ans=0;
    rep(i,0,k){
        rep(j,0,k){
            if(i+j>=s-k&&i+j<=s){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,tot;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		if(i%2!=0)
			tot++;
	printf("%.6lf",(double)tot/n);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    String y = sc.next();
    String z = sc.next();
    char[] a = x.toCharArray();
    char[] b = y.toCharArray();
    char[] c = z.toCharArray();

    System.out.print(a[0]);
    System.out.print(b[1]);
    System.out.print(c[2]);
    System.out.println("");

  }

}


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

vector<int> graph[100000];
long long n, k;

long long MOD = 1000000007;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1; finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long dfs(int cur, int parent) {
  int deg = graph[cur].size() - 1;
  long long ret;
  if (parent == -1) {
    ret = fac[k-1] * finv[k - 2 - deg];
  } else {
    ret = fac[k-2] * finv[k - 2 - deg];
  }
  ret %= MOD;
  for (int to: graph[cur]) {
    if (to == parent) {
      continue;
    }
    ret *= dfs(to, cur);
    ret %= MOD;
  }
  return ret;
}

int main() {
  cin>>n>>k;
  for (int i=0; i<n-1; i++) {
    int a, b;
    cin>>a>>b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (int i=0; i<n; i++) {
    if (graph[i].size() >= k) {
      cout<<0<<endl;
      return 0;
    }
  }
  COMinit();
  cout<<((k * dfs(0, -1)) % MOD)<<endl;

}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % 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; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    if(W%2 == 0 && H % 2 == 0){
        cout << W * H / 2.0 << " " << ((x == W/2) && (y == H/2)) << endl;
    }else{
        cout << W * H / 2.0 << " " << 0 << endl;
    }


    return 0;
}



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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(0,c - (a - b)) << endl;
}


Measured memory_bytes: 256
import sys

def CountingSort(A,B,k):
    C = [0]*(10001)
    for i in range(n):
        C[A[i+1]] += 1
    for i in range(1,k+1):
        C[i] = C[i] + C[i-1]
    for i in range(1,n+1):
        B[C[A[i]]] = A[i]
        C[A[i]]-=1

if __name__ == "__main__":
    n = int(input())
    A = [0] + list(map(int,input().split()))
    k = 10000
    B = [0]*(n+1)
    CountingSort(A,B,k)
    print(*B[1:])




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

  int H, W;
  int h, w;

  cin >> H >> W;
  cin >> h >> w;

  cout << H * W - (h * W + w * H - h * w) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1e9+7
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define M 1000010

ll cnt[M];
int main(){
    IOS;
 
 	ll n;cin>>n;
 	ll a[n];
 	rep(i,0,n)cin>>a[i],cnt[a[i]]++;
 	ll ans=0;
 	rep(i,0,n){
 		bool ok=1;
 		if(a[i]==1){
 			if(cnt[1]==1)ans++;
 			continue;
 		}
 		for(ll j=1;j*j<=a[i];++j){
 			if(a[i]%j==0){
 				if(cnt[j])ok=0;
 				if(j*j!=a[i]){
 					ll t=cnt[a[i]/j];
 					if(j==1 and t>1)ok=0;
 					if(j!=1 and t)ok=0;
 				}
 			}
 		}
 		if(ok)ans++;
 	}
 	cout<<ans;
    return 0;
}

Measured memory_bytes: 13000
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		long N=stdIn.nextLong();
		long max=0;
		for(int i=1;i<Math.sqrt(N)+1;i++){
			if(N%i==0&&max<i)
				max=i;
		}
		System.out.println(max+N/max-2);
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, int> pli;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 998244353;
const lint INF = mod*mod;
const int MAX = 100010;

typedef struct edge{
    int from, to; lint cost;
    edge(int f, int t, lint c){
        from = f; to = t; cost = c;
    }
}edge;

vector<vector<edge>> G;

typedef struct exGraph{
    int n=1, m;
    vector<int> f_id, t_id, q_id, f_v, t_v;

    exGraph(int n_, int m_) : n(n_), m(m_){
        while(n<n_) n*=2;
        f_id.resize(2*n-1);
        t_id.resize(2*n-1);
        q_id.resize(m);
        f_v.resize(n);
        t_v.resize(n);
        G.resize(4*n-2+m);

        int cur=0;
        rep(i, 2*n-1){
            f_id[i]=cur;
            if(i>=n-1) f_v[i-n+1]=cur;
            ++cur;
        }
        rep(i, 2*n-1){
            t_id[i]=cur;
            if(i>=n-1) t_v[i-n+1]=cur;
            ++cur;
        }
        rep(i, m) q_id[i]=cur++;
    }

    void add_edge(int from, int to, lint cost){
        G[from].emplace_back(from, to, cost);
    }

    void build(){
        For(i, 1, 2*n-1) add_edge(f_id[i], f_id[(i-1)/2], 0);
        rep(i, n-1){
            add_edge(t_id[i], t_id[i*2+1], 0);
            add_edge(t_id[i], t_id[i*2+2], 0);
        }
        rep(i, n) add_edge(t_id[i+n-1], f_id[i+n-1], 0);
    }

    void f_query(int a, int b, int t){
        for(a+=n-1, b+=n-1; a<b; a=(a-1)/2, b=(b-1)/2){
            if(!(a&1)) add_edge(f_id[a++], q_id[t], 0);
            if(!(b&1)) add_edge(f_id[--b], q_id[t], 0);
        }
    }

    void t_query(int a, int b, int t, lint c){
        for(a+=n-1, b+=n-1; a<b; a=(a-1)/2, b=(b-1)/2){
            if(!(a&1)) add_edge(q_id[t], t_id[a++], c);
            if(!(b&1)) add_edge(q_id[t], t_id[--b], c);
        }
    }

    vector<lint> dijkstra(int s){
        vector<lint> d(4*n-2+m, INF);
        priority_queue<pli, vector<pli>, greater<>> que;
        d[f_v[s]]=0;
        que.push(pli(0, f_v[s]));
        while(!que.empty()){
            pli p=que.top(); que.pop();
            lint td=p.fi;
            int v=p.se;
            if(d[v]<td) continue;
            for(edge &e: G[v])if(chmin(d[e.to], td+e.cost)){
                que.push(pli(d[e.to], e.to));
            }
        }
        return d;
    }
}exGraph;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    exGraph xgr(n, m);
    xgr.build();
    rep(i, m){
        int L, R;
        lint c;
        scanf("%d%d%lld", &L, &R, &c);
        xgr.f_query(L-1, R, i);
        xgr.t_query(L-1, R, i, c);
    }
    int t=xgr.t_v[n-1];
    vector<lint> d=xgr.dijkstra(0);
    printf("%lld\n", d[t]<INF ? d[t] : -1LL);
}

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

using namespace std;

int main() {

	long long int n, m;
	cin >> n >> m;

	vector<long long int> x(m);

	for (long long int i = 0; i < m; i++) {
		cin >> x[i];
	}

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

	vector<long long int> diff(m - 1);
	for (long long int i = 0; i < m-1; i++) {
		diff[i] = x[i + 1] - x[i];
	}

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

	long long int ans = 0;

	for (long long int i = 0; i < m-1-(n-1); i++) {
		ans += diff[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    [a, b] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
    let [alice, bob] = map (\x -> if x == 1 then 14 else x) [a, b]
    putStrLn $ [ "Alice", "Draw", "Bob" ] !! (signum (bob - alice) + 1)


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    int c;
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++)
    {
        c = count(s.begin(),s.end(),s.at(i));
        if(c>1) {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

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

using namespace std;
#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;
llong mergeSort(int[],int,int,int);
llong merge(int[], int, int, int,int);


int L[MAX/2+2];
int R[MAX/2+2];

int main(){
  int pre[MAX],num,i;
  llong ans;
  cin >> num;
  for(i = 0; i < num; i++){
    cin >> pre[i];
  }
  ans = mergeSort(pre,num,0,num);
  cout << ans << endl;
  return 0;
}


llong merge(int pre[], int num, int left, int mid ,int right){
  int i,j,k;
  llong cnt = 0;
  int num1 = mid-left;
  int num2 = right - mid;
  for(i = 0; i < num1; i++){
    L[i] = pre[left+i];
  }
  for(i = 0; i < num2; i++){
    R[i] = pre[mid + i];
  }
  L[num1] = R[num2] = SENTINEL;
  i = j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      pre[k] = L[i++];
    }
    else{
      pre[k] = R[j++];
      cnt += num1 - i;
    }
  }
  return cnt;
}


llong mergeSort(int pre[], int num, int left,int right){
  int mid;
  llong v1,v2,v3;
  if(left + 1 < right){
    mid = (left+right)/2;
    v1 = mergeSort(pre,num,left,mid);
    v2 = mergeSort(pre, num, mid,right);
    v3 = merge(pre, num, left, mid,right);
    return v1+v2+v3;
  }else{
    return 0;
  }
}

Measured memory_bytes: 4660
N,T=map(int,input().split())
shop=[]
easyshop=[]
for i in range(N):
    a,b=map(int,input().split())
    A,B=a+1,a+b+1
    if A==1:
        easyshop.append(B)
    else:
        shop.append(((A-1)/B,A,B))

shop.sort(reverse=True)
easyshop.sort()

if shop:
    dp=[0,shop[0][2]]
    for i in range(1,len(shop)):
        ndp=[]
        val,A,B=shop[i]
        for j in range(len(dp)):
            t=min(A*dp[j-1]+B,dp[j])
            if T>=t:
                ndp.append(t)
            else:
                break
        else:
            t=A*dp[-1]+B
            if T>=t:
                ndp.append(t)
        dp=ndp

    import bisect
    id=bisect.bisect_right(dp,T)
    ans=id-1
    if not easyshop:
        print(ans)
    else:
        n=len(easyshop)
        for i in range(1,n):
            easyshop[i]+=easyshop[i-1]
        for i in range(n):
            if T>=easyshop[i]:
                id=bisect.bisect_right(dp,T-easyshop[i])
                ans=max(ans,id+i)
            else:
                break
        print(ans)
else:
    import bisect
    n=len(easyshop)
    for i in range(1,n):
        easyshop[i]+=easyshop[i-1]
    ans=bisect.bisect_right(easyshop,T)
    print(ans)

Measured memory_bytes: 82648
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    string s;
    cin >> s;
    string a[3];
    int j = 0;
    for(int i = 0; i < 19; i++) {
        if(s[i] == ',') {
            i++;
            j++;
        }
        a[j] += s[i];
    }
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
    return 0;
}

Measured memory_bytes: 3588
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a=INT()
    b=INT()
    A=str(a)
    B=str(b)
    flg=2
    if len(A)>len(B):
        flg=0
    elif len(A)<len(B):
        flg=1
    else:
        for i in range(len(A)):
            if int(A[i])>int(B[i]):
                flg=0
                break
            elif int(A[i])<int(B[i]):
                flg=1
                break
            else:
                pass
        
    if flg==0:
        print('GREATER')
    elif flg==1:
        print('LESS')
    else:
        print('EQUAL')
if __name__ == '__main__':
    do()

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

typedef long long ll;
const int INF = 1001001001;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)


int main() {
    ll n,x,y;
    cin>>n>>x>>y;
    x--;y--;
    /*
    vector<vector<ll>> v(n);
    rep(i,n-1){
      v[i].push_back(i+1);
      v[i+1].push_back(i);
    }
    v[x].push_back(y);
    v[y].push_back(x);

*/
  ll ans=0;
  vector<ll> v(n);

  rep(i,n-1){
    for(int j=i+1;j<n;j++){
      int l;
      int l1=j-i;
      int l2=abs(x-i)+abs(j-y)+1;
    //  int l3=abs(y-i)+abs(j-x)+1;
      l=min(l1,l2);
      //l=min(l,l3);
      v[l]++;
    }
  }
  rep(i,n-1)
  cout<<v[i+1]<<endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

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

using ll = long long;

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

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<ll> A(n); rep(i,n) std::cin >> A[i];
  std::sort( all(A), std::greater<ll>() );

  ll s = 0;
  rep(i,n-1) {
    if ( i == 0 ) s += A[0];
    else {
      if ( i % 2 == 1 ) s += A[(i+1)/2];
      else s += A[i/2];
    }
  }
  std::cout << s << std::endl;
  return 0;
}



Measured memory_bytes: 4780
N = int(input())
F = [int(input().replace(" ",""), 2) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]

ans = -(1e9+7)
for i in range(1, 2**10):
  b = 0
  for f, p in zip(F, P):
    b += p[bin(f&i).count("1")]
  ans = max(ans, b)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    string s; cin>>s;
    int cnt=0;
    rep(i,s.size())if(s.at(i)=='1')cnt++;
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n) {
        int a;
        cin >> a;
        cnt += (a % 2 == 1);
    }
    cout << (cnt % 2 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256