akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

type point struct {
	x, y int
}

type points []point

var sel = false

func (p points) Len() int {
	return len(p)
}

func (p points) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p points) Less(i, j int) bool {
	if sel == true {
		return p[i].y > p[j].y
	}
	return p[i].x < p[j].x
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	ab := make(points, N)
	cd := make(points, N)
	for i := 0; i < N; i++ {
		ab[i].x, ab[i].y = getInt(), getInt()
	}
	for i := 0; i < N; i++ {
		cd[i].x, cd[i].y = getInt(), getInt()
	}

	sort.Sort(cd)
	sel = true
	sort.Sort(ab)
	ans := 0
	// out(ab)
	// out(cd)
	used := make([]bool, N)
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			// out(ab[j], cd[i])
			if used[j] {
				continue
			}
			if cd[i].x > ab[j].x && cd[i].y > ab[j].y {
				// out("ok")
				used[j] = true
				ans++
				break
			}
		}
	}
	out(ans)
}


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

int main()
{
  ll n; cin>>n;
  int arr[n][3];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  }
  int dp[n][3];
  dp[0][0]=arr[0][0];
  dp[0][1]=arr[0][1];
  dp[0][2]=arr[0][2];
  for(int i=1;i<n;i++)
  {
    dp[i][0]=max(arr[i][0]+dp[i-1][1],arr[i][0]+dp[i-1][2]);
    dp[i][1]=max(arr[i][1]+dp[i-1][0],arr[i][1]+dp[i-1][2]);
    dp[i][2]=max(arr[i][2]+dp[i-1][0],arr[i][2]+dp[i-1][1]);
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int a=0,s;
	cin>>s;
	if(s/100==1){
		a=a+900;
	}
	
	if(s/10-(s/100)*10==1){
		a=a+90;
	}
	
	if(s-(s/10)*10==1){
		a=a+9;
	}
	
	if(s/100==9){
		a=a+100;
	}
	
	if(s/10-(s/100)*10==9){
		a=a+10;
	}
	
	if(s-(s/10)*10==9){
		a=a+1;
	}
	
	cout<<a<<endl;
}

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

using namespace std;

#define ll long long
#define vi vector<int>
#define pii pair<int, int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int N, M, buffA, buffB;
ll ans = 0;
vector<pii> vec;

void solve(){
    rep(i, N){
        pii cur = vec[i];

        ans += (ll)cur.first * (ll)min(cur.second, M);

        M -= cur.second;
        if(M < 0) break;
    }
    printf("%lld\n",ans);
}

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

    vec.resize(N);

    rep(i,N){
        scanf("%d %d", &buffA, &buffB);
        vec[i] = make_pair(buffA, buffB);
    }

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

    solve();
}


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

using namespace std;
typedef long long ll;
int main() {
    ll a, b, e, f, g;
    cin >> a >> b;
    ll c = min(a, b/2);
    e = b - (c * 2);
    if(e > 1)
    f = e / 4;
    cout << c + f << endl;


}


Measured memory_bytes: 256
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define pb	push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int N = 100005;

int n, vis[N];
vector<int>g[N];
vector<int>path, ex;

void dfs(int at){
    path.push_back(at);
    vis[at] = 1;
    for(auto u : g[at]){
        if(!vis[u]){
            dfs(u);
            return;
        }
    }
}

void extend(int at){
    vis[at] = 1;
    for(auto u : g[at]){
        if(vis[u]) continue;
        ex.push_back(u);
        extend(u);
        return;
    }
}

int main(){
    int x, y, m;
    scanf("%d %d", &n, &m);
    repn(i, m){
        scanf("%d %d", &x, &y);
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1);
    extend(1);
    printf("%d\n", int(path.size()) + int(ex.size()));
    reverse(ex.begin(), ex.end());
    for(auto u : ex) printf("%d ", u);
    for(auto u : path) printf("%d ", u);
    printf("\n");
	return 0;
}



Measured memory_bytes: 9976
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

#define TOP_NUM 18
#define NOTOP_NUM 8

