akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x;
	string s;
	cin>>x>>s;
	ll val=100*(s[0]-'0')+10*(s[2]-'0')+s[3]-'0';
	x*=val;
	x/=100;
	cout<<x<<'\n';
	return 0;
}

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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		vector<pii> data;
		data.clear();
		for(int i =0;i <n;i++){
			int v,w;
			cin>>v>>w;
			data.push_back(pii(w,-v));
		}
		sort(data.begin(),data.end());
		int sum =0;
		bool flag =true;
		for(int i =0;i <data.size();i++){
			sum +=(-data[i].second);
			if(sum>data[i].first){
				cout<<"No"<<endl;
				flag =false;
				break;
			}
		}
		if(flag)cout<<"Yes"<<endl;
	}
	return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

long long inv(long long x){
  long long m = mod, u = 1, v = 0;
  while(m){
    long long t = x / m;
    x -= t * m; swap(x, m);
    u -= t * v; swap(u, v);
  }
  u %= mod;
  if(u < 0) u += mod;
  return u;
}

long long power(long long a, long long e){
  if(e == 0) return 1ll;
  if(e & 1){
    return power(a, e - 1) * a % mod;
  }
  long long re = power(a, e >> 1);
  return re * re % mod;
}

int main(){
  int n, k;
  cin >> n >> k;
  
  long long fac[n + 2];
  fac[0] = 1;
  for(int i = 1; i <= n + 1; i++) fac[i] = fac[i - 1] * i % mod;
  
  long long pattern = 1;
  for(int i = 1; i <= min(k, n - 1); i++){
    pattern += fac[n] * inv(fac[i] * fac[n - i]) % mod * fac[n - 1] % mod * inv(fac[n - i - 1] * fac[i]) % mod;
    pattern %= mod;
  }
  
  cout << pattern << endl;
  
  return 0;
}

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

