akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

/*
g(L, R) := \prod_{i=L}^{R} (1 + q^{A_i})
f(L, R) = [q^S] g(L, R)
\sum_{1<=L<=R<=N} f(L, R)
p[i] := \sum_{1<=L<=i} g(L, i)
p[i] = (p[i-1] + 1) * (1 + q^{A_i})
*/

constexpr unsigned mod = 998244353;

int n, s;
unsigned dp[3001];

int main(){
  scanf("%d%d", &n, &s);

  long long int ans = 0;
  for(int i = 0; i < n; i++){
    int a;
    scanf("%d", &a);
    dp[0]++;
    for(int j = s; j >= a; j--){
      dp[j] += dp[j - a];
      if(dp[j] >= mod) dp[j] -= mod;
    }
    ans += dp[s];
  }
  printf("%d\n", (int) (ans % mod));
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int b,r,g,c,s,t;
  while(cin >> b>>r>>g>>c>>s>>t,b||r||g||c||s||t) {
    int res = 100 + b * 15 + r*15 + g*7 + c*2;
    int bonus = b*5 + r*3;
    res += 15 * bonus;
    res -= (t - s - bonus) * 3 + bonus * 2;
    cout << res << endl;
  }
}

Measured memory_bytes: 0
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int x, y; cin >> x >> y;

	cout << x + y / 2 << endl;
}

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

