akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int size = 1000;
		int[][] imos = new int[size + 1][size + 1];
		for (int i = 0; i < n; i++) {
		    int x1 = sc.nextInt();
		    int y1 = sc.nextInt();
		    int x2 = sc.nextInt();
		    int y2 = sc.nextInt();
		    imos[x1][y1]++;
		    imos[x2][y2]++;
		    imos[x1][y2]--;
		    imos[x2][y1]--;
		}
		int max = imos[0][0];
		for (int i = 1; i <= size; i++) {
		    imos[i][0] += imos[i - 1][0];
		    max = Math.max(imos[i][0], max);
		}
		for (int i = 1; i <= size; i++) {
		    imos[0][i] += imos[0][i - 1];
		    max = Math.max(imos[0][i], max);
		    for (int j = 1; j <= size; j++) {
		        imos[j][i] += imos[j - 1][i] + imos[j][i - 1] - imos[j - 1][i - 1];
		        max = Math.max(imos[j][i], max);
		    }
		}
		System.out.println(max);
	}
}



Measured memory_bytes: 118248
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}



int main() {
    ll N,A,B; cin >> N >> A >> B;
    vector<ll> X(N);
    for (int i = 0; i < N; i++) cin >> X[i];

    ll res = 0;
    for (int i = 0; i < N-1; i++) {
        res += min(A*(X[i+1]-X[i]),B);
    }
    cout << res << endl;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

bool IsPrime(ll n) {
	if (n <= 1)return false;
	for (ll i = 2; i <= sqrt(n); i++)
	{
		if (n % i == 0)return false;
	}
	return true;
}

vector<bool> era(ll n) {
	vector<bool> ok(n + 1, true);
	for (ll i = 2; i <= sqrt(n); ++i) {
		if (IsPrime(i)) {
			for (ll j = i * i; j <= n; j += i) ok[j] = false;
		}
	}
	return ok;
}

vector<bool> ip;
ll ans[11000000];
int main() {
	ip = era(10001000);
	FOR(i, 13, 10001000) {
		if (ip[i] and ip[i - 2] and ip[i - 6] and ip[i - 8]) {
			ans[i] = i;
		}
		else ans[i] = ans[i - 1];
	}
	REP(i, INF) {
		ll a;
		cin >> a;
		if (a == 0)break;
		cout << ans[a] << endl;
	}
	return 0;
}



Measured memory_bytes: 82204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	int N;
	cin >> N;
	vl x(N), y(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> x[i] >> y[i];
	}
	vl k(N), m(N);
	for (int i = 0; i < N; ++i)
	{
		k[i] = x[i] + y[i];
		m[i] = y[i] - x[i];
	}
	sort(k.begin(), k.end());
	sort(m.begin(), m.end());
	ll diff1 = k.back() - k.front();
	ll diff2 = m.back() - m.front();
	cout << max(diff1, diff2) << endl;
	return 0;
}

Measured memory_bytes: 9540
import sys

def insertionSort(A, n, g):
    for i in range(g, n):
        global cnt
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

def shellSort(A, n):
    global m
    global G
    for i in range(0, m):
        insertionSort(A, n, G[i])


n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

if n == 1:
    print(1)
    print(1)
    print(0)
    print(A[0])
    sys.exit()
t = n - 1
G = []
G.append(t)
while t != 1:
    t = t//2
    G.append(t)
m = len(G)

cnt = 0
shellSort(A, n)
print(m)
print(' '.join(map(str, G)))
print(cnt)
for i in range(n):
    print(A[i])



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

#define MOD 1000000007
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  map<string, int> m;

  string a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    m[a]++;
  }

  int max = 0;
  for (pair<string, int> p : m) {
    if (max < p.second) {
      max = p.second;
    }
  }
  for (pair<string, int> p : m) {
    if (max == p.second) {
      cout << p.first << endl;
    }
  }
}


Measured memory_bytes: 27264
n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(q)]
L=[]
for i in range(1,m+1):
  if n==1:
    L.append((i))
  else:
    for i2 in range(i,m+1):
      if n==2:
        L.append((i,i2))
      else:
        for i3 in range(i2,m+1):
          if n==3:
            L.append((i,i2,i3))
          else:
            for i4 in range(i3,m+1):
              if n==4:
                L.append((i,i2,i3,i4))
              else:
                for i5 in range(i4,m+1):
                  if n==5:
                    L.append((i,i2,i3,i4,i5))
                  else:
                    for i6 in range(i5,m+1):
                      if n==6:
                        L.append((i,i2,i3,i4,i5,i6))
                      else:
                        for i7 in range(i6,m+1):
                          if n==7:
                            L.append((i,i2,i3,i4,i5,i6,i7))
                          else:
                            for i8 in range(i7,m+1):
                              if n==8:
                                L.append((i,i2,i3,i4,i5,i6,i7,i8))
                              else:
                                for i9 in range(i8,m+1):
                                  if n==9:
                                    L.append((i,i2,i3,i4,i5,i6,i7,i8,i9))
                                  else:
                                    for i10 in range(i9,m+1):
                                      L.append((i,i2,i3,i4,i5,i6,i7,i8,i9,i10))