int main() {
    string S;
    cin >> S;

    string ans = "";

    rep(i,5){
        ans += "hi";
        if(ans==S){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,j,n,k,min,max;

  scanf("%d %d",&n,&k);
  int a[n];
  scanf("%d",&a[0]);
  min=a[0];
  max=a[0];
  for(i=1;i<n;i++){
    scanf(" %d",&a[i]);
    if(min>a[i]) min=a[i];
    if(max<a[i]) max=a[i];
  }
  if(max<k){
    printf("IMPOSSIBLE");
    return 0;
  }
  if(min==1){
    printf("POSSIBLE");
    return 0;
  }

  for(i=min;i>=1;i--){
    for(j=0;j<n;j++){
      if(a[j]%i!=0) break;
    }
    if(j==n){
      if(k%i==0){
        printf("POSSIBLE");
        return 0;
      } else{
        printf("IMPOSSIBLE");
        return 0;
      }
    }
  }
  //printf("IMPOSSIBLE");
  return 0;
}


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

int n;

void dfs(int max_c, string s)
{
    if(s.size() == n)
    {
        cout << s << endl;
        return;
    }
    rep(i, max_c)
    {
        dfs(max_c, s + (char)('a' + i));
    }
    dfs(max_c + 1, s + (char)('a' + max_c));
    return;
}

int main()
{
    cin >> n;
    dfs(1, "a");

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, m;
	string s;
	cin >> n >> m >> s;
	vector<int> p;
	rep(i, n + 1) if (s[i] == '0') p.push_back(i);
	vector<int> ans;
	int now = n;
	while (now) {
		auto itr = lower_bound(all(p), now - m);
		if (itr == p.end()) {
			cout << -1 << endl;
			return 0;
		}
		if (*itr >= now) {
			cout << -1 << endl;
			return 0;
		}
		ans.push_back(now - *itr);
		now = *itr;
	}
	int N = ans.size();
	for (int i = N - 1; i >= 0; i--) {
		if (i < N - 1) cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
  char c; cin >> c;
  if(c=='z') {
    cout << "a" << endl;
    return 0;
  }
  cout << (char)(c + 1) << endl;
}


Measured memory_bytes: 256
a = []
for i in range(3):
    a.append(list(map(int, input().split())))

n = int(input())
b = []

for i in range(n):
    b.append(int(input()))

# print(a, b)

def isBingo():
    # Horizontal bingo
    for i in range(3):
        if all(a[i][j] is None for j in range(3)):
            return True

    # Vertical bingo
    for i in range(3):
        if all(a[j][i] is None for j in range(3)):
            return True

    # Diagonal bingo
    if a[0][0] is None and a[1][1] is None and a[2][2] is None:
        return True
    if a[0][2] is None and a[1][1] is None and a[2][0] is None:
        return True

    return False

for x in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[x]:
                a[i][j] = None

if isBingo():
    print('Yes')
else:
    print('No')



Measured memory_bytes: 38384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, L, sum = 0; cin >> N >> L;
    for (int i = 1; i <= N; ++i) sum += L + i - 1;
    int tmp = 10e9 + 1, ans = 0;
    for (int i = 1; i <= N; ++i) {
        int x = sum - (L + i - 1);
        if (tmp >= abs(sum - x)) tmp = abs(sum - x), ans = i;
    }
    sum = 0;
    for (int i = 1; i <= N; ++i) {
        if (ans == i) continue;
        sum += L + i - 1;
    }
    printf("%d\n", sum);
}


Measured memory_bytes: 3752
#include <iostream>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
int N,K; 
vector<int> numbers{0,1,2,3,4,5,6,7,8,9};
queue<int> q;
void serch(){
  
    for(int i=0;i<numbers.size();i++)q.push(numbers.at(i)); 
    while(q.front()<N){
        for(int i=0;i<numbers.size();i++){
          q.push(q.front()*10+numbers.at(i)); 
        }
        q.pop();
    }
    cout<<q.front()<<endl;
    return;
}



int main(){
    cin>>N>>K;
    for(int i=0;i<K;i++){
        int k;
        cin>>k;
        for (auto it = numbers.begin(); it != numbers.end();) {
            // 条件一致した要素を削除する
            if (*it == k) {
            // 削除された要素の次を指すイテレータが返される。
             it = numbers.erase(it);
             }
            // 要素削除をしない場合に、イテレータを進める
            else {
                ++it;
             }
  }
    }
    //for(int i=0;i<numbers.size();i++)cout<<numbers.at(i)<<endl;
    serch();
}

Measured memory_bytes: 512
[W,H,N] = list(map(int,input().split()))
minx = 0
maxx = W
miny = 0
maxy = H
for i in range(N):
    [x,y,a] = list(map(int,input().split()))
    if a == 1:
        minx = max(minx,x)
    elif a == 2:
        maxx = min(maxx,x)
    elif a == 3:
        miny = max(miny,y)
    else:
        maxy = min(maxy,y)
print(max(0,maxx-minx)*max(0,maxy-miny))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int INF=(int) 0x3f3f3f3f;
const LL  LINF=(LL) INF<<32|INF;
const int maxn=1e2+20;
struct Dinic{
    struct E{
        int from,to;LL cap,flow;
        E(){}
        E(int _from,int _to,LL _cap,LL _flow):from(_from),to(_to),cap(_cap),flow(_flow) {}
    };
    int n,m,s,t;
    vector<E> edge;
    vector<int> G[maxn];
    bool vis[maxn];
    int d[maxn],cur[maxn];

    void init(int _n,int _s,int _t){
        n=_n; s=_s; t=_t;
        m=0;
        for(int i=0;i<=n;i++) G[i].clear();
        edge.clear();
    }

    void add(int from,int to,LL cap){
        edge.push_back(E(from,to,cap,0));G[from].push_back(m++);
        edge.push_back(E(to,from,0,0));G[to].push_back(m++);
    }

    queue<int> Q;
    bool BFS(){
        for (int i=0;i<=n;i++) vis[i]=false;
        while (!Q.empty())Q.pop();
        Q.push(s);d[s]=0;vis[s]=1;
        while(!Q.empty()){
            int x=Q.front(); Q.pop();
            for(int i=0,siz=G[x].size();i<siz;i++){
                E &e=edge[G[x][i]];
                if(!vis[e.to] && e.cap>e.flow){
                    vis[e.to]=1;
                    d[e.to]=d[x]+1;
                    Q.push(e.to);
                }
            }
        }
        return vis[t];
    }

    LL DFS(int x,LL a){
        if(x==t || a==0) return a;
        LL flow=0, f;
        for(int &i=cur[x],siz=G[x].size();i<siz;i++){
            E &e=edge[G[x][i]];
            if(d[x]+1==d[e.to] && (f = DFS(e.to,min(a,e.cap-e.flow)))>0){
                e.flow+=f;
                edge[G[x][i]^1].flow-=f;
                flow+=f;
                a-=f;
                if(a==0) break;
            }
        }
        return flow;
    }

    LL mf(){
        LL res=0;
        while(BFS()){
            for (int i=0;i<=n;i++) cur[i]=0;
            res+=DFS(s,LINF);
        }
        return res;
    }
}MF;
int main(){
    #ifdef VGel
    freopen("E.in","r",stdin);
    #endif // VGel
    int n,x;
    while (~scanf("%d",&n)){
        MF.init(n+2,0,n+1);
        LL ans=0;
        for (int i=1;i<=n;i++){
            scanf("%d",&x);
            if(x<0) MF.add(0,i,-x);else MF.add(i,n+1,x),ans+=x;
            for (int j=i+i;j<=n;j+=i) MF.add(i,j,INF);
        }
        printf("%lld\n",ans-MF.mf());
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();		//たこ焼きの数
		
		int[]o=new int[n];
		int ans=0;
		
		for(int i=0;i<n;i++) {
			o[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				ans+=o[i]*o[j];
			}
		}
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int n,k;
vector<int>a,f;
bool isOK(int mid){
    int cnt=0;
    for (int i = 0; i < n; i++)
    {
        if(a[i]*f[i]<=mid) continue;
        cnt+=a[i]-mid/f[i];
    }
    if(cnt<=k) return true;
    else return false;
    
}

signed main(){
   
    cin>>n>>k;
    a.resize(n);
    f.resize(n);
    REP(i,n) cin>>a[i];
    REP(i,n) cin>>f[i];
    //sort(a.rbegin(),a.rend());
    int index=0;
    
    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());
    int left=-1,right=1e12;

    while(abs(left-right)>1){
        int mid =(left+right)/2;
        if(isOK(mid)) right=mid;
        else left=mid;
      //  cerr<<left<<" "<<right<<endl;
    }
    cout<<right<<endl;

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>
#include <iomanip>
 
using namespace std;
 
int main(){
 
  int a, b, ans;
  cin >> a >> b;
 
  int x, xa_max, xa_min, xb_max, xb_min;
  xa_min = int(a/0.08+0.5); xa_max = int((a+1)/0.08+0.5);
  xb_min = b/0.1; xb_max = (b+1)/0.1;
 
  //  cout << xa_min <<" "<<xa_max << " " << endl;
  //  cout << xb_min <<" "<<xb_max << " " << endl;
 
  if(xa_min <= xb_min && xb_min < xa_max) {
    cout << xb_min;
  } else if (xb_min <= xa_min && xa_min < xb_max){
    cout << xa_min;
  } else {
    cout << -1;
  }
}

Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

def main():
    N = gete(int)

    cur, prev = [0]*3, [0]*3

    for _ in range(N):
        a, b, c = geta(int)
        prev, cur = cur, prev
        cur[0] = max(prev[1], prev[2]) + a
        cur[1] = max(prev[2], prev[0]) + b
        cur[2] = max(prev[0], prev[1]) + c


    print(max(cur))

if __name__ == "__main__":
    main()

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

struct LazySegTree {
  vector<ll> seg, lazy;
  int size;
  LazySegTree() {}
  LazySegTree(int n) {
    init(n);
  }
  void init(int n) {
    size = 1;
    while (size < n) size *= 2;
    seg.resize(size * 2);
    lazy.resize(size * 2);
    for(int i = 0; i < size*2; i++)seg[i]=-INF;
  }
  void update(int k,ll v){
    k += size-1;
    seg[k] = v;
    while(k > 0){
      k = (k - 1)/2;
      seg[k] = max(seg[k * 2 + 1], seg[k * 2 + 2]);
    }
  }
  void push(int k, int l, int r) {
    seg[k] += lazy[k];
    if (r - l > 1) {
      lazy[k * 2 + 1] += lazy[k];
      lazy[k * 2 + 2] += lazy[k];
    }
    lazy[k] = 0;
  }
  void add(int a, int b, ll v, int k, int l, int r) {
    push(k, l, r);
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      lazy[k] += v;
      push(k, l, r);
    } else {
      add(a, b, v, k * 2 + 1, l, (l + r) / 2);
      add(a, b, v, k * 2 + 2, (l + r) / 2, r);
      seg[k] = max(seg[k * 2 + 1], seg[k * 2 + 2]);
    }
  }
  void add(int a, int b, ll v) {
    add(a, b, v, 0, 0, size);
  }
  ll query(int a, int b, int k, int l, int r) {
    push(k, l, r);
    if (r <= a || b <= l) return -INF*100; // caution
    if (a <= l && r <= b) return seg[k];
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return max(vl,vr);
  }
  ll query(int a, int b) {
    return query(a, b, 0, 0, size);
  }
};

ll n,m;
ll l[200010],r[200010],a[200010];
vector<ll> ls[200010];
vector<P> rs[200010];
ll dp[200010];

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

  cin>>n>>m;
  rep(i,m){
    cin>>l[i]>>r[i]>>a[i];
    r[i]++;
    ls[l[i]].push_back(a[i]);
    rs[r[i]].push_back(P(l[i],a[i]));
  }
  LazySegTree sgt(n+2);
  rep(i,n+2)sgt.update(i,0);

  repl(i,1,n+2){
    for(ll v : ls[i]){
      sgt.add(0,i,v);
    }
    for(P p : rs[i]){
      sgt.add(0,p.fi,-p.se);
    }
    dp[i]=sgt.query(0,i);
    sgt.add(i,i+1,dp[i]);
  }
  cout<<dp[n+1]<<endl;

  return 0;
}


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

int main(){
    string w;
    cin >> w;
    bool ans = true;
    for(char i: w){
        int cnt = 0;
        for(char jj: w){
            if(i == jj) cnt++;
        }
        if(cnt %2) ans = false;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}   

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static PrintWriter writer = new PrintWriter(System.out);
  static int N;
  static char[] query;
  static boolean[][] graph;
  static UnionFind uf;
  static int count = 0;

  public static void main(String[] args) {
    N = sc.nextInt();
    query = new char[N];
    Arrays.fill(query, '0');
    graph = new boolean[N][N];
    uf = new UnionFind(N);
    for (int i = 0; i < N; i++) {
      solve(i);
    }
    writer.print("!");
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        if (graph[i][j]) writer.print(" (" + i + "," + j + ")");
      }
    }
    writer.println();
    writer.flush();
  }

  static void solve(int axis) {
    final int BUCKET = 10;
    ArrayList<Integer> pos = new ArrayList<>();
    for (int i = axis + 1; i < N; i++) {
      if (uf.find(axis, i)) continue;
      pos.add(i);
      if (pos.size() == BUCKET) {
        solveSub(axis, pos);
        pos.clear();
      }
    }
    if (!pos.isEmpty()) {
      solveSub(axis, pos);
    }
  }

  static int solveSub(int axis, ArrayList<Integer> pos) {
    if (count == N - 1) return 0;
    pos.add(axis);
    int v = query(pos);
    pos.remove(pos.size() - 1);
    if (v == 0) return v;
    if (pos.size() == 1 && v == 1) {
      graph[axis][pos.get(0)] = graph[pos.get(0)][axis] = true;
      uf.union(axis, pos.get(0));
      ++count;
    }
    if (pos.size() == 1) return v;
    ArrayList<Integer> subPos = new ArrayList<>();
    for (int i = 0; i < pos.size() / 2; i++) {
      subPos.add(pos.get(i));
    }
    int sv = solveSub(axis, subPos);
    if (sv == v) return v;
    subPos.clear();
    for (int i = pos.size() / 2; i < pos.size(); i++) {
      subPos.add(pos.get(i));
    }
    solveSub(axis, subPos);
    return v;
  }

  static int query(ArrayList<Integer> pos) {
    for (int p : pos) {
      query[p] = '1';
    }
    writer.write("? " + String.valueOf(query) + "\n");
    writer.flush();
    for (int p : pos) {
      query[p] = '0';
    }
    return sc.nextInt();
  }

  static class UnionFind {
    int[] set;

    UnionFind(int n) {
      set = new int[n];
      Arrays.fill(set, -1);
    }

    void union(int a, int b) {
      int rtA = root(a);
      int rtb = root(b);
      if (rtA == rtb) {
        return;
      }
      set[rtA] += set[rtb];
      set[rtb] = rtA;
    }

    boolean find(int a, int b) {
      return root(a) == root(b);
    }

    int root(int a) {
      if (set[a] < 0) {
        return a;
      } else {
        set[a] = root(set[a]);
        return set[a];
      }
    }

    int size(int a) {
      return -set[root(a)];
    }
  }

}




