akhauriyash/Code-Regression huggingface dataset:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))
B = list(map(int, sys.stdin.buffer.readline().split()))

graph = [[] for _ in range(51)]
for i in range(51):
    for k in range(1, i + 1):
        # i から i%k に k を使って行ける
        graph[i].append((i % k, k))

memo = [[None] * 51 for _ in range(51)]


def can_go(s, t, graph):
    if s == t:
        return True
    if memo[s][t] is not None:
        return memo[s][t]
    ret = False
    for u, _ in graph[s]:
        if can_go(u, t, graph):
            ret = True
            break
    memo[s][t] = ret
    return ret


ok = True
for a, b in zip(A, B):
    ok &= can_go(a, b, graph)
# 同頑張っても無理
if not ok:
    print(-1)
    exit()

ans = 0
# ある k を使うだけで、0 から k-1 までのすべてを使うよりもコストが大きくなる
# →k の大きい順に使うか使わないかを決められる。
for k in reversed(range(51)):
    # k を使わないグラフを構築
    next_graph = [[] for _ in range(51)]
    for v in range(len(graph)):
        for u, w in graph[v]:
            if w != k:
                next_graph[v].append((u, w))
    memo = [[None] * 51 for _ in range(51)]
    ok = True
    for a, b in zip(A, B):
        ok &= can_go(a, b, next_graph)
    if ok:
        # この k は使わなくていい
        graph = next_graph
    else:
        # この k は必要
        ans += 1 << k
print(ans)
# print(bin(ans))


Measured memory_bytes: 50652
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;
int m;

class M{
	public:
	ll a[3][3];
	M() {
		memset(a, 0, sizeof a);
	}
	M operator*(M b) {
		M c;
		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++) {
				for(int k=0;k<3;k++) {
					c.a[i][j] += a[i][k] * b.a[k][j] % m;
					c.a[i][j] %= m;
				}
			}
		}
		return c;
	}	
};

M pw(M A, int b) {
	if(b == 0) {
		M id;
		for(int i=0;i<3;i++)
			id.a[i][i] = 1;
		return id;
	}
	M T = pw(A, b/2);
	if(b & 1) {
		return T * T * A;
	} else {
		return T * T;
	}
}

int32_t main()
{
	IO_OP;
	
	int L, a, b, p = 1;
	cin >> L >> a >> b >> m;
	M v;
	v.a[0][0] = 0, v.a[1][0] = a % m, v.a[2][0] = b % m;
	for(int w=1;w<=18;w++,p *= 10) {
		int l = max((p-a+b-1)/b + 1, 1LL);
		int r = (p*10-a+b-1)/b;
//		cout << l << " " << r << endl;
//		cout << v.a[0][0] << endl;
		if(l > L) break;
		if(r < l)
			continue;	
		r = min(r, L);
		int k = r - l + 1;
		M A;
		A.a[0][0] = p * 10 % m;
		A.a[0][1] = 1;
		A.a[1][1] = 1;
		A.a[1][2] = 1;
		A.a[2][2] = 1;
		A = pw(A, k);
		v = A * v;
	}
	cout << v.a[0][0] << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		final String s = sc.next();
		final String t = sc.next();

		final int sLength = s.length();

		String result = "No";
		String s2 = s;
		for (int i = 0; i < sLength; i++) {
			final String last = s2.substring(sLength - 1, sLength);
			String tmps = s2.substring(0, sLength - 1);
			s2 = last + tmps;
			if (s2.equals(t)) {
				result = "Yes";
				break;
			}
		}

		java.lang.System.out.println(result);

	}

}


Measured memory_bytes: 21844
/*
- テ」ツ?古・ツキツヲテ、ツクツ?or テ・ツ渉ウテ、ツクツ凝」ツ?催」ツ?クテ」ツ?ョテ」ツδォテ」ツδシテ」ツδ暗」ツつ津ィツ?ε」ツ?暗」ツつ凝・ツ?エテ・ツ青暗」ツ?づ」ツδ榲」ツδウテ」ツδ湘」ツδε」ツつソテ」ツδウティツキツ敕ゥツ崢「テ」ツ?ァテ・ツ債?・ツ按?
- テ」ツ?古・ツキツヲテ、ツクツ?or テ・ツ渉ウテ、ツクツ甘」ツ?催」ツ?クテ」ツ?ョテ」ツδォテ」ツδシテ」ツδ暗」ツ?ッテ」ツ??」ツ?ェテ」ツつ凝」ツ?ケテ」ツ?湘」ツ?ェテ」ツ?ェテ」ツつ?」ツつ津、ツスツソテ」ツ?」テ」ツ?ヲテ」ツ??」ツ?づ」ツ?ィテ」ツ?ッテァツクツヲ or テヲツィツェテ」ツつ津、ツスツソテ」ツ??
-- テァツクツヲテ」ツ?ョdiff, テヲツィツェテ」ツ?ョdiffテ」ツつ津」ツ?敕」ツつ古」ツ?榲」ツつ古ヲツアツづ」ツつ?」ツ?ヲテ」ツ??」ツ?敕」ツつ古」ツつ嘉」ツ?ョテヲツ慊?・ツーツ湘」ツ?ョテ・ツ按?」ツ??」ツ?妥ヲツ鳴愿」ツつ?、ツスツソテ」ツ?暗」ツつ?
-- テ」ツ?づ」ツ?ィテ」ツ?ッテ」ツ??」ツ?敕」ツつ古」ツつ嘉」ツ?ョテヲツ慊?・ツ、ツァテ」ツ?凝」ツつ嘉ヲツ鳴愿」ツつ?」ツ?ョテ・ツ崢榲ヲツ閉ーテ」ツつ津」ツ?イテ」ツ??」ツ?淌・ツ按?」ツ??」ツ?妥・ツ仰陛」ツ?妥」ツ?ーテ」ツ??」ツ??
 */
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int W, H, N;
vector<int> X, Y;