ans=[]
for i in range(len(L)):
  ct=0
  for j in range(q):
    if L[i][l[j][1]-1]-L[i][l[j][0]-1]==l[j][2]:
      ct+=l[j][3]
  ans.append(ct)
print(max(ans))

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

int main(){
  int a, b;
  char op;
  while (true){
    cin >> a >> op >> b;
    if (op == '?') break;
    if (op == '+') cout << a+b << endl;
    if (op == '-') cout << a-b << endl;
    if (op == '*') cout << a*b << endl;
    if (op == '/') cout << a/b << endl;
  }
  return 0;
}

Measured memory_bytes: 3080
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        long a[] = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }

        long sum1[] = new long[n + 1];
        long sum2[] = new long[n + 1];
        sum1[0] = 0;
        sum2[0] = 0;
        for (int i = 1; i <= n; i++) {
            sum1[i] = sum1[i - 1] + a[i - 1];
            sum2[i] = sum2[i - 1] + Math.max(0, a[i - 1]);
        }

        long ans = 0;
        for (int i = 0; i <= n - k; i++) {
            ans =
                Math.max(ans, Math.max(0, sum1[i + k] - sum1[i]) + sum2[n] - sum2[i + k] + sum2[i]);
        }

        System.out.println(ans);
    }

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


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


int main() {
    int n, m;
    vector<int> a;

    cin >> n >> m;
    rep(i,m) {
       int temp;
       cin >> temp;
       a.push_back(temp);
    }

    int sum = 0;
    rep(i,m) sum += a[i];

    int ans = n-sum;

    if (ans >= 0) {
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }




    return 0;
}



Measured memory_bytes: 3728
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 17:30:58 2020

