akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt() 
    val w = readListOfInt()
    var i = 1 
    var ans = Math.abs(w.slice(0 until 1).sum() - w.slice(1 until n).sum())
    while(i < n) {
        val tmp = Math.abs(w.slice(0 until i).sum() - w.slice(i until n).sum()) 
        if(ans > tmp) {
            ans = tmp
        }
        i++
    }
    println(ans)
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 35984
#include <iostream>
#include <algorithm>
using namespace std;
int a[201];
int main()
{
	int n,g=0;
	cin>>n;
	n*=2;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i+=2)
		g+=a[i];
	cout<<g<<endl;
	return 0;
}

Measured memory_bytes: 256
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int a,b,k;cin>>a>>b>>k;

  int i = 1;
  vi res;
  rep(i, 1, 101){
    if (a%i==0 and b%i==0) {
      res.pb(i);
    }
  }
  dump(res);
  cout << res[sz(res)-k] << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
// ~/SolverToBe/Developers/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <assert.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 100005, M = 1000005;
const ll MOD = 1e9 + 7;
const double eps = 1e-9;

int n,k,h[N],dp[N];

int main() {
    scanf("%d%d",&n,&k);
    for(int i=0; i<n; i++)
    scanf("%d",h+i);
    dp[n-1] = 0;
    for(int i=n-2; i>=0; i--) {
        dp[i] = 2e9;
        for(int j=1; j<=k && i+j<n; j++)
            dp[i] = min(dp[i], dp[i+j] + abs(h[i]-h[i+j]));
    }
    printf("%d\n", dp[0]);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#define Find order_of_key
#define at find_by_order
#define x first
#define y second
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'

ll arr[15][15],val[15],n,m,x;

int main()
{
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>val[i];
		for(int j=0;j<m;j++)cin>>arr[i][j];
	}

	ll mi=1000000000000000000LL;
	for(int v=0;v<(1<<n);v++){
		ll va[15]={0};
		ll cc=0;
		for(int i=0;i<n;i++){
			if(v&(1<<i)){
				cc+=val[i];
				for(int j=0;j<m;j++){
					va[j]+=arr[i][j];
				}
			}
		}
		bool f=1;
		for(int i=0;i<m;i++)if(va[i]<x)f=0;
		if(f){
			mi=min(mi,cc);
		}
	}
	if(mi!=1000000000000000000LL)cout<<mi<<endl;
	else cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 3676
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.next().split("");

        Arrays.sort(str);
        String key = "";
        for (String s : str) {
            key += s;
        }

        String result = "No";
        if (key.contains("abc")) result = "Yes";
        System.out.println(result);
    }
}


Measured memory_bytes: 39392
S = input()
N = len(S)
for i in range(N - 2):
    if S[i] == S[i + 1]:
        print(i + 1, i + 2)
        exit()
    elif S[i] == S[i + 2]:
        print(i + 1, i + 3)
        exit()
if S[N - 2] == S[N - 1]:
    print(N - 1, N)
else:
    print(-1, -1)


Measured memory_bytes: 3188
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
post=0
for i in range(N):
    if B[i]-A[i]>0:
        count +=A[i]
        if A[i+1]-(B[i]-A[i])<=0:
            count+=A[i+1]
            A[i+1]=0
        else:
            A[i + 1] -= B[i] - A[i]
            count+=B[i] - A[i]
    else:
        count += B[i]
print(count)



