akhauriyash/Code-Regression huggingface dataset:
//Red Scarf

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    int s = a[0];
    rep(i,1,n){
        s=s xor a[i];
    }
    rep(i,0,n){
        cout<<(s xor a[i])<<nnn;
    }
    return 0;
}

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


int main() {
	string sss;
	int count = 0;
	cin >> sss;

	if (sss.at(0) == '1') ++count;
	if (sss.at(1) == '1') ++count;
	if (sss.at(2) == '1') ++count;

	cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
ll mod= 1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
string s[110000];
map<string,ll> f;
main(){
    ll n,ans=0;
    cin>>n;
    rep(i,0,n)cin>>s[i];
    rep(i,0,n)sort(s[i].begin(),s[i].end());
    ll cnt=0;
    rep(i,0,n)f[s[i]]++;
    for(auto i:f)ans+=i.second*(i.second-1)/2;
    cout<<ans;

}

Measured memory_bytes: 18304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,arr[400000],ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n,greater<ll>());
    n-=2;
    ans+=arr[0];
    ll i=1;
    while(n>0)
    {
        if(n==1)
        {
            n--;
            ans+=arr[i];
        }
        else
        {
        n=n-2;
        ans=ans+2*arr[i];
        i++;
        }

    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 5196
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
		a[i]--
	}
	c := 0
	now := 0
	for i := 0; i < N; i++ {
		if now == 1 {
			fmt.Println(c)
			return
		} else {
			now = a[now]
			c++
		}
	}
	fmt.Println(-1)
}

Measured memory_bytes: 5504
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7 ;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define vvv64 vector<vv32>
#define vvvv64 vector<vvv32>
 
ll exp(ll n, ll e)
{
    if (e==0)
        return 1;
    ll temp=exp((n*n)%MOD,e/2);
    return e%2==0 ? temp : (temp*n)%MOD;
}
void norm(ll &n)
{
    n%=MOD;
    n+=MOD;
    n%=MOD;
}


ll rec(ll n)
{
    if (n==1)
        return 1;
    return 2*rec(n/2)+1;
}
void solve()
{
    ll h;
    cin>>h;
    cout<<rec(h)<<endl;
}
 
int main() {
    fast_cin();
    int t=1;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
    public static void main(String[] args){
        int n, q;
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        q = scanner.nextInt();
        UnionFind uf = new UnionFind(n);

        for(int i = 0; i < q; i++){
            int query, x, y;
            query = scanner.nextInt();
            x = scanner.nextInt();
            y = scanner.nextInt();
            if(query == 0){
                uf.unite(x, y);
            }
            if(query == 1){
                if(uf.same(x, y)){
                    System.out.println(1);
                }else{
                    System.out.println(0);
                }
            }
        }
    }
}

class UnionFind {
    private int n;
    private int[] root;

    UnionFind(int n){
        this.n = n;
        this.root = new int[n];
        for(int i = 0; i < n; i++){
            root[i] = i;
        }
    }

    private int find(int x){
        if(x == root[x]) {
            return root[x];
        }
        return root[x] = find(root[x]);
    }

    public boolean same(int x, int y){
        return find(x) == find(y);
    }

    public void unite(int x, int y){
        if(same(x, y)) return;
        x = find(x);
        y = find(y);

        root[y] = x;
    }
}






Measured memory_bytes: 100024
#include<stdio.h>

bool linerSearch(int A[], int n, int t) {
  int i = 0;
  while ( i < n) {
    if (A[i] == t) break;
    i++;
  }

  return i < n ? true : false;
}

int main() {
  int n, A[10000], cnt = 0;
  scanf("%d", &n);

  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);

  int m, t;
  scanf("%d", &m);
  for ( int i = 0; i < m; i++ ) {
    scanf("%d", &t);
    if (linerSearch(A, n, t)) cnt++;
  }

  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 2748
# -*- coding: utf-8 -*-

import numpy as np

EDPC = "https://atcoder.jp/contests/DP/"
TDPC = "https://atcoder.jp/contests/tDPc/tasks"

############### TESTCASE ###############
test = ""
#test = \
"""
3 8
3 30
4 50
5 60
ans 90
"""

"""
5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
ans 5000000000(>int32)
"""

"""
6 15
6 5
5 6
6 4
6 6
3 5
7 2
ans 17
"""
########################################
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
########################################
#np.maximum(*arrays) == np.max(np.vstack(*arrays), axis=0)
(np.maximum(np.array([1,3,2]), np.array([2, 1, 3])) == 
 np.max(np.vstack([np.array([1,3,2]), np.array([2, 1, 3])]), axis=0)).all()
