akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

int ab[5], c;

int main() {
    for (int i = 0; i < 2; ++i) {
        scanf("%d", &ab[i]);
    }
    scanf("%d", &c);
    sort(ab, ab + 2);
    if (c >= ab[0] && c <= ab[1]) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100

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

int main()
{
	int n , p[N+1] , m[N+1][N+1];
	scanf("%d",&n);
	for( int i = 1; i <= n; i++)
	{
		scanf("%d %d",&p[i-1],&p[i]);
	}
		for(int i = 1; i <= n; i++) m[i][i] = 0;
		for(int l = 2; l <= n; l++)
		{
			for(int i = 1; i <= n - l + 1; i++)
			{
				int j = i + l -1;
				m[i][j] = ( 1 << 21);
				for(int k = i; k <= j -1 ; k++)
				{
					m[i][j] = min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
				}
			}
		}
		printf("%d\n",m[1][n]);
		return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int maxN = 500 + 9;
const double EPS = 1e-9;

int n, m;
int a[maxN][maxN];
vector<pair<pair<int, int>, pair<int, int> > > ans;

void read(){
  cin >> n >> m;
  for(int i = 1; i <= n; i++)
    for(int j = 1; j <= m; j++)
      cin >> a[i][j];
}

void solv(){
  for(int i = 1; i <= n; i++){
    for(int j = 1; j + 1 <= m; j++){
      if(a[i][j] & 1){
        a[i][j]--;
        a[i][j + 1]++;
        ans.push_back(make_pair(make_pair(i, j), make_pair(i, j + 1)));
      }
    }
  }

  for(int i = 1; i + 1 <= n; i++){
    if(a[i][m] & 1){
      a[i][m]--;
      a[i + 1][m]++;
      ans.push_back(make_pair(make_pair(i, m), make_pair(i + 1, m)));
    }
  }

  int L = ans.size();
  cout << L << '\n';
  for(int i = 0; i < L; i++){
    cout << ans[i].first.first << ' ' << ans[i].first.second << ' ' << ans[i].second.first << ' ' << ans[i].second.second << '\n';
  }

//  for(int i = 1; i <= n; i++){
//    for(int j = 1; j <= m; j++){
//      cerr << a[i][j] << ' ';
//    }
//    cerr << '\n';
//  }
}

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

  #ifdef DEBUG
    freopen("in.txt", "r", stdin);
  #endif

  read();
  solv();

  return 0;
}


Measured memory_bytes: 5232
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    const char White = '.';
    const char Black = '#';

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var m = int.Parse(spl[1]);

        var bo = new HashSet<int>[n];
        for (int i = 0; i < n; i++)
            bo[i] = new HashSet<int>();

        for(int i=0; i<m; i++) {
            spl = input.ReadLine().Split(' ');
            var a = int.Parse(spl[0]) - 1;
            var b = int.Parse(spl[1]) - 1;

            bo[a].Add(b);
            bo[b].Add(a);
        }

        foreach(var x in bo[0]) {
            if (bo[x].Contains(n - 1)) return "POSSIBLE";
        }

        return "IMPOSSIBLE";
    }


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


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

int dis(P x,P y){
  return abs(x.first-y.first)+abs(x.second-y.second);
}

int main(){
  int h,w,d;
  cin>>h>>w>>d;
  P b[h*w+1];
  rep(i,0,h){
    rep(j,0,w){
      int a;
      cin>>a;
      b[a]=P(i,j);
    }
  }
  int sum[h*w+1];
  sum[0]=0;
  rep(i,1,h*w+1){
    if(i<=d) sum[i]=0;
    else sum[i]=sum[i-d]+dis(b[i],b[i-d]);
  }
  int q;
  cin>>q;
  rep(i,0,q){
    int l,r;
    cin>>l>>r;
    cout<<sum[r]-sum[l]<<endl;
  }
}

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

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll ans2 = 0;
    for(ll i = 1;i*i<=n;++i){
        ll val = i;
        if(n%val==0){
            val--;
            if(val>0 and n/val == n%val) ans2 += val;
            if(n/i != i){
                val = (n/i) - 1;
                if(val>0 and n/val == n%val) ans2 += val;
            }
        }
    }
    cout << ans2 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