int main(){
  int H, W;
  cin >> H >> W;
string s[H];
  
  for(int i = 0;i < H;i++){
  cin >> s[i];  
  }

  for(int i = 0;i < H;i++){
  cout << s[i] << endl;
  cout << s[i] << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> cnt(1000005);
  for (int x : a) {
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for (int i = x; i < 1000005; i += x) cnt[i]++;
  }
  int ans = 0;
  for (int x : a) {
    if (cnt[x] == 1) ans++;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 7912
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

#define MAX 500000
#define SENTINEL 2000000000
int L[MAX/2+2],R[MAX/2+2];
int n;
int cnt;

void merge(int *a,int n, int l,int mid,int r) {
    int n1=mid-l;
    int n2=r-mid;
    rep(i,n1) L[i]=a[l+i];
    rep(i,n2) R[i]=a[mid+i];
    L[n1]=R[n2]=SENTINEL;
    int i,j;
    i=j=0;
    for(int k=l;k<r;k++) {
        cnt++;
        if(L[i]<=R[j]) a[k]=L[i++];
        else a[k]=R[j++];
    }
}
void merge_sort(int *a,int n,int l,int r) {
    if(l+1<r) {
        int mid=(l+r)/2;
        merge_sort(a,n,l,mid);
        merge_sort(a,n,mid,r);
        merge(a,n,l,mid,r);
    }
}
int a[MAX];

int main() {
    cin>>n;
    rep(i,n) cin>>a[i];

    merge_sort(a,n,0,n);
    rep(i,n) cout<<(i==0?"":" ")<<a[i];
    cout<<endl;
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 5064
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    string s;
    int q;
    cin >> s >> q;
 
    string ans = s;
    int count = 0;
 
    for(int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if(t == 1) {
            count++;
        } else {
            int f;
            string c;
            cin >> f >> c;
            if((f == 1 && count % 2 == 0) || (f == 2 && count % 2 == 1)) ans.insert(0, c);
            else if((f == 2 && count % 2 == 0) || (f == 1 && count % 2 == 1)) ans += c;
        }
    }
 
    if(count % 2 == 1) reverse(ans.begin(), ans.end());
 
    cout << ans << endl;
 
    return 0;
}

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

int main(void){
    int n,m,l;
    int mat1[100][100], mat2[100][100];
    long long out[100][100]={0};
    
    
    cin>>n>>m>>l;
    for(int i=0; i < n; i++){
        for(int j=0; j<m;j++){
            cin >> mat1[i][j];
        }
    }
    for(int i=0; i < m; i++){
        for(int j=0; j<l;j++){
            cin >> mat2[i][j];
        }
    }

    for(int i=0; i < n; i++){
        for(int j=0; j<l;j++){
            for(int k=0; k<m;k++)
                out[i][j] += mat1[i][k]*mat2[k][j];
        }
    }
    for(int i=0; i < n; i++){
        for(int j=0; j<l-1;j++){
            cout << out[i][j] << " ";
        }
        cout <<out[i][l-1]<< endl;
    }
    
    return 0;
}





Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    string s, t;
    cin>>s>>t;
    ll a,b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (s == u) cout << a - 1 <<" "<< b << endl;
    else
        cout << a << " " << b - 1 << endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <math.h>

int main(void) {
	int dist=1, ang=1, direction=90;
	double x=0, y=0;
	
	while(dist != 0 || ang != 0) {
		scanf("%d,%d", &dist, &ang);
		
		x += (double)dist*cos(M_PI*direction/180);
		y += (double)dist*sin(M_PI*direction/180);		
		
		direction = direction - ang;
	}
	
	printf("%d\n%d\n", (int)x, (int)y );
	
	return 0;
}

Measured memory_bytes: 604
let rec for_fold a b v f = if a >= b then v else for_fold (a+1) b (f v a) f
let () = print_endline @@
  Scanf.scanf "%d" @@ fun n ->
  let w = Array.init n (fun _ -> Scanf.scanf " %s" (fun x -> x)) in
  let c = Array.to_list w |> List.sort_uniq compare |> List.length in
  let b = 
    for_fold 0 (n-1) true (fun b i ->
      b && (w.(i).[String.length w.(i) - 1] = w.(i+1).[0]))
  in
  if b && c = n then "Yes" else "No"

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s, t; 
  cin >> s >> t;

  sort(ALL(s));
  sort(ALL(t), greater<>());

  if(s < t) Yes;
  else No;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
using namespace std;
main (){
ll n,t;
cin>>n>>t;
vector<ll>a;
vector<ll>d;
a.resize(n+1);
d.resize(n+1,10e10);
for (int i=1;i<=n;i++)
    cin>>a[i];
d[1]=0;
d[2]=abs(a[2]-a[1]);
for (int i=3;i<=n;i++)
   for(int k=1;k<=min(int(t),i);k++)
    d[i]=min(abs(a[i]-a[i-k])+d[i-k],d[i]);
    cout<<d[n];
return 0;}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

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

    rep(i,s.length()){
      if(s.at(i)=='?') s.at(i)='D';
    }

    cout << s << endl;
    
}


Measured memory_bytes: 3752
/*
“Yesterday is history, tomorrow is a mystery, today is a gift of God,
which is why we call it the present.” ― Bill Keane
*/
#include<bits/stdc++.h>
#define endl "\n"
#ifdef ONLINE_JUDGEsj
#define DEBUG(x)
#else
#define DEBUG(x) cout<<#x<<" : {"<<x<<"}"<<endl;
#endif
using namespace std;
typedef long long int lli;
constexpr int MAX=3e5;
inline lli add(lli a, lli b, int mod){
	lli x=a+b;
	if(x>=mod)
		x-=mod;
	return x; 
}
inline lli mul(lli a, lli b, int mod){
	return ((a%mod)*(b%mod))%mod;	
}
inline lli sub(lli a, lli b, int mod){
	lli x=a-b;
	if(x<0)
		x+=mod;
	return x;
}
lli powr(lli a, lli b, lli m){
	a%=m;
	if(b==0) return 1LL;
	else if(b&1) return mul(a, powr(a*a, (b-1)/2, m), m);
	else return powr(a*a, b/2, m);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int bitcnt=0;
	for(char c: s) if(c=='1') bitcnt++;
	lli u, v;
	u=v=0;
	for(int i=n-1; i>=0; --i){
		if(s[i]=='1'){
			u=add(u, powr(2,n-i-1,bitcnt+1), bitcnt+1);
			if(bitcnt-1==0) continue;
			v=add(v, powr(2,n-i-1,bitcnt-1), bitcnt-1);
		}	
	}
	
	int dp[MAX]={0};
	dp[1]=1;
	dp[2]=1;
	for(int i=3; i<MAX; ++i){
		dp[i]=1+dp[i%__builtin_popcount(i)];
	}
	lli res;
	for(int i=0; i<n; ++i){
		if(s[i]=='1'){
			if(bitcnt-1==0){
				cout<<0<<endl;
				continue;
			}
			res=sub(v,powr(2,n-i-1,bitcnt-1),bitcnt-1);
			cout<<1+dp[res]<<endl;
		}
		else{
			res=add(u,powr(2,n-i-1,bitcnt+1),bitcnt+1);	
			cout<<1+dp[res]<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4952
"""
17D8101031C 杉山　祥吾 ID:keisei334 python
"""

def levenshtein(s1, s2):
    n=len(s1)
    m=len(s2)
    dp = [[0]*(m+1) for i in range(n+1)]
    
    for i in range(n+1):
        dp[i][0] = i
    
    for j in range(m+1):
        dp[0][j] = j

    for i in range(1,n+1):
        for j in range(1,m+1):
            cost=0 
            if s1[i-1] == s2[j-1]:
                cost=0
            else:
                cost=1
            dp[i][j]=min(dp[i-1][j] + 1, dp[i][j-1]+1, dp[i-1][j-1] + cost)
            
    return dp[n][m]

    
s1 = input()
s2 = input()

print(levenshtein(s1, s2))

"""実行結果

"""



Measured memory_bytes: 43076
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>

using namespace std;

int main(){
    string su;
vector<char>s(200000);
cin>>su;
int h=su.length();
for(int i=0;i<h;i++){
    if(su[i]=='?'){
       su[i]='D';

    }
}
cout<<su<<endl;
}

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

int main(){
  int N;
  cin >> N;
  int card[N];
  int a,b,max,max_i;
  a = 0;
  b = 0;
  max = 0;
  max_i = 0;
  for (int i = 0; i < N; i++){
    cin >> card[i];
  }
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if (max < card[j]){
        max = card[j];
      	max_i = j;
      }
    }
    if (i%2 == 0){
      a += max;
    }
    else {
      b += max;
    }
    card[max_i] = 0;
    max = 0;
  }
  cout << a-b << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var max = 0;
            for(var i=1;i<N;i++)
            {
                var left = S.Remove(i).Distinct().ToArray();
                var right = S.Substring(i).Distinct().ToArray();
                var cnt = left.Where(x => right.Contains(x)).Count();
                max = Math.Max(max, cnt);
            }
            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N; cin >> N;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  vector<ll> len(N+1,0);
  ll sumlen = 0;
  rep(i,N){
    sumlen += A[i];
    len[i+1] = len[i]+A[i];
  }
  ll ans = 1e18;
  ll mindiv=1e18;
  rep(i,N+1){
    mindiv = min(mindiv, abs(len[i] - (sumlen-len[i])));
  }
  ans = mindiv;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3456
/**
 *    author:  math2do
 *    created: 04.09.2020 16:41:41 IST
**/

#include <bits/stdc++.h>

using namespace std;

const int N = (int) 1e5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m = 2, w;
  cin >> n >> w;
  vector <vector <int> > mat(n, vector <int> (m));
  for (int i = 0; i < n; i++) {
    cin >> mat[i][0] >> mat[i][1];
  } 
  const int pinf = numeric_limits<int>::max();
  vector <long long> dp(N + 1, pinf);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = N - mat[i][1]; j >= 0; j--) {
      dp[j + mat[i][1]] = min(dp[j + mat[i][1]], dp[j] + mat[i][0]);
    } 
  } 
  
  int ans = 0;
  for (int i = 0; i <= N; i++) {
    if (dp[i] <= w) {
      ans = i;
    } 
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3992
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ans += (2 * i + (n/i-1)*i)*(n/i)/2;
    }
    cout << ans << endl;
}


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

int main(){
  char ch;
  cin >> ch;
  switch (ch){
    case 'a' :
    case 'i' :
    case 'u' :
    case 'e' :
    case 'o' :
      cout << "vowel" << endl;
      break;
    default:
      cout << "consonant" << endl;
      break;
  }
}

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

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

    for (int i = 1; i <= 9; i++)
        for (int j = 1; j <= 9; j++){
            if(i*j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
            cout << "No" << endl;
            return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
void solve(){
    
     int n,t,k; cin>>n>>t>>k;
     int m=n+t-1;
     m/=t;
     long long kk=k*m;
     cout<<kk<<endl;
 }

int main() {
   #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

 ios_base::sync_with_stdio(0);
 cin.tie(0);

  int t=1 ;  /*cin>>t ;*/

  while(t--){
  solve();
  }

 return 0;
}


Measured memory_bytes: 3636
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


//Sleeping Cats
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int w = sc.nextInt();
			int q = sc.nextInt();
			if(w==0&&q==0)break;
			boolean[] wall = new boolean[w];
			Map<Integer, Integer> cat = new HashMap<Integer, Integer>();
			Map<Integer, Integer> pos = new HashMap<Integer, Integer>();
			while(q--!=0){
				char cmd = sc.next().charAt(0);
				if(cmd=='s'){
					int id = sc.nextInt();
					int need = sc.nextInt();
					int p = 0;
					boolean f = false;
					while(p<w){
						if(wall[p]){
							p++;
							continue;
						}
						int dt = 0;
						int pp = p;
						while(p < w && !wall[p]){
							p++;
							dt++;
							if(dt==need){
								cat.put(id, need);
								pos.put(id, pp);
								System.out.println(pp);
								for(int i=pp;i<pp+need;i++)wall[i]=true;
								f = true;
								break;
							}
						}
						if(f)break;
					}
					if(!f)System.out.println("impossible");
				}
				else{
					int id = sc.nextInt();
					int p = pos.get(id);
					int need = cat.get(id);
					for(int i=p;i<p+need;i++)wall[i] = false;
				}
			}
			System.out.println("END");
		}
	}
}

