akhauriyash/Code-Regression huggingface dataset:
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	vector<ll> x(n), y(n), z(n);
	rep(i, n)cin >> x[i] >> y[i] >> z[i];
	ll res = -1e18;
	rep(i, 8)
	{
		int a, b, c;
		a = b = c = 1;
		if (i&(1 << 0))a = -1;
		if (i&(1 << 1))b = -1;
		if (i&(1 << 2))c = -1;
		vector<ll> d;
		rep(j, n)
		{
			ll tmp = x[j] * a + y[j] * b + z[j] * c;
			d.push_back(tmp);
		}
		sort(all(d), greater<ll>());
		ll sum = 0;
		rep(j, m)sum += d[j];
		res = max(res, sum);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b)	cout<<"YES"<<endl;
	else	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <random>
#include <deque>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

const ll MOD = 1e9+7;

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

template<typename T>
void chmax(T &a, T &b){
	a = max(a, b);
}

template<typename T>
void chmin(T &a, T &b){
	a = min(a, b);
}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

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

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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

class RMQ{
	int n;
	vector<int> dat;
public:
	RMQ(int n_){
		n = 1;
		while(n < n_) n *= 2;
		REP(i, n*2-1){
			dat.push_back(INF);
		}
	}

	void update(int x, int i){
		i += n-1;
		dat[i] = x;
		while(i > 0){
			i = (i-1)/2;
			dat[i] = min(dat[i*2+1], dat[i*2+2]);
		}
	}

	int query(int a, int b, int l, int r, int x){
		if(a <= l && r <= b) return dat[x];
		if(r <= a || b <= l) return INF;

		int res = INF;
		res = min(query(a, b, l, (l+r)/2, x*2+1), query(a, b, (l+r)/2, r, x*2+2));
		return res;
	}
	int query(int a, int b){
		return query(a, b, 0, n, 0);
	}
};

const ll mod = 1e9+7;

ll f(ll b, ll n){
	ll sum = 0;
	while(n > 0){
		sum += n%b;
		n = n/b;
	}
	return sum;
}

int main(void){
	ll n, s;
	cin >> n >> s;
	if(n == s){
		cout << n+1 << endl;
		return 0;
	}
	ll ans = INF_LL;
	for(int i = 2;i <= sqrt(n);i++){
		if(f(i, n) == s){
			ans = min(ans, (ll)i);
		}
	}
	for(int i = 1;i <= sqrt(n);i++){
		ll b = (n-s)/i+1;
		if(b > 1 && f(b, n) == s){
			ans = min(ans, b);
		}
	}
	cout << (ans == INF_LL ? -1 : ans) << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i;
  int a[n];
  int num[n]={};
  int chk = 1;
  for(i=0;i<n;i++){
    cin >> a[i];
    num[a[i]]++;
  }
  int oe = n%2;
  for(i=1;i<n;i++){
    if(num[i]!=(i+oe)%2*2)chk = 0;
  }
  long ans = chk;
  for(i=0;i<n/2;i++){
    ans *= 2;
    ans %= 1000000007;
  }
  cout << ans;

}


Measured memory_bytes: 1024
N = int(input())
cnt = [0]*5
for i in range(N):
    S = input()
    if S[0] == "M":
        cnt[0] += 1
    elif S[0] == "A":
        cnt[1] += 1
    elif S[0] == "R":
        cnt[2] += 1
    elif S[0] == "C":
        cnt[3] += 1
    elif S[0] == "H":
        cnt[4] += 1
res = 0
for i in range(4):
    for j in range(i+1,5):
        for k in range(j+1,5):
            res += cnt[i]*cnt[j]*cnt[k]
print(res)

Measured memory_bytes: 44392
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007LL;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
llint LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	llint h,i,j,n;cin>>n;
	//O(n^(log2/log6))
	//O(n^0.387)
	//3の倍数の下bitから決めていく(典型)
	vector<int>dp(9,9999);
	dp[0]=0;
	llint rok=1;//6の累乗/3の累乗
	for(h=0;;h++){
		if(h%2==0){
			//+1できる
			for(i=1;i<dp.size();i++){mineq(dp[i],dp[i-1]+1);}
		}
		//5つまで+rokできる
		for(i=rok;i<dp.size();i++){mineq(dp[i],dp[i-rok]+1);}
		int ama=n%3;
		n/=3;
		rok*=2;
		vector<int>ddp;
		int nesiz=min((llint)(n+2),(llint)(10+rok*5+(dp.size()+5-ama)/3));
		ddp.resize(nesiz);
		for(i=ama;i<dp.size();i+=3){ddp[i/3]=dp[i];}
		for(i/=3;i<ddp.size();i++){ddp[i]=9999;}
		dp=move(ddp);
		if(n==0){break;}
	}
	cout<<dp[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n,k;
    cin >> n >> k;
    pf(min(n % k, abs(n % k - k)));
    return 0;
}