Measured memory_bytes: 49576
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;
const string YES = "YES";
const string NO = "NO";


void solve();

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

void solve(){
    string s1,s2;cin>>s1>>s2;
    reverse(all(s2));
    cout<<(s1==s2?YES:NO)<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

ans = "APPROVED"
for a in A:
  if a % 2 == 0:
    if a % 3 == 0 or a % 5 == 0:
      pass
    else:
      ans = "DENIED"
      break
print(ans)

Measured memory_bytes: 61804
#include <atcoder/maxflow>
#include <iostream>
#include <string>

using namespace std;
using namespace atcoder;

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> grid(n);
    for(int i = 0; i < n; ++i) cin >> grid[i];

    mf_graph<int> g(n * m + 2);
    int s = n * m, t = n * m + 1;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j) {
            if(grid[i][j] == '#') continue;
            int v = i * m + j;
            if((i + j) % 2 == 0) g.add_edge(s, v, 1);
            else g.add_edge(v, t, 1);
            if(j+1 < m && grid[i][j+1] == '.') {
                int from = v;
                int to = v + 1;
                if((i+j) % 2 == 1) swap(from, to);
                g.add_edge(from, to, 1);
            }
            if(i+1 < n && grid[i+1][j] == '.') {
                int from = v;
                int to = v + m;
                if((i+j) % 2 == 1) swap(from, to);
                g.add_edge(from, to, 1);
            }
        }
    }
    cout << g.flow(s, t) << endl;
    vector<mf_graph<int>::edge> ve = g.edges();
    for(auto& e : ve) {
        if(e.from == s || e.to == t || e.flow == 0) continue;
        int j0 = e.from % m;
        int i0 = (e.from - j0) / m;
        int j1 = e.to % m;
        int i1 = (e.to - j1) / m;
        if(i0 == i1) {
            if(j1 < j0) swap(j1, j0);
            grid[i0][j0] = '>';
            grid[i1][j1] = '<';
        }
        else if(j0 == j1) {
            if(i1 < i0) swap(i1, i0);
            grid[i0][j0] = 'v';
            grid[i1][j1] = '^';
        }
    }
    for(auto& _g : grid) cout << _g << endl;
}