int calcDist(int x1, int y1, int x2, int y2){
  if((x1 >= x2 && y1 <= y2) ||
     (x1 <= x2 && y1 >= y2)){
    return abs(x1 - x2) + abs(y1 - y2);
  }

  int diffX = abs(x1 - x2);
  int diffY = abs(y1 - y2);

  int minDiff = min(diffX, diffY);
  int maxDiff = max(diffX, diffY);

  return minDiff + (maxDiff - minDiff);
}

void solve(){
  int ans = 0;
  for(int i = 0; i < N - 1; i++){
    ans += calcDist(X[i], Y[i], X[i + 1], Y[i + 1]);
  }
  cout << ans << endl;
}

int main(){
  while(cin >> W >> H >> N){
    X.clear();
    Y.clear();

    for(int i = 0; i < N; i++){
      int x, y;
      cin >> x >> y;
      X.push_back(x);
      Y.push_back(y);
    }

    solve();
  }
}

Measured memory_bytes: 1228
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int N,L,i;
    cin >> N >> L;
    
    //辞書順なら，配列からのsort関数で行こう

    vector<string> A(N);

    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }

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

    for(int i=0;i<N;i++){
        cout << A.at(i);
    }



    
    
    
}

Measured memory_bytes: 256
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    int sz = 1;
    rep(_, n) sz *= 2;
    vi a(sz);
    cin >> a;
    vi mx(sz);
    rep2(i, 1, sz) {
        int fi = 0, se = 0;
        for (int bit = i;; (--bit) &= i) {
            if (fi < a[bit]) {
                se = fi;
                fi = a[bit];
            } else chmax(se, a[bit]);
            if (bit == 0) break;
        }
        mx[i] = fi + se;
    }
    rep2(k, 1, sz) {
        int ans = mx[k];
        int now = k;
        rep(i, n) {
            if (k >> i & 1) {
                chmax(ans, mx[now - 1]);
                now -= 1 << i;
            }
        }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 5344
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q;
	cin >> N >> Q;
	vector<int> A(N);
	vector<int> res(Q);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int X;
	vector<int> sum(N);
	vector<int> sumrev(N);
	for (int i = 0; i < N; i++) {
		if ((i + N) % 2 == 1) {
			sum[i] = A[i];
		}
		if (i > 0)sum[i] += sum[i - 1];
	}
	for (int i = N - 1; i >= 0; i--) {
		sumrev[i] = A[i];
		if (i + 1 < N)sumrev[i] += sumrev[i + 1];
	}
	for (int i = 0; i < Q; i++) {
		cin >> X;
		int ok = N - 1;
		int ng = -1;
		int l;
		while (ok - ng > 1) {
			int m = (ok + ng) / 2;
			int len = A[m] - X;
			if (len < 0) {
				ng = m;
				continue;
			}
			int c = upper_bound(A.begin(), A.end(), X + len - 1) - lower_bound(A.begin(), A.end(), X - len);
			//cerr << X << " " << m << " " << c << endl;
			if (c +1 >= N - m) {
				ok = m;
			}
			else {
				ng = m;
			}
		}
		int le = 2 * ok - N - 1;
		//cerr << X << " " << ok << " " << le <<  endl;

		res[i] = 0;
		if (le >= 0)res[i] += sum[le];
		res[i] += sumrev[ok];
	}
	for (int i = 0; i < Q; i++) {
		cout << res[i] << endl;
	}

}

Measured memory_bytes: 4864
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  vector<int> n;
  int temp;
  while (cin >> temp) {
    n.push_back(temp);
  }
  sort(n.begin(), n.end(), greater<int>());
  for (int i = 0; i < 3; i++) {
    printf("%d\n", n[i]);
  }
  return 0;
}

Measured memory_bytes: 1196
s = input()


def solve(query):
    while 1:
        for frag in ("erase", "eraser", "dream", "dreamer"):
            if query.endswith(frag):
                query = query[:-len(frag)]
                break
        else:
            print("NO")
            break
        if not query:
            print("YES")
            break



solve(s)

Measured memory_bytes: 3316
import Data.List

splitRec _ [] = []
splitRec n xs = let (h, t) = splitAt n xs in h : splitRec n t

counting = (++[(0, 0)]) . sortBy (flip compare) . map (\es -> (length es, head es)) . group . sort 

calc n [os, es]
  | ov /= ev || length (takeWhile ((==oc) . fst) os) > 1 || length (takeWhile ((==ec) . fst) es) > 1 = n - oc - ec
  | otherwise = min (n - oc - secondc es) (n - ec - secondc os)
  where
    (oc, ov) = head os
    (ec, ev) = head es
    secondc = fst . head . tail

