akhauriyash/Code-Regression huggingface dataset:
require 'prime'
require 'set'
require 'tsort'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

a =  [ 1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x,y = gi
if a.include?(x) && a.include?(y) || b.include?(x) && b.include?(y) || c.include?(x) && c.include?(y)
  puts "Yes"
else
  puts "No"
end

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)

int a; string S;

int32_t main()
{
	cin>>a>>S;
	
	cout<<((a >= 3200) ? S : "red");
	
}


Measured memory_bytes: 3628
n=int(input())
a=list(map(int,input().split()))
b=[0]*n

for i in range(1,n):
  b[i]=(a[i-1]-b[i-1])
b[0]=(a[n-1]-b[n-1])//2


for i in range(1,n):
  b[i]=a[i-1]-b[i-1]

print(" ".join(map(str,[b[i]*2 for i in range(n)])))
    

Measured memory_bytes: 28272
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1000000007
using namespace std;
typedef long long ll;

typedef struct PLAYER{
public:
  string card;
  int n;
}player;

int main(){
  int pn = 3;
  vector<player> pm(pn);
  rep(i, 0, pn){
    cin >> pm[i].card;
    pm[i].n = 0;
  }
  int turn = 0;
  while(true){
    if(pm[turn].n==pm[turn].card.length()){
      break;
    }
    char card = pm[turn].card[pm[turn].n];
    pm[turn].n++;
    switch(card){
      case 'a':
      turn = 0;
      break;
      case 'b':
      turn = 1;
      break;
      case 'c':
      turn = 2;
      break;
    }
  }
  switch(turn){
    case 0:
    cout << 'A' << endl;
    break;
    case 1:
    cout << 'B' << endl;
    break;
    case 2:
    cout << 'C' << endl;
    break;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

struct point{
  double x,y;
};
int convex(struct point p1,struct point p2,struct point p3,struct point q);
int main(void){
  struct point a,b,c,d;
  int naibu;
  while((scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y,&d.x,&d.y))!=EOF){
    naibu=0;
    naibu+=convex(b,c,d,a);
    naibu+=convex(a,c,d,b);
    naibu+=convex(a,b,d,c);
    naibu+=convex(a,b,c,d);
    if(naibu==0){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }
  return 0;
}

int convex(struct point p1,struct point p2,struct point p3,struct point q){
  int answer=0;
  double s,t;
  struct point v1,v2,v3;
  v1.x=q.x-p1.x;  v1.y=q.y-p1.y;
  v2.x=p2.x-p1.x; v2.y=p2.y-p1.y;
  v3.x=p3.x-p1.x; v3.y=p3.y-p1.y;
  s=(v1.x*v2.y-v2.x*v1.y)/(v3.x*v2.y-v2.x*v3.y);
  t=(v1.x*v3.y-v3.x*v1.y)/(v2.x*v3.y-v3.x*v2.y);
  if(0<s&&1>s&&0<t&&1>t&&s+t<1){
    answer++;
  }
  return answer;
}

Measured memory_bytes: 608
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s = read(&mut stdin_lock, &mut buf, b'\n');
    println!("{}", solve(s));
}

fn solve(s: String) -> &'static str {
    if s <= "2019/04/30".to_owned() {
        "Heisei"
    } else {
        "TBD"
    }
}

#[test]
fn example1() {
    assert_eq!("Heisei", solve("2019/04/30".to_owned()))
}

#[test]
fn example2() {
    assert_eq!("TBD", solve("2019/11/01".to_owned()))
}


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

using namespace std; 

int main(){ 
  int64_t n,m;
  cin>>n>>m;
  int64_t h[100000];
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int64_t a[100000],b[100000];
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
  }
  int s[100000]={0};
  for(int i=0;i<m;i++){
    if(h[a[i]-1]>h[b[i]-1]){
      s[b[i]-1]=1;
    }
    else if(h[a[i]-1]<h[b[i]-1]){
      s[a[i]-1]=1;
    }
    else {
      s[a[i]-1]=1;
      s[b[i]-1]=1;
    }
    
  }  
  int ans=0;
  for (int i=0;i<n;i++){
    if(s[i]!=0){
      ans+=1;
    }
  }
  cout<<n-ans; 
}   


Measured memory_bytes: 6368
N, M, X, Y = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)

(X + 1).upto(Y) do |i|
  fail = false
  x.each do |j|
    if j >= i
      fail = true
      break
    end
  end

  next if fail

  y.each do |j|
    if j < i
      fail = true
      break
    end
  end

  next if fail

  puts 'No War'
  exit
end

