akhauriyash/Code-Regression huggingface dataset:
h, w, a, b = map(int, input().split())
mod = 10 ** 9 + 7
n = h + w

f = [1 for _ in range(n)]
f_inv = [1 for _ in range(n)]
for i in range(1, n):
    f[i] = f[i-1] * i % mod
    f_inv[i] = pow(f[i], mod-2, mod)


def comb(n, k):
    return (f[n] * f_inv[k] % mod) * f_inv[n-k] % mod

ans = comb(h+w-2, h-1)
for i in range(b):
    ans -= comb(h-a+i-1, i) * comb(a+w-i-2, a-1) % mod
    ans %= mod

print(ans)

Measured memory_bytes: 18928
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  k = input().upper()
  if k == 'AC':
    ac +=1
  elif k == 'WA':
    wa +=1
  elif k == 'TLE':
    tle +=1
  elif k == 'RE':
    re +=1
    
print('{} x {}'.format('AC',ac))
print('{} x {}'.format('WA',wa))
print('{} x {}'.format('TLE',tle))
print('{} x {}'.format('RE',re))

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;

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

    long min_abs = 1000000000;
    int minus_num = 0;
    long S = 0;

    for (int n = 0; n < N; n++)
    {
        min_abs = min(min_abs, abs(A[n]));
        S += abs(A[n]);
        if (A[n] < 0)
        {
            minus_num++;
        }
    }

    if (minus_num % 2 == 0)
    {
        cout << S;
    }
    else
    {
        cout << S - min_abs * 2;
    }

    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t / 2;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}

int main() {
    int a, b, x;
    vector<vector<int>> c(3, vector<int>(3));
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    a = c[0][1] - c[0][0];
    b = c[0][2] - c[0][1];
    x = c[0][2] - c[0][0];
    for (int i = 1; i < 3; i++){
        if (c[i][1] - c[i][0] == a && c[i][2] - c[i][1] == b && c[i][2] - c[i][0] == x){
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m=0,a,b=100,d;
  cin>>n;
  while(n--){
    cin>>d>>a;
    if(m<a){
      m=a;
      b=d;
    }
      else if(m==a&&b>d)b=d;
  }
  cout<<b<<' '<<m<<endl;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main() {
 int N;
  cin>>N;
   vector<string> vec(N);
  int cnt=N;
  if(N>1){
  for (int i = 0; i < N; i++) { cin >> vec.at(i);}
  sort(vec.begin(), vec.end());
  for (int i = 0; i < N-1; i++) { 
    if(vec.at(i)==vec.at(i+1)) cnt-- ;
  }
  cout <<cnt;}
  else cout <<N;
}


Measured memory_bytes: 9512
#include<stdio.h>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	pair<pair<string,int>,int> r[100];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		char s[11];
		int m;
		scanf("%s%d",s,&m);
		r[i]=make_pair(make_pair(s,-m),i+1);
	}
	sort(r,r+n);
	
	for(int i=0;i<n;i++) printf("%d\n",r[i].second);
	
	return 0;
}


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

int main() {
long long N;
  int count = 0;
  cin>>N;
  int result = 0;
  for(int a = 2;a <= sqrt(N);a++){
    count = 0;
while(N % a == 0){
  count += 1;
    N = N / a;
}
    for(int b = 1;b >= 0;b++){
     if(count >= b){
      result++;
       count -= b;
     }else{
      break; 
     }
      
    }
  }
  if(N > 1)result++;
  cout << result << endl;

}

Measured memory_bytes: 3680
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
  int n;
  scanf("%d", &n);
  int S[n];
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &S[i]);
  }
  int q;
  scanf("%d", &q);
  int T[q];
  for (int i = 0; i < q; i++)
  {
    scanf("%d", &T[i]);
  }
  int cnt = 0;
  for (int i = 0; i < q; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if (S[j] == T[i])
      {
        cnt++;
        break;
      }
    }
  }

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 3184
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static ArrayList<Integer>[] list;
	static int[] a;
	static int[] dp;
	static int[] ans;
	static int max;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		list=new ArrayList[n];
		a=new int[n];
		dp=new int[n+1];
		ans=new int[n];
		max=0;
		Arrays.fill(dp,1000000001);
		dp[0]=0;
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt();
			list[i]=new ArrayList<>();
		}
		for(int i=1; i<n; i++){
			int u=sc.nextInt()-1;
			int v=sc.nextInt()-1;
			list[u].add(v);
			list[v].add(u);
		}
		dfs(0,0);
		PrintWriter pw=new PrintWriter(System.out);
		for(int i=0; i<n; i++){
			pw.println(ans[i]);
		}
		pw.flush();
	}
	static void dfs(int now,int from){
		int idx=Arrays.binarySearch(dp,a[now]);
		if(idx<0){
			idx=-idx-1;
		}
		int tmp=idx;
		int val=dp[idx];
		dp[idx]=a[now];
		int pp=max;
		max=Math.max(max,idx);
		ans[now]=max;
		
		for(int i:list[now]){
			if(i!=from){
				dfs(i,now);
			}
		}
		max=pp;
		dp[tmp]=val;
	}
}

Measured memory_bytes: 99548
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <string>

