akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(RALL(x))
#define SUM(x) accumulate(ALL(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int n, k;
  cin >> n >> k;
  vi h(n);
  //rep(i,n) cin >> h[i];
  rep(i,n) scanf("%d", &h[i]);

  int ans = 0;
  rep(i,n) {
    if (h[i] >= k) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
    int K, r, i, j;
    long long tmp_lun;
    long long lun[100000] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    i = 0;
    j = 9;//ルンルン数の個数
    
    scanf("%d", &K);
    while(j < K){
        r = lun[i] % 10;
        tmp_lun = 10 * lun[i] + r;
        if(r > 0) lun[j++] = tmp_lun - 1;
        lun[j++] = tmp_lun;
        if(r < 9) lun[j++] = tmp_lun + 1;
        i++;
    }
    printf("%lld\n", lun[K-1]);

    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


int main()
{
	std::string S;
	std::string T;

	cin >> S >> T;

	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == T[i]) count++;
	}

	cout << count << '\n';

	return 0;
}



Measured memory_bytes: 256
// abc121_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll A, B;
    cin >> A >> B;

    ll x=0, y=0;

    auto func = [](int i, ll X){
        if (i == 0) return (X & 1) ^ ((X >> 1) & 1);

        ll tmp = ((X >> i) & 1) && !(X & 1);

        return tmp << i;
    };

    REP(i, 40){
        x += func(i, A-1);
        y += func(i, B);
    }

    ll ans = x ^ y;
    print(ans);


    return 0;
}


Measured memory_bytes: 256
def DFS(N, copyedge):
    matrix = [[] for i in range(N)]
    for a, b in copyedge:
        matrix[a].append(b)
        matrix[b].append(a) #aからb　bからaへの道を配列で作成
    check = [True]*N #checkは既に通った道をFalseとした
    check[0] = False
    Que = [0] #スタートは0から

    while len(Que) != 0:
        now = Que.pop() #スタート位置をpop
        for i in matrix[now]:
            if check[i] == True:
                check[i] = False
                Que.append(i) #スタート位置から直接行ける場所をスタート位置に加え、その位置を通過済みに
    if True not in check:
        return 0 #スタート位置が無くなった際に全ての位置を通っていれば（つまり道でなければ）0を出力
    else:
        return 1 #道なら1を出力


ans = 0
n, m = map(int,input().split())
edge = []

for i in range(m):
    edge.append([int(i) - 1 for i in input().split()])
for i in range(m):
    copyedge = edge[:i] + edge[i+1:]
    ans += DFS(n, copyedge)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#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 _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N = in();
  vector<string> S(N); vector<int> P(N);
  rep(i,N) cin >> S[i] >> P[i];
  map<string, map<int,int>> m;
  rep(i,N){
    m[S[i]][-P[i]] = i+1;
  }
  for(auto kv : m){
    for(auto kv2 : kv.second){
      dump(kv.first, kv2.first, kv2.second);
      cout << kv2.second << endl;
    }
  }
  return 0;
}


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