################# MAIN #################

N, W = map(int, input2().split())
WV = np.array([tuple(map(int, input2().split())) for _ in range(N)])

dp = np.zeros(W + 1, dtype="int64")
for w, v in WV:
    dp[W:w-1:-1] = np.max(np.vstack([dp[W:w-1:-1], dp[W-w::-1] + v]), axis=0)
    
print(dp[-1])


Measured memory_bytes: 17028
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n;
cin >> n;
int a[n];
for(int i=0;i<n;i++){
    cin >> a[i];
}
sort(a,a+n);
double ans=a[0];
for(int i=1;i<n;i++){
    ans=(ans+a[i])/2.0;
}
cout << ans <<endl;
    return 0;   
}

Measured memory_bytes: 256
N = gets.to_i
S1, S2 = readlines.map(&:chomp)
MOD = 1000000007

i, res, hor = 0, 1, nil
while i < N
  if S1[i] == S2[i]
    i += 1
    case hor
    when true  # h + v
      res
    when false # v + h
      res = res * 2 % MOD
    when nil   # v
      res = 3
    end
    hor = false
  else
    i += 2
    case hor
    when true  # h + h
      res = res * 3 % MOD
    when false # v + h
      res = res * 2 % MOD
    when nil   # h
      res = 6
    end
    hor = true
  end
end
puts res

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N,K;
	ll result=INF;
	cin>>N>>K;
	VI vec(N);
	REP(i, N) cin >> vec[i];
	FOR(i,0,N-K){
		if(vec[i]*vec[i+K-1]>=0){
			result=min({result,max(abs(vec[i]),abs(vec[i+K-1]))});
		}
		else{
			result=min({result,2*vec[i+K-1]-vec[i],vec[i+K-1]-2*vec[i]});
		}
	}


	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	string s;cin >> s;
	int ans = 0;
	rep(i,10){
		rep(j,10){
			rep(k,10){
				int t = 0;
				rep(l,n){
					if(t == 0){
						if(s.at(l) - '0' == i) t++;
					}
					else if(t == 1){
						if(s.at(l) - '0' == j) t++;
					}
					else if(t == 2){
						if(s.at(l) - '0' == k) t++;
					}
				}
				if(t == 3) ans++;
			}
		}
	}
	cout << ans << endl;
}


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

struct circle {
    double x, y, r;
};
double dist(double a1, double b1, double a2, double b2) {
    //cout << sqrt(((a1 - a2) * (a1 - a2)) + ((b1 - b2) * (b1 - b2))) << " **\n";
    return sqrt(((a1 - a2) * (a1 - a2)) + ((b1 - b2) * (b1 - b2)));
}
int main()
{
    circle arr[1015];
    cin >> arr[0].x >> arr[0].y >> arr[1].x >> arr[1].y;
    arr[0].r = arr[1].r = 0;
    int n; cin >> n;
    vector<vector<pair<int, double> > > v(1015);
    v[0].push_back({1, dist(arr[0].x, arr[0].y, arr[1].x, arr[1].y)});
    v[1].push_back({0, dist(arr[0].x, arr[0].y, arr[1].x, arr[1].y)});
    vector<double> cost(1015, 1e18); cost[0] = 0;
    for (int i = 2; i < n + 2; i++) {
        cin >> arr[i].x >> arr[i].y >> arr[i].r;
        for (int j = 0; j < i; j++) {
            //cout << "!!! " << arr[i].x << " " << arr[i].y << " " << arr[j].x << " " << arr[j].y << " " << arr[i].r << " " << arr[j].r << "\n";
            v[i].push_back({j, max(0.0, dist(arr[i].x, arr[i].y, arr[j].x, arr[j].y) - arr[i].r - arr[j].r)});
            v[j].push_back({i, max(0.0, dist(arr[i].x, arr[i].y, arr[j].x, arr[j].y) - arr[i].r - arr[j].r)});
        }
    }
    priority_queue<pair<double, int> > pq;
    pq.push({0, 0});
    while (pq.size()) {
        int idx = pq.top().second;
        pq.pop();
        for (int i = 0; i < v[idx].size(); i++) {
            int cur = v[idx][i].first;
            //cout << v[idx][i].second << "\n";
            if (cost[cur] > cost[idx] + v[idx][i].second) {
                cost[cur] = cost[idx] + v[idx][i].second;
                pq.push({-1 * cost[cur], cur});
            }
        }
    }
    cout << fixed << setprecision(10) << cost[1] << "\n";
    return 0;
}


Measured memory_bytes: 22384
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>



using namespace std;




