akhauriyash/Code-Regression huggingface dataset:
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
          long[] n = new long[3];
          n =　ReadLine().Split(' ').Select(long.Parse).ToArray();

          if(n[1] == 0){
              WriteLine(0);
              return;
          }else if(n[2] == 0){
              WriteLine(n[0]);
              return;
          }

          long ans1 = n[0] / (n[1] + n[2]);
          long ans2 = n[0] % (n[1] + n[2]);
          long ans = 0;
          if(ans2 <= n[1]){
              ans = ans1 * n[1] + ans2;
          }else{
              ans = ans1 * n[1] + n[1];
          }
          WriteLine(ans);
      }
   }
}

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

int main(){
	int n,m,d;
	cin>>n>>m>>d;
	
	int ans = 0;
	for(int i = n; i<=m; i++){
		if (i % d ==0) 
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = n; i >= b; i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const string lowercase = "abcdefghijklmnopqrstuvwxyz";
const string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int gcd(int a, int b){return b ? gcd(b, a % b): a;}

int main()
{
    int n;
    cin >> n;
    int h[101] = {};
    for (int i=0; i<n; i++){
        cin >> h[i];
    }

    int ans = 0;
    for (int k=1; k<=100; k++) {
        bool seekingl = true;
        for (int i=0; i<n; i++) {
            if (seekingl) {
                if (h[i]>=k) {
                    ans++;
                    seekingl = false;
                }
            }
            else {
                if (h[i]<k) {
                    seekingl = true;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int a;
	a=n/2;
	int flag=1;
	if(n%2==1)
	{
		flag=0;
	}
	for(int i=0;i<a;i++)
	{
		if(s[i]!=s[i+a])
		{
			flag=0;
			break;
		}
	}
	if(flag==1)
	cout<<"Yes";
	else
	cout<<"No";
 } 

Measured memory_bytes: 256
n = int(input())
g = [[-1, -1] for i in range(n*n)]
z = [0] * (n*n)

a = []
for _ in range(n):
    a.append([int(i) for i in input().split()])

for i in range(n):
    for j in range(n-2):
        p, q = (i, a[i][j]-1)
        r, s = (i, a[i][j+1]-1)
        r, s = (min(r, s), max(r ,s))
        if p < q:
            g[p*n+q][0] = r*n + s
        else:
            g[q*n+p][1] = r*n + s
        z[r*n+s] += 1

qu = set([])
for i in range(n):
    p, q = (i, a[i][0]-1)
    p, q = (min(p, q), max(p ,q))
    if z[p*n+q] == 0:
        qu.add(p*n+q)

ans = 0
re = 0
while True:
    nqu = []
    while qu:
        s = qu.pop()
        re += 1
        for t in g[s]:
            if t != -1:
                z[t] -= 1
                if z[t] == 0:
                    nqu.append(t)
    ans += 1    
    qu = nqu
    if not qu:
        break

if re == n*(n-1)//2:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 144968
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define NREP(i, n) for(int i = 1; i <= (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int nums(int n){
	return to_string(n).length();
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cout << fixed << setprecision(7);
////////////////////////////////////////////
	int a,b;
	cin >> a >> b;
	int c = max({a+b,a-b,a*b});
	cout << c << endl;
///////////////////////////////////////////
}


Measured memory_bytes: 256
#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 each(itr,v) for(auto itr:v)
#define pb push_back
#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_popcount

#define INF INT_MAX/3

struct node{
  node *p,*l,*r;
  int val;
};

node* root=NULL;

void insert(node* z){
  node* x=root;
  node* y=NULL;
  while(x!=NULL){
    y=x;
    if(z->val<x->val)x=x->l;
    else x=x->r;
  }
  z->p=y;

  if(y==NULL)root=z;
  else if(z->val<y->val)y->l=z;
  else y->r=z;
}

void dfs1(node* v){
  if(v->l!=NULL)dfs1(v->l);
  cout<<" "<<v->val;
  if(v->r!=NULL)dfs1(v->r);
}

void dfs2(node* v){
  cout<<" "<<v->val;
  if(v->l!=NULL)dfs2(v->l);
  if(v->r!=NULL)dfs2(v->r);
}

bool f(node* v,int x){
  if(v==NULL)return false;
  if(x==v->val)return true;
  else if(x<v->val)return f(v->l,x);
  else return f(v->r,x);
}

int main(){
  int q;
  cin>>q;
  while(q--){
    string s;
    cin>>s;
    if(s=="insert"){
      int v;
      cin>>v;
      node* z=(node *)malloc(sizeof(node));
      z->p=NULL; z->l=NULL; z->r=NULL;
      z->val=v;
      insert(z);
    }else if(s=="print"){
      dfs1(root);
      cout<<endl;
      dfs2(root);
      cout<<endl;
    }else{
      int v;
      cin>>v;
      if(f(root,v))cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
  }
	return 0;
}



Measured memory_bytes: 21908
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	ll n,m,k; cin>>n>>m>>k;
  vl a(n+1),b(m+1);
  a[0]=0; b[0]=0;
 rep(i,1,n+1){
   ll x; cin>>x;
   a[i]=x;
   a[i]+=a[i-1];
 }
  rep(i,1,m+1){
    ll x; cin>>x;
    b[i]=x;
    b[i]+=b[i-1];
  }
  ll ans=0,j=m;
  rep(i,0,n+1){
    if(a[i]>k)break;
    while(b[j]>k-a[i]){
      j--;
    }
    chmax(ans,i+j);
  }
  cout<<ans<<endl;
  
    
  

  
 
		
	return 0;
}


Measured memory_bytes: 6412
#include<iostream>
using namespace std;
int main(){

	int i,k,j,a=0,b=0,c=0,d=0;
while(1){
	cin>>i>>k>>j;
	if(i>j){swap(i,j);}
	if(k>j){swap(k,j);}

	if(i+k>j&&k+j>i&&i+j>k){a=a+1;}
	else{break;}

	if(i*i+k*k>j*j){b=b+1;}
	if(i*i+k*k<j*j){c=c+1;}
	if(i*i+k*k==j*j){d=d+1;}

}
    cout<<a<<" "<<d<<" "<<b<<" "<<c<<endl;

	return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int tmp;
		cin>>tmp;
		ans+=tmp;
	}
	cout<<ans-n;
}

Measured memory_bytes: 768
# -*- coding: utf-8 -*-
a = int(input())
b = []
for i in range(a):
    b.append(int(input()))

c = [0] * (100+1)
for i in b:
    c[i] = i

d = []
for g in c:
    if g != 0:
        d.append(g)

print(len(d))




Measured memory_bytes: 3060
#include <iostream>
#include <string>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int n;
string ss[1001];

void solve() {
  rep (i,n) {
    string s = ss[i];

    int j = 0;
    while(s[j] == '.')j++; 

    for (int k = 0;k < j - 1;k++) {
      ss[i][k] = ' ';
    }

    if (j - 1 >= 0) ss[i][j - 1] = '+';

    int m = i - 1;
    for (;m >= 0 && ss[m][j - 1] == ' ';m--) {
      ss[m][j - 1] = '|';
    } 
  }

  rep (i,n) {
    cout << ss[i] << endl;
  }
}

int main() {
  while(1) {
    cin >> n;
    if (n > 0) {
      rep(i,n) {
        cin >> ss[i];
      }
      solve();
    } else break;
  }
  return 0;
}



Measured memory_bytes: 3872
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


pair<pii, int> get(const vector<int>& a) {
    int n = a.size();
    vector<int> c(100000 + 10, 0);
    
    for (int i = 0; i < n; ++i) {
        ++c[a[i]];
    }
    int m1 = 0, m2 = 0;
    int id = 0;
    for (int i = 0; i < c.size(); ++i) {
        if (c[i] > m1) {
            m2 = m1;
            m1 = c[i];
            id = i;
            continue;
        }
        if (c[i] > m2) {
            m2 = c[i];
        }
    }
    return make_pair(pii(m1, id), m2);
}

void solve() {
    int n;
    cin >> n;
    int res = n;
    int m = n / 2;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
    }
    pair<pii, int> r1 = get(a), r2 = get(b);
    if (r1.first.second == r2.first.second) {
        cout << min(res - r1.first.first - r2.second, res - r1.second - r2.first.first) << endl;

    }
    else
        cout << res - r1.first.first - r2.first.first << endl;

}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    vector<int> p(a);
    for (int i = 0; i < a; i++) cin >> p[i];
    vector<int> q(b);
    for (int i = 0; i < b; i++) cin >> q[i];
    vector<int> r(c);
    for (int i = 0; i < c; i++) cin >> r[i];
    
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());

    priority_queue<int, vector<int>, greater<int>> que;
    for (int i = 0; i < x; i++) que.emplace(p[i]);
    for (int i = 0; i < y; i++) que.emplace(q[i]);

    for (int i = 0; i < c; i++) {
        if (r[i] <= que.top()) break;
        que.pop(); que.emplace(r[i]);
    }

    ll ans = 0;
    while (!que.empty()) {
        ans += que.top(); que.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2552
const main = arg => {
  const input = arg.trim().split('\n');
  const k = Number(input[0]);
  const s = input[1];

  if (s.length <= k) {
    console.log(s);
  } else {
    console.log(`${s.slice(0, k)}...`);
  }
};

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

#define fi first
#define se second
#define endl '\n'
#define lc (rt<<1)
#define rc (rt<<1|1)
#define mp make_pair
#define pb push_back
#define lowbit(a) (a&(-a))
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define mst(a,v) memset(a,v,sizeof(a))
#define debug(x) cout<<#x": "<<x<<'\n';
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

const int N=1000010;
const int mod=1e9+7;
const ld PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

template<typename T>inline void gmax(T &A,T B) {(A<B)&&(A=B);}
template<typename T>inline void gmin(T &A,T B) {(A>B)&&(A=B);}

template <class T>
inline bool re(T &ret)
{
    char c;
    int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}

int h[111111],dp[111111];

int main()
{
#ifdef local
    //freopen("in.txt", "r", stdin);
#endif
    IOS;
    int n,k;
    cin>>n>>k;
    for(int i=1; i<=n; i++) cin>>h[i];
    mst(dp,0x3f);
    dp[1]=0,dp[2]=abs(h[1]-h[2]);
    for(int i=3; i<=n; i++)
        for(int j=i-1; j>=max(i-k,1); j--)
            gmin(dp[i],dp[j]+abs(h[i]-h[j]));
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1152
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    long long a,b;
    cin>>a>>b;
    if(a==b){
        rep(i,a){
            cout<<a;
        }
        cout<<endl;
    }
    else{
        if(a<b){
            rep(i,b){
                cout<<a;
            }
            cout<<endl;
        }
        if(a>b){
            rep(i,a){
                cout<<b;
            }
            cout<<endl;
        }
    }
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] jal = new String[3];
		int[] ana = new int[3];
		jal = line.split(" ");
		for(int i=0;i<jal.length;i++)
			ana[i]=Integer.parseInt(jal[i]);
		if(ana[1]-ana[0]==ana[2]-ana[1])
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}

Measured memory_bytes: 21204
import itertools
import math
import fractions
import functools
import copy
n = int(input())
x = []
u = []
for i in range(n):
    a, b = input().split()
    x.append(float(a))
    u.append(b)

sum = 0
for i in range(n):
    if u[i] == "JPY":
        sum += x[i]
    else:
        sum += x[i]*380000

print(sum)

Measured memory_bytes: 66412
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long
int op(int t, int a, int b){
        if(t==0) return a+b;
        else if(t==1) return a-b;
        else return a*b;
}
string os(int t, string a, string b){
        if(t==0) return "("+a+" + "+b+")";
        else if(t==1) return "("+a+" - "+b+")";
        else return "("+a+" * "+b+")";
}
bool solve(){
        vector<int> a(4);
        if(scanf("%lld %lld %lld %lld", &a[0], &a[1], &a[2], &a[3]) == EOF) return false;
        if(a[0]==0&&a[1]==0&&a[2]==0&&a[3]==0) return false;
        sort(a.begin(),a.end());
        do{
                for(int i=0;i<3;i++){
                        for(int j=0;j<3;j++){
                                for(int k=0;k<3;k++){
                                        if(op(k,op(j,op(i,a[0],a[1]),a[2]),a[3])==10){
                                                cout << os(k,os(j,os(i,to_string(a[0]),to_string(a[1])),to_string(a[2])),to_string(a[3])) << endl;
                                                return true;
                                        }else if(op(k,op(i,a[0],op(j,a[1],a[2])),a[3])==10){
                                                cout << os(k,os(i,to_string(a[0]),os(j,to_string(a[1]),to_string(a[2]))),to_string(a[3])) << endl;
                                                return true;
                                        }else if(op(j,op(i,a[0],a[1]),op(k,a[2],a[3]))==10){
                                                cout << os(j,os(i,to_string(a[0]),to_string(a[1])),os(k,to_string(a[2]),to_string(a[3]))) << endl;
                                                return true;
                                        }else if(op(i,a[0],op(j,op(k,a[1],a[2]),a[3]))==10){
                                                cout << os(i,to_string(a[0]),os(j,os(k,to_string(a[1]),to_string(a[2])),to_string(a[3]))) << endl;
                                                return true;
                                        }else if(op(i,a[0],op(j,a[1],op(k,a[2],a[3])))==10){
                                                cout << os(i,to_string(a[0]),os(j,to_string(a[1]),os(k,to_string(a[2]),to_string(a[3])))) << endl;
                                                return true;
                                        }
                                }
                        }
                }
        }while(next_permutation(a.begin(),a.end()));
        cout << "0"  << endl;
        return true;
}
signed main(){
        while(solve()){}
        return 0;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N; cin >> N;
    vi a(N); REP(i, N) cin >> a[i];
    cout << *max_element(ALL(a)) - *min_element(ALL(a)) << endl;
}

Measured memory_bytes: 3592
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

S = input()
T = input()

if any(i not in sorted(list(set(S))) for i in sorted(list(set(T)))):
    print(-1)
    exit()

d = {}
for sidx, s in enumerate(S):
    if s not in d.keys():
        d[s] = []
    d[s].append(sidx+1)

if 'LOCAL' in os.environ:
    print('d', d)
current_idx = -1
round_count = 0
for tidx, t in enumerate(T):
    #  pdb.set_trace()
    if 'LOCAL' in os.environ:
        print('t:  ', t, tidx)

    char_position_idx = bisect.bisect_right(d[t], current_idx)
    if char_position_idx >= len(d[t]):
        # 同じ文字だがこえているので次の順目に
        round_count += 1
        current_idx = d[t][0]
        continue

    #  print('char posi idx', char_position_idx)
    #  print('d[t][char posi idx]', d[t][char_position_idx], current_idx)
    if d[t][char_position_idx] < current_idx:
        # この順目にない場合
        current_idx = d[t][0]
        round_count += 1
    else:
        # この順目にある場合
        current_idx = d[t][char_position_idx]
print(len(S)*round_count + current_idx)


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */

struct Cumusum {
	vector<LL>csum;
	Cumusum() {}
	Cumusum(vector<LL>&a) {
		csum.assign((int)a.size() + 1, 0);
		for (int i = 0; i < (int)a.size(); i++) {
			csum[i + 1] = csum[i] + a[i];
		}
	}
	LL query(int l, int r) {
		return csum[r] - csum[l];
	}
};


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

	LL N, C; cin >> N >> C;
	vector<LL>s(N), t(N), c(N);
	for (int i = 0; i < N; ++i) {
		cin >> s[i] >> t[i] >> c[i];
		c[i]--;
	}
	VVL vc(C, VL(2e5 + 10)); // 倍して扱うことにする
	FOR(i, 0, N) {
		vc[c[i]][2 * s[i] - 1]++;
		vc[c[i]][2 * t[i]]--;
	}
	vector<Cumusum>vcsum(C);
	FOR(i, 0, C) {
		vcsum[i] = Cumusum(vc[i]);
	}
	VL a(2e5 + 30);
	FOR(c, 0, C) {
		FOR(i, 0, 2e5 + 10) {
			if (vcsum[c].csum[i])
				a[i]++;
		}
	}

	LL ans = *max_element(ALL(a));


	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 98020
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int h,w,n;
    cin>>h>>w>>n;
    int kai=max(h,w);
    if(n%kai==0){
        cout<<n/kai<<endl;
    }
    else{
        cout<<n/kai+1<<endl;
        
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<stack>

using namespace std;

struct Coord {
  int row;
  int col;
};

int solve (int W, int H);
  
int main () {
  int W, H;

  while(1)
    {
      scanf("%d%d", &W, &H);
      if(W==0 && H==0) break;	
      printf("%d\n", solve(W,H));	
    }
}

int solve (int W, int H) {
  int n=0;
  char M[H+2][W+2];
  Coord start;
  for (int i=0; i<=W+1; i++) { M[0][i] = '0'; M[H+1][i] = '0'; }
  for (int i=1; i<=H; i++) { M[i][0] = '0'; M[i][W+1] = '0'; } 
  for (int i=1; i<=H; i++) {
    for (int j=1; j<=W; j++) {
      scanf(" %c", &M[i][j]);
    }
  }
  for(int i=1 ; i<=H ; i++) {
    for(int j=1 ; j<=W ; j++){
      if(M[i][j]=='1'){	
        start.row=i;
        start.col=j;
        M[start.row][start.col]='@';

        stack<Coord> S;
        S.push(start);
        while (!S.empty()) {
          Coord current = S.top(); S.pop();
          int D1[]={1,1,0,-1,-1,-1,0,1}; int D2[]={0,-1,-1,-1,0,1,1,1};
          for (int d=0; d<8; d++) {
            Coord nc = current;
            nc.row += D1[d];
            nc.col += D2[d];
            if(M[nc.row][nc.col]!='0' && M[nc.row][nc.col]!='*' && M[nc.row][nc.col]!='@')
	      {
	        M[nc.row][nc.col] = '*';
	        S.push(nc);
	      }
          } 
        }
        n++;
      }
    }
  }
  return n;
}

Measured memory_bytes: 1056
s = int(input())

a = set()
cnt = 0
while True:
    cnt += 1
    
    if s in a:
        print(cnt)
        break
        
    if s % 2 == 0:
        am = s / 2
    else:
        am = 3 * s + 1
    a.add(s)
    s = am

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <map>
#include <cmath>
#define ll long long int 

using namespace std;

ll n, m;
int a[100100];
int main()
{
    //freopen("a.txt", "r", stdin);
    cin >> n >> m;
    n = (n % m);
    n = min(n, abs(n - m));
    cout << n;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<int> a(3);
	cin >> a;
	sort(a.begin(), a.end());
	if (a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

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

  vector<string> S(N);
  int C[4] = {0};
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    // cout << S[i] << endl;
    if (S[i] == "AC") {
      C[0] += 1;
    } else if (S[i] == "WA") {
      C[1] += 1;
    } else if (S[i] == "TLE") {
      C[2] += 1;
    } else if (S[i] == "RE") {
      C[3] += 1;
    }
  }

  cout << "AC x " << C[0] << endl;
  cout << "WA x " << C[1] << endl;
  cout << "TLE x " << C[2] << endl;
  cout << "RE x " << C[3] << endl;
  return 0;
}

Measured memory_bytes: 6424
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int H, N;
  cin >> H >> N;

  int A[N];
  rep(i, N) { cin >> A[i]; }

  rep(i, N) { H -= A[i]; }
  if (H <= 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int C, D, W, X, a[33][17], b[33][17], dp[33][55][7];
int solve(int d, int s, int x) {
	if (d == D) return 0;
	if (dp[d][s][x]) return dp[d][s][x] - 1;
	int ret = solve(d + 1, s, x);
	for (int i = 0; i < C; i++) {
		if (s + b[d][i] <= W && a[d][i] != 0) {
			int res = solve(d + 1, s + b[d][i], x);
			ret = max(ret, res + a[d][i]);
		}
	}
	if (x != X) {
		for (int i = 0; i < C; i++) {
			int sum = 0, prof = 0;
			for (int j = i; j < C; j++) {
				prof += a[d][j];
				sum += b[d][j];
				if (a[d][j] == 0 || s + sum > W) break;
				int res = solve(d + 1, s + sum, x + 1);
				ret = max(ret, res + prof);
			}
		}
	}
	dp[d][s][x] = ret + 1;
	return ret;
}
int main() {
	while (cin >> C >> D >> W >> X, C) {
		for (int i = 0; i < C; i++) {
			for (int j = 0; j < D; j++) {
				cin >> a[j][i];
			}
		}
		for (int i = 0; i < C; i++) {
			for (int j = 0; j < D; j++) {
				cin >> b[j][i];
			}
		}
		for (int i = 0; i <= D; i++) {
			for (int j = 0; j <= W; j++) {
				for (int k = 0; k <= X; k++) {
					dp[i][j][k] = 0;
				}
			}
		}
		int ret = solve(0, 0, 0);
		cout << ret << endl;
	}
	return 0;
}

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

int main(){
  ll n, k;
  cin >> n >> k;
  if(k == 0){
    cout << n * n << endl;
    return 0;
  }
  ll sum = 0;
  for(ll b = 1; b <= n; b++){
    ll p = n / b, r = n % b;
    sum += p * max(0LL, b-k);
    sum += max(0LL, r-k+1);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, n1, n2, n3, n4;
  cin >> n;
  
  n1 = n % 10;
  n2 = n % 100 / 10;
  n3 = n % 1000 / 100;
  n4 = n / 1000;
  
  if ( ( n1 == n2 || n3 == n4 ) && n2 == n3 ) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;

signed main(){
    int n,m,k[111111],a[36][36];
    map<int,int> s;
    cin>>n>>m;
    rep(i,n){
        cin>>k[i];
        rep(j,k[i]){
            cin>>a[i][j];
            s[a[i][j]]++;
        }
    }
    int ans=0;
    for(auto x:s){
        if(x.second==n)ans++;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
a=[]
a=input().split(" ")
A=int(a[0])
B=int(a[1])
C=int(a[2])

if C-1<=B :
    x=B+C
elif C-1>B :
    if C-B-1<=A :
        x=B+C
    else:
        x=2*B+A+1
print(x)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>K>>M;
    rep(i,K) {
        cout<<M;
        if(i != N - 1) cout<<' ';
    }
    reps(i,K,N) {
        cout << M + (M == 1e+9 ? -1 : 1);
        if (i != N - 1) cout << ' ';
    }
    cout<<endl;
}

Measured memory_bytes: 1280
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return [int(x) for x in readline().split()]

def main():
    a,b,c = LI()
    if((a==b and a!=c) or (a==c and a!=b) or (b==c and a!=b)):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[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 , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }
#[allow(dead_code)]
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
#[allow(dead_code)]
fn solve() {
    input! {
        n: usize,
        l: [usize; 2 * n],
    }
    let mut L = l;
    L.sort();
    let mut ans = 0;
    for i in 0..2 * n {
        if i % 2 == 1 {
            continue;
        }
        ans += L[i];
    }
    println!("{}", ans);
}

Measured memory_bytes: 8572
void main()
{
    string n = rdStr;

    writeln(n.canFind('7') ? "Yes" : "No");
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

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

Measured memory_bytes: 2700
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    long long h,w;
    cin>>h>>w;
    long long a,b,c;
    long long res = h*w;
    for(int i=1;i<=w-1;i++){
        a=h/2*i;
        b=(h+1)/2*i;
        c=h*(w-i);
        res = min(res,max({a,b,c})-min({a,b,c}));
    }
    for(int i=1;i<=h-1;i++){
        a=w/2*i;
        b=(w+1)/2*i;
        c=w*(h-i);
        res = min(res,max({a,b,c})-min({a,b,c}));
    }
    for(int i=1;i<=w-1;i++){
        a=h*i;
        b=(w-i)/2*h;
        c=(w-i+1)/2*h;
        res = min(res,max({a,b,c})-min({a,b,c}));
    }
    for(int i=1;i<=h-1;i++){
        a=w*i;
        b=(h-i)/2*w;
        c=(h-i+1)/2*w;
        res = min(res,max({a,b,c})-min({a,b,c}));
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int N, l, r, a, i, b = 0, j = 0;
	scanf("%d", &N);
	for (i = 0;i <N;i++) {
		scanf("%d %d", &l, &r);
		a = r - l;
		if (i < N) {
			j = a + 1;
		}
		b = b + j;
	}
	printf("%d", b);
}



Measured memory_bytes: 128
def main(N, C):
    counta_R = 0
    counta_W = 0
    for i, c in enumerate(C):
        if c == 'R':
            counta_R += 1
        else:
            counta_W += 1
    if counta_R == 0 or counta_W == 0:
        print(0)
        exit()
    ideal = 'R' * counta_R + 'W' * counta_W
    print(C.count('W', 0, counta_R))


if __name__ == '__main__':
    N = int(input())
    C = input()
    main(N, C)

Measured memory_bytes: 9640
N, A, B, C = map(int, input().split())
ans = []
d = {'A': A, 'B': B, 'C': C}
s = [input() for _ in range(N)]


def add_ans(s1, s2):
    d[s1] += 1
    d[s2] -= 1
    ans.append(s1)


for i in range(N):
    now = s[i]
    x = now[0]
    y = now[1]
    if d[x] == d[y] == 0:
        print('No')
        exit()
    elif d[x] == 0:
        add_ans(x, y)
    elif d[y] == 0:
        add_ans(y, x)
    elif i == N - 1:
        add_ans(x, y)
    elif x in s[i + 1]:
        add_ans(x, y)
    else:
        add_ans(y, x)

print("Yes")
for i in ans:
    print(i)


Measured memory_bytes: 87792
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
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 VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    cin>>n;
    vector<int>p(n);
    vector<int>q(n);
    for(int i=0;i<n;i++){
        cin>>p.at(i);
        q.at(i)=p.at(i);
    }
    sort(q.begin(),q.end());
    int ans=0;
    for(int i=0;i<n;i++){
        if(q.at(i)!=p.at(i)){
            ans++;
        }
    }
    if(ans==0 || ans==2){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }





    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a=0,b=0,c =0;
		int[] n= new int[10];
		for(int i=0;i<10;i++){
			n[i]=sc.nextInt();
			if(n[i]>a){
				c=b;
				b=a;
				a=n[i];
			}else if(n[i]>b){
				c=b;
				b=n[i];
			}else if(n[i]>c){
				c=n[i];
			}
		}
		System.out.println(a);
		System.out.println(b);
		System.out.println(c);
	}
}

Measured memory_bytes: 17308
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]
g = [set() for _ in range(N + 1)]
for a, b in edges:
    g[a].add(b)
    g[b].add(a)

ans = 0
for a, b in edges:
    cur_g = [x.copy() for x in g]
    cur_g[a].remove(b)
    cur_g[b].remove(a)
    visited = [False] * (N + 1)
    dfs_stack = [1]
    while dfs_stack:
        s = dfs_stack.pop()
        visited[s] = True
        for t in cur_g[s]:
            if not visited[t]:
                dfs_stack.append(t)
    if not all(visited[1:]):
        ans += 1
print(ans)

Measured memory_bytes: 3064
-- Your code here!
f :: (Int, Char) -> Bool
f (i, c) = ((mod i 2 == 0) && not (c == 'L')) || ((mod i 2 == 1) && not (c == 'R'))

g :: Bool -> String
g True = "Yes"
g False = "No"

main = do
    str <- getLine
    putStrLn $ g $ foldr (&&) True $ map f (zip [0..] str)


Measured memory_bytes: 380
main :: IO ()
main = print . solve . map read . words =<< getContents

solve :: [Integer] -> Integer
solve (ai:ao:at:aj:al:_)
  | ai `mod` 2 == 1 && aj > 0 && al > 0 = 3 + solve [ai - 1, ao, at, aj - 1, al - 1]
  | aj > 1 = 2 * (aj `div` 2) + solve [ai, ao, at, aj `mod` 2, al]
  | al > 1 = 2 * (al `div` 2) + solve [ai, ao, at, aj, al `mod` 2]
  | aj == 1 && al == 1 && ai > 0 = 3 + solve [ai - 1, ao, at, aj - 1, al - 1]
  | ai > 1 = 2 * (ai `div` 2) + solve [ai `mod` 2, ao, at, aj, al]
  | otherwise = ao


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

int main() {
  int n[4];
  char s[4];

  cin >> s;
  for(int i = 0; i < 4; i++){
    n[i] = s[i] - '0';
  }

  char op[3];
  for(int bit = 0; bit < (1<<3); bit++){
    int tot = n[0];
    for(int i = 0; i < 3; i++){
      if(bit & (1 << i)){
        op[i] = '+';
        tot += n[i+1];
      }
      else{
        op[i] = '-';
        tot -= n[i+1];
      }
    }

    if(tot == 7){
      cout << n[0];
      for(int i = 0; i < 3; i++){
        cout << op[i];
        cout << n[i+1];
      }
      cout << "=7" << endl;

      break;
    }
  }

  return 0;
}

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

int main() {
	int a[100],n;
	cin >> n;
	for (int i = 0; i < n; i++){
	cin>> a[i];
	}
	for(int i = n-1; i >=0; i--){
	   cout <<a[i];
	   if(i != 0){
		   cout <<" ";
	   }else {
		  cout << endl;
	   }
	}
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &&i : v) scanf("%lld", &i);
    vector<ll> ans(n, 1000);
    for (int i = 0; i < n; ++i) {
        if(i) ans[i] = max(ans[i], ans[i-1]);
        for (int j = 0; j < i; ++j) {
            ans[i] = max(ans[i], ans[j]%v[j]+ans[j]/v[j]*v[i]);
        }
    }
    cout << *max_element(ans.begin(),ans.end()) << "\n";
    return 0;
}

Measured memory_bytes: 3692
local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local start_stage = 1
  while right - left + 1 < self.size[start_stage] do
    start_stage = start_stage + 1
  end
  local ret = self.emptyvalue
  local t1, t2, t3 = {start_stage}, {left}, {right}
  while 0 < #t1 do
    local stage, l, r = t1[#t1], t2[#t1], t3[#t1]
    table.remove(t1) table.remove(t2) table.remove(t3)
    local sz = self.size[stage]
    if (l - 1) % sz ~= 0 then
      local newr = mmi(r, mce((l - 1) / sz) * sz)
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)
      l = newr + 1
    end
    if sz <= r + 1 - l then
      ret = self.func(ret, self.stage[stage][mce(l / sz)])
      l = l + sz
    end
    if l <= r then
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)
    end
  end
  return ret
end
SegTree.update = function(self, idx, value)
  if self.stage[self.stagenum][idx] < value then
    self.stage[self.stagenum][idx] = value
    for i = self.stagenum - 1, 1, -1 do
      local dst = mce(idx / 2)
      local rem = dst * 4 - 1 - idx
      self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
      idx = dst
    end
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n = io.read("*n")
local h = {}
local a = {}
for i = 1, n do h[i] = io.read("*n") end
for i = 1, n do a[i] = 0LL + io.read("*n") end
local st = SegTree.new(n, function(x, y) return x < y and y or x end, 0)
for i = 1, n do
  if h[i] == 1 then
    st:update(h[i], a[i])
  else
    local cur = st:getRange(1, h[i] - 1)
    st:update(h[i], cur + a[i])
  end
end
local str = tostring(st.stage[1][1]):gsub("LL", "")
print(str)


Measured memory_bytes: 58596
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);

  int a[n+2] , count = 0;
  for(int i = 1;i <= n;i ++){
    scanf("%d",&a[i]);
    if(i%2 == 1 && a[i]%2 == 1){
      count ++;
    }
  }

  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define X first
#define Y second
#define sz(v) (int)v.size()

void solve();

main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ONPC
	freopen("in.txt", "r", stdin);
#endif
	int t = 1;
	//cin >> t;
	while (t--) solve();
	return 0;
}

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<pair<int, int>> b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (i == 0) b[i].first = b[i].second = 1;
		else {
			if (a[i] >= a[i - 1]) b[i].first |= b[i - 1].first;
			if (a[i] >= a[i - 1] - 1) b[i].first |= b[i - 1].second;
			if (a[i] - 1 >= a[i - 1]) b[i].second |= b[i - 1].first;
			if (a[i] - 1 >= a[i - 1] - 1) b[i].second |= b[i - 1].second;
		}
	}
	if (b[n - 1].first || b[n - 1].second) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 1408