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

using namespace std;

int n;

struct Circle {
    int x, y, r;
    int c;
    Circle() {}
    Circle(int x, int y, int r, int c) : x(x), y(y), r(r), c(c) {}
};

bool intersect(Circle& a, Circle& b) {
    return (a.r+b.r) * (a.r+b.r) > (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);
}

vector<Circle> cs;
vector< vector<int> > upper;
void init() {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (intersect(cs[i], cs[j])) {
                upper[i].push_back(j);
            }
        }
    }
}
 
char dp[1<<24];
int remove(int used=0) {
    if (dp[used] >= 0) return dp[used];
    vector<int> tops;
    for (int i = 0; i < n; i++) {
        if (used & (1<<i)) continue;
        bool cover = false;
        for (int j = 0; j < upper[i].size(); j++) {
            if (!(used & (1<<upper[i][j]))) {
                cover = true;
                break;
            }
        }
        if (!cover) tops.push_back(i);
    }
    int cnt = 0;
    for (int i = 0; i < tops.size(); i++) {
        for (int j = 0; j < tops.size(); j++) {
            if (i == j) continue;
            if (cs[tops[i]].c == cs[tops[j]].c) {
                used |= (1<<tops[i]);
                used |= (1<<tops[j]);
                cnt = max(cnt, remove(used)+2);
                used ^= (1<<tops[i]);
                used ^= (1<<tops[j]);
            }
        }
    }
    return dp[used] = cnt;
}

int main() {
    while (cin >> n, n) {
        cs = vector<Circle>(n);
        upper = vector< vector<int> >(n);
        for (int i = 0; i < n; i++) {
            int x, y, r, c;
            cin >> x >> y >> r >> c;
            cs[i] = Circle(x, y, r, c);
        }
        init();
        memset(dp, -1, sizeof(dp));
        cout << remove() << endl;
    }
    return 0;
}

Measured memory_bytes: 17608
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
a=n1()
b=n1()
ans=0

for i in range(n):
    a1,a2,b1=a[i],a[i+1],b[i]
#     print(a,b,ans)
    if a1-b1>=0:
        ans+=b1
    else:
        ans+=a1
        b1-=a1
        a[i+1]-=min(b1,a2)
        ans+=min(b1,a2)
# print(a,b,ans)
print(ans)

Measured memory_bytes: 19004
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n);
    for(int i=0;i<n;++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i=0;i<n;++i) {
        b[i] = a[i] + ((i>0)?b[i-1]:0);
    }

    ll ng = -1, ok = 1+a[n-1]+a[n-1];  // ok 以上の和となるような握手を使う
    ll ok_cnt = 0, ok_sum = 0;
    while(ok - ng > 1) {
        ll mid = (ng + ok) / 2;
        // cerr << mid << endl;
        ll cnt = 0, _sum = 0;;
        for(int i=n-1;i>=0&&a[i]+a[i]>=mid;--i) {
            auto itr = lower_bound(a.begin(), a.begin()+i, mid-a[i]);
            int idx = itr - a.begin();
            if(idx == i) {
                ++cnt;
                _sum += a[i]+a[i];
            } else {
                cnt += 2LL * (i - idx) + 1LL;
                // cerr << i << ", " << idx << ": " << b[i-1] - (idx>0?b[idx-1]:0) << endl;
                _sum += 2LL * ((i-idx) * a[i] + b[i-1] - (idx>0?b[idx-1]:0)) + a[i]+a[i];
            }
        }
        
        if(cnt > m) {
            ng = mid;   // 回数が多い = 条件がゆるすぎる
        } else {
            ok = mid;
            ok_cnt = cnt;
            ok_sum = _sum;
        }
    }
    // cerr << ok << " " << ok_cnt << " " << ok_sum << endl;
    ok_sum += (m-ok_cnt) * ng;
    cout << ok_sum << endl;
}


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

