akhauriyash/Code-Regression huggingface dataset:
/* AtCoder Beginner Contest abc128
 * Problem A
 * Au: SJoshua
 */
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>

using namespace std;

int main(void) {
	int A, P;
	cin >> A >> P;
	cout << (A * 3 + P) / 2 << endl;
	return 0;
}


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

int main(){
	int n,m;
	cin >> n >>m;
	priority_queue<ll> q;
	ll a;
	rep(i,n){
		cin >> a;
		q.push(a);
	}
	rep(i,m){
		a = q.top();q.pop();
		a = a>>1;
		q.push(a);
	}
	ll ans(0);
	rep(i,n){
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String s = br.readLine();
		int a = 0, b = n;
		while(a+1 < b) {
			int c = (a+b)/2;
			if(check(c, s, n)) {
				a = c;
			}
			else {
				b = c;
			}
		}
		System.out.println(a);
	}
	static boolean check(int len, String s, int n) {
		HashMap<String, MinMax> map = new HashMap<>();
		for(int i = 0; i + len <= n; i++) {
			String t = s.substring(i, i+len);
			if(map.containsKey(t)) {
				map.get(t).add(i);
			}
			else {
				map.put(t, new MinMax(i));
			}
		}
		for(String t: map.keySet()) {
			MinMax p = map.get(t);
			if(p.min + len <= p.max) {
				return true;
			}
		}
		return false;
	}
	static class MinMax{
		int min, max;
		public MinMax(int k) {
			min = k; max = k;
		}
		public void add(int k) {
			if(k < min) min = k;
			if(k > max) max = k;
		}
		public String toString() {
			return min+"/"+max;
		}
	}

}


Measured memory_bytes: 136204
package main

import "fmt"

var N int
var P []int

func main() {
    fmt.Scan(&N)
    P = make([]int, N)
    for i := range P {
        fmt.Scan(&P[i])
    }
  
    min := N + 100
    ans := 0
  
    for i := range P {
        if min > P[i] {
          min = P[i]
          ans ++
        }  
    }

    fmt.Println(ans)
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
ll round_up(ll a, ll b) {
  return (a + b - 1) / b;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int a,b;
    cin >> a >> b;
    int an = min(a,b);
    int mi = max(a,b);
    int ans = 0;
    int tmp = 1;
    rep(i,mi){
      ans += an * tmp;
      tmp *= 10;
    }
    print(ans);
}


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

int main() {
	int N; cin >> N;
	multiset<int> ms;
	set<int> st;
	for (int i = 0; i < N; i++) {
		int v; cin >> v;
		ms.insert(v);
		st.insert(v);		
	}
	int res = 0;
	for (auto itr = st.begin(); itr != st.end(); itr++) {
		int dif = ms.count(*itr) - *itr;
		if (dif >= 0) res += dif;
		else res += ms.count(*itr);
	}
	cout << res << endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 9216
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<complex>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll d,n;
	cin>>d>>n;
	if(d==0) {
		if(n!=100) cout<<n<<endl;
		else cout<<101<<endl;
	}
	else if(d==1) {
		if(n!=100) cout<<n*100<<endl;
		else cout<<101*100<<endl;
	}
	else {
		if(n!=100) cout<<n*10000<<endl;
		else cout<<101*10000<<endl;
	}
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    int r[n] = {};
    while(m--){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        r[a]++;
        r[b]++;
    }
    for(int i=0; i<n; i++) cout << r[i] << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, *AB = map(int, read().split())
    ans = [0] * N
    for a, b in zip(*[iter(AB)] * 2):
        ans[a - 1] += 1
        ans[b - 1] += 1

    print(*ans, sep='\n')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 62096
#include<iostream>
#include<array>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
const int MAX_V = 1001;
array<array<int, MAX_V>,MAX_V> ary;
string strx,stry;
int minimum(int x,int y){
  int res=strx[x-1]==stry[y-1]?ary[x-1][y-1]+1:ary[x-1][y-1];
  if(res<ary[x][y-1]) res=ary[x][y-1];
  if(res<ary[x-1][y]) res=ary[x-1][y];
  return res;
}

int main(){
  int n; cin>>n;
  REP(i,n){
    cin>>strx>>stry;
    int sizex=strx.size(),sizey=stry.size();
    REP(j,sizex)
      REP(k,sizey)
        ary[j+1][k+1]=minimum(j+1,k+1);
    cout<<ary[strx.size()][stry.size()]<<endl;
  }
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
namespace mint {
  constexpr int md = 1e9 + 7;
  inline void add (int &a, int b) {
    a += b; if (a >= md) a -= md;
  }
  inline void sub (int &a, int b) {
    a -= b; if (a < 0) a += md;
  }
  inline int sum (int a, int b) {
    add(a, b); return a;
  }
  inline int dif (int a, int b) {
    sub(a, b); return a;
  }
  // inline int prod (int a, int b) {
  //   return (int)((long long)a * b % md);
  // }
  template<class... A>
  inline int prod (A... args) {
    long long ret = 1;
    for (int a : initializer_list<int>{args...}) {
      ret *= a;
    }
    return (int)(ret % md);
  }
  inline void mul (int &a, int b) {
    a = prod(a, b);
  }
  inline int inv (int a) {
    a %= md;
    if(a < 0) a += md;
    int b = md, u = 0, v = 1;
    while (a) {
      int t = b / a;
      b -= a * t; swap(a, b);
      u -= v * t; swap(u, v);
    }
    assert(b == 1);
    if(u < 0) u += md;
    return u;
  }
  inline int quat (int a, int b) {
    return prod(a, inv(b));
  }
  inline void div (int& a, int b) {
    a = quat(a, b);
  }
  inline int pow (int a, long long b) {
    int res = 1;
    for (; b; b >>= 1) {
      if (b & 1) mul(res, a);
      mul(a, a);
    }
    return res;
  }
}
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>> dp(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dp[i][j] = a[i] > a[j] ? 1 : 0;
    }
  }
  int inv2 = mint::inv(2);
  int coeff = mint::pow(2, q);
  while (q--) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    auto half = [&] (int& a, int& b) -> void {
      mint::add(a, b);
      a = b = mint::prod(a, inv2);
    };
    half(dp[x][y], dp[y][x]);
    for (int z = 0; z < n; z++) if (z != x && z != y) {
      half(dp[x][z], dp[y][z]);
      half(dp[z][x], dp[z][y]);
    }
  }
  int ret = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      mint::mul(dp[i][j], coeff);
      mint::add(ret, dp[i][j]);
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 35584
// A - Changing a Character
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n,k; string s; cin>>n>>k>>s;
	for(int i=1; i<=n; ++i) if(i==k) s[i-1] -= 'A'-'a';
	cout<< s <<endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

cnt = 0
two = 0
for i in range(n):
    if a[i] % 4 == 0:
        cnt += 1
    elif a[i] % 2 == 0:
        two += 1

if cnt >= n//2:
    print('Yes')
else:
    if n - cnt*2 <= two:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14252
#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 mod = 998244353;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    mint choose(int n, int a){
        mint x = 1 ,y = 1;
        for(int i = 0; i < a; ++i){
            x *= n-i;
            y *= i+1;
        }
        return x / y;
    }
    friend istream& operator>>(istream& is, mint& m){
        is >> m.x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

mint dp[3010][3010][4];

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

  dp[0][0][0]=1;
  for(int i=0; i<n; ++i){
    for(int j=0; j<=s; ++j){
      for(int k=0; k<=2; ++k){
        if(a[i]+j<=s){
          if(k==0)dp[i+1][j+a[i]][k+2]+=dp[i][j][k];
          if(k==1)dp[i+1][j+a[i]][k]+=dp[i][j][k];
          dp[i+1][j+a[i]][k+1]+=dp[i][j][k];
        }
        dp[i+1][j][k]+=dp[i][j][k];
        dp[i+1][j][k+1]+=dp[i][j][k];
      }
    }
  }
  cout<<dp[n][s][2]<<endl;
  /*rep(k,3){
      rep(j,s+1){
          rep(i,n+1){
              cout<<dp[i][j][k]<<" ";
          }
          cout<<endl;
      }
      cout<<endl;
  }*/
}

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

string S;
ll ans = 0;

int keta(ll num) {
	int ret = 0;
	while (num > 0) {
		ret++;
		num /= 10;
	}
	return ret;
}


ll mystoi(string s) {
	ll ten = 1;
	ll ans = 0;
	for (int i=s.length()-1; i>=0; i--) {
		ans += ten * (s[i] - '0');
		ten *= 10;
	}
	return ans;
}

signed main()
{
	cin >> S;

	//int k = keta(S);
	int k = S.length();
	k--;

	for (int i=0; i<1<<k; i++) {
		string pre_num = "";
		int wa = 0;
		for (int j=0; j<k; j++) {
			pre_num += S[j];
			if (i >> j & 1) {
				wa += mystoi(pre_num);
				pre_num = "";
			}
		}
		pre_num += S[k];
		wa += mystoi(pre_num);
		ans += wa;
	}
	//ans += atoi(S.c_str());

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

string s,t;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n >> s >> t;
	for(int k = n; ; ++k) {
		string m(k,'0');
		for(int i = 0; i < s.size(); ++i) {
			m[i] = s[i];
		}
		bool ok = true;
		for(int j = 0; j < t.size(); ++j) {
			if(m[k-1-j] != '0' && m[k-1-j] != t[t.size()-1-j]) ok = false;
			m[k-1-j] = t[t.size()-1-j];
		}
		if(ok) {
			cout << k << "\n";
			return 0;
		}
	}	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // 標準入力から取得
        Scanner scan = new Scanner(System.in);
        // 取得した文字を格納する可変長リスト
        ArrayList<String> scList = new ArrayList<>();
        
        for (int i = 0; i >= 0; i++) {
            try {
                // 可変長リストに標準入力の値を格納
                scList.add(scan.nextLine());
            } catch (Exception e) {
                break;
            }
        }
        
        String[] numlist = scList.get(0).split(" ");
        
        int numA = Integer.parseInt(numlist[0]);
        int numB = Integer.parseInt(numlist[1]);
        int numC = Integer.parseInt(numlist[2]);
        int numD = Integer.parseInt(numlist[3]);
        
        for (int i = 0; i >= 0; i++) {
            numC = numC - numB;
            if(numC <= 0) {
                System.out.println("Yes");
                break;
            }
            numA = numA - numD;
            if (numA <= 0) {
                System.out.println("No");
                break;
            } 
        } 
    }
}

Measured memory_bytes: 35800
#include<iostream>
#include<vector>
#include<map>
using namespace std;

const int cmax = 31;
const int nmax = 501;

int d[cmax][cmax];
int cnt[3][nmax];

int main() {
    int n, c, x;
    cin >> n >> c;
    for(int i = 0; i < c; i++) for(int j = 0; j < c; j++) cin >> d[i][j];
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> x, cnt[(i+j)%3][x-1]++;

    int ans = 1e9+1;
    for(int i = 0; i < c; i++) {
        for(int j = 0; j < c; j++) {
            for(int k = 0; k < c; k++) {
                if(i == j || j == k || k == i) continue;
                int t = 0;
                for(int l = 0; l < c; l++) t += d[l][i] * cnt[0][l];
                for(int l = 0; l < c; l++) t += d[l][j] * cnt[1][l];
                for(int l = 0; l < c; l++) t += d[l][k] * cnt[2][l];
                ans = min(ans, t);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int A[n][m];
    int b[m];
    
    for(int nA = 0; nA < n; nA++){
        for(int mA = 0; mA < m; mA++){
            int a;
            cin >> a;
            A[nA][mA] = a;
        }
    }
    
    for(int mb = 0; mb < m; mb++){
        int bb;
        cin >> bb;
        b[mb] = bb;
    }
    
    for(int nc = 0; nc < n; nc++){
        int sum = 0;
        for(int mc = 0; mc < m; mc++){
            int p = A[nc][mc] * b[mc];
            sum += p;
        }
        cout << sum << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <set>

using namespace std;

int main(int argc, char const *argv[])
{
    int numq; cin >> numq;
    bool flg; // true if #a = odd;
    multiset<long long> l, r;
    long long a, b, c, b0, lsum=0ll, rsum=0ll;
    char z;
    int erased_num;

    // initialize
    cin >> z >> c >> b0; flg = true;
    --numq;

    for(;numq>0;--numq) {
        cin >> z;
        if(z=='1') {
            cin >> a >> b;
            b0 += b;
            if(flg) {
                if(a<=c) {
                    l.insert(a); lsum += a; 
                    r.insert(c); rsum += c;
                } else {
                    l.insert(c); lsum += c; 
                    r.insert(a); rsum += a;
                }
            } else {
                if(a < *(l.rbegin())) {
                    c = *(l.rbegin());
                    erased_num = l.erase(c);
                    for(--erased_num;erased_num>0;--erased_num) l.insert(c);
                    l.insert(a);
                    lsum += a - c;
                } else if (*(l.rbegin()) <= a && a <= *(r.begin())) {
                    c = a;
                } else {
                    c = *(r.begin());
                    erased_num = r.erase(c);
                    for(--erased_num;erased_num>0;--erased_num) r.insert(c);
                    r.insert(a);
                    rsum += a - c;
                }
            }
            flg = !flg;
        } else {
            if(flg) {
                cout << c << " " << rsum - lsum + b0 << endl;
            } else {
                cout << *(l.rbegin()) << " " << rsum - lsum + b0 << endl;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include<vector>
#include <list>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#include <tuple>
#include <string>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
#define FORk(N) for(int k=0;k<N;++k)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
void swap(ll &a,ll &b){
  ll tmp=a;
  a=b;
  b=tmp;
}
int main(){
  ll N,L;
  cin>>N>>L;
  ll sum=0;
  FORi(N){
    sum+=L+i;
  }
  if(L>0){
    sum-=L;
  }else if(L<=-N){
    if(abs(L)>abs(L+N-1)){
      sum-=L+N-1; 
    }else{
      sum-=L; 
    }
  }else{
    
  }
  cout<<sum<<endl;
  return 0;
  
}


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

int main() {
  long long n;
  cin >> n;
  long long ans=0;
  
  if (n%2==0) {
    for(long long temp=10;temp<=n;temp*=5) {
      ans+=n/temp;
    }
  }
  else {
    ans=0;
  }
  cout << ans << endl;
}

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

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<ll> nums(N);
    int minusCount = 0;
    for(int i = 0; i < N; i++)
    {
       ll num;
       cin >> num;
       if(num < 0){
           minusCount++;
           num *= -1;
       }
       nums.at(i) = num;
    }
    if(minusCount % 2 == 1){
        sort(nums.begin(), nums.end());
        nums.at(0) *= -1;
    }
    cout << accumulate(nums.begin(), nums.end(), (ll)0) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	long long n,k,sum,b,i;
	while(scanf("%lld%lld",&n,&k)!=EOF)
	{
		if(k==0)
		sum=n*n;
		else
		{
			sum=0;
			for(i=k+1;i<=n;i++)
			{
				sum+=(n/i)*(i-k);
				if(n%i>=k)
				sum+=n%i-k+1;
			}
		}
		printf("%lld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 128
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

ll exec(int a, int b, int c) {
    int three = b / 3LL - (a - 1LL) / 3LL;
    int five = b / 5LL - (a - 1LL) / 5LL;
    int x = b / 15LL - (a - 1LL) / 15LL;

    int bobo = b - a + 1LL - (three + five - x);
    ll ans = bobo * c + (three + five) * 4;
    return ans;
}

void solve(){
    ll s;
    cin >> s;
    int now = 9;
    for (int i = 1;; ++i) {
        int bot = now / 9;
        int top = (now / 9LL) * 10LL - 1LL;
        if (exec(bot, top, i) < s) {
            s -= exec(bot, top, i);
        }
        else {
            ll bott = bot - 1;
            int topp = top;
            while (topp - bott > 1) {
                ll mid = (topp + bott) / 2LL;
                if (exec(bot, mid, i) < s) {
                    bott = mid;
                }
                else {
                    topp = mid;
                }
            }
            s -= exec(bot, bott, i);
            string c;
            for (int i = bott + 1; c.length() <= 50; ++i) {
                if (i % 15 == 0) {
                    c += "FizzBuzz";
                }
                else if (i % 5 == 0) {
                    c += "Buzz";
                }
                else if (i % 3 == 0) {
                    c += "Fizz";
                }
                else {
                    c += to_string(i);
                }
            }
            for (int q = 0; q < 20; ++q) {
                cout << c[q + s - 1];
            }
            cout << endl;
            return;
        }
        now *= 10LL;
    }
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 3296
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush
# from heapq import heappop, heappush
# from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect
# import numpy as np
# from copy import deepcopy
from collections import deque

# from decimal import Decimal
# from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())

def run():
    H, W = mapline()
    A = []
    for i in range(H):
        A.append(list(mapline()))

    output = []
    for i in range(H):
        for j in range(W - 1):
            if A[i][j] % 2:
                A[i][j] -= 1
                A[i][j + 1] += 1
                output.append((i, j, i, j + 1))
    for i in range(H - 1):
        if A[i][W - 1] % 2:
            A[i][W - 1] -= 1
            A[i + 1][W - 1] += 1
            output.append((i, W - 1, i + 1, W - 1))

    print(len(output))
    for i1, j1, i2, j2 in output:
        print(f'{i1 + 1} {j1 + 1} {i2 + 1} {j2 + 1}')


if __name__ == "__main__":
    run()


Measured memory_bytes: 26528
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i) = 0; i < (n); i++)

int main(){
  string s, t, ans;
  bool f = true;
  vector<int> vc;
  cin >> s >> t;
  rep(i, 26){
    vc.clear();
    rep(j, s.length()) if(s[j] == 'a' + i) vc.push_back(j);
    rep(j, vc.size()) if(t[vc[0]] != t[vc[j]]) f = false;
  }rep(i, 26){
    vc.clear();
    rep(j, s.length()) if(t[j] == 'a' + i) vc.push_back(j);
    rep(j, vc.size()) if(s[vc[0]] != s[vc[j]]) f = false;
  }
  puts(f ? "Yes":"No");
}	

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    // freopen("B.01.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, alice = 0, bob = 0;
    cin >> n;
    vi a(n);
    rep(i, 0, n)
    {
        cin >> a[i];
    }
    sort(all(a));
    reverse(all(a));
    // trav(it, a){
    //     printf("%d ",it);
    // }
    rep(i, 0, n)
    {
        if (i % 2 == 0)
        {
            alice += a[i];
        }
        else
        {
            bob += a[i];
        }
    }
     cout << alice - bob << endl;
    return 0;
}

Measured memory_bytes: 3648
/* Author : Pranav Deshmukh
            PICT,Pune
   Purpose: Practice Atcoder
*/

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int             long long
#define dip(type,var)   type var; cin>>var;
#define dipi(x)			int x; cin>>x;
#define w(x)            int x; cin>>x; while(x--)
#define mka(arr,n,type) type *arr=new type[n];
#define fo(i,n)			for(int i=0;i<n;i++)
#define mod             pow(10,9)+7
#define inf             1e18
#define pi 				3.141592653589793238
#define fo(i,n)        for(int i=0;i<n;i++)
#define endl			"\n"
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mimp             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
	c_p_c();
	string s;
	cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7')
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,m,n,k;
    t = 1;
    for(int i=0;i<t;i++)
    {
        cin>>n>>m>>k;
        int arr[n],brr[m];
        ll prea[n+1],preb[m+1];
        prea[0] = preb[0] = 0;
        for(ll j=0;j<n;j++)
        {
            cin>>arr[j];
            prea[j+1] = prea[j]+arr[j];
        } 
        for(ll j=0;j<m;j++)
        {
            cin>>brr[j];
            preb[j+1] = preb[j]+brr[j];
        }
        int maxi = 0;
        for(int i=0;i<=n;i++)
        {
            for(int j=m;j>=0;j--)
            {
                if(prea[i]+preb[j]<=k)
                {
                    maxi = max(maxi,i+j);
                    m = j;
                    break;
                }
            }
        }
        cout<<maxi;
    }
    return 0;
}

Measured memory_bytes: 8188
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int s; cin >> s;
  int a = s/100, b = s%100;
  if (0 < a && a <= 12) {
    if (0 < b && b <= 12) {
      cout << "AMBIGUOUS" << endl;
      return 0;
    } else {
      cout << "MMYY" << endl;
      return 0;
    }
  } else {
    if (0 < b && b <= 12) {
      cout << "YYMM" << endl;
      return 0;
    } else {
      cout << "NA" << endl;
      return 0;
    }
  }
  return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

ll dp[10005][2][105];
const ll mod = 1000000007ll;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	string s; int d;
	read(s, d);

	int n = sz(s);
	s = ' ' + s;

	dp[0][1][0] = 1;
	rep(i, 1, n + 1) {
		// tight ->
		int tb = s[i] - '0'; // tight bound
		rep(j, 0, d) if (dp[i - 1][1][j]) {
			rep(k, 0, tb) {
				(dp[i][0][(j + k) % d] += dp[i - 1][1][j]) %= mod;
				//printf("TN %d %d %d -> %d %d %d with %d: %lld\n", i - 1, 1, j, i, 0, (j + k) % d, k, dp[i - 1][1][j]);
			}
			(dp[i][1][(j + tb) % d] += dp[i - 1][1][j]) %= mod;
			//printf("TT %d %d %d -> %d %d %d with %d: %lld\n", i - 1, 1, j, i, 1, (j + tb) % d, tb, dp[i - 1][1][j]);
		}
		// non-tight ->
		rep(j, 0, d) if (dp[i - 1][0][j]) {
			rep(k, 0, 10) {
				(dp[i][0][(j + k) % d] += dp[i - 1][0][j]) %= mod;
				//printf("NN %d %d %d -> %d %d %d with %d: %lld\n", i - 1, 0, j, i, 0, (j + k) % d, k, dp[i - 1][0][j]);
			}
		}
	}

	ll ans = (dp[n][0][0] + dp[n][1][0] + mod - 1) % mod;
	write(ans % mod);
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define len(array) (sizeof(array) / sizeof(array[0]))
#define asort(array) sort(array, array + len(array))

int main() {
  int n;cin>>n;
  long an[n];
  rep(i,n) cin>>an[i];
  asort(an);
  int cnt=0;
  long a0=0;
  rep(i,n) {
    if (an[i] != a0) {
      cnt++;
      a0 = an[i];
    } else {
      cnt--;
      a0 = 0;
    }
  }
  cout << cnt;
}


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

 using namespace std;

 int main() {
   int N, A, B, sumd, ans;

   cin >> N >> A >> B;

   ans = 0;
   for (int i = 1; i <= N; i++) {
     sumd = 0;
     int t = i;
     for (int j = 0; j < 5; j++) {
       sumd += t % 10;
       t /= 10;
     }
     if (A <= sumd && sumd <= B) ans += i;
   }

   cout << ans << endl;

 }


Measured memory_bytes: 256
S = input()
left = int(S[:2])
right = int(S[2:])
mm = 12
if left > mm and right <= mm and right != 0:
    print('YYMM')
elif left <= mm and right > mm and left != 0:
    print('MMYY')
elif left <= mm and right <= mm and left == 0 and right != 0:
    print('YYMM')
elif left <= mm and right <= mm and right == 0 and left != 0:
    print('MMYY')
elif left <= mm and right <= mm and left + right != 0:
    print('AMBIGUOUS')
else:
    print('NA')


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int64> a(n), b(m);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%lld", &b[i]);
  }
  int64 X = 0, Y = 0;
  for (int i = 1; i < n; ++i) {
    X += (a[i] - a[i - 1]) * i % MOD * (n - i) % MOD;
  }
  for (int i = 1; i < m; ++i) {
    Y += (b[i] - b[i - 1]) * i % MOD * (m - i) % MOD;
  }
  X %= MOD;
  Y %= MOD;
  printf("%lld\n", X * Y % MOD);
  return 0;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
n, t = map(int, input().split()) # 入力が複数
people = [int(i) for i in input().split()] # 配列で数字

ans = 0
pre = 0
for i in range(n):
    if pre >= people[i]:
        ans += t - (pre - people[i])
    else:
        ans += t
    pre = people[i] + t
print(ans)

Measured memory_bytes: 77648
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

long long gcd(long long a, long long b) {
    if(a < b) gcd(b, a);
    long long r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main(){
    

    ll n,k;
    cin >> n >> k;
    cout << (n - gcd(n,k))*3 << endl;
}

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

using namespace std;
#define int long long
const int N = 666666 , mod = 1e9+7;
int n,m,sz[N],f[N];
int getf(int v){
	if(v==f[v]){
		return f[v];
	}else {
		f[v]=getf(f[v]);
		return f[v];
	}
}
void merge(int u,int v){
	int t1=getf(u);
	int t2=getf(v);
	if(t1!=t2){
		f[t1]=t2;
		sz[t2]+=sz[t1]; 
	}
}

signed main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++) f[i]=i,sz[i]=1;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		merge(a,b);
	}
	int ans=0;
	for(int i=1;i<=n;i++) ans=max(ans,sz[getf(i)]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 12984
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int use[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int w[10];
using A = array<int, 10>;
using P = pair<int, A>;
P dp[11234];

// smin, smax {{{
// clang-format off
template < class T, class U > inline void smin(T &a, const U &b) { a = a < (T) b ? a : b; }
template < class T, class U > inline void smax(T &a, const U &b) { a = a < (T) b ? b : a; }
// clang-format on
// }}}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, m;
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int x;
    cin >> x;
    w[i] = x;
  }
  sort(w, w + m);

  constexpr int inf = 1e9;
  P infp(inf, A());

  for(int k = 1; k <= n; k++) dp[k] = infp;

  for(int i = 0; i < m; i++) {
    for(int k = 0; k + use[w[i]] <= n; k++) {
      auto d = dp[k];
      if(d == infp) continue;
      d.first--;
      d.second[m-1-i]--;
      smin(dp[k + use[w[i]]], d);
    }
  }

  for(int i = 0; i < m; i++) {
    for(int k = 0; k < -dp[n].second[i]; k++) {
      cout << w[m - 1 - i];
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 640
//Solution for aoj:0595 Schedule
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
using namespace std;
const int surplus = 10007;
int n, num[1001], num2[4], num3[4], ans;
int dp[1001][8];
string s;
int henkan(char a){
	if (a == 'J')
		return 1;
	if (a == 'O')
		return 2;
	if (a == 'I')
		return 3;
}
int main(){
	cin >> n;
	cin >> s;
	for (int i = 0; i < n; i++){
		num[i + 1] = henkan(s[i]);
	}
	if (num[1] == 1){
		dp[1][1] = 1;
		dp[1][3] = 1;
		dp[1][5] = 1;
		dp[1][7] = 1;
	}
	else if (num[1] == 2){
		dp[1][3] = 1;
		dp[1][7] = 1;
	}
	else{
		dp[1][5] = 1;
		dp[1][7] = 1;
	}
	for (int i = 2; i <= n; i++){
		for (int j = 1; j < 8; j++){
			for (int k = 1; k < 8; k++){
				int a = 1 << (num[i] - 1);
				a = j&a;
				if (!a) continue;
				int b = j;
				b = b&k;
				if (b){
					dp[i][j] += dp[i - 1][k];
					dp[i][j] %= surplus;
				}
			}
		}
	}
	for (int i = 1; i < 8; i++){
		ans += dp[n][i];
	}
	cout << ans%surplus << endl;
}

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

int main() {
  int H,W;
  cin>>H>>W;
  int U[H][W]={0},D[H][W]={0},L[H][W]={0},R[H][W]={0};
  char P[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>P[i][j];
    }
  }
  
  //LR
  for(int i=0;i<H;i++){
    int cur=1;
    for(int j=0;j<W;j++){
      if(P[i][j]=='#'){
        L[i][j]=0;
        cur=1;
      }
      else{
        L[i][j]=cur;
        cur++;
      }
    }
  }
  
  for(int i=0;i<H;i++){ 
    int cur=1;
    for(int j=W-1;j>=0;j--){
      if(P[i][j]=='#'){
        R[i][j]=0;
        cur=1;
      }
      else{
        R[i][j]=cur;
        cur++;
      }
    }        
  }
  
  //UD
  for(int i=0;i<W;i++){
    int cur=1;
    for(int j=0;j<H;j++){
      if(P[j][i]=='#'){
        U[j][i]=0;
        cur=1;
      }
      else{
        U[j][i]=cur;
        cur++;
      }
    }
  }
  
  for(int i=0;i<W;i++){
    int cur=1;
    for(int j=H-1;j>=0;j--){
      if(P[j][i]=='#'){
        D[j][i]=0;
        cur=1;
      }
      else{
        D[j][i]=cur;
        cur++;
      }
    }        
  }
  
  int cnt=0;
  int maxcnt=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cnt=U[i][j]+D[i][j]+R[i][j]+L[i][j]-3;
      maxcnt=max(maxcnt,cnt);
    }
  }
  cout<<maxcnt<<endl;

 return 0;
}

Measured memory_bytes: 69964
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  int A[110];
  cin>>N;
  bool ans=true; 
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N;i++){
    if(A[i]%2==0){
      if(A[i]%3==0);
      else if(A[i]%5==0);
      else ans=false;
    }
  }
  if(ans)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    VI sumr(n + 1, 0), sumg(n + 1, 0), sumb(n + 1, 0);
    rep(i, n)
    {
        sumr[i + 1] = sumr[i];
        sumg[i + 1] = sumg[i];
        sumb[i + 1] = sumb[i];
        if (s[i] == 'R')
            sumr[i + 1]++;
        if (s[i] == 'G')
            sumg[i + 1]++;
        if (s[i] == 'B')
            sumb[i + 1]++;
    }
    ll ans = 0;
    map<char, bool> mp;
    rep(i, n)
    {
        rep(j, i + 1, n)
        {

            if (s[i] == s[j])
                continue;
            int dist = j - i;
            mp.clear();
            mp[s[i]] = true;
            mp[s[j]] = true;
            if (mp['R'] == false)
            {
                ans += sumr[n] - sumr[j];
                if (j + dist < n && s[j + dist] == 'R')
                    ans--;
            }
            if (mp['G'] == false)
            {
                ans += sumg[n] - sumg[j];
                if (j + dist < n && s[j + dist] == 'G')
                    ans--;
            }
            if (mp['B'] == false)
            {
                ans += sumb[n] - sumb[j];
                if (j + dist < n && s[j + dist] == 'B')
                    ans--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
# coding: utf-8

n = int(input().rstrip())


def get_list(flag: int):
    if (1 << n) - 1 == flag:
        return []
    ret = []
    for i in range(n):
        key = (1 << i)
        if (flag & key) != 0:
            continue
        tmp = get_list(flag + key)
        if len(tmp) == 0:
            ret.append([i + 1])
        else:
            for t in tmp:
                ret.append([i + 1] + t)
    return ret


list1 = [int(i) for i in input().rstrip().split(" ")]
list2 = [int(i) for i in input().rstrip().split(" ")]

index1 = 0
index2 = 0

kumiawase = get_list(0)
for i in range(len(kumiawase)):
    if list1 == kumiawase[i]:
        index1 = i
    if list2 == kumiawase[i]:
        index2 = i

print(abs(index1 - index2))


Measured memory_bytes: 9972
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

vi v[N];
int dis[N], used[N];
int main()
{
	int n, x, y;
	cin >> n >> x >> y;
		map<int, int> mp;
	for(int i = 2; i <= n; i ++)
		v[i].pb(i - 1), v[i - 1].pb(i), mp[i - 1] = 0;
	v[x].pb(y);
	v[y].pb(x);
	for(int i = 1; i <= n; i ++)
	{
		for(int j = 1; j <= n; j ++)
			dis[j] = used[j] = 0;
		queue<int> q;
		q.push(i);
		used[i] = 1;
		while(q.size())
		{
			int u = q.front();
			q.pop();
			for(auto it : v[u])
			{
				if(used[it])
					continue;
				dis[it] = dis[u] + 1;
				used[it] = 1;
				q.push(it);
			}
		}
		for(int j = i + 1; j <= n; j ++)
			mp[dis[j]] ++;
	}
	for(auto it : mp)
		cout << it.S << '\n';
	





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    char s;
    cin >> s;
    int ans = s;
    ans++;
    cout << char(ans) << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define md (ll)(1e9+7)
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M=1e6+6;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll ar[M],dp[M];

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

	ll n,k,i,j;

	cin >> n >> k;

	for(i=1;i<=n;++i)
		cin >> ar[i];

	dp[ar[1]] = 1;

	for(i=ar[1]+1;i<=k;++i)
	{
		for(j=1;j<=n;++j)
		{
			if(i-ar[j] >= 0 && dp[i-ar[j]] == 0)
			{
				dp[i] = 1;
				break;
			}
		}
	}

	if(dp[k] == 1)
		cout << "First" << "\n";
	else
		cout << "Second" << "\n";

	return 0;
}

Measured memory_bytes: 3072
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int K = Integer.parseInt(in.next());
            int x = 7 % K;
            for (int i = 1; i <= K; i++) {
                if (x == 0) {
                    out.println(i);
                    return;
                } else {
                    x = (x * 10 + 7) % K;
                }
            }
            out.println(-1);
        }

    }
}



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

int dfs(vector<vector<int>> &veq, int cnt, int sum, int incomp){
  if (sum <=0) return 0;
  if (cnt == veq.size()){
   if (incomp != 100){
     int t = min(sum/((incomp+1)*100), veq.at(incomp).at(0) -1);
     if ((sum - t*(incomp+1)*100) <= 0) return t;
   }
   return 1e9;
  }
  int ans1 = dfs(veq, cnt+1, sum, incomp);
  int ans2 = dfs(veq, cnt+1, sum - veq.at(cnt).at(0)*(cnt+1)*100 - veq.at(cnt).at(1), incomp) + veq.at(cnt).at(0);
  int ans3 = 1e9;
  if(incomp == 100){
    ans3 = dfs(veq, cnt+1, sum, cnt);
  }
  return min({ans1, ans2, ans3});
}

int main(){
  int D, G;
  cin >> D >> G;
  vector<vector<int>> veq(D, vector<int>(2));
  for (int i; i<D; i++){
   cin >> veq.at(i).at(0) >> veq.at(i).at(1);
  }
  int ans = dfs(veq, 0, G, 100);
  cout << ans << endl;
}

Measured memory_bytes: 256
import math
def sieve(n):
    if n < 2:
        is_prime = [False for _ in range(n+1)]
        return is_prime
 
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
 
    for i in range(2, int(n**0.5)+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
 
    return is_prime

N=10**5
prime=sieve(N)
a=[0 for i in range(N+1)]
for i in range(3,N):
	if prime[i] and prime[(i+1)//2]: a[i]=a[i-1]+1
	else: a[i]=a[i-1]

Q=int(input())
for i in range(Q):
	l,r=map(int,input().split())
	print(a[r]-a[l-1])

Measured memory_bytes: 5144
import math

n=int(input())
P=[]
for i in range(n):
    x,y=map(int,input().split())
    P.append([x,y])
    
ans=0
for i in range(n-1):
    x1=P[i][0]
    y1=P[i][1]
    for j in range(i+1,n):
        x2=P[j][0]
        y2=P[j][1]
        ans+=math.sqrt((x1-x2)**2+(y1-y2)**2)
ans=ans*2/n
print(ans)

Measured memory_bytes: 38256
x, n = gets.split.map(&:to_i)
ps = []
ps = gets.split.map(&:to_i) if n.nonzero?

min = 1000
result = nil

((0..101).to_a - ps).each do |n|
  l = (n - x).abs
  if l < min
    min = l
    result = n
  end
end

puts result

Measured memory_bytes: 14288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    string s;
    cin >> s;
    int n = s.size(), cnt = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256