akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;

long long N, X[1009], Y[1009], H[1009]; vector<tuple<long long, long long, long long>>vec;

int main() {
	cin >> N; tuple<long long, long long, long long>G = make_tuple(-1, -1, -1);
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i] >> H[i];
		if (H[i] >= 1) G = make_tuple(X[i], Y[i], H[i]);
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			long long V = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j); V = max(V, 0LL); bool flag = true;
			for (int k = 1; k <= N; k++) {
				long long VV = V - abs(X[k] - i) - abs(Y[k] - j); VV = max(VV, 0LL);
				if (H[k] != VV) flag = false;
			}
			if (flag == true) vec.push_back(make_tuple(i, j, V));
		}
	}
  	cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl;
	return 0;
}



Measured memory_bytes: 256
/*input
10 4 8
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int n, x, y, i, j;
	cin >> n >> x >> y;
	--x; --y;
	vector<vector<int>> dist(n, vector<int>(n, 1e9));
	for(i=0; i<n; i++) {
		dist[i][i] = 0;
		for(j=i+1; j<n; j++) {
			dist[i][j] = dist[j][i] = j - i;
		}
	}
	dist[x][y] = dist[y][x] = 1;
	vector<int> freq(n+1, 0);
	for(i=0; i<n; i++) {
		for(j=i+1; j<n; j++) {
			dist[i][j] = min({dist[i][j], dist[i][x] + 1 + dist[y][j], dist[i][y] + 1 + dist[x][j]});
			if(dist[i][j] <= n) {
				freq[dist[i][j]]++;
			}
		}
	}
	for(i=1; i<n; i++)
		cout << freq[i] << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);		
	int t = 1;
	while(t--) {
		run();
	}
}


Measured memory_bytes: 16000
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll ans=0;
  rep(i,n){
    ans=ans^a[i];
  }
  rep(i,n){
    ans=ans^a[i];
    cout << ans << " ";
    ans^=a[i];
  }cout << endl;
  
}

Measured memory_bytes: 4000
program main
	implicit none
	integer n,m,l
	read(*,*)n,m
	l=(n-1)*(m-1)
	if(l<10)then
		write(*,'(i1)')l
	elseif(l<100)then
		write(*,'(i2)')l
	elseif(l<1000)then
		write(*,'(i3)')l
	else
		write(*,'(i4)')l
	endif
end program main


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define endl '\n'
#define mp make_pair
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef long long int ll;
ll mod =1000000007;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,d,a,b;
    cin>>n;
    ll arr[n];
    ll sum=0;
    for(int i=0;i<n;i++){
       cin>>arr[i];
       if(i%2==1) {
           sum-=arr[i];
       }
       else sum+=arr[i];
    }
    cout<<sum<<" ";
    for(int i=0;i<n-1;i++){
       sum=( 2*arr[i])-sum;
       cout<<sum<<" ";
    }
    
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<string.h>
 
int main(void)
{
    char m[21];
    int f1, s;
    scanf("%s",m);
    s = strlen(m);
    for(f1 = s - 1; f1 >= 0; f1--)
    {
        printf("%c",m[f1]);
    }
    printf("\n");
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  string input_str;
  cin >> input_str;
  
  int cnt;
  while (input_str.find("ABC") != string::npos) {
    cnt++;
    input_str.erase(input_str.find("ABC"), 3);
  }
  cout << cnt << endl;
}

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

using namespace std;

vector<int> a;
typedef long long ll;
// int dp[1 << 15][1 << 8][5];

// idxより後でk個以内をとってnを作る方法は何通り
int dfs(int n, int idx, int k)
{
    /*int & res = dp[n][idx][k];
    if (res != -1)return res;
*/
    int res = 0;
    if (n == 0) res = 1;
    else {
        res = 0;
        if (k != 0)
        {
            for (int i = idx; i < a.size(); i++)
            {
                if (n - a[i] >= 0)
                {
                    res += dfs(n - a[i], i, k - 1);
                }
            }
        }
    }
    return res;
}

int main(){
    for (int i = 1; i*i <= 1 << 15; i++){
        a.push_back(i*i);
    }
    // memset(dp, -1, sizeof(dp));
    int n;
    while (cin>> n && n)
    {
        cout << dfs(n, 0, 4) << endl;
    }
}

Measured memory_bytes: 1216
// BEGINNING WITH NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
// ATCODER BEGINNERS PROBLEMS
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.flush();
    int x,t;
    cin >> x >> t;
   	((x-t)<=0) ? cout<<"0" : cout<< x-t;
    return 0;
    // Bye Bye 2019
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    int a, cnt = 0;
	double ans;

	cin >> a;

	for (int i = 1; i <= a; i++) {
		if (i % 2 != 0) {
			cnt++;
		}
	}

	ans = (double)cnt / a;

	cout << ans << endl;
}

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

int main()
{
    int n; cin >> n;
    string inp;
    vector<string> s;

    for(int i = 0; i < n; i++){
        cin >> inp;
        sort(inp.begin(), inp.end());
        s.push_back(inp);
    }

    sort(s.begin(), s.end());
    long long int ans = 0, cnt = 1;
    for(int i = 1; i < n; i++){
        if(s[i-1] == s[i]){
            cnt++;
        }else{
            if(cnt > 0){
                ans += cnt*(cnt-1)/2;
                cnt = 1;
            }
        }
    }
    ans += cnt*(cnt-1)/2;
    
    cout << (ans == n ? 0 : ans)<< endl;
    return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  rep(i,10){
    int cnt = 0;
    if(i==a)cnt++;
    if(i==b)cnt++;
    if(i==c)cnt++;
    if(cnt==2){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3600
n, p = map(int, input().split())
s = input()
if p == 2:
	ans = 0
	for i in range(n):
		if int(s[i]) % 2 == 0:
			ans += i+1
	print(ans)
elif p == 5:
	ans = 0
	for i in range(n):
		if s[i] == "5" or s[i] == "0":
			ans += i+1
	print(ans)

else:
	mods = [0 for _ in range(p)]
	cur = 0
	mods[0] += 1
	t = s[::-1]
	for i in range(n):
		cur = (cur + int(t[i]) * pow(10, i, p)) % p
		mods[cur] += 1
	#print(mods)
	ans = 0
	for m in mods:
		ans += (m * (m-1)) // 2
	print(ans)

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

row1 = list(map(int,input().split()))

row2 = list(map(int,input().split()))

mx = 0
for i in range(n):
	pass
	up = sum(row1[:i+1])
	down = sum(row2[i:])
	mx = max(mx,up+down)

print(mx)
	

Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	int a,x[5],i,s,flg;
	scanf("%d",&a);
	s=1000;
	for(i=0;i<4;i++){
		x[i]=a/s;
		a-=x[i]*s;
		s/=10;
	}
	flg=0;
	if(x[1]==x[2]){
		if(x[0]==x[1]||x[1]==x[3]) flg=1;
	}
	if(flg==0) printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 128
import java.util.*;

public class Main{

    int n,m;
    int[][] c;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt();
            m = sc.nextInt();
            if(n==0 && m==0) break;

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

            System.out.println(getMin());
        }
    }

    int getMin(){
        //pos,cost,ticket
        PriorityQueue<int[]> q = 
            new PriorityQueue<int[]>(n,new Comparator<int[]>(){
                    public int compare(int[] a, int[] b){
                        return a[1] - b[1];
                    }
                });
        q.add(new int[]{0,0,0});
        int[][] v = new int[101][3];
        for(int i=0; i<101; i++) Arrays.fill(v[i],Integer.MAX_VALUE);

        while(q.size()>0){
            int[] qq = q.poll();
            int pos = qq[0], cost = qq[1], ticket = qq[2];

            //System.out.println(Arrays.toString(qq));

            if(pos==n-1 && ticket!=1) return cost;
            if(v[pos][ticket]<=cost) continue;
            v[pos][ticket] = cost;

            for(int i=0; i<n; i++){
                if(c[pos][i]==0) continue;
                if(ticket==0){
                    q.add(new int[]{i,cost,1});
                    q.add(new int[]{i,cost+c[pos][i],0});
                }else if(ticket==1){
                    q.add(new int[]{i,cost,2});
                }else if(ticket==2){
                    q.add(new int[]{i,cost+c[pos][i],2});
                }
            }
        }

        return -1;
    }

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

Measured memory_bytes: 13000
#include "bits/stdc++.h"
using namespace std;

int main() {
	vector<int> A(3);
	for (int i = 0; i < 3; ++i) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	cout << A[2] - A[0] << endl;
	return 0;
}


Measured memory_bytes: 3512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////

int d[2010];
vector<int>G[2010];
int N, X, Y;
void dijkstra(int n) {
	priority_queue<pii,vector<pii>,greater<pii>>que;
	que.push({ 0,n });
	d[n] = 0;
	while (!que.empty()) {
		pii x = que.top();
		que.pop();
		for (int i : G[x.second]) {
			if (d[i] == INF) {
				d[i] = min(d[i], d[x.second] + 1);
				que.push({d[i],i});
			}
			else {
				d[i] = min(d[i], d[x.second] + 1);
			}
		}
	}
}
int main() {
	cin >> N >> X >> Y;
	X--, Y--;
	REP(i, N - 1) {
		G[i].push_back(i + 1);
		G[i + 1].push_back(i);
	}
	G[X].push_back(Y);
	G[Y].push_back(X);
	int cnt[2010];
	REP(i, 2010)cnt[i] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 2010; ++j)d[j] = (int)INF;
		dijkstra(i);
		for (int j = 0; j < N; ++j) {
			if (i == j)continue;
			cnt[d[j]]++;
		}
	}
	for (int i = 1; i <= N - 1; ++i) {
		cout << cnt[i]/2 << endl;
	}
	return 0;
}


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

long long x,n;
int main() 
{ 

	ios::sync_with_stdio(false);
    cin.tie(NULL);
    int cnt=0;
    cin>>n;
    long long p = 100;
    while(p<n)
    {
    	p+=p/100;
    	cnt++;
    }
    cout<<cnt;
} 


Measured memory_bytes: 3640
#include <iostream>
#include <stack>
#include <string>

using namespace std;

void solve()
{
	string str;
	while(getline(cin,str) && str != "."){
		string c;
		for(int i = 0 ; i < str.size() ; i++)
			if(str[i] == ')' || str[i] == '(' || str[i] == '[' || str[i] == ']')
				c += str[i];
		stack<char> s;
		bool f = true;
		for(int i = 0 ; i < c.length() ; i++){
			if(s.empty() || c[i] == '(' || c[i] == '[')
				s.push(c[i]);
			else if( (s.top() == '(' && c[i] == ')') || (s.top() == '[' && c[i] == ']') ){
				s.pop();
			}else{
				f = false;
				break;
			}
		}
		cout << (f && s.empty() ?"yes":"no") << endl;
	}

}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 904
#include<bits/stdc++.h>
using namespace std;
int ans;
int cnt;
vector<int> G[200200];
bool vis[200200];
void dfs(int x)
{
  cnt++;
  vis[x]=true;
  for(int i=0;i<(int)(G[x].size());i++)
    if(!vis[G[x][i]])
      dfs(G[x][i]);
  return ;
}
int main()
{
  int N,M;
  cin>>N>>M;
  while(M--)
  {
    int x,y;
    cin>>x>>y;
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for(int i=0;i<N;i++)
    if(!vis[i])
    {
      cnt=0;
      dfs(i);
      ans=max(ans,cnt);
    }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 20904
import java.util.*;
import static java.lang.System.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    int A= sc.nextInt();
    int B= sc.nextInt();
    String U = sc.next();
    if(U.equals(S)){
      A-=1;
    }
    if(U.equals(T)){
      B-=1;
    }
    out.print(A+" "+B);
  }




  }



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

int main(void){
    int s = 3;
    vector<vector<int>> A(3, vector<int>(3));
    rep(i, s){rep(j, s){cin >> A[i][j];}}
    int N;cin >> N;
    vector<int> B(N);
    rep(i, N){cin >> B[i];}

    vector<vector<int>> o(3, vector<int>(3));
    rep(i, s){rep(j, s){rep(k, N){
        if(A[i][j] == B[k]){
            o[i][j] = 1;
            break;
        } else {
            o[i][j] = 0;
        }
    }}}

    rep(i, s){
        if(o[i][0] == 1 && o[i][1] == 1 && o[i][2] == 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(i, s){
        if(o[0][i] == 1 && o[1][i] == 1 && o[2][i] == 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(o[1][1] == 1 && o[0][0] == 1 && o[2][2] == 1){
        cout << "Yes" << endl;
        return 0;
    }
    else if(o[1][1] == 1 && o[0][2] == 1 && o[2][0] == 1){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
/**
 * ABC126
 * C - Dice and Coin
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d", $n, $k);

$total = 0;

for ($i = 1; $i <= $n; $i++) {
    $point = $i;
    $probability = 1 / $n;
    while ($k > $point) {
        $point *= 2;
        $probability *= 1 / 2;
    }
    $total += $probability;
}

echo sprintf('%.12f', $total), PHP_EOL;


Measured memory_bytes: 4604
#入力高速化 + 再帰回数制限解除
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10000000)

from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,input().split()))
edge=[[]for _ in range(n)]
for _ in range(n-1):
  u,v=map(int,input().split())
  u-=1
  v-=1
  edge[u].append(v)
  edge[v].append(u)
ans=[-1]*n
dp=[10**10]*n

#オイラーツアー
#n=頂点数、s=始点、edge=隣接リスト
#木構造を投げると訪問順listが帰ってくる、|ans|=2*n-1
#適宜書き換えて実装を楽にしましょう
def EulerTour(n,s,e):
  EulerTour_list=[]
  def EulerTour_dfs(i,root):
    EulerTour_list.append(i)
    ind=bisect_left(dp,a[i])
    bef=dp[ind]
    dp[ind]=a[i]
    ans[i]=bisect_left(dp,10**10)
    for j in e[i]:
      if j!=root:
        EulerTour_dfs(j,i)
    if root!=-1:
      EulerTour_list.append(root)
      dp[ind]=bef
  EulerTour_dfs(s,-1)
  return EulerTour_list

EulerTour(n,0,edge)
print(*ans)

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

using namespace std;
using ll = long long int;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(16);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    map<pair<ll,ll>,ll> mp;

    auto idiv = [&](pair<ll,ll> t) -> pair<ll,ll> {
        auto [a, b] = t;
        if(a==0&&b==0) return {1e9, 0};
        if(a==0) return {0, 1};
        if(b==0) return {1, 0};
        ll g = __gcd(a, b);
        return {a/g, b/g};
    };
    auto div = [&](ll a, ll b) -> pair<ll,ll> {
        if(a==0&&b==0) return {1e9, 0};
        if(a==0) return {0, 1};
        if(b==0) return {1, 0};
        ll g = __gcd(a, b);
        return {a/g, b/g};
    };
    auto powmod = [&](ll a, ll b) -> ll {
        ll r = 1;
        while(b) {
            if(b&1) (r *= a) %= MOD;
            (a *= a) %= MOD;
            b >>= 1;
        }
        return r % MOD;
    };

    for(ll i=0; i<n; i++) {
        ll a, b;
        cin >> a >> b;
        ll g = __gcd(a, b);
        if(g != 0)
            a /= g, b /= g;
        if(b < 0) a *= -1, b *= -1;
        if(a == 0 && b == 0) {
        } else {
            if(b == 0) a = 1;
            if(a == 0) b = 1;
        }
        mp[{a,b}]++;
    }

    set<pair<ll,ll>> st;

    ll res = 1;
    for(auto [t, cnt]: mp) {
        auto [a, b] = t;
        if(a == 0 && b == 0) continue;
        if(st.count({a,b})) continue;

        ll tmp = 0;
        tmp += powmod(2, cnt);
        ll ta = -b, tb = a;
        if(tb < 0) ta *= -1, tb *= -1;
        if(ta == 0 && tb == 0) {
        } else {
            if(tb == 0) ta = 1;
            if(ta == 0) tb = 1;
        }
        if(mp.count({ta,tb}) && (make_tuple(a,b)!=make_tuple(ta,tb)))
            tmp += powmod(2, mp[{ta,tb}]), tmp += MOD-1;

        tmp %= MOD;
        (res *= tmp) %= MOD;

        st.insert({a,b});
        st.insert({ta,tb});
    }
    res += mp[{0,0}];

    res += MOD-1;
    res %= MOD;
    cout << res << endl;
}


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

int main(void){
    int N;
    cin >> N;
    vector<int> p(N),q(N);
    for(int i=0;i<N;i++) cin >> p[i];
    for(int i=0;i<N;i++) cin >> q[i];

    vector<int> vec(N);
    for(int i=0;i<N;i++) vec[i] = i+1;

    int count = 0;
    int porder,qorder;
    do{
        count++;
        bool pok = true, qok = true;
        for(int i=0;i<N;i++){
            if(vec[i]!=p[i]) pok = false;
            if(vec[i]!=q[i]) qok = false;
        }
        if(pok) porder = count;
        if(qok) qorder = count;
    }while(next_permutation(vec.begin(),vec.end()));

    cout << abs(porder-qorder) << endl;
}

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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut stack1 = VecDeque::new();
    let mut stack2 = VecDeque::new();
    let mut area: u32 = 0;
    let data: String = read();
    for (index, data_char) in data.chars().enumerate() {
        match data_char {
            '/' => {
                if !stack1.is_empty() {
                    let stacked_index: usize = stack1.pop_back().unwrap();
                    let this_area: u32 = (index - stacked_index) as u32;
                    area += this_area;
                    let mut done: bool = false;
                    let mut stacked2_area: u32 = 0;
                    while !done {
                        let stacked_index_2: (usize, u32, bool) = stack2.pop_back().unwrap();
                        if stacked_index_2.2 {
                            stacked2_area += stacked_index_2.1;
                        } else {
                            done = true;
                            stack2.push_back((stacked_index_2.0, stacked2_area + this_area, true))
                        }
                    }
                }
                ()
            }
            '\\' => {
                stack1.push_back(index);
                stack2.push_back((index, 0, false));
            }
            _ => (),
        }
    }
    println!("{}", area);
    let stack2_answer: Vec<(usize, u32, bool)> = stack2.iter().filter(|&x| x.2).cloned().collect();
    let stack2_answer_len = stack2_answer.len();

    if stack2_answer_len == 0 {
        println!("0")
    } else {
        print!("{} ", stack2_answer.len());

        for (index, stack) in stack2_answer.iter().enumerate() {
            if index != (stack2_answer.len() - 1) {
                print!("{} ", stack.1);
            } else {
                println!("{}", stack.1);
            }
        }
    }
}



Measured memory_bytes: 5028
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
#define atoi hoge

int hoge(char c) {
    return c - '0';
}
int main()
{
  	ios::sync_with_stdio(false);
	cin.tie(nullptr);
    string s; cin >> s;
    reverse(s.begin(), s.end());
    vector<vector<int>> dp(s.size()+1, vector<int>(2));
    for(int i=0;i < int(s.size()); i++) {
        dp[i+1][0] = min(dp[i][0]+atoi(s[i]), dp[i][1]+atoi(s[i])+1);
        if (i!=0) {
            dp[i+1][1] = min(dp[i][0] + 10 - atoi(s[i]), dp[i][1]+10-(atoi(s[i])+1));
        }else {
            dp[i+1][1] = dp[i][0] + 10 - atoi(s[i]);
        }
    }
    cout << min(dp[s.size()][0], dp[s.size()][1]+1) << "\n";
            
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


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

using namespace std;
string a,b;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b;
	for(int i=0;i<a.size();i++)
	{
		cout<<a[i];
		if(i<b.size()) cout<<b[i];
	}
	cout<<endl;

	return 0;
}


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

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

  while (q == 0) {
    for (int i = 0; i < N; i++) {
      if (a[i] % 2 == 1) q = 1;
      a[i] /= 2;
    }
  	p++;
  }
  cout << p - 1 << endl;
}


Measured memory_bytes: 3560
n = gets.chop.split.map(&:to_i)
n.sort!
min, med, max = n[0], n[1], n[2]
if n.uniq.length == 1
  puts 0
elsif [min, med].select{|item| item.even? }.length == 2 || [min, med].select{|item| item.odd? }.length == 2
  puts (max - min + max - med)/2
else
  puts (max - min + max - med)/2 + 2
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;
const ll INF = 0x7f7f7f7f;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) +(ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int n, t, a, h[maxn];
double dis = INF;
int ans;

int main() {
    ios::sync_with_stdio(false);
    n = read(), t = read(), a = read();
    for (reg int i = 1; i <= n; i++) {
        h[i] = read();
        reg double tmp = (double)t - h[i] * 0.006;
        if (fabs(tmp - (double)a) < dis) dis = fabs(tmp - (double)a), ans = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 map<char,char> S;
  S['A']='T';
  S['T']='A';
  S['C']='G';
  S['G']='C';
  char b;
  cin>>b;
  cout<<S[b]<<endl;
}
       
  

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

int read(){
	int a = 0; char c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)){a = a * 10 + c - 48; c = getchar();}
	return a;
}
const int MOD = 1e9 + 7;
int arr[100003] , N , inv[100003] , jc;

int poww(long long a , int b){
	int times = 1;
	while(b){if(b & 1) times = times * a % MOD; a = a * a % MOD; b >>= 1;}
	return times;
}

int main(){
	N = read(); for(int i = 1 ; i <= N ; ++i) arr[i] = read();
	jc = 1; for(int i = 1 ; i <= N ; ++i) jc = 1ll * jc * i % MOD;
	for(int i = 1 ; i <= N ; ++i) inv[i] = (poww(i , MOD - 2) + inv[i - 1]) % MOD;
	int sum = 0;
	for(int i = 1 ; i <= N ; ++i)
		sum = (sum + (inv[i] + inv[N - i + 1] - inv[1] + 1ll * MOD) * arr[i]) % MOD;
	cout << 1ll * sum * jc % MOD; return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &v[i]);
	const int M = 1000000007;
	vector<vector<unsigned int> > dp(n + 1, vector<unsigned int>(k + 1));
	fill(dp[n].begin(), dp[n].end(), 1);
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j <= k; ++j) {
			int l = max(0, j - v[i]);
			int r = j;
			dp[i][j] = dp[i + 1][r];
			if (l) {
				dp[i][j] += M - dp[i + 1][l - 1] + M;
				if (dp[i][j] >= M)
					dp[i][j] %= M;
			}
			if (j) {
				dp[i][j] += dp[i][j - 1] + M;
				if (dp[i][j] >= M)
					dp[i][j] %= M;
			}
		}
	}
	printf("%d\n", (int)(dp[0][k] + M - (k ? dp[0][k - 1] : 0)) % M);
	return 0;
}

Measured memory_bytes: 40192
#include<cstdio>
#define M 400004
#define N 200002
int a[N],b[M],c[M],f[N],g[N],h[N],i,j,l,n,q[N],r,s[N],t,u,v;bool d[N];
int main()
{
    for(scanf("%d",&n),i=s[++t]=1;i<n;i++)scanf("%d%d",&u,&v),b[i<<1]=a[u],c[a[u]=i<<1]=v,b[i<<1|1]=a[v],c[a[v]=i<<1|1]=u;
    while(t)
    {
        for(q[l=0]=s[t--],r=1;l<r;)if((u=q[l++])<=*q)for(i=a[u];i;i=b[i])if(c[i]!=f[u])f[q[r++]=c[i]]=u,c[i]<*q?0:h[s[++t]=c[i]]=*q;
        for(l=0,r=1;l<r;)for(i=a[u=q[l++]];i;i=b[i])if(c[i]!=f[u]&&c[i]<h[*q])d[q[r++]=c[i]]=true;
        for(g[*q]+=r-1,j=a[*q];j;j=b[j])if(c[j]!=f[*q])
        {
            for(v=g[*q],r=2,q[l=1]=c[j];l<r;)if((u=q[l++])<*q)for(i=a[u],v+=!d[u];i;i=b[i])if(c[i]!=f[u])f[q[r++]=c[i]]=u;
            for(i=1;i<r;i++)g[q[i]]=q[i]<*q?v:v+1;
        }
    }
    for(i=2;i<=n;i++)printf("%d%c",g[i],i==n?'\n':' ');
    return 0;
}

Measured memory_bytes: 8320
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007


int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	int lar, sma;
	if(a>b){
		lar = a;
		sma = b;
	}
	else{
		lar = b;
		sma = a;
	}
	long int ans = lar;
	while(ans%sma != 0){
		ans += lar;
	}

	printf("%ld\n", ans);

	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, K, S;
	cin >> N >> K >> S;
	vector<long long>A(N);
	for (long long i = 0; i < K; i++) {
		A.at(i) = S;
	}
	for (long long i = K; i < N; i++) {
		if (S == pow(10, 9)) A.at(i) = 1;
		else A.at(i) = S + 1;
	}
	for (long long i = 0; i < N; i++) {
		cout << A.at(i);
		if (i != N - 1) cout << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    int n;
    cin>>n;
    vector<int>v;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a==v.size()+1){
            v.push_back(a);
        }
    }
    
    int x=n-v.size();

    if(x==n){
        cout<<-1<<endl;
    }
    else{
        cout<<x<<endl;
    }
    
    


   

}

Measured memory_bytes: 1400
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 11;

int T[maxN][maxN];

void rob(int i, int j, int n)
{
	T[i+n/2][j+n/2] = 1;
	if (n == 1)
		return;
	rob(i, j, n/2);
	rob(i, j+n/2+1, n/2);
	rob(i+n/2+1, j, n/2);
	rob(i+n/2+1, j+n/2+1, n/2);
}

void solve()
{
	int n, m;
	scanf ("%d%d", &n, &m);
	n = (1<<n)-1, m = (1<<m)-1;
	
	rob(0, 0, max(n, m));
	
	FOR(i, 0, n)
	{
		FOR(j, 0, m)
			printf("%d", T[i][j]);
		printf("\n");
	}
} 

 
int main()
{
    int t;
    t=1;//scanf ("%d", &t);
    while (t--)
    	solve();
    return 0;    
}


Measured memory_bytes: 11520
n, m = map(int, input().split())
li = []
for _ in range(m):
    ks = list(map(int, input().split()))
    li.append(ks[1:])
p = list(map(int, input().split()))

ans = 0
for i in range(2 ** n):
    state = [0] * n
    flag = True
    for j in range(n):
        if (i >> j) & 1:
            state[j] = 1
    for k in range(m):
        c = 0
        for l in li[k]:
            c += state[l-1]
        if c%2 != p[k]:
            flag = False
            break
    if flag == True:
        ans += 1

print(ans)

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

// 遅延セグメントツリー
// 区間加算 / 区間和
template<typename T>
struct LazyRangeSum{
    int n;
    vector<T> dat, lazy;

    LazyRangeSum(vector<T> v){
        int sz = (int)v.size();
        n = 1;
        while(n < sz) n <<= 1;
        dat.resize(2*n-1,0);
        lazy.resize(2*n-1,0);

        for(int i=0;i<sz;i++) dat[i+n-1]=v[i];
        for(int i=n-2;i>=0;i--) dat[i]=dat[i*2+1]+dat[i*2+2];
    }

    inline void propagation(int k,int l,int r){
        dat[k]+=lazy[k];
        if(2*k+2<2*n-1){
            lazy[2*k+1]+=(lazy[k]/2);
            lazy[2*k+2]+=(lazy[k]/2);
        }
        lazy[k]=0;
    }

    // add to [a,b)
    void add(int a,int b, T x, int k, int l, int r){
        propagation(k,l,r);
        if(r<=a||b<=l) return;  // not overlap
        if(a<=l&&r<=b){ // [a,b) contains [l,r)
            lazy[k]+=(r-l)*x;
            propagation(k,l,r);
        }else{ // overlap
            add(a,b,x, 2*k+1, l, (l+r)/2);
            add(a,b,x, 2*k+2, (l+r)/2, r);
            dat[k]=dat[2*k+1]+dat[2*k+2];
        }
    }
    void add(int a,int b, T x){ add(a,b,x,0,0,n); }

    // sum of [a,b)
    T get(int a,int b,int k,int l, int r){
        propagation(k,l,r);
        if(r<=a||b<=l) return 0; // not overlap
        if(a<=l&&r<=b){ // contain
            return dat[k]; // 既に伝播済みなのでdatの値を返せば良い
        }
        T lv=get(a,b,2*k+1,l,(l+r)/2);
        T rv=get(a,b,2*k+2,(l+r)/2,r);
        return lv+rv;
    }
    T get(int a,int b){
        return get(a,b,0,0,n);
    }
};

int main(){
    int n,q; cin >> n >> q;
    vector<long long> a(n,0);
    LazyRangeSum<long long> seg(a);
    for(int i=0;i<q;i++){
        int type; cin >> type;
        if(type==0){
            int s,t,x;
            cin >> s >> t >> x;
            s--; t--;
            seg.add(s,t+1,x);
        }else{
            int s,t; cin >> s >> t;
            s--; t--;
            cout << seg.get(s, t+1) << endl;
        }
    }
}



Measured memory_bytes: 8420
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair< int64, int64 > Pi;
struct edge
{
  int to, cost;
};
const int64 INF = 1LL << 60;

struct BinaryIndexedTree
{
  vector< int > data;
  BinaryIndexedTree(int sz)
  {
    data.assign(++sz, 0);
  }
  int Query(int k)
  {
    int ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return(ret);
  }
  void Add(int k, int x)
  {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

int N, M;
vector< edge > graph[100000];

int64 Dijkstra(int s, int g, vector< int64 >& min_cost)
{
  priority_queue< Pi, vector< Pi >, greater< Pi > > Que;
  min_cost.assign(N, INF);
  Que.push(Pi(0, s));
  min_cost[s] = 0;
  while(!Que.empty()) {
    Pi p = Que.top(); Que.pop();
    if(p.second == g) return(p.first);
    if(min_cost[p.second] < p.first) continue;
    for(auto e : graph[p.second]) {
      if(p.first + e.cost < min_cost[e.to]) {
        min_cost[e.to] = p.first + e.cost;
        Que.push(Pi(min_cost[e.to], e.to));
      }
    }
  }
  return(-1);
}


int main()
{
  scanf("%d %d", &N, &M);
  for(int i = 0; i < M; i++) {
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    graph[A].push_back((edge){B, C});
    graph[B].push_back((edge){A, C});
  }

  vector< int64 > toS, toG;
  Dijkstra(0    , -1, toS);
  Dijkstra(N - 1, -1, toG);

  vector< Pi > Start(N);
  for(int i = 0; i < N; i++) Start[i] = Pi(toS[i], i);
  sort(Start.begin(), Start.end());

  vector< int64 > nums(toG);
  nums.push_back(-1);
  sort(nums.begin(), nums.end());
  nums.erase(unique(nums.begin(), nums.end()), nums.end());
  for(int i = 0; i < N; i++) {
    toG[i] = lower_bound(nums.begin(), nums.end(), toG[i]) - nums.begin();
  }

  int Q;
  scanf("%d", &Q);
  vector< pair< Pi, int > > Query(Q);
  for(int i = 0; i < Q; i++) {
    scanf("%lld %lld", &Query[i].first.first, &Query[i].first.second);
    Query[i].second = i;
  }
  sort(Query.begin(), Query.end());

  int ptr = 0;
  vector< int > ret(Q);
  BinaryIndexedTree bit(nums.size());
  for(int i = 0; i < Q; i++) {
    const Pi& q = Query[i].first;
    while(ptr < N && q.first >= Start[ptr].first) {
      bit.Add(toG[Start[ptr].second], 1);
      ++ptr;
    }
    int tail = lower_bound(nums.begin(), nums.end(), q.second) - nums.begin();
    ret[Query[i].second] = bit.Query(nums.size() - 1) - bit.Query(tail - 1); 
  }

  for(int i = 0; i < Q; i++) {
    printf("%d\n", ret[i]);
  }
}

Measured memory_bytes: 15980
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

int ty,a,b,l,r,k;

int Div(int x,int y) {return x/y+((x%y)>0);}

int find(int a,int b) {
	int l=0,r=a+b+1,p=0;
	while (l<=r) {
		int mid=l+r>>1;
		int A=a-mid/(k+1)*k-mid%(k+1),B=b-mid/(k+1);
		if (B/k<=A) p=mid,l=mid+1;
		else r=mid-1;
	}
	return p;
}

int main() {
	for(scanf("%d",&ty);ty;ty--) {
		scanf("%d%d%d%d",&a,&b,&l,&r);
		k=Div(max(a,b),min(a,b)+1);
		int p=find(a,b);
		int A=a-p/(k+1)*k-p%(k+1),B=b-p/(k+1),d=p+B-A*k+1;
		for(int i=l;i<=min(p,r);i++) putchar(i%(k+1)?'A':'B');
		for(int i=max(l,p+1);i<=r;i++) putchar((i-d)%(k+1)?'B':'A');
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
const int mod = 1e9+7;


ll C[2010][2010];

int main() {
  memset(C,0,sizeof C);
  rep(i,2010) {
    for(int j = 0; j <= i; j++) {
      if(j==0||j==i) C[i][j] = 1;
      else {
        C[i][j] = C[i-1][j]+C[i-1][j-1];
        C[i][j] %= mod;
      }
    }
  }
  ll n, k;
  cin >> n >> k;
  for(int i = 1; i <= k; i++) {
    if(n-k+1<i) cout << 0 << endl;
    else cout << C[n-k+1][i]*C[k-1][i-1]%mod << endl;
  }
  return 0;
}

Measured memory_bytes: 35176
#include<bits/stdc++.h>
using namespace std;
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,o,p,q;
    while(cin>>m)
    {
        if(m%2==0)
            cout<<m<<endl;
        else
            cout<<2*m<<endl;
    }
    return 0;
}


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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	LD a, b;
	cin>>a>>b;
	LD w = a*b;
	LL wx = (LL) w;
	cout<<wx;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e3+6;
const int mod = 1e9+7;
const int inf = 1e8;
void solve(){
    ll x;
    cin>>x;
    ll ans = x/11;
    ans*=2;
    if(x%11>0)ans++;
    if(x%11>6)ans++;
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
const ld TAU=2*acos(-1);
const ld eps=1e-7;
const int inf=1e9+99;
const ll linf=1e18+88;
const int P=1e9+7;


string a[512];
int n;
int row_ct[512],col_ct[512];

int32_t main() {
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	bool poss=0;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(a[i][j]=='#') {
		++row_ct[i];
		++col_ct[j];
		poss=1;
	}
	if(!poss) return cout<<-1<<endl,0;

	for(int i=0;i<n;i++) if(row_ct[i]==n) {
		int Z=0;
		for(int j=0;j<n;j++) if(col_ct[j]!=n) ++Z;
		return cout<<Z<<endl,0;
	}
	int be=inf;
	for(int i=0;i<n;i++) if(col_ct[i]>0) {
		int Z=n-row_ct[i];
		for(int j=0;j<n;j++) if(col_ct[j]!=n) ++Z;
		be=min(Z,be);
	}
	for(int i=0;i<n;i++) if(col_ct[i]==0) {
		int Z=n-row_ct[i]+1;
		for(int j=0;j<n;j++) if(col_ct[j]!=n) ++Z;
		be=min(Z,be);
	}
	cout<<be<<endl;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

const ll Lim = 1e18;
const int Mod = 1e9 + 7;

#define pll pair<ll, ll>

int Q;
ll x, y;
vector<pll> fib;
vector<vector<pll>> F;

boolean check(pll x) {
	return x.first <= Lim && x.second <= Lim;
}

void prepare() {
	F.push_back({pll(2, 1)}); // x > y
	F.push_back({pll(3, 2), pll(4, 3)});
	while (!F.back().empty()) {
		vector<pll> g;
		boolean first = true;
		vector<pll>& f = F.back();
		for (auto x : f) {
			if (first) {
				pll y = pll(x.second + x.first, x.first);
				if (check(y))
					g.push_back(y);
				y = pll(x.second * 2 + x.first, x.first + x.second);
				if (check(y))
					g.push_back(y);
			} else {
				pll y = pll(x.second + x.first, x.first);
				if (check(y))
					g.push_back(y);
			}
			first = false;
		}
		F.push_back(g);
	}
	fib.emplace_back(2, 1);
	ll a = 2, b = 1;
	while (true) {
		b += a;
		swap(a, b);
		if (a <= Lim && b <= Lim) {
			fib.emplace_back(a, b);
		} else {
			break;
		}
	}
}

int M;
int work(ll n, ll m) {
	ll ans = 0;
	for (auto x : F[M]) {
		if (x.first <= n && x.second <= m) {
			ans = (ans + (n - x.first) / x.second + 1) % Mod;
		}
	}
	return ans;
}

int main() {
	prepare();
	scanf("%d", &Q);
	while (Q--) {
		scanf("%lld%lld", &x, &y);
		if (x < y)
			swap(x, y);
		if (x == 1 && y == 1) {
			M = 0;
		} else {
			int l = 0, r = (signed) fib.size() - 1, mid;
			while (l <= r) {
				mid = (l + r) >> 1;
				if (x >= fib[mid].first && y >= fib[mid].second) {
					l = mid + 1;
				} else {
					r = mid - 1;
				}
			}
			M = l - 1;
		}
		int ans = work(x, y);
		ans += work(y, x);
		if (M == 0)
			ans += min(x, y);
		printf("%d %d\n", M + 1, ans % Mod);
	}
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define MAXN 100005
const int mod = 1e9 + 7;
using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    int len_s = s.length();
    if(t.substr(0,len_s) == s) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    int H, W;
    while(1) {
        cin >> H >> W;
        if(H < 1 | W < 1)
            break;
        rep(i, H) {
            rep(j, W) {
                if(i > 0 && i < H - 1 && j > 0 && j < W - 1) {
                    cout << '.';
                } else {
                    cout << '#';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3100
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def lcs(s1, s2):
    dp = []
    for s2_k in s2:
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if not chr_idx:
                break
            dp[i] = min(cur_idx, chr_idx)
            bgn_idx = cur_idx
        else:
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if chr_idx:
                dp.append(chr_idx)
    return len(dp)

q = INT()

for _ in range(q):
	S = input()
	T = input()
	print(lcs(S, T))



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

using namespace std;

int main() {
    string S;
    string T;
    cin >> S;
    cin >> T;
    
    string ret = S;
    
    int flag = 1;
    int pos = -1;
    for (int i = 0; i < ret.size() - T.size() + 1; ++i)
    {
        flag = 1;
        for (int j = 0; j < T.size(); ++j)
        {
            if (T[j] != ret[i + j] && ret[i + j] != '?')
            {
                flag = 0;
                break;
            }
        }
        if (flag == 1)
        {
            pos = max(pos, i);
        }
    }
    if (pos >= 0)
    {
        for (int j = 0; j < T.size(); ++j)
        {
            ret[pos + j] = T[j];
        }
        for (int i = 0; i < ret.size(); ++i)
        {
            if (ret[i] == '?')
            {
                ret[i] = 'a';
            }
        }
        cout << ret << endl;
    }
    else
    {
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
using namespace std;

int main(){
	int N;
	int S[100];
	int sum=0;
	int Z = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
		sum += S[i];
		if (S[i] % 10 != 0)Z++;
	}
	sort(S, S + N);


	if (sum % 10 == 0) {
		if (Z != 0) {
			for(int i = 0; i < N; i++) {
				if (S[i] % 10 != 0) {
					cout << sum - S[i] << endl;
					break;
				}
			}
		}
		else {
			cout << 0 << endl;
		}
	}
	else {
		cout << sum << endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := new(big.Int)
	b := new(big.Int)
	fmt.Sscan(getNextString(scanner), a)
	fmt.Sscan(getNextString(scanner), b)
	fmt.Fprintln(writer, a.Sub(a, b))
}



Measured memory_bytes: 6504
var n,m,x,y,i,a:Longint;
begin
	read(n,m,x,y);
	for i:=1 to n do begin
		read(a);
		if x<a then x:=a;
	end;
	for i:=1 to m do begin
		read(a);
		if a<y then y:=a;
	end;
	if x<y then write('No ');
	writeln('War');
end.


Measured memory_bytes: 128
from heapq import heappop, heapify, heappush


def main():
    n, m = map(int, input().split())
    work = [[] for _ in range(10 ** 5 + 1)]
    for _ in range(n):
        a, b = map(int, input().split())
        work[a].append(b)
    ans = 0
    q = []
    heapify(q)
    for i in range(1, m + 1):
        for w in work[i]:
            heappush(q, -w)
        if len(q) == 0:
            continue
        ans += heappop(q)
    ans *= -1
    print(ans)


if __name__ == '__main__':
    main()


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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

int c[3][3];
int main(){
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++)  cin >> c[i][j];
    }
    int sa[3];
    sa[0] = c[0][0] - c[0][1];
    sa[1] = c[0][0] - c[0][2];
    sa[2] = c[0][1] - c[0][2];
    for(int i = 0; i < 3; i++){
        for(int j = 1; j < 3; j++){
            if(sa[j-1] != c[i][0] - c[i][j]){
                cout << "No\n";
                return 0;
            }
        }
        if(sa[2] != c[i][1] - c[i][2]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int x = scan.nextInt();

		for (int i = 3; i <= x; i++) {
			if (i % 10 == 3 || i % 3 == 0) {
				System.out.print(" " + i);
			}

			else {
				int y = 0;
				y = i;
				while (y > 0) {
					y /= 10;

					if (y % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
				}
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 24272
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}
int main(void){
  int n,i;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  qsort(a,n,sizeof(int),cmp);
  printf("%d\n",a[n-1]-a[0]);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();

        int d = 2;
        while (true) {
            if (d > X/2) {
                break;
            }

            if (X%d == 0) {
                X++;
                d = 2;
            } else {
                d++;
            }
        }

        System.out.println(X);
    }
}


Measured memory_bytes: 21844