Measured memory_bytes: 256
def main():
	N, X = map(int,input().split())
	m = [0]*N
	total = 0
	cheap = 1000
	for i in range(N):
		m[i] = int(input())
		total += m[i]
		cheap = min(cheap, m[i])

	ans = ((X - total) // cheap) + N
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 3060
#include<stdio.h>
int main() {
	int n, i, j, r[200000], maxv, minv;
	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d", &r[i]);
	maxv = -2000000000;
	minv = r[0];
	for (j = 1; j < n; j++) {
		if (maxv < r[j] - minv)maxv = r[j] - minv;
		if (minv > r[j])minv = r[j];
	}
	printf("%d\n", maxv);
	return 0;
}

Measured memory_bytes: 1380
#include<bits/stdc++.h>
using namespace std;
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define int long long int 
#define F first
#define S second
#define boost ios_base::sync_with_stdio(false),cin.tie(NULL);
const int MOD = 998244353;
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp>  
//using namespace __gnu_pbds; 
//stringstream ss; string temp; ss<<str(original string) ss>>temp;


int32_t main()
{	
	
  	
  	int n,d; cin>>n>>d;
  	int ans = 0;
  	int last = -1;
  	for(int i=d+1;i<=n;i+=(2*d+1))
  	{
  		ans++;
  		last = i;
  	}
  	if(last==-1 || n-last > d)
  		ans++;
  	//ans = max(ans,1ll);
  	cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

int main() {
  int n;
  while(cin >> n) {
    int a[200][3];
    REP(i,n) REP(j,3) cin >> a[i][j];
    int ans[200] = {};
    REP(j,3) {
      int t[101] = {};
      REP(i,n) t[a[i][j]]++;
      REP(i,n) if (t[a[i][j]]==1) ans[i]+=a[i][j];
    }
    REP(i,n) cout << ans[i] << endl;
  }
}

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

int main(void)
{
    std::string S;

    std::cin >> S;

    std::cout << (S.at(0) == S.at(1) && S.at(1) == S.at(2) ? "No" : "Yes") << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for(int i=0; i<n; i++){
			int a[] = new int[3];
			a[0] = in.nextInt();
			a[1] = in.nextInt();
			a[2] = in.nextInt();
			Arrays.sort(a);
			if(a[0]*a[0] + a[1]*a[1] == a[2]*a[2]){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
	}

}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1000000007;
const int N = 200006;
const ll INF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a > b) swap(a, b);
    if(c > d) swap(c, d);
    cout << max({a * c, b * d, a * d, b * c}) << '\n';
    return 0;
}

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

int main(){
  ll n, k;
  cin >> n >> k;
  ll a[n];
  ll sum = 0;
  rep(i,n) {
    cin >> a[i];
    sum += a[i];
  }
  vector<ll> val;
  for(ll i = 1; i*i <= sum; i++) {
    if(sum % i == 0) {
      val.push_back(i);
      val.push_back(sum/i);
    }
  }
  ll ans = 1;
  for(ll x : val) {
    vector<int> mod(n);
    rep(i,n) mod[i] = a[i] % x;
    sort(mod.begin(),mod.end());
    vector<int> s(n);
    rep(i,n) {
      s[i] += x - mod[i];
      if(i > 0) s[i] += s[i-1];
    }
    ll res = 0;
    rep(i,n) {
      res += mod[i];
      if(res == s[n-1] - s[i]) break;
    }
    if(res <= k) ans = max(ans,x);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
signed main(){
	int a,b;
	cin>>a>>b;
	if(b>=0&&a<=0)puts("Zero");
	else if(min(-1,b)-a>=0&&(min(-1,b)-a)%2==0)puts("Negative");
	else puts("Positive");
}


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

using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;

    vector<int> a(n, 0);
    for (int i=0; i<q; i++) {
        int in_a;
        cin >> in_a;
        a[in_a-1] += 1;
    }

    for (int i=0; i<n; i++) {
        if (k - (q - a[i]) > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}


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

using namespace std;

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

const int inf = 1e9;
const ll inf64 = 1e18;

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m, sz;

    cin >> n >> m >> sz;

    int x, y;
    cin >> x >> y;

    string s, t;

    cin >> s >> t;

    string q = "";

    for (int i = 0; i < sz; i++) {
        q.push_back(s[i]);
        q.push_back(t[i]);
    }

    sz <<= 1;

    {
        int mx = 0, b = y;
        for (int i = 0; i < sz; i++) {
            if (i % 2 == 0 && q[i] == 'L') {
                if (b == 1) {
                    cout << "NO\n";
                    return 0;
                } else {
                    b--;
                }
            }
            if (i % 2 == 1 && q[i] == 'R') {
                b = min(m, b + 1);
            }
        }
    }

    {
        int mx = 0, b = y;
        for (int i = 0; i < sz; i++) {
            if (i % 2 == 0 && q[i] == 'R') {
                if (b == m) {
                    cout << "NO\n";
                    return 0;
                } else {
                    b++;
                }
            }
            if (i % 2 == 1 && q[i] == 'L') {
                b = max(1, b - 1);
            }
        }
    }

    {
        int mx = 0, b = x;
        for (int i = 0; i < sz; i++) {
            if (i % 2 == 0 && q[i] == 'U') {
                if (b == 1) {
                    cout << "NO\n";
                    return 0;
                } else {
                    b--;
                }
            }
            if (i % 2 == 1 && q[i] == 'D') {
                b = min(n, b + 1);
            }
        }
    }

    {
        int mx = 0, b = x;
        for (int i = 0; i < sz; i++) {
            if (i % 2 == 0 && q[i] == 'D') {
                if (b == n) {
                    cout << "NO\n";
                    return 0;
                } else {
                    b++;
                }
            }
            if (i % 2 == 1 && q[i] == 'U') {
                b = max(1, b - 1);
            }
        }
    }

    cout << "YES\n";

    return 0;
}

Measured memory_bytes: 1432
#pragma GCC optimize("Ofast")
#include<stdio.h>
#define lim 100000
int min(int a, int b) {
	if (a > b) return b;
	else return a;
}
int main() {
	int N;
	
	int his[lim] = { -1 };
	int DP[lim];
	scanf("%d", &N);
	for (int i = 0; i < N; i++)scanf("%d", &his[i]);
	DP[0] = 0;
	DP[1] = abs(his[0] - his[1]);
	int i;
	for (i = 2; i < N; i++) {
		DP[i] = min( (DP[i - 1] + abs(his[i - 1] - his[i]) ), DP[i - 2] + abs(his[i - 2] - his[i]) );
	}
	printf("%d", DP[N-1]);


}

Measured memory_bytes: 896
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, cnt_odd, chars[26];
vector<int> cindx[26];
string s;

int bit[200009]={0};

int sum(int i){int s=0;while(i>0){s+=bit[i];i-=i&-i;}return s;}
void add(int i,int x){while(i<=200009){bit[i]+=x;i+=i&-i;}}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>s;
    N=s.size();
    
    rep(i,N) chars[s[i]-'a']++;
    rep(i,26) cnt_odd+=chars[i]%2;
    
    if(cnt_odd>1){
        cout1(-1);
        return 0;
    }
    
    rep(i,N){
        int cnum=s[i]-'a';
        cindx[cnum].push_back(i);
    }
    
    int len=N-1;
    ll total=0;
    rep(s,N/2){
        int t=N-1-s, best, mn=INF;
        pii p;
        rep(i,26){
            if(cindx[i].size()>1){
                int si = cindx[i].front(); 
                int ti = cindx[i].back();
                
                int left = si-sum(si+1);
                int right = ti-sum(ti+1);
                int d = left+(len-right);
                if(mn>d){
                    mn=d;
                    best=i;
                }
            }
        }
        total+=mn;
        add(cindx[best][0]+1,1);
        add(cindx[best].back()+1,1);
        cindx[best].erase(cindx[best].begin());
        cindx[best].pop_back();
        len-=2;
    }
    cout1(total)
}

Measured memory_bytes: 2320
# ビンゴを用意x3行
A = [list(map(int, input().split())) for _ in range(3)]
# N個呼ぶ
N = int(input())

for _ in range(N):
    b = int(input())
    for y in range(3):
        for x in range(3):
            # リストAのy行x列目がbと一緒なら-1印をつける
            if A[y][x] == b:
                A[y][x] = -1
# たてビンゴの処理　もし1回もfalseにならなかったらyes
for y in range(3):
    f = True
    for x in range(3):
        # 上の処理で-1がビンゴとして
        if A[y][x] != -1:
            f = False
    if f:
        print('Yes')
        exit()
# 横ビンゴの処理
for x in range(3):
    f = True
    for y in range(3):
        if A[y][x] != -1:
            f = False
    if f:
        print('Yes')
        exit()
# 1,1 2,2 3,3 右斜めビンゴの処理
f = True
for x in range(3):
    if A[x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()
# xが2のとき0、１の時1、0の時2と左斜めビンゴの処理
f = True
for x in range(3):
    if A[2 - x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()

print('No')


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

 int main() {
   int N, M;
   cin >> N >> M;
   cout << (N * (N - 1) + M * (M - 1)) / 2 << endl;
 }


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		String[] A = new String[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.next();
		}
		String[] B = new String[M];
		for (int i = 0; i < M; i++) {
			B[i] = sc.next();
		}

		for (int i = 0; i < N - M + 1; i++) {
			int fromIndex = -1;
			while (true) {
				fromIndex = A[i].indexOf(B[0], fromIndex + 1);
				if (fromIndex == -1) {
					break;
				}

				boolean found = true;
				for (int j = 1; j < M; j++) {
					if (A[i + j].indexOf(B[j], fromIndex) != fromIndex) {
						found = false;
						break;
					}
				}

				if (found) {
					System.out.println("Yes");
					return;
				}
			}
		}

		System.out.println("No");
		return;
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 22996
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
		if (a.equals("ABC")) {
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}
	}
	
}

Measured memory_bytes: 35776
#include <bits/stdc++.h>
/**
*   author: j o s e m a g o
*   date:
**/
using namespace std;
#pragma GCC optimize ("Ofast")
#define f first
#define s second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"

typedef double db;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;
const int JJJ = 100009;




int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

    ios_base::sync_with_stdio(0); cin.tie(0);

    int N;
    cin >> N;
    vector<int>h(N);
    for(int i = 0;i < N;i++){
        cin >> h[i];
    }
    vector<int>dp(N,INT_MAX);
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    for(int i = 2;i < N;i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[N-1];







    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        StringBuilder s = new StringBuilder(sc.nextLine());
        StringBuilder t = new StringBuilder(sc.nextLine());
        int ovCount = 0;
        for (int i = 0; i < N; ++i) {
            if (s.substring(i).equals(t.substring(0, N - i))) {
                ovCount = N - i;
                break;
            }
        }
        System.out.println((s.length() + t.length() - ovCount));
    }
}

Measured memory_bytes: 21844
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from bisect import insort

class BIT():
 
    def __init__(self, n):
        '''
        n = 要素数
        添字は i = 0 ~ n-1 となる
        '''
        self.n = n
        self.bit = [0] * (n + 1)
 
    def add(self, i, x):
        '''i番目の要素にxを加算する'''
        i = i + 1
        while i <= self.n:
            self.bit[i] += x
            i += i & -i
 
    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s
 
    def get(self, i, j):
        '''[i, j)の和を求める'''
        return self._sum(j) - self._sum(i)
  
def compress(list1):
    list2 = sorted(set(list1))
    memo = {value : index for index, value in enumerate(list2)}
    return memo, len(list2)

q = int(readline())
info = [list(map(int, input().split())) for i in range(q)]
 
#座圧する
li1 = []
for i in range(q):
    if info[i][0] == 1:
        li1.append(info[i][1])
        
memo, len_memo = compress(li1)

def median():
    ok = len_memo
    ng = 0
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if 2 * bit1.get(mid, len_memo) <= cnt :
            ok = mid
        else:
            ng = mid
    return memo_inv[ng]
  
#値を管理するBIT
bit = BIT(len_memo)
#要素数を管理するBITに
bit1 = BIT(len_memo)
memo_inv = dict([(v,k) for k,v in memo.items()])
  
s = 0
cnt = 0
for i in range(q):
  que = info[i]
  if que[0] == 1:
    a,b,c = que
    s += c
    cnt += 1
    bit.add(memo[b],b)
    bit1.add(memo[b], 1)
  else:
    d = median()
    sum1 = bit.get(0, memo[d])
    num1 = bit1.get(0, memo[d])
    sum2 = bit.get(memo[d], len_memo)
    num2 = bit1.get(memo[d], len_memo)
    print(d, abs(num1*d- sum1) + abs(num2*d - sum2) + s)

Measured memory_bytes: 124880
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll MOD = (ll)1e9 + 7; // 998244353
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	string S; cin >> S;
	int ans = 0, N = S.size(), L = 0, R = N - 1;
	while (L < R) {
		if (S[L] == S[R]) {
			L++;
			R--;
		}
		else if(S[L] != 'x' && S[R] != 'x'){
			cout << -1 << endl;
			return 0;
		}
		else if(S[L] == 'x' && S[R] != 'x') {
			ans++;
			++L;
		}
		else if(S[L] != 'x' && S[R] == 'x') {
			ans++;
			--R;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
def find_divisors(n):
    divisors = set()
    
    div = 1
    while div ** 2 <= n:
        if n % div == 0:
            divisors.add(div)
            divisors.add(n // div)
        div += 1
    
    return divisors


def main():
    n = int(input())
    
    res = 0
    
    for k in find_divisors(n) - {1}:
        t = n
        while t % k == 0:
            t //= k
        if t % k == 1:
            res += 1
    
    res += len(find_divisors(n - 1)) - 1
    
    print(res)


main()


Measured memory_bytes: 3952
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#define mp make_pair
#define pb push_back
using namespace std;

namespace Header_Template {
  typedef long long li;
  template<class T>inline void read(T &x) {
    x = 0;
    T tmp = 1;
    char c = getchar();
    while ((c < '0' || c > '9') && c != '-') c = getchar();
    if (c == '-') tmp = -1, c = getchar();
    while (c >= '0' && c <= '9')
      x = (x << 1) + (x << 3) + c - '0', c = getchar();
    x *= tmp;
  }
  template<class T>inline void Max(T &x, T y) {
    if (y > x) x = y;
  }
  template<class T>inline void Min(T &x, T y) {
    if (y < x) x = y;
  }
}
using namespace Header_Template;

const int Mod = 1e9 + 7;
inline int Add(int x, int y) { x += y; return x >= Mod ? x - Mod : x; }
inline int Sub(int x, int y) { x -= y; return x < 0 ? x + Mod : x; }
inline int Mul(int x, int y) { return 1LL * x * y % Mod; }

const int N = 5010;
int n, sz[N], f[N][N][2], tmp[N][N][2];
int fac[N];
vector<int> g[N];

void Dfs(int x, int pre) {
  sz[x] = f[x][1][0] = 1;
  for (int y : g[x]) {
    if (y == pre) continue;
    Dfs(y, x);

    for (int i = 1; i <= sz[x] + sz[y]; ++i)
      tmp[x][i][0] = tmp[x][i][1] = 0;
    for (int i = 1; i <= sz[x]; ++i)
      for (int j = 1; j <= sz[y]; ++j) {
        tmp[x][i][0] = Add(tmp[x][i][0], Mul(Mul(f[x][i][0], f[y][j][1]), fac[j]));
        tmp[x][i][0] = Add(tmp[x][i][0], Mul(Mul(f[x][i][1], f[y][j][0]), fac[j]));
        tmp[x][i][1] = Add(tmp[x][i][1], Mul(Mul(f[x][i][0], f[y][j][0]), fac[j]));
        tmp[x][i][1] = Add(tmp[x][i][1], Mul(Mul(f[x][i][1], f[y][j][1]), fac[j]));

        tmp[x][i + j][0] = Add(tmp[x][i + j][0], Mul(f[x][i][0], f[y][j][0]));
        tmp[x][i + j][0] = Add(tmp[x][i + j][0], Mul(f[x][i][1], f[y][j][1]));
        tmp[x][i + j][1] = Add(tmp[x][i + j][1], Mul(f[x][i][0], f[y][j][1]));
        tmp[x][i + j][1] = Add(tmp[x][i + j][1], Mul(f[x][i][1], f[y][j][0]));
      }
    for (int i = 1; i <= sz[x] + sz[y]; ++i)
      for (int j = 0; j < 2; ++j)
        f[x][i][j] = tmp[x][i][j];
    
    sz[x] += sz[y];
  }
}
int main(void) {
  read(n);
  fac[0] = 1;
  fac[1] = 0;
  for (int i = 2; i <= n; ++i)
    fac[i] = Mul(fac[i - 2], i - 1);
  for (int i = 1, x, y; i < n; ++i) {
    read(x), read(y);
    g[x].pb(y);
    g[y].pb(x);
  }
  Dfs(1, 0);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = Add(ans, Mul(f[1][i][0], fac[i]));
    ans = Sub(ans, Mul(f[1][i][1], fac[i]));
  }
  printf("%d\n", ans);
  
  return 0;
}


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

int main()
{
  int64_t A, B;
  cin >> A >> B;
  
  int64_t H, L;
  int64_t C;
  int64_t r;
  
  if(A >= B)
  {
    H = A;
    L = B;
  }
  else
  {
    H = B;
    L = A;
  }
  r = H % L;
  while(r)
  {
    H = L;
    L = r;
    r = H % L;
  }
  cout << A * B / L << endl;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  int i;
  for(i = 0; i < m; i++)cin >> a.at(i) >> b.at(i);
  vector<pair<int, int> > p(m);
  for(i = 0; i < m; i++)p.at(i) = make_pair(b.at(i), a.at(i));
  sort(p.begin(), p.end());
  int rm = -1;
  int ans = 0;
  for(i = 0; i < m; i++)
  {
    if(p.at(i).second > rm || ans == 0)
    {
      rm = p.at(i).first-1;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int k;
  cin >> k;
  ll ans = 0;
  rep3(a, 1, k + 1) rep3(b, 1, k + 1) rep3(c, 1, k + 1) {
    ans += gcd(gcd(a, b), c);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {
  private static final long MAX = (long)1e18;
  
  public static void main(String args[]) {
  	long multiplication = 1;
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    
    for (int i=0; i<n; i++) {
      long num = in.nextLong();
      if (num == 0) {
        System.out.print(0);
        return;
      } 
      
      if (multiplication != -1) {
        if (num > MAX / multiplication) {
          multiplication = -1;
        } else {        
          multiplication *= num;
        }
      }
    }
    
    if (multiplication > MAX) {
        System.out.print(-1);
    } else {
      System.out.print(multiplication);
    }
  }
}


Measured memory_bytes: 59584
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0,f=1;char c;
	while((c=tc())<'0'||c>'9')c=='-'?f=-1:0;
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a*f;
}
int n,a[100005],ans,now=0;
int main(void){
	register int i;
	n=read(),a[0]=a[n+1]=0;
	for(i=1;i<=n;++i)a[i]=read();
	for(i=1;i<=n+1;++i)ans+=abs(a[i]-now),now=a[i];
	for(i=1;i<=n;++i)
		printf("%d\n",ans+abs(a[i-1]-a[i+1])-abs(a[i-1]-a[i])-abs(a[i+1]-a[i]));
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  for(char &c : s){
    char after = (char)(c+N);
    if(after > 'Z'){
      after -= 'Z'+1;
      after += 'A';
    }
    cout << after;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
long long int MOD = 1000000007;
using namespace std;

typedef pair<long long int, long long int> P;

int main(){
	
	int n, dum;
	cin >> n;
	dum = n;
	
	vector<int> v;
	
	for(int i = 2; i * i <= n; i++){
		if(dum % i == 0){
			v.push_back(i);
		}
		while(dum % i == 0){
			dum /= i;
		}
	}
	if(dum != 1){
		v.push_back(dum);
	}
	
	int num = v.size();
	long long int ans = 0;
	
	for(int i = 1; i < (1 << num); i++){
		int hoge = i;
		int ret = 1;
		int cnt = 0;
		for(int j = 0; j < num; j++){
			if(hoge % 2 == 1){
				ret *= v[j];
				cnt++;
			}
			hoge /= 2;
		}
		//cout << ret << endl;
		if(cnt % 2 == 1){
			ans += n / ret;
		}else{
			ans -= n / ret;
		}
	}
	
	cout << n - ans << endl;
	
	return 0;
}


Measured memory_bytes: 3160
#include <stdio.h>
#define IMF 100000

void maxHeapify(int);
void buildMaxHeap();
void maxHeapInsert(int);
void heapIncreaseKey(int,int);
int  heapExtractMax();
int S[2000000];
int size=0;

int main(){
  int i,n,max;
  char com[20];


  while(1){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&n);
      maxHeapInsert(n);
    }
    if(com[0] == 'e' && com[1] == 'x'){
      max = heapExtractMax();
      printf("%d\n",max);
    }
    if(com[0] == 'e' && com[1] == 'n'){
      break;
    }
  }
  return 0;
    
  }

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void maxHeapify(int i){
  int l,r,largest,hozon;
  l = left(i);
  r = right(i);

  if(l <= size && S[l]>S[i]){
    largest = l;
  }
  else largest = i;
  if(r <= size && S[r]>S[largest]){
    largest = r;
  }
  if (largest != i){
    hozon = S[i];
    S[i] = S[largest];
    S[largest] = hozon;
    maxHeapify(largest);
  }
  
}


void maxHeapInsert(int key){
  size++;
  S[size] = -IMF;
  heapIncreaseKey(size,key);
}

void heapIncreaseKey(int size,int key){
  int hozon;
  if(key < S[size]){
    printf("new hey is smaller than current key");
  }
  S[size] = key;
  while ( size > 1  && S[parent(size)]<S[size]){
    hozon = S[size];
    S[size] = S[parent(size)];
    S[parent(size)] = hozon;
    size = parent(size);
  }
}

int heapExtractMax(){
  int max;
  if (size < 1){
    printf("heap underflow");
  }
  max = S[1];
  S[1] = S[size];
  size--;
  maxHeapify(1);
  return max;
}



Measured memory_bytes: 5604
#include <stdio.h>
#include <string.h>
#include <ctype.h>

typedef struct {
	char	card;
	char	dmy[3];
	char*	fwd_p;
	char*	bk_p;
} CARD_T;

void func_init(char* data_p, int size, CARD_T *card_p,CARD_T **top_p,CARD_T **end_p)
{
	int i;

	memset(card_p,'\0',sizeof(CARD_T) * size);
	*top_p=0;
	*end_p=0;
	for (i=0 ; i<size ; i++,card_p++,data_p++) {
		card_p->card = *data_p;
		if (i == (size-1)) {
			card_p->fwd_p  = NULL;
			card_p->bk_p   = (char*)(card_p-1);
			*end_p = card_p;
		}
		else {
			card_p->fwd_p  = (char*)(card_p+1);
			if (i!=0) {
				card_p->bk_p  = (char*)(card_p-1);
			}
			else {
				card_p->bk_p  = NULL;
				*top_p = card_p;
			}
		}
	}
}
void func_get(int num,CARD_T *top_p,CARD_T *end_p,char *out_p)
{
	int i;

	CARD_T *wk_p;
	wk_p = top_p;
	for (i=0 ;i<num; i++) {
		out_p[i] = wk_p->card;
		wk_p = (CARD_T*)wk_p->fwd_p;
	}
	out_p[i]='\0';
}

void func_cut(int cut_num,CARD_T **top_p,CARD_T **end_p)
{
	CARD_T *wk_p,*secd_wk_p;
	int 	i;

	/**?????????????°?????????§??????**/
	(*end_p)->fwd_p = (char*)*top_p;
	secd_wk_p = (CARD_T*)((*top_p)->fwd_p);  //??????????????????????????????????????????????????????
	(*top_p)->bk_p    = (char*)*end_p;

	/**cut_num??????????????§???????????´??°**/
	wk_p = *top_p;
	for (i=1 ; i<cut_num ; i++) {
		wk_p = (CARD_T*)wk_p->fwd_p;
	}
	*top_p = (CARD_T*)wk_p->fwd_p;
	wk_p->fwd_p   = NULL;

	(*top_p)->bk_p = NULL;
	*end_p = wk_p;
}



int main()
{
	char data[256];
	int  m;
	int  h[100];
	static CARD_T card[256];
	static CARD_T *top_p;
	static CARD_T *end_p;
	char out_dt[256];
	int	 i;
	int  w_size;

	while(1) {
		scanf("%s",data);
		if (data[0]=='-') {
			return 0;
		}
		w_size  = strlen(data);
		scanf("%d",&m);
		for (i=0 ; i<m ; i++) {
			scanf("%d",&(h[i]));
		}

		func_init(data,w_size,card,&top_p,&end_p);

		for (i=0 ; i<m ; i++) {
			func_cut(h[i],&top_p,&end_p);
		}
		func_get(w_size,top_p,end_p,out_dt);
		printf("%s\n",out_dt);
	}
}

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000001
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  int n, x;
  cin >> n >> x;
  int m[n];
  REP(i, n) cin >> m[i];
  sort(m, m+n);
  int sum = 0;
  REP(i, n) sum += m[i];
  int ans = n;
  x -= sum;
  ans += x/m[0];
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

#define int ll

const int INF = 1e9;

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int s;cin >> s;
	cout << "0 0 ";
	if(s<=INF){
		cout << s << " 0 0 1" << "\n";
		return 0;
	}
	int l=0, r=INF+100;
	while(r-l>1){
		int mid = (l + r)/2;
		if(mid*mid <= s)
			l = mid;
		else
			r = mid;
	}
	int sq = l;
	if(sq*sq == s){
		cout << sq << " 0 0 " << sq << "\n";
		return 0;
	}
	if((sq+1)*sq >= s){
		cout << sq+1 << " 1 " << (sq+1)*sq-s << " " << sq << "\n";
		return 0;
	}
	cout << sq+1 << " 1 " << (sq+1)*(sq+1)-s << " " << sq+1 << "\n";
 	return 0;
}
















Measured memory_bytes: 256
while True:
    a, op, b = list(map(str, input().split()))
    A = int(a)
    B = int(b)
    if op == "?" :
        break
    if op == "+":
        ans = A + B
    elif op == "-":
        ans = A- B
    elif op == "/":
        ans = A/B
    elif op == "*":
        ans = A*B
    print(int(ans))


Measured memory_bytes: 5592
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
  int a[15][15]={0};
  int x,y,size,c=0,m=0;
  while(scanf("%d,%d,%d",&x,&y,&size) != EOF){
    a[x][y]++;
    a[x-1][y]++;
    a[x+1][y]++;
    a[x][y-1]++;
    a[x][y+1]++;
    if(size==1) continue;
    a[x-1][y-1]++;
    a[x+1][y-1]++;
    a[x-1][y+1]++;
    a[x+1][y+1]++;
    if(size==2) continue;
    a[x-2][y]++;
    a[x+2][y]++;
    a[x][y-2]++;
    a[x][y+2]++;
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(!a[i][j]) c++;
      m=max(m,a[i][j]);
    }
  }
  printf("%d\n%d\n",c,m);
}


Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
int a[4005],b[4005],l[4005],r[4005],mx[4005];
char sa[2005],sb[2005];
int main()
{
	scanf("%s%s",sa,sb);int n=strlen(sa);
	for(int i=1;i<=n;i++)a[i]=sa[i-1]-'0',b[i]=sb[i-1]-'0',a[n+i]=a[i];
	bool f=0;
	for(int i=1;i<=n;i++)if(b[i]==1)f=1;
	for(int i=1;i<=n;i++)
	{
		bool ff=1;
		for(int j=1;j<=n;j++)if(a[i+j]!=b[j])ff=0;
		if(ff){f=1;break;}
	}
	if(!f){puts("-1");return 0;}
	for(int i=1;i<=n;i++)
	{
		l[i]=b[i]?0:n+1;r[i]=b[i]?0:n+1;
		for(int j=1;j<=n;j++)if(i!=j&&b[j])
		{
			if(i<j)r[i]=min(r[i],j-i),l[i]=min(l[i],n+i-j);
			else l[i]=min(l[i],i-j),r[i]=min(r[i],n-i+j);
		}
	}
	for(int i=1;i<=n;i++)l[n+i]=l[i],r[n+i]=r[i]; 
	int ans=5*n;
	for(int i=0;i<=n;i++)
	{
		int res=0;
		for(int j=1;j<=n;j++)if(a[j+i]!=b[j])res++;
		for(int j=0;j<=n;j++)mx[j]=0;
		for(int j=1;j<=n;j++)if(a[j+i]!=b[j]&&l[j+i])mx[l[j+i]-1]=max(mx[l[j+i]-1],r[j+i]);
		for(int j=n;j>=1;j--)mx[j-1]=max(mx[j-1],mx[j]);
		int rot=5*n;
		for(int j=0;j<=n;j++)
		{
			int tl=-j,tr=mx[j],p=-i,t=5*n,t1=5*n;
			if(tl<=p&&p<=tr)t1=min(tr-tl+tr+p-tl,tr-tl-tl+tr-p);
			else if(tl>p)t1=tr+tr-p;
			p+=n;
			if(tl<=p&&p<=tr)t=min(tr-tl+tr+p-tl,tr-tl-tl+tr-p);
			else if(tr<p)t=p-tl-tl;
			rot=min(rot,min(t,t1));
		}
		ans=min(ans,res+rot);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v, res;
    int c = 0;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        c ^= t;
        v.push_back(t);
    }
    for (int i = 0; i < n; i++) {
        cout << (c ^ v[i]) << " ";
    }
}


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

vector<int> A(200001, 0);

void So(int x) {
	if (x == 1) return;
	A[0]++;
	int y = sqrt(x);
	for (int i = 2;i <= y;i++) {
		if (x % i == 0) {
			A[i - 1]++;
			if (i*i != x)
				A[x / i - 1]++;
		}
	}
}

int main() {
	int N, M = 0;
	cin >> N;

	for (int i = 0;i < N;i++)
		cin >> A[i];

	for (int i = N - 1;i >= 0;i--) {
		A[i] %= 2;
		if (A[i]) {
			M++;
			So(i + 1);
		}
	}
	cout << M << endl;
	for (int i = 0;i < N;i++) {
		if (A[i]) {
			cout << i + 1 << " ";
		}
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n;
	cin >> n;
	string a, b;
	cin >> a >> b;
	rep(i, n) {
		if (b.substr(0, n - i) == a.substr(i, n - i)) {
			cout << n + i<<endl;
			return 0;
		}
	}
	cout << n * 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    ll m;cin>>m;
    vector<int> keta(n,-1);
    For(i,0,m){
        int s,c;cin>>s>>c;
        if(keta[s-1]>-1&&keta[s-1]!=c){
            cout<<-1<<endl;
            return;
        }
        keta[s-1]=c;
    }
    if(keta[0]==0&&n>1){
        cout<<-1<<endl;
        return;
    }
    if(keta[0]==-1) {
        if(n>1) keta[0]=1;
        else keta[0]=0;
    }
    For(i,1,n){
        if(keta[i]==-1) keta[i]=0;
    }
    For(i,0,n) cout<<keta[i];
    cout<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = h[0], k = h[1], s = h[2], M = 1000000000;
		Console.WriteLine(string.Join(" ", Enumerable.Repeat(s, k).Concat(Enumerable.Repeat(s == M ? 1 : M, n - k))));
	}
}


Measured memory_bytes: 37472
def function(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n + 1

s = int(input())
a = [s]
check = True
m = 1

while check:
    if function(a[m-1]) in a:
        check = False
    else:
        a.append(function(a[m-1]))
        m += 1
print(m+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
    ll k,t,sum=0;cin>>k>>t;
    vector<ll> v(t);
    rep(i,t){
        cin>>v[i];
        sum+=v[i];
    }
    sort(all(v));

    sum-=v[t-1];

    cout<<max(0ll,v[t-1]-1-sum)<<endl;


    
}

Measured memory_bytes: 256