using namespace std;


int main(){
    int N;
    int ret = 0;

    scanf("%d", &N);
    ret = 180 * (N-2);
    printf("%d\r\n", ret);
    fflush(stdout);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
	while(1){
		int one, two;
		scanf(" %d %d", &one, &two);
		if(one==0 && two==0) break;
		
		for(int i=0; i<one; ++i){
			for(int j=0; j<two; ++j){
				if( (i+j)%2==0 ) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");

	}
	return 0;
}



Measured memory_bytes: 2596
#-*-coding:utf-8-*-

def main():
    N, M, X = list(map(int, input().split()))
    A = list(map(int, input().split()))
    cnt_first = 0
    cnt_last = 0

    #前半を調べる
    for i in range(X):
        if i in A:
            cnt_first += 1

    for j in range(X, N):
        if j in A:
            cnt_last += 1

    if cnt_first < cnt_last:
        print(cnt_first)
    else:
        print(cnt_last)




if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e13;
int main() {
    ll n, i, j, k;
    cin >> n;
    vector<ll> a(n);
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<ll> l(n + 1, 0), r(n + 1, 0); //i番目未満のmax ,i番目以降のmax
    for(i = 1; i <= n; i++) {
        l[i] = max(l[i - 1], a[i - 1]);
    }
    for(i = n - 2; i >= 0; i--) {
        r[i] = max(r[i + 1], a[i+1]);
    }

    for(i = 0; i < n; i++) {
        cout << max(l[i],r[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 6272
#include <stdio.h>

#define CHECK_NUM 1
#define INCLUDE3 2
#define END_CHECK_NUM 3

void call(int n)
{
  int i = 1;
  int mode = CHECK_NUM;
  int x;

  while (1) {
    switch (mode) {
    case CHECK_NUM:
      x = i;
      if (x % 3 == 0) {
	printf(" %d", i);
	mode = END_CHECK_NUM;
	break;
      }
    case INCLUDE3:
      if (x % 10 == 3) {
	printf(" %d", i);
	mode = END_CHECK_NUM;
	break;
      }

      x /= 10;
      if (x) {
	mode = INCLUDE3;
	break;
      }
    case END_CHECK_NUM:
      if (++i <= n ) {
	mode = CHECK_NUM;
	break;
      }

      printf("\n");
      return;
    }
  }
}


int main(int argc, char *argv[])
{
  int a;
  
  scanf("%d", &a);

  call(a);

  return 0;
}

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

using vi = vector<int>;
#define f(i,a,b) for (int i = a; i < b; i++)
#define pb push_back

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin>>n>>k;
	vi adj[n];
	f(i,0,n-1) {
		int a, b; cin >> a >> b;
		adj[--a].pb(--b); adj[b].pb(a);
	}
	function<int(int,int,int)> dfs = [&](int v, int p, int d) {
		int ans = d>k/2;	
		for (int w : adj[v]) if (w != p)
			ans += dfs(w,v,d+1);
		return ans;
	};
	int ans = n;
	if (k&1) {
		f(v,0,n) for (int w : adj[v]) 
			ans = min(ans, dfs(v,w,0)+dfs(w,v,0));
	} else 
		f(v,0,n) ans = min(ans,dfs(v,-1,0));
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int N;
vector<int> v;
int main(){
	scanf("%d", &N);
	int inp;
	for(int i=0; i<N; i++){
		scanf("%d", &inp);
		v.push_back(inp);
	}

	while( v.size() != 2 && v.size() != 1 ) {
		// for(size_t i=0; i<v.size(); i++){
		// 	cout << v.at(i) << " ";
		// }
		// cout << "\n";
		for(size_t i=0; i<v.size(); i++){
			for(size_t j=v.size() - 1; j>i; j--){
				int dat[2];
				dat[0] = v.at(i);
				dat[1] = v.at(j);
				if( dat[0] % 2 == dat[1] % 2 ) {
					v.erase(v.begin() + j);
					v.erase(v.begin() + i);
					v.push_back(dat[0] + dat[1]);
				}
			}
		}
	}

	if( v.size() == 2 ) {
		if( v.at(0) % 2 == v.at(1) % 2 ) {
			cout << "YES\n";
		}else{
			cout << "NO\n";
		}
	}else{
		cout << "YES\n";
	}
	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  s='$'+s+'$';
  
  vector<char> t(q),d(q);    
  for(Int i=0;i<q;i++) cin>>t[i]>>d[i];

  auto check=
    [&](Int x)->Int{
      for(Int i=0;i<q;i++){
        if(t[i]==s[x]){
          if(d[i]=='L') x--;
          if(d[i]=='R') x++;
        }
      }
      return x;
    };
  // [ll, rr]
  Int ll=0,rr=n-1;  
  // n -> deru
  {
    Int l=0,r=n+1;
    while(l+1<r){
      Int m=(l+r)>>1;
      if(check(m)==n+1) r=m;
      else l=m;
    }
    rr=l;
  }
  // deru <- 0
  {
    Int l=0,r=n+1;
    while(l+1<r){
      Int m=(l+r)>>1;
      if(check(m)==0) l=m;
      else r=m;
    }
    ll=r;
  }
  
  cout<<max(0LL,rr-ll+1)<<endl;
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>

int main(void){
  int i,j,k,l;
  int a,b;
  int s=0,t=0;
  
  for(i=0;i<4;i++){
    scanf("%d",&a);
    s+=a;
  }
  for(i=0;i<4;i++){
    scanf("%d",&b);
    t+=b;
  }
  
  if(s<t){
    printf("%d\n",t);
  }else{
    printf("%d\n",s);
  }
  return(0);
}

Measured memory_bytes: 592
import java.util.*;
public class Main {
	
	static int h, w;
	static int dp[][][] = new int[81][81][81*160];
	static int maxB = 80 * 160;
	static int A[][] = new int[81][81];
	static int B[][] = new int[81][81];
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		h = sc.nextInt();
		w = sc.nextInt();
		
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				A[i][j] = sc.nextInt();
			}
		}
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				B[i][j] = sc.nextInt();
			}
		}
		
		dp[0][1][0] = 1;
		dp[1][0][0] = 1;
	
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				int dif = Math.abs(A[i][j] - B[i][j]);
				for(int k=0;k<=maxB;k++){
					if(dp[i-1][j][k] == 1 || dp[i][j-1][k] == 1){
						dp[i][j][Math.abs(dif - k)] = 1;
						dp[i][j][dif + k] = 1;
					}
				}
			}
			
		}
		
		for(int i=0;i<=maxB;i++){
			if(dp[h][w][i]==1){
				System.out.println(i);
				break;
			}
		}
		
	}
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAX_N = 50;

int main() {
  int N;
  std::priority_queue<double> pq;
  std::cin >> N;
  rep(i, N) {
    double v;
    std::cin >> v;
    pq.push(-v);
  }

  double ans = 0.0;
  rep(i, N - 1) {
    double v1 = - pq.top(); pq.pop();
    double v2 = - pq.top(); pq.pop();
    ans = 0.5 * (v1 + v2);
    pq.push(- ans);
  }

  std::cout << std::fixed;
  std::cout << std::setprecision(10) << ans << '\n';
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

count = 0
for i in A:
    if i < 0:
        count+=1

if count % 2 == 0:
    for i in range(N):
        if A[i] < 0:
            A[i] = A[i] * -1

    print(sum(A))
else:
    abs_min_ind = 0
    abs_min = 10**9
    for i in range(N):
        if A[i] < 0:
           A[i] = A[i] * -1
        if abs_min > abs(A[i]):
            abs_min = abs(A[i])
            abs_min_ind = A.index(A[i])

    A[abs_min_ind] = A[abs_min_ind] * -1

    print(sum(A))

Measured memory_bytes: 14412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define OUT(x) cout << (x) << endl;
#define ALL(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<(int)(n); ++i)
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

const int MAX_X=50, 
          MAX_Y=50;
const ll INF = 10e9;

string A[100];
string B[100];
int N,M;

int main() {
    string S; cin >> S;
    if(S=="SUN"){
        OUT(7);
    } else if (S=="MON"){
        OUT(6);
    } else if (S=="TUE"){
        OUT(5);
    } else if (S=="WED"){
        OUT(4);
    } else if (S=="THU"){
        OUT(3);
    } else if (S=="FRI"){
        OUT(2);
    } else if (S=="SAT"){
        OUT(1);
    }
}

Measured memory_bytes: 256
# 無限回試行できる時、Kの最小値を最大化する問題
s = input()
now = s[0]
cnt = 1
use = []
for i in range(1,len(s)):
    if now == s[i]:
        cnt += 1
    else:
        use.append(cnt)
        cnt = 1
        now = s[i]
use.append(cnt)

min_prob = len(s)
sum_s = sum(use)
def ketsugou(l):
    global min_prob
    global sum_s
    #一番小さいやつをくっつけていく
    m = l.index(min(l))
    if m == 0 or m == len(l) - 1:
        s1 = l[m]
        s2 = sum_s - l[m]
        min_prob = min(min_prob, max(s1, s2))
        if m == 0:
            l = l[1:]
            l[0] += s1
        else:
            l.pop()
            l[-1] += s1
    else:
        s1 = sum(l[:m])
        s2 = s1 + l[m]
        s3 = sum_s - s1
        s4 = sum_s - s2
        min_prob = min(min_prob, max(s1, s2,s3,s4))
        if l[m - 1] < l[m + 1]:
            l[m - 1] += l[m]
        else:
            l[m + 1] += l[m]
        l.pop(m)
#while(len(use) > 1):
#    ketsugou(use)
sum_ss = 0
for i in range(len(use)):
    sum_ss += use[i]
    min_prob = min(min_prob, max(sum_s - sum_ss, sum_ss))

print(min_prob)


Measured memory_bytes: 3708
#include <stdio.h>
#include <math.h>
int main(void){
  double a,b,h,m;
  scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
  double l,s;
  l=2*M_PI/43200;
  s=2*M_PI/3600;
  double sec1,sec2;
  sec1=h*3600+m*60;
  sec2=m*60;
  double ans1,ans2,ans3,ans4,ans;
  ans1=l*sec1;
  ans2=s*sec2;
  ans3=fabs(ans1-ans2);
  if(ans3<M_PI){
  ans4=a*a+b*b-2*a*b*cos(ans3);
  ans=sqrt(ans4);
}else{
  ans3=2*M_PI-ans3;
  ans4=a*a+b*b-2*a*b*cos(ans3);
  ans=sqrt(ans4);
}
  printf("%.10f", ans);
  return 0;
}

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

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 100007

using namespace std;

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int a[n],ans[h][w];
    pan(i,n) cin>>a[i];
    int i=0,j=0;
    pan(k,n){
        int count = a[k]+1;
        for(i;i<h;i++){
            if(i%2!=0){
                if(j==w || j==-1) j=w-1;
                for(j;j>=0;j--){ 
                    count--;
                    if(count!=0) ans[i][j]=k+1;
                    else break;
                }
            }
            else{
                if(j==w || j==-1) j=0;
                for(j;j<w;j++) {
                    count--;
                    if(count!=0) ans[i][j]=k+1;
                    else break;
                }
            }
            if(count==0) break;
        }
    }
    pan(i,h){
        pan(j,w) cout<<ans[i][j]<<" ";
        cout<<endl;
    }
}


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

const double PI = 3.14159265358979323846;
int main(){
  // 標準入力高速化のおまじない
  // scanfとの同期を切る。以降紛らわしいのでscanf使用不可。
  ios::sync_with_stdio(false);
  // // cin前の自動flashをやめる
  cin.tie(nullptr);

  int A,B,H,M;
  cin >> A >> B >> H >> M;
  long double deg_hour = (H*60.0+M) * 0.5;  // 時針は1分間に0.5度進む
  long double deg_minute = M*6.0;  // 分針は1分間に6度進む
  long double deg = abs(deg_hour-deg_minute);
  long double result = sqrt(A*A + B*B - 2*A*B*cos(deg*(PI/180.0)));

  cout << fixed << setprecision(10.0) << result << endl;
  return 0;
}

Measured memory_bytes: 4140
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    int X = 0, Y = 0, T = 0;
    rep(i, N){
        int t, x, y;
        cin >> t >> x >> y;
//        cout << abs(x - X) + abs(y - Y) << endl;
        if(abs(x - X) + abs(y - Y) <= t - T && (t - T - (abs(x - X) + abs(y - Y)))  % 2 == 0){
            X = x, Y = y, T = t;
//            output(i);
        }
        else {
            output("No");
            return 0;
        }
    }
    output("Yes");
    
    return 0;
}