int main(){
	IO_STREAM;
	int D;	cin>>D;
	vi c(26);
	vector<pair<int,int>>cs(26);
	rep(i,0,26){
		cin>>c[i];
		cs[i].first=c[i];
		cs[i].second=i;
	}
	int s[D][26];
	rep(i,0,D){
		rep(j,0,26){
			cin>>s[i][j];
		}
	}

	sort(all(cs));
	reverse(all(cs));
	vi top(D,1);
	rep(i,0,TOP_NUM){
		top[i]=cs[i].second+1;
	}
	vi notop(D,1);
	rep(i,0,NOTOP_NUM){
		notop[i]=cs[i+TOP_NUM].second+1;
	}

	int cnt=1;
	int nt_idx=0;
	while(1){
		rep(i,0,TOP_NUM){
			cout<<top[i]<<endl;
			cnt++;
			if(cnt>D) return 0;
		}
		rep(i,0,5){
			cout<<notop[nt_idx]<<endl;
			nt_idx++;
			if(nt_idx>=NOTOP_NUM) nt_idx=0;
			cnt++;
			if(cnt>D) return 0;
		}
	}
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  long long a[n];
  for(int i=0;i<n;i++)
    cin >> a[i];
   deque<long long> b(0);
  if(n%2==1){
      b.push_back(a[0]);
    for(int i=1;i<n-1;i+=2){
      b.push_back(a[i]);
      b.push_front(a[i+1]);
    }
  }
  else{
    for(int i=0;i<n;i+=2){
    b.push_back(a[i]);  
    b.push_front(a[i+1]);
    }
  }
  for(int i=0;i<b.size();i++)
  cout << b.at(i) << " ";
  cout << endl;
}

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

int main()
{
	int n;
	int i, j, k;
	int build[4][3][10] = { {{}} };
	cin >> n;
	int b, f, r, v;
	for (i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		build[b - 1][f - 1][r - 1] += v;
	}
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 10; k++) {
				cout << " ";
				cout << build[i][j][k];
			}
			cout << endl;
		}
		if (i < 3)cout << "####################"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
using namespace std;
using ll = long long;
int main()
{
    ll k, n, m;
    cin >> k >> n >> m;
    ll polp;

    ll pip = n / k;
    if(n%k == 0){
        polp = pip * k;
    }else
    {
        polp = pip * k + k;
    }
    
    
    if(polp <=m ){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }

    /*ll k,n,m;
    cin >> k >>n >> m;
    ll pop = 0;
    int temp = -1;
    while (pop <= m)
    {
        pop += k;
        if(n <= k){
            cout << "OK" << endl;
            temp = 0;

            break;
        }
    }
    if(temp == -1){
        cout << "NG" << endl;
    }*/
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,q,vis[N];
int main()
{
    long long sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        vis[x]++;sum+=x;
    }
    scanf("%d",&q);
    while(q--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        sum=sum-(long long)vis[a]*a+(long long)vis[a]*b;
        vis[b]+=vis[a];vis[a]=0;
        printf("%lld\n",sum);
    }
}


Measured memory_bytes: 4144
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,N,X,a[1000],sum=0,rem,j,rem1,sum1=0,temp;
    scanf("%d%d",&N,&X);
    for(i=0;i<N;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    rem=X-sum;
    for(i=0;i<N-1;i++)
    {
        for(j=0;j<N-i-1;j++)
        {
            if(a[j]>a[j+1])
            {
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=a[j];
            }
        }
    }
    rem1=rem/a[0];
    sum1=N+rem1;
    printf("%d",sum1);
    return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BDigits {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int res = 0;
            int current = n;
            while (current > 0) {
                current /= k;
                res++;
            }
            out.println(res);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22740
import java.util.*
import kotlin.math.min

data class ParenParts(val min: Int, val sum: Int)

fun main() {
//    val builder = StringBuilder()

    val n = readInputLine().toInt()

    val up = PriorityQueue<ParenParts> { x, y -> y.min.compareTo(x.min) }
    val down = PriorityQueue<ParenParts> { x, y -> (y.sum - y.min).compareTo(x.sum - x.min) }

    repeat(n) {
        val s = readInputLine()

        var minTmp = 0
        var sumTmp = 0

        for (c in s) {
            when(c) {
                '(' -> {
                    sumTmp++
                }
                else -> {
                    sumTmp--
                    minTmp = min(minTmp, sumTmp)
                }
            }
        }

        if (sumTmp >= 0) {
            up.add(ParenParts(minTmp, sumTmp))
        } else {
            down.add(ParenParts(minTmp, sumTmp))
        }
    }

    var current = 0

    while (up.isNotEmpty()) {
        val (min, sum) = up.poll()
        if (current + min < 0) {
            println("No")
            return
        }
        current += sum
    }

    while (down.isNotEmpty()) {
        val (min, sum) = down.poll()
        if (current + min < 0) {
            println("No")
            return
        }
        current += sum
    }

    if (current == 0) {
        println("Yes")
    } else {
        println("No")
    }

//    builder.appendln(ans)

//    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 91372
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;
ll mn1=-9223372036854775808;
int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
// --------------------------------------------------</TEMPLATE>--------------------------------------------------


void solve()
{
    ll n,x,y;
    ll cnt=0;
    cin>>n;
    vector<pair<int,int> >v;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        v.push_back({x,y});
    }
    for(int i=0;i<n-2;i++)
    {
        if(v[i].first==v[i].second && v[i+1].first==v[i+1].second && v[i+2].first==v[i+2].second)
        {
            cout<<"Yes"<<endl;
            return;
        }
    }
    cout<<"No"<<endl;
}
int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);

}


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

int main(){
	int p[110][110], N, M[110], K, l[110];
	while(1){
		int a = 0, b[110] = {}, c = 0;

		cin>>N;
		if(N == 0) break;

		for(int i = 0; i < N; i++){
			cin>>M[i];
			for(int j = 0; j < M[i]; j++){
				cin>>p[i][j];
			}
		} 
		cin>>K;
		for(int i = 0; i < K; i++){
			cin>>l[i];
		}
	
		for(int i = 0; i < K; i++){
			for(int j= 0; j < N; j++){
				int x = 0;
				if(b[j] == 1){
				} else {
					for(int k = 0; k < M[j];k++){
						if(l[i] == p[j][k]){
							x = 1;
						}
					}
					
					if(x == 0) b[j] = 1;
				}
			}
		}
		
		for(int i = 0; i < N; i++){
			if(b[i] == 0) {
				a++;
				c = i;
			}
			
		}
		if(a == 1) cout<<c + 1<<endl;
		else cout<<"-1"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    ll a1,b1;
    double a, b;
    cin >> a1 >> b1;
    a = 0.08;
    b = 0.1;
    for(ll num = 1; num <= (ll)1e7; ++num){
        if((floor(num * a) ==  a1) && floor(num * b) == b1) {
            cout << num << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){
	if(b==0)
		return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
	return a * b / gcd(a, b);
}

int main()
{
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(i, n){
		cin >> a[i];
		a[i] /= 2;
	}
	int count = 0;
	rep(i, n)
	{
		ll tmp = 0;
		while(a[i]%2==0){
			a[i] /= 2;
			tmp++;
		}
		if (i == 0)
		{
			count = tmp;
			continue;
		}
		if(count != tmp){
			cout << 0 << endl;
			return 0;
		}
	}
	ll x = 1;
	rep(i,n){
		x = lcm(x, a[i]);
		if (x > m)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	ll ans = (m / (x * pow(2, count))+1) / 2;
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	int t = 0,  x = 0, y = 0;
	bool ok = true;
	rep(i, n) {
		int a, b, c;
		cin >> a >> b >> c;
		int dist = abs(b - x) + abs(c - y);
		if (dist > a - t) ok = false;
		if (dist % 2 != (a - t) % 2) ok = false;
		t = a, x = b, y = c;
	}
	puts((ok) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
W, H, N = map(int, input().split())
W0, H0 = 0, 0

for _ in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        W0 = max(W0, x)
    elif a == 2:
        W = min(W, x)
    elif a == 3:
        H0 = max(H0, y)
    else:
        H = min(H, y)

# X, Y, X and Yが負のケースでは答えは0
X = max(0, W - W0)
Y = max(0, (H - H0))

print(X * Y)

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

using namespace std;

int main()
{
    bool ans = false;
    vector<pair<int,bool>>arr;
    for(int i = 0;i<9;i++){
        int a; cin>>a; arr.push_back(make_pair(a,false));
    }
    int n;cin>>n;
    while(n--){
        int a; cin>>a;
        for(int i = 0;i<arr.size();i++){
            if(arr[i].first==a)arr[i].second = true;
        }
    }
    
    for(int i = 0;i<3;i++){
        if(arr[i].second&&arr[i+3].second&&arr[i+6].second||arr[3*i].second&&arr[(3*i)+1].second&&arr[(3*i)+2].second){
            ans = true;
        }
    }
    if(arr[0].second&&arr[4].second&&arr[8].second){
        ans = true;
    }
    if(arr[2].second&&arr[4].second&&arr[6].second){
        ans = true;
    }
    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main(){
	typedef pair<int,int>P;
	typedef set<P>Set;
	int n,m,i,x,y;
	for(;cin>>m,m;){
		Set cns,photo;
		for(i=m;i--;){
			cin>>x>>y;
			cns.insert(P(x,y));
		}
		cin>>n;
		for(i=n;i--;){
			cin>>x>>y;
			photo.insert(P(x,y));
		}
		for(Set::iterator itp=photo.begin();itp!=photo.end();++itp){
			Set::iterator itc=cns.begin();
			int dx=itp->first-itc->first,dy=itp->second-itc->second;
			for(;++itc!=cns.end();){
				if(photo.find(P(itc->first+dx,itc->second+dy))==photo.end())
					break;
			}
			if(itc==cns.end()){
				cout<<dx<<" "<<dy<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTA(a,n) sort(a,a+n)
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int n;
    cin >> n;
    int l[1100],r[1100];
  	int ans=0;
    REP(i,0,n){
      cin >> l[i] >> r[i];
      ans += r[i]-l[i]+1;
    }
    //処理
    //出力
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF=1LL<<62;
inline void read(int &x){
    x=0;
    char ch=getchar();
    while(!isdigit(ch)) ch=getchar();
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
}
int main(){
    int a,b;
    read(a),read(b);
    cout<<a*b<<' '<<a+a+b+b<<endl;
    return 0;
}


Measured memory_bytes: 3092
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
let n = input.map(Number);
let count = 0;
function primeNumber (num) {
    if(num === 2) {
        return true;
    }
    if (num < 2 || num % 2 === 0) {
        return false;
    }
    let i = 3;
    while (i <= Math.sqrt(num)) {
            if(num % i === 0) {
                return false;
            }
            i = i + 2;
    }
    return true;
}

for (i=0; i<n.length; i++) {
    if (primeNumber(n[i])) count++;
}
console.log(count);


Measured memory_bytes: 17600
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Pair struct {
	Key   int64
	Value int64
}

// sort.Sort(ByKey(pairs))
type ByKey []Pair

func (s ByKey) Len() int {
	return len(s)
}

func (s ByKey) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s ByKey) Less(i, j int) bool {
	return s[i].Key < s[j].Key
}

// sort.Sort(ByValue(pairs))
type ByValue []Pair

func (s ByValue) Len() int {
	return len(s)
}

func (s ByValue) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s ByValue) Less(i, j int) bool {
	return s[i].Value < s[j].Value
}

type Int64Slice []*item

func (p Int64Slice) Len() int           { return len(p) }
func (p Int64Slice) Less(i, j int) bool { return p[i].val < p[j].val }
func (p Int64Slice) Swap(i, j int)      { p[i].val, p[j].val = p[j].val, p[i].val }

type item struct {
	val int64
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n := nextInt()

	order := make([]Pair, 0, n)

	for i := 0; i < n; i++ {
		a, b := nextInt64(), nextInt64()
		p := Pair{
			Key:   a,
			Value: b,
		}
		order = append(order, p)
	}

	sort.Sort(ByValue(order))

	var val int64
	for _, item := range order {
		val += item.Key
		if val > item.Value {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


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

int main() {
    int n;
    cin >> n;
    vector<int>b(n-1);
    vector<int>a(n);
    for(int i=0; i<n-1; ++i){
        cin >> b[i];
        a[0]=b[0];
        a[i+1]=b[i];
    }
    int ans;
    ans =0;
    for(int i=0; i<n-1; ++i){
        if(a[i]>a[i+1]){
            a[i]=a[i+1];
        }
    }
    for(int i=0; i<n; ++i){
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
int q;
vector<int> e[SIZE];
ll x[SIZE];
ll d[SIZE];
ll f[SIZE];

void dfs(int v,ll c){
  f[v] = 1;
  c += x[v];
  d[v] = c;
  for(int nxt : e[v]) if(f[nxt]==0) {
    dfs(nxt,c);
  }
}


int main(){
  cin >> n >> q;
  rep(i,0,n-1){
    int a,b;
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  rep(i,0,q){
    int p;
    ll y=0;
    cin >> p;
    cin >> y;
    x[p] += y;
  }

  dfs(1,0);

  rep(i,1,n+1){
    if(i!=1)cout << " ";
    cout << d[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 24320
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define MAX 10000
#define INFTY (1 << 20)

using namespace std;

class Disjoint {
public:
	vector<int> rank, p;

	Disjoint() {}
	Disjoint(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);

		for (int i = 0; i < size; i++) {
			Makeset(i);
		}
	}

	void Makeset(int x) {
		p[x] = x;
		rank[x] = 0;
	}

	bool same(int x, int y) {
		return Findset(x) == Findset(y);
	}

	void unite(int x, int y) {
		link(Findset(x), Findset(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	int Findset(int x) {
		if (x != p[x]) {
			p[x] = Findset(p[x]);
		}
		return p[x];
	}
};

class Edge {
public:
	int sou, tar, cost;
	Edge(int sou = 0, int tar = 0, int cost = 0) :
		sou(sou), tar(tar), cost(cost) {}

	bool operator < (const Edge& e) const {
		return cost < e.cost;
	}
};

int Kruskal(int N, vector < Edge> edges){
	int acost = 0;
	sort(edges.begin(), edges.end());

	Disjoint dset = Disjoint(N + 1);

	for (int i = 0; i < N; i++) {
		dset.Makeset(i);
	}

	int sou, tar;

	for (int i = 0; i < edges.size(); i++) {
		Edge e = edges[i];

		if (!dset.same(e.sou, e.tar)) {
			acost += e.cost;
			dset.unite(e.sou, e.tar);
		}
	}
	return acost;
}

int main() {
	int N, M, cost;
	int sou, tar;

	cin >> N >> M;

	vector<Edge> edges;

	for (int i = 0; i < M; i++) {
		cin >> sou >> tar >> cost;

		edges.push_back(Edge(sou, tar, cost));
	}

	cout << Kruskal(N, edges) << endl;

	return 0;
}


Measured memory_bytes: 5432
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}

ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n,m;
    cin >> n >> m;
    priority_queue<int>pq;
    rep(i,n){
        int a;
        cin >> a;
        pq.push(a);
    }
    rep(i,m){
        int x=pq.top();pq.pop();
        pq.push(x/2);
    }
    ll ans=0;
    while(!pq.empty()){
        int x=pq.top();pq.pop();
        ans+=x;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	int ans = 0;
	cin >> N;
	VI X(N);
	REP(i, N)cin >> X[i];
	
	/*
	int K = 1;
	int kai = 1;
	double C = 1.0;
	REP(i, N - 1) {
		int Y = X[i + 1] - X[i];
		//ans *= K;
		ans += kai * C*Y;
		K++;
		kai *= K;
		C += 1.0 / (i + 2.0);
		kai %= mod;
		ans %= mod;
	}
	
	*/
	VI ny(N + 1);
	ny[0] = ny[1] = 1;
	eFOR(i, 2, N)ny[i] = (mod - mod / i)*ny[mod%i] % mod;
	eFOR(i, 2, N) {
		ny[i] += ny[i - 1];
		ny[i] %= mod;
	}

	FOR(i, 1, N) {
		int Y = X[i] - X[i - 1];
		ans += ny[i] * Y%mod;
		ans %= mod;
	}

	eFOR(i, 1, N - 1) {
		ans *= i;
		ans %= mod;
	}
	
	cout << ans << endl;



	return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define P 1000000007
#define N 100010
int n, a[N], b[N];

int main() {
	cin >> n;
	for (int i = 0; i < n; i ++) cin >> a[i];
	int S = 1;
	for (int i = 0; i < n; i ++) {
		// first i-(a[i]+1)/2 are in first i+1
		b[i] = max(i-(a[i]-1)/2, 0);
	}
	for (int i = 1; i < n; i ++)
		b[i] = max(b[i], b[i-1]);
	for (int i = n-1; i >= 1; i --)
		S = (ll)S*(n-b[i-1]-(n-i-1))%P;
	printf ("%d\n", S);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin>>N;
    int A[N];
    int B[N];
    map<int,int> m;
    rep(i,N) {
        cin>>A[i];
        B[i]=i-A[i];
        m[B[i]]++;
    }
    int ans=0;
    for(int i=0;i<N;i++){
        int x=A[i]+i;
        ans+=m[x];
    }
    cout << ans << endl;


}


Measured memory_bytes: 29360
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();                                             
        int b = scan.nextInt();
        int area = a * b;
        int circ = (a + b) * 2;
  
        System.out.println(area + " " + circ);
    }
}

Measured memory_bytes: 26012
# coding: utf-8
# Here your code !

numt = input()
for i in xrange(numt):
    count = 0
    lis = [[0,0]]
    ma = 0
    tmpl = [0,0]
    while True:
        x,y = map(int,raw_input().split())
        tempx = lis[count][0] + x
        tempy = lis[count][1] + y
        count += 1
        if(x == 0 and y == 0):
            for l in lis:
                if(l[0]**2 + l[1]**2 > ma):
                    ma = l[0]**2 + l[1]**2
                    tmpl = l
                elif(l[0]**2 + l[1]**2 == ma):
                    if(tmpl[0] < l[0]):
                        tmpl = l
            print tmpl[0],tmpl[1]
            break
        lis.append([tempx,tempy])
    

Measured memory_bytes: 6348
X = int(input())

if 400 <= X <= 599:
    print("8")
elif 600 <= X <= 799:
    print("7")
elif 800<= X <= 999:
    print("6")
elif 1000 <= X <= 1199:
    print("5")
elif 1200 <= X <= 1399:
    print("4")
elif 1400<= X <=1599:
    print("3")
elif 1600<= X <= 1799:
    print("2")
elif 1800<= X <= 1999:
    print("1")

Measured memory_bytes: 9184
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  
  #0条件
  if 0 in A:
    print(0)
    exit()
  
  ans = 1
  for a in A:
    #積
    ans *= a
    
    #条件
    if ans > 10**18:
      print(-1)
      exit()
  print(ans)

main ()

Measured memory_bytes: 21788
import java.util.Scanner

/**
 * タイプAの物質とタイプBの物質の混合比が Ma:Mb
 * sum(a_)*mb = sum(b_)*ma
 * よって、a * mb - b * maの合計が0になる組み合わせを探す。
 * cとnについての動的計画法で行う。
 *
 * 発散するかに見えるが、
 * -100 < a * mb -b * ma < 100
 * costの上限は、N * c <= 40 *100
 * 分量の状態は200*40以下
 * で間に合いそう。
 */
fun main(args: Array<String>) {
    class Drug(a: Int, b: Int, val cost: Int, ma: Int, mb: Int) {       // 1≦ai,bi≦10, 1≦ci≦100
        val excess = a * mb - b * ma
    }

    data class Input(val n: Int, val ma: Int, val mb: Int, val drugs: List<Drug>)
    val (n, ma, mb, drugs) = Scanner(System.`in`).use<Scanner, Input> {
        val n = it.nextInt()    // 1≦N≦40
        val ma = it.nextInt()   // 1≦Ma,Mb≦10
        val mb = it.nextInt()
        val drugs: List<Drug> = Array(n) {n ->
            Drug(it.nextInt(), it.nextInt(), it.nextInt(), ma, mb)
        }.toList()

        Input(n, ma, mb, drugs)
    }

    // cell[i+1][c] = cell[i][c] + cell[i][c - drugs[i+1].cost].map
    // メモ化テーブル
    var minimumCost = 4001      // N * c <= 40 *100
    var memo: MutableList<Set<Int>>     //Array<Set<Int>> = arrayOf()
    var nextMemo: MutableList<Set<Int>> = Array(minimumCost, {mutableSetOf<Int>()}).toMutableList()        //Array<Set<Int>> = Array(minimumCost, {mutableSetOf<Int>()})
    // 初期設定
    nextMemo[0] = mutableSetOf(0)
    for (i in 0 until n) {
        memo = nextMemo
        nextMemo = mutableListOf(memo[0])//Array(minimumCost, {mutableSetOf<Int>()})
        // nextMemo[0] = memo[0]       // cost == 0 生成量0で目的を満たさないので判定にかけない。
        for (cost in 1 until memo.size) {
            //nextMemo[cost]
            val next = if (cost - drugs[i].cost < 0) {
                memo[cost]
            } else {
                memo[cost] + memo[cost - drugs[i].cost].map{it + drugs[i].excess}
            }
            nextMemo.add(next)
            // minimumCostより上については考慮する必要がない。
            if (0 in nextMemo[cost]) {
                minimumCost = cost
                break
            }
        }

    }

    println(if (minimumCost == 4001) -1 else minimumCost)
}


Measured memory_bytes: 169808
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

#define LL long long
const int N = 1e5 + 100;

int a[N],n,k,q,x;

int main() {
    scanf("%d%d%d",&n,&k,&q);
    for(int i = 1 ; i <= n ; i++) a[i] = k - q;
    /*while(q--) {
        scanf("%d",&x);
        for(int i = 1 ; i <= n ; i++) a[i]--;
        a[x]++;
    }*/
    while(q--) {
        scanf("%d",&x);
        a[x]++;
    }
    for(int i = 1 ; i <= n ; i++) {
        if(a[i] > 0) puts("Yes");
        else if(a[i] <= 0) puts("No");
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 1024
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string input = Console.ReadLine();
      int index=input.IndexOf("7");
 	if(index!=-1){
      Console.WriteLine("Yes");
    }else{
      Console.WriteLine("No");
      }

	}
  }
}


Measured memory_bytes: 26188
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
//#define MOD 998244353
#define MOD 1000000007
#define PI 3.14159265358979
using ll = long long;
using namespace std;

int main(){
    int a[5];
    rep(i,3){
        cin>>a[i];
    }
    sort(a, a+3);
    cout<<a[0]+a[1];
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int n, m;
  scanf("%d %d", &n, &m);
  cout << (1900*m + 100 * (n-m)) * pow(2,m);

//  printf("%d", (1900*m + 100 * (n-m)) * pow(2,m)); //longに対しては%ld

  return 0;
}


Measured memory_bytes: 512
import sys
# import collections
# import math
import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    s, t = sys.stdin.read().split()
    n, m = len(s), len(t)
    s = sorted(s)
    t = list(reversed(sorted(t)))
    if n < m:
        for i in range(n):
            f_s, f_t = False, False
            for c in string.ascii_lowercase:
                if s[i] == c: f_s = True
                if t[i] == c: f_t = True
                
                if f_s and not f_t: print('Yes'); exit()
                elif not f_s and f_t: print('No'); exit()
                elif f_s and f_t: break
                else: continue
        ans = 'Yes'
    else:
        for i in range(m):
            for c in string.ascii_lowercase:
                f_s, f_t = False, False
                if s[i] == c: f_s = True
                if t[i] == c: f_t = True
                
                if f_s and not f_t: print('Yes'); exit()
                elif not f_s and f_t: print('No'); exit()
                elif f_s and f_t: break
                else: continue
        ans = 'No'

    print(ans)
        

if __name__ == "__main__":
    # execute only if run as a script
    main()


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

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


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(12);

    string s;
    cin >> s;


    for(int i = 0; i < (1<<3); i++){
        int tmp = s[0]-'0';
        for(int j = 0; j < 3; j++){
            if(i&(1<<j)){
                tmp += s[j+1]-'0';
            }else{
                tmp -= s[j+1]-'0';
            }
        }
        if(tmp == 7){
            for(int j = 0; j < 3; j++){
                if(i&(1<<j)){
                    s.insert(2*j+1, "+");
                }else{
                    s.insert(2*j+1, "-");
                }
            }
            s.append("=7");
            break;
        }
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
nums = [0] * (10 ** 5 + 1)
for i in a:
    nums[i] += 1
nsum = sum(a)
for _ in range(q):
    b, c = map(int, map(int, input().split()))
    nsum = nsum + (c - b) * nums[b]
    print(nsum)
    nums[c] += nums[b]
    nums[b] = 0
    

Measured memory_bytes: 21068
# import math
# import statistics
# import itertools
a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
# e1,e2,e3,e4 = map(int,input().split())
f = list(map(int,input().split()))
# g = [int(input()) for _ in range(a)]
bunbo=0
for i in range(len(f)):
    bunbo+=1/f[i]
print(1/bunbo)

Measured memory_bytes: 8984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

bool num(int p[],int N,int k){
  bool ans = false;
  for(int i=0;i<N;i++){
    if(k==p[i]) {
      ans=true;
      break;
    }
  }
  return ans;
}

int main(){
  int N,X;
  cin >> X >> N;
  int p[N];
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  sort(p,p+N);
  int i=X;
  while(num(p,N,i)){
    i++;
  }
  int j=X;
  while(num(p,N,j)){
    j--;
  }
  if(X-j>i-X) cout << i << endl;
  else cout << j << endl;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[500];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,cnt=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    while(1)
    {
        int res=0,f=0;
        for(int i=0; i<n; i++)
        {
            if(arr[i])
            {
                arr[i]--;
                res=1;
            }
            else if(res)
            {
                f=1;
                res=0;
                cnt++;
            }
        }
        if(res)
            cnt++,f=1;
        if(!f)
            break;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3660
import sys  
import numpy as np

input = sys.stdin.readline

S_ = input()
T = input()

S_ = list(S_)[:-1]
T = list(T)[:-1]

j = False
for i in range(len(S_)-len(T)+1):
    if i==0:
        part = S_[-len(T):]
    else :
        part = S_[-len(T)-i:-i]
    j = False
    for k in range(len(part)-1,-1,-1):
        if part[k] == "?":
            if k==0:
                j = True
            continue
        elif part[k] == T[k]:
            if k==0:
                j = True
        else:
            break
    if j:
        break


if j:
    for p in range(len(T)):
        S_[len(S_)-len(T)-i+p] = T[p]
    # print("*",S_)
    for k in range(len(S_)):
        if S_[k] == "?":
            S_[k] = "a"

    print("".join(S_))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 21416
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define ll long long
using namespace std;
vector<int> pat[114514];
int vu[114514],eu[114514],deg[114514],d[114514];
signed main(){
	int n,m;
	cin>>n>>m;
	map< pair<int,int>, int > mope;
	vector<int> a,b;
	for(int i=0;i<m;i++){
		int ta,tb;
		cin>>ta>>tb;
		ta--;tb--;
		a.pb(ta);b.pb(tb);
		pat[ta].pb(tb);pat[tb].pb(ta);
		mope[mp(ta,tb)]=i;
		mope[mp(tb,ta)]=i;
	}
	queue<int> q;
	q.push(0);
	vu[0]=1;
	if(m%2==1){
		cout<<"-1"<<endl;
		return 0;
	}
	while(!q.empty()){
		int ci = q.front(); q.pop();
		for(int i=0;i<pat[ci].size();i++){
			int cd = pat[ci][i];
			if(vu[cd]==0){
				vu[cd]=1;
				eu[mope[mp(ci,cd)]]=1;
				d[ci]++;d[cd]++;
				q.push(cd);
			}
		}
	}
	vector< pair<int,int> > ans;
	for(int i=0;i<m;i++){
		if(eu[i]==0){
			ans.pb(mp(a[i],b[i]));
			deg[a[i]]++;
		}
	}
	for(int i=0;i<n;i++){
		vu[i]=0;
	}
	for(int i=0;i<n;i++){
		if(d[i]==1){
			q.push(i);
			//cout<<i<<endl;
		}
	}
	while(!q.empty()){
		int ci = q.front(); q.pop();
		vu[ci]=1;
		for(int i=0;i<pat[ci].size();i++){
			int cd = pat[ci][i];
			if(vu[cd]==0){
				int ced = mope[mp(ci,cd)];
				if(eu[ced]==1){
					if(deg[ci]%2==1){
						ans.pb(mp(ci,cd));
						deg[ci]++;
					}
					else{
						ans.pb(mp(cd,ci));
						deg[cd]++;
					}
					eu[ced]=0;
d[cd]--;
				if(d[cd]==1){q.push(cd); /* cout<<cd<<endl;*/}
				}
			}
		}
	}
	for(int i=0;i<ans.size();i++){
		cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
	}
	for(int i=0;i<n;i++){
		//cout<<deg[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 23152
void main() {
	auto ip = readAs!(long[]), I = ip[0], O = ip[1], T = ip[2], J = ip[3], L = ip[4], S = ip[5], Z = ip[6];
	long res = 2*(I/2+J/2+L/2) + O;
	if(I > 0 && J > 0 && L > 0) {
		I--; J--; L--;
		res = max(res, 2*(I/2+J/2+L/2) + 3 + O);
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

struct Edge{
    ll to, cost;
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
ll inf = 1e15;
ll mod = 1e9 + 7;
vll dijkstra(const Graph &g, int s){
    vll d(g.size(), inf);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    while(!que.empty()){
        ll dist = que.top().first;
        int v = que.top().second;
        que.pop();
        if(d[v] < dist) continue;
        for(const auto &e: g[v]){
            if(d[e.to] <= d[v] + e.cost) continue;
            d[e.to] = d[v] + e.cost;
            que.push(P(d[e.to], e.to));
        }
    }
    return d;
}

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

    ll h, w;
    cin >> h >> w;

    ll c;
    Graph g(10);
    REP(i, 10){
        REP(j, 10){
            cin >> c;
            g[j].push_back((Edge){i, c});
        }
    }
    vll dist = dijkstra(g, 1);
    ll a, res = 0;
    REP(i, h){
        REP(j, w){
            cin >> a;
            if(a == -1) continue;
            res += dist[a];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);
			Map<String, Integer> bloodType = new HashMap<String, Integer>();
			while (sc.hasNextLine()) {
				// ??\???
				String[] str = sc.nextLine().split(",");

				// ????¶??????¨????????\????????°?????????
				int count = 1;
				if (bloodType.containsKey(str[1])) {
					count += bloodType.get(str[1]);
				}
				bloodType.put(str[1], count);
			}
			// ??????
			if (!bloodType.containsKey("A")) {
				System.out.println("0");
			} else {
				System.out.println(bloodType.get("A"));
			}
			if (!bloodType.containsKey("B")) {
				System.out.println("0");
			} else {
				System.out.println(bloodType.get("B"));
			}
			if (!bloodType.containsKey("AB")) {
				System.out.println("0");
			} else {
				System.out.println(bloodType.get("AB"));
			}
			if (!bloodType.containsKey("O")) {
				System.out.println("0");
			} else {
				System.out.println(bloodType.get("O"));
			}

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 17176
n = int(input())
t = {"AC":0, "WA":1, "TLE":2, "RE":3}
u = ["AC", "WA", "TLE", "RE"]
ans = [0]*4
for _ in range(n):
    ans[t[input()]] += 1
for i in range(4):
    print(u[i], "x", ans[i])

Measured memory_bytes: 9196
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int a, b, c;
    cin >> a >> b >> c;

    if(b - a == c - b){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

void func(int a,int b,int c){
  int cont;
  if(a<b){
    cont=a;
    a=b;
    b=cont;
  }
  if(a<c){
    cont=a;
    a=c;
    c=cont;
  }
  a=a*a;
  if(a==(b*b+c*c))
    printf("YES\n");
  else
    printf("NO\n");
}

int main (void){
  int a,b,c,i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&a,&b,&c);
    func(a,b,c);
  }
  return (0);
}

Measured memory_bytes: 580
def abc174d():
    n = int(input())
    s = input()
    cnt = s.count('R')
    if cnt == len(s):
        print(0)
        return
    start = 0
    while s[start] == 'R':
        start += 1
        cnt -= 1
    ans = cnt
    for i in range(start, start+cnt):
        if s[i] == 'R':
            ans -= 1
    print(ans)
abc174d()

Measured memory_bytes: 64528