akhauriyash/Code-Regression huggingface dataset:
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        s: [chars; n],
    }

    let mut map = HashMap::new();

    for x in s {
        *map.entry(x).or_insert(0) += 1;
    }

    let mut v = vec![];
    for (s, c) in map {
        v.push((-(c as isize), s));
    }
    v.sort();
    let cm = v[0].0;
    for (c, x) in v {
        if c != cm {
            break;
        }
        println!("{}", x.into_iter().collect::<String>());
    }
}


Measured memory_bytes: 36620
ConstNum = 0.006
castle_N = int(input())
T,avg_A = input().rstrip().split()

dict_rec = {}
place_Cnt = 1
for i in input().rstrip().split():
  dict_rec[place_Cnt] = abs((int(T) - int(i) * ConstNum) - int(avg_A))
  place_Cnt += 1

rec = [k for k, v in dict_rec.items() if v == min(dict_rec.values())][0]
print(rec)


Measured memory_bytes: 3316
#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using namespace internal;
#define rep(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
    int n,q;
    cin >> n >> q;
    dsu uf(n);
    rep(i,q) {
        int t, u1, u2;
        cin >> t >> u1 >> u2;
        if(t == 0) {
            uf.merge(u1,u2);
        }else if(t == 1) {
            int ans = 0;
            if(uf.same(u1,u2)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 3992
import java.io.*;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int a = fs.nextInt();
        int b = fs.nextInt();
        int ans = Math.max( a , b );
        if( a == ans ){
            a--;
        }
        else {
            b--;
        }
        System.out.println( ans + Math.max(a,b) );
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) {
                return buffer[ptr++];
            } else {
                return -1;
            }
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
                throw new NumberFormatException();
            }
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 22996
n,m = map(int,input().split())
lr = list(list(map(int,input().split())) for i in range(m))

l_max = lr[0][0]
r_min = lr[0][1]

for i in range(1,m):
    if l_max < lr[i][0]:
        l_max = lr[i][0]
    if r_min > lr[i][1]:
        r_min = lr[i][1]

print(max(r_min - l_max + 1 , 0))


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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n;
    cin >> n;

    vector<int> pow2 = {64, 32, 16, 8, 4, 2, 1};

    [&](){
        for(int i = n; i >= 1; i--){
            rep(j, pow2.size()){
                if(i == pow2[j]){
                    cout << pow2[j] << endl;
                    return;
                }
            }
        }
    }();

    return 0;
}


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


int main() {
	int n;
	cin >> n;
	int cnt = 0;
	for(int i =1;i < n ;i++) {
		int add = (n+i-1)/i -1;
		cnt+=add;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

typedef long double lld;

using namespace std;


// https://atcoder.jp/contests/abc151/tasks/abc151_f

lld _abs(lld x) {
    if (x < 0) return -x;
    return x;
}

lld sqr(lld x) {
   return x * x;
}

lld det(const vector<vector<lld>> a) {
    return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) -
           a[1][0] * (a[0][1] * a[2][2] - a[2][1] * a[0][2]) +
           a[2][0] * (a[0][1] * a[1][2] - a[0][2] * a[1][1]);
}

pair<lld, lld> find_center(lld x1, lld y1, lld x2, lld y2, lld x3, lld y3) {
    // https://en.wikipedia.org/wiki/Circumscribed_circle#Cartesian_coordinates
    lld len1 = sqr(x1) + sqr(y1);
    lld len2 = sqr(x2) + sqr(y2);
    lld len3 = sqr(x3) + sqr(y3);    
    vector<vector<lld>> a = { {len1, y1, 1}, {len2, y2, 1}, {len3, y3, 1} };
    vector<vector<lld>> b = { {x1, len1, 1}, {x2, len2, 1}, {x3, len3, 1} };
    vector<vector<lld>> c = { {x1, y1, 1}, {x2, y2, 1}, {x3, y3, 1} };
    lld sx = 0.5 * det(a);
    lld sy = 0.5 * det(b);
    lld A = det(c);
    if (_abs(A) < 1e-9) return {0, 0};
    sx /= A;
    sy /= A;
    return {sx, sy};
}    

int main() {
    ios_base::sync_with_stdio(0);

    int n;
    cin >> n;
    vector<lld> x(n);
    vector<lld> y(n);
    
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }
    
    lld ans = -1;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n;  ++j) {
            lld xr = (x[i] + x[j]) / 2;
            lld yr = (y[i] + y[j]) / 2;
            lld res = 0;
            for (int l = 0; l < n; ++l) {
                res = max(res, sqr(xr - x[l]) + sqr(yr - y[l]));
            }
            if (ans < 0 || ans >= res) {
                ans = res;
            }
            
            for (int k = j + 1; k < n; ++k) {
                auto p = find_center(x[i], y[i], x[j], y[j], x[k], y[k]);
                lld xr = p.first;
                lld yr = p.second;
                lld res = 0;
            
                for (int l = 0; l < n; ++l) {
                      res = max(res, sqr(xr - x[l]) + sqr(yr - y[l]));
                }
                if (ans < 0 || ans >= res) {
                    ans = res;
                }
            }
        }
    }

    cout.precision(15);
    cout << sqrt(ans) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 50001;