Measured memory_bytes: 256
N, X = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

def solve0(N, X, A):
    A2 = A + A
    T = [
        [min(A2[N+j+1-i-1:N+j+1]) for j in range(N)]
        for i in range(N)
    ]
    mins = [
        sum(T[i]) + i * X
        for i in range(N)
    ]
    result = min(mins)
    return result

def solve(N, X, A):
    M = A[:]
    result = sum(M)
    for i in range(1, N):
        M = [min(M[j], A[(j-i)%N]) for j in range(N)]
        r = sum(M) + X * i
        result = min(result, r)
    return result

print(solve(N, X, A))


Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;


int main()
{
	int s,ans = 0;
	cin >> s;
	if (s >= 100) {
		ans += 1;
		s -= 100;
	}
	if (s >= 10) {
		ans += 1;
		s -= 10;
	}
	if (s == 1) {
		ans += 1;
	}
	cout << ans;
	return 0;
}

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

int main() {
    int a, b;
    std::cin >> a >> b;
    
    for(int i = 1; i <= 1250; ++i)
    {
        if(static_cast<int>(std::floor(i * 0.08)) == a
           && static_cast<int>(std::floor(i * 0.1)) == b)
        {
            std::cout << i << std::endl;
            return 0;
        }
    }
    
    std::cout << "-1" << std::endl;
}