int main(){
	
	long long int a,b,c,x=0;;
	cin>>a>>b>>c;
	if(a)a--;
	else x++;
	x+=b/c-a/c;
	
	//if(a/c==0)x++;
	cout<<x<<endl;;


	return 0;
	

}


	

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

#define rb(a,b,c) for(int a=b;a<=c;++a)

#define rl(a,b,c) for(int a=b;a>=c;--a)

#define niv vector<int>

#define LL long long

#define IT iterator

#define PB(a) push_back(a)

#define II(a,b) make_pair(a,b)

#define FIR first

#define SEC second

#define FREO freopen("check.out","w",stdout)

#define rep(a,b) for(int a=0;a<b;++a)

#define KEEP while(1)

#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())

#define random(a) rng()%a

using namespace std;

const int INF=0x3f3f3f3f;

typedef pair<int,int> mp;

typedef pair<mp,mp> superpair;

int  n;

int res[505][505];

void dfs(int start,int to,int index){

	if(to-start+1<=1) return;

	for(int i=start;i<to;i++)

		for(int j=i+1;j<=to;j++) {res[i][j]=index;

		}

	int mid=(start+to)>>1;

	dfs(start,mid,index+1),dfs(mid+1,to,index+1);

}

int main(){

	cin>>n;

	dfs(1,n,1);

 

	for(int i=1;i<n;i++)

        for(int j=i+1;j<=n;j++)

	cout<<res[i][j]<<" ";

}

 


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

int main() {
  string s; cin >>s;
  string ans = "Yes";
  for (int i=0; i<s.size(); i++){
    if (i%2==0){
      if (s.at(i)=='L') ans = "No";
    }else{
      if (s.at(i)=='R') ans = "No";
    }
  }
  
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int main(){
    fastcin();

    int n;
    cin >> n;
    Graph G(n);
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> c(n, -1);
    const int d[] = {0, 1};
    vector<int> cnt(2, 0);
    queue<pair<int, int>> que;
    que.emplace(0, 0);
    while(!que.empty()){
        int u, cost;
        tie(u, cost) = que.front(); que.pop();
        c[u] = d[cost%2];
        cnt[d[cost%2]]++;
        repe(i, G[u]){
            if(c[i] != -1) continue;
            que.push(make_pair(i, cost+1));
        }
    }
    vector<int> ans(n, -1);
    vector<pair<int, int>> tmp;
    rep(i, 2) tmp.emplace_back(cnt[i], i);
    sort(all(tmp));
    reverse(all(tmp));
    vector<int> rem(3, n/3);
    if(n%3==1) rem[1]++;
    if(n%3==2){ rem[1]++; rem[2]++; }
    if(tmp[1].first <= n/3){
        // 少ないやつ0で埋める
        rep(i, n) if(c[i] == tmp[1].second){
            ans[i] = 0;
            rem[0]--;
        }
        rep(i, n){
            if(ans[i] == -1){
                if(rem[1]==0){
                    if(rem[2]==0){
                        ans[i] = 0;
                        rem[0]--;
                        continue;
                    }
                    ans[i] = 2;
                    rem[2]--;
                    continue;
                    
                }
                ans[i] = 1;
                rem[1]--;
            }
        }
    }else{
        rep(i, n){
            if(c[i] == tmp[0].second){
                if(rem[1]==0){
                    ans[i] = 0;
                    rem[0]--;
                    continue;
                    
                }
                ans[i] = 1;
                rem[1]--;
            }else{
                if(rem[2]==0){
                    ans[i] = 0;
                    rem[0]--;
                    continue;
                    
                }
                ans[i] = 2;
                rem[2]--;
            }
        }
    }
    // repe(i, rem) cout << i << endl;

    int m[] = {3,1,2};
    rep(i, n){
        cout << m[ans[i]] << (i==n-1?"\n":" ");
        m[ans[i]]+=3;
    }
}

Measured memory_bytes: 15984
#include <iostream>
using namespace std;
int main (){
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if (s==u){
        a-=1;
        cout<<a<<" "<<b;
    }else{
        b-=1;
        cout<<a<<" "<<b;
    }
    return 0;
}

Measured memory_bytes: 256
/*  ex3_3
    pptenshi  */

#include<stdio.h>

int main(void) {
    int num, base;  // N, k
    int digits = 0;  // 桁数

    // input
    scanf("%d %d", &num, &base);

    //caluculate digits
    while (num > 0) {
        num /= base;
        digits++;
    }

    //output
    printf("%d", digits);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

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

    int ans = (n + 2*d) / (2*d + 1);
    cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
s=[input() for i in range(N)]
lost_list=[]
taro_card=[]
card_list=[]
for i in s:
    taro_card.append(i.split())
for i in range(1,14):
    card_list.append(["S",str(i)])
for i in range(1,14):
    card_list.append(["H",str(i)])
for i in range(1,14):    
    card_list.append(["C",str(i)])
for i in range(1,14):    
    card_list.append(["D",str(i)])
for i in card_list:
    if i not in taro_card:
        lost_list.append(i)
for i in lost_list:
    print(i[0]+" "+i[1])


Measured memory_bytes: 5600
#!/usr/bin/env python3
import math

a, b, h, m = map(int, input().split())

hour = 30 * h + 0.5 * m
minutes = 6 * m

theta = max(hour, minutes) - min(hour, minutes)
theta = min(360 - theta, theta)

c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(theta)))
print(c)