vector< int > z_algorithm(const string &s) {
  vector< int > prefix(s.size());
  for(int i = 1, j = 0; i < s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while(i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int) s.size();
  return prefix;
}

int main(){
  string s,t; cin >> s >> t;
  string x;
  int n=s.length();
  x = s+t+t;
  string ans="No";
  auto v = z_algorithm(x);
  for(int i=n;i<3*n;i++){
  	if(v[i]>=n) ans="Yes";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
using namespace std;
int x;
string s;
int main(){
	cin>>s;
	for(int i=0;i<s.length();++i){
		x+=s[i]-'0';
		if(x>=9)x-=9;
	}
	printf(x?"No":"Yes");
	return 0;
}

Measured memory_bytes: 3364
import math

X = int(input())

def main():
    hit_nums = set([1])
    
    limit = math.floor(math.sqrt(X))
    base = 2
    while base <= limit:
        curr = base
        while curr <= X:
            hit_nums.add(curr)
            curr *= base
        base += 1

    print(max(hit_nums))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, k, x, ans = 0;

    cin >> n >> k;

    while (n--) {

        cin >> x;

        if (x >= k) ans++;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
S = gets.chomp
T = gets.chomp
t = T.chars
SZ = t.size

ans = 1000
(S.size-SZ+1).times do |i|
  cnt = SZ - t.each_with_index.count {|c,j| c == S[i+j] }
  ans = cnt if cnt < ans
end
puts ans

Measured memory_bytes: 14296
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
const ll MOD = 998244353;
const ll INF = 1e18;
using namespace std;


main(){    
    #ifdef XOX
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\Input.txt", "r", stdin);
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\OPT.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll k, a, b;
    cin >> k >> a >> b;
    ll tmp = (a + k - 1) / k;
    tmp *= k;
    if(tmp <= b)    cout << "OK\n";
    else    cout << "NG\n";
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<bool> is(N, false);
    vector<int> count(N, 1);
    is[0] = true;
    rep(i, M){
        int x, y;
        cin >> x >> y;
        if(is[x-1]){
            is[y-1] = true;
        }
        if(count[x-1] == 1 && is[x-1]){
            is[x-1] = false;
        }
        count[x-1]--;
        count[y-1]++;
    }
    int cnt = 0;
    rep(i, N) if(is[i]) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3672
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A11 = sc.nextInt();
    int A12= sc.nextInt();
    int A13 = sc.nextInt();
    int A21 = sc.nextInt();
    int A22 = sc.nextInt();
    int A23 = sc.nextInt();
    int A31 = sc.nextInt();
    int A32 = sc.nextInt();
    int A33 = sc.nextInt();
    int N = sc.nextInt();
    int[] b = new int[N];
    for (int i = 0; i < N; i++) {
      b[i] = sc.nextInt();
    }
    boolean A11t =false;
    boolean A12t =false;
    boolean A13t =false;
    boolean A21t =false;
    boolean A22t =false;
    boolean A23t =false;
    boolean A31t =false;
    boolean A32t =false;
    boolean A33t =false;

    for (int j = 0; j < N; j++) {
      if(b[j] == A11){
        A11t =true;
      }
    }
    
    for (int j = 0; j < N; j++) {
      if(b[j] == A12){
        A12t =true;
      }
    }

    
    for (int j = 0; j < N; j++) {
      if(b[j] == A13){
        A13t =true;
      }
    }
    
    for (int j = 0; j < N; j++) {
      if(b[j] == A21){
        A21t =true;
      }
    }
    for (int j = 0; j < N; j++) {
      if(b[j] == A22){
        A22t =true;
      }
    }
    for (int j = 0; j < N; j++) {
      if(b[j] == A23){
        A23t =true;
      }
    }
    for (int j = 0; j < N; j++) {
      if(b[j] == A31){
        A31t =true;
      }
    }
    for (int j = 0; j < N; j++) {
      if(b[j] == A32){
        A32t =true;
      }
    }    for (int j = 0; j < N; j++) {
      if(b[j] == A33){
        A33t =true;
      }
    }
    if(A11t == true &&A12t == true&&A13t == true){
      System.out.println("Yes"); 
      return; 
    }
    if(A21t == true &&A22t == true&&A23t == true){
      System.out.println("Yes"); 
      return; 
    }
    if(A31t == true &&A32t == true&&A33t == true){
      System.out.println("Yes"); 
      return; 
    }
    if(A11t == true &&A21t == true&&A31t == true){
      System.out.println("Yes"); 
      return; 
    }
    if(A12t == true &&A22t == true&&A32t == true){
      System.out.println("Yes"); 
      return; 
    }
    if(A13t == true &&A23t == true&&A33t == true){
      System.out.println("Yes"); 
      return; 
    }
    if(A11t == true &&A22t == true&&A33t == true){
      System.out.println("Yes"); 
      return; 
    }
    if(A31t == true &&A22t == true&&A13t == true){
      System.out.println("Yes"); 
      return; 
    }
      System.out.println("No") ;

  }
}

Measured memory_bytes: 21844
N, W = map(int, input().split())
w = []
v = []
for _ in range(N):
    x, y = map(int,input().split())
    w.append(x)
    v.append(y)
    
dp = [ [0 for i in range(W+1)] for j in range(N+1) ]

for i in range(N):
    for j in range(W+1):
        if j-w[i] >= 0:
            dp[i+1][j] = max( dp[i][j], dp[i][j-w[i]]+v[i] )
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])

print(dp[N][W])

Measured memory_bytes: 172040
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a != c) cout << "Yes" << '\n';
  else if (b == c && a != c) cout << "Yes" << '\n';
  else if (a == c && b != c) cout << "Yes" << '\n';
  else cout << "No" << '\n'; 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define int long long