Measured memory_bytes: 12000
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=1001000,P=1000000007;
int i,j,k,n,m,sum;
int f[N];
int main() {
	scanf("%d",&n);
	f[1]=n;f[2]=(ll) n*n%P;sum=((ll) n*n+n)%P;
	for (i=3;i<=n;i++) {
		f[i]=((ll) (n-1)*(n-1)+(n-i+2)+sum+P-f[i-2])%P;
		sum=(sum+f[i])%P;
	}
	printf("%d\n",f[n]);
}

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

int main(){
  int h1, h2, k1, k2, a, b, c, d, H, K;

  cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
  H = h1*a + (h1/10)*c + h2*b + (h2/20)*d;
  K = k1*a + (k1/10)*c + k2*b + (k2/20)*d;

  if ( H > K ) cout << "hiroshi" << endl;
  else if ( H < K ) cout << "kenjiro" << endl;
  else cout << "even" << endl;

  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a;
    int count=0;
    int ans=1000000000;
    for(int i=0; i<n; i++){
        cin >> a;
        count=0;
        while(count<ans){
            if(a%2) break;
            a/=2;
            count++;
        }
        ans=min(ans,count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Problem solver = new Problem();
        solver.solve(0, in, out);
        out.close();
    }

    static class Problem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int H = in.nextInt(), N = in.nextInt();
            int[] arr = new int[N];
            for (int i = 0; i < N; i++)
                arr[i] = in.nextInt();

            int sum = Arrays.stream(arr).sum();
            if(sum >= H)
                out.println("Yes");
            else
                out.println("No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 36268
n = gets.to_i
a = [[3,5,7]]

8.times do |i|
  x = []
  d = a[i].dup
  [3,5,7].each do |j|
    v = j * (10 ** (i+1))
    d.each do |t|
      x << (t + v)
    end
  end
  a << x
end
a.flatten!
ans = 0
a.each do |v|
  str = v.to_s
  check = [false,false,false]
  str.each_char {|c|
    if c == "3"
      check[0] = true
    elsif c == "5"
      check[1] = true
    elsif c == "7"
      check[2] = true
    end
  }
  ans += 1 if  v <= n && check[0] && check[1] && check[2]
end
p ans


Measured memory_bytes: 2428
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();

    for (int c = M / N; c > 0; c--) {
      if (M % c != 0) continue;
      int d = M / c;
      if (d >= N) {
        System.out.println(c);
        return;
      }
    }
  }
}


Measured memory_bytes: 23764
n, m = map(int, input().split())
matrix = []
for _ in range(n):
    matrix.append(list(map(int, input().split())))
    
vec = []
for _ in range(m):
    vec.append(int(input()))
    
for row in matrix:
    s = 0
    for x in zip(row, vec):
        s += x[0] * x[1]
        
    print(s)
    



Measured memory_bytes: 6012
// C.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	map<long long, int> m;
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		long long a;
		cin >> a;
		m[a] += 1;
	}
	LL ans = 0;
	vector<long long> v;
	for (auto &kv : m) {
		if (kv.second >= 4) {
			ans = max(ans, kv.first * kv.first);
		}
		if (kv.second >= 2) {
			v.push_back(kv.first);
		}
	}
	if (v.size() >= 2) {
		ans = max(ans, v[v.size() - 2] * v[v.size() - 1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static char[] array = new char[13];

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;

		try {
			while ((line = br.readLine()) != null) {
				line = line.trim();
				array = line.toCharArray();
				int[] numCount = new int[10];
				for (int i = 0; i < array.length; i++) {
					numCount[array[i] - '0']++;
				}
				String ans = "0";
				for (int i = 1; i <= 9; i++) {
					if (numCount[i] == 4)
						continue;
					searchHead: for (int j = 1; j <= 9; j++) {
						int[] num = numCount.clone();
						num[i]++;
						if (num[j] - 2 < 0)
							continue;
						num[j] -= 2;
						// 順子チェック
						for (int k = 1; k <= 7; k++) {
							if (num[k] < 0)
								continue searchHead;
							int surplus = num[k] % 3;
							if (surplus != 0) {
								num[k] -= surplus;
								num[k + 1] -= surplus;
								num[k + 2] -= surplus;
							}
						}
						// 8と9は0か3
						if (((num[8] % 3) + (num[9] % 3)) == 0 && num[8] >= 0 && num[9] >= 0) {
							if (ans.equals("0")) {
								ans = Integer.toString(i);
							} else {
								ans += " " + Integer.toString(i);
							}
							break searchHead;
						}
					}
				}
				System.out.println(ans);
			}
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

const ll MAX = (1<<18);
const ll INF = (1<<29);
ll N,M,K,D,S;
ll A[100001];
ll B[100001];
ll C[100001];

struct state{
  ll a,b,c,k;
  bool operator<(const state st) const {
    if( a == st.a ) return k > st.k;
    return a > st.a;
  }
};
ll compress(){
  vector<ll> x;
  for(ll i=0;i<M;i++) x.push_back( C[i] );
  sort(x.begin(),x.end());
  x.erase(unique(x.begin(),x.end()),x.end());
  for(ll i=0;i<M;i++){
    C[i] = lower_bound(x.begin(),x.end(),C[i])-x.begin();
  }
  return x.size();
}
typedef pair<ll,ll> P;
struct seg{
  ll n, d[MAX+1];
 
  void init(ll _n){
    n = 1;
    while( n < _n ) n*=2;
    memset( d, 0, sizeof(d) );
  }
 
  // k番目の値をaに変更
  void update(ll k, ll a){
    k += n - 1;
    d[k] = a;
    while(k > 0){
      k = (k - 1) / 2;
      d[k] = min(d[k*2+1], d[k*2+2]);
    }
  }
 
  // [a,b) の最小値を求める
  ll query(ll a, ll b){ return query(a, b, 0, 0, n);}
  ll query(ll a, ll b, ll k, ll l, ll r){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return d[k];
    else{
      ll vl = query(a, b, k*2+1, l, (l+r)/2);
      ll vr = query(a, b, k*2+2, (l+r)/2, r);
      return min(vl,vr);
    }
  }
};

seg Seg;
int main(){
  //cin >> N >> M >> K >>D >> S;
  scanf("%d %d %d %d %d",&N,&M,&K,&D,&S);
  for(ll i=0;i<M;i++){
    //cin >> A[i] >> B[i] >> C[i];
    scanf("%d %d %d",&A[i],&B[i],&C[i]);
  }
  ll n = compress();
  if( n < N ) N = n + 1;
  // cout << N << endl;

  priority_queue<state> q;
  for(ll i=0;i<M;i++){
    q.push( (state){A[i],B[i],C[i],0} );
  }
  q.push( (state){S+D,0,0,1} );

  Seg.init(N);

  ll co = 0;
  ll res = 0;
  while( co < K ){
    state p = q.top(); q.pop();
    ll now = p.a;
    //   cout << p.a << " " << p.b << " " << p.c <<" "<< p.k << endl;
    if( p.k == 0 ){
      ll id = p.c;
      ll time = Seg.query(id,id+1);
      Seg.update(id,max(time,now)+p.b); 
      //  cout << id <<" -> " << max(time,now)+p.b << endl;     
    } else {
      ll time = Seg.query(0,N);
      ll nex = max(time,now) + D;
      // cout << time << endl;
      co++;
      res = max(time,now);
      q.push( (state){nex,0,0,1} );
    }
  }
  //cout << res-S << endl;
  printf("%d\n",res-S);

}

Measured memory_bytes: 9536
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  long int A, B;
  cin >> A >> B;
  // 最小公倍数
  for (int i = 1; i <= B; i++)
  {
    if ((A * i) % B == 0)
    {
      cout << A * i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    val po = readLine()!!.split(' ').map(String::toInt)
    var score = -1000000000
    (0..k).forEach { i1 ->
        (0..Math.min(i1, n)).forEach { i2 ->
            (0..i2).forEach { i3 ->
                val meu = (po.take(i3) + po.drop(n - (i2 - i3))).sorted().drop(i1 - i2).sum()
                score = Math.max(score, meu)
            }
        }
    }
    println(score)
}


Measured memory_bytes: 71132
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N;
  long long K;
  cin >> N >> K;
  vector<int> A(N+1);
  for(int i = 1; i < N+1; i++){
    cin >> A.at(i);
  }
  
  int c = 1;
  while(K){
    if(K&1) c = A.at(c);
    vector<int> NA(N+1);
    for(int i = 1;i < N+1; i++){
      NA.at(i) = A.at(A.at(i));
    }
    A.swap(NA);
    K >>= 1;
  }
  cout << c << "\n";
}


Measured memory_bytes: 5116
#include<stdio.h>
#include<math.h>

#define TRUE  1
#define FALSE 0
#define MAX_NUM 1000000

int main(){

	int n;
	int i,j;
	int count=0;
	int flag=0;
	int num[MAX_NUM+1];
	
	/*初期化と0,1の除外*/
	for(i=0;i<MAX_NUM+1;i++){
		if(i<=1)
			num[i]=FALSE;
		else
			num[i]=TRUE;
	}
	
	/*1000000の素数をあらかじめ見つけておく*/
	for(i=2;i<sqrt(MAX_NUM)+1;i++){
		if(num[i]){
			/*倍数は見ないようにする*/
			for(j=i*2;j<=MAX_NUM;j+=i){
				num[j]=FALSE;
			}
		}
	}
	
	
	while(scanf("%d",&n)!=EOF){
		count=0;
		for(i=0;i<=n;i++){
			if(num[i]){
				count++;
			}
		}
		printf("%d\n",count);
	}

	return 0;
}

Measured memory_bytes: 4500
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a<b){
		string s(b,'0'+a);
		cout<<s<<endl;
	}
	else{
		string s1(a,'0'+b);
		cout<<s1<<endl;
	}
	return 0;
}

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

int n, k;
int x[50], y[50];
int sx[50], sy[50];

int Count(int lx, int rx, int ly, int ry) {
	lx = sx[lx];
	rx = sx[rx];
	ly = sy[ly];
	ry = sy[ry];
	
	int ret = 0;
	for (int i = 0; i < n; i++) {
		if (lx <= x[i] && x[i] <= rx && ly <= y[i] && y[i] <= ry) {
			ret++;
		}
	}
	return ret;
}

signed main() {
	int i;
	
	cin >> n >> k;
	for (i = 0; i < n; i++) cin >> x[i] >> y[i];
	for (i = 0; i < n; i++) sx[i] = x[i];
	for (i = 0; i < n; i++) sy[i] = y[i];
	
	sort(sx, sx + n);
	sort(sy, sy + n);
	
	int ans = 4e+18;
	for (int lx = 0; lx < n; lx++) {
		for (int rx = lx; rx < n; rx++) {
			//[sx[lx], sx[rx]]
			int ry = 0;
			for (int ly = 0; ly < n; ly++) {
				while (ry < n && Count(lx, rx, ly, ry) < k) ry++;
				if (ry < n) {
					int area = (sx[rx] - sx[lx]) * (sy[ry] - sy[ly]);	//スペルミス！！！
					ans = min(ans, area);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
import java.util.*;
import java.io.*;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;

/*
 * J - Sushi
 */
public class Main
{
double[][][] cache = new double[ 301 ][ 301 ][ 301 ];

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

private void initCache()
{
	for( int i = 0; i < 301; ++i )
	{
		for( int j = 0; j < 301; ++j )
		{
			for( int k = 0; k < 301; ++k )
			{
				cache[ i ][ j ][ k ] = -1;
			}
		}
	}
}

public void run() throws Exception
{
	initCache();
	final Scanner sc = new Scanner( getInputStream() );
	final int N = sc.nextInt();
	int[] data = new int[] { 0, 0, 0, 0 };
	for( int i = 0; i < N; ++i )
	{
		data[ sc.nextInt() ]++;
	}
	p( getE2( N, data ) );
}

/*
 * すばり回数の期待値を返す
 */
public double getE2( double dish_size, int[] data )
{
	double cached = cache[ data[ 0 ] ][ data[ 1 ] ][ data[ 2 ] ];
	if( cached != -1 )
	{
		return cached;
	}

	//0とそれ以外の比率を求める
	double count = 0;
	for( int i = 1; i <= 3; ++i )
	{
		count += data[ i ];
	}
	double p = count / (count + data[ 0 ]);
	if( p == 0 )
	{
		return 0;
	}

	double ex = 1 / p;//この状態で次の1つを消費するまでの回数の期待値

	//消費するそれぞれのパターンについて確率を求める
	for( int i = 3; i > 0; --i )
	{
		if( data[ i ] > 0 )
		{
			double patternRatio = data[ i ] / count;
			int[] data2 = Arrays.copyOf( data, data.length );
			data2[ i ]--;//今回選択されたものが減る
			data2[ i - 1 ]++;//1つ少ない数が増える
			ex += patternRatio * getE2( dish_size, data2 );
		}
	}

	//p( ex );

	cache[ data[ 0 ] ][ data[ 1 ] ][ data[ 2 ] ] = ex;
	return ex;
}

public static void p( Object o )
{
	System.out.println( o );
}

public static InputStream getInputStream() throws IOException
{
	//p( System.getProperties() );
	if( System.getProperty( "test" ) != null )
	{
		return new FileInputStream( "1" );
	}
	else
	{
		return System.in;
	}
}

}


Measured memory_bytes: 403320
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 9223372036854775807
#define N 8
int q[N];
int col[N];
int row[N];
int dpos[2 * N - 1];
int dneg[2 * N - 1];

void put(int y, int x)
{
    q[y] = x;
    col[x] = 0;
    row[y] = 0;
    dpos[x + y] = 0;
    dneg[y - x + (N - 1)] = 0;
}

void remove(int y, int x)
{
    q[y] = -1;
    col[x] = 1;
    row[y] = 1;
    dpos[x + y] = 1;
    dneg[y - x + (N - 1)] = 1;
}

bool canPut(int y, int x)
{
    return (col[x] && row[y] && dpos[x + y] && dneg[y - x + (N - 1)]);
}

void print()
{
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (q[i] == j)
                cout << 'Q';
            else
                cout << '.';
        }
        cout << endl;
    }
}

bool solve(int i)
{
    if (i == N)
        return true;

    if (q[i] != -1)
        return solve(i + 1);

    for (int j = 0; j < N; j++)
    {
        if (canPut(i, j))
        {
            put(i, j);
            if (solve(i + 1))
                return true;
            remove(i, j);
        }
    }

    return false;
}

signed main()
{
    for (int i = 0; i < N; i++)
    {
        q[i] = -1;
        col[i] = 1;
        row[i] = 1;
    }

    for (int i = 0; i < 2 * N - 1; i++)
        dpos[i] = dneg[i] = 1;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int y, x;
        cin >> y >> x;
        put(y, x);
    }
    solve(0);
    print();
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        if((i & 1) and (a & 1)) ans++;
    }
    cout << ans  << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main(){
	fast;
	ll a,b,c;
	cin>>a>>b>>c;
	ll d=c-(a-b);
	if(d<=0){
		cout<<0<<endl;
	} else cout<<d<<endl;
	return 0;
	return 0;
}/*『你强归你强，我永不示弱』*/


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right;
  }

  z->parent = y;
  if(y == NIL) {
    root = z;  
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else y->right = z;
}


void inorder(Node u){
  if(u->left != NIL){
    inorder(u->left);
  }
  printf(" %d",u->key);
  if(u->right != NIL){
    inorder(u->right);
  }

}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!= NIL){
    preorder(u->left);
  }
  if(u->right!= NIL){
    preorder(u->right);
  }
  
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24040
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			ArrayList<ArrayList<Boolean>> field = new ArrayList<>();
			String jfen = in.next();
			if(jfen.equals("#")) break;
			field.add(new ArrayList<Boolean>());
			for(int i=0;i<jfen.length();i++){
				char trg = jfen.charAt(i);
				if(trg=='/'){
					field.add(new ArrayList<Boolean>());
				}else if(trg=='b'){
					field.get(field.size()-1).add(true);
				}else{
					for(int j=0;j<trg-'0';j++){
						field.get(field.size()-1).add(false);
					}
				}
			}
			int[] s = {in.nextInt()-1,in.nextInt()-1};
			int[] g = {in.nextInt()-1,in.nextInt()-1};
			
			field.get(s[0]).set(s[1],false);
			field.get(g[0]).set(g[1],true);
			
			StringBuffer buffer = new StringBuffer();
			for(int i=0;i<field.size();i++){
				for(int j=0;j<field.get(i).size();j++){
					if(field.get(i).get(j)){
						buffer.append('b');
					}else{
						int count = 1;
						while(j+count<field.get(i).size() &&
								!field.get(i).get(j+count)){
							count ++;
						}
						buffer.append(count);
						j += count -1;
					}
				}
				buffer.append((i==field.size()-1)?"":'/');
			}
			System.out.println(buffer.toString());
		}
	}
}