Measured memory_bytes: 9496
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
const int MAXN = 5005;
const int mod = 1e9 + 7;

vector<int> vx, vy;

bool knap(vector<int> &v, int x){
	if(x < 0) return false;
	if(x > 16004) return false;
	bitset<16005> bs;
	bs[0] = 1;
	for(auto &i : v) bs |= (bs << i);
	return bs[x];
}

int main(){
	bool flg = 0;
	string s;
	int x, y;
	cin >> s;
	cin >> x >> y;
	while(s.size() && s[0] == 'F'){
		x--;
		s = s.substr(1, s.size() - 1);
	}
	while(s.size()){
		s = s.substr(1, s.size() - 1);
		flg ^= 1;
		int cnt = 0;
		while(s.size() && s[0] == 'F'){
			s = s.substr(1, s.size() - 1);
			cnt++;
		}
		if(flg) vy.push_back(cnt);
		else vx.push_back(cnt);
	}
	for(int i=0; i<vx.size(); i++) x += vx[i];
	for(int i=0; i<vy.size(); i++) y += vy[i];
	for(auto &i : vx) i *= 2;
	for(auto &i : vy) i *= 2;
	puts(knap(vx, x) && knap(vy, y) ? "Yes" : "No");
}


Measured memory_bytes: 384
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	ll x;
	cin >> x;
	ll ans;
	ll mem;
	ans = x / 500;
	ans = ans * 1000;
	mem = (x - ans / 2) / 5;
	ans = mem * 5 + ans;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
ll mulmod(ll a,ll b,ll c) 
{ 
    if (b==0) 
        return 0; 
    ll s = mulmod(a, b/2, c); 
    if (b%2==1) 
        return (a%c+2*(s%c)) % c; 
 
    else
        return (2*(s%c)) % c; 
} 
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
ll int t;
t=1;

while(t--)
{ ll int n,m,i,j,k,count=0,flag=0;
cin>>n>>m;
if(n==m)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;


    
    
    
    
    
    
    
    
}



 
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int res = 0;
  for (int i = a; i <= b; i++) {
    string str = to_string(i);
    string rev = str;
    reverse(rev.begin(), rev.end());
    if (str == rev)
      ++res;
  }   
  cout << res << '\n';
  return 0;
}

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

using namespace std;