@author: shinba
"""

a,b,k = map(int,input().split())

if b-a+2 <= 2*k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)



Measured memory_bytes: 3060
def cnt(l,r):
  rl=[0]*(r-1)
  ll=[0]*(l-1)
  if l == r:
    return rl+[r]+[l]+ll

  if abs(l-r)%2 == 0:
    return rl+[(r+l)//2]+[(r+l)//2]+ll
  if l>r:
    if l%2 == 0:
      return rl+[(r+l)//2+1]+[(r+l)//2]+ll
    else:
      return rl+[(r+l)//2]+[(r+l)//2+1]+ll
  else:
    if r%2 == 0:
      return rl+[(r+l)//2]+[(r+l)//2+1]+ll
    else:
      return rl+[(r+l)//2+1]+[(r+l)//2]+ll

s=input()
ans=[]
l,r = 0,0
for i in range(len(s)-1):
  if s[i] == "L":
    l+=1
  if s[i] == "R":
    r+=1
  if s[i] == "L" and s[i+1] == "R":

    ans.extend(cnt(l,r))
    l,r = 0,0
else:
  l+=1
  ans.extend(cnt(l,r))

ans = [str (i) for i in ans]
print(" ".join(ans))


Measured memory_bytes: 10580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */


int main(void){ 
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    /* vector< pair<int,int> > query;
    for(int i=0; i<q; i++){
        int l,r;
        cin >> l >> r;
        query.push_back(make_pair(l,r));
    } */

    // 連続するふた文字をみて格納
    vector<int> ac(n+1); // ac[i] には i 番目までにいくつ AC があるかを格納
    ac[1] = 0;
    for(int i=0; i<n-1; i++){
        if(s[i] == 'A' && s[i+1] == 'C'){
            ac[i+2] = ac[i+1] + 1;
        }
        else{
            ac[i+2] = ac[i+1];
        }
    }

    for(int i=0; i<q; i++){
        int l,r;
        cin >> l >> r;
        int ans = ac[r] - ac[l];
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main() {
	string S;
	cin >> S;
	char now = S[0];
	int ans = 0;
	for (int i = 1; i < S.length(); i++) {
		if (now != S[i])ans++;
		now = S[i];
	}
	cout << ans << endl;
}


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

bool visit[100001];
const int MAXN = 100001;
int parent[MAXN],Rank[MAXN]; //we can’t use rank as a variable in C++
void Init(){
   for(int i=1;i<=100000;i++){
      parent[i]=i;
      Rank[i]=1;
   }
}
int Find(int x){ // Path Compression
   return x==parent[x] ? x : parent[x] = Find(parent[x]);
}
void Union(int x,int y){ //Union by Rank
   int rootx = Find(x),rooty = Find(y);
   if(rootx!=rooty){
      if(Rank[rootx] < Rank[rooty])    swap(rootx,rooty);
      parent[rooty]=rootx;
      if(Rank[rootx] == Rank[rooty])    Rank[rootx]++;
   }
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	Init();
	int n,m;
	cin>>n>>m;
	for(int i=1,x,y,z;i<=m;i++){
		cin>>x>>y>>z;
		Union(x,y);
	}
	for(int i=1;i<=n;i++)
		visit[Find(i)]=true;
	int ans=0;
	for(int i=1;i<=n;i++)
		if(visit[i])
			ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 1152
while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break
    for h in range(H):
        if h % 2 == 0:
            print('#.' * (W//2) + '#' * (W % 2))
        elif h % 2 == 1:
            print('.#' * (W//2) + '.' * (W % 2))
    print()



Measured memory_bytes: 5612
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
int main() {
	int N;
	cin >> N;
	int A[100001] = {};//０で初期化、各値の数
	int a;
	for (int i = 0; i < N; i++) {
		cin >> a;
		A[a]++;//a階にあるをたす。
	}
	long long sum;
	long long ans = A[0] + A[1];
	for (int i = 1; i < 100000; i++) {
		sum = A[i - 1] + A[i] + A[i + 1];
		ans = max(sum, ans);
	}



	cout << ans << endl;


	return 0;
}

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

int main()
{
	int a,b;long long c;
	scanf("%d%d",&a,&b);b=min(b,0);
	if(a>0) printf("Positive\n");
	else
	{
		if(b==0) printf("Zero\n");
		else if((b-a)&1) printf("Positive\n");
		else printf("Negative\n");
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using edge = struct { int to; ll cost; };
const int limit = 100010;
vector<edge> tree[limit];
ll depth[limit];
void dfs(int v, int p,ll d) {
	depth[v] = d;
	for (auto &e : tree[v]) {
		if (e.to == p) continue;
		dfs(e.to, v, d + e.cost);
	}
}
int main() {
	int n; cin >> n;
	for (int i = 0; i <n-1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		ll c; cin >> c;
		tree[a].push_back({ b,c });
		tree[b].push_back({ a,c });
	}
	int q, k; cin >> q >> k;
	k--;
	dfs(k, -1, 0);
	for (int i = 0; i < q; i++) {
		int x, y; cin >> x >> y;
		x--; y--;
		cout << depth[x] + depth[y] << endl;
	}
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int s;
  cin >> s;
  set<int> st;
  int now = s;
  st.insert(s);
  int i = 2;
  while (true) {
    if (now%2) {
      now = 3*now + 1;
    }
    else {
      now = now / 2;
    }
    if (st.count(now)) {
      cout << i << endl;
      return 0;
    }
    st.insert(now);
    i++;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから
void solve(){
  int n,m;
  cin>>n>>m;
  int sz[9]={2,5,5,4,5,6,3,7,6};
  vector<int>a(m);
  rep(i,m)cin>>a[i];
  vector<vector<string>>dp(n+5,vector<string>(m,"0"));
  rep(i,m)dp[0][i]="";
  rep(i,n){
    rep(j,m){
      rep(k,m){
        if(i+sz[a[k]-1]>n)continue;
        if(dp[i][j]=="0")continue;
        if(dp[i+sz[a[k]-1]][k].size()==dp[i][j].size()+1)chmax(dp[i+sz[a[k]-1]][k],dp[i][j]+to_string(a[k]));
        else if(dp[i+sz[a[k]-1]][k].size()<dp[i][j].size()+1)dp[i+sz[a[k]-1]][k]=dp[i][j]+to_string(a[k]);
      }
    }
  }
  string ans="";
  rep(i,m){
    if(ans.size()==dp[n][i].size())chmax(ans,dp[n][i]);
    else if(ans.size()<dp[n][i].size())ans=dp[n][i];
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

Measured memory_bytes: 285440
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;

int main()
{
	long long x = 1;
	bool flag = false;
	int size = 1;
	for (int t = 0; t < 11; t++) {
		if (t == 10) {
			flag = true;
			break;
		}
		x *= 10;

		cout << "? " << x << endl;

		char c; cin >> c;
		if (c == 'Y') {
			size++;
		}
		else {
			break;
		}
	}

	long long y = 0;
	if (flag) {
		while (1) {
			y *= 10;
			y += 9;

			cout << "? " << y << endl;

			char c; cin >> c;

			if (c == 'Y') {
				cout << "! " << (y + 1) / 10 << endl;
				return 0;
			}
		}
	}

	long long ans = 0;
	for (int i = 0; i < size-1; i++) {
		ans *= 10;

		int l = 0, r = 10;
		int m;
		while (l < r) {
			m = (l + r) / 2;

			cout << "? " << ans + m << endl;

			char c; cin >> c;
			if (c == 'Y') {
				l = m+1;
			}
			else {
				r = m;
			}
		}

		ans += l-1;
	}

	ans *= 10;

	int l = 0, r = 10;
	int m;
	while (l < r) {
		m = (l + r) / 2;

		cout << "? " << (ans + m)*10 << endl;

		char c; cin >> c;
		if (c == 'N') {
			l = m + 1;
		}
		else {
			r = m;
		}
	}

	ans += l;

	cout << "! " << ans << endl;

	return 0;
}



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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(true) {
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
A, B, C, D = map(int, input().split())
dis = 0

if B <= C or D <= A:
  print(dis)
elif A <= C < B <= D:
  print(B-C)
elif C <= A < D <= B:
  print(D-A)
elif A <= C < D <= B:
  print(D-C)
elif C <= A < B <= D:
  print(B-A)

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

int main() {
    int n, x;

    while(1) {
      	cin >> n >> x;
        if(n==0 && x==0) break;
      	int count=0;

        for(int i = 1; i <= n; i++) {
            for(int j = i+1; j <= n; j++) {
                int c = x-i-j;
              	//cout << i << ' ' << j << ' ' << c << endl;
                if(c<=n && 1<=c && j<c) count++;
            }
        }
      
     	cout << count << endl;
    }
}


Measured memory_bytes: 3060
N, M, X, Y = gets.chomp.split.map(&:to_i)
x_field = gets.chomp.split.map(&:to_i)
y_field = gets.chomp.split.map(&:to_i)
max = x_field.max
min = y_field.min
if ([max+1, X+1].max..[min, Y].min).size >= 1
  puts 'No War'
else
  puts 'War'
end


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

using namespace std;

int main() {

	string s;
	cin >> s;
	string t;
	cin >> t;

	map<char, char> ss;
	map<char, char> tt;

	for (int i = 0; i < s.size(); i++) {
		if (ss.count(s[i])) {
			if (ss[s[i]] != t[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
		ss[s[i]] = t[i];
	}
	for (int i = 0; i < t.size(); i++) {
		if (tt.count(t[i])) {
			if (tt[t[i]] != s[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
		tt[t[i]] = s[i];
	}
	cout << "Yes" << endl;

	return 0;

}

Measured memory_bytes: 776
# include<bits/stdc++.h>
# define LL long long
using namespace std;
const int MAX=1e5+1;
int n,m;
struct p{
	int l,r;
	bool operator< (const p &a)
	const{
		return l<a.l;
	}
}b[MAX];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;++i)
	  cin>>b[i].l>>b[i].r;
	int ans=0;
	int hh=0;
	sort(b+1,b+1+m);
	for(int i=1;i<=m;++i)
	  {
	  	if(hh<=b[i].l) hh=b[i].r,++ans;
	  	else hh=min(hh,b[i].r);
	  }
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	vector<ll>num(101010);
	ll ans = 0;
	rep(i, n) {
		cin >> a[i];
		num[a[i]]++;
		ans += a[i];
	}
	ll q;
	cin >> q;
	rep(i, q) {
		ll b, c;
		cin >> b >> c;
		ll res = num[b];
		ll res2 = num[c];
		ans += res * (c - b);
		num[c] += res;
		num[b] = 0;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 4820
A, B =map(int, input().split())

def f(n):
    if n % 2 == 0:
        if int(n / 2) % 2 == 0:
            return n
        else:
            return 1 ^ n
    else:
        if (int(n + 1) / 2) % 2 == 0:
            return 0
        else:
            return 1

if A > 0:
    print(f(A-1) ^ f(B))
else:
    print(f(B))

Measured memory_bytes: 3060
#include<stdio.h>

int main (void){

    int k,i;
    int red,blue,green;
    char c;
    int check=0;

    scanf("%d %d %d",&red,&green,&blue);
    scanf("%c",&c);
    scanf("%d",&k);

    for(i=0;i<k;i++){
        if(green<=red){
            green*=2;
        }else{
            // red < green
            if(blue<=green){
                blue*=2;
            }
        }

        if(red<green&&green<blue){
            //clear the role
            check=1;
            break;
        }
    }


    //check==1 Yes
    if(check==0){
        printf("No");
    }else{
        printf("Yes");
    }


    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	ll N;
	cin >> N;

	string S;
	cin >> S;

	vector<ll> n(30, 0);

	for (ll i = 0; i < N; ++i)
	{
		n[S[i] - 'a']++;
	}

	//map<ll, ll> m;

	ll ans = 1;

	for (ll i = 0; i < 30; ++i)
	{
		if (n[i] != 0)
		{
			ans *= (n[i] + 1);
			ans %= MOD;
		}
		//cout << n[i] << endl;
	}



	ans = ans - 1;
	ans %= MOD;

	cout << ans << endl;

	//system("pause");
}

Measured memory_bytes: 512
n,x=map(int,input().split())
a,b=[1],[1]
for i in range(50):
    a.append(a[-1]*2+3)
    b.append(b[-1]*2+1)
def paty(l,u):
    if l==0 and u==1:
        return 1
    if u==1:
        return 0
    elif u<a[l]//2+1:
        return paty(l-1,u-1)
    elif u==a[l]//2+1:
        return b[l-1]+1
    elif u<a[l]:
        return b[l-1]+1+paty(l-1,u-a[l]//2-1)
    else:
        return b[l]
print(paty(n,x))

Measured memory_bytes: 3064
#include <stdio.h>

void call(int n){
        int i;
        for(i=1;i<=n;i++){
                if(i%3==0 || i%10==3 || i/10==3 || (i/10)%10==3 || (i/100)%10==3 || (i/1000)%10==3)
                        printf(" %d", i);
        }
        putchar('\n');
}

int main(void){
        int n;
        scanf("%d", &n);
        call(n);
        return 0;
}



Measured memory_bytes: 2076
#!/usr/bin/env python3

n, m = map(int, input().split())
a = list(map(int, input().split()))
# print(n, m, a)

sum_vote = sum(a)
cond = (1 / (4 * m)) * sum_vote

a = sorted(a, reverse=True)

# print(a)
flag = True
for i in range(m):
    if a[i] < cond:
        flag = False

if flag:
    print("Yes")
else:
    print("No")


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

int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}

int nCr(int n, int r)
{
    return fact(n) / (fact(r) * fact(n - r));
}
  

int main(){
    int n, m;
    cin >> n >> m;
    cout << (n*(n-1))/2 +(m*(m-1))/2;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc126
{
    class Program
    {
        static void Main(string[] args)
        {
            var tmp = Console.ReadLine().Split(' ').Select(_ => int.Parse((string) _)).ToArray();
            // var tmp = new int[] {10000, 5};
            // var tmp = new int[] {3, 10};
            var n = tmp[0];
            var k = tmp[1];

            var kratio = 1;
            var krate = 1.0;
            var total = 0.0;
            var inversen = 1.0 / n;
            var firstmaxNext = n;

            for (var ik = 0; ik < k; ik++)
            {
                var firstmax = firstmaxNext;
                var firstmin = (k + kratio - 1) / kratio;

                if (firstmin < 1)
                {
                    break;
                }

                if (firstmin <= n)
                {
                    firstmax = Math.Min(firstmax, n);
                    var rate = krate * (firstmax - firstmin + 1) * inversen;
                    total += rate;
                }

                firstmaxNext = firstmin - 1;
                if (firstmaxNext < 1)
                {
                    break;
                }
                krate *= 0.5;
                kratio *= 2;
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
  int n,k;
  cin>>n>>k;
  int h[n];
  vector<int>c(n,INT_MAX);

  for(int i=0; i<n; i++) cin>>h[i];
  c[0]=0;
//  cout<<c[n-1]<<endl;
  for(int i=0; i<n; i++)
  {
      for(int j=1; j<=k && i+j<n; j++)
      {
          c[i+j]=min(c[i+j], (c[i]+abs(h[i+j]-h[i])) );
      }
  }
/*
  if(n>=2) c[1]=abs(h[1]-h[0]);
  for(int i=2; i<n; i++)
  {
      c[i]=min((c[i-1]+abs(h[i]-h[i-1])) , (c[i-2]+abs(h[i]-h[i-2])) );
  }
*/  cout<<c[n-1]<<"\n";
}


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

int bi(int a){
	int r=1,i;
	for(i=1;i<=a;i++)r*=i;
	return r;
}

int main(){
	int n,i,j;
	int xy[10][2];
	double ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d%d",&xy[i][0],&xy[i][1]);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			ans+=bi(n-1)*2*sqrt((xy[i][0]-xy[j][0])*(xy[i][0]-xy[j][0])+(xy[i][1]-xy[j][1])*(xy[i][1]-xy[j][1]));
		}
	}
	printf("%.10f\n",ans/bi(n));
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
using namespace std; const int Mod=1e9+7, N=400010;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); return s*w;
}
void print(int x) {if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int n,dp[N],size[N],f[N],fac[N]={1};
int head[N],maxE; struct Edge{int nxt,to; }e[N];
inline void Add(int u,int v) {e[++maxE].nxt=head[u]; head[u]=maxE; e[maxE].to=v; }
inline int ksc(int x,int p) {int res=1; for(;p;p>>=1, x=x*x%Mod) if(p&1) res=res*x%Mod; return res; }
void DFS1(int x,int fa)
{
	size[x]=f[x]=1;
	for(int i=head[x];i;i=e[i].nxt)
	{
		if(e[i].to==fa) continue;
		DFS1(e[i].to,x);
		size[x]+=size[e[i].to];
		(f[x]*=f[e[i].to])%=Mod;
	}
	(f[x]*=size[x])%=Mod;
}
void DFS2(int x,int fa,int w)
{
	int now=w;
	for(int i=head[x];i;i=e[i].nxt) if(e[i].to^fa) (now*=f[e[i].to])%=Mod;
	dp[x]=ksc(now,Mod-2)*fac[n-1]%Mod;
	for(int i=head[x];i;i=e[i].nxt) if(e[i].to^fa) (w*=f[e[i].to])%=Mod;
	for(int i=head[x];i;i=e[i].nxt) if(e[i].to^fa) DFS2(e[i].to,x,w*(n-size[e[i].to])%Mod*ksc(f[e[i].to],Mod-2)%Mod);
}
signed main()
{
	for(ri int i=1;i<=300000;i++) fac[i]=fac[i-1]*i%Mod;
	n=read();
	for(ri int i=1;i<n;i++)
	{
		int u,v;
		u=read(), v=read();
		Add(u,v), Add(v,u);
	}
	DFS1(1,0); DFS2(1,0,1);
	for(ri int i=1;i<=n;i++) printf("%lld\n",dp[i]);
	return 0;
}

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

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


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

    sort(a,a+3);
    
    cout << a[0] << " " << a[1] << " " << a[2] <<  endl;
    return 0;
}


Measured memory_bytes: 3196
#include <cstdio>
#include <vector>

using namespace std;

int width,height;
vector< vector<int> > m;
vector< vector<int> > mm;

int Get(int y,int x);

int main(){
	int self;
	while(scanf("%d",&width) != EOF){
		scanf("%d",&height);
		if(width == 0 && height == 0){
			break;
		}
		//printf("%d:%d\n",width,height);
		m.clear();
		mm.clear();
		
		for(int j=0;j<height;j++){
			vector<int> v;
			for(int i=0;i<width;i++){
				scanf("%d",&self);
				v.push_back(self);
			}
			m.push_back(v);
		}
		for(int j=0;j<=height;j++){
			vector<int> vv;
			for(int i=0;i<width;i++){
				vv.push_back(0);
			}
			mm.push_back(vv);
		}
		
		/*
		for(int j=0;j<height;j++){
			for(int i=0;i<width;i++){
				printf("%d ",m[j][i]);
			}
			printf("\n");
		}
		*/
		
		int xx,yy;

		for(int y = 0; y <= height; y ++){
			for(int x = 0; x < width; x ++){
				xx = x;
				yy = y - 1;
				if(y == height){
					mm[y][x] += mm[yy][xx];
					yy = y - 2;
					if(yy >= 0){
						if(m[yy][xx] == 2){
							mm[y][x] += mm[yy][xx];
						}
					}
				}else{
					switch(m[y][x]){
						case 0: //ó
							if(yy == -1){
								mm[y][x] = 1;
							}else{
								mm[y][x] += Get(yy,xx-1) + Get(yy,xx) + Get(yy,xx+1);
								yy = y - 2;
								if(yy >= 0){
									if(m[yy][xx] == 2){
										mm[y][x] += mm[yy][xx];
									}
								}
							}
							break;
						case 1: //áQ¨
							break;
						case 2: //Wvä
							mm[y][x] += Get(yy,xx);
							yy = y - 2;
							if(yy >= 0){
								if(m[yy][xx] == 2){
									mm[y][x] += mm[yy][xx];
								}
							}
							break;
					}
				}
			}
			
		}
		
		/*
		for(int j=0;j<=height;j++){
			for(int i=0;i<width;i++){
				printf("%d	",mm[j][i]);
			}
			printf("\n");
		}
		*/
		int ans = 0;
		for(int i=0;i<width;i++){
			ans += mm[height][i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

int Get(int y,int x){
	if(y >= height){ return 0; }
	if(x >= width){ return 0; }
	if(y < 0){ return 0; }
	if(x < 0){ return 0; }
	if(m[y][x] == 2){ return 0; }
	return mm[y][x];
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int N, M;
	cin >> N >> M;

	vector<int> a(N), b(N), c(M), d(M);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i) >> b.at(i);
	}
	for (int i = 0; i < M; i++) {
		cin >> c.at(i) >> d.at(i);
	}

	for (int i = 0; i < N; i++) {
		int dif, sub;

		for (int j = 0; j < M; j++) {
			int n = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));

			if (!j) {
				dif = n;
				sub = j + 1;
			}
			else {
				if (dif > n) {
					dif = n;
					sub = j + 1;
				}
			}
		}

		cout << sub << endl;
	}
}

Measured memory_bytes: 3472
#include <bits/stdc++.h>
#define N 17
#define MASK 70000
#define mod 1000000007
using namespace std;

int n,m,tp,sum;
int g[MASK][N], F[MASK],e[N*N];
inline int lowbit(int x) {return x&(-x);}
inline int rd() {int r;scanf("%d",&r);return r;}
inline void inc(int &x,int y) {x=(x+y)%mod;}

int main() {
	n = rd(), m = rd(), tp = (1<<n) - 1;

	e[0] = 1;
	for (int _=1;_<=m;_++) e[_] = 1LL * e[_-1] * 2 % mod;
	sum = e[m];

	for (int _=1;_<=m;_++) {
		int a = rd(), b = rd();
		g[1<<(b-1)][a] = 1;
	}
	
	for (int _=1;_<=tp;_++)
		for (int i=1;i<=n;i++) {
			int x = lowbit(_);
			g[_][i] = g[_^x][i] + g[x][i];
		}
		
	F[0] = 1;
	for (int i=1;i<=tp;i++) if ((i&1) == ((i>>1)&1)){
		for (int k=i;k;k=(k-1)&i) if ((k&1) == ((k>>1)&1)){
			int j = i^k, cur = F[j], tmp = 1;
			for (int x=1;x<=n;x++) if ((1<<(x-1))&i) {
				if ((1<<(x-1)) & j)
					tmp = 1LL * tmp * (e[g[k][x]]-1) % mod;
				else
					tmp = 1LL * tmp * e[g[j][x]] % mod;
			}
			inc(F[i], 1LL * cur * tmp % mod);
		}
	}
	
	int ans = (sum - F[tp]) % mod;
	ans < 0 ? ans += mod : 0;
	cout << ans << endl;
	return 0;
}

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

int main(void) {
	long long n;
	vector<long long> a(5);
	vector<long long> b(5, 0);
	cin >> n;
	for (int i = 0; i < 5; ++i) {
		cin >> a[i];
	}
	auto a2 = a;
	sort(a2.begin(), a2.end());

	long long nnn = n / a2[0];
	if (n % a2[0] > 0) {
		++nnn;
	}

	nnn += 4;

	cout << nnn;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define endl '\n'
#define PI acos(-1)
#define bitcount(a) __builtin_popcountll(a)
#define P pair<int,int>
#define ff first
#define ss second
typedef tree<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
long double eps=1e-9;
int mod=1e9+7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	for(int i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			int one=i;
			int two=n/i;
			if(one<=9&&two<=9)
			{
				cout<<"Yes";
				return 0;
			}
		}
	}	
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int rainy = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'R' && rainy == 0)
        {
            rainy++;
        }
        else if (s[i] == 'R' && rainy != 0)
        {
            if (s[i - 1] == s[i])
            {
                rainy++;
            }
        }
    }
    printf("%d\n", rainy);
}

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

typedef long long LL;
const int MAXN=2005;
const double eps=1e-7;

int n,m;
vector<int> f,g,ans1,ans2;

int main(){
    scanf("%d%d",&m,&n);
    for(int i=1;i<=n;i++){
        int a; scanf("%d",&a);
        if (a%2==0) f.push_back(a);
        else g.push_back(a);
    }
    if (g.size()>2){
        puts("Impossible");
    } else{
        if (g.size()==0){
            for(int i=0;i<f.size();i++) ans1.push_back(f[i]);
            ans2.push_back(1);
            for(int i=0;i<f.size();i++){
                ans2.push_back(i==f.size()-1?f[i]-1:f[i]);
            }
        } else if (g.size()==1){
            ans1.push_back(g[0]);
            for(int i=0;i<f.size();i++) ans1.push_back(f[i]);
            if (f.size()==0){
                if (g[0]>1) ans2.push_back(g[0]-1);
                ans2.push_back(1);
            } else {
                ans2.push_back(g[0]+1);
                for(int i=0;i<f.size();i++){
                    ans2.push_back(i==f.size()-1?f[i]-1:f[i]);
                }
            }
        } else{
            assert(g.size()==2);
            ans1.push_back(g[0]);
            for(int i=0;i<f.size();i++) ans1.push_back(f[i]);
            ans1.push_back(g[1]);
            if (f.size()==0){
                //assert(false);
                ans2.push_back(g[0]+1);
                if (g[1]>1) ans2.push_back(g[1]-1);
            } else{                
                ans2.push_back(g[0]+1);
                for(int i=0;i<f.size();i++){
                    //ans2.push_back(i==f.size()-1?f[i]-1+g[1]:f[i]);
                    ans2.push_back(f[i]);
                }
                if (g[1]>1) ans2.push_back(g[1]-1);
            }
            
        }
        for(int i=0;i<ans1.size();i++) printf("%d%c",ans1[i],i==ans1.size()-1?'\n':' ');
        printf("%d\n",ans2.size());
        for(int i=0;i<ans2.size();i++) printf("%d%c",ans2[i],i==ans2.size()-1?'\n':' ');
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string x, y;
    cin >> x;
    y = x;
    vrev(x);
    if (x == y) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b,c,x,i=0;
  scanf("%d %d %d",&a,&b,&c);
  while(!(a==(b+1))){
  	x=c%a;
  	if(x==0){
  		i++;
  	}
  	a++;
  }
  printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 596
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	s = chomp(readline())
	t = chomp(readline())
	ls = length(s)
	lt = length(t)
	gflg = 0
	initial = 0
	for i in 0:ls-lt
		lflg = 0
		for j in 1:lt
			if s[ls-lt-i+j] != t[j] && s[ls-lt-i+j] != '?'
				lflg = 1
				break
			end
		end
		if lflg == 0
			initial = ls-lt-i+1
			gflg = 1
			break
		end
	end
	if gflg == 0
		println("UNRESTORABLE")
	else
		for i in 1:initial-1
			if s[i] == '?'
				print('a')
			else
				print(s[i])
			end
		end
		print(t)
		for i in initial+lt:ls
			if s[i] == '?'
				print('a')
			else
				print(s[i])
			end
		end
	end
end

main()


Measured memory_bytes: 110320
//
//  main.c
//  ITP1_10_A
//
//  Created by k16031kk on 2018/05/28.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    double x1, y1, x2, y2;
    double z;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    z=pow(x1 - x2, 2) + pow(y1 - y2, 2);
    
    printf("%lf\n", sqrt(z));
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> x(n + 1), y(m + 1);
  cin >> x[n] >> y[m];
  for (int i = 0; i < n; i++) cin >> x[i];
  for (int i = 0; i < m; i++) cin >> y[i];
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  cout << (y[0] - x[n] > 0 ? "No War" : "War") << '\n';
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const int mod = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    ll res = 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] != 0) {
            if (res > 1000000000000000000 / a[i]) {
                cout << -1 << endl;
                return 0;
            }
        }
        res *= a[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;

const int N=3001;
int dp[N][N];


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();
    
    string s,t;
    cin>>s>>t;
    ll n=s.size(), m=t.size();
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i>0) dp[i][j]=max(dp[i][j],dp[i-1][j]);
            if(j>0) dp[i][j]=max(dp[i][j],dp[i][j-1]);
            if(i>0&&j>0&&s[i-1]==t[j-1])
                dp[i][j]=max(dp[i][j],1+dp[i-1][j-1]);
        }
    }
    //cout<<dp[n][m];
    ll i=n,j=m;
    string ans;
    while(i>0&&j>0){
        if(s[i-1]==t[j-1]){
            ans+=s[i-1];
            i--,j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;

    

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

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



long long int inf = 1e17;

long long int a[100010];
long long int can[100010],tot[100010];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	bool ok=true;
	for(int i=0;i<=n;i++){
		cin>>a[i];
		if(i==0){
			if(a[i]>1)	ok=false;
			can[i]=1-a[i];
		}
		else{
			can[i]=2*can[i-1]-a[i];
			if(can[i]<0)	ok=false;
			if(can[i]>inf)	can[i]=inf;
		}
	}
	if(!ok)	return cout<<-1<<endl,0;
	long long int ans=0;
	for(int i=n;i>=0;i--){
		if(i==n){
			tot[i]=a[i];
		}
		else{
			tot[i]=min(tot[i+1],can[i])+a[i];
		}
		ans+=tot[i];
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 5956
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
int main(){
    ll N; cin >> N;
    string S = "";
    if(N % 2 == 0) S += "0";
    if(N % 2 != 0) {S += "1"; N -= 1;}
    ll cnt = 2;
        
    while(1){
        if(N == 0) break;
        ll powed = pow(2, cnt);
        if(N % powed == 0) S += "0";
        else {
            N -= pow(-2, cnt-1);
            S += "1";
        }
        cnt++;
        //cout << N << endl;
    }
    reverse(S.begin(), S.end());
    cout << S << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(all(a));
	cout << a[n-1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    int x,y;
    int i;
    while(1){
        scanf("%d%d", &x, &y);
        if( x == 0 && y == 0){
            break;
        }
        if( x < y ){
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
    }
    return 0;
}

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

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

    int ans = 0;
    for(int i = 0; i < n; i++) {
        int h;
        cin >> h;
        if(h >= k) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <set>
const int maxlongint=2147483647;
const int mo=1e9+7; 
const int N=505;
using namespace std;
int n,m,a[N][N],v[N][N],v1[N][N];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            char c=getchar();
            while(c!='.' && c!='#') c=getchar();
            v[i][j]=v1[i][j]=a[i][j]=c=='#';
        }
    for(int i=1;i<=n;i++)
    {
        v[i][1]=1,v1[i][m]=1;
        if(i&1)
            for(int j=1;j<=m-1;j++) v[i][j]=1;
        else
            for(int j=2;j<=m;j++) v1[i][j]=1;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++) printf("%c",v[i][j]?'#':'.');
        putchar('\n');
    }
    putchar('\n');
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++) printf("%c",v1[i][j]?'#':'.');
        putchar('\n');
    }
}

Measured memory_bytes: 3840
import java.util.Scanner;

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

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    System.out.println(Math.max(Math.abs(a - b), Math.abs(b - c)) <= d || Math.abs(a - c) <= d ? "Yes" : "No");
  }
}

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

int main()
{
	int n,m,ans=0,s=0;
	cin>>n>>m;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		ans+=a[i];
	}
	
	int p=ans/(4*m);
	int ys=ans%(4*m);
	
	if(ys==0){
		for(int i=1;i<=n;i++)
		{
			if(a[i]>=p)
				s++;
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			if(a[i]>p)
				s++;
		}
	}
	if(s>=m)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <ll> v;

ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}

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

	ll n,i,m,j,k,x,y,a,b;
	string s;
	cin >> n;
	cout << n*n*n;

	return 0;
}


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

int main(){
  int a, b;
  cin>>a>>b;
  string Sa=to_string(a), Sb=to_string(b);
  for(int i=1; i<b; i++) Sa+=to_string(a);
  for(int i=1; i<a; i++) Sb+=to_string(b);
  cout<<(Sa<Sb?Sa:Sb)<<endl;
  return 0;
}

Measured memory_bytes: 256