using namespace std;

int x[100000], y[100000];
signed main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		x[i] = a + b, y[i] = a - b;
	}
	int minx = *min_element(x, x + n);
	int maxx = *max_element(x, x + n);
	int miny = *min_element(y, y + n);
	int maxy = *max_element(y, y + n);
	int a = 0, b = 0;
	for (int i = 0; i < n; i++) {
		a = max(a, min(max(x[i] - minx, y[i] - miny), max(maxx - x[i], maxy - y[i])));
		b = max(b, min(max(x[i] - minx, maxy - y[i]), max(maxx - x[i], y[i] - miny)));
	}
	cout << min(a, b) << endl;
}

Measured memory_bytes: 4584
#include<stdio.h>
#include<string.h>
int main (){
  char box[200];
  int a,b,sum=0;
  while(1){
    sum=0;
    scanf("%s",box);
    if(box[0] == '-')break;
    scanf("%d",&a);
    for(int i=0;i<a;i++){
      scanf("%d",&b);
      sum+=b;
    }
    sum=sum%(strlen(box));
    for(int i=sum;i<strlen(box);i++){
      printf("%c",box[i]);
    }
    for(int i=0;i<sum;i++){
      printf("%c",box[i]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll ans = (x / 11) * 2;
	x %= 11;
	if(x == 0) ;
	else if(x <= 6) ans++;
	else ans += 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//Keep Working Hard
  // I__Like__Food
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define f first
  #define s second
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 3005
  #define INF 1e10
  const double PI = acos(-1);

int dp[N][N];
int32_t main()
{


    // dp[i][j] denotes the maximum difference b/w  Taro's and Jiro's values
    

    int n;
    cin >> n;
    int arr[n+1];
    

    for(int i = 1; i <= n; i++)
    {
      cin >> arr[i];
      dp[i][i] = arr[i];
    }




    for(int i = 2; i <= n; i ++)
    {
      // fill with increasing length of segments in variable i
      for(int j = 1; j + i - 1<= n; j++)
      {
        int l = j;
        int r = j + i - 1;  
        dp[l][r] = max(arr[l] - dp[l+1][r],arr[r] - dp[l][r-1]);
      }
    }

    cout << dp[1][n];


  return 0;
  
}   

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

int main() {
	string Ans;
	int N; cin>>N;
	int K; cin>>K;
	vector<int> A(N);
	REP(i,N) cin>>A[i];
	REP(i,N-K){

		if (A[i+K]>A[i]){
			cout << "Yes" << '\n';
		}else{
			cout << "No" << '\n';
		}
	}


	return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N; cin >> N;
  vector<int64_t> a(N); cin >> a;
  vector<int64_t> b(N); cin >> b;
  int64_t acnt = 0;
  rep(i, a.size()) {
    if (a[i] < b[i]) {
      auto num = (b[i] - a[i] + 1) / 2;
      a[i] += 2LL * num;
      acnt += num;
    }
  }

  int64_t bcnt = 0;
  rep(i, b.size()) {
    if (b[i] < a[i]) {
      auto num = a[i] - b[i];
      b[i] += num;
      bcnt += num;
    }
  }

  cout << (acnt >= bcnt ? "Yes\n" : "No\n");
}


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

int main() {
  long a,b,c;
  cin >> a>>b>>c;
  if(a<b){
    swap(a,b);
  }
  if(a<c){
    swap(a,c);
  }
  if(a%2==0||b%2==0||c%2==0){
    cout<<0<<endl;
  }
  else{
    cout<<b*c<<endl;
  }
  
 
}





Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int M = int.Parse(str[1]);
        bool[] b = new bool[N];
        bool[] c = new bool[N];
        for(int i=0;i<M;i++){
            str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]) - 1;
            int d = int.Parse(str[1]) - 1;
            if(a == 0){
                b[d] = true;
            }
            if(d == N-1){
                c[a] = true;
            }
        }
        bool ans = false;
        for(int i=1;i<N-1;i++){
            ans |= b[i] && c[i];
        }
        if(ans){
            sb.Append("POSSIBLE\n");
        }
        else{
            sb.Append("IMPOSSIBLE\n");
        }
    }
}

Measured memory_bytes: 15400
#include<iostream>
#include<cstdio>
#include<stack>
#include<string>
#include<cstdlib>
using namespace std;