int main() {
    int N,A,B;
    cin >> N >> A >> B;
    if((B - A) % 2 == 0) {
        cout << "Alice" << endl;
    } else {
        cout << "Borys" << endl;
    }
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    int hugNum = 0;
    for (int i = 0, n = S.size(); i < n / 2; ++i)
    {
        if (S[i] != S[n - 1 - i])
        {
            ++hugNum;
        }
    }
    cout << hugNum << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	
	static Map<Integer, Integer> all_factor = new HashMap<>();

    static void factorize_each(int n){
        int div = 1;
        while(n > 1){
            
            div++;
            int cnt = 0;
            while(n % div == 0){
                cnt++;
                n /= div;
            }
            if(cnt == 0)
                continue;
                
            if(all_factor.get(div) != null){
                cnt += all_factor.get(div);
            }
            all_factor.put(div, cnt);

        }
        return;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        sc.close();

        for(int i = 1; i <= N; i++){
            factorize_each(i);
        }

        int ans = 0;

        for(Map.Entry<Integer, Integer> fst_entry : all_factor.entrySet()){
            int fst_key = fst_entry.getKey();
            int fst_val = fst_entry.getValue();
            
            if(fst_val < 4) continue;

            for(Map.Entry<Integer, Integer> scd_entry : all_factor.entrySet()){
                int scd_key = scd_entry.getKey();
                int scd_val = scd_entry.getValue();

                if(scd_key <= fst_key || scd_val < 4) continue;

                for(Map.Entry<Integer, Integer> thd_entry : all_factor.entrySet()){
                    int thd_key = thd_entry.getKey();
                    int thd_val = thd_entry.getValue();

                    if(thd_key == fst_key || thd_key == scd_key || thd_val < 2) continue;

                    ans++;
                }

                if(fst_val >= 14) ans++;
                if(scd_val >= 14) ans++;
            }
        }

        for(Map.Entry<Integer, Integer> fst_entry : all_factor.entrySet()){
            int fst_key = fst_entry.getKey();
            int fst_val = fst_entry.getValue();
            
            if(fst_val < 2) continue;
            if(fst_val >= 74) ans++;

            for(Map.Entry<Integer, Integer> scd_entry : all_factor.entrySet()){
                int scd_key = scd_entry.getKey();
                int scd_val = scd_entry.getValue();

                if(scd_key == fst_key || scd_val < 24) continue;
                
                ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 22100
while True:
    a1,op,b1 = input().split()
    if op == '?':
        break
    a = int(a1)
    b = int(b1)
    if op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)
    elif op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)

            



Measured memory_bytes: 5596
#include<stdio.h>
#include<string.h>
int main()
{
        char a[11],b[11],c[11];
	scanf("%s %s %s",a,b,c);
    if(a[strlen(a)-1]==b[0] && b[strlen(b)-1]==c[0])
    printf("YES");
    else
    printf("NO");
return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int N,K,screen;
	int i;
	scanf("%d%d",&N,&K);
	i = 0;
	screen = 1;
	for (i = 0; i < N; i++)
	{
		if(screen < K)
			screen *= 2;
		else
			screen += K;
	}		
	printf("%d\n",screen);
	return 0;
}

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

using ll = long long;
const int N = 2e5+10;

int k, n, a[N];

int main () {
  scanf("%d %d", &k, &n);
  for(int i = 1; i <= n; i++)
    scanf("%d", &a[i]);

  int ans = 1e9;
  for(int i = 1; i <= n; i++) {
    if(i < n) ans = min(ans, k - (a[i + 1] - a[i]));
    else ans = min(ans, a[n] - a[1]);
  } printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;

long long a, b, x;

long long f(long long n) {
	if (n >= 0) {
		return n / x + 1;
	}
	else if (n == -1) {
		return 0;
	}
}

int main() {
	cin >> a >> b >> x;
	cout << f(b) - f(a - 1) << endl;
	cin >> a;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        boolean flgA = false;
        boolean flgB = false;

        if (S.indexOf('A') != -1)
            flgA = true;
        if (S.indexOf('B') != -1)
            flgB = true;

        if (flgA && flgB)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

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

  vector<vector<long long>> dist(N, vector<long long>(N, 1e18));
  for(int i = 0; i < M; i++){
    int a, b, c;
    cin >> a >> b >> c;
    dist[a - 1][b - 1] = c;
    dist[b - 1][a - 1] = c;
  }

  for(int k = 0; k < N; k++){
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
	dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  vector<vector<int>> refresh_dist(N, vector<int>(N, 300));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(dist[i][j] <= L){
	refresh_dist[i][j] = 1;
      }
    }
  }

  for(int k = 0; k < N; k++){
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
	refresh_dist[i][j] = min(refresh_dist[i][j], refresh_dist[i][k] + refresh_dist[k][j]);
      }
    }
  }

  /*
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      cout << refresh_dist[i][j] << ' ';
    }
    cout << endl;
  }
  */
  
  int Q;
  cin >> Q;
  for(int i = 0; i < Q; i++){
    int s, t;
    cin >> s >> t;
    cout << ((refresh_dist[s - 1][t - 1] == 300)? (-1): refresh_dist[s - 1][t - 1] - 1) << endl;
  }
}


Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, K;
vec a;
bool dp[5010][5010];

bool C(const int &m) {
  m0(dp);
  dp[0][0] = true;
  vector<int> b;

  for (int i = 0; i < N; i++) {
    if (i != m) b.push_back(a[i]);
  }

  for (int i = 0; i < N - 1; i++) {
    for (int k = 0; k <= K; k++) {
      if (!dp[i][k]) continue;
      dp[i + 1][k] = true;
      if (k + b[i] <= K) dp[i + 1][k + b[i]] = true;
    }
  }

  int tmp = 0;
  for (int i = 0; i <= K; i++) {
    if (dp[N - 1][i]) {
      tmp = a[m] + i;
      if (tmp >= K) break;
    }
  }
  return (tmp < K) || (K <= tmp - a[m]);
}