main = calc <$> readLn <*> (map counting . transpose . splitRec 2 . map (read :: String -> Int) . words <$> getLine) >>= print

Measured memory_bytes: 52732
a, b, c, d = map(int, input().split())
if c%b==0:
    x = c//b
else:
    x = c//b+1
if a%d==0:
    y = a//d
else:
    y = a//d+1
    
if x<=y:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61608
import sys
input=lambda: sys.stdin.readline().rstrip()
mod=10**9+7
n,m=map(int,input().split())
A=set(int(i) for i in input().split())
B=set(int(i) for i in input().split())
if len(A)<n or len(B)<m:
  print(0)
else:
  ans=1
  r,c=0,0
  for i in range(1,m*n+1)[::-1]:
    if i in A and i in B:
      r+=1
      c+=1
    elif i in A:
      ans=(ans*c)%mod
      r+=1
    elif i in B:
      ans=(ans*r)%mod
      c+=1
    else:
      if r==n and c==m:
        ans=(ans*i)%mod
      else:
        ans=(ans*(r*c-(m*n-i)))%mod
  print(ans)

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

int main(){

    vector<char> S(3);

    for(int i=0; i<S.size(); i++)
    {
        cin >> S.at(i);
    }

    bool can=true;

    if((S.at(0)==S.at(1)) && (S.at(1)==S.at(2)))
    {
        can = false;
    }

    if(can)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	set<string> st;
	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		st.insert(s);
	}
	cout << st.size() << '\n';
	return 0;
}

Measured memory_bytes: 19196
H, W = map(int, raw_input().split())
while H | W != 0:
    for i in range(H):
        if i == 0 or i == H - 1:
            print '#' * W
        else:
            print '#' + '.' * (W - 2) + '#'
    print ''
    H, W = map(int, raw_input().split())