int main() {
	stack<int> S;
	int a, b, x;
	string s;

	while (cin >> s) {
		if (s[0] == '+') {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
		}
		else if (s[0] == '-') {
			b = S.top(); S.pop();
			a = S.top(); S.pop();
			S.push(a - b);
		}
		else if (s[0] == '*') {
			a = S.top(); S.pop();
			b = S.top();S.pop();
			S.push(a*b);
		}
		else {
			S.push(atoi(s.c_str()));
		}
	}

	cout << S.top() << endl;

	return 0;
}

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

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

	vector<pair <long,long> > Shop(N);

	for(int i = 0; i < N; i++){
		cin >> Shop[i].first >> Shop[i].second;
	}
	
	sort(Shop.begin(),Shop.end());
	
	long sum = 0,num = 0;
	int a = 0,b = 0;
	
	while(num < M){
		num++;
		sum += Shop[a].first;
		b++;
		
		if(b == Shop[a].second){
			a++;
			b = 0;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 1792
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int n = sc.nextInt();
		int[] p = nextIntArray(sc, n);

		sc.close();

		int ans = 0;
		for (int i = 1; i < n - 1; i++) {
			if (p[i - 1] < p[i] && p[i] < p[i + 1] ||
				p[i - 1] > p[i] && p[i] > p[i + 1]) {
				ans++;
			}
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 25172
using System;
class Program{
    static void Main(string[]args){
        string N=Console.ReadLine();
        string[]t=N.Split(' ');
        int []T=new int[t.Length];
        for(int i=0;i<T.Length;i++){
            T[i]=int.Parse(t[i]);
        }
        int K=int.Parse(Console.ReadLine());
        
        for(int i=0;i<T.Length-1;i++){
            if(T[i]>T[i+1]){
                int n=T[i];
                T[i]=T[i+1];
                T[i+1]=n;
            }
        }
        int s=T[0]+T[1]+T[2]*(int)Math.Pow(2,K);
        Console.WriteLine(s);
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
int main(){
  long int a, b, c, k;
  scanf("%ld%ld%ld%ld", &a,&b,&c,&k);
  if(k-a<0){
    printf("%ld",k);
    return 0;
  }
  if(k-a-b<0){
    printf("%ld",a);
    return 0;
  }else{
    printf("%ld",a-(k-a-b));
    return 0;
  }
  return 0;
}

Measured memory_bytes: 1684
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  ll H, W; cin >> H >> W;

  if (H == 1 || W == 1){
    cout << 1 << endl;
    return 0;
  }

  ll ans = H * (W / 2);
  if (W % 2 != 0) ans += (H + 1) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

int main(void){
    ll N,A,B;
    cin >> N >> A >> B;
    
    if(A*B<N){GOODBYE;}
    if(A+B>N+1){GOODBYE;}
    
    
    vector<ll> D(B,1);
    ll remain = N-B;
    REP(i,B){
        if(remain>=A-1){
            D[i]+=A-1;
            remain -= A-1;
        }else{
            D[i]+=remain;
            remain=0;
        }
    }
    
    vector<ll> Ans;
    remain = N;
    
    REP(j,D.size()){
        for(ll i=remain-D[j]+1;i<=remain;i++){
            Ans.push_back(i);
        }
        remain-=D[j];
    }
    
    REP(i,N){
        if(i!=0){cout << " ";}
        cout << Ans[i];
    }
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 8568
#!/usr/bin/env ruby
def read_input()
  edge_num = gets(chomp: true).to_i
  edges = []
  graph = {}
  (1...edge_num).each do
    edge = gets(chomp: true).split()
    edges << edge
    a,b = edge
    if (!graph.has_key?(a))
      graph[a] = []
    end
    graph[a] << b
  end
  [edges, graph]
end

def solve(graph, node, base_color, color_edge, max)
  children = graph[node]
  return [max, color_edge] if children.nil?
  edge_num = children.length
  edge_num += 1 unless (base_color.nil?)
  max = edge_num if (edge_num > max)
  color = 0
  children.each { |child|
    color += 1
    color += 1 if (color == base_color)
    color_edge[node] = {} if (color_edge[node].nil?)
    color_edge[node][child] = color
    max, color_edge = solve(graph, child, color, color_edge, max)
  }
  [max, color_edge]
end

edges, graph = read_input
max, color_edge = solve(graph, "1", nil, {}, -1)

puts max
edges.each do |a,b|
  puts color_edge[a][b]
end


Measured memory_bytes: 124932
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
       int x = input.nextInt();
       String s = input.next();
       
        int c=0;
        for(int i = 0;i<x-2;i++){
            
           if(s.charAt(i)=='A'&&s.charAt(i+1)=='B'&&s.charAt(i+2)=='C'){
               c++;
               
           }
            
            
    
    }
        System.out.println(c);
    
}}

Measured memory_bytes: 22608
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    ll a,b,c; cin>>a>>b>>c;
    if(c-a-b<=0){
        cout<<"No"<<endl;
        return 0;
    }
    if(4LL*a*b<(c-a-b)*(c-a-b)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main(){
	vector<int> a,b;
	int n;
	for(int i = 0 ; i*i*i < 200000; i++) a.push_back(i*i*i);
	b.insert(b.end(),a.begin(),a.end());
	for(int i = 0 ; i*(i+1)*(i+2)/6 < 200000; i++){
		for(int j = 0 ; j < a.size() ; j++)
			b.push_back( i*(i+1)*(i+2)/6  + a[j] );
	}
	sort(b.begin(),b.end());
	while(cin >> n , n){
		cout << *(upper_bound(b.begin(),b.end(),n)-1) << endl;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main(){
char moji[1200];
int i;
scanf("%[^\n]",&moji);

for(i=0;i<=strlen(moji);i++){
if(moji[i]>='a' && moji[i]<='z') {moji[i]=moji[i]-32;}
else if(moji[i]>='A' && moji[i]<='Z') {moji[i]=moji[i]+32;}
}

printf("%s\n",moji);
return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main()
{
  ll N,K;
  ll ans=0;
  cin >> N >> K;
  vector <ll> H(300000);
  for(ll i=0; i<N; i++){
    cin >> H.at(i);
  }
  sort(H.begin(),H.end());
  reverse(H.begin(),H.end());
  for(ll i=0; i<K; i++){
    H.at(i)=0;
  }
  for(ll i=0; i<N; i++){
    ans+=H.at(i);
  }
  cout << ans << endl;
  return 0;
}


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

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

	char now=s[0];
	int count=1;
	for(int i=1;i<s.length();i++){
		if(s[i]==now){
			continue;
		}else{
			now=s[i];
			count++;
		}
	}
	//cout<<count<<endl;
	cout<<(count-1)<<endl;

	return 0;
}


Measured memory_bytes: 512
h,w = map(int, input().split())
al = []
bl = []

for _ in range(h):
    row = list(map(int, input().split()))
    al.append(row)

for _ in range(h):
    row = list(map(int, input().split()))
    bl.append(row)


cl = [ [0]*w for _ in range(h) ]
for i in range(h):
    for j in range(w):
        cl[i][j] = abs(al[i][j] - bl[i][j]) 

INF = 10**9
lim = (h+w)*80//2+1
# dp = [ [INF]*6400 for _ in range(h) ]
dp = [ [ [False]*(lim+1)  for _ in range(w) ] for _ in range(h) ]

dp[0][0][cl[0][0]] = True

for i in range(h):
    for j in range(w):
        for k in range(0,lim+1):
            if dp[i][j][k] == True:
                if i+1 < h:
                    v = cl[i+1][j]
                    if k+v <= lim: dp[i+1][j][k+v] = True
                    dp[i+1][j][abs(k-v)] = True
                if j+1 < w:
                    v = cl[i][j+1]
                    if k+v <= lim: dp[i][j+1][k+v] = True
                    dp[i][j+1][abs(k-v)] = True


for i,v in enumerate(dp[-1][-1]):
    if v == True:
        print(i)
        break

Measured memory_bytes: 395596
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def palindrome(string):
    return string==string[::-1]

def main():
    S = input()
    N = len(S)
    if palindrome(S) and palindrome(S[0:((N-1)//2)]) and palindrome(S[((N+3)//2)-1:N]):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.io.*;

public class Main{

	public static void main(String[] args) throws IOException{

		int i, q;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] A = new int[n];

		String[] in = br.readLine().split(" ");
		for(i = 0; i < n; i++){
			A[i] = Integer.parseInt(in[i]);
		}

		q = partition(A, 0, n-1);

		StringBuffer sb = new StringBuffer();
		for(i = 0; i < n; i++){
			if(i != 0)
				sb.append(" ");
			if(i == q)
				sb.append("[");
			sb.append(A[i]);
			if(i == q)
				sb.append("]");
		}
		System.out.println(sb);
	}

	public static int partition(int[] A, int p, int r){
		int x, i, j, t;
		x = A[r];
		i = p-1;
		for(j = p; j < r; j++){
			if(A[j] <= x){
				i++;
				t = A[i];
				A[i] = A[j];
				A[j] = t;
			}
		}
		t = A[i+1];
		A[i+1] = A[r];
		A[r] = t;
		return i+1;
	}
}

Measured memory_bytes: 41028
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define MOD (1000000007ll)

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

ll dp[55][55][2525];

int main(void){
	int n,a,x[55],i,j,k;
	ll ans = 0ll;
	fill(dp[0][0],dp[55][0],0ll);
	dp[0][0][0] = 1ll;
	cin >> n >> a;
	for(i=1; i<=n; ++i){
		cin >> x[i];
	}
	for(i=1; i<=n; ++i){
		for(j=0; j<=n; ++j){
			for(k=0; k<2525; ++k){
				if(k < x[i]){
					dp[i][j][k] += dp[i-1][j][k];
				}else if(j > 0){
					dp[i][j][k] += dp[i-1][j][k] + dp[i-1][j-1][k-x[i]];
				}
			}
		}
	}
	for(i=1; i<=n; ++i){
		ans += dp[n][i][i*a];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 59904
import sys
# from collections import deque
# from collections import Counter
# from math import sqrt
# from math import log
# from math import ceil

# def gcd(a, b):
# 	if(a==0):
# 		return b 
# 	return gcd(b%a,a)

# def sieve(n): 
# 	prime=[True for i in range(n+1)]
# 	p=2
# 	while(p*p<=n): 
# 		if (prime[p]==True): 
# 			for i in range(p*p,n+1,p): 
# 				prime[i]=False
# 		p+=1
# 	prime[0]=False
# 	prime[1]=False
# 	s=set()
# 	for i in range(len(prime)):
# 		if(prime[i]):
# 		s.add(i)
# 	return s 

# alpha=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
# mod=10**9+7

fast_reader=sys.stdin.readline
fast_writer=sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i)) for i in argv))
	fast_writer('\n')

def list_input():
	return list(map(int, input().split()))

def sep_input():
	return map(int, input().split())

#_______________________________________________________________________________________________________________________________________

x,n=sep_input()
l=list_input()
s=set(l)
i=0
while(True):
	if(x-i not in s):
		print(x-i)
		break
	elif(x+i not in s):
		print(x+i)
		break
	else:
		i+=1

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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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 n;
vi h;

void solve() {
  cin>>n;
  h.resize(n);
  rep(i,0,n) cin>>h[i];

  bool flag=true;
  rep(i,0,n) {
    if(i==0) {
      h[i]--;
      continue;
    }
    if(h[i]>h[i-1]) h[i]--;
    else if(h[i]==h[i-1]) continue;
    else {
      flag=false;
      break;
    }
  }
  if(flag==true) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a, b, ans;

int main() {
	cin >> a >> b;
	for(int i = 1; i <= 1250; i++) {
		double x = i * 0.08;
		double y = i * 0.1;
		if(floor(x) == a && floor(y) == b) {
			ans = i;
			break;
		}
	}
	if(!ans) puts("-1");
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "-1\n"; return;}

void solve() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while (b <= a && k) {
        --k; b <<= 1;
    }
    while (c <= b && k) {
        --k; c <<= 1;
    }
    cout << (b > a && c > b ? "Yes" : "No");
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3632
n,k,c = list(map(int, input().split()))
s = list(input())
l = []
r = []

i = 0
while i < n and len(l) <= k:
  if s[i] == "o":
    l.append(i)
    i += (c + 1)
  else:
    i += 1

i = n-1
while i >= 0 and len(r) <= k:
  if s[i] == "o":
    r.append(i)
    i -= (c+1)
  else:
    i -= 1
  
i = 0
while i < k:
  if l[i] == r[k-1-i]:
    print(l[i]+1)
  i += 1
  
  



Measured memory_bytes: 22044
using System;using System.Linq;
class A{
static void Main()
{
long []a=Console.ReadLine().Split().Select(long.Parse).ToArray();
Array.Sort(a);
if(a[0]>0&&a[1]>0){Console.WriteLine("Positive");}
else if(a[0]<=0&&a[1]>=0){Console.WriteLine("Zero");}
else if(a[0]==0||a[1]==0){Console.WriteLine("Zero");}
else if((a[1]-a[0])%2==0){Console.WriteLine("Negative");}
else{Console.WriteLine("Positive");}
}

}

Measured memory_bytes: 13396
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

#define MAXN 400

ll dp[MAXN][MAXN];
ll s[MAXN+1];

ll dfs(ll i, ll j){
  if(dp[i][j]!=-1) return dp[i][j];
  else if(i==j) return dp[i][j] = 0;
  else{
    ll temp = INF;
    for(ll k = i; k < j; k++){
      temp = min(temp,dfs(i,k)+dfs(k+1,j));
    }
    return dp[i][j] = temp+s[j+1]-s[i];
  }
}

int main(){
  ll n;
  cin >> n;
  ll a[n];
  s[0] = 0;
  REP(i,n){
    cin >> a[i];
    s[i+1] = s[i]+a[i];
  }
  fill(dp[0],dp[n],-1);
  cout << dfs(0,n-1) << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#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 ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,m,x;
  cin >> n>>m>>x;
  vector<vector<int>> a(n,vector<int>(m));
  vector<int> c(n);
  REP(i,n){
    cin >> c[i];
    REP(j,m){
      cin >> a[i][j];
    }
  }
  vector<int> tmp(m);
  ll min = INF;
  ll sum = 0;
  for(int i=1;i<(1<<n);i++){
    for(int j=0;j<m;j++)tmp[j] = 0;
    sum = 0;
    for(int j=0;j<n;j++){
		if((i>>j)&1){
          sum += c[j];
			for(int k=0;k<m;k++){
				tmp[k] += a[j][k];
              
            }
        }
    }
    bool flag = true;
    for(int j=0;j<m;j++){
		if(tmp[j] < x){
          flag = false;
          break;
        }
    }
    if(flag){
      if(sum < min){
        min = sum;
      }
    }
  }
  if(min == INF){
	cout << -1 <<endl;
  }else{
    cout << min << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int ans=1,res=1;
const int md=998244353;
char buf[200010];
int n;
int sum=0;
bool f1=true,f2=false;
int main()
{
	scanf("%s",buf);
	n=strlen(buf);
	for(int i=0;i+1<n;i++)
	{
		if(buf[i]!=buf[i+1])f1=false;
		else f2=true;
		sum+=buf[i]-'a';
		if(sum>=3)sum-=3;
	}
	sum+=buf[n-1]-'a';
	if(sum>=3)sum-=3;
	if(f1)return !printf("1");
	for(int i=1;i<n;i++)
	{
		ans=3LL*ans%md;
		res=2LL*res%md;
	}
	ans=ans+md-res;
	if(ans>=md)ans-=md;
	if(n==3 && !sum)return !printf("3");
	if(!f2)
	{
		ans++;
		if(ans>=md)ans-=md;
	}
	if(n%3==0)
	{
		int tmp=1;
		for(int i=1;i<n/3;i++)tmp=2LL*tmp%md;
		if(sum)ans+=tmp;
		else ans-=2LL*tmp%md-md;
		if(ans>=md)ans-=md;
	}
	printf("%d",ans);
	return 0;
} 

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

int main() {
  char c;
  cin >> c;
  if (c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
 
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, x, max;
    int a, b, c;
    int ans;
    
    while (1) {
        scanf("%d %d", &n, &x);
        
        if (n == 0 && x == 0) {
            break;
        }
        
        ans = 0;
        max = x; if (max > n) max = n;
        
        for (a = 1; a <= max; a++) {
            for (b = a + 1; b <= max; b++) {
                c = x - a - b;
                
                if (c > b && c <= n) {
                    ans++;
                }
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


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

int solve(int n,char *sA,char *sB)
{
  bool A[2000],B[2000];
  for(int i=0;i<n;i++){
    A[i]=(sA[i]=='1');
    B[i]=(sB[i]=='1');
  }
  int t=n-1;
  while(!B[t])t--;
  t-=n;
  int b0[2000];
  for(int i=0;i<n;i++){
    if(B[i])t=i;
    b0[i]=i-t;
  }
  t=0;
  while(!B[t])t++;
  int b1[2000];
  t+=n;
  for(int i=n-1;i>=0;i--){
    if(B[i])t=i;
    b1[i]=t-i;
  }
  /*for(int i=0;i<n;i++){
    printf("%d %d %d\n",B[i],b0[i],b1[i]);
    }*/
  int ans=-1;
  for(int s=0;s<2*n;s++){
    int ct=s;
    vector<pair<int,int> > P;
    for(int i=0;i<n;i++){
      int j=(i+s)%n;
      if(A[i]!=B[j]){
	ct++;
      }
      if(A[i]==1&&B[j]==0&&b0[j]>s){
	P.push_back(make_pair(b0[j]-s,b1[j]));
      }
    }
    sort(P.begin(),P.end());
    int N=P.size();
    vector<int> mx(N+1);
    mx[N]=0;
    for(int i=N-1;i>=0;i--){
      mx[i]=max(mx[i+1],P[i].second);
    }
    int op=mx[0];
    for(int i=0;i<N;i++){
      op=min(op,P[i].first+mx[i+1]);
    }
    ct+=2*op;
    if(ans==-1||ans>ct){
      ans=ct;
    }
  }
  return ans;
}

int main()
{
  char A[3000],B[3000];
  scanf("%s%s",A,B);
  int n=strlen(A);
  bool F=0;
  for(int i=0;i<n;i++){
    if(B[i]=='1'){
      F=1;
      break;
    }
  }
  if(!F){
    F=0;
    for(int i=0;i<n;i++){
      if(A[i]=='1'){
	F=1;
	break;
      }
    }
    printf("%d\n",F?-1:0);
    return 0;
  }
  char RA[3000],RB[3000];
  for(int i=0;i<n;i++){
    RA[i]=A[n-i-1],RB[i]=B[n-i-1];
  }
  int ans=solve(n,A,B);
  ans=min(ans,solve(n,RA,RB));
  printf("%d\n",ans);
  return 0;
}


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

int main()
{
    int m,p;
    cin>>m;
    int a[8],b[8],c[8];
    for(int i=0;i<m;i++){
        cin>>a[i];
        c[i]=a[i];
    }
    for(int i=0;i<m;i++)
        cin>>b[i];

    long count=0;
    int flag1=1;
    do{
        int flag=0;
        for(int i=0;i<m;i++){
            if(a[i]==b[i])
                flag++;
        }
        count++;
        if(flag==m){
            flag1=0;
            cout<<count-1;
            break;
        }
    }while(next_permutation(a,a+m));
    if(flag1==1){
        count=0;
        long n=1;
        for(int i=1;i<=m;i++){
            n=n*i;
        }
        do{
        int flag2=0;
        for(int i=0;i<m;i++){
            if(c[i]==b[i])
                flag2++;
        }
        count++;
        if(flag2==m){
            cout<<count-1;
            break;
        }
    }while(next_permutation(b,b+m));
    }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	int[] boll;

	void run() {
		int N = sc.nextInt();
		while (N-- > 0) {
			boll = sc.nextIntArray(10);
			System.out.println(dfs(0, 0, 0) ? "YES" : "NO");
		}
	}

	boolean dfs(int index, int right, int left) {
		if (index == 10) {
			return true;
		}
		if (boll[index] > right) {
			return dfs(index + 1, boll[index], left);
		}
		if (boll[index] > left) {
			return dfs(index + 1, right, boll[index]);
		}
		return false;
	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int lim) {
		return 0 <= h && h < lim && 0 <= w && w < lim;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (a[i] >= border)
	int lower_bound(int a[], int border) {
		int l = -1;
		int r = a.length;

		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (border <= a[mid]) {
				r = mid;
			} else {
				l = mid;
			}
		}
		// r = l + 1
		return r;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}
	}
}

Measured memory_bytes: 17136
n=int(input())
bignum=10**30
num1,num2,num3,num4=-bignum,bignum,-bignum,bignum
for i in range(n):
  x,y=map(int, input().split())
  num1=max(x+y,num1)
  num2=min(x+y,num2)
  num3=max(x-y,num3)
  num4=min(x-y,num4)
print(max(num1-num2,num3-num4))

Measured memory_bytes: 9144
Imports System

Public Class Program

    Public Shared Sub Main()

        Dim N As Integer = Integer.Parse(Console.ReadLine())
        Dim dn(N - 1) As Integer



        For i As Integer = 0 To N - 1

            dn(i) = Integer.Parse(Console.ReadLine)

        Next

        Array.Sort(dn)

        Dim cnt As Integer = 1
        Dim temp As Integer = dn(0)

        For i As Integer = 0 To N - 1

            If Not (temp = dn(i)) Then
                cnt += 1
                temp = dn(i)
            End If

        Next


        Console.WriteLine(cnt)



    End Sub
End Class

Measured memory_bytes: 13140
check = [False,False]


for i in range(0,999998):
    check.append(True)

for i in range(2,1000000):
    if(check[i]):
        for j in range(i*i,1000000,i):
            check[j]=False



while True:
    try:
        ans = 0
        a = int(input())
        for y in range(0,a+1):
            if(check[y]):
                ans += 1

        print(ans)

    except:
        break;




Measured memory_bytes: 13372
N, M, X = map(int, input().split())
C = []
lst = []

for _ in range(N):
    c, *A = map(int, input().split())
    C.append(c)
    lst.append(A)

p = [i for i in range(N)]

cost = 10 ** 8
for i in range(2 ** N):
    bit = []
    for j in range(N):
        if ((i >> j) & 1) == 1:
            bit.append(p[j])

    t = [0] * M
    for m in range(M):
        c = 1
        for n in bit:
            t[m] += lst[n][m]
        if t[m] < X:
            c = 0
            break
    co1 = 0
    if c:
        for n in bit:
            co1 += C[n]
        if co1 <= cost:
            cost = co1

if cost ==  10 ** 8:
    cost = -1

print(cost)


Measured memory_bytes: 9184
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
signed main(){
  double r,pi;
  cin>>r;
  pi = M_PI;
  cout<<fixed<<setprecision(17)<<r*2*pi<<"\n";
  return(0);
}

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



int findDigit(int n, int digit){
    int cnt = 0;
    int temp = n;
    while (n > 0){
        n /= 10;
        cnt++;
    }
    int res = temp / pow(10, cnt - digit);
    if (res == 5) return res;
    else {
        res = res % 10;
        return res;
    }
}

int main() {
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    for(int i = a; i <= b; i++){
        if(findDigit(i,1)  == findDigit(i,5) && findDigit(i,2) == findDigit(i,4)) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256