signed main() {
  cin >> N >> K;
  a.resize(N);

  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    a[i] = min(tmp, K);
  }

  sort(ALL(a));

  int ok = -1, ng = N + 1;
  for (;ng-ok>1;) {
    int mid = (ok + ng) / 2;
    if (C(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << min(ng, N) << endl;
  return 0;
}

Measured memory_bytes: 24960
import math
import sys
import random

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))

def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

input_list = sieve_of_erastosthenes(10**6+1)
prime_list = [i for i, b in enumerate(input_list) if b == True]

def factorization(n):
    arr = []
    temp = n
    for i in prime_list:
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)
    if temp!=1:
        arr.append(temp)
    if arr==[]:
        arr.append(n)
    return arr
random.shuffle(a)
g = a[0]
arr = factorization(a[0])
used = set()
for i in arr:
    if i == 1: continue
    used.add(i)

# not coprimeか判定
for i in range(n-1):
    g = gcd(g, a[i+1])
if g > 1:
    print('not coprime')
    exit(0)

# pairwise coprimeか判定
used = [0] * (10**6+1)
pair = True
for _a in a:
    if _a == 1:
        continue
    if used[_a]:
        print('setwise coprime')
        exit(0)
    else:
        used[_a] = True

for p in prime_list:
    v = p
    cnt = 0
    while v < 10**6+1:
        if used[v]:
            cnt+=1
        v += p
    if cnt > 1:
        print('setwise coprime')
        exit(0)
print('pairwise coprime')