Measured memory_bytes: 3220
import copy
S = input()
EX = ' '.join(list(S))
EX = list(EX)
sum = 0
for i in range(2 ** (len(S)-1)):
    P = copy.deepcopy(EX)
    for j in range((len(S)-1)):
        if ((i >> j) & 1):
            P[j*2+1] = '+'
    sum += eval(''.join(P).replace(' ',''))
print(sum)


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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int sx, sy, tx, ty;
  read(sx, sy, tx, ty);
  int dx = tx - sx, dy = ty - sy;
  write(
      "L" +
      string(dy + 1, 'U') +
      string(dx + 1, 'R') +
      "D" +
      "R" +
      string(dy + 1, 'D') +
      string(dx + 1, 'L') +
      "U" +
      string(dy, 'U') +
      string(dx, 'R') +
      string(dy, 'D') +
      string(dx, 'L')
      );
}


Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
#define EPS 1e-8
#define equals(a,b) fabs((a) - (b)) < EPS

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct Point {
	double x, y;

	Point(double x=0, double y=0) : x(x), y(y) {}

	Point operator+(const Point &o) const { return Point(x+o.x, y+o.y); }

	Point operator-(const Point &o) const { return Point(x-o.x, y-o.y); }

	Point operator*(const double m) const { return Point(x*m, y*m); }

	Point operator/(const double d) const { return Point(x/d, y/d); }

	bool operator<(const Point &o) const { return x != o.x ? x < o.x : y < o.y; }

	bool operator==(const Point &o) const { return fabs(x-o.x) < EPS && fabs(y-o.y) < EPS; }
};