bool isP[N];
int res[N];

int main(void){
    MEMSET(isP, true);
    rep(i, 2) isP[i] = false;
    rep(i, N) if(isP[i]) for(ll j = i; i * j < N; j ++) isP[i * j] = false;

    MEMSET(res, 0);
    rep(i, N) if(isP[i]) for(int j = i; i + j < N; j ++) if(isP[j]) res[i + j] ++;

    for(int n; cin >> n, n;){
        cout << res[n] << endl;
    }
 
    return 0;
}

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

int main()
{
	int n;
	while (cin >> n, n) {
		vector<string> s(n), res(n);
		vector<int> cnt(n);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			for (auto c : s[i]) {
				if (c == '.') {
					cnt[i]++;
				}
			}
		}
		for (int i = 1; i < n; i++) {
			if (cnt[i]) {
				s[i][cnt[i] - 1] = '+';
			}
		}
		for (int i = 1; i < n; i++) {
			if (cnt[i] < cnt[i - 1]) {
				for (int j = i - 1; cnt[j] > cnt[i]; j--) {
					s[j][cnt[i] - 1] = '|';
				}
			}
		}
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < cnt[i]; j++) {
				if (s[i][j] == '.') {
					s[i][j] = ' ';
				}
			}
		}
		for (auto ss : s) {
			cout << ss << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3656
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextLong();
		}
		long[] B = new long[N];
		B[0] = A[0];
		int p = 1;
		for (int i = 1; i < N; ++i) {
			int ok = p;
			int ng = -1;
			while (ok - ng > 1) {
				int middle = (ok + ng) / 2;
				if (B[middle] < A[i]) {
					ok = middle;
				} else {
					ng = middle;
				}
			}
			B[ok] = A[i];
			if (p == ok)
				++p;
		}
		System.out.println(p);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 60824
#include <stdio.h>
int gcd(int,int);
int main(){
  int x,y;
  scanf("%d%d",&x,&y);
  printf("%d\n",gcd(x,y));
  return 0;
}
int gcd(int x,int y){
  int i,k;
  if(x>y){
    i=x%y;
    while(i!=0){
      x = y;
      y = i;
      i = x%y;
      k = y;
    }
  }
  else if(x<y){
    i=y%x;
    while(i!=0){
      y = x;
      x = i;
      i = y%x;
      k = x;
    }
  }
  else if(x==y){
    k=x;
  }
  return k;
}
  

    

    


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

int main(){
  int n, x, count = 0;
  int i, j, k;
  
  while(1){
    cin >> n >> x;
     if(n == 0 && x == 0) break;
    for(i = 3; i <= n; i++){
      for(j = 2; j < i; j++){
        for(k = 1; k < j; k++){
          if(i + j + k == x) count++;
        }
      }
    }
    cout << count << endl;
    count = 0;
  }

  return 0;
}



Measured memory_bytes: 3100
#include"bits/stdc++.h"