Measured memory_bytes: 5504
#include <stdio.h>
int main(){
    int a=0,b=0,c=0;
    int i=0;
    char s[101];
    scanf("%s",s);
    for(i=0; s[i]!=0; i++);

    int n=1;
    i--;
    for(; s[i]!='/'; i--){c+=(s[i]-48)*n;n*=10;}
    i--;n=1;
    for(; s[i]!='/'; i--){b+=(s[i]-48)*n;n*=10;}
    i--;n=1;
    for(; i>=0; i--){a+=(s[i]-48)*n;n*=10;}

    int heisei=1;
    if(a>2019||(a==2019&&b>4))heisei=0;
    if(heisei)printf("Heisei");
    else printf("TBD");
    return 0;
}


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

const long MAX = 100001;

long nCr(int n, int r)
{
    if(n < r){
        return 0;
    }else{
        long a = 1, b = 1;
        for(int i = n; i >= n - r + 1; i--){
            a *= i;
        }
        for(int i = r; i >= 1; i--){
            b *= i;
        }
    return a / b;
    }
}

int main()
{
    long N;
    string s[MAX];
    cin >> N;
    for(long i = 0; i < N; i++){
        cin >> s[i];
    }
    for(long i = 0; i < N; i++){
        sort(s[i].begin(), s[i].end());
    }   
    sort(s, s + N);

    int cnt = 1;
    long ans = 0;
    for(long i = 0; i < N; i++){
        if(s[i] == s[i + 1]){
            cnt++;
        }else{
            ans += nCr(cnt, 2);
            cnt = 1;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
import java.util.*;
import java.util.stream.*;

class Main{
	public static void main(String[] args) {
		List<Integer> primes = new ArrayList<>(1<<15);
		LABEL: for(int i = 2; i < 55555; i++) {
			for(int prime : primes) {
				if(prime*prime>i) break;
				if(i%prime==0) continue LABEL;
			}
			primes.add(i);
		}

		Scanner scan = new Scanner(System.in);
		int input = scan.nextInt();

		String ans = primes.stream()
			.filter(num -> num%5==1)
			.limit(input)
			.map(num->num.toString())
			.collect(Collectors.joining(" "));
		System.out.println(ans);
	}
}


Measured memory_bytes: 30136
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
l = [None] * m
li = [None] * m
for i in range(m):
    l[i] = list(map(int, input().split()))
    li[i] = list(map(int, input().split()))
dp = [[float('inf')] * (2 ** n) for _ in range(m + 1)]
dp[0][0] = 0
for i in range(m):
    for j in range(2 ** n):
        if dp[i][j] == float('inf'):
            continue
        tmp = j
        for x in li[i]:
            tmp |= 2 ** (x - 1)
        dp[i + 1][tmp] = min(dp[i + 1][j | tmp], dp[i][j] + l[i][0])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
res = dp[m][2 ** n - 1]
if res == float('inf'):
    print(-1)
else:
    print(res)


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

int main() {
  int N, K, H[200001];
  long long sum = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) 
    cin >> H[i];
  if (K >= N) {
    cout << 0 << '\n';
    return 0;
  }
  sort(H, H+N);
  for (int i = 0; i < N-K; i++) 
    sum += H[i];
  cout << sum << '\n';
}


Measured memory_bytes: 1024
#include<algorithm>
#include<cstdio>
using namespace std;

int n, k;
int a[200000], b[200001];

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        int p;
        scanf("%d", &p);
        a[i] = p + 1; 
    }
    for (int i = 1; i <= n; i++) b[i] = b[i - 1] + a[i - 1];
    int ans = 0;
    for (int i = k; i <= n; i++) ans = max(ans, b[i] - b[i - k]); 
    printf("%.10lf\n", static_cast<double>(ans) / 2);
    return 0;
}