ostream& operator << (ostream& os, const Point& p) {
	os << "(" << p.x << ", " << p.y << ")";
	return os;
}

double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
double atan(Point p) { return atan2(p.y, p.x); }
double norm(Point p) { return p.x * p.x + p.y * p.y; }
double distancePP(Point p, Point o) { return sqrt(norm(o - p)); }

int ccw(Point a, Point b, Point c) {
	b = b-a;
	c = c-a;

	if(cross(b, c) > 0.0) return +1;	//conter clockwise
	if(cross(b, c) < 0.0) return -1;	//clockwise
	if(dot(b, c) < 0.0) return +2;	//a on Seg(b,c)
	if(norm(b) < norm(c)) return -2;	//b on Seg(a,c)
	return 0;	//c on Seg(a,b)
}

struct Line {
	Point a, b;

	Line() : a(Point(0, 0)), b(Point(0, 0)) {}
	Line(Point a, Point b) : a(a), b(b) {}
};

ostream& operator << (ostream& os, const Line& l) {
	os << "(" << l.a.x << ", " << l.a.y << ")-(" << l.b.x << "," << l.b.y << ")";
	return os;
}

struct Seg {
	Point a,b;

	Seg() : a(Point(0, 0)), b(Point(0, 0)) {}

	Seg (Point a, Point b) : a(a),b(b) {}
};

ostream& operator << (ostream& os, const Seg& s) {
	os << "(" << s.a.x << ", " << s.a.y << ")-(" << s.b.x << "," << s.b.y << ")";
	return os;
}

bool isOrthogonal(Line l1, Line l2) { return equals(dot((l1.b - l1.a), (l2.b - l2.a)), 0.0); }

bool isParallel(Line l1, Line l2) { return equals(cross((l1.b - l1.a), (l2.b - l2.a)), 0.0); }

bool sameLine(Line l1, Line l2){ return abs(cross(l1.b - l1.a, l2.b - l1.a)) < EPS; }

bool isIntersect(Seg s1, Seg s2) { 
	return ccw(s1.a, s1.b, s2.a) * ccw(s1.a, s1.b, s2.b) <= 0 
		&& ccw(s2.a, s2.b, s1.a) * ccw(s2.a, s2.b, s1.b) <= 0;
}

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

	Seg s1, s2;
	rep(i, q) {
		cin >> s1.a.x >> s1.a.y >> s1.b.x >> s1.b.y >> s2.a.x >> s2.a.y >> s2.b.x >> s2.b.y;

		if(isIntersect(s1, s2)) {
			cout << 1 << endl;
		} else {
			cout << 0 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1236
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

b = [(a[0], 1)]
for i in range(len(a) - 1):
    if a[i] == a[i + 1]:
        x, y = b[-1]
        b[-1] = (x, y + 1)
    else:
        b.append((a[i + 1], 1))
b.sort(key=lambda x: x[1], reverse=True)
if len(b) <= k:
    print(0)
else:
    print(sum([x[1] for x in b[k:]]))


Measured memory_bytes: 29448
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()

//#if __cplusplus >= 201103
typedef long long ll;
//#endif
typedef pair<int, int> P;
typedef pair<int, P> IP;

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

const int INF = 100000000;
//#if __cplusplus >= 201103
const ll LINF = 10000000000000000ll;
//#endif
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
// }}}

class UnionFind{
    vector<size_t> m_parents;
    vector<ll> m_ranks;

public:
    UnionFind(size_t n){
        m_parents.resize(n);
        m_ranks.resize(n);
        for(size_t i = 0; i < n; i++){
            m_parents[i] = i;
            m_ranks[i] = 0;
        }
    }

    size_t root(size_t x){
        if(m_parents[x] == x) return x;
        size_t r = root(m_parents[x]);
        m_parents[x] = r;
        return r;
    }

    bool isSame(size_t x, size_t y){
        return root(x) == root(y);
    }

    void unite(size_t x, size_t y){
        size_t rx = root(x);
        size_t ry = root(y);
        if(rx != ry){
            if(m_ranks[rx] < m_ranks[ry]) swap(rx, ry);
            if(m_ranks[rx] == m_ranks[ry]) m_ranks[rx]++;
            m_parents[ry] = rx;
        }
    }

    void print_parents(){
        for(auto v: m_parents){
            cout << v << " ";
        }
        cout << endl;
    }
};

int N, M;
int a[100010];

void init()
{
}

void solve()
{
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    UnionFind uf(N);
    REP(i, N){
        cin >> a[i];
        a[i]--;
    }
    REP(i, M){
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.unite(x, y);
    }
    int ans = 0;
    REP(i, N){
        //if(i == a[i]) ans++;
        if(uf.isSame(i, a[i])) ans++;
    }
    cout << ans << endl;
    //uf.print_parents();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 2176
n = gets.to_i
h = Hash.new(0)
n.times do
    h[gets.chomp] += 1
end
h = h.sort{|a,b| a[1]<=>b[1]}.reverse
max = h[0][1]
ans = Array.new
h.each do |hh|
    if hh[1] == max
        ans.push(hh[0])
    else
        break
    end
end
puts ans.sort

Measured memory_bytes: 42856
#include <stdio.h>
 
int main(void) {
  
  int N,A[20],B[20],C[20];
  
  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 - 1; i++) {
    scanf("%d", &C[i]);
  }
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += B[A[i] - 1];
    if (A[i+1] - A[i] == 1) {
      sum += C[A[i] -1];
    }
  }
  
  printf("%d", sum);
  
  return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a > b){
        cout << "a > b\n";   
    }else if(a == b){
        cout << "a == b\n";
    }else{
        cout << "a < b\n";
    }
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int x,i,j,ciur[150010];
int main()
{
    ciur[0]=ciur[1]=1;
    for(i=2;i*2<=150000;i++)
        if(ciur[i]==0)
            for(j=2;j*i<=150000;j++)
                ciur[j*i]=1;
    cin>>x;
    while(ciur[x]==1)
        x++;
    cout<<x;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//#define int ll
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
const int INF = 1e9;
const int MOD = 1e9+7;

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    string s; cin >> s;
    int k; cin >> k;
    set<string> ss;
    REP(i, s.size()) {
        FOR(j, i, i+min(k, 5)) {
            if (j > s.size()) break;
            ss.insert(s.substr(i, j-i+1));
        }
    }
    int cnt = 1;
    for(auto itr = ss.begin(); itr != ss.end(); ++itr) {
        if (cnt == k) {
            cout << *itr << endl;
            break;
        }
        cnt++;
    }
}

Measured memory_bytes: 1664
# include <iostream>

int main(){
	int W, H , x, y ,r;
	std::cin >> W >> H >> x >> y >> r;

// 0 <= x -r, x + r  <= W
// 0 <= y -r, y + r <= H
	bool b = true;
	if( r > x)
		b = false;
	if( r > y)
		b = false;
	if(x + r > W)
		b = false;
	if(y + r > H)
		b = false;
	if(b)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;

	return 0;
}

Measured memory_bytes: 3108
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 62);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