Measured memory_bytes: 127852
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main() {
    int n, k, a[201010];
    cin >> n >> k;
    rep(i, n) cin >> a[i];

    // 数字の種類を数える
    map<int, int> cnt;
    rep(i, n) cnt[a[i]]++;

    // 数字の種類の数だけを配列にして少ない順にする
    vector<int> v;
    for (auto p : cnt) v.push_back(p.second);
    sort(v.begin(), v.end());

    // 種類数
    int size = v.size();

    // 種類が最初からK種類以下なら変える必要がないので0
    if (size <= k) {
        printf("0\n");
    } else {
        // それ以外の場合では、数の種類から条件種類を引いて、その差の分、種類の数の配列から変更する個数をansに入れる
        int ans = 0;
        rep(i, size - k) ans += v[i];
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 14228
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  int cnt= 0;
  if(s[0] == '1') cnt++;
  if(s[1] == '1') cnt++;
  if(s[2] == '1') cnt++;
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
//y16-7
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

#define large 1000000007

string t,b;
LL dp[1000][1000];

LL solve(int sekiban, int jumon){
    if(jumon == b.size()) return 1;
    if(sekiban == t.size()) return 0;
    if(dp[sekiban][jumon] != -1) return dp[sekiban][jumon];
    LL re = 0;
    for(int i=sekiban; i<t.size(); i++){
        if(t[i] == b[jumon]) re += solve(i+1, jumon+1);
    }
    re %= large;
    dp[sekiban][jumon] = re;
    return re;
}

int main(){
    cin >> t >> b;
    for(int i=0; i<t.size(); i++){
        for(int j=0; j<b.size(); j++){
            dp[i][j] = -1;
        }
    }
    cout << solve(0,0) << endl;

    return 0;
}



Measured memory_bytes: 11040
using System;

namespace WA048A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());

            if(N % 500 <= A)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

string to_string(string s) { return '"' + s + '"'; }
string to_string(char c) { string s = "'"; s += c; return s + "'"; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } 
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
istream_iterator<string> eos;
void dbg_out(istream_iterator<string> it) { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(istream_iterator<string> it, Head H, Tail... T) {
    cerr << *it << " = " << to_string(H);
    if(++it != eos) cerr << ", ";
    dbg_out(it, T...);
}
#ifdef LOCAL
    #define dbg(...) { string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); dbg_out(_it, __VA_ARGS__); }
#else
    #define dbg(...)
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = h1 * 60 + m1, t2 = h2 * 60 + m2;
    cout << (t2 - t1 - k) <<  nl;
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int h,a[2000001];
 
void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  //左の子、自分、右の子で値が最大のノードを見る
  if(l<=h && a[l]>a[i]) largest=l;
  else largest=i;
  if(r<=h && a[r]>a[largest]) largest=r;
  if(largest!=i){
    swap(a[i],a[largest]);
    maxHeapify(largest);
  }
}
 
int main(){
  cin>>h;
  for(int i=1;i<=h;++i) cin>>a[i];
  for(int i=h/2;i>=1;--i) maxHeapify(i);
  for(int i=1;i<=h;++i){
    cout<<" "<<a[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 5016
package main

import (
	"fmt"
	"sort"
)

var N int
var L []int

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

func main() {
	fmt.Scan(&N)

	L = make([]int, 2*N)
	for i := 0; i < 2*N; i++ {
		fmt.Scan(&L[i])
	}
	sort.Ints(L)

	count := 0
	for i := 0; i < 2*N; i += 2 {
		count += min(L[i], L[i+1])
	}

	fmt.Println(count)
}


Measured memory_bytes: 512
import java.util.Scanner;

/**
 * @author subaru
 */
public class Main {
    // Five Dishes
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int totalTime = 0;
        int adjustment = 10;
        for (int i = 0; i < 5; i++) {
            int time = sc.nextInt();
            totalTime += time + (time % 10 == 0 ? 0 : 10 - time % 10);
            if (time % 10 != 0 && time % 10 < adjustment) {
                adjustment = time % 10;
            }
        }
        totalTime -= (10 - adjustment);
        System.out.println(totalTime);
    }
}


Measured memory_bytes: 23252
import java.util.Scanner;

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

		try (Scanner sc = new Scanner(System.in)) {
			long N = Long.parseLong(sc.next());
			long temp = 0L;
			int ret = 10;
			// Set<Long> s = new HashSet<>();
			for(long i = 1L; i <= 100000; i++) {
				if(!(N % i == 0)) {
					continue;
				}
				// System.out.println("F(" + (N /i) + ", " + i + ")");
				temp = Math.max(N /i, i);
				// if(!s.add(temp)) break;
				ret = Math.min(ret, String.valueOf(temp).length());
			}
			System.out.println(ret);
		} // Scanner Close
	}
}

Measured memory_bytes: 23124
#include <iostream>

using namespace std;

int main(void) {

    int N, M = 0;
    scanf("%d %d", &N, &M);

    int *A = NULL;
    A = (int*)malloc(sizeof(int)*N);
    for(int ii = 0; ii < N; ii++) {
        scanf("%d", &A[ii]);
    }

    //総投票数を数える
    int totalVoteNum = 0;
    for(int ii = 0; ii < N; ii++) {
        totalVoteNum = totalVoteNum + A[ii];
    }

    double border = 0.0;
    border = totalVoteNum * ( 1.0 / ( 4.0 * M ) );

    int popularNum = 0;
    for(int ii = 0; ii < N; ii++) {
        if( A[ii] >= border ) {
            popularNum++;
        }
    }

    if( M <= popularNum ) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    if( A != NULL ) {
        free(A);
    }

    return 0;
}

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

int main(void){
    ll N;
    vector<ll> d(5);
    cin >> N;
    rep(i, 5) cin >> d[i];
    
    ll ans = 4;
    ans += N / *min_element(d.begin(), d.end());
    if (N % *min_element(d.begin(), d.end()) != 0)
        ans++;
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s,t;
  cin >> s >> t;
  int ss=s.size(),tt=t.size();
  set<string> q;
  rep(i,ss-tt+1){
    string c=s;
    int y=0;
    rep(j,tt){
      if(c[j+i]!='?'&&c[j+i]!=t[j]){
        y=1;
        break;
      }
      if(c[j+i]=='?')c[j+i]=t[j];
    }
    if(y==1)continue;
    rep(x,ss){
      if(c[x]=='?')c[x]='a';
    }
    q.insert(c);
  }
  if(q.size()==0)cout << "UNRESTORABLE" << endl;
  else cout << *begin(q) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define INF 100000000
#define mod 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

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


int main() {
    ll n, a, i;
    cin >> n >> a;
    ll x[n], X=a;
    for(i=1; i<=n; i++) {
        cin >> x[i];
        X = max(X, x[i]);
    }
    
    ll d[n+1][n+1][2501];
    ll j, k, s;
    
    for(j=0; j<=n; j++) {
        for(k=0; k<=n; k++) {
            for(s=0; s<=n*X; s++) {
                if(j==0 && k==0 && s==0)
                    d[j][k][s]=1;
                else if(s<x[j] && j>=1)
                    d[j][k][s]=d[j-1][k][s];
                else if(s>=x[j] && j>=1 && k>=1)
                    d[j][k][s]=d[j-1][k][s]+d[j-1][k-1][s-x[j]];
                else
                    d[j][k][s]=0;
            }
        }
    }
    
    ll ans=0;
    for(i=1; i<=n; i++)
        ans += d[n][i][i*a];
    cout << ans << endl;
}


Measured memory_bytes: 51072
#include <stdio.h>

int A[1000000], n;


int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while ( left < right ) {
		mid = (left + right) / 2;
		if ( key == A[mid] ) return 1;
		if( key > A[mid] ) left = mid + 1;
		else if ( key < A[mid] ) right = mid;
	}
	return 0;
}

int main() {
	int i, q, k, sum = 0;
	
	scanf ("%d", &n);
	for ( i = 0; i < n; i++ ) {
		scanf("%d", &A[i]);
	}
	
	scanf ( "%d", &q);
	for ( i = 0; i < q; i++ ) {
		scanf ("%d", &k);
		if ( binarySearch( k ) ) sum++;
	}
	
	printf ("%d\n", sum);
	
	return 0;
}


Measured memory_bytes: 2136
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s == "G") cout << "C";
  if (s == "C") cout << "G";
  if (s == "T") cout << "A";
  if (s == "A") cout << "T";
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define INF 1000000000
using namespace std;