puts 'War'

Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c,d;
	while(~scanf("%d %d %d %d",&a,&b,&c,&d))
	{
		int t;
		if(a < c) t = c;
		else t = a;
		int k;
		if(b < d) k = b;
		else k = d;
		if(k - t > 0)
			printf("%d\n",k-t);
		else printf("0\n");
	}
	return 0;
}

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

int main(){
    int k;
    string str;
    cin >> k >> str;
    int size = str.length();
    int i;
    if (size > k){
        for (i = 0; i < k ;i++){
            cout << str[i];
        }
        cout << "..."<< endl;
    }
    else {cout << str << endl;}
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
using namespace std;
const int INF = 1e9;

vector<int> dijkstra(vector< vector< pair<int,int> > > G, int s, int v){
  priority_queue< pair<int, int> > wait;
  vector<int> result(v, INF);
  result[s] = 0;
  wait.push(make_pair(0, s));
  while(!wait.empty()){
    int nowpoint = wait.top().second;
    int nowcost = wait.top().first;
    wait.pop();
    if(nowcost <= result[nowpoint]){
      for(int i = 0; i < G[nowpoint].size(); ++i){
        int nextpoint = G[nowpoint][i].second;
        int nextcost = -nowcost + G[nowpoint][i].first;
        if(nextcost < result[nextpoint]){
          wait.push(make_pair(-nextcost, nextpoint));
          result[nextpoint] = nextcost;
        }
      }
    }
  }
  return result;
}

bool in_range(int a, int b){
  return a >= 0 && a < b;
}

int main(){
  int w, h;
  while(cin >> w >> h, w){
    vector< vector<int> > M(h, vector<int>(w));
    for(int i = 0; i < h; ++i)
      for(int j = 0; j < w; ++j)
        cin >> M[i][j];
    vector<int> C(4);
    for(int i = 0; i < 4; ++i) cin >> C[i];
    int n = 4*h*w, dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
    vector< vector< pair<int,int> > > G(n);
    for(int i = 0; i < h; ++i){
      for(int j = 0; j < w; ++j){
        for(int k = 0; k < 4; ++k){
          int v = i*w + j + k*h*w;
          for(int l = 0; l < 4; ++l){
            int d = (k+l)%4, i_ = i + dy[d], j_ = j + dx[d], v_ = i_*w + j_ + d*h*w;
            if((!in_range(i_, h)) || (!in_range(j_, w))) continue;
            if(M[i][j] == l){
              G[v].push_back(make_pair(0, v_));
            }else{
              G[v].push_back(make_pair(C[l], v_));
            }
          }
        }
      }
    }
    /*
    for(int i = 0; i < n; ++i){
      int d = i/(h*w), x = (i%(h*w))/w, y = (i%(h*w))%w;
      printf("(d = %d, x = %d, y = %d)\n", d, x, y);
      for(int j = 0; j < G[i].size(); ++j){
        int t = G[i][j].second, c = G[i][j].first;
        int d = t/(h*w), x = (t%(h*w))/w, y = (t%(h*w))%w;
        printf("(d = %d, x = %d, y = %d) : c = %d\n", d, x, y, c);
      }
      cout << endl;
    }
    */
    vector<int> D = dijkstra(G, 0, n);
    int ans = INF;
    for(int i = 0; i < 4; ++i){
      ans = min(ans, D[h*w*i + h*w - 1]);
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3496
import sys
sys.setrecursionlimit(1000000)

def DFS(start):
    global graph
    global zahyou

    start_num=zahyou[start]

    for w,d in graph[start]:
        if(zahyou[w]==None):
            zahyou[w]=start_num + d
            if( not DFS(w)):
                return False
        else:
            if(start_num + d != zahyou[w]):
                return False

    return True



n,m=map(int,input().split())
graph=[[] for _ in range(n)]

zahyou=[None]*n
for i in range(m):
    l,r,d=map(int,input().split())
    graph[l-1].append((r-1,d))
    graph[r-1].append((l-1,-1*d))

flag=True
for i in range(n):
    if(zahyou[i]==None):
        zahyou[i]=0
        flag&=DFS(i)
        if( not flag):
            break

if(flag):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 128896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  ll a, b, x;
  cin >> a >> b >> x;

  ll bn = b / x;
  ll an = a / x;
  if (a % x == 0) cout << bn - an + 1 << endl;
  else cout << bn - an << endl;
}


Measured memory_bytes: 256
// Author: getharshkumar

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    for (char &c : s)
        c = (c - 'A' + n) % 26 + 'A';
    cout << s;
    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a+b<10) cout << a+b << endl;
    else cout << "error" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int W,a,b;
    cin>>W>>a>>b;
    int a2,b2;
    a2=W+a;
    b2=W+b;
    if(a<b) {
        if(a2>=b) cout<<0<<endl;
        else cout<<b-a2<<endl;
    }
    else if(a>b) {
        if(a<=b2) cout<<0<<endl;
        else cout<<a-b2<<endl;
    }
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;


typedef pair<LL, LL> P;

void solve() {
  LL N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  priority_queue<P, vector<P>, greater<P>> que;
  set<LL> s;

  que.push({0, N});
  while (true) {
    auto [coin, v] = que.top(); que.pop();

    if (s.count(v)) continue;
    s.insert(v);

    if (v == 0) {
      cout << coin << endl;
      break;
    } else if (v == 1) {
      cout << coin + D << endl;
      break;
    }

    if (v % 2 == 0) {
      que.push({coin + A, v / 2});
    } else {
      que.push({coin + A + D, (v - 1) / 2});
      que.push({coin + A + D, (v + 1) / 2});
    }

    if (v % 3 == 0) {
      que.push({coin + B, v / 3});
    } else {
      LL r = v % 3;
      que.push({coin + B + r * D, (v - r) / 3});
      que.push({coin + B + (3-r) * D, (v + 3 - r) / 3});
    }

    if (v % 5 == 0) {
      que.push({coin + C, v / 5});
    } else {
      LL r = v % 5;
      que.push({coin + C + r * D, (v - r) / 5});
      que.push({coin + C + (5-r) * D, (v + 5 - r) / 5});
    }

    if (1e18/D > v) {
      // cout << coin + v * D << " " << v*D << " " << coin << endl;
      que.push({coin + v * D, 0});
    }
  }
}

int main() {
  int T; cin >> T;
  for (int i = 0; i < T; ++i) {
    solve();
  }
}


Measured memory_bytes: 4140
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;
with Ada.Float_Text_IO;
use Ada.Float_Text_IO;

procedure main is
	type ar is array(1..10000) of Integer;
	s:String(1..3);
begin
	get(s);
    if s(1)='7' or s(2)='7' or s(3)='7' then
    put_line("Yes");
    else 
   	put_line("No");
    end if;
end Main;

Measured memory_bytes: 3604
let () =
  Scanf.scanf "%d" @@ fun k ->
  let a = Array.init k (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let l, u = Array.fold_right (fun x (l, u) ->
    (l+x-1)/x*x, u/x*x + x-1
  ) a (2, 2) in
  if l > u then print_endline "-1" else Printf.printf "%d %d\n" l u

Measured memory_bytes: 5376
#include<stdio.h>
#include<string.h>
int N,S[200],i,j,k,l,f[35000]={0};

int main()
{
	for(i=0;i<183;i++)
		S[i]=i*i;
	for(i=0;i<183;i++)
		for(j=i;j<183;j++)
			for(k=j;k<183;k++)
				for(l=k;l<183;l++)
					if(S[i]+S[j]+S[k]+S[l]<35000)
						f[S[i]+S[j]+S[k]+S[l]]++;

	for(;scanf("%d",&N),N;)
		printf("%d\n",f[N]);
	return 0;
}

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

int main(){
    string o, e;
    cin >> o >> e;
    string ans;

    rep(i, min(o.size(),e.size())){
        cout << o.at(i) << e.at(i);
    }
    if (o.size() > e.size()){
        cout << o.at(o.size() - 1) << endl;
    }
    if (o.size() < e.size()){
        cout << e.at(e.size() - 1) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define ld long double
#define tc() ll t;cin>>t;while(t--)
#define inp(n) ll n;cin>>(n)
#define inp2(n,m) ll n,m;cin>>(n);cin>>(m)
#define inp3(n,m,g) ll n,m,g;cin>>(n);cin>>(m);cin>>(g)
#define inps(s) string s;cin>>(s)
#define fr(i,n) for(ll i=0;i<n;i++)
#define rf(n,i) for(ll i=n-1;i>=0;i--)
#define vi vector<int >
#define vl vector<ll>
#define vd vector<ld>
#define vs vector<string >
#define pii pair<int,int>
#define pci pair<char ,int>
#define pic pair<int ,char>
#define psi pair<string ,int>
#define mii map<int ,int >
#define mci map<char ,int>
#define msi map<string ,int>
#define si set<int >
#define ss set<string>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007

int main() {
    fast
    
    int n;
    cin>>n;
    
    if(n==1){
        
        cout<<"0"<<endl;
    }
    else{
        
            cout<<"1"<<endl;
    }
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    string s; cin>>s;
    int K; cin>>K;
    int N=s.size();

    string t=s;
    sort(t.begin(),t.end());
    if(t[0]==t[N-1]){
        cout<<N*K/2<<endl;
        return 0;
    }

    if(s[0]!=s[N-1]){
        int ans=0;
        for(int i=0;i<N;){
            int i0=i;
            while(i<N and s[i]==s[i0]) i++;
            ans+=(i-i0)/2;
        }
        ans*=K;
        cout<<ans<<endl;
        return 0;
    }

    int x=0,y=0;
    int l=0,r=N-1;
    int ans=0;
    for(;l<N;l++){
        if(s[l]==s[0]) x++;
        else break;
    }
    for(;r>=0;r--){
        if(s[r]==s[N-1]) y++;
        else break;
    }
    for(int i=l;i<=r;){
        int i0=i;
        while(i<=r and s[i]==s[i0]) i++;
        ans+=(i-i0)/2;
    }
    ans*=K;
    ans+=x/2;
    ans+=(x+y)/2*(K-1);
    ans+=y/2;
    cout<<ans<<endl;
    // cout<<l<<' '<<r<<' '<<x<<' '<<y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn=1e5+111;
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int fi=1,se=m+1;
    while(fi<se){
        printf("%d %d\n",fi,se);
        ++fi,--se;
    }
    fi=m+2,se=(m<<1|1);
    while(fi<se){
        printf("%d %d\n",fi,se);
        ++fi,--se;
    }
    return 0;
}

Measured memory_bytes: 3820
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    int N, time;
    cin>>N;
    vector< pair<int, int> > num;
    rep(i, N){
        cin >>time;
        num.push_back({time, i+1});
    }
    sort(all(num));
    rep(i, N-1){
        cout << num[i].second << " ";
    }
    cout <<num[N-1].second <<endl;
    return 0;
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int mat[3003][3003];
int dp[3003][3003][4];
int n , m , k;

int alpha(int i , int j ,int cnt)
{
	if(i == n && j == m)
	{
		if(cnt < 3)return mat[i][j];
		return 0;
	}
	if(i > n || j > m )return -inf;

	int &abs = dp[i][j][cnt];
	if(abs != -1)return abs;

	int a1 = 0 , a2 = 0 , a3 = 0 , a4 = 0;
	if(cnt < 3)a1 = mat[i][j] + alpha(i+1 , j, 0);
	a4 = alpha(i+1 , j ,0);
	a2 = alpha(i ,j+1 , cnt);
	if(cnt < 3)a3 = mat[i][j] + alpha(i ,j+1,cnt+1);

	return abs = max({a1 , a2 , a3 ,a4});
}

void solve()
{
	cin >> n >> m >> k;

	// mset(mat , -1);
	mset(dp , -1);

	loop(i,0,k)
	{
		int x, y ,val;
		cin >> x >> y >> val;
		mat[x][y] = val;
	}

	int ans = alpha(1,1,0);

	cout << ans;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 356412
<?php
fscanf(STDIN, "%d", $M);
$sumDC = $sumC = 0;
for ($i = 0; $i < $M; $i++) {
    fscanf(STDIN, "%d %d", $d, $c);
    $sumDC += $d * $c;
    $sumC += $c;
}
echo intdiv($sumDC - 1, 9) + $sumC - 1;


Measured memory_bytes: 4604
import sys
input = sys.stdin.readline

import heapq

n,h = map(int, input().split())

pq = []
amax = 0

for i in range(n):
    a,b = map(int, input().split())
    heapq.heappush(pq, -b)
    if a > amax:
        amax = a

heapq.heappush(pq, -amax)

d = 0
dtotal = 0
ans = 0

while dtotal > -h:
    d = heapq.heappop(pq)
    dtotal += d
    ans += 1
    if d == -amax:
        break
if -dtotal < h:
    if (h+dtotal)%amax == 0:
        ans += (h+dtotal)//amax
    else:
        ans += 1 + (h+dtotal)//amax

print(ans)

Measured memory_bytes: 7116
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> a;
  tools::read(a, N);

  std::cout << (std::all_of(a.begin(), a.end(), [](const i64& a_i) { return a_i % 2 == 0; }) ? "second" : "first") << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define f(i,s,v) for(int i=(int)s;i<(int)v;++i)
#define rf(i,s,v) for(int i=(int)s-1;i>(int)v;--i)
#define pb push_back
#define all(v) ((v.begin()),(v.end()))
#define memset(c, value) memset(c, (int)value, sizeof(c))
using namespace std;
typedef long long ll;
const ll oo = 1e18;
const ll MOD =1e9+7;
const double pi = acos(-1);
void fast(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n, m;
bool valid (int r,int c){
    return (r < n && r >= 0 && c >= 0 && c < m);
}

int row[] = {0 , 1 , 0, -1};
int column[] = {1 , 0, -1, 0};

vector<string>v(100002);
ll a[100002];
ll vis[100002][2];

int maxi = 100001;
ll dp[101][100001];

int main()
{
    fast();

    ll c;
    cin>>n>>c;
    int v[n], w[n];

    f(i, 0, n){
        cin>>w[i]>>v[i];
    }

    f(i, 0, n){
        f(j, 0, maxi){
            dp[i][j] = oo;
        }
    }
    f(i, 0, n) dp[i][v[i]] = w[i];

    f(i, 1, n){
        f(j, 0, maxi){
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if(j >= v[i]){
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
            }
        }
    }
    int m = 0;
    f(i, 0, maxi)
        if(dp[n-1][i] <= c)
            m = i;
    cout<<m<<'\n';



    return 0;
}


Measured memory_bytes: 84504
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	long long n,ans=0;
	cin>>n;
	for (long long i=1;i<=n;i++){
		if (i%3!=0 && i%5!=0){
			ans+=i;
		}
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}



int main(){
    char b;
    cin >> b;
    
    if(b=='A')cout << 'T' << endl;
    else if(b=='T')cout << 'A' << endl;
    else if(b == 'C') cout << 'G' << endl;
    else cout << 'C' << endl;     
     
    return 0;

}



Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1);
    return 0;
}

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

int main() {
    string S;
    cin>>S;
    int s0=int(S.at(0))-48;
    int s1=int(S.at(1))-48;
    int s2=int(S.at(2))-48;
    int s3=int(S.at(3))-48;
    int a=10*s0+s1;
    int b=10*s2+s3;
    if((1<=a&&a<=12)&&(1<=b&&b<=12)){
        cout<<"AMBIGUOUS"<<endl;
    }else if((1<=a&&a<=12)&&!(1<=b&&b<=12)){
        cout<<"MMYY"<<endl;
    }else if(!(1<=a&&a<=12)&&(1<=b&&b<=12)){
        cout<<"YYMM"<<endl;
    }else{
        cout<<"NA"<<endl;
    }
return 0;}
/*
g++ code.cpp
./a.out
*/

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


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum[] = new long[n];
        sum[0] = sc.nextLong();
        for (int i = 1; i < n; i++) {
            sum[i] = sum[i - 1] + sc.nextLong();
        }
        long min = 10000000000l;
        for (int i = 0; i < n - 1; i++) {
            min = Math.min(min, Math.abs(sum[n - 1] - 2 * sum[i]));
        }
        System.out.println(min);
    }
}

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

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  for(int i=0; i<s.size(); i++){
    if(s[i] == 'o'){
      cnt++;
    }
  }
  if(8-cnt <= 15 - s.size()){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};

struct edge {
    ll to, cost;
};


void dijkstra(int s, vector<vector<edge>> G, vector<ll>& d) {
    priority_queue<LP, vector<LP>, greater<LP>> que; //first:最短距離, second:頂点番号
    d[s] = 0;
    que.push(LP(0,s));

    while (!que.empty()) {
        LP p = que.top(); que.pop(); //距離最小のものを取り出す
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(i, sz(G[v])) { //頂点vから伸びる点を見る
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(LP(d[e.to], e.to));
            }
        }
    }
}

ll money = 1000000000000000;

int main() {
    int n,m,s,t;
    cin >> n >> m >> s >> t;
    s--; t--;
    vector<ll> ds(n,LINF), dt(n,LINF);
    vector<vector<edge>> Gs(n);
    vector<vector<edge>> Gt(n);

    rep(i,m) {
        ll j,k,l,o;
        cin >> j >> k >> l >> o;
        j--; k--;
        edge e1, e2,e3,e4;
        e1.to = k; e1.cost = l;
        e2.to = k; e2.cost = o;
        e3.to = j; e3.cost = l;
        e4.to = j; e4.cost = o;
        Gs[j].push_back(e1);
        Gs[k].push_back(e3);
        Gt[j].push_back(e2);
        Gt[k].push_back(e4);
    }

    dijkstra(s, Gs, ds);
    dijkstra(t, Gt, dt);
    //ds,dtが更新できていない・・・

    priority_queue<LP, vector<LP>, greater<LP>> q;
    rep(i,n) {
        q.push(LP(ds[i]+dt[i],i)); //支払うお金と両替する頂点番号
    }

    LP p = q.top(); q.pop();
    rep(i,n) { //i年後
        while (p.second < i) { //もしもう両替できないなら
            p = q.top(); q.pop();
        }
        cout << money - p.first << endl;
    }
} 

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

int main() {
	int c[26] = {}, offset = 'a' - 'A';
	char n;
	while (scanf("%c", &n)!= -1) {
		if ('z' >= n&&n >= 'a') n -= offset;
		if ('Z' >= n && n >= 'A') c[n - 'A']++;
	}
	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n", 'a' + i, c[i]);
	}
	return 0;
}



Measured memory_bytes: 2668
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#define ll 	 long long
#define pb push_back
#define mp make_pair
using namespace std;

int main() 
{ 

int n; cin>>n;
string x; cin>>x;

for(int i=0; i<x.size(); i++)
{
	x[i]+= n;
	
if(x[i]-'A'>=26) x[i]-=26;
	
	cout<<x[i];
}


    return 0;
} 


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a > 0) cout << "Positive" << '\n';
  else if (b < 0) {
    if (abs(b - a + 1) % 2 == 0) cout << "Positive" << '\n';
    else cout << "Negative" << '\n';
  }
  else cout << "Zero" << '\n';
}