int main(){
  
  char c;

  cin >> c;

  switch (c) {
  case 'a':
  case 'e':
  case 'i':
  case 'o':
  case 'u':    
    cout << "vowel" << endl;
    break;

  default:
    cout << "consonant"  << "\n";
    break;
  }
  
  return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  string a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;
  char tmp = 'a';
  while(1){
    switch (tmp) {
      case 'a':
        if(a == ""){
          cout << "A" << endl;
          return 0;
        }
        tmp = (char)a[0];
        a.replace(0, 1, "");
        break;
      case 'b':
        if(b == ""){
          cout << "B" << endl;
          return 0;
        }
        tmp = (char)b[0];
        b.replace(0, 1, "");
        break;
        case 'c':
          if(c == ""){
            cout << "C" << endl;
            return 0;
          }
          tmp = (char)c[0];
          c.replace(0, 1, "");
          break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import math

def main():
    N = int(input())
    nums = list(map(int, input().split(' ')))
    n_max = nums[0]
    total = 0
    for i in nums:
        diff = n_max-i
        if diff<0:
            n_max=i
            diff=0
        total += diff
    print(total)

if __name__=="__main__":
  main()

Measured memory_bytes: 93112
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	ll N;
	cin >> N;
	
	ll k;
	for(ll i=N; i*(i+1)>=2*N; --i){
		k = i;
	}
	
	ll n=N;
	for(ll i=k; i>0; --i){
		if(n-i >= 0){
			cout << i << endl;
			n -= i;
		}
		if(n<=0) break;
	}
	
	
	
	return 0;
}

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

int main() {
  int a, b, k; cin >> a >> b >> k;
  if (b - a < 2 * k) {
    for (int i = a; i <= b; i++) cout << i << endl;
  } else {
    for (int i = a; i < a + k; i++) cout << i << endl;
    for (int i = b - k; i < b; i++) cout << i + 1 << endl;
  }
}

Measured memory_bytes: 256
from collections import defaultdict, deque


def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(M)]

    route = defaultdict(list)
    for ab in AB:
        route[ab[0]].append(ab[1])
        route[ab[1]].append(ab[0])

    ans = [-1] * N
    ans[0] = 0
    que = deque([1])

    # BFSを使って、目印を埋めていく
    while(len(que) != 0):
        v = que.popleft()

        for nv in route[v]:
            if ans[nv-1] != -1:
                continue

            ans[nv-1] = v
            que.append(nv)

    print('Yes')
    for i in range(1, N):
        print(ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 127496
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


ll dp[55][55][2501];

ll solve( int n, int K )
{
    memset(dp, 0, sizeof(dp));
    dp[0][0][0]=1;
    dp[0][1][2]=1;
    int i,j,p;
    for(i=0; i<n-1; i++) {
        for(j=0; j<=i+1; j++) {
            for(p=0; p<=K; p++) {
                if(dp[i][j][p]) {
                    if(j>0 && p+(j-1)*2<=K) {
                        dp[i+1][j-1][p+(j-1)*2] = (dp[i+1][j-1][p+(j-1)*2] + dp[i][j][p]*j*j)%MOD;
                    }
                    if(p+j*2<=K) {
                        dp[i+1][j][p+j*2] = (dp[i+1][j][p+j*2] + dp[i][j][p]*(j*2+1))%MOD;
                    }
                    if(p+(j+1)*2<=K) {
                        dp[i+1][j+1][p+(j+1)*2] = (dp[i+1][j+1][p+(j+1)*2] + dp[i][j][p])%MOD;
                    }
                }
            }
        }
    }
    return dp[n-1][0][K];
}

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

    if(K%2) {
        printf("0\n"); return 0;
    }
    if(n==1) {
        printf("1\n"); return 0;
    }

    ll ans = solve( n, K );
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 59264
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		String p = scan.nextLine();
		scan.close();
		String ring =s+s;
		if(ring.contains(p))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


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

ll dp[55][10005] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    dp[0][5000] = 1;
    rep(i,n){
        int x;
        cin >> x;
        rep(j,10000){
            dp[i+1][j+x-a] += dp[i][j];
            dp[i+1][j] += dp[i][j];
        }
    }
    ll ans = dp[n][5000] - 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7524
// ※※※ 解答不能 ※※※
// semiexp氏.
// https://atcoder.jp/contests/dwacon6th-prelims/submissions/9421084
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 1e9 + 7;
#define ADD(X,Y) ((X) = ((X) + (Y) % MOD) % MOD)

int X[101010];
LL invs[101010];
LL fact[101010], facti[101010], sums[101010];
LL modpow(LL x, int p = MOD - 2){
    if(p == 0) return 1;
    LL tmp = modpow(x, p / 2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * x % MOD;
    return tmp;
}

int main(){
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%d", X + i);
    repx(i, 1, N + 1) invs[i] = modpow(i);
    fact[0] = facti[0] = 1;
    repx(i, 1, N + 1){
        fact[i] = fact[i - 1] * i % MOD;
        facti[i] = facti[i - 1] * invs[i] % MOD;
    }
    sums[0] = 0;
    repx(i, 1, N + 1) sums[i] = (sums[i - 1] + invs[i]) % MOD;
    LL ret = 0;
    repx(i, 1, N) ADD(ret, (X[i] - X[i - 1]) * sums[i]);
    ret = ret * fact[N - 1] % MOD;
    printf("%lld\n", ret);
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define ll long long
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()
using namespace std;

ll dp[10000],n;
int main() {
    dp[0]=1;
    dp[1]=1;
    cin>>n;
    rep(i,n){
        dp[i+2]=dp[i]+dp[i+1];
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <deque>
#include <cassert>

using namespace std;

int main() {
  int q;
  cin >> q;
  deque<int> a;
  while(q--) {
    int t;
    cin >> t;
    if(t == 0) {
      int d, x;
      cin >> d >> x;
      if(d == 0) a.push_front(x);
      else if(d == 1) a.push_back(x);
      else assert(false);
    } else if(t == 1) {
      int p;
      cin >> p;
      cout << a.at(p) << endl;
    } else if(t == 2) {
      int d;
      cin >> d;
      if(d == 0) a.pop_front();
      else if(d == 1) a.pop_back();
      else assert(false);
    } else {
      assert(false);
    }
  }
  return 0;
}



Measured memory_bytes: 4540
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define PI acos(-1)
using namespace std;
int main(){
double x=0,y=0,ka=PI/2;
int ho,kai;
char d;
while(cin>>ho>>d>>kai,ho||kai){
x+=ho*cos(ka);
y+=ho*sin(ka);
ka-=PI/180*kai;
}
//cout<<(double)sin(0)<<endl;
cout<<(int)x<<endl<<(int)y<<endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int f(int x,int y)
{
    return x<y?y-x:x-y;
}
int main()
{
    int n,l,sum=0,a[100000],ans=0,cha=10000000;
    cin>>n>>l;
    for(int i=1; i<=n; i++)
    {
        a[i]=l+i-1;
        sum+=a[i];
    }
    for(int i=1; i<=n; i++)
        if(f(sum-a[i],sum)<cha)
        {
            cha=f(sum-a[i],sum);
            ans=sum-a[i];
        }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
int main() {
    ll N, W; cin >> N >> W;
    ll ans = 0;
    map<ll, ll> mp;
    rep(i, N) {
        ll w, v; cin >> w >> v;
        vector<P> pp;//post-processing
        for(auto it=mp.begin(); it!=mp.end(); it++) {
            ll ww = it->first;
            ll vv = it->second;
            if(ww+w<=W&&mp[ww+w]<vv+v) {
                //mp[ww+w] = vv + v;
                pp.emplace_back(ww+w, vv+v);
                ans = max(ans, vv+v);
            }
        }
        rep(j, pp.size()) {
            mp[pp[j].first] = pp[j].second;
        }
        if(v > mp[w] && w <= W) {
            mp[w] = v;
            ans = max(ans, v);
        }
    }
    cout << ans;
}


Measured memory_bytes: 640
A, B, C, D = map(int, input().split(' '))
start = 0
end = 0

if B <= C or D <= A:
    print(0)
    exit()

if A < C:
    start = C
else:
    start = A

if B < D:
    end = B
else:
    end = D

print(end - start)


Measured memory_bytes: 2940
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	string s;
	int al[26];
	cin>>s;
	for(int i=0;i<26;i++) al[i]=0;
	for(int i=0;s[i]!='\0';i++){
		al[s[i]-'a']=1;
	}
	for(int i=0;i<26;i++){
		if(al[i]==0){
			cout<<(char)(i+'a')<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 512
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:input()

"""========main code==============="""

t=ii()
ans=0
for i in range(1,t+1):
    for j in range(1,t+1):
        for k in range(1,t+1):
            ans+=math.gcd(math.gcd(i,j),k)
print(ans)            

Measured memory_bytes: 68444
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] V = new int[N];
		int ans = 0;
		for (int i = 0; i < N; i++) {
			V[i] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			int dif = V[i] - sc.nextInt();;
			if (dif > 0) {
				ans += dif;
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

Measured memory_bytes: 23252
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut itr = buf.split_whitespace().map(|i| i.parse::<i64>().unwrap());
    let h = itr.next().unwrap();
    let w = itr.next().unwrap();

    let mut ans = h*w;
    for &(x, y) in vec![(h, w), (w, h)].iter() {
        for t in 1..x {
            // 縦3分割
            let s_1 = t*y;
            let s_2 = (x-t)/2*y;
            let s_3 = (x-t)*y - s_2;
            let s_max = if s_1 > s_2 && s_1 > s_3 { s_1 } else if s_2 > s_3 { s_2 } else { s_3 };
            let s_min = if s_1 < s_2 && s_1 < s_3 { s_1 } else if s_2 < s_3 { s_2 } else { s_3 };
            let dif = s_max - s_min;
            if ans > dif { ans = dif; }

            // 縦横
            let s_1 = t*y;
            let s_2 = (x-t)*(y/2);
            let s_3 = (x-t)*y - s_2;
            let s_max = if s_1 > s_2 && s_1 > s_3 { s_1 } else if s_2 > s_3 { s_2 } else { s_3 };
            let s_min = if s_1 < s_2 && s_1 < s_3 { s_1 } else if s_2 < s_3 { s_2 } else { s_3 };
            let dif = s_max - s_min;
            if ans > dif { ans = dif; }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
loop :: Int -> Int -> Int -> [String]
loop x' x y = if x > 0 then (take y $ drop (x'-x) $ concat $ replicate 1000 "#.") : loop x' (x - 1) y else [""]

solve :: [Int] -> [String]
solve (x : y : xs)
  | x == 0 && y == 0 = []
  | otherwise = loop x x y ++ solve xs

main = getContents >>= mapM_ putStrLn . solve . map read . words

Measured memory_bytes: 4956
#include<stdio.h>
 
 
int gcd( int x, int y )
{
    int t;
    while( 0 < y ) {
        t = y;
        y = x % y;
        x = t;
    }
     
    return x;
}
 
int main( )
{   
    int x, y;
      
    scanf( "%d%d", &x, &y );
      
    int t;
    if( y <= x ) {
        t = x;
        x = y;
        y = t;
    }
      
    printf( "%d\n", gcd( x, y ) );
     
    return 0;
}

Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

bool sub(string a);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    string str;
    cin >> str;

    if(!sub(str))
    {
        cout << "No" << endl;
        return 0;
    }

    string sub1, sub2;
    sub1 = str.substr(0, str.size()/2);
    sub2 = str.substr(str.size()/2+1, str.size()/2);

    if(!sub(sub1))
    {
        cout << "No" << endl;
        return 0;
    }
    if(!sub(sub2))
    {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}

bool sub(string a)
{
    for(LL i=0; i<a.size(); i++)
    {
        if(i>(a.size() / 2))
        {
            break;
        }
        if(a.at(i) != a.at(a.size()-1-i))
        {
            return false;
        }
    }
    return true;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstring>
#include <queue>
#include<map>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}

ll fact(int n,int d)
{
	ll ans=0;
	int i=1;
	for(i=2;i*i<n;i++)
	{
		
		if(n%i==0)
		{
			char n1= (i+'0');
			char n2= (n/i+'0');
			
			string s1="",s2="";
			s1+=n1;
			s1+=n2;
			
			s2+=n2;
			s2+=n1;
			
			int num1= atoi(s1.c_str());
			int num2= atoi(s2.c_str());
			
			if(i>=2&&i<=9&&n/i<=9&&n/i>=2&&(num1<=d))
			ans++;
			
			if(i>=2&&i<=9&&n/i<=9&&n/i>=2&&(num2<=d))
			ans++;
		}
	}
	
	if(i*i==n)
	{
		char n1= (i+'0');

			string s1="";
			s1+=n1;
			s1+=n1;
			int num1= atoi(s1.c_str());
			
		if(i>=2&&i<=9&&n/i<=9&&n/i>=2&&num1<=d)
			ans++;
	}
	return ans;
}

	
	
	
	
	
	
	
	
	

int main()
{
	int m,d;

	cin>>m>>d;
	ll ans=0;
	for(int i=4;i<=m;i++)
	{
		
		ans+=fact(i,d);
		
	}
	
	cout<<ans<<endl;
}
	




Measured memory_bytes: 256
n,k=map(int,input().split())
lst=[list(map(int,input().split())) for i in range(k)]
mod=998244353

dp=[0]*(2*n+10)
dp[0]=1
dp[1]=-1
for i in range(n):
    for l,r in lst:
        dp[i+l]+=dp[i]
        dp[i+r+1]-=dp[i]
    
    dp[i+1]+=dp[i]
    dp[i+1]%=mod


print(dp[n-1])

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

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

    string ans = "Yes";
    if(s[2] != s[3]){
        ans = "No";
    }
    if(s[4] != s[5]){
        ans = "No";
    }

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

Measured memory_bytes: 256
h,w,a,b = map(int,input().split())
li = [[0]*w for _ in range(h)]

for i in range(b):
    for j in range(a):
        li[i][j] = 1
for i in range(b,h):
    for j in range(a,w):
        li[i][j] = 1

for i in range(h):
    for j in range(w):
        print(li[i][j],end = '')
    print()


Measured memory_bytes: 13300
#include <stdio.h>
int main(void){
    int p,q,r;
    scanf("%d%d%d", &p, &q, &r);
    if(p > q && p > r){
        printf("%d",q+r);
    }
    else if(q >= p && q > r){
        printf("%d", p+r);
    }
    else {
        printf("%d", p+q);
    }
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			double[] arr = Console.ReadLine().Trim().Split(' ').Select(hogehoge => double.Parse(hogehoge)).ToArray<double>();

			double a = arr[0];
			double b = arr[1];
			double x = arr[2];

			double h = 2 * (b - (x / Math.Pow(a, 2)));

			if (h < b)
			{
				double angle = Math.Atan2(h, a) * 180 / Math.PI;

				Console.WriteLine(angle);
			}
			else
			{
				double w = 2 * (x / a / b);

				double angle = Math.Atan2(b, w) * 180 / Math.PI;
			
				Console.WriteLine(angle);

			}


			return;
		}
	}

}


Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int x,y;
	cin >> x >> y;
	int ans=2000000000;
	if(y==x)
		ans=0;
	else if(y>x)
		ans=min(ans,y-x);

	x*=(-1);
	if(y==x)
		ans=min(ans,0+1);
	else if(y>x)
		ans=min(ans,y-x+1);

	y*=(-1);
	if(y==x)
		ans=min(ans,0+2);
	else if(y>x)
		ans=min(ans,y-x+2);

	x*=(-1);	
	if(y==x)
		ans=min(ans,0+1);
	else if(y>x)
		ans=min(ans,y-x+1);

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pr pair <ll,ll> 
#define ff first
#define ss second
#define MP make_pair
#define PB push_back
#define pri 1000000007
#define mn 25
#define sz noofnodes +2
#define all(x) x.begin(),x.end()
using namespace std;

void masterstroke()
{   

	ll n;
	cin>>n;
	ll a[n];
	vector <ll> mi,pl;
	ll ze=0,mini=pri;
	ll M=0;
	
	for(ll i=0;i<n;i++){
		cin>>a[i];
		if(a[i]<0){mi.PB(a[i]);}
		else if(a[i]>0){pl.PB(a[i]);}
		else ze++;
		
		M+=abs(a[i]);
		mini=min(mini,abs(a[i]));
	}
//	cout<<M<<mini<<endl;
	if(((int)mi.size()==0&&(int)pl.size()==0))
	{
		cout<<0<<endl;
		for(ll i=0;i<n-1;i++){
			cout<<0<<" "<<0<<endl;
		}
	}
	else if(ze!=0||((int)mi.size()>0&&(int)pl.size()>0)){
		cout<<M<<endl;
		
		if((int)pl.size()==0){
			while(ze--){pl.PB(0);}
		}
		else{
			while(ze--){mi.PB(0);}
		}
		while((int)mi.size()!=1){
			ll x1=pl.back();
			pl.pop_back();
			ll y1=mi.back();
			mi.pop_back();
			cout<<x1<<" "<<y1<<endl;
			pl.PB(x1-y1);
		}
		
	   while((int)pl.size()>1){
			ll x1=mi[0];
			ll y1=pl.back();
			cout<<x1<<" "<<y1<<endl;
			mi.pop_back();
			pl.pop_back();
			mi.PB(x1-y1);
		}
		
		
		cout<<pl[0]<<" "<<mi[0];
		
	}
	else{
		cout<<(M-(2ll)*mini)<<endl;
		if(mi.size()==0){
			if(pl.size()==2){
			  cout<<max(pl[0],pl[1])<<" "<<min(pl[0],pl[1])<<endl;
			  return;
			}
			else{
				
			     sort(all(pl));
			     reverse(all(pl));
			     
			     ll x1=pl.back();
			     pl.pop_back();
			     ll y1=pl.back();
			     pl.pop_back();
			     
			     cout<<x1<<" "<<y1<<endl;
			     mi.PB(x1-y1);
                  while(pl.size()>1){
								ll x1=mi[0];
								ll y1=pl.back();
								cout<<x1<<" "<<y1<<endl;
								mi.pop_back();
								pl.pop_back();
								mi.PB(x1-y1);
						}
			     
					cout<<pl[0]<<" "<<mi[0];
			}
			
		}
		else{
				if(mi.size()==2){
						cout<<max(mi[0],mi[1])<<" "<<min(mi[0],mi[1])<<endl;
							return;
			}
			else{
				 sort(all(mi));
			     ll x1=mi.back();
			     mi.pop_back();
			     ll y1=mi.back();
			     mi.pop_back();
			     cout<<x1<<" "<<y1<<endl;
			     pl.PB(x1-y1);
				 	while((int)mi.size()!=1){
								ll x1=pl.back();
								pl.pop_back();
								ll y1=mi.back();
								mi.pop_back();
								cout<<x1<<" "<<y1<<endl;
								pl.PB(x1-y1);
							}
		
					 while(pl.size()>1){
								ll x1=mi[0];
								ll y1=pl.back();
								cout<<x1<<" "<<y1<<endl;
								mi.pop_back();
								pl.pop_back();
								mi.PB(x1-y1);
								}
		
		
					cout<<pl[0]<<" "<<mi[0]<<endl;
				
				
				
			}
			
		}
		
		
	}
	
	
	
}

int main(){

	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)
	masterstroke();

}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int i,n,n2,count;
    count=0;
    cin >> n;
    n2=n;
    for(i=0;i<10;i++){
        if (n2/10 >0) {
            n2 = n2/10;
            count++;
        }
        else break;
    }
    if(count==0){
        cout<<n<<endl;
    }
    else if(count==1){
        cout<<9<<endl;
    }
    else if(count==2){
        i=n-99;
        cout<<9+i<<endl;
    }
    else if(count==3){
        cout<<909<<endl;
    }
    else if(count==4){
        i=n-9999;
        cout<<909+i<<endl;
    }
    else{
        cout<<90909<<endl;
    }

}

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

int main()
{
    int a[3][3],n,i,j,k;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    cin>>n;
    int b[n];
    for(i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            for(k=0;k<3;k++)
            {
                if(b[i]==a[j][k])
                {
                    a[j][k]=-1;
                }
            }
        }
    }
    int flag=0;
    if(a[0][0]==-1 and a[0][1]==-1 and a[0][2]==-1)
    {
        flag=1;
    }
    else if(a[1][0]==-1 and a[1][1]==-1 and a[1][2]==-1)
    {
        flag=1;
    }
    
    else if(a[2][0]==-1 and a[2][1]==-1 and a[2][2]==-1)
    {
        flag=1;
    }
    else if(a[0][0]==-1 and a[1][0]==-1 and a[2][0]==-1)
    {
        flag=1;
    }
    else if(a[0][1]==-1 and a[1][1]==-1 and a[2][1]==-1)
    {
        flag=1;
    }
    else if(a[0][2]==-1 and a[1][2]==-1 and a[2][2]==-1)
    {
        flag=1;
    }
    else if(a[0][0]==-1 and a[1][1]==-1 and a[2][2]==-1)
    {
        flag=1;
    }
    else if(a[0][2]==-1 and a[1][1]==-1 and a[2][0]==-1)
    {
        flag=1;
    }
    else
    flag=0;
    if(flag==1)
    {
        cout<<"Yes";
    }
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

int main() {
	int x = 1, i = 1;
	while (x != 0) {
		cin >> x;
		if (x == 0) {
			break;
		}
		cout << "Case " << i << ": " << x << endl;
		i++;
	}
}


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

int main(){
    int p, q, r;
    cin >> p >> q >> r;
    int ans = min(min(p + q, q + r), r + p);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>

int main(void)
{
    int a, b, c = 0;
    int k = 0;
    int m, n = 0;
    int tmpm = 0;
    int tmpn = 0;
    int judge = 0;

    scanf("%d %d %d", &a, &b , &c);
    scanf("%d", &k);

    tmpm = b;
    tmpn = c;
    for (m = 0; m < k; m++) {
        for (n = m; n < k; n++) {
            tmpn = tmpn * 2;
            if (tmpm > a && tmpn > tmpm) {
                judge = 1;
                goto end;
            }
        }
        tmpn = c;
        tmpm = tmpm * 2;
        if (tmpm > a && tmpn > tmpm) {
            judge = 1;
            goto end;
        }
    }

end:
    if (judge) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}


Measured memory_bytes: 1664
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  int a, b, x;
  cin>>x>>a>>b;
  if(a>=b)
    std::cout << "delicious" << std::endl;
  else if(b-a <= x)
    std::cout << "safe" << std::endl;
  else
    std::cout << "dangerous" << std::endl;
  return 0;
}


Measured memory_bytes: 504
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



long long int numk(vector<long long int> &a,long long int x){
	int n = a.size();
	long long int k = 0;
	rep(i, n)
	{
		if (a[i] < 0){
			long long int l = -1, r = n;
			while(l+1<r){
				long long int m = (l + r) / 2;
				if(a[i] * a[m] < x)
					r = m;
				else
					l = m;
			}
			k += n - r;
		}
		else
		{
			long long int l = -1, r = n;
			while(l+1<r){
				long long int m = (l + r) / 2;
				if(a[i] * a[m] < x)
					l = m;
				else
					r = m;
			}
			k += r;
		}
		if (a[i]*a[i] < x)
			k--;
		// cout << a[i] <<" : " << k << endl;
	}
	if (k % 2 == 1)
		cout << "wrong" << endl;
	k = k / 2;
	return k;
}

int main()
{
	int n;
	long long int k;
	cin >> n >> k;
	vector<long long int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));

	long long int l = -1e18, r = 1e18;
	while(l + 1 < r){
		long long int mid = (l + r) / 2;
		long long int nk = numk(a, mid);
		// cout << "x:" << mid  <<" nk:" << nk << endl;
		if (k <= nk)
			r = mid;
		else
			l = mid;
		// break;
	}
	cout << l << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    string s;
    cin >> s;
    int ss = s.length();
    int ans = 0;
    rep(i, int(ss/2)){
        if(s[i] != s[ss-1-i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
int N;
vector<P> G;
void no() {
    cout<<-1<<endl;
    exit(0);
}
int main() {
    cout.precision(15);
    cout << fixed;
    string S;
    cin >> S;
    N=S.size();
    // check
    if (S[0]!='1'||S[N-1]!='0')no();
    for(int i=0;i<N-1;++i) {
        if (S[i]!=S[N-i-2])no();
    }
    //
    int p=0,c=1;
    while(c<N) {
       if (S[c-1]=='1') {
           G.pb({p,c});
           p=c;
       } else {
           G.pb({p,c});
       }
       c++;
    }
    REP(i,N-1) {
        cout<<G[i].fi+1 << " " << G[i].se+1<<endl;
    }


}


Measured memory_bytes: 3312
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1e9+7;
ll fac[100001];
ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}
bool comp(PI a,PI b){
    return b.F<a.F;
}

int main(){
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;
    if(m==n)cout<<"Yes";
    else cout<<"No";

	return 0;
}


Measured memory_bytes: 256
#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;

ll sumtoN(ll n){
  if(n%2==0){
    return (n/2)*(n+1) % mod;
  }
  else{
    return (((n-1)/2)*n+n) % mod;
  }
}

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  ll ans = 0;
  vector<ll> tentou(N,0);
  vector<ll> tentou_all(N,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i==j) continue;
      if(A[i] > A[j]){
        tentou_all[i]++;
        if(i<j) tentou[i]++;
      }
    }
  }
  rep(i,N){
    //cout << tentou[i]  << " " << tentou_all[i] << endl;
  }

  for(int i=0;i<N;i++){
    ans += tentou[i]*sumtoN(K);
    ans %= mod;
    ans += (tentou_all[i]-tentou[i])*sumtoN((K-1));
    ans %= mod;
  }


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


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long ans = -100100100100L;
		for(long i = 0 ; i <= n ; i++) {
			if(i * i <= n) {
				ans = Math.max(ans, i * i);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
#include <stdio.h>
int main() {
  int m, f, r;
  int x;
  while(1) {
    scanf("%d %d %d", &m , &f , &r);
    x = m + f;
    if(m == -1 && f ==-1 && r == -1)break;
    if(m == -1 || f == -1) 
      printf("F\n");
    else if(x >= 80) {
      printf("A\n");
    } else if (x >= 65) {
      printf("B\n");
    } else if(x >= 50) {
      printf("C\n");
    } else if ( x >=30) {
      if(r >= 50) {
    printf("C\n");
      } else {
    printf("D\n");
      }
    } else if (x < 30) {
      printf("F\n");
    }
  }
  return 0;
}


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

#define llong long long 
int N;
int res[1001];
int score[1001][2][2][2][2][2][2];

int solve(int day, int J, int O, int I, int yJ, int yO, int yI){
	if(day != 0){
		int p = res[day];
		if(p == 0){
			if(J == 0) return score[day][J][O][I][yJ][yO][yI] = 0;
		}else if(p == 1){
			if(O == 0) return score[day][J][O][I][yJ][yO][yI] = 0;
		}else if(p == 2){
			if(I == 0) return score[day][J][O][I][yJ][yO][yI] = 0;
		}
	}

	if(day > 0){
		bool check = false;
		if(yJ == 1 && J == 1) check = true;
		if(yO == 1 && O == 1) check = true;
		if(yI == 1 && I == 1) check = true;

		if(check == false) return score[day][J][O][I][yJ][yO][yI] = 0;
	}
	// cout << day << " " << J << " " << O << " " << I << " " << yJ << " " << yO << " " << yI << " " << score[day][J][O][I][yJ][yO][yI] << endl;
	if(score[day][J][O][I][yJ][yO][yI] != -1) return score[day][J][O][I][yJ][yO][yI];
	if(day == N) return score[day][J][O][I][yJ][yO][yI] = 1;



	int ret = 0;
	if(day != 0){
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < 2; j++){
				for(int k = 0; k < 2; k++){
					ret += solve(day + 1, i, j, k, J, O, I) % 10007; 
				}
			}
		}
	}else{
		for(int j = 0; j < 2; j++){
			for(int k = 0; k < 2; k++){
				ret += solve(1, 1, j, k, 1, O, I) % 10007;
			}
		}
	}

	return score[day][J][O][I][yJ][yO][yI] = ret % 10007;
}


int main(){
	fill_n(******score, 1001 * 2 * 2 * 2 * 2 * 2 * 2, -1);
	fill_n(res, 1001, -1);
	cin >> N;
	char in[1000];
	cin >> in;
	for(int i = 0; i < N; i++){	
		if(in[i] == 'J') res[i + 1] = 0;
		else if(in[i] == 'O') res[i + 1] = 1;
		else if(in[i] == 'I') res[i + 1] = 2;
	}


	cout << solve(0, 0, 0, 0, 0, 0, 0) << endl;

	return 0;
}

Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a + w >= b && a <= b + w) {
            System.out.println(0);
            return;
        }
        if (a + w < b) {
            System.out.println(b - (a + w));
            return;
        }
        System.out.println(a - (b + w));
    }

}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[n-1];
		int ans = 0;

		for(int i = 0;i<n;i++){
			a[i] = sc.nextInt();
		}
		for(int i = 0;i<n;i++){
			b[i] = sc.nextInt();
		}
		for(int i = 0;i<n-1;i++){
			c[i] = sc.nextInt();
		}
		sc.close();

		for(int i = 0;i<n;i++){
			ans += b[a[i]-1];
			if(i !=0 && a[i]-a[i - 1] == 1){
				ans += c[a[i -1]-1];
			}
		}

System.out.println(ans);
	}
}

Measured memory_bytes: 22740
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#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>
#include <functional>
using namespace std;

vector<int> len;
vector<map<int, int> > value;

int dfs(string& s, int& k)
{
    if(isdigit(s[k])){
        int ret = 0;
        while(k < s.size() && isdigit(s[k])){
            ret *= 10;
            ret += s[k] - '0';
            ++ k;
        }
        return ret;
    }

    char c = s[k];
    k += 2;
    int a = dfs(s, k);
    ++ k;

    if(k < s.size() && s[k] == '='){
        ++ k;
        if(a == -1 || a >= len[c])
            return -1;
        else
            return value[c][a] = dfs(s, k);
    }else{
        if(a == -1 || value[c].find(a) == value[c].end())
            return -1;
        else
            return value[c][a];
    }
}

bool substitute (string& s)
{
    char c=s[0];
    int k=2;
    int a=dfs(s,k);
    if(a==-1 || len[c]<=a) return false;
 
    k += 2;
    int res=dfs(s,k);
    if(res == -1)
        return false;
    value[c][a]=res;
    return true;
}

int solve(vector<string>& s)
{
    len.assign(128, 0);
    value.assign(128, map<int, int>());

    int n = s.size();
    for(int i=0; i<n; ++i){
        if(s[i].find('=') == string::npos){
            int k = 2;
            len[s[i][0]] = dfs(s[i], k);
        }else{
            int k = 0;
            if(!substitute(s[i]))
                return i + 1;
        }
    }

    return 0;
}

int main()
{
    for(;;){
        vector<string> s;
        for(;;){
            string t;
            cin >> t;
            if(t == ".")
                break;
            s.push_back(t);
        }

        if(s.empty())
            return 0;

        cout << solve(s) << endl;
    }
}

Measured memory_bytes: 1340