using namespace std; 

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main()
{
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    

    REP(i,h){
        REP(j,w){
            if(j!=0){
               // cout << " ";
            }
            if(i<b && j<a){
                cout << 0;
            }
            if(i>=b && j<a){
                cout << 1;
            }
            if(i<b && j>=a){
                cout << 1;
            }
            if(i>=b && j>=a){
                cout << 0;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define INF (1 << 30)
#define MAX (1 << 20)

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

    int n, m, x;

    cin >> n >> m;

    string s;
    int pen[n+1];
    bool is_right[n+1];

    for(int i = 1; i <= n; i++){
        is_right[i] = false;
        pen[i] = 0;
    }

    for(int i = 0; i < m; i++){
        cin >> x >> s;
        if(s == "WA" && !is_right[x])
            pen[x]++;
        else
            is_right[x] = true;
    }

    int ans = 0, count = 0;

    for(int i = 1; i <= n; i++){
        if(is_right[i]){
            count++;
            ans += pen[i];
        }
    }

    cout << count << " " << ans << endl;

    return 0;
}

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

int main() {
    long long n, m;
    cin >> n >> m;

    long long ans = (n-1) * n;
    ans /= 2;
    long long tmp = (m-1) * m;
    tmp /= 2;
    ans += tmp;

    cout << ans;

    return 0;
}


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

using namespace std;
const int maxn = 2e5+5;
vector<int>ve[maxn];
int n;
void adg(int x,int y) {
	ve[x].push_back(y);
}
int f[maxn],ans;
void dfs(int x,int ba) {
	f[x] = 1;
	for(auto y:ve[x]) {
		if(y==ba) continue;
		dfs(y,x);
		ans = max(ans,f[x]+f[y]);
		f[x] = max(f[x],f[y]+1);
	}
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<n;i++) {
		int x,y; scanf("%d%d",&x,&y);
		adg(x,y); adg(y,x);
	}
	dfs(1,0);
	if(ans%3==2) printf("Second");
	else puts("First"); 
}


Measured memory_bytes: 23936
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define sc3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define scl2(a, b) scanf("%lld%lld", &a, &b)
#define ss(a) scanf("%s", a)
#define mem(a, b) memset(a, b, sizeof(a))
#define PII pair<int, int>
using namespace std;
int main(){
    string s;
    int n,cnt=0,ans=0;
    sc(n);
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='R')cnt++;
    }
    for(int i=0;i<cnt;i++){
        if(s[i]=='W')ans++;
    }
    cout<<ans<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int a[MAXN];
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
	read(a[i]);
    }
    int ans = 0;
    for(int i = 1 ; i <= N ; ++i) {
	if(a[a[i]] == i) ++ans;
    }
    out(ans / 2);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

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


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}