Measured memory_bytes: 3572
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			printf("\n")
#define nl			cout<<'\n'
#define sf(N)       scanf("%lld",&N)
#define pf(N)       printf("%lld",N)
#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup erase(unique(V.begin(),V.end()),V.end())

#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli N,K;
    cin>>N>>K;
    
    map<lli,lli>M;
    map<lli,lli> :: itr it;
    
    while(N--)
    {
        lli x,y;
        cin>>x>>y;
        
        M[x]+=y;
    }
    
    lli Store;
    for(it=M.begin();it!=M.end();it++)
    {
        if(K<=0)
        {
            break;
        }
        
        Store=it->F;
        K-=it->S;
    }
    
    cout<<Store;    
    
    
    
    



 return 0;
}


Measured memory_bytes: 4224
N,K = map(int, input().split())

h = []

for n in range(N):
    h.append(int(input()))

h.sort(reverse=True)

ans = 1000000000 
for i in range(N-K+1):
    if h[i]-h[i+K-1] < ans:
        ans = h[i]-h[i+K-1]

print(ans)

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


int main()
{
    int n;
    std::cin>>n;
    std::string s;
    std::cin>>s;
    std::vector<std::pair<int,int>> p(n); //first : 自分より左でWの人数 / second : 自分より右でE人数
    int cnt = 0;
    for(int i=1;i<n;i++){
        if(s[i] == 'E')cnt++;
    }
    p[0] = {0,cnt};
    for(int i=1;i<n;i++){
        std::pair<int,int> last = p[i-1];
        if(s[i-1] == 'W')last.first++;
        if(s[i] == 'E')last.second--;
        p[i] = last;
    }
    int ans = 10000000;
    for(int i=0;i<n;i++){
        ans = std::min(ans,p[i].first + p[i].second); 
    }
    std::cout<<ans<<std::endl;

    
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  int n, k, q;
  cin >> n >> k >> q;
  vi32 a(n);
  cin >> a;
  int ans = INF;
  rep(i, n) {
    vi32 use(n);
    rep(j, n) if (a[j] >= a[i]) use[j] = 1;
    int id = 0;
    vi32 cnt;
    using T = tuple<int, int>;  // value, group id
    pqasc<T> que;
    rep(j, n) {
      if (!use[j]) continue;
      int l = j;
      while (j < n && use[j]) j++;
      int r = j;
      repi(k, l, r) {
        que.emplace(a[k], id);
      }
      cnt.push_back(r - l);
      id += 1;
    }
    int mi = 0;
    int c = 0;
    while (sz(que)) {
      int val, id;
      tie(val, id) = que.top();
      que.pop();
      if (cnt[id] < k) continue;
      c += 1;
      amax(mi, val);
      cnt[id]--;
      if (c == q) break;
    }
    if (c < q) continue;
    amin(ans, mi - a[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll gcd(ll a, ll b)
{
  if (!b)
    return a;
  return gcd(b, a % b);
}
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x %= p;
  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
ll po(ll base, ll powerRaised)
{
  if (powerRaised != 0)
    return (base * po(base, powerRaised - 1));
  else
    return 1;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll h, n;
  cin >> h >> n;
  ll a[n + 1], b[n + 1];
  for (int i = 1; i <= n; i++)
    cin >> a[i] >> b[i];
  ll ans[h + 1];
  ll dp[h + 1][n + 1];
  for (int i = 1; i <= h; i++)
  {
    for (int j = 1; j <= n; j++)
    {
      if (i - a[j] <= 0)
        dp[i][j] = b[j];
      else
        dp[i][j] = b[j] + ans[i - a[j]];
    }
    ll res = INT_MAX;
    for (int k = 1; k <= n; k++)
      res = min(res, dp[i][k]);
    ans[i] = res;
  }
  cout << ans[h];

  // cout << cnt;
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}

Measured memory_bytes: 78592
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;


int main()
{
    int w,s;
    cin>>s>>w;
    if (w>=s) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}



Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int c = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        scan.close();

        if (k <= a) {
            System.out.println(k);
        } else if (k <= a + b) {
            System.out.println(a);
        } else {
            System.out.println(a - (k - a - b));
        }

    }
}


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

int main() {
  int N, count = 0;
  string S;
  cin >>  S;

  for(int i = 0; i < S.size(); i++){
      if(S.at(i) == 'D' || S.at(i) == '?'){
          cout << 'D';
      }
      else if(S.at(i) == 'P'){
          cout << 'P';
      }
  }
  cout << endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int k,s,ans;
int main()
{
    cin>>k>>s;
    for(int x=0;x<=k;x++)
    {
        for(int y=0;y<=k;y++)
        {
            if(s-x-y>=0&&s-x-y<=k)
			ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <memory.h>
using namespace std;

const int N = 305;

int C[N][N];

const int MOD = 1000 * 1000 * 1000 + 7;

typedef long long llong;

inline int add(int x, int y) {
    return (x + y) % MOD;
}

inline int mul(int a, int b) {
    return (((llong)a) * b) % MOD;
}

llong D[N][N];
llong pD[N][N];

void init() {
    for (int n = 0; n < N; n++) {
        C[n][0] = C[n][n] = 1;
        for (int k = 1; k < n; k++)
            C[n][k] = add(C[n - 1][k - 1], C[n - 1][k]);
    }
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    init();
    D[1][1] = 1;
    for (int i = 1; i < m; i++) {
        memcpy(pD, D, sizeof(D));
        for (int b = 0; b <= n; b++)
            for (int a = b; a <= n; a++)
                D[b][a] = 0;
        for (int b = 1; b <= n; b++) {
            for (int a = b; a <= n; a++) {
                int val = pD[b][a];
                if (a + 1 <= n)
                    D[b + 1][a + 1] = add(D[b + 1][a + 1], mul(val, n - a));
                if (a + 1 <= n)
                    D[b][a + 1] = add(D[b][a + 1], mul(val, n - a));
                if (b >= 2)
                    D[b - 1][a] = add(D[b - 1][a], mul(val, b));

                D[b][a] = add(D[b][a], mul(val, b));
            }
        }
    }
    int ans = D[1][n];
    printf("%d\n", ans);
}


Measured memory_bytes: 1920
/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL; 
typedef long double LD;
const int INF=1e4;
const int MAX=2e3+5;
int a[MAX];
int b[MAX];
int toR[MAX];
int toL[MAX];
pair<int,int> c[MAX];

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

	for(int i=0;i<s.length();i++)
	{
		a[i]=(s[i]=='1');
	}

	cin>>s;
	
	for(int i=0;i<s.length();i++)
	{
		b[i]=(s[i]=='1');
	}	
	bool allz=true;
	bool alleq=true;
	for(int i=0;i<n;i++)
	{
		allz&=(b[i]==0);
		alleq&=(a[i]==b[i]);
	}
	if(alleq)
	{
		printf("0\n");
		return 0;
	}
	if(allz)
	{
		printf("-1\n");
		return 0;
	}
	toR[n]=INF;
	for(int i=n-1;i>=0;i--)
	{
		toR[i]=toR[i+1];
		if(b[i]==1)
		{
			toR[i]=i;
		}
	}
	for(int i=n-1;i>=0;i--)
	{
		if(toR[i]!=INF)
		{
			break;
		}
		else
		{
			toR[i]=n+toR[0];
		}
	}
	toL[0]=INF;
	if(b[0]==1)
	{
		toL[0]=0;
	}
	for(int i=1;i<n;i++)
	{
		toL[i]=toL[i-1];
		if(b[i]==1)
		{
			toL[i]=i;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(toL[i]!=INF)
		{
			break;
		}
		else
		{
			toL[i]=toL[n-1]-n;
		}
	}
	int ans=1e6;
	for(int sh=-n;sh<=n;sh++)
	{
		int res=abs(sh);
		int m=0;
		for(int i=0;i<n;i++)
		{
			int q=(i+sh+n)%n;
			if(a[i]==b[q])
			{
				continue;
			}
			res++;
			if(sh<=0)
			{
				if((i-toL[i])<=(-sh))
				{
					continue;
				}
				c[m].first=toR[i]-i;
				c[m].second=q-toL[q];
				m++;
			}
			else
			{
				if((toR[i]-i)<=sh)
				{
					continue;
				}
				c[m].first=i-toL[i];
				c[m].second=toR[q]-q;
				m++;
			}
		}
		c[m++]=make_pair(0,0);
		sort(c,c+m);
		int bst=c[m-1].first;
		int mx=0;
		for(int i=m-1;i>0;i--)
		{
			mx=max(mx,c[i].second);
			bst=min(bst,c[i-1].first+mx);
		}
		ans=min(ans,res+2*bst);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    int mx1 = 0;
    rep(i, n) if(a[mx1] < a[i]) mx1 = i;
    int mx2 = mx1 == 0 ? 1 : 0;
    rep(i, n) if(i != mx1 && a[mx2] < a[i]) mx2 = i;
    rep(i, n) {
        if(i == mx1) {
            cout << a[mx2] << endl;
        } else {
            cout << a[mx1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  map<string,int> mp;
  int n;
  cin >> n;
  string s[n];
  rep(i,n)cin >> s[i];
  rep(i,n){
    mp[s[i]]++;
  }
  int mx = 0;
  for(auto p:mp){
    chmax(mx,p.second);
  }
  for(auto p:mp){
    if(p.second==mx)cout << p.first << endl;
  }
  return 0;
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;

int main(){
    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    for(int i= 0; i< n; i++){
        cin >> a.at(i);
    }
   
   sort(a.begin(),a.end());
   for(int i = 0; i<n; i++){
       h -=a.at(i);
       if(h<=0){
           cout << "Yes" << endl;
           return 0;
       }
   }
   cout << "No" << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define ROF(i,a,b) for (int i = (b-1); i >= a; --i)
#define REP(i,a,b) for (int i = a; i <= b; ++i)
#define PER(i,a,b) for (int i = b; i >= a; --i)
#define F0R(i,b) FOR(i,0,b)
#define R0F(i,b) ROF(i,0,b)
#define R1P(i,b) REP(i,1,b)
#define P1R(i,b) PER(i,1,b)
using namespace std;

int n, a[200];
char s[201];
int x[63];

void solve() {
	int n;
	cin >> n;
	F0R(i,n) cin >> a[i];
	cin >> s;
	memset(x, 0, sizeof(x));
	R0F(i,n) {
		if (s[i] == '0') {
			R0F(j, 63) if (a[i] & (1ll<<j)) {
				if (!x[j]) { x[j] = a[i]; break; }
				a[i] ^= x[j];
			}
		} else {
			R0F(j, 63) if (a[i] & (1ll<<j)) a[i] ^= x[j];
			if (a[i]) { puts("1"); return; }
		}
	}
	puts("0");
}

signed main() {
	int t;
	cin >> t;
	while (t--) solve();
}


Measured memory_bytes: 3408
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int a, b, c;
	cin >> a >> b >> c;

	cout << min(b / a, c) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long n = Long.parseLong(scn.next());
		scn.close();

		double value = Math.sqrt(n);

		long i = (long) value;
		for (; i >= 1; i--) {
			if (n % i == 0) {
				System.out.println((long) (Math.log10(n / i) + 1));
				return;
			}
		}

	}
}


Measured memory_bytes: 23764
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int main() {
    string s; int w;
    cin >> s >> w;
    string t;
    for (int i = 0; w * i < (int) s.size(); i ++) {
        t += string(1, s[w*i]);
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 100005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
#define endl "\n"
#define mid  (l + r + 1)/2
#define s3   1.73205080757
const int inf = (int)1e18 + 10;


signed main(){
  fast;
  
  int n  , ans;
  double t , a;
  cin >> n >> t >> a;
  double x , y , diff , mindiff = 1000000;
  for(int i = 1 ; i<= n ; i++){
  	    cin >> x;
  	    y = t - x *(0.006) ;
  	    diff = abs(a - y);
  	    if(diff < mindiff)
  	      mindiff = diff , ans = i;
  }
  cout << ans << endl;



  

}	


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int trout = sc.nextInt();
		int[] Line1 = new int[trout];
		int[] Line2 = new int[trout];
		for(int i = 0; i < trout; i++){
			Line1[i] = sc.nextInt();
		}
		for(int i = 0; i < trout; i++){
			Line2[i] = sc.nextInt();
		}
		int Result = 0;
		for(int i = 0; i < trout; i++){
			int total = 0;
            for(int j = 0; j <= i; j++){
				total += Line1[j];
			}
			for(int j = i; j < trout; j++){
				total += Line2[j];
			}
			if(Result < total){
				Result = total;
			}
		}
		System.out.println(Result);
		sc.close();
	}
}



Measured memory_bytes: 23764
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a,b] <- getIntList
    putStrLn $ if odd (a*b) then "Yes" else "No"

Measured memory_bytes: 380