int N, Ma, Mb, a[40], b[40], c[40];

int min(int x, int y) {
    return x < y ? x : y;
}

int main() {
    cin >> N >> Ma >> Mb;
    for(int i=0; i<N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vector<int> > dp[41];
    for(int i=0; i<=N; i++) dp[i] = vector<vector<int> >(N*10+1, vector<int>(N*10+1));
    for(int n=0; n<=N; n++) {
        for(int ca=0; ca<=N*10; ca++) {
            for(int cb=0; cb<=N*10; cb++) {
                dp[n][ca][cb] = INF;
            }
        }
    }
    dp[0][0][0] = 0;
    for(int n=1; n<=N; n++) {
        for(int ca=0; ca+a[n-1]<=N*10; ca++) {
            for(int cb=0; cb+b[n-1]<=N*10; cb++) {
                dp[n][ca][cb] = min(dp[n][ca][cb], dp[n-1][ca][cb]);
                dp[n][ca+a[n-1]][cb+b[n-1]] = min(dp[n][ca+a[n-1]][cb+b[n-1]], dp[n-1][ca][cb] + c[n-1]);
            }
        }
    }
    int ans = INF;
    for(int ca=1; ca<=N*10; ca++) {
        for(int cb=1; cb<=N*10; cb++) {
            if(ca*Mb == cb*Ma) {
                if(ans > dp[N][ca][cb]) ans = dp[N][ca][cb];
            }
        }
    }
    if(ans == INF) {
        cout << "-1" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 26624
N = int(input())
Point = [list(map(int, input().split())) for i in range(N)]


# 各点の原点からのマンハッタン距離の偶奇は一致していなければならない
if len(set([(abs(x) + abs(y)) % 2 for x, y in Point])) == 2:
    print(-1)
    exit()


# 2べきの腕を構成
Arms = [2 ** i for i in reversed(range(39))]

# 偶数に合わせたい場合は長さ1の腕を追加
if (abs(Point[0][0]) + abs(Point[0][1])) % 2 == 0:
    Arms.append(1)


# Arm部の答えを出力
print(len(Arms))
print(' '.join(map(str, Arms)))


# 各点に到達するための腕の決める
for x, y in Point:
    ans = ''
    for length in Arms:
        min_diff, tmp_s = float('inf'), ''
        next_x, next_y = None, None
        for order, dx, dy in (('L', 1, 0), ('R', -1, 0), ('D', 0, 1), ('U', 0, -1)):
            tmp_x, tmp_y = (x + length * dx), (y + length * dy)
            diff = abs(tmp_x) + abs(tmp_y)

            if diff < min_diff:
                min_diff = diff
                tmp_s = order
                next_x, next_y = tmp_x, tmp_y

        ans += tmp_s
        x, y = next_x, next_y
    print(ans)


Measured memory_bytes: 3316
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

void main() {
  auto N = readln.chomp.to!ulong;
  auto An = readln.split.to!(int[]);
  auto Bn = readln.split.to!(int[]);
  auto Cn = 0 ~ readln.split.to!(int[]);

  int prev = -1;
  int satisfaction = 0;
  foreach(i; An) {
    i--;

    satisfaction += Bn[i];
    if (prev == i-1) satisfaction += Cn[i];
    prev = i;
  }

  writeln(satisfaction);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define  endl 			"\n"
#define  FOR(i, a, n)   for (ll i = a; i < n; i++)
#define  ROF(i, a, n)   for (ll i = a; i >= n; i--)
#define  all(x)         (x).begin(), (x).end()
#define  dline          cout<<"///REACHED///\n";

typedef long long ll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  4e+5+7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	string s;
	cin >> n >> s;
	if (s.length() <= n) cout << s << endl;
	else {
		cout << s.substr(0, n) << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3612