Measured memory_bytes: 1792
input()
s = input()

def find_cost(s):
    counter, i, j = 0, 0, len(s)-1
    while i < j:
        while i < len(s) and s[i] != 'W':
                i += 1
        while j >= 0 and s[j] != 'R':
                j -= 1
        if i < j:
            s[i], s[j] = s[j], s[i]
            counter += 1
        i += 1
        j -= 1
    for i in range(0, len(s) - 2):
        if s[i] == 'W' and s[i + 1] == 'R':
            counter += 1
    print(counter)
 
s = list(s)
find_cost(s)

Measured memory_bytes: 10564
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <sstream>
#include <cmath>
#include <cstdio>

using namespace std;

string s;

signed main() {
    while (true) {
        int n, m;
        cin >> n;
        if (n == 0)
            return 0;
        cin >> m >> s;
        string target = "I";
        for (int i = 0; i < n; ++i) {
            target += "OI";
        }

        int end = m - n;
        int result = 0;
        for (int i = 0; i < end; ++i) {
            string temp = s.substr(i, target.length());
            if (temp == target) {
                result++;
            }
        }

        cout << result << endl;
    }
}

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

using namespace std;
int main(){
    int n,c;
    bool ans=false;
    cin>>n;
    int A[100],B[100];
    for(int i=0;i<n;i++) cin>>A[i];
    for(int i=0;i<n-1;i++){
        for(int j=i;j<n;j++){
            c=0;
            for(int k=0;k<n;k++) B[k]=A[k];
            swap(B[i],B[j]);
            for(int k=0;k<n-1;k++){
                if(B[k]>B[k+1]) c++;
            }
            if(c==0){
                ans=true;
                break;
            }
        }
    }
    if(ans) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    set<char> S;
    map<char,char> m;
    string s;
    string t;
    cin>>s>>t;
    rep(i,s.size()){
        if(m.find(s[i])==m.end()&&S.count(t[i])==1){
            fin("No");
            // cout<<i<<" "<<1<<endl;
            return 0;
        }
        if(m.find(s[i])!=m.end()&&m[s[i]]!=t[i]){
            fin("No");
            // cout<<i<<" "<<2<<endl;
            return 0;
        }
        m[s[i]]=t[i];
        S.insert(t[i]);
    }
    fin("Yes");
}

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