int main() {
    LL H, W;
    cin >> H >> W;
    VS S(H);
    VVI hpos(H), wpos(W);
    REP(i, H) {
        cin >> S[i];
        REP(j, W) {
            if (S[i][j] == '#') {
                hpos[i].PB(j);
                wpos[j].PB(i);
            }
        }
    }
    LL ans = LLONG_MIN;
    REP(i, H) {
        REP(j, W) {
            /*$(i);
              $(j);*/
            if (S[i][j] == '#') continue;
            LL l, r, u, d;
            r = lower_bound(ALL(hpos[i]), j) - hpos[i].begin();
            l = r - 1;
            if (l == -1) l = -1;
            else l = hpos[i][l];
            if (r == SZ(hpos[i])) r = W;
            else r = hpos[i][r];
            d = lower_bound(ALL(wpos[j]), i) - wpos[j].begin();
            u = d - 1;
            if (u == -1) u = -1;
            else u = wpos[j][u];
            if (d == SZ(wpos[j])) d = H;
            else d = wpos[j][d];
            /*$(l);
            $(r);
            $(d);
            $(u);*/
            LL count = (r - l - 1) + (d - u - 1) - 1;
            if (ans < count) ans = count;
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 70272
x=int(input())
D=[1]
for i in range(2,int(x**0.5)+1):
    if x%i==0:
        D.append(i)
for d in D:
    for i in range(1000):
        if i**5-(i-d)**5==x:
            print(i,i-d)
            exit()

Measured memory_bytes: 9260
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N;
  cin >> N;

  set<string> s;
  REP(i, N){
    string str;
    cin >> str;
    s.insert(str);
  }

  cout << s.size() << "\n";

  return 0;
}

Measured memory_bytes: 19244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n;
int a[20];

ll cnt = 0;
void dfs(int idx, ll sum) {
	if(idx == n){
		if(sum % 2 == 0)cnt++; return ;
	}
	dfs(idx + 1, sum * (a[idx] - 1));
	dfs(idx + 1, sum * (a[idx]));
	dfs(idx + 1, sum * (a[idx] + 1));

}
int main(void) {
	cin >> n;
	rep(i, n) cin >> a[i];
	dfs(0, 1);
	printf("%lld\n", cnt);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();

		System.out.println(Math.min(b / a, c));
	}
}


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


int main()
{
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    if (A == 0)
    {
        cout << 1 << endl;
    }
    if (B == 0)
    {
        cout << 2 << endl;
    }
    if (C == 0)
    {
        cout << 3 << endl;
    }
    if (D == 0)
    {
        cout << 4 << endl;
    }
    if (E == 0)
    {
        cout << 5 << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
t=0
for i in range(n):
  if A[i]<=B[i]:
    t+=A[i]
    B[i]-=A[i]
  else:
    t+=B[i]
    B[i]=0
    
  if A[i+1]<=B[i]:
    t+=A[i+1]
    A[i+1]=0
  else:
    t+=B[i]
    A[i+1]-=B[i]
    
print(t)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int H,W;
string s[2000];
bool table[2000][2000];
vector<int> solve2(vector<int> a){
	int N = a.size();
	vector<int> res;

	stack<int> st;
	st.push(-1);
	rep(i,N){
		while(st.top()!=-1 && a[st.top()]>=a[i]) st.pop();
		int j = st.top();
		res.pb(j);
		st.push(i);
	}
	return res;
}
int solve(vector<int> a){
	int N = a.size();
	vector<int> x = solve2(a);
	reverse(all(a));
	vector<int> y = solve2(a);
	reverse(all(y));
	rep(i,N) y[i] = N-1 - y[i];
	reverse(all(a));

	int res = 0;
	rep(i,N) chmax(res,a[i]*(y[i]-x[i]));
	return res;
}
int main(){
	// while(true){
	// 	int N;
	// 	cin>>N;
	// 	vector<int> a(N);
	// 	rep(i,N) cin>>a[i];
	// 	show(solve(a));
	// }
	cin>>H>>W;
	rep(i,H) cin>>s[i];
	rep(i,H) rep(j,W-1) table[i][j] = (s[i][j]==s[i][j+1]);
	int ans = max(H,W);
	vector<int> a(W-1,1);
	rep(h,H){
		if(h!=0){
			rep(i,W-1){
				if(table[h][i] == table[h-1][i]) a[i]++;
				else a[i] = 1;
			}
		}
		int tmp = solve(a);
		chmax(ans,tmp);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 8448
#[allow(dead_code)]
fn main() {
    let mut nn = i::u();
    let mut vec1=i::iv(nn);
    let mut vec2 = vec1.clone();
    let mut sum1=0;
    for xx1 in vec1 {
        sum1 += xx1;
    }
    let mut avg1 =((sum1 as f64)*1.0)/(nn as f64);
    let mut min:f64= 200.0;
    let mut minnum= 0;
    let mut num=0;
    let mut first =true;
    for xx1 in vec2 {
        let mut sa = ((xx1 as f64) -avg1).abs();
        if (min > sa||first){
            min =sa;
            minnum= num;
        }
        first=false;
        num+=1;
    }
    println!("{}",minnum);
}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2112
n=gets.to_i
a1,a2 = gets.split.map(&:to_i).each_slice(2).map{|m|m}.transpose.map{|m|m.group_by {|p|p}.map{|k,v| [v.size,k] }.sort.reverse }
a1<<[0,-1]
a2<<[0,-1]
if a1[0][1] == a2[0][1]
    p [ n-a1[1][0]-a2[0][0] , n-a1[0][0]-a2[1][0] ].min
else
    p n-a1[0][0]-a2[0][0]
end

Measured memory_bytes: 31104
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

ll n, k;

int main() {
    cin >> n >> k;
    if (k%2 == 0) {
        cout << (ll)(pow(n/k, 3LL) + pow(n/(k/2) - n/k, 3LL)) << '\n';
    } else {
        cout << (ll)pow(n/k, 3LL) << '\n';
    }

    return 0;
}


Measured memory_bytes: 384
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input! {
        n: usize,
        s: [chars; n],
    }
    let cnt = s.iter().collect::<HashSet<_>>().iter().count();
    //debug!(cnt);
    println!("{}", if cnt==4 {"Four"} else {"Three"});
}


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

int main()
{
    long long x;
    cin >> x;
    int ans = 0;
    long long a = 100;
    while(a<x)
    {
        a = a+(a/100);
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



VI g[200005];
VI ans(200005, 0);

void dfs(int a, int b) {

	for (int i : g[a]) {
		if (i == b)continue;
		ans[i] += ans[a];
		dfs(i, a);
	}

}

int main() {

	int n, q;
	cin >> n >> q;

	REP(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--, b--;

		g[a].push_back(b);
		g[b].push_back(a);
	}

	REP(i, q) {
		int p, x;
		cin >> p >> x;
		p--;
		ans[p] += x;
	}

	dfs(0, -1);


	REP(i, n) {
		cout << ans[i] << ' ';
	}

}

Measured memory_bytes: 23424
#include<iostream>
#include<cassert>

using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )
#define INF (1<<20)
#define MAX 101
main(){
  int n, m, a, b, c;
  int D[MAX][MAX], M[MAX][MAX];
  while(1){
    cin >> n >> m;

    if ( n == 0 && m == 0 ) break;
    assert( 2 <= n && n <= 100);
    rep(i, n) rep(j, n) { D[i][j] = INF; M[i][j] = 0; }
    rep(i, n) D[i][i] = 0;
    rep(i, m){
      cin >> a >> b >> c; 
      assert( 1 <= c && c <= 1000 );
      a--; b--;
      D[a][b] = D[b][a] = c;
      M[a][b] = M[b][a] = 1;
    }

    rep(k, n) rep(i, n) rep(j, n)
      D[i][j] = min(D[i][j], D[i][k] + D[k][j]);

    int ans = D[0][n-1];
    rep(k, n) rep(i, n) rep(j, n)
      if ( M[i][k] && M[k][j] ) ans = min(ans, D[0][i] + D[j][n-1] );
    
    cout << ans << endl;
  }
}

Measured memory_bytes: 1240
/* -------------------------------------------------

Author :- Vaibhav Pal
College :- Northern India Engineering College, New Delhi
Coding Handle :- underdog_eagle
Title :-

----------------------------------------------------*/
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 1000000000000000000          // 10^18
#define nl '\n'
#define sp ' '
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define fo(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)

inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
inline ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int main()
{
	FAST_IO
    /*#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
    #endif*/
	int n;
	cin >> n;
	ll prev = 2, cur = 1;
	fo(i, 1, n - 1) {
		ll temp = cur;
		cur = prev + cur;
		prev = temp;
	}
	cout << cur;
				
	return 0;
}

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

typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;

#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double epsilon = 1e-9;        // Add epsilon when casting double to int to avoid rounding pitfall issues, eg, 0.94*8178 in int
const int maxn = 1e6+10;


void solve()
{
    ll n;
    cin >> n;

    ll val[n];
    ll sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> val[i];
        sum += val[i];
    }

    ll avg1 = ceil(sum/(n*1.0));
    ll avg2 = sum/(n*1.0);

    ll ans1 = 0, ans2 = 0;

    for(int i = 0; i < n; i++)
    {
        ans1 += (avg1-val[i])*(avg1-val[i]);
        ans2 += (avg2-val[i])*(avg2-val[i]);
    }

    cout << min(ans1, ans2) << "\n";
    
}

int main()
{
    int t = 1;
    //cin >> t;
    while(t--)
        solve();

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3888
package main

import (
	"fmt"
	"regexp"
)

func main() {
	var a string

	fmt.Scan(&a)

	regSmall := regexp.MustCompile(`^[a-z]$`)
	regLarge := regexp.MustCompile(`^[A-Z]$`)

	if regSmall.MatchString(a) {
		fmt.Println("a")
	} else if regLarge.MatchString(a) {
		fmt.Println("A")
	}
}


Measured memory_bytes: 1992
# -*- coding: utf-8 -*-
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline


class RollingHash():
    """
    Original code is https://tjkendev.github.io/procon-library/python/string/rolling_hash.html
    """
    class RH():
        def __init__(self, s, base, mod):
            self.base = base
            self.mod = mod
            self.rev = pow(base, mod-2, mod)

            l = len(s)
            self.h = h = [0]*(l+1)
            tmp = 0
            for i in range(l):
                num = ord(s[i])
                tmp = (tmp*base + num) % mod
                h[i+1] = tmp

            self.pw = pw = [1]*(len(s)+1)
            v = 1
            for i in range(l):
                pw[i+1] = v = v * base % mod

        def calc(self, l, r):
            return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod

    @staticmethod
    def gen(a, b, num):
        import random
        result = set()
        while 1:
            while 1:
                v = random.randint(a, b)//2*2+1
                if v not in result:
                    break
            for x in range(3, int(math.sqrt(v))+1, 2):
                if v % x == 0:
                    break
            else:
                result.add(v)
                if len(result) == num:
                    break
        return result

    def __init__(self, s, rand=False, num=5):
        if rand:
            bases = RollingHash.gen(2, 10**3, num)
        else:
            assert num <= 10
            bases = [641, 103, 661, 293, 547, 311, 29, 457, 613, 599][:num]

        MOD = 10**9+7
        self.rhs = [self.RH(s, b, MOD) for b in bases]

    def calc(self, l, r):
        return tuple(rh.calc(l, r) for rh in self.rhs)


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo


def slv(N, S):
    srh = RollingHash(S, num=2)

    def f(m):
        h2i = defaultdict(list)
        for i in range(N-m+1):
            j = i + m
            h = srh.calc(i, j)
            h2i[h].append(i)

        for l in h2i.values():
            l0 = l[0]
            for i in range(1, len(l)):
                n = l[i] - l0
                if n >= m:
                    return 0
        return 1

    b = Bisect(f)
    return b.bisect_right(0, 1, N) - 1


def main():
    N = int(input())
    S = input()
    print(slv(N, S))



if __name__ == '__main__':
    main()


Measured memory_bytes: 48092
#include<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	ll memo=0;
	string s,t;
	cin>>s>>t;
	ll n=s.size(),m=t.size();
	string ans;
	if(n<m)puts("UNRESTORABLE");
	else {
	rep(i,n){
		if(s[i]=='?')ans[i]='a';
		else ans[i]=s[i];
	}
	for(int i=n-m;i>=0;i--){
		for(int j=i;j<i+m;j++){
			if(s[j]==t[j-i]||s[j]=='?')memo++;
		}
		if(memo==m){
			for(int k=i;k<i+m;k++){
				ans[k]=t[k-i];
			}
			break;
		}
		memo=0;
	}
	if(memo==0)puts("UNRESTORABLE");
	else rep(i,n)cout<<ans[i];
	} 
	ggr
}



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

int main() {

	int n, m, x;
	int up = 0;
	int down = 0;
	scanf("%d %d %d", &n, &m, &x);
	vector<bool> v(n + 1);
	for(int i = 0; i < n; i++) {
		v[i] = false;
	}
	for(int i = 0; i < m; i++) {
		int a;
		scanf("%d", &a);
		v[a] = true;
	}
    int i = x;
	while(i != 0) {
		if(v[i] == true) {
			up++;
		}
		i--;
	}
	int j = x;
	while(j != n) {
		if(v[j] == true) {
			down++;
		}
		j++;
	}
	int ans = min(up, down);
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t,ans;
int dp[3001][3001];
int calcLCS(int i, int j){
    if(dp[i][j]!=-1) return dp[i][j];
    if(s[i]=='\0' || t[j]=='\0') return 0;
    if(s[i]==t[j]){
        dp[i][j]=1+calcLCS(i+1,j+1);
        return dp[i][j];
    }
    dp[i][j]=max(calcLCS(i+1,j),calcLCS(i,j+1));
    return dp[i][j];
}
void printLCS(int i,int j){
    if(s[i]=='\0' || t[j]=='\0'){
        cout<<ans<<'\n';
        return;
    }
    if(s[i]==t[j]){
        ans+=s[i];
        printLCS(i+1,j+1);
    } else{
        if(dp[i+1][j]>dp[i][j+1]) printLCS(i+1,j);
        else printLCS(i,j+1);
    }
}
int main(){
    memset(dp,-1,sizeof(dp));
    cin >> s >> t;
    calcLCS(0,0);
    printLCS(0,0);
    // while(1);
    return 0;
}

Measured memory_bytes: 35840
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <vector>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const ll INFll=0x3f3f3f3f3f3f3f3fll;

int ans[100005];
int n;
char s[100005];
int main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    s[0] = s[n];
    s[n+1] = s[1];
    char sw[3];
    sw[1] = 0;
    sw[1] = 'S';
    sw[2] = 'W';

    for(int k = 0;k<4;k++){
        memset(ans,0,sizeof(ans));
        ans[0] = (k/2)+1; ans[n] = (k/2)+1;
        ans[1] = (k%2)+1;ans[n+1] = (k%2)+1;
        bool f = true;
        for(int i = 1;i<=n;i++){
            if(ans[i]==1){
                if(s[i]=='o'){
                    if(ans[i-1]!=0&&ans[i+1]!=0){
                        if(ans[i-1]!=ans[i+1]){
                            f = false;break;
                        }
                    }
                    else if(ans[i-1]!=0&&ans[i+1]==0){
                        ans[i+1] = ans[i-1];
                    }
                    else if(ans[i-1]==0&&ans[i+1]!=0){
                        ans[i-1] = ans[i+1];
                    }
                }
                if(s[i]=='x'){
                    if(ans[i-1]!=0&&ans[i+1]!=0){
                        if(ans[i-1]==ans[i+1]){
                            f = false;break;
                        }
                    }
                    else if(ans[i-1]!=0&&ans[i+1]==0){
                        if(ans[i-1]==1) ans[i+1]=2;
                        if(ans[i-1]==2) ans[i+1]=1;
                    }
                    else if(ans[i-1]==0&&ans[i+1]!=0){
                        if(ans[i+1]==1) ans[i-1]=2;
                        if(ans[i+1]==2) ans[i-1]=1;
                    }
                }
            }
            if(ans[i]==2){
                if(s[i]=='o'){
                    if(ans[i-1]!=0&&ans[i+1]!=0){
                        if(ans[i-1]==ans[i+1]){
                            f = false;break;
                        }
                    }
                    else if(ans[i-1]!=0&&ans[i+1]==0){
                        if(ans[i-1]==1) ans[i+1]=2;
                        if(ans[i-1]==2) ans[i+1]=1;
                    }
                    else if(ans[i-1]==0&&ans[i+1]!=0){
                        if(ans[i+1]==1) ans[i-1]=2;
                        if(ans[i+1]==2) ans[i-1]=1;
                    }
                }
                if(s[i]=='x'){
                    if(ans[i-1]!=0&&ans[i+1]!=0){
                        if(ans[i-1]!=ans[i+1]){
                            f = false;break;
                        }
                    }
                    else if(ans[i-1]!=0&&ans[i+1]==0){
                        ans[i+1] = ans[i-1];
                    }
                    else if(ans[i-1]==0&&ans[i+1]!=0){
                        ans[i-1] = ans[i+1];
                    }
                }
            }
        }
        if(f){
            for(int i = 1;i<=n;i++){
                printf("%c",sw[ans[i]]);
            }
            printf("\n");
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	int h, w;
	char str[100][101];
	int ans[100][100];
	cin >> h >> w;
	REP(i, h) cin >> str[i];

	memset(ans, -1, sizeof(ans));
	REP(i, h) {
		REP(j, w) {
			if (str[i][j] == 'c') ans[i][j] = 0;
			else if (j >= 1 && ans[i][j-1] != -1) ans[i][j] = ans[i][j-1] + 1;
		}
	}

	REP(i, h) {
		REP(j, w) {
			printf("%d", ans[i][j]);
			if (j != w - 1) putchar(' ');
			else putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 1204