public class Example
{
	public static void Main ()
	{
		string line;
		List <string> resultStr = new List<string> ();

		do { 
			line = Console.ReadLine ();
			if (line != null){
				resultStr.Add (line);

				if (resultStr.Count >= 200){
					break;
				}
			}
		} while (line != null);   

		foreach (string r in resultStr) {

			string[] tempStr = r.Split (' ');

			int resultInteger = int.Parse (tempStr [0]) + int.Parse (tempStr [1]);
			Console.WriteLine (resultInteger.ToString().Length);

		}

	}
}

Measured memory_bytes: 5704
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{    
    int n;
    vector<int> d;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int tmp;
        cin>>tmp;
        d.push_back(tmp);
    }
    sort(d.begin(),d.end());
    int center=n/2;
    int center_min=d[center-1];
    int center_max=d[center];
    if(center_min==center_max)
    {
        cout<<0<<endl;
        return 0;
    }
    else
    {
        vector<int> targets;
        for(int i=center_min+1;i<=center_max;i++)
        {
            targets.push_back(i);
        }
        cout<<targets.size()<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 1400
from bisect import bisect_left


INF = 10 ** 12
A, B, Q = map(int, input().split())
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
Q = [int(input()) for _ in range(Q)]


for q in Q:
    ps = bisect_left(S, q)
    s1, s2 = S[ps - 1], S[ps]

    pt = bisect_left(T, q)
    t1, t2 = T[pt - 1], T[pt]

    ans = INF
    for s in (s1, s2):
        for t in (t1, t2):
            path1 = abs(q - s) + abs(s - t)
            path2 = abs(q - t) + abs(s - t)
            ans = min(ans, path1, path2)
    print(ans)


Measured memory_bytes: 86104
#include <iostream>
using namespace std;
int main(){
  int n, ans=0;
  cin >> n;
  int v[n], c[n];
  for(int i=0; i<n; i++)
    cin >> v[i];
  for(int i=0; i<n; i++)
    cin >> c[i];

  for(int i=0; i<n; i++)
    if(v[i]>c[i]) ans+=(v[i]-c[i]);

  cout << ans;
  return 0;
}


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

int main(){
  int X;
  cin >> X;
  if(X==2){
    cout << 2 << endl;
    return 0;
  }
  for(int i=X;;i++){
    bool flag=true;
    if(i%2==0){
      continue;
    }
    for(int j=3;j<=sqrt(X);j++){
      if(i%j==0){
        flag=false;
        break;
      }
    }
    if(flag){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>


typedef long long LL;
using namespace std;
 
void read(int &v) {
    int k = 0, l = 1;
    char ch;
    ch = getchar();
    while (ch > '9' || ch < '0') {
        if (ch == '-')
            l = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') k = k * 10 + ch - '0', ch = getchar();
    v = l * k;
}

void print(int v) {
    if (v < 0)
        putchar('-'), v = -v;
    if (v > 9)
        print(v / 10);
    putchar(v % 10 + '0');
}

int max(int a, int b) {
        return a > b ? a : b;
}

int min(int a, int b) {
        return a < b ? a : b;
}

static int n;
static int a[200005], b[200005];
static int tot = 0;

int main() {
        read(n);
        for (int i=1;i<=n;++i){
            read(a[i]);
        }
        for (int i=n;i>=1;--i){
            if ((i << 1) > n) b[i] = a[i];
            else{
                int sum=0;
                for (int j =i+i;j<=n;j+=i){
                    sum=(sum+b[j])%2;
                }
                b[i]=sum^a[i];
            }
        }
        int tot=0;
        for (int i=1;i<=n;++i) tot+=b[i];
        print(tot), puts("");
        for (int i=1;i<=n;++i){
            if (b[i]) printf("%d ",i);
        }
    


        return 0;
}

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


int main(){
    int h,a,ans = 0,value;

        cin>> h >> a;
            while(a--){
                cin>> value;
                ans += value;
            }
        if(ans>=h)cout<< "Yes" <<endl;
        else cout<< "No" <<endl;

          //  cout<< ans <<endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x,y;cin>>x>>y;
  ll cnt = 0;
  while(x <= y){
    cnt++;
    x *= 2;
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 256
sz;
k;
char x[18],buf[2200000];
A,B,p,T;
long ans;
main()
{
	sz=read(0,buf,2200000);
	sz-=2;
	while(1)
	{
		A=B=0;
		p=1;
		while(1)
		{
			k=buf[sz--];
			if(k<'0')break;
			B+=(k-'0')*p;
			p*=10;
		}
		p=1;
		if(sz<0)break;
		while(1)
		{
			k=buf[sz--];
			if(k<'0')break;
			A+=(k-'0')*p;
			p*=10;
		}
		ans=(A+ans+B-1)/B*B-A;
	}
	sz=17;
	do
	{
		x[--sz]=ans%10+'0';
		ans/=10;
	}while(ans);
	write(1,x+sz,17-sz);
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include<string>
using namespace std;
typedef long long ll;
typedef vector < int > vi;
typedef pair<int,int> pi;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define re(i,a,b) for(ll i=a;i<b;i++)
//add below to remove endl in input just before getline()
//cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');
int main(){
	//ios::sync_with_stdio(0);cin.tie(0);
	//freopen("input.txt", "r", stdin);
	string s,t;cin>>s>>t;int c=0;
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i])c++;
		}
		cout<<c;
return 0;}


Measured memory_bytes: 3900
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <utility>
#include <bitset>
#include <functional>
#include <algorithm>

int main() {
    long long n, t;
    std::cin >> n;
    std::vector<long long> x(n);
    std::vector<std::deque<long long>> c(n);
    for (auto i = 1ll; i < n; i++) {
        std::cin >> t;
        t--;
        c[t].push_back(i);
    }
    for (auto i = 0ll; i < n; i++) std::cin >> x[i];

    std::deque<long long> q, q2;
    q.push_back(0);
    q2.push_back(0);
    while (!q2.empty()) {
        auto curr = q2.front();
        for (auto el : c[curr]) {
            q.push_back(el);
            q2.push_back(el);
        }
        q2.pop_front();
    }

    /* costs[i].first >= costs[i].second */
    std::vector<std::pair<long long, long long>> costs(n);
    while (!q.empty()) {
        auto curr = q.back();
        q.pop_back();
        auto chsum = 0ll, sum = 0ll;
        if (c[curr].size() == 0) {
            costs[curr] = { x[curr], 0 };
            continue;
        }
        for (auto ch : c[curr]) {
            chsum += costs[ch].second;
            sum += costs[ch].first + costs[ch].second;
        }
        if (chsum > x[curr]) {
            std::cout << "IMPOSSIBLE" << std::endl;
            return 0;
        }
        std::multiset<long long, std::greater<>> candidates;
        for (auto ch : c[curr]) {
            auto diff = costs[ch].first - costs[ch].second;
            if (diff <= x[curr] - chsum) candidates.insert(diff);
        }
        std::bitset<5000> bs;
        for (auto c : candidates) {
            bs |= (bs << c);
            bs[c] = true;
        }
        for (auto i = x[curr] - chsum; i >= 0; i--) {
            if (bs[i]) {
                chsum += i;
                break;
            }
        }
        costs[curr] = { std::max(x[curr], sum - chsum), std::min(x[curr], sum - chsum) };
    }
  
    std::cout << "POSSIBLE" << std::endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

int main() {
	intt N; std::cin >> N;
	std::map<intt, intt> MAP;
	for (intt i = 0; i < N; ++i) {
		intt t; std::cin >> t;
		++MAP[t];
	}
	intt count = 0;
	for (auto& r : MAP) {
		if (r.second % 2 == 1)
			++count;
	}
	std::cout << count << std::endl;

}

Measured memory_bytes: 9624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> p;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = INT_MAX;
  for(int i = 0; i <= 200000; i += 2) {
    int ab = i * c;
    int aa = (x - i / 2) * a;
    int bb = (y - i / 2) * b;
    int value = ab + max(0, aa) + max(0, bb);
    ans = min(ans, value);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
	int a[3],sum1=0,sum2=0;
	for(int i=0;i<3;i++){
		cin>>a[i];
		if(a[i]==5) sum1++;
		else if(a[i]==7) sum2++;
	}
	if(sum1==2&&sum2==1) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int sx,sy,tx,ty;
    while(cin>>sx>>sy>>tx>>ty)
    {
    	for(int i=1;i<=(tx-sx);i++)
    	cout<<"R";
    	for(int i=1;i<=(ty-sy);i++)
    	cout<<"U";
    	for(int i=1;i<=(tx-sx);i++)
    	cout<<"L";
    	for(int i=1;i<=(ty-sy);i++)
    	cout<<"D";
    	cout<<"D";
    	for(int i=1;i<=(tx-sx)+1;i++)
    	cout<<"R";
    	for(int i=1;i<=(ty-sy)+1;i++)
    	cout<<"U";
    	cout<<"L";
    	cout<<"U";
    	for(int i=1;i<=(tx-sx)+1;i++)
    	cout<<"L";
    	for(int i=1;i<=(ty-sy)+1;i++)
    	cout<<"D";
    	cout<<"R"<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a-1;i>=0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    print((n-h+1) * (n-w+1));
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;

int main(){
     
    int a,b,c,d;
    
    cin>>a>>b>>c>>d;
    if(a*b>=c*d)cout<<a*b<<endl;
    else cout<<c*d<<endl;
     
    return 0;
}
 

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int k; cin>>k;
	string s; cin>>s;
	if(s.size()<=k){
		cout<<s<<endl;
	}else{
		cout<<s.substr(0, k)+"..."<<endl;
	}
	return 0;
}


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

int N;
vector<int> P;
vector<int> A, B;

int main(void) {
	cin >> N;

	P.resize(N);
	A.resize(N);
	B.resize(N);
	for (int i = 0; i < N; ++i) {
		int idx;
		cin >> idx;
		P[i] = idx - 1;
		A[i] = N * (i + 1);
		B[i] = N * (N - i);
	}
	for (int i = 0; i < N; ++i) {
		int idx = P[i];
		A[idx] += i;
	}

	for (int i = 0; i < N; ++i) {
		cout << A[i];
		char c = (i == N - 1) ? '\n' : ' ';
		cout << c;
	}
	for (int i = 0; i < N; ++i) {
		cout << B[i];
		char c = (i == N - 1) ? '\n' : ' ';
		cout << c;
	}
	return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
 
int main (void)
{ 
  int n, i;
  scanf("%d", &n);
  int array[100];
  for(i=0; i <= n-1; i++){
  	scanf("%d", &array[i]);
  }
  for(i=n-1; i >= 1; i--){
  	printf("%d ", array[i]);
  }
  printf("%d\n", array[0]);
  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int main(){
	int a, b, c;
	int flag = 0;

	scanf("%d %d %d", &a, &b, &c);

	if(a == b && a != c){
		flag = 1;
	}else if(a == c && a != b){
		flag = 1;
	}else if(b == c && a != b){
		flag = 1;
	}

	if(flag == 1){
		printf("Yes");
	}else{
		printf("No");
	}

	return 0;
}


Measured memory_bytes: 128
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
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;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I "; else cout << A[i] << " ";}}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  s += t[SIZE(t, int)-1];
  if (s == t) cout << "Yes";
  else cout << "No";

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  string HITACHI = "hi";
  string s; cin >> s;
  string hi = HITACHI;
  while (s.size() >= hi.size()) {
    if (s == hi) {
      cout << "Yes" << CRLF;
      return;
    }
    hi += HITACHI;
  }

  cout << "No" << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

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

    vector<LL> L(N+1);
    vector<LL> R(N+1);
    L[0] = 0;
    R[0] = 0;
    rep(i,N){
        if(S[i] == 'W')L[i] = 1;
        else R[i] = 1;
    }
    vector<LL> ruiL(N+1);
    vector<LL> ruiR(N+1);

    rep(i,N){
        ruiL[i+1] = ruiL[i] + L[i];
        ruiR[i+1] = ruiR[i] + R[i]; 
    }

    LL ans = 1e9;

    rep(i,N){
        LL tmp = ruiL[i] + ruiR[N] - ruiR[i];
        if(S[i] == 'E')tmp--;
        ans = min(ans,tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 9988
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int h, a;
	cin>>h>>a;
	cout<<(h+a-1)/a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

int main() {
    int n, m;
    while ( cin >> n >> m ) {
        if ( n == 0 && m == 0 ) break;
        vector <int> M( n );
        for ( int i = 0; i < n; ++ i ) {
            M[i] = i + 1;
        }

        int ind = 0;
        for ( int i = 0; i < n - 1; ++ i ) {
            ind = ( ind + m - 1 ) % M.size();
            M.erase( M.begin() + ind );
        }

        cout << M[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 0
def ok
  k = N*(N+1)/2
  s = A.inject(:+)
  return false unless (s%k).zero?

  q = s/k
  d = ([A[0]]+A.reverse).each_cons(2).map{|i|i.inject(:-)}
  d.each do |i|
    t = i+(N-1)*q
    return false unless (t%N).zero?
    return false unless t/N <= q
  end
  true
end

N=gets.to_i
A=gets.split.map &:to_i
puts ok ? "YES": "NO"


Measured memory_bytes: 12940
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

long long mod = 1e9+7;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}


int main(){
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  std::vector<long long > array(K+4, 0);
  std::vector<long long > exactly(K+4, 0);
  for (int i=1; i<=K; i++){
    array[i]=modpow(K/i, N, mod);
  }
  long long ans = 0;
  for (int i=K; i>=1; i--){
    exactly[i] = array[i];
    for (int j=2*i; j<=K; j+=i){
      //printf("array[%d]=%lld\n", j, array[j]);
      exactly[i] -= exactly[j];
      if (exactly[i]<0) exactly[i]+=mod;
    }
    ans += ((long long)i*exactly[i])%mod;
    ans %= mod;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 4464
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int M, K; cin >> M >> K;
  if(M == 0) {
    if(K == 0) {
      cout << "0 0\n"; return 0;
    } else {
      cout << -1 << "\n"; return 0;
    }
  }
  if(M == 1) {
    if(K == 0) {
      cout << "0 1 1 0\n"; return 0; 
    } else {
      cout << -1 << "\n"; return 0;
    }
  }

  if(K >= (1<<M)) {
    cout << -1 << "\n"; return 0;
  }  
  
  rep(i, (1<<M)) {
    if(i != K) cout << i << " ";
  }
  cout << K << " ";
  per(i, (1<<M)) {
    if(i != K) cout << i << " ";
  }
  cout << K << "\n";
  return 0;
}

Measured memory_bytes: 1792
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

x = inn()
print('Yes' if x>=30 else 'No')


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];
    int m = 0;
    rep(i, n) {
        m += b[a[i] - 1];
        if(i < n - 1 and a[i] + 1 == a[i + 1]) {
            m += c[a[i] - 1];
        }
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, i, j, k, x, minn, ct, s;
	cin >> n >> x >> minn;
	x -= minn;
	for (i = 1; i < n; i++) {
		cin >> s;
		x -= s;
		minn = min(minn, s);
	}
	ct = n + x / minn;
	cout << ct << "\n";


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; 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));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n;
	cin >> n;
	int a=0;

	if(n/100>0&&n/100<=12) a++;
	//cout << a << endl;
	if(n%100>0&&n%100<=12) a+=10;
	//cout << a << endl;

	switch(a){
		case 0: cout << "NA" << endl;break;
		case 1: cout << "MMYY" << endl;break;
		case 10: cout << "YYMM" << endl;break;
		case 11: cout << "AMBIGUOUS" << endl;break;
	}
	
/////////////////////////////////////////////
}

Measured memory_bytes: 256
package main
  
import (
    "fmt"
)

func main() {
    var n, m int
    fmt.Scan(&n, &m)
    maxl := 0
    minr := int(1e5 + 1)
    for i := 0; i < m; i++ {
        var l, r int
        fmt.Scan(&l, &r)
        if l > maxl {
            maxl = l
        }
        if r < minr {
            minr = r
        }
    }
    if minr-maxl >= 0 {
        fmt.Println(minr - maxl + 1)
    } else {
        fmt.Println(0)
    }
}


Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();

		// 500円の枚数
		int count500 = X/500;
		// 余り
		int too = X%500;
		
		// 5円の枚数
		int count5 = too/5;
		
		System.out.println(count500 * 1000 + count5 * 5);
		
	}
}


Measured memory_bytes: 21844
#include<iostream>

using namespace std;

int main()
{
	int r,D,x_2000;
	int x[11];

	cin >> r >> D >> x_2000;

	x[0] = x_2000;

	for(int i=1;i<=10;i++)
	{
		x[i] = x[i-1]*r - D;
		cout << x[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int N;
    scanf("%d",&N);

    int a[N];

    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
    }

    int flag=0;

    for(int i=0;i<N;i++){
        if((i+1)%2!=0 && a[i]%2!=0){
            flag++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 2144
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**7) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
s = ns()
t = ns()
match = 0

for i in range(1,n+1):
    if s[-i:] == t[:i]:
        match = i

print(len(s)+len(t)-match)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int main() {
  int w, h;
  while (scanf("%d %d", &h, &w) > 0) {
    int ans = 0;
    REP(y, h) {
      int sum = 0;
      REP(x, w) {
        int v;
        scanf("%d", &v);
        sum += v;
      }
      ans = max(ans, sum);
    }
    printf("%d\n", ans);
  }
}

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

typedef long long ll;

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

int main(){

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,d; cin >> n >> d;

  cout << (n-1)/(d*2+1)+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    map <string, ll> m;
    string s, t, u;
    cin >> s;
    for(auto x: s)
        cout << 'x';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
ll const MOD=1000000007;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<int>L(N);
    REP(i,N)cin>>L[i];

    sort(ALL(L));
    int count=0;
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            auto itr=lower_bound(L.begin()+j+1,L.end(),L[i]+L[j]);
            count+=distance(L.begin()+j,itr-1);
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, count int
	fmt.Scan(&N)
	if N%2 == 0 {
		for i := 1; i < N/2; i++ {
			count++
		}
	} else {
		for i := 1; i < N/2+1; i++ {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <stdio.h>
#define INF 0x10000000

int cities, roads, road[1000][1000], startcity, goalcity;

int main()
{
	int i, j, a, b, c, d,
	    reward, woodcost;
	for(i = 0; i < 1000; i++) {
		for(j = 0; j < 1000; j++) road[i][j] = INF;
	}
	/* input */
	scanf("%d\n%d", &cities, &roads);
	for(i = 0; i < roads; i++) {
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		road[a - 1][b - 1] = c;
		road[b - 1][a - 1] = d;
	}
	scanf("%d,%d,%d,%d", &startcity, &goalcity, &reward, &woodcost);
	reward -= woodcost;
	/* Dijkstra */
	/* outward way */
	reward -= dijkstra(startcity - 1, goalcity - 1);
	/* return path */
	reward -= dijkstra(goalcity - 1, startcity - 1);
	printf("%d\n", reward);
	return 0;
}
int dijkstra(int start, int goal)
{
	int i, u,
	    d[20], used[20];
	for(i = 0; i < 20; i++) {
		d[i] = INF;
		used[i] = 0;
	}
	d[start] = 0;
	for(i = 0; i < cities; i++) {
		if(road[start][i] != INF) d[i] = road[start][i];
	}
	while(1) {
		u = -1;
		for(i = 0; i < cities; i++) {
			if(!used[i] && (u == -1 || d[i] < d[u])) u = i;
		}
		if(u == -1) break;
		used[u] = 1;
		for(i = 0; i < cities; i++) {
			if(d[i] > d[u] + road[u][i]) d[i] = d[u] + road[u][i];
		}
	}
	return d[goal];
}

Measured memory_bytes: 0
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if ( k <= a ) {
        cout << k << endl; 
    }
    else if ( k <= a + b ) {
        cout << a << endl;
    }
    else {
        cout << a - ( k - ( a + b ) ) << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Wed Feb  6 12:22:28 2019
//
package main

import "fmt"

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

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

func main() {
	var S string
	fmt.Scan(&S)

	ans := len(S)
	for i := range S {
		if i+1 < len(S) {
			if S[i] != S[i+1] {
				ans = min(ans, max(i+1, len(S)-i-1))
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1280
#include <map>
#include <vector>
#include <cstdio>
using namespace std;

class union_find{
	int *parent,n;
public:
	union_find(int _n){n=_n;parent=new int[n+1];for(int i=1;i<=n;i++)parent[i]=i;}
	~union_find(){delete []parent;}
	int root(int a){return parent[a]==a?a:(parent[a]=root(parent[a]));}
	int unite(int a,int b){
		int x=root(a),y=root(b);
		if(x==y)return 0;
		parent[x]=y;
		return 1;
	}
};

void perform(int X,union_find &uf){
	for(int i=0;i<X;i++){
		int a,b;
		scanf("%d%d",&a,&b);a--,b--;
		if(a>b)swap(a,b);
		uf.unite(a,b);
	}
}

int main(){
	int N,K,L;
	scanf("%d%d%d",&N,&K,&L);
	union_find ufk(N),ufl(N);
	perform(K,ufk);
	perform(L,ufl);
	vector<pair<int,int> >m(N);
	map<pair<int,int>,int>q;
	for(int i=0;i<N;i++){
		pair<int,int>p=make_pair(ufk.root(i),ufl.root(i));
		m[i]=p;
		q[p]++;
	}
	for(int i=0;i<N;i++)printf(i<N-1 ? "%d " : "%d\n",q[m[i]]);
}

Measured memory_bytes: 15104
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  stringstream ss(str);
  vector<string> v;
  vector<int> n;
  while(ss >> str){
    bool f=false;
    for(int i=0;i<v.size();i++){
      if(str==v[i]) {
	n[i]++;
	f=true;
      }
    }
    if(!f){
      v.push_back(str);
      n.push_back(1);
    }
  }
  str="";
  int c=0;
  for(int i=0;i<v.size();i++){
    if(c<n[i]) c=n[i];
  }
  for(int i=0;i<v.size();i++){
    if(n[i]==c) cout << v[i];
    if(str.size()<v[i].size()) str=v[i];
  }
  cout << " " << str << endl;
}

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

int main() {
    int64_t h, s, count;
    cin >> h;
    s = 1;
    count = 0;

    while (true) {

        if(h%2 == 0) {
            h /= 2;
            count += s;
            s *= 2;
        }

        else if (h == 1) {
            h /= 2;
            count += s;
            break;
        }

        else {
            h /= 2;
            count += s;
            s *= 2;
        }
    }
    cout << count << endl;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string s;
int x, y, memo[8001][16002];
std::vector<int>dx, dy;

int dp1(int k, int px)
{
	if (k == dx.size()) return (px == x ? 0 : 1);
	if (memo[k][px + 8001] != -1) return memo[k][px];
	auto res1 = dp1(k + 1, px + dx[k]);
	auto res2 = dp1(k + 1, px - dx[k]);
	return memo[k][px + 8001] = ((res1 == 0 || res2 == 0) ? 0 : 1);
}
int dp2(int k, int py)
{
	if (k == dy.size()) return (py == y ? 0 : 1);
	if (memo[k][py + 8001] != -1) return memo[k][py];
	auto res1 = dp2(k + 1, py + dy[k]);
	auto res2 = dp2(k + 1, py - dy[k]);
	return memo[k][py + 8001] = ((res1 == 0 || res2 == 0) ? 0 : 1);
}

int main()
{
	in >> s >> x >> y;
	int start = 0, cou = 0;
	rep(i, s.length())
	{
		if (s[i] == 'T')
		{
			if (cou % 2 == 0) dx.push_back(i - start);
			else dy.push_back(i - start);
			start = i + 1;
			++cou;
		}
		else if (i == s.length() - 1)
		{
			if (cou % 2 == 0) dx.push_back(i - start + 1);
			else dy.push_back(i - start + 1);
			break;
		}
	}
	memset(memo, -1, sizeof(memo));
	auto ans1 = dp1(1, dx[0]);
	memset(memo, -1, sizeof(memo));
	auto ans2 = dp2(0, 0);
	out << ((ans1 == 0 && ans2 == 0) ? "Yes" : "No") << std::endl;
	return 0;
}


Measured memory_bytes: 500608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int s;
  cin >> s;
  ll p=s/100;
  ll q=s-p*100;
  if(p>0 &&p<13 && q>0 && q<13){
    cout <<"AMBIGUOUS";
  }else if( p>0 &&p<13 ){
    cout << "MMYY";
  }else if(q>0&&q<13){
    cout << "YYMM";
  }else{
    cout << "NA";
  }
}



Measured memory_bytes: 3568
def main():
    S = input()
    S = S.replace("BC", "D")

    ans = 0
    count_A = 0
    for c in S:
        if c == "A":
            count_A += 1
        elif c == "D":
            ans += count_A
        else:
            count_A = 0
    print(ans)

if __name__ == "__main__":
    main()

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

int main() {
  int N;
  cin >> N;
  
  if ((N / 10) % 111 == 0 || (N % 1000) % 111 == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i];

	vl b(n);
	FOR(i,0,n) b[a[i]-1] = i+1;
	FOR(i,0,n) cout << b[i] << " ";
	cout << endl;
}



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

int main(){
    int n, c=0;
    cin >> n;
    int arr1[n],arr2[n];
    for(int i=0; i<n; i++){
        cin >> arr1[i];
        arr2[i]=arr1[i];
    }
    sort(arr1, arr1+n);
    for(int i=0; i<n; i++){
        if(arr1[i]!=arr2[i])
            c++;
    }
    if(c==0 || c==2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    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++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  long long ans = 1;
  int mod = 1e9 + 7;
  FOR(i, 1, N)
  {
    ans *= i;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class B1 {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int X;
    cin >> X;
    int now = 100;
    rep(i, 1000000) {
      now = now + now / 100;
      if (now >= X) {
        cout << (i + 1) << endl;
        return;
      }
    }
  }
};


signed main() {
  B1 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3680
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    s=str(input())
    ls=len(s)
    if ls==2: print("-1 -1" if s[0]!=s[1] else "1 2")
    else:
        for i in range(ls-2):
            if len(set(s[i:i+3]))!=3:
                print(i+1,i+3)
                break
        else: print('-1 -1')
            

    
resolve()

Measured memory_bytes: 72456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll k,i;
  cin>>k;
  ll x=7;
  for (i=1;i<=k;i++)
  {
    if (x % k == 0) 
    {
      cout <<i<< endl;
      return 0;
    }
    x=(x*10+7)%k;
  }
 
  cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 3636
N, K = map(int, input().split())
p = int(1e9+7)
res = 0
d = [0]*K

for i in range(K, 0, -1):
    n = pow(K//i, N, p)

    for j in range(2*i, K+1, i):
        n -= d[j-1]

    d[i-1] = n
    res += n*i
    res %= p

print(res)


Measured memory_bytes: 11100
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int N;
  long long K;
  scanf("%d", &N);
  scanf("%lld", &K);
  std::vector<int > A(N), F(N);
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  for (int i=0; i<N; i++){
    scanf("%d", &F[i]);
  }
  std::sort(A.begin(), A.end(), std::greater<int>());
  std::sort(F.begin(), F.end());
  long long min = -1;
  long long max = 1e18;
  while(max-min>1) {
    //printf("[%lld, %lld]\n", min, max);
    long long mid = (min+max)/2;
    bool ok = [&]{
      long long sum = 0;
      for (int i=0; i<N; i++){
	if ((long long)A[i]*F[i]>mid){
	  sum += A[i]-mid/(long long)F[i];
	}
      }
      return sum<=K;
    }();
    if (ok) {
      max=mid;
    } else {
      min=mid;
    }
  }
  std::cout << max << std::endl;
  return 0;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
	"strings"
)

func one(dx, dy int) string {
	return strings.Repeat("U", dy) + strings.Repeat("R", dx)
}

func two(dx, dy int) string {
	return strings.Repeat("D", dy) + strings.Repeat("L", dx)
}

func three(dx, dy int) string {
	p := "L"
	p += strings.Repeat("U", dy+1)
	p += strings.Repeat("R", dx+1)
	p += "D"

	return p
}

func four(dx, dy int) string {
	p := "R"
	p += strings.Repeat("D", dy+1)
	p += strings.Repeat("L", dx+1)
	p += "U"

	return p
}
func main() {
	var sx, sy, tx, ty, dx, dy int
	fmt.Scanf("%d %d %d %d", &sx, &sy, &tx, &ty)

	dx = tx - sx
	dy = ty - sy
	paths := make([]string, 4, 4)

	paths[0] = one(dx, dy)
	paths[1] = two(dx, dy)
	paths[2] = three(dx, dy)
	paths[3] = four(dx, dy)

	fmt.Println(strings.Join(paths, ""))
}


Measured memory_bytes: 768