void solve () {
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 1000; i++) {
        int f = i * 8 / 100;
        int s = i * 10 / 100;
        if (f == a && b == s) {
            cout << i;
            return;
        }
    }
    cout << -1;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	
	SP;
	cout << (double) (w * h) / 2 << " ";
	
	if (2 * x == w and 2 * y == h) {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 380
#include <iostream>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int a,b;	cin >> a >> b;
    if(a == 1){
	if(b == 1)  cout << "Draw" << endl;
	else	    cout << "Alice" << endl;
    }else{
	if(b == 1)  cout << "Bob"   << endl;
	else if(a > b)	cout << "Alice" << endl;
	else if(a < b)	cout << "Bob"	<< endl;
	else		cout << "Draw"	<< endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



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;
}



int main() {
	string S;
	int i, j, k;
	//ll N, M, K;
	int N, M, K;
	int A[200000];
	cin >> N;
	map<int, int> L, R;

	rep(i, 0, N) {
		cin >> A[i];
		L[A[i] + i] += 1;
		R[i - A[i]] += 1;
	}
	ll ans = 0;

	for (pair<int, int> x : L) {
		ans += (ll)x.second * (ll)R[x.first];


	}



	cout << ans;
	return 0;

}


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

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

	char a,b;
	int i,j;
	int tmp;
	int answer;
	int counter=0;
	double ave;
	vector<int> given;

	cin >> a >> b;
	
	if(a<b){
		for(i=0;i<b-'0';i++){
			cout << a;
		}
	}else{
		for(i=0;i<a-'0';i++){
			cout << b;
		}
	}
	
	cout << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 3005;
int dp[N][N];
pair<int, int> cameFrom[N][N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	string s, t;
	cin >> s >> t;
	s = "#" + s;
	t = "#" + t;
	int n = s.length() - 1;
	int m = t.length() - 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(s[i] == t[j]) {
				dp[i][j] = dp[i-1][j-1] + 1;
				cameFrom[i][j] = {i-1, j-1};
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);			
				if(dp[i][j] == dp[i-1][j])
					cameFrom[i][j] = {i-1, j};
				else
					cameFrom[i][j] = {i, j-1};
			}
		}
	}
	
	string ans = "";
	pair<int, int> cur = {n, m};
	while(n >= 1 && m >= 1) {
		cur = cameFrom[n][m];
		if(cur.first == n-1 && cur.second == m-1) {
			ans += s[n]; 
		}
		n = cur.first;
		m = cur.second;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 105984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;


int main(){
  int n;
  cin >> n;
  ll lis[60];
  fill(lis, lis + 60, 0);
  for(int i = 0; i < n; i++){
    ll a;
    cin >> a;
    ll p = 1;
    for(int j = 0; j < 60; j++){
      if(a & p) lis[j]++;
      p <<= 1;
    }
  }
  
  ll ans = 0;
  ll p = 1;
  for(int i = 0; i < 60; i++){
    ll tmp = lis[i] * (n - lis[i]) % MOD;
    ans += p * tmp % MOD;
    ans = ans % MOD;
    p = p * 2 % MOD;
  }
  cout << ans <<endl;
}

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

void fnSelectionSort(vector<int> &rvnSort, int &rnSortCnt)
{
  for (int nSorting = 0; nSorting < rvnSort.size() - 1; nSorting++)
  {
    int nMin = nSorting;
    bool bSorting = false;

    for (int j = nSorting + 1; j < rvnSort.size(); j++)
    {
      if (rvnSort[j] < rvnSort[nMin])
      {
        nMin = j;
        bSorting = true;
      }
    }
    if (bSorting)
    {
      swap(rvnSort[nSorting], rvnSort[nMin]);
      rnSortCnt++;
    }
  }
}

void fnOutput(const vector<int> &cnrvnSort, int nSortCnt)
{
  for (int i = 0; i < cnrvnSort.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvnSort[i];
  }
  cout << endl;
  cout << nSortCnt << endl;
}

int main()
{ 
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int nSortCnt = 0;
  vector<int> vnSort;
  int nMaxSiz;
  
  cin >> nMaxSiz;
  for (int i = 0; i < nMaxSiz; i++)
  {
    int nNum;
    cin >> nNum;
    vnSort.push_back(nNum);
  }

  fnSelectionSort(vnSort, nSortCnt);
  fnOutput(vnSort, nSortCnt);

  return 0;
}

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

typedef long long ll;

ll H, W, N;
ll X, Y;
vector<vector<ll>> R;

int main() {
  cin >> H >> W >> N;
  R.resize(H);
  for (auto &r : R) r.resize(W);
  for (ll c = 0; c < N; ++c) {
    ll a;
    cin >> a;
    for (ll k = 0; k < a; ++k) {
      R[Y][X] = c;
      if (Y % 2 == 0) {
        if (X < W - 1)
          ++X;
        else
          ++Y;
      } else {
        if (X > 0)
          --X;
        else
          ++Y;
      }
    }
  }
  for (ll y = 0; y < H; ++y) {
    for (ll x = 0; x < W; ++x) cout << (x == 0 ? "" : " ") << R[y][x] + 1;
    cout << endl;
  }
  return 0;
}


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


int main(void) {
    string S,T;cin>>S>>T;
    if (S.size() < T.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    int SN = S.size();
    int TN = T.size();
    int last_index = -1;
    for (int i = 0; i < SN - TN + 1; i++) {
        bool hit = true;
        for (int j = i; j < i + TN; j++) {
            if (S[j] != T[j - i] && S[j] != '?') {
                // printf("i=%d,j=%d,S=%c,T=%c\n", i, j,S[j], T[j - i]);
                hit = false;
                break;
            }
        }
        if (hit) last_index = i;
    }
    if (last_index == -1) {
        cout << "UNRESTORABLE" << endl;
    } else {
        for (int i = 0; i < SN; i++) {
            char s = S[i];
            if (s != '?') printf("%c", s);
            else {
                if (last_index <= i && i < last_index + TN) printf("%c", T[i - last_index]);
                else cout << 'a';
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = input().split()
l1 = []
for i in range(int(n[1])):
    l1.append(input().split())

for i in range(int(n[1])):
    for j in range(2):
        l1[i][j] = int(l1[i][j])


m = 0
for k in l1:
    k.append(m)
    m += 1


l3 = sorted(l1)


l3[0][1] = 1
for i in range(1,len(l3)):
    if l3[i][0]==l3[i-1][0]:
        l3[i][1]=l3[i-1][1]+1
    else:
        l3[i][1]=1

for i in range(len(l3)):
    l3[i][2],l3[i][0]=l3[i][0],l3[i][2]
for i in range(len(l3)):
    l3[i][1],l3[i][2]=l3[i][2],l3[i][1]
l3.sort()


for i in range(int(n[1])):
    for j in range(2):
        l3[i][j] = str(l3[i][j])

for i in range(len(l3)):
    print(str(l3[i][1]).zfill(6)+str(l3[i][2]).zfill(6))

Measured memory_bytes: 47268
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	if(a > b){
		cout << a - 1 << endl;
	}
	else{
		cout << a << endl;
	}
	return 0;
}

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

int main(){

    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    int n , k;
    std::cin >> n >> k;

    std::vector<int> h(n);
    for(int i = 0 ; i < n ; ++i){
        std::cin >> h[i];
    }

    std::vector<int> dp(n);
    dp[0] = 0;
    dp[1] = std::abs(h[0] - h[1]);

    for(int i = 2 ; i < n ; ++i){
        dp[i] = INT_MAX;
        for(int j = 1 ; j <= k && i - j >= 0 ; ++j){
            dp[i] = std::min(dp[i] , std::abs(h[i] - h[i - j]) + dp[i - j]);
        }
    }

    std::cout << dp[n - 1] << '\n';

}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){

    int H, W;
    char S[50][50];
    
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> S[i][j];
        }
    }
    int count = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            count = 0;
            if(S[i][j] == '#'){
                if(i - 1 >= 0)
                    count += S[i-1][j] == '#';
                if(j - 1 >= 0)
                    count += S[i][j - 1] == '#';
                if(i + 1 <= H - 1)
                    count += S[i+1][j] == '#';
                if(j + 1 <= W - 1)
                    count += S[i][j+1] == '#';
                if(count == 0){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}





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

int main() {
    int n; cin >> n;
    int oddnum = 0;
    for(int i = 0; i < n; ++i) {
        int a; cin >> a;
        if(a % 2 == 1) ++oddnum;
    }
    
    if(oddnum % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mod 1000000007
using namespace std;
typedef long long ll;

int main(void)
{
    int n, m;
    vector<int> a(m);
    cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    if (sum > n)
        cout << -1 << endl;
    else
        cout << n - sum << endl;

    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
 
using namespace std;
          
#define endl        "\n"
#define int         long long
#define all(v)      v.begin(),v.end()
#define sz(v)       (int)v.size()
#define pii         pair<int,int>
#define fi          first
#define se          second
#define mod         1e9+7
#define forn(i,a,b) for(int i=a;i<b;i++)
#define deb(x)      cout << #x << ' ' << x << endl
#define clock       cerr << 1000 * (double)clock() / (double)CLOCKS_PER_SEC << "ms" << endl;

const long double pi=acos(0.0)*2.0;

void solve(){
    long double a,b,h,m;
    cin>>a>>b>>h>>m;
    long double angle=abs(6.0*m-0.5*(h*60.0+m));
    angle=min(angle,360.0-angle)*(pi/180.0);
    long double ans=a*a+b*b-2*a*b*cosl(angle);
    cout<<fixed<<setprecision(20)<<sqrtl(ans)<<endl;
}
 
int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 4176
#include <iostream>
using namespace std;
int main(){
int a,b,c,d,e,f;
cin >>a>>b>>c>>d>>e>>f; if(a+5*b+c*10+d*50+e*100+f*500>999) cout << "1\n";
else  cout << "0\n";
return 0; }

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

int main() {
  int x,y,a,b;
  scanf("%d%d%d%d",&x,&y,&a,&b);
  for(int i = 0;i < b;i++){
  	for(int j = 0;j < a;j++) printf("0");
    for(int j = a;j < y;j++) printf("1");
    printf("\n"); 
  }
  for(int i = b;i < x;i++){
    for(int j = 0;j < a;j++) printf("1");
    for(int j = a;j < y;j++) printf("0");
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1280
<?php
# 標準出力
fscanf(STDIN, "%d %d %d",$N,$A,$B);
$answer = 0;

# 一人分の値段の比較
if($A < $B/$N){
	
	$answer = $A * $N;
}else{
	
	$answer = $B;
}
echo $answer;
?>

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int i##_to_ = (t), i = (f); i <= i##_to_; i++)
#define uptil(f, t, i)   for(int i##_to_ = (t), i = (f); i <  i##_to_; i++)
#define downto(f, t, i)  for(int i##_to_ = (t), i = (f); i >= i##_to_; i--)
#define downtil(f, t, i) for(int i##_to_ = (t), i = (f); i >  i##_to_; i--)
typedef long double LD;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 2
#define _LIBCPP_DEBUG2 2
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '



signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    string s; cin >> s;
    vector<char> t; t.reserve(s.size());
    for(char c : s) if(c != 'x') t.push_back(c);

    vector<char> tr = t;
    reverse(tr.begin(), tr.end());
    if(t != tr) {
        cout << -1 ln;
        return 0;
    }

    long ans = 0;
    for(int l = 0, r = s.size(); l < r; ++l, --r) {
        long dl = 0, dr = 0;
        while(s[l] == 'x' && l < r) ++l, ++dl;
        while(s[r-1] == 'x' && l < r) --r, ++dr;
        if(l < r) {
            ans += abs(dl - dr);
            if(debug) cout << dl sp << dr sp << ans ln;
            if(s[l] != s[r-1]) ans /= !r;
        } else {
            //ans += (dl + dr) % 2;
        }
    }

    cout << ans ln;

    return 0;
}


Measured memory_bytes: 592
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

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

int n;
std::cin >> n;
if(n >999) {
    std::cout << "ABD";
}
else {
    std::cout << "ABC";
}
std::cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
	std::string x, y;
	std::cin >> x >> y;
	bool ans = false;

	for(int i=0; i<x.size(); ++i) {
		if(x==y) {
			ans = true;
			break;
		} else {
			x = x.back() + x.substr(0, x.size()-1);
		}
	}
	
	if(ans) {
		std::cout << "Yes" <<std::endl;
	} else {
		std::cout << "No" <<std::endl;
	}

	return 0;
}


Measured memory_bytes: 256