Measured memory_bytes: 19156
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(ll num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(ll i = 3; i <= sqrtNum; i += 2){
        if(num%i==0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}


using Edge = PII;
using Graph = vector<vector<Edge> >;

int n;
Graph g;
VI res;

void dfs(int v, int p, int c){
  res[v] = c;
  for(auto e : g[v]){
    if(e.first == p) continue;
    if(e.second & 1) dfs(e.first, v, 1-c);
    else dfs(e.first, v, c);
  }
}


signed main(){
  cin>>n;
  g.assign(n, vector<Edge>());
  rep(i,n-1){
    int u,v,w; cin>>u>>v>>w; u--;v--;
    g[u].PB(Edge(v,w)); g[v].PB(Edge(u,w));
  }
  res.assign(n,0);
  dfs(0,-1,1);
  for(auto v : res) cout << v << endl;

  return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

vector<ll> a, p;

ll solve(ll n, ll x) {
  if (n == 0) return (x <= 0 ? 0 : 1);
  else if (x <= 1 + a[n-1])
    return solve(n-1, x-1);
  else
    return p[n-1] + 1 + solve(n-1, x-2-a[n-1]);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  ll n, x; std::cin >> n >> x;
  a.resize(n), p.resize(n);
  a[0] = 1, p[0] = 1;
  rep(i, n-1) a[i+1] = a[i] * 2 + 3, p[i+1] = p[i] * 2 + 1;
  cout << solve(n, x) << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>

//#include <map>

using namespace std;

int main()
{
	string s, p;
	getline(cin, s);
	getline(cin, p);

	s += s;

	if (s.find(p) != string::npos)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

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


Measured memory_bytes: 3096
n = int(input())

dp = [1000000 for _ in range(n+1)]
dp[0] = 0

for i in range(0,n):
  if i+1 <= n:
    dp[i+1] = min(dp[i+1], dp[i] + 1)
  for j in range(1,7):
    a = 6**j
    if i+a <= n:
      dp[i+a] = min(dp[i+a], dp[i] + 1)
  for k in range(1,6):
    a = 9**k
    if i+a <= n:
      dp[i+a] = min(dp[i+a], dp[i] + 1)

print(dp[n])

Measured memory_bytes: 9692
N,K = map(int,input().split())
A = [0] + list(map(int,input().split()))
turn = [-1] * (N+1) # いつ訪問したかを記録する
c = 1
for k in range(K):
    if turn[c]!=-1:
        T = k - turn[c] # 周期
        bias = turn[c] # バイアス
        break
    turn[c] = k
    c = A[c]
else:
    print (c)
    exit()

K -= bias # Kを減らしてリスタート
K %= T
K += bias
c = 1 
for k in range(K):
    c = A[c]
print (c)


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

int main(){
  int count = 6;
  string coffee;
  cin >> coffee;

  if(coffee.at(2) == coffee.at(3) && coffee.at(4) == coffee.at(5)){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int dp[12][8][2];

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

  int n = s.size();
  fill(dp[0][0], dp[11][0], 0);
  dp[0][0][1] = 1;
  const string x = "753";
  rep(i,n){
    rep(mask,8)rep(just,2){
      rep(k,3) if(!just || s[i]>=x[k]) if(dp[i][mask][just] > 0){
        dp[i+1][mask | (1<<k)][just && (s[i]==x[k])] += dp[i][mask][just];
      }
    }
    if(i > 0) rep(k,3) dp[i+1][1<<k][0]++;
  }

  cout << dp[n][7][0] + dp[n][7][1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//DPかな、1個目をとるかどうか、2個目をとるかどうか。
//Wで管理はできないか
//全探索は2^100でむり
//重さが最初のやつの3以下までって変な条件
//重さは4種類しかない
//同じ重さなら価値の高いものからとっていく
//全探索か 最大25^4でいける
//0,1,2,3の重さのやつをDFSで再帰でいけたら超スムーズか。やってみたい
//3のやつをとれるだけとる
//3を1個へらし、2をとれるだけとるみたいな
//forを4つでいいか･･･。むずくてかけん。
//これはこれで重さの管理がむずい、毎回引くのはだめだな
//最後に重さでいいか
//累積和でとっておいたほうがいいか
int main(){
  ll N,W; cin>>N>>W;
  vector<ll> zr,on,tw,th;
  ll w,v; cin>>w>>v;
  zr.emplace_back(v);
  for(int i=1; i<N; i++){
    ll x,y; cin>>x>>y;
    if(w-x==0) zr.emplace_back(y);
    else if(x-w==1) on.emplace_back(y);
    else if(x-w==2) tw.emplace_back(y);
    else if(x-w==3) th.emplace_back(y);
  }
  sort(zr.begin(), zr.end(), greater<ll>());
  sort(on.begin(), on.end(), greater<ll>());
  sort(tw.begin(), tw.end(), greater<ll>());
  sort(th.begin(), th.end(), greater<ll>());
  ll zrsz=zr.size(), onsz=on.size(), twsz=tw.size(), thsz=th.size();
  for(int i=0; i<zrsz-1; i++) zr[i+1]+=zr[i];
  for(int j=0; j<onsz-1; j++) on[j+1]+=on[j];
  for(int k=0; k<twsz-1; k++) tw[k+1]+=tw[k];
  for(int n=0; n<thsz-1; n++) th[n+1]+=th[n];
  ll ans=0;
  for(int i=0; i<=zrsz; i++){
    for(int j=0; j<=onsz; j++){
      for(int k=0; k<=twsz; k++){
        for(int n=0; n<=thsz; n++){
          ll we=i*w+j*(w+1)+k*(w+2)+n*(w+3);
          if(we<=W){
            ll en=0;
            if(i>0) en+=zr[i-1];
            if(j>0) en+=on[j-1];
            if(k>0) en+=tw[k-1];
            if(n>0) en+=th[n-1];
            ans=max(ans,en);
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>

int main()
{
	std::ios_base::sync_with_stdio(false);
	int n;
	std::cin >> n;
	int min_val = std::numeric_limits<int>::max();
	int cc = 0;
	for (int i = 0; i < n; i++)
	{
		int cur;
		std::cin >> cur;
		if (cur <= min_val)
		{
			cc++;
			min_val = cur;
		}
	}
	std::cout << cc << std::endl;
	return 0;
}

Measured memory_bytes: 384
# ABC158 A
s=input()

if s.count('A')==3 or s.count('B')==3:
    print('No')
else:
    print('Yes')
# if s[0]=='A' and s[2]=='A':
#     print('Yes')
# elif s[0]=='B' and s[2]=='B':
#     print('No')

Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double L = 6378.1;
const double PI = acos(-1.0);

void solve(double n0, double e0, double& x, double& y, double& z)
{
    double n = n0 / 180 * PI;
    double e = e0 / 180 * PI;

    x = cos(n) * cos(e);
    y = cos(n) * sin(e);
    z = sin(n);
}

int main()
{
    for(;;){
        double a, b, c, d;
        cin >> a >> b >> c >> d;
        if(b < -0.5)
            return 0;

        double x1, y1, z1, x2, y2, z2;
        solve(a, b, x1, y1, z1);
        solve(c, d, x2, y2, z2);

        double dist = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2) + pow(z1-z2, 2));
        double theta = asin(dist / 2) * 2;

        int ret = (int)(L * theta + 0.5);
        cout << ret << endl;
    }
}

Measured memory_bytes: 1276
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cctype>
using namespace std;


int main(){
    string o,e;
    cin>>o>>e;
    int i;
    for(i=0;i<e.size();i++){
        printf("%c%c",o[i],e[i]);
    }
    if(i<o.size()) printf("%c",o[i]);
    cout <<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	double Max = 0;
	int W = 0, S = 0;
	for (int i = 0; 100*A*i <= F; i++) {
		for (int j = 0; 100 * (A*i + B*j) <= F; j++) {
			if (i == 0 && j == 0) continue;
			int max_sugar = min((A*i + B*j)*E, F - 100 * (A*i + B*j));
			for (int k = 0; C*k <= max_sugar; k++) {
				for (int l = 0; D*l <= max_sugar - C*k; l++) {
					double water = 100 * (A*i + B*j);
					double sugar = C*k + D*l;
					if (100 * sugar / (water + sugar) >= Max) {
						W = water;
						S = sugar;
						Max = 100 * sugar / (water + sugar);
					}
				}
			}
		}
	}
	cout << (W + S) << " " << S << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;
use std::collections::*;

pub fn read_from<T: FromStr, R: Read>(s: &mut R) -> T {
    let s = s.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if !s.is_empty() {
        if let Ok(s) = s.parse::<T>() {
            s
        } else {
            panic!("faild to parse {}", s);
        }
    } else {
        if cfg!(local) {
            // eprintln!("reached to EOF");
        }
        std::process::exit(0)
    }
}

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    read_from(&mut stdin)
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let ans = if a * b % 2 == 1 { "Yes" } else { "No" };
    println!("{}", ans);
}


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


void solve(std::string S, std::string T){
    cout << T << S << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
n=int(input())

a = 0
for i in range(n):
    li = input().split()
    if(li[0]==li[1]):
        a+=1
    elif(a<3):
        a=0
    else:
        print("Yes")
        exit()
if(a>2):
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 62160
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define rep(i,n) for(int i=0;i<n;i++) 
#define pi pair<int,int> 
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
long long dp[100010];
const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int ans=0,i=0;
  bool two=0;
  while(i<n){
    if(two){
      ans++; two=0; i++;
    }
    else{
      if(s[i]==s[i+1]){
        ans++; two=1; i+=2;
      }
      else{
        ans++; i++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
long long s=0,n,m,i,j,k,d[3][110],r[3][110],rr[3][110],c[110][110][110],b;
int main(){
	scanf("%d %d",&n,&m);
	for(i=0;i<n*2;i++){
		for(j=0;j<3;j++){
			scanf("%d",&d[j][i]);
			for(k=i;k&&d[j][r[j][k-1]]>d[j][i];k--)r[j][k]=r[j][k-1];
			r[j][k]=i;
		}
	}
	for(i=0;i<n*2;i++){
		for(j=0;j<3;j++)rr[j][r[j][i]]=i;
	}
	for(i=0;i<n;i++){
		for(j=0;j<8;j++){
			b=0;
			for(k=j;k;k/=2)b+=k%2;
			c[rr[0][i*2+(j/1%2)]][rr[1][i*2+(j/2%2)]][rr[2][i*2+(j/4%2)]]=1-(b%2*2);
		}
	}
	for(i=0;i<n*2;i++){
		for(j=0;j<n*2;j++){
			for(k=0;k<n*2;k++)c[i][j][k+1]+=c[i][j][k];
		}
	}
	for(i=0;i<n*2;i++){
		for(j=0;j<n*2;j++){
			for(k=0;k<n*2;k++)c[i][k+1][j]+=c[i][k][j];
		}
	}
	for(i=0;i<n*2;i++){
		for(j=0;j<n*2;j++){
			for(k=0;k<n*2;k++)c[k+1][i][j]+=c[k][i][j];
		}
	}
	for(i=0;i<n*2;i++){
		for(j=0;j<n*2;j++){
			for(k=0;k<n*2;k++){
				if(c[i][j][k]>=m)s+=(d[0][r[0][i+1]]-d[0][r[0][i]])
						   *(d[1][r[1][j+1]]-d[1][r[1][j]])
						   *(d[2][r[2][k+1]]-d[2][r[2][k]]);
			}
		}
	}
	printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 11896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = 0;
	rep(i, n){
		ans += i+1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3 5
0 0 1
0 1 2
0 2 3
1 0 2
1 1 2

output:
1
2
"""

import math
import sys


class SegmentTree(object):
    __slots__ = ('dat', 'tree_range')

    def __init__(self, n):
        """
        Init a SegmentTree with update and find for range minimum queries.
        """
        self.tree_range = pow(2, math.ceil(math.log2(n)))
        self.dat = [float('inf')] * (2 * self.tree_range - 1)

    # let A[k]=a
    def update(self, k, a):
        k += self.tree_range - 1
        self.dat[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2])

    # get min(A[s] A[s+1] ... A[t])
    def find(self, s, t, k=0, left=0, right=float('inf')):
        if right <= s or t <= left:
            return float('inf')
        elif s <= left <= right <= t:
            return self.dat[k]
        else:
            vl = self.find(s, t, k * 2 + 1, left, (left + right) // 2)
            vr = self.find(s, t, k * 2 + 2, (left + right) // 2, right)
            return min(vl, vr)


def cmd_exec(cmd_list, n_num):
    case = SegmentTree(n_num)
    end = pow(2, math.ceil(math.log2(n_num)))
    init_max = pow(2, 31) - 1

    for query in cmd_list:
        cmd, ele_1, ele_2 = map(int, query)
        if cmd == 0:
            case.update(ele_1, ele_2)
        elif cmd == 1:
            assert ele_1 <= ele_2
            res = case.find(s=ele_1, t=ele_2 + 1, right=end)
            print(res) if not math.isinf(res) else print(init_max)

    return None


def solve():
    _input = sys.stdin.readlines()
    n_num, q_num = map(int, _input[0].split())
    q_list = map(lambda x: x.split(), _input[1:])

    cmd_exec(q_list, n_num)
    return None


if __name__ == '__main__':
    solve()

Measured memory_bytes: 19720
n,k=gets.split.map(&:to_i)
dp=[1]*n
k.times{dp[gets.to_i-1]=0}

1.upto(n-1) do |i|
    next if dp[i]==0
    b = dp[i-1]
    bb= dp[i-2]

    dp[i]=b+bb
end

p dp[n-1]%(10**9+7)


Measured memory_bytes: 445148
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long N;cin>>N;
    vector<long long>A(N);
    for(long long i=0;i<N;i++){
        cin>>A[i];
    }
    long long ans,tmp;ans=tmp=0;
    for(long long i=0;i<N;i++){
        tmp=0;
        while(A[i]%2==0){
            A[i]/=2;
            tmp++;
        }
        ans+=tmp;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


struct UnionFind {
	vector<int> par, rank, cnt;
	UnionFind(int n) : par(n), rank(n, 0), cnt(n, 1){
		for(int i = 0; i < n; ++i) par[i] = i;
	}
 
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
 
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
 
		if (rank[x] < rank[y]) swap(x, y);
 
		par[y] = x;
		cnt[x] += cnt[y];
		if (rank[x] == rank[y]) rank[x]++;
	}
 
	bool same(int x, int y) {
		return find(x) == find(y);
	}
 
	int size(int x) {
		return cnt[find(x)];
	}
};



int main(){
    int N, M; cin >> N >> M;
    vector<int> a(M), b(M);
    for (int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    int ans = 0;
    //cout << ans << endl;
    for (int i = 0; i < M; i++){
        int point = i;
        UnionFind uf(N);
        for (int j = 0; j < M; j++){
            if (j == point){
                continue;
            }
            uf.unite(a[j], b[j]);
        }
        if (uf.size(0) < N) ans++;
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    val (x, a, b) = s.split(" ").map(String::toInt)

    // 賞味期限を0日とすると、買ったのは-a日、食べたのはb-a日。食べても大丈夫なのはx日まで。
    val result = when {
        b - a <= 0 -> "delicious"
        b - a <= x -> "safe"
        else -> "dangerous"
    }
    println(result)
}


Measured memory_bytes: 37620
#include <bits/stdc++.h>
#include <algorithm>
#include <limits>
#include <cmath> 
using namespace std;

int main(){
    int n,m,x,ans=100;
    cin>>n>>m>>x;
    int a[m];
    int s=0,t=0;
    for(int i=0;i<m;i++){
        cin>>a[i];
        if(a[i]>x)s++;
        else t++;
    }
    ans=min(ans,min(s,t));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
 
#define int long long
 
#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()
 
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846//20 decimals
#define MOD 1000000007

int32_t main(){
 
   
     IOS
    
    int n;
    scanf("%d", &n);
    vi h(n);
    for(int& x : h) {
        scanf("%d",&x);
    }
   vi dp(n,INT_MAX);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j : {i + 1, i + 2}) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    
    cout<< dp[n-1];
return 0;
}

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

int main(void)
{
    string S;
    int cnta=0, cntb=0, cntc=0;
    cin >> S;

    for(int i=0; i<3; i++){
        if(S[i] == 'a'){
            cnta++;
        }
        if(S[i] == 'b'){
            cntb++;
        }
        if(S[i] == 'c'){
            cntc++;
        }
    }

    if(cnta > 1 || cntb > 1 || cntc > 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
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;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}
template<class T>istream&operator>(istream&i,T&t){return i>>t;}
#ifndef LOCAL
struct ostdmy{
template<class T>ostdmy&operator<<(const T&t){return*this;}
template<class T>ostdmy&operator<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>n;

    vector<string> s(n);
    cin>s;
    int a=0;
    int b=0;
    int ab=0;
    int ba=0;
    REP(i,n){
        REP(j,s[i].size()-1){
            if(s[i][j]=='A' && s[i][j+1]=='B')ab++;
        }
        if(s[i][s[i].size()-1]=='A')a++;
        if(s[i][0]=='B')b++;
        if(s[i][s[i].size()-1]=='A' && s[i][0]=='B')ba++;
    }
    if(!a){
        cout<ab;
    }else{
        if(a==ba && b==ba){
            cout<ab+ba-1;
        }else{
            cout<ab+min(a,b);
        }
    }
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

bool kai(string x){
  int m=x.size();
  rep(i,m){
    if(x[i]!=x[m-1-i]){
      return false;
    }
  }
  return true;
}

int main(){
  string s;
  cin >> s;
  int n=s.size();
  string t,u;
  for(int i=0;i<(n-1)/2;i++)t+=s[i];
  for(int i=(n-1)/2+1;i<n;i++)u+=s[i];
  if(kai(s) && kai(t) && kai(u)){
    cout << "Yes" << endl;
  }else cout << "No" << endl;
return 0;}

Measured memory_bytes: 256
import itertools
import sys
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def get_lcm(num):
    return reduce(lambda x,y:(x * y) // fractions.gcd(x, y), num, 1)

def main():
    N,M = map(int,input().split())
    half_A = list(map(lambda x:int(x)//2,input().split()))

    lcm = get_lcm(half_A)

    if lcm > M:
        print(0)
        exit()

    for a in half_A:
        if (lcm // a) % 2 == 0:
            print(0)
            exit()

    print(math.ceil((M//lcm)/2))


if __name__ == "__main__":
  main()


Measured memory_bytes: 25052
#include<iostream>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	int ans = 0;

	for (int i = 0; i < 4; ++i) {
		if (s[i] == '2') {
			ans++;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 5) {
        cout << 0 << endl;
    } else if (a >= 13) {
        cout << b << endl;
    } else {
        cout << b/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const char c[]={'R','L','U','D'};
int n;
long long x[1010],y[1010];
long long tx[1010],ty[1010];
int m;
long long l[51];
long long dist(long long a,long long b,long long c,long long d)
{
	return abs(a-c)+abs(b-d);
}
void getl()
{
	long long mx=0;
	for(int i=1;i<=n;i++)
		mx=max(mx,tx[i]+ty[i]);
	while(mx>0)
	{
		l[++m]=(mx+1)/2;
		for(int i=1;i<=n;i++)
			tx[i]-=l[m];
		mx=0;
		for(int i=1;i<=n;i++)
		{
			tx[i]=abs(tx[i]);
			ty[i]=abs(ty[i]);
			if(tx[i]<ty[i])swap(tx[i],ty[i]);
			mx=max(mx,tx[i]+ty[i]);
		}
	}
	return ;
}
char ans[51];
void work(long long a,long long b,int now)
{
	if(now>m)return ;
	long long mn=2e9;
	for(int i=0;i<4;i++)
		mn=min(mn,dist(dx[i]*l[now],dy[i]*l[now],a,b));
	for(int i=0;i<4;i++)
		if(dist(dx[i]*l[now],dy[i]*l[now],a,b)==mn)
		{
			ans[now]=c[i];
			work(a-dx[i]*l[now],b-dy[i]*l[now],now+1);
			break;
		}
	return ;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld %lld",&x[i],&y[i]);
		tx[i]=abs(x[i]);
		ty[i]=abs(y[i]);
		if(tx[i]<ty[i])swap(tx[i],ty[i]);
	}
	for(int i=1;i<=n;i++)
		if(((x[i]+y[i])&1)!=((x[1]+y[1])&1)){
			printf("-1\n");
			return 0;
		}
	getl();
	printf("%d\n",m);
	for(int i=1;i<=m;i++)
		printf("%lld ",l[i]);
	printf("\n");
	for(int i=1;i<=n;i++)
	{
		work(x[i],y[i],1);
		printf("%s\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 256
def inv(a,p):
    if a==1:
        return 1
    elif a==0:
        return 0
    return p-(inv(p%a,p)*(p//a))%p
x,y=map(int,input().split())
if (x+y)%3!=0:
    print("0")
    exit()
if x==0 and y>0:
    print("0")
    exit()
if y/x>2 or y/x<0.5:
    print("0")
    exit()
n=(x+y)//3
r=(2*x-y)//3
p=10**9+7
def fact(n,p):
    a=[[] for _ in range(n+1)]
    a[0]=1
    for i in range(n):
        a[i+1]=(a[i]*(i+1))%p
    return a
f=fact(n,p)
c=f[-1]
d=f[r]
e=f[n-r]
dd=inv(d,p)
ee=inv(e,p)
ans=(c*dd*ee)%p
print(ans)

Measured memory_bytes: 56712
import math
N, K = (int(x) for x in input().split())
p = 0
for i in range(1,N+1):
    if i < K:
        times = math.ceil(math.log2(K/i))
        p = p + (1/N)*(1/2)**times
    else:
        p = p + (1/N)
print(p)

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

int main(void){

    int N, K;
    cin >> N >> K;

    string S;
    cin >> S;

    vector<int> Nums;
    int now = 1, cnt = 0;
    for(char c : S){
        if( c == (char)'0'+now ){
            cnt++;
        } else{
            now = 1 - now;
            Nums.push_back(cnt);
            cnt = 1;
        }
    }
    if(cnt != 0)    Nums.push_back(cnt);
    if(Nums.size() % 2 ==0)    Nums.push_back(0);

    vector<int> sum(Nums.size()+1, 0);
    for(int i=0;i<Nums.size();i++){
        sum[i+1] = sum[i] + Nums[i];
    }

    int ans = 0;
    for(int i=0;i<Nums.size();i+=2){
        int left = i;
        int right = min( i + (2*K+1), (int)Nums.size() );
        ans = max(ans, sum[right] - sum[left]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1272
#include <cstdio>
#include <iostream>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
template<class T> void read(T &x)
{
	x=0; int f=1,ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=getchar();}
	x*=f;
}
template<class T> inline bool Cmax(T &x,T y) {return x<y?x=y,1:0;}
const int inf=1e9;
const int maxn=2e6+50;
int n,m,K;
char s[maxn];
char t[maxn];
int cnt;
int top;
int A[maxn];
int B[maxn];
int S[maxn];
int T[maxn];
void print(int *r)
{
	bool flag=0;
	for(int i=maxn-1;~i;--i)
	{
		if(r[i]) flag=1;
		if(flag) printf("%d",r[i]);
	}
	printf("\n");
}
int main()
{
	read(n),read(m),read(K);
	scanf("%s",s);
	scanf("%s",t);
	for(int i=0;i<n;++i) S[i]=s[n-i-1]-'0';
	for(int i=0;i<m;++i) T[i]=t[m-i-1]-'0';
	Cmax(n,m);
	for(int i=n-1;~i;--i)
	{
		if(S[i]==1&&T[i]==0)
		{
			A[++top]=i;
		}
		else if(S[i]==0&&T[i]==1)
		{
			A[++top]=i;
		}
		else if(S[i]==1&&T[i]==1)
		{
			S[i]=T[i]=0;
			int z=K-1,x=3;
			int now=i;
			while(true)
			{
				int j=top?A[top--]:inf;
				if(j!=now+1)
				{
					if(x!=3)
					{
						if(x==1) S[now+1]=1,T[now+1]=0;
						else S[now+1]=0,T[now+1]=1;
						B[++cnt]=now+1;
						B[++cnt]=j;
						break;
					}
					if(j-now-1>z)
					{
						S[now+1+z]=T[now+1+z]=1;
						B[++cnt]=now+1+z;
						B[++cnt]=j;
						break;
					}
					z-=j-now-1; 
				}
				if(S[j]==1&&T[j]==0)
				{
					if(x==3) 
					{
						S[j]=0,T[j]=1,x=1;
						B[++cnt]=j;
					}
					else if(x==1) S[j]=0;
					else if(x==2)
					{
						if(z==0)
						{
							T[j]=1;
							B[++cnt]=j;
							break;
						}
						--z;
						S[j]=0,x=3;
					}
				}
				else if(S[j]==0&&T[j]==1)
				{
					if(x==3) 
					{
						S[j]=1,T[j]=0,x=2;
						B[++cnt]=j;
					}
					else if(x==2) T[j]=0;
					else
					{
						if(z==0)
						{
							S[j]=1;
							B[++cnt]=j;
							break;
						}
						--z;
						T[j]=0,x=3;
					}
				}
				now=j;
			}
			while(cnt) A[++top]=B[cnt--];
		}
	}
	print(S);
	print(T);
	return 0;
}

Measured memory_bytes: 24576
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
      	int i = 0;
        int count = 0; 
        int start = 0;
      	int finish = 0;
      	String[] List = S.split("");
 
		for(i = 0;i < List.length; i++){
          if(List[i].equals("A")){
             start = 1;
          }
          if(start == 1){
            count += 1;
            if(List[i].equals("Z")){
              finish = count;
            }
          }
        }
          System.out.println(finish);
    }
}

Measured memory_bytes: 65528
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, pos = 1;
    long long k;
    cin >> n >> k;
    long long a[n + 1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int index[n + 1] = {0};
    index[1] = 0;
    int mul, ama;
    long long j;
    vector<int> rec;
    rec.push_back(1);
    for(j = 1; j <= k; j++){
        pos = a[pos];
        if(index[pos] != 0){
            ama = index[pos];
            mul = j - ama;
            break;
        } else {
            index[pos] = j;
            rec.push_back(pos);
        }
    }
    if(j > k){
        cout << pos << endl;
        return 0;
    }
    long long hoge = (k - ama) % mul;
    cout << rec[ama + hoge] << endl; 
    return 0;
}

Measured memory_bytes: 6664
#include <iostream>
#include <vector>
#define mod 1000000007
using namespace std;
int a[30][30];
int n;
int dp[2100000],cnt[2100000];
int main(int argc, char** argv) {
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			cin >> a[i][j];
	}
	for(int i=1;i<=2099000;i++)
		cnt[i]=cnt[i^i&(-i)]+1;
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<(1<<n);j++)
		{
			if(cnt[j]!=(i-1)) continue;
			for(int k=1;k<=n;k++)
			{
				if(!a[i][k]) continue;
				if(j&(1<<k-1)) continue;
				dp[j|(1<<k-1)]+=dp[j],dp[j|(1<<k-1)]%=mod;
			}
		}
	}
	cout << dp[(1<<n)-1];
	return 0;
}

Measured memory_bytes: 16640
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define mod 1000000007

int main()
{
    int acm=1;
    string s1,s2="",s3="";
    cin>>s1;
    ll l=s1.size();
    for(ll i=0;i<l/2;i++)
        s2+=s1[i];
    for(ll i=l-1;i>l/2;i--)
        s3+=s1[i];
    for(int i=0;i<s2.size()/2;i++)
    {
        if(s2[i]!=s2[s2.size()-i-1])
        {

            acm=0;
            break;
        }
        if(s3[i]!=s3[s3.size()-1-i])
        {
            acm=0;break;
        }
    }
    if(s2!=s3)
        acm=0;
    if(acm)
        printf("Yes\n");
    else
        printf("No\n");
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
count = 1
ans = 0
for i in range(1,n):
    if a[i] != a[i-1]:
        if a[i-1] < count:
            ans += count - a[i-1]
        elif a[i-1] > count:
            ans += count
        count = 1
    else:
        count+=1
if a[n-1] < count:
    ans += count - a[n-1]
elif a[n-1] > count:
    ans += count
print(ans)

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

int main(int argc, char const* argv[])
{
    vector<int> input;
    int a;

    for (int i = 0; i < 3; i++) {
        cin >> a;
        input.push_back(a);
    }

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

    if(input[0] == 5 && input[1] == 5 && input[2] == 7)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio> 
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int Mo=1000000007;
int w[26];
char s[100010];
int main() {
    int n,ans=1;
    scanf("%d%s",&n,s);
    for(int i=0;i<n;i++) ++w[s[i]-'a'];
    for(int i=0;i<26;i++) ans=1LL*ans*(w[i]+1)%Mo;
    cout<<(ans-1+Mo)%Mo;
    return 0;
}

Measured memory_bytes: 384
import sys
def main():
    input = sys.stdin.readline
    NAB = list(map(int, input().split()))
    N = NAB[0]
    A = NAB[1]
    B = NAB[2]

    if N * A > B:
        res = B
    else:
        res = N * A
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import itertools

N_st = input()
keta = len(N_st)
N = int(N_st)


hit53 =['3','5','7']
res = []

all_perm = []
for k in range(3,keta + 1):
    all_perm.extend(list(itertools.product(hit53,repeat= k)))
for a in all_perm:
    target = int(''.join(a))
    if target <= N and '3' in str(target) and '5' in str(target) and '7' in str(target):
        res.append(target)

print(len(res))

Measured memory_bytes: 7860
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 5e5 + 5;
multiset<int,greater<int>> s[maxn];
int n , a[maxn];

int main(){
    if(fopen(taskname".INP","r")){
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    int n , A , B;cin >> n >> A >> B;
    if(A + B > n + 1 || (ll)A * B < n)return cout << -1 , 0;
    int rem = n - A;
    int now = 0;
    for(int i = 1 ; i <= A ; ++i){
        for(int j = now + min(rem , B - 1) + 1 ; j >= now + 1 ; --j){
            cout << j << " ";
        }
        now += min(rem , B - 1) + 1;
        rem -= min(rem , B - 1);
    }
}



Measured memory_bytes: 25600
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  const long long mod=1e9+7;

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

  vector<int> oks(n+1, true);
  REP(i, m) {
    int a;
    cin >> a;
    oks[a] = false;
  }

  vector<long long int> dp(n+1);
  dp[0] = 1;
  REP(now, n) {
    for(int next = now+1;next<=min(n, now+2); ++next) {
      if(oks[next]) {
        dp[next] += dp[now];
        dp[next] %= mod;
      }
    }
  }

  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int H,W;

		H = sc.nextInt();
		W = sc.nextInt();

		int table[][] = new int[H+1][W+1];

		for(int row = 0; row < H; row++){
			for(int col = 0; col < W; col++){
				table[row][col] = sc.nextInt();
			}
		}

		for(int row = 0; row < H; row++){
			table[row][W] = 0;
			for(int col = 0; col < W; col++){
				table[row][W] += table[row][col];
			}
		}

		for(int col = 0; col <= W; col++){
			table[H][col] = 0;
			for(int row = 0; row < H; row++){
				table[H][col] += table[row][col];
			}
		}

		for(int row = 0; row <= H; row++){
			System.out.printf("%d", table[row][0]);
			for(int col = 1; col <= W; col++){
				System.out.printf(" %d", table[row][col]);
			}
			System.out.printf("\n");
		}
	}
}




Measured memory_bytes: 59624