int n,k;
vec w,d;

bool check(int mid){
    int cnt=0;
    rep(i,n){
        if(w[i]>mid) continue;
        cnt+=1+(mid-w[i])/d[i];
        if(cnt>=k) return true;
    }
    
    return false;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    cin>>n>>k;
    w.resize(n);d.resize(n);
    rep(i,n) cin>>w[i]>>d[i];
    int ng = 0, ok = INF;
    while (abs(ng-ok)>1) {
      int mid = ng+(ok-ng)/2;
      (check(mid)?ok:ng) = mid;
    }
    // debug(ng); debug(ok);
    cout<<ok<<endl;
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>

using namespace std;
int n, m;
unsigned long long ans;
map<int, int> D;
int x;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  bool good = true;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    D[x]++;
  }
  cin >> m;
  for (int i = 0; (i < m) && good; i++) {
    cin >> x;
    if (D[x] > 0) {
      D[x]--;
    } else {
      good = false;
    }
  }
  if (good) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}


Measured memory_bytes: 9600
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int H, W;
    int h, w;
    cin >>H>> W;
    cin >> h >> w;
    int ans;
    ans = (H-h)*(W-w);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int re = a - c;
    cout << max(b - re, 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int getnum(int x){
	return (x/10) * (x%10);
}

bool flag(int x){
	return x/10 >= 2 && x%10 >= 2;
}

int main(){
	LL N, K;
	cin >> N >> K;
	vector<int> line(N);
	foreach(i, line)cin>>i;
	vector<int> sum(2001, 0);
	foreach(i, line)++sum[i];
	REP(i, 2000){
		sum[i+1]+=sum[i];
	}
	LL ans = 0;
	REP(i, N){
		if(line[i]==1)continue;
		ans += sum[line[i]-1] * K % MOD * (K-1) % MOD * modinv(2);
		ans %= MOD;
		for(int j=i+1;j<N;++j){
			if(line[i]>line[j]){
				ans += K;
				ans%=MOD;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
flag = 1
count = 0
while flag:
    flag = 0
    for i in range(n-1):
        if a[i] > a[i+1]:
            a[i], a[i+1] = a[i+1], a[i]
            count += 1
            flag = 1
print(" ".join(map(str,a)))

print(count)

Measured memory_bytes: 7720
#include<map>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXL = 30;
const int MAXN = 400000;
struct edge{
	int to; edge *nxt;
}edges[MAXN + 5], *adj[MAXN + 5], *ecnt;
void addedge(int u, int v) {
	edge *p = (++ecnt);
	p->to = v, p->nxt = adj[u], adj[u] = p;
}
bool tag[MAXN + 5], vis[MAXN + 5];
int tot[MAXN + 5], arr[MAXN + 5], cnt;
vector<int>vec[MAXN + 5];
map<int, int>mp;
int lowbit(int x) {
	return x & -x;
}
long long dp[MAXN + 5][2];
void dfs(int rt) {
	dp[rt][1] = tot[rt]; dp[rt][0] = 0;
	for(edge *p=adj[rt];p!=NULL;p=p->nxt) {
		dfs(p->to);
		dp[rt][1] += dp[p->to][0];
		dp[rt][0] += max(dp[p->to][0], dp[p->to][1]);
	}
	adj[rt] = NULL, vis[rt] = false;
}
int main() {
	int N, A; scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		scanf("%d", &A);
		vec[int(log2(lowbit(A)))].push_back(A/lowbit(A)/2);
	}
	long long ans = 0;
	for(int i=0;i<=MAXL;i++) {
		cnt = 0; ecnt = &edges[0]; mp.clear();
		for(int j=0;j<vec[i].size();j++) {
			if( !mp.count(vec[i][j]) ) mp[vec[i][j]] = (++cnt);
			arr[j] = mp[vec[i][j]]; tot[arr[j]]++;
		}
		for(int j=0;j<vec[i].size();j++) {
			if( vis[arr[j]] ) continue;
			vis[arr[j]] = true;
			int p = 0;
			for(int k=0;k<=MAXL;k++) {
				if( (1<<k) > vec[i][j] ) break;
				if( !((1<<k) & vec[i][j]) ) p |= (1<<k);
			}
			if( mp.count(p) && vec[i][j] != 0 ) addedge(mp[p], arr[j]);
			else tag[arr[j]] = true;
		}
		ans += vec[i].size();
		for(int j=0;j<vec[i].size();j++) {
			if( tag[arr[j]] ) {
				dfs(arr[j]);
				if( vec[i][j] == 0 ) {
					long long del = -(1LL<<40);
					for(int k=0;k<=tot[arr[j]];k+=2)
						del = max(del, -max(dp[arr[j]][0]+k/2, dp[arr[j]][1]-k/2));
					ans += del;
				}
				else ans -= max(dp[arr[j]][0], dp[arr[j]][1]);
				tag[arr[j]] = false;
			}
		}
		for(int j=0;j<vec[i].size();j++)
			tot[arr[j]] = 0;
	}
	printf("%lld\n", ans);
}

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

typedef pair<int,int> P;
int main(){
  int n;
  cin >> n;
  int b[n];
  for(int i = 0;i < n-1;i++){
    cin >> b[i];
  }
  int a[n];
  a[0] = b[0];
  for(int i = 1;i < n-1;i++){
    a[i] = min(b[i-1],b[i]);
  }
  a[n-1] = b[n-2];
  int ans = 0;
  for(int i = 0;i < n;i++){
    ans += a[i];
  }
  cout << ans << endl;
}

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

typedef long long ll;

int main() {
  int N; cin >> N;
  int x; cin >> x;
  vector<int>a(N);
  for ( int i = 0; i < N; i++ ) cin >> a[i];
  sort(a.begin(),a.end());
  int cnt = 0;
  for ( int i = 0; i < N; i++ ) {
    if( i == N-1 && x == a[i]){
      cnt++;
      break;
    }
    else if (i == N-1 && x != a[i])break;
    x -= a[i];
    if ( x >= 0 )cnt++;
    else break;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ch() getchar()
#define pc(x) putchar(x)
template<typename T>inline void read(T&x){
	int f;char c;
	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;
	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;
}
template<typename T>inline void write(T x){
	static char q[64];int cnt=0;
	if(!x)pc('0');if(x<0)pc('-'),x=-x;
	while(x)q[cnt++]=x%10+'0',x/=10;
	while(cnt--)pc(q[cnt]);
}
int main(){
	int ok=false;
	for(char c=ch();c>='a'&&c<='z';c=ch()){
		ok=c=='s';pc(c);
	}
	if(ok)pc('e'),pc('s');
	else pc('s');pc('\n');
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

void dfs(int vertex, int &ans, const vector<vector<int>> &adj_mat, vector<int> &vertex_vec);

bool has_visited_every_vertex(vector<int> &vertex_vec);

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj_mat(n, vector<int> (n, 0));
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj_mat[a][b] = adj_mat[b][a] = 1;
    }

    vector<int> vertex_vec(n, 0);
    int ans = 0;
    dfs(0, ans, adj_mat, vertex_vec);
    cout << ans << endl;
}

void dfs(int vertex, int &ans, const vector<vector<int>> &adj_mat, vector<int> &vertex_vec){
    /* 既に訪問済みの頂点である場合 */
    if(vertex_vec[vertex] == 1){
        return;
    }

    /* 現在いる頂点に訪問済みの印をつける */
    vertex_vec[vertex] = 1;

    /* すべての頂点を訪問済みである場合 */
    if(has_visited_every_vertex(vertex_vec)){
        ans++;
        vertex_vec[vertex] = 0;
        return;
    }

    /* 現在いる頂点に隣接しているそれぞれの頂点に対して再帰呼び出し */
    for(size_t i = 0; i < adj_mat[vertex].size(); ++i){
        if(adj_mat[vertex][i] == 1){
            dfs(i, ans, adj_mat, vertex_vec);
        }
    }

    /* 現在いる頂点から訪問済みの印を消す */
    vertex_vec[vertex] = 0;
}

bool has_visited_every_vertex(vector<int> &vertex_vec){
    for(size_t i = 0; i < vertex_vec.size(); ++i){
        if(vertex_vec[i] == 0){
            return false;
        }
    }
    return true;
}

Measured memory_bytes: 256
/*input
1 1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
#define version 20190814
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int main(){
	IOS;
	int x,y;
	cin>>x>>y;
	int ans=0;
	for(int i=1;i<=y;i++){
		int a=i/10;
		int b=i%10;
		if(a<2||b<2) continue;
		if(a*b<=x) ans++;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<bitset>
#include<deque>
#include<iterator>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include <cmath>
#include<vector>
using namespace std;
#define pb push_back
#define pf push_front
#define M 1000000007
#define ll long long int
int main()
 {
 	 
     ll n,k;
     cin>>n>>k;
     ll m=1000000007;
     ll sum,sum1,sum2;
     ll ans=0;
     ll i;
     for(i=k;i<=n+1;i++)
     {
     	sum=n*(n+1)/2-(n-i)*(n-i+1)/2;
     	sum1=i*(i-1)/2;
   //   	cout<<sum<<" "<<sum1<<" ";
        sum2=(sum%m-sum1%m+m+1)%m;
        ans=(ans%m+sum2%m)%m;
     //   cout<<ans<<" ";
     }
cout<<ans;
     return 0;
 }


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    private static final PrintWriter sysout = new PrintWriter(System.out, false);

    private static StringTokenizer buffer;

    private static String readLine() {
        buffer = null;
        try {
            return br.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static String read() {
        if (buffer == null || !buffer.hasMoreTokens()) {
            buffer = new StringTokenizer(readLine());
        }
        return buffer.nextToken();
    }

    private static int readInt() {
        return Integer.parseInt(read());
    }

    private static int[] readIntArray(int loop) {
        int[] result = new int[loop];
        for (int i = 0; i < loop; i++) {
            result[i] = readInt();
        }
        return result;
    }

    private static int[] splitInt() {
        String[] tmp = read().split("");
        int[] result = new int[tmp.length];
        for (int i = 0, n = tmp.length; i < n; i++) {
            result[i] = Integer.parseInt(tmp[i]);
        }
        return result;
    }

    private static long readLong() {
        return Long.parseLong(read());
    }

    private static double readDouble() {
        return Double.parseDouble(read());
    }

    public static void main(String[] args){
        run();
    }

    private static void run() {
        int x = readInt();
        int y = readInt();
        if ((x * y) % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}


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

int main(){
  char c;
  cin >> c;
  bool s=false;
  vector<char> vec{'a','i','u','e','o'};
  for (int i=0;i<5;i++){
    if(c==vec.at(i)){
      s=true;
      break;
      
    }
  }
  if(s){
    cout << "vowel" <<endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  long ans = 1;
  for (long n = 1; n <= N; n++) {
    ans *= n;
    ans %= MOD;
  }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for (int i=n-2;i>=0;i--)
    {
        if (a[i]-a[i+1]>0)
        {
            a[i]--;
            if (a[i]-a[i+1]>0)
            {
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 4004
def main():
   N = int(input())
   a = list(map(int, input().split()))
   a.sort()
   A = a.pop()
   k = A/2
   for i in a:
      if k - i == 0:
         B = i
         break
      else:
         sa = k - i
         if sa < 0:
            if abs(B-k)>abs(sa):
               B = i
            break
         B = i
   return str(A)+" "+str(B)
         


print(main())



Measured memory_bytes: 14052
#!/usr/bin/env python
N, c = map(int, input().split())
S = [list(map(int, input().split())) for i in range(N)]

sum_ = 0
r = [0]
for x, v in S:
    sum_ += v
    r.append(sum_-x)

sum_ = 0
l = [0]
for x, v in S[::-1]:
    sum_ += v
    l.append(sum_ - (c-x))

def right():
    max_ = r[0]
    for i in r:
        if max_ < i:
            max_ = i
        yield max_
 
def left():
    max_ = l[0]
    for i in l:
        if max_ < i:
            max_ = i
        yield max_
 
rm = [[0, 0]] + S
lm = S + [[c, c]]
 
rpath = list(right())
lmax = max([l[i]+rpath[-(i+1)]-(c-lm[-(i+1)][0]) for i in range(N)])
 
lpath = list(left())
rmax = max([r[i]+lpath[-(i+1)]-rm[i][0] for i in range(N)])
 
 
print(max(rmax, lmax))

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

typedef long long ll;

int main () {
	int N;
	int cnt = 0;
	bool flag = false;
	cin >> N;
	for (int i=0; i<N; i++) {
		int d1, d2;
		cin >> d1 >> d2;
		if (d1==d2)
			cnt ++;
		else
			cnt = 0;
		if (cnt>=3 && !flag) {
			flag = true;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#!/usr/bin/env python

def main():
    N = int(input())
    V = list(map(int, input().split()))
    V.sort()

    ans = V[0]
    for i in range(N-1):
        ans = (ans + V[i+1]) / 2
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 38484
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    string s,t;cin >> s >> t;
    int a,b;cin >> a >>b;
    string u;cin >> u;
    if(s ==u)cout << a-1 <<" "<< b << endl;
    else cout << a <<" " <<  b-1 << endl;
    return 0;
}

Measured memory_bytes: 256