Measured memory_bytes: 4196
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll jo(int a, int b) {
  ll s = 1;
  for(int i = 0; i < b; i++) {
    s *= a;
  }
  return s;
}
/*ll sumsum(bitset<10> &cal, vector<string> &num) {
  string x;
  ll sum = 0;
  for(int i = 9; i >= 0; i--) {
    if(cal.test(i)) {
      x += num.at(i);
      //cout << x << endl;
    } else {
      int number = stoi(x);
      sum += number;
      x = "";
    }
  }
  return sum;
}*/
int main() {
  string S;
  cin >> S;
  int a = 10 - S.size();
  int b = S.size() - 1;
  /*for(int i = 0; i < a; i++) {
    S = "0" + S;
    //cout << 1;
  }*/
  //cout << S << endl;
  /*vector<string> num(S.size());
  for(int i = 0; i < num.size(); i++) {
    num.at(i) = S.at(i);
    //cout << num.at(i);
  }
  cout << endl;*/
  ll sum = 0;
  for(ll i = 0; i < jo(2, S.size()); i++) {
    //bitset<10> cal(i);
    ll l = i;
    vector<bool> cal(S.size());
    for(int k = 0; k < cal.size(); k++) {
      cal.at(k) = l % 2;
      l /= 2;
    }
    //cout << cal << endl;
    //sum += sumsum(cal, num);
    string x = "";
    for(int j = 0; j < S.size(); j++) {
      if(cal.at(j)) {
        x += S.at(j);
        if(j == S.size() - 1) {
          ll number = stoll(x);
          //if(number > 0) {
          //cout << "x=" << x << endl;
          //}
          sum += number;
          x = "";
        }
        //cout << x << endl;
      } else {
        if(x == "") {
          continue;
        }
        ll number = stoll(x);
        //if(number > 0) {
        //cout << "x=" << x << endl;
        //}
        sum += number;
        x = "";
      }
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int par[100010], rankh[100010];
void init(int n) {
	for (int i = 0; i <= n; i++) {
		par[i] = i;
		rankh[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rankh[x] < rankh[y])par[x] = y;
	else {
		par[y] = x;
		if (rankh[x] == rankh[y])rankh[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int n, m, p[100010], x, y, ans;
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> p[i];
	init(n + 10);
	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		unite(p[x], p[y]);
	}
	for (int i = 1; i <= n; i++) {
		if (same(p[i], i))ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main (void){

	/*?????°?????£?¨???¨?????????*/

	int n = 0 ;
	int m = 0 ;				//??????????????±???????´????????????°

	int i = 0 ;
	int j = 0 ;				//???????????°

	/*n,m???????????????*/

	scanf("%d", &n);
	scanf("%d" ,&m);


	/*
	 * ??????????????????????????±??????????????£?¨?
	 * ?????????????????¶??????????§£??¨????????????????????????????´????????°???????0
	 * ?????§?????????1000*1000*100=10~8
	 */

	int A[n][m];
	int b[m];
	int c[n];

	/*??????c????????????*/

	for( i = 0 ; i < n ; i++){
		c[i] = 0 ;
	}


	/*??????A???????´??????????*/

	for( i = 0 ; i < n ; i++){			//n(???)????????????
		for( j = 0 ; j < m ; j++){		//m(???)????????????
			scanf("%d", &A[i][j]);
		}
	}

	/*????????????b???????´??????????*/

	for( j = 0 ; j < m ; j++){		//????´????m???
		scanf("%d", &b[j]);
	}

	/*c???????´?????¨??????¨??????*/

	for( i = 0 ; i < n ; i++){			//????????????c???????´????n???
		for( j = 0 ; j < m ; j++){
			c[i] += A[i][j] * b[j];
		}
		printf("%d\n" ,c[i]);
	}


	return 0;
}

Measured memory_bytes: 640
def print_even_case(N):
    for i in range(1, N ):
        for j in range(i + 1, N + 1):
            if i + j != N + 1:
                print("{} {}".format(i, j))

N = int(input())

if N % 2 == 0:
    print((N - 2) * N // 2)
    print_even_case(N)
else:
    print((N - 3) * (N - 1) // 2 + (N - 1))
    print_even_case(N - 1)
    for i in range(1, N):
        print("{} {}".format(i, N))

Measured memory_bytes: 3336
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	vector<int> edge(3);
	int triangle = 0;
	int right_triangle = 0;
	int acute_triangle = 0;
	int obtuse_triangle = 0;
	while(cin >> edge[0] >> edge[1] >> edge[2])
	{
		if(edge[0] + edge[1] > edge[2] && edge[1] + edge[2] > edge[0] && edge[2] + edge[0] > edge[1])
		{
			++triangle;
		}
		else
		{
			break;
		}
		sort(edge.begin(), edge.end());
		double cos_theta = (double)(edge[0] * edge[0] + edge[1] * edge[1] - edge[2] * edge[2]) / (2 * edge[0] * edge[1]);
		if( edge[0] * edge[0] + edge[1] * edge[1] == edge[2] * edge[2] ||
			edge[1] * edge[1] + edge[2] * edge[2] == edge[0] * edge[0] ||
			edge[2] * edge[2] + edge[0] * edge[0] == edge[1] * edge[1])
		{
			++right_triangle;
		}
		else if(cos_theta < 0)
		{
			++obtuse_triangle;
		}
		else
		{
			++acute_triangle;
		}
	}
	cout << triangle << " " << right_triangle << " " << acute_triangle << " " << obtuse_triangle << endl;
}

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

Measured memory_bytes: 1212
using System;

namespace A___Maximize_the_Formula
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);
            var d = 10 * a + b + c;
            var e = a + 10 * b + c;
            var f = a + b + 10 * c;
            var max = d;
            max = Math.Max(max, e);
            max = Math.Max(max, f);
            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pai 3.1415926535

int main(void) {
	int N;
	scanf("%d", &N);
	int count = 0;
	for (int i = N; i >1; i /= 2) {
		count++;
	}
	printf("%d\n",(int)pow(2,count));

	return 0;

}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

bool isPalindrome(int x) {
	vector <int> Vu;
	while (x) {
		Vu.push_back(x % 10);
		x /= 10;
	}
	
	int i;
	for (i = 0; i < Vu.size(); i++) if (Vu[i] != Vu[Vu.size() - 1 - i]) return false;
	return true;
}
int main() {
	int A, B, i, j;
	scanf("%d %d", &A, &B);

	int ans = 0;
	for (i = A; i <= B; i++) ans += (int)isPalindrome(i);
	return !printf("%d\n", ans);
}

Measured memory_bytes: 384
number_count = int(input())
b_numbers = list(map(int, input().split()))
sum_max_a = 0
for x in range(number_count):
  if x == number_count - 1:
    sum_max_a += b_numbers[x - 1]
  elif x > 0:
    sum_max_a += min(b_numbers[x], b_numbers[x - 1])
  else:
    sum_max_a += b_numbers[x]
print(sum_max_a)

Measured memory_bytes: 3188
n,m,c=map(int,input().split())
ls1 = list(map(int,input().split()))
ls2 = [list(map(int,input().split())) for i in range(n)]
ls = []
for i in range(n):
    a = 0
    for j in range(m):
        a += ls2[i][j]*ls1[j]
    a += c
    if a > 0:
        ls.append(1)
print(len(ls))

Measured memory_bytes: 3188
#include <stdio.h>
#define LIMIT 100010

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  int N, W;
  scanf("%d%d", &N, &W);

  int w[N], v[N];
  for (int i = 0; i < N; i++) {
    scanf("%d%d", &w[i], &v[i]);
  }

  int dp[LIMIT+1];
  for (int i = 0; i < LIMIT; i++) {
    dp[i] = W+1;
  }
  dp[0] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = LIMIT; j >= v[i]; j--) {
      dp[j] = min(dp[j], dp[j-v[i]]+w[i]);
    }
  }

  for (int i = LIMIT-1; i >= 0; i--) {
    if(dp[i] <= W){
      printf("%d\n", i);
      return 0;
    }
  }
}

Measured memory_bytes: 512
N=io.read("n")
M=io.read("n")
t={}
for i=1,M do 
  t[i]=io.read("n")
end
if N>=M then 
  print(0)
  else
	table.sort(t)
	r={}
	for i=1,M-1 do
  		r[i]=t[i+1]-t[i]
	end
	table.sort(r)
	s=0
	for i=1,M-N do 
    	s=s+r[i]
    end
  	print(s)
end

Measured memory_bytes: 4472
import math
from statistics import mean

while True:

    n = int(input())

    if n == 0:
        break
    
    scores = [float(x) for x in input().split()]
    m = mean(scores)
    
    a = 0
    a2 = 0
    for i in range(len(scores)):
        a2 += (scores[i] - m) ** 2 / len(scores)
    
    a = math.sqrt(a2)
    
    print(a)


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

using namespace std;

int calc_Greatest_common_divisor(int n, int m)
{
  while (n % m != 0)
  {
    int temp = m;
    m = n % m;
    n = temp;
  }
  return m;
}

long long calc_Least_common_multiple(long long n, long long m)
{
  long long big = max(n, m);
  if (big == m)
  {
    m = n;
    n = big;
  }
  long long ans = n * m;
  return ans / calc_Greatest_common_divisor(n, m);
}

void AntiDivision()
{
  long long a;
  long long b;
  long long c;
  long long d;
  cin >> a >> b >> c>> d;
  
  long long sub = 0;
  long long all = b - a + 1;
  long long lcm = calc_Least_common_multiple(c, d);
  sub = (b / c - (a - 1) / c) + (b / d - (a - 1) / d) - (b / lcm - (a - 1) / lcm);

  cout << all - sub << endl;
  return;
}

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

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < 4; i++) {
    if (s[i] == '+') ans++;
    if (s[i] == '-') ans--; 
  }
  cout << ans << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    string s, c;
    int q, cmd, f;
    bool r = false;
    deque<string> deq;
    cin >> s >> q;
    deq.push_back(s);
    rep(i, q){
        cin >> cmd;
        if(cmd == 1){
            // cmd 1
            r = r^1;
        }
        else{
            // cmd 2
            cin >> f >> c;
            if(!r){
                if(f == 1){
                    deq.push_front(c);
                }
                else if(f == 2){
                    deq.push_back(c);
                }
            }
            else if(r){
                if(f == 1){
                    deq.push_back(c);
                }
                else if(f == 2){
                    deq.push_front(c);
                }
            }
        }
    }
    s = "";
    for(auto p: deq) s+= p;
    if(r) reverse(all(s));
    cout << s << endl;
}

Measured memory_bytes: 12368
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
#define SIZE 200000
class unionfind
{
public:
	int par[SIZE];
	int ran[SIZE];
	int ren[SIZE];
	void init()
	{
		for (int i = 0; i<SIZE; i++)
		{
			par[i] = i;
			ran[i] = 0;
			ren[i] = 1;
		}
	}
	int find(int a)
	{
		if (a == par[a])return a;
		else return par[a] = find(par[a]);
	}
	void unite(int a, int b)
	{
		a = find(a);
		b = find(b);
		if (a == b)return;
		if (ran[a]>ran[b])
		{
			par[b] = a;
			ren[a] += ren[b];
		}
		else
		{
			par[a] = b;
			ren[b] += ren[a];
		}
		if (ran[a] == ran[b])ran[b]++;
	}
};
unionfind uf;
int col[200000], wei[200000];
typedef pair<int, int>pii;
vector<pii>ws[200000];
typedef long long ll;
ll mod = 1000000007;
vector<int>ans[200000];
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
int main()
{
	int num, ga, gb;
	scanf("%d%d%d", &num, &ga, &gb);
	for (int i = 0; i < num; i++)scanf("%d%d", &col[i], &wei[i]), col[i]--, ws[col[i]].push_back(make_pair(wei[i], i));
	uf.init();
	for (int i = 0; i < num; i++)sort(ws[i].begin(), ws[i].end());
	vector<pii>v;
	for (int i = 0; i < num; i++)if (!ws[i].empty())v.push_back(ws[i][0]);
	sort(v.begin(), v.end());
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < ws[i].size(); j++)if (ws[i][0].first + ws[i][j].first <= ga)uf.unite(ws[i][0].second, ws[i][j].second);
		if (col[v[0].second] != i)
		{
			for (int j = 0; j < ws[i].size(); j++)
			{
				if (v[0].first + ws[i][j].first <= gb)uf.unite(v[0].second, ws[i][j].second);
			}
		}
		else if (v.size() >= 2)
		{
			for (int j = 0; j < ws[i].size(); j++)
			{
				if (v[1].first + ws[i][j].first <= gb)uf.unite(v[1].second, ws[i][j].second);
			}
		}
	}
	for (int i = 0; i < num; i++)ans[uf.find(i)].push_back(col[i]);
	invinit();
	ll ret = 1;
	for (int i = 0; i < num; i++)
	{
		sort(ans[i].begin(), ans[i].end());
		int now = -1, cnt = 0;
		ans[i].push_back(-2);
		vector<int>r;
		for (int j = 0; j < ans[i].size(); j++)
		{
			if (now != ans[i][j])r.push_back(cnt), now = ans[i][j], cnt = 1;
			else cnt++;
		}
		ll s = 1;
		int sum = ans[i].size() - 1;
		for (int j = 0; j < r.size(); j++)
		{
			s *= com(sum, r[j]);
			s %= mod;
			sum -= r[j];
		}
		ret = ret*s%mod;
	}
	printf("%lld\n", ret);
}