Measured memory_bytes: 26684
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

string s;
int n;

void check(){
    bool f=1;
    if(s[1]=='0'||s[n]=='1') f=0;
    if(f){
        rep1(i,n-1){
            if(s[i]!=s[n-i]){
                f=0;
                break;
            }
        }
    }
    if(!f){
        cout1(-1)
        exit(0);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>s;
    n=s.size();
    s='0'+s;
    check();
    
    s[n]='1';
    int nxt=0;
    vector<pii> ans;
    rep1(i,n-1){
        while(i>=nxt||s[nxt]=='0') nxt++;
        ans.push_back({i,nxt});
    }
    
    for(auto p:ans){
        cout2(p.first,p.second)
    }
}

Measured memory_bytes: 2420
public class Main {

	public static void main(String[] args) {
		String str = new java.util.Scanner(System.in).nextLine();
		String[] array = str.split(" ");
		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);

		int menseki = a * b;
		int shuu = 2*a + 2*b;
		System.out.println(menseki + " " + shuu);

	}
}

Measured memory_bytes: 26220
a = {"1": 1, "2": 9, "3": 30, "4": 76, "5": 141, "6": 267, "7": 400, "8": 624, "9": 885, "10": 1249, "11": 1590, "12": 2208, "13": 2689, "14": 3411, "15": 4248, "16": 5248, "17": 6081, "18": 7485, "19": 8530, "20": 10248, "21": 11889, "22": 13687, "23": 15228, "24": 17988, "25": 20053, "26": 22569, "27": 25242, "28": 28588, "29": 31053, "30": 35463, "31": 38284, "32": 42540, "33": 46581, "34": 50893, "35": 55362, "36": 61824, "37": 65857, "38": 71247, "39": 76884, "40": 84388, "41": 89349, "42": 97881, "43": 103342, "44": 111528, "45": 120141, "46": 128047, "47": 134580, "48": 146316, "49": 154177, "50": 164817, "51": 174438, "52": 185836, "53": 194157, "54": 207927, "55": 218812, "56": 233268, "57": 245277, "58": 257857, "59": 268182, "60": 288216, "61": 299257, "62": 313635, "63": 330204, "64": 347836, "65": 362973, "66": 383709, "67": 397042, "68": 416448, "69": 434025, "70": 456967, "71": 471948, "72": 499740, "73": 515581, "74": 536073, "75": 559758, "76": 583960, "77": 604833, "78": 633651, "79": 652216, "80": 683712, "81": 709065, "82": 734233, "83": 754734, "84": 793188, "85": 818917, "86": 846603, "87": 874512, "88": 909496, "89": 933081, "90": 977145, "91": 1006126, "92": 1041504, "93": 1073385, "94": 1106467, "95": 1138536, "96": 1187112, "97": 1215145, "98": 1255101, "99": 1295142, "100": 1342852, "101": 1373253, "102": 1422195, "103": 1453816, "104": 1502376, "105": 1553361, "106": 1595437, "107": 1629570, "108": 1691292, "109": 1726717, "110": 1782111, "111": 1827492, "112": 1887772, "113": 1925853, "114": 1986837, "115": 2033674, "116": 2089776, "117": 2145333, "118": 2197483, "119": 2246640, "120": 2332104, "121": 2379085, "122": 2434833, "123": 2490534, "124": 2554600, "125": 2609625, "126": 2693919, "127": 2742052, "128": 2813988, "129": 2875245, "130": 2952085, "131": 3003306, "132": 3096024, "133": 3157249, "134": 3224511, "135": 3306240, "136": 3388576, "137": 3444609, "138": 3533637, "139": 3591322, "140": 3693924, "141": 3767085, "142": 3842623, "143": 3912324, "144": 4027884, "145": 4102093, "146": 4181949, "147": 4270422, "148": 4361548, "149": 4427853, "150": 4548003, "151": 4616104, "152": 4718640, "153": 4812789, "154": 4918561, "155": 5003286, "156": 5131848, "157": 5205481, "158": 5299011, "159": 5392008, "160": 5521384, "161": 5610705, "162": 5739009, "163": 5818390, "164": 5930196, "165": 6052893, "166": 6156139, "167": 6239472, "168": 6402720, "169": 6493681, "170": 6623853, "171": 6741078, "172": 6864016, "173": 6953457, "174": 7094451, "175": 7215016, "176": 7359936, "177": 7475145, "178": 7593865, "179": 7689630, "180": 7886244, "181": 7984165, "182": 8130747, "183": 8253888, "184": 8403448, "185": 8523897, "186": 8684853, "187": 8802826, "188": 8949612, "189": 9105537, "190": 9267595, "191": 9376656, "192": 9574704, "193": 9686065, "194": 9827097, "195": 9997134, "196": 10174780, "197": 10290813, "198": 10493367, "199": 10611772, "200": 10813692}

k = input().strip()
print(a[k])

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

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

  ll b_quotient = b / x;
  ll ans = 0;
  if (a == 0) {
    ans = b_quotient + 1;
  } else {
    ll a_quotient = (a - 1) / x;
    ans = b_quotient - a_quotient;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll n,m,c,ans,temp;
void solve()
{
   string s;cin>>s;
   n=s.size();
   for(int i=0;i<n;i++)
   {
       if(i%2)
       {
           if(s[i]!='1')
            temp++;
       }
       else
       {
           if(s[i]!='0')
            temp++;
       }
   }
   ans=temp;temp=0;
   for(int i=0;i<n;i++)
   {
       if(i%2==0)
       {
           if(s[i]!='1')
            temp++;
       }
       else
       {
           if(s[i]!='0')
            temp++;
       }
   }
   cout<<min(temp,ans)<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


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


def read():
    a, b = map(int, input().strip().split())
    return a, b


def solve(a, b):
    if a <= 0 and 0 <= b:
        return "Zero"
    minus = 0
    if b < 0:
        minus = abs(b - a) + 1
    return "Positive" if minus % 2 == 0 else "Negative"


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
 
int main(){
char a1,a2,a3,a4;
  cin >>a1>>a2>>a3>>a4;
  int syu =0;
  if(a1 ==a2) syu ++;
  if(a1 ==a3) syu ++;
  if(a1 ==a4) syu ++;
  if(a2 ==a3) syu ++;
  if(a3 ==a4) syu ++;
  if(a2 ==a4) syu ++;
  
  if(syu ==2) cout <<"Yes"<<endl;
  else cout <<"No"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define long long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }

const int N= 2010;
const int base= 924844033;
int n,f[2*N][N],k,m,c[2*N],md[2*N];
long gt[N];
void input()
{
    cin>>n>>k;
    m= 0; c[1]= 1;
    up(i,0,2*k-1)
    {
    	int j= i% k;
		m+= (n-1-j)/ k +1;
		c[m+1] = 1;
    }

}
int Add(int a,int b)
{
	return (a+b)% base;
}

void solve()
{
	f[0][0]= 1;
    up(i,1,2*n)
     up(j,0,n)
     {
     	f[i][j]= Add(f[i][j],f[i-1][j]);
     	if (j>0 and !c[i]) f[i][j]= Add(f[i][j],f[i-2][j-1]);
     }

    gt[0]= 1;
    up(i,1,n) gt[i]= gt[i-1]* i % base;
    long res= 0;
    up(k,0,n) res= Add(res, ( gt[n-k]* f[2*n][k]* ((k%2==0)?1:-1 ) % base+ base)% base );
    cout<< res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// don't use when interactive

    #ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
	#endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 31744