Measured memory_bytes: 31604
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void){
	long long inf=10000000000;
	int N, H[101010], dp[101010];
	cin >> N;
    for(int i=0;i<N;i++){ 
		cin >> H[i];
	}
    for(int i=0;i<N;i++){ 
		dp[i] = inf;
	}
	dp[0] = 0;
 
    for(int i=0;i<N;i++){ 
        dp[i+1]=min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]));
        dp[i+2]=min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]));
    }
    cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#define DEBUG 0

/**
 * File    : D2.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-3-24 22:42:41
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
const ll MOD = 1000000007;

int N;
set<string> forbid;
string chars[4] = {"A", "G", "C", "T"};
typedef tuple<int, string> key;
map<key, ll> M;

void make(string S)
{
  if ((int)S.size() < 4)
  {
    for (auto i = 0; i < 4; i++)
    {
      make(S + chars[i]);
    }
  }
  else
  {
    for (auto i = 0; i < 4; i++)
    {
      string T = S;
      if (i < 3)
      {
        swap(T[i], T[i + 1]);
      }
      for (auto i = 0; i < 2; i++)
      {
        if (T.substr(i, 3) == "AGC")
        {
          forbid.insert(S);
          return;
        }
      }
    }
  }
}

bool ok(string S)
{
  return (forbid.find(S) == forbid.end());
}

ll dfs(int x, string S)
{
  if (M.find(key(x, S)) != M.end())
  {
    return M[key(x, S)];
  }
  if (x == N)
  {
    return 1;
  }
  ll ans = 0;
  for (auto i = 0; i < 4; i++)
  {
    string T = S + chars[i];
    if (ok(T))
    {
      ans += dfs(x + 1, T.substr(1, 3));
      ans %= MOD;
    }
  }
  return M[key(x, S)] = ans;
}

int main()
{
  cin >> N;
  make("");
#if DEBUG == 1
  for (auto x : forbid)
  {
    cerr << x << endl;
  }
#endif
  cout << dfs(0, "TTT") << endl;
}

Measured memory_bytes: 896
#include <iostream>
#define INF 1e9

using namespace std;

void chmax(int& a, int b) {
    if(b > a) {
        a = b;
    }
    return;
}

int main() {
    int N;
    cin >> N;
    int abc[N][3];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> abc[i][j];
        }
    }

    int dp[N][3];
    for(int i = 0; i < 3; i++) {
        dp[0][i] = abc[0][i];
    }
    for(int i = 1; i < N; i++) {
        for(int j = 0; j < 3; j++) {
            dp[i][j] = 0;
        }
    }

    for(int i = 1; i < N; i++) {
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(j != k) {
                    chmax(dp[i][j], dp[i-1][k] + abc[i][j]);
                }
            }
        }
    }

    int max = dp[N-1][0];
    for(int i = 1; i < 3; i++) {
        if(max < dp[N-1][i]) {
            max = dp[N-1][i];
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int H,W;

char field[10][10];

int main(){
  scanf("%d %d",&H,&W);
  int i,j;
  for (i = 0; i < H; i++) {
    scanf("%s",field[i]);
  }
  int ans = 0;
  for ( i = 0; i < H; i++) {
    for ( j = 0; j < W; j++) {
      if (field[i][j] == '#') ans+=1;
    }
  }
  if (ans == H+W-1) printf("Possible\n");
  else printf("Impossible\n" );

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
char a[200010];
int d[200010];
int nxt[200010][30];
int main()
{


    scanf("%s", a);
    int n = strlen(a);
    d[n] = 1;
    d[n + 1] = 0;
    for (int i = 0; i < 26; i++) {
        nxt[n][i] = n;
    }
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            nxt[i][j] = nxt[i + 1][j];
        }
        nxt[i][a[i] - 'a'] = i;
        d[i] = inf;
        for (int j = 0; j < 26; j++) {
            d[i] = min(d[i], d[nxt[i][j] + 1] + 1);
        }
    }
    int loc = 0;
    while (loc != n + 1) {
        int j = 0;
        while (d[nxt[loc][j] + 1] + 1 != d[loc]) j++;
        putchar('a' + j);
        loc = nxt[loc][j] + 1;
    }
    puts("");
}


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

const int MAX=100;
const int INF=(1<<21);

int main(){

  int n, m;
  int a, b, cost, time;
  int p, q, r;
  int rail_cost[MAX][MAX];
  int rail_time[MAX][MAX];
  int k;
  while( cin >> n >> m, n+m ) {
 
    
    for(int i=0; i<m; i++) {
      for(int j=0; j<m; j++) {
	rail_cost[i][j] = INF;
	rail_time[i][j] = INF;
      }
    }
    
    for(int i=0; i<n; i++) {
      cin >> a >> b >> cost >> time; 
      rail_cost[a-1][b-1] = rail_cost[b-1][a-1] = cost;
      rail_time[a-1][b-1] = rail_time[b-1][a-1] = time;
    }
    
    for(int i=0; i<m; i++) {
      for(int j=0; j<m; j++) {
	for(int k=0; k<m; k++) {
	  rail_cost[j][k] = min(rail_cost[j][k], rail_cost[j][i]+rail_cost[i][k]);
	  rail_time[j][k] = min(rail_time[j][k], rail_time[j][i]+rail_time[i][k]);
	}
      }
    }
    
    cin >> k;
    for(int i=0; i<k; i++) {
      cin >> p >> q >> r;
      if( !r ) {
	cout << rail_cost[p-1][q-1] << endl;
      } 
      else {
	cout << rail_time[p-1][q-1] << endl;
      }
    }
  }
}

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

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) << endl;
    
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    unsigned long long h, w;
    std::cin >> h >> w;
    if (h == 1 || w == 1) {
        std::cout << 1 << std::endl;
    } else {
        std::cout << (h * w + 1ull) / 2ull << std::endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

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

class Solver {

    public int getHlast(char[] S) {
        int hlast = S.length - 1;
        for (int i = hlast; i >= 0; i--) {
            if (S[i] == 'W' || S[i] == 'E') {
                return i;
            }
        }
        return 0;
    }

    public int getVlast(char[] S) {
        int vlast = S.length - 1;
        for (int i = vlast; i >= 0; i--) {
            if (S[i] == 'N' || S[i] == 'S') {
                return i;
            }
        }
        return 0;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        int N = S.length;

        int hlast = getHlast(S);
        int vlast = getVlast(S);

        int[] a = new int[2];
        for (int i = 0; i < N; i++) {
            char ch = S[i];
            switch (ch) {
                case 'N':
                    if (a[0] < 0 && i == vlast) a[0]=0;
                    else a[0] = 1;
                    break;
                case 'S':
                    if (a[0] > 0 && i == vlast) a[0]=0;
                    else a[0] = -1;
                    break;
                case 'W':
                    if (a[1] < 0 && i == hlast) a[1]=0;
                    else a[1] = 1;
                    break;
                case 'E':
                    if (a[1] > 0 && i == hlast) a[1]=0;
                    else a[1] = -1;
                    break;
            }
        }
        
        if (a[0] == 0 && a[1] == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        return;
    }

}


Measured memory_bytes: 21844
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	h=int(input())
	
	cnt=0
	p=1
	while h>0:
		cnt+=p
		h//=2
		p*=2
	
	print(cnt)
	
	
	
	
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 2940
using System;

namespace abc086A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            if ((A * B) % 2 == 0)
                Console.WriteLine("Even");
            else
                Console.WriteLine("Odd");
        }
    }
}


Measured memory_bytes: 11092
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    string S;
    cin>>S;
    int min_v=1000;
    int st_size=S.size();
    REP(i,st_size-2){
        min_v=min(min_v,abs(100*(S[i]-'0')+10*(S[i+1]-'0')+S[i+2]-'0'-753));
    }
    cout<<min_v<<endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	sr := make([]int, n)
	kr := make([]int, n)
	if s[0:1] == "#" {
		kr[0]++
	} else {
		sr[0]++
	}
	for i := 1; i < n; i++ {
		sr[i] = sr[i-1]
		kr[i] = kr[i-1]
		if s[i:i+1] == "#" {
			kr[i]++
		} else {
			sr[i]++
		}
	}
	ans := n
	var kans, sans int
	for i := 0; i <= n; i++ {
		if i != n {
			ks := kr[n-1]
			if i != 0 {
				ks -= kr[i-1]
			}
			kans = n - i - ks
		} else {
			kans = 0
		}
		if i == 0 {
			sans = 0
		} else {
			ss := sr[i-1]
			sans = i - ss
		}
		if kans+sans < ans {
			ans = kans + sans
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5248
require 'set'
d_map = {'<' => [-1, 0], '>' => [1, 0], '^' => [0, -1], 'v' => [0, 1]}
until (h_w = gets.split(' ').map(&:to_i)) == [0, 0]
  h = h_w.first
  f = h.times.map { gets.chomp.each_char.map {|c| d_map[c] } }
  xy = [0, 0]
  visited = Set.new
  loop do
    if visited.include? xy
      puts 'LOOP'
      break
    end

    visited << xy
    d = f[xy[1]][xy[0]]

    if d.nil?
      puts xy.join(' ')
      break
    end

    xy = [xy[0] + d[0], xy[1] + d[1]]
  end
end

Measured memory_bytes: 6224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int  i = 0 ; i < n ; i++ ) 
typedef long long ll ;
int main(){
    char a[4] ;
    int b[4] ;
    cin >> a[0] >> a[1] >> a[2] >> a[3] ;
    rep(i,4) b[i] = (int) (a[i] - '0')  ;
    for(int x = 0 ; x < 9 ; x++ ){
        string S ;
        //int T ;
        //T = { x&(1<<2 )  , x&(1<<1) , x&(1<<0) } ;
        int sum = b[0] ;
        S = (char)( a[0] ) ;
        for(int i = 0 ; i < 3 ; i++ ){
            if( x&(1<<i) ){
                sum += b[i+1] ;
                S += '+' ;
                S +=(char)( a[i+1] ) ; 
            }
            else{
                sum -= b[i+1] ;
                S += '-' ;
                S +=(char)(  a[i+1] ) ; 
            }
            if( sum == 7 && i == 2 ){
                S += "=7" ;
                cout << S << endl ;
                return 0 ;
            }
        }
    }
}

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

int d[11][11];
int c[111][111];

int main(){
    int A, B; scanf("%d%d",&A,&B);
    for(int i=1;i<=A;i++) for(int j=1;j<=B;j++) scanf("%d",&d[i][j]);

    for(int i=0;i<=100;i++) for(int j=0;j<=100;j++) c[i][j] = -1;

    for(int x=1;x<=A;x++) for(int y=1;y<=B;y++){
        bool found = false;
        for(int a=0;a<=100;a++){
            for(int b=0;b<=100;b++){
                int curC = d[x][y] - x*a - y*b;
                if(0<=curC && curC<=100){
                    bool cur = true;
                    for(int xx=1;xx<=A;xx++){
                        for(int yy=1;yy<=B;yy++){
                            if(curC + xx*a + yy*b < d[xx][yy]){
                                cur = false;
                                break;
                            }
                        }
                        if(!cur) break;
                    }
                    if(cur){
                        found = true;
                        c[a][b] = curC;
                        break;
                    }
                }
            }
            if(found) break;
        }
        if(!found) return !printf("Impossible\n");
    }

    printf("Possible\n");

    int xMax = 0, yMax = 0;
    for(int i=0;i<=100;i++) for(int j=0;j<=100;j++) if(c[i][j]>=0){
        xMax = max(xMax, i);
        yMax = max(yMax, j);
    }
    int N = xMax + yMax + 2;

    int M = N - 2;
    for(int i=0;i<=100;i++) for(int j=0;j<=100;j++) if(c[i][j] >= 0) M++;

    printf("%d %d\n", N, M);
    for(int i=1;i<=xMax;i++) printf("%d %d X\n", i, i+1);
    for(int i=0;i<yMax;i++) printf("%d %d Y\n", N-i-1, N-i);

    for(int i=0;i<=100;i++) for(int j=0;j<=100;j++) if(c[i][j] >= 0)
        printf("%d %d %d\n", 1+i, N-j, c[i][j]);

    printf("1 %d\n", N);
}


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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false);
    long long mod=1e9+7;
    long n,m;
    cin>>n>>m;
    vector<long long> x;
    vector<long long> y;
    for(long i=0;i<n;i++){
        long long k;
        cin>>k;
        x.push_back(k);
    }
    for(long i=0;i<m;i++){
        long long k;
        cin>>k;
        y.push_back(k);
    }
    vector<long long> v1;
    vector<long long> v2;
    for(long i=1;i<n;i++){
        v1.push_back(x[i]-x[i-1]);
    }
    for(long i=1;i<m;i++){
        v2.push_back(y[i]-y[i-1]);
    }
    long long ansx=0;
    for(long i=0;i<n-1;i++){
        long long k=v1[i]*(i+1)*(n-i-1);
        ansx+=k;
        ansx=ansx%mod;
    }
    long long ansy=0;
    for(long i=0;i<m-1;i++){
        long long k=v2[i]*(i+1)*(m-i-1);
        ansy+=k;
        ansy=ansy%mod;
    }
    long long k=ansx*ansy;
    k=k%mod;
    cout<<k;
    return 0;
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = int64_t;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];


signed main(){
	IOS;
	ll n;
	cin >> n;
	map<ll,ll,greater<ll>> a;
	REP(i,n){
		ll x;
		cin >> x;
		a[x]++;
	}
	ll ans = 0;
	for(auto it = a.begin();it != a.end();it++){
		if(it -> second <= 0)continue;
		ll div = 2;
		while(it -> first / div > 0)div *= 2;
		auto i = a.find(div - it->first);
		if(i == a.end()){
			continue;
		}
		ll used;
		if(it->first == i->first)used = it -> second / 2;
		else used = min(it -> second,i ->second);
		i->second -= used;
		it ->second -= used;
		ans += used;
	}
	dump(ans);
}

Measured memory_bytes: 12800
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
# ----------------------------------------------------------- #

x, y = (int(x) for x in input().split())
if y % 2 == 1:
    print("No")
elif x*2 <= y <= x*4:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 72468
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var s = o.r(n,1);
  var a = 0;
  var b = 0;
  var c = 0;
  var ans = 0;
  for(var i = 0; i < n; i++){
    var x = s[i][0];
    for(var j = 1; j < s[i].length; j++){
      if(x === "A" && s[i][j] === "B")ans++;
      x = s[i][j];
    }
    if(s[i][0] === "B"){
      if(s[i][s[i].length-1] === "A")c++;
      else b++;
    }else if(s[i][s[i].length-1] === "A")a++;
  }
  var mn = Math.min(a,b);
  var mx = Math.max(a,b);
  if(mx){
    if(c)ans += mn+c;
    else ans += mn;
  }else if(c)ans += c-1;
  return ans;
}

Measured memory_bytes: 7500
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto A = RD;
	auto B = RD;
	auto C = RD;
	auto D = RD;

	auto cnt1 = (C+B-1) / B;
	auto cnt2 = (A+D-1) / D;

	writeln(cnt1 <= cnt2 ? "Yes" : "No");
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 2712
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
b_list=[[] for i in range(m)]
for i in range(n):
    a,b=map(int,input().split())
    if a<=m:
        b_list[a-1].append(b)
import heapq
p=[]
ans=0
for i in range(m):
    if b_list[i]==[]:
        pass
    else:
        for j in b_list[i]:
            heapq.heappush(p,-j)
    if len(p)!=0:
        now=-heapq.heappop(p)
        ans+=now
print(ans)


Measured memory_bytes: 65968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    int n,x,y;
    cin >> n >> x >> y;

    int ans[n+10];
    rep(i,n+10){
        ans[i]=0;
    }

    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            ans[min(min(j-i,abs(j-x)+1+abs(i-y)),abs(i-x)+1+abs(j-y))]++;
        }
    }

    for(int i=1;i<n;i++){
        cout << ans[i] << endl;
    }


}

Measured memory_bytes: 256