akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;s
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

const int nax = 1e6 + 44, mod = 1e9 + 7;
ll fac[nax * 2], fin[nax * 2];

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

ll inv(ll x) {
	ll e = mod - 2, r = 1;
	while (e) {
		if (e & 1) r = r * x % mod;
		x = x * x % mod;
		e >>= 1;
	}
	return r;
}
ll cho(int a, int b) {
	if (b < 0 || b > a) return 0;
	return fac[a] * fin[b] % mod * fin[a - b] % mod;
}

void solve(){
	int k; string s; cin >> k >> s;
	int n = s.size();
	fac[0] = 1;
	for (int i = 1; i < nax * 2; ++i) fac[i] = fac[i - 1] * i % mod;
	fin[nax * 2 - 1] = inv(fac[nax * 2 - 1]);
	for (int i = nax * 2 - 2; i >= 0; --i) fin[i] = fin[i + 1] * (i + 1) % mod;
	ll ans = 0;
	forn(i,0,k+1) {
		(ans += cho(n + i - 1, i) * power(26, k - i) % mod * power(25, i)) %= mod;
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 35624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  string S;
  cin >> N >> S;
  vector<int> W(N,0);
  vector<int> E(N,0);
  W[0] = 0;
  for(int i=1;i<N;i++){
    if(S[i-1] == 'E') W[i] = W[i-1];
    else W[i] = W[i-1]+1;
  }
  E[N-1] = 0;
  for(int i=N-2;i>=0;i--){
    if(S[i+1] == 'W') E[i] = E[i+1];
    else E[i] = E[i+1]+1;
  }
  int ans = 1e9;
  for(int i=0;i<N;i++){
    //cout << W[i] << " " << E[i] << endl;
    ans = min(ans,W[i]+E[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3076
S = input()                                                                                                                                                  
N = len(S)                                                                                                                                                   
                                                                                                                                                             
C = 0                                                                                                                                                        
for i in range(0,N,2):                                                                                                                                       
    if S[i] != '0':                                                                                                                                          
        C = C+1                                                                                                                                              
                                                                                                                                                             
for i in range(1,N,2):                                                                                                                                       
    if S[i] != '1':                                                                                                                                          
        C = C+1                                                                                                                                              
                                                                                                                                                             
print(min(C,N-C)) 

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <set>

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

using namespace std;

void dfs(vector<set<string>>& v, const vector<string>& gn, int i) {
  vector<int> apd;
  for(string name:v[i]) {
    auto itr=find(begin(gn),end(gn),name);
    if(itr != end(gn)){
      int j=itr-begin(gn);
      apd.push_back(j);
      dfs(v,gn,j);
    }
  }
  for(int j:apd)
    v[i].insert(begin(v[j]),end(v[j]));
  for(auto itr=begin(v[i]);itr!=end(v[i]);++itr){
    while(itr!=end(v[i])&&find(begin(gn),end(gn),*itr) != end(gn)){
      itr=v[i].erase(itr);
    }
    if(itr==end(v[i]))break;
  }
}

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    vector<set<string>> v(n);
    vector<string> gn(n);
    REP(i,n){
      string str;
      cin>>str;
      int pos=str.find(':');
      gn[i]=str.substr(0,pos);
      int old=pos+1;
      while((pos=str.find(',',old)) != string::npos){
        v[i].insert(str.substr(old,pos-old));
        old=pos+1;
      }
      v[i].insert(str.substr(old,str.size()-old-1));
    }
    REP(i,n){
      dfs(v,gn,i);
    }
    cout<<v[0].size()<<endl;
  }
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;

const int MX = 100005;

#define F0R(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define sz(x) (int)x.size()
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define f first
#define s second

void setIO(string name) {
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

int N, K, a[MX];
int dp[MX];

int main() {
	cin >> N >> K;
	F0R(i, N) cin >> a[i];

	memset(dp, 1000000, sizeof dp);

	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int k = 0; k <= K && i + k < N; k++) {
			dp[i + k] = min(dp[i + k], dp[i] + abs(a[i] - a[i + k]));
		}
	}
	cout << dp[N - 1] << "\n";
}

// watch out for int overflow

Measured memory_bytes: 1024
from sys import stdin

N = int(stdin.readline().rstrip())

ans = ""

if N == 0:
    ans += '0'
while abs(N) >= 1:
    if N % (-2) == -1:
        N = N // (-2) + 1
        ans += '1'
    elif N % (-2) == 0:
        N = N // (-2)
        ans += '0'
ans = ans[::-1]

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> ans(n,0);
  vector<bool> f(n,false);

  for (int i=0; i<n; i++) {
    if (f[i]) continue;
    if(s[i] == 'R') {
      int cnt = 0;
      int ad = 0;

      while(i+cnt < n && s[i+cnt] != 'L') {
        if (cnt%2==0) {
          f[i+cnt] = true;
          ad++;
        }
        cnt++;
      }
      if (cnt%2 == 0) ans[i+cnt]+=ad;
      else ans[i+cnt-1]+=ad;

    }
  }

  for (int i=n-1; i>0; i--) {
    if (f[i]) continue;

    if (s[i] == 'L') {
      int cnt = 0;
      int ad = 0;
      while( i-cnt>0 && s[i-cnt] != 'R') {
        if (cnt%2 == 0) {
          f[i-cnt] = true;
          ad++;
        }
        cnt++;
      }
      if (cnt%2 == 0) ans[i-cnt]+=ad;
      else ans[i-cnt+1]+=ad;
    }
  }

  for (int i=0; i<n; i++) {
    printf("%d%c",ans[i],(i<n-1? ' ' : '\n'));
  }
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define repP(i, a, b) for(int i = a; i < b; i++)
#define repM(i, a, b) for(int i = a - 1; i >= b; i--)

using namespace std;

int main()
{
  int a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0, i = 0, j = 0;
  int num = 0, count = 1, ans = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[256], a2[512], a3[1024];
  //char s1[200000], s2[200000], s3[200000];
  string s1, s2, s3;
  
  cin >> a >> s1;
  
  for(i = 0; i < a - 1; i++){
    if(s1[i] != s1[i + 1]){
      count++;
    }
  }
    cout << count << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>

using namespace std;

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

    int max1 = 0;
    int max2 = 0;
    for (int i=0; i<N; i++) {
        if (max1 < A[i]) {
            max1 = A[i];
        } else if (max2 <= A[i]) {
            max2 = A[i];
        }
    }
    //cout << "max1 " << max1 << " max2 " << max2 << endl;
    for (int i=0; i<N; i++) {
        //cout << "--- " << i << " " << A[i] << endl;
        if (A[i] == max1) {
            cout << max2 << "\n";
        } else {
            cout << max1 << "\n";
        }
    }

    return 0;
}   


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
using namespace std;

#define int long long

signed main() {
    int n, t; cin >> n >> t;
    int ans = 10000;
    for(int i = 0; i < n; i++) {
        int cost, time; cin >> cost >> time;
        if(time <= t) {
            ans = min(ans, cost);
        }
    }

    if(ans == 10000) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

int n, p, x, cnt[2];
LL ans, p2[55], ncr[55][55];

int main () {
	
	p2[0] = 1;
	
	FOE(i, 1, 50) p2[i] = p2[i - 1] + p2[i - 1];
	
	scanf("%d%d", &n, &p);
	
	ncr[0][0] = 1;
	ncr[1][1] = ncr[1][0] = 1;
	
	FOE(i, 2, n) {
		ncr[i][0] = 1;
		FOE(j, 1, i) ncr[i][j] = ncr[i - 1][j] + ncr[i - 1][j - 1];
	}
	
	FOR(i, 0, n) {
		scanf("%d", &x);
		cnt[x % 2]++;
	}
	
	if (p == 0) {
		FOE(i, 0, cnt[1]) {
			ans += ncr[cnt[1]][i];
			i++;
		}
		ans *= p2[cnt[0]];
		printf("%lld\n", ans);
	} else {
		FOE(i, 1, cnt[1]) {
			ans += ncr[cnt[1]][i];
			i++;
		}
		ans *= p2[cnt[0]];
		printf("%lld\n", ans);
	}
		
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long k; cin >> k;
    long long ans = 0;
    for (long long a = 1; a <=k ; a++) {
        for (long long b = 1; b <= k; b++) {
            for (long long c = 1; c <=k; c++) {
                ans += __gcd(__gcd(a,b),c);
            }
        }
    }
    cout << ans<<endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long[] tmp = Console.ReadLine().Split().Select(long.Parse).ToArray();
        string ans = ""; 
        if (tmp[0] < tmp[1])
        {
            for (int i = 0; i < tmp[1]; i++)
            {
                ans += tmp[0].ToString();
            }
        }
        else
        {
            for (int i = 0; i < tmp[0]; i++)
            {
                ans +=  tmp[1].ToString();
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11348
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var N = IO_ShortCut.ReadInt;
            var a = new List<int> { 111, 222, 333, 444, 555, 666, 777, 888, 999 };
            a.Add(N);
            a.Sort();
            int idx = a.IndexOf(N);
            WriteLine(a[idx + 1]);
        }
    }

    public class IO_ShortCut
    {
        #region Input
        public static string ReadString => ReadLine();
        public static int ReadInt => int.Parse(ReadLine());
        public static long ReadLong => long.Parse(ReadLine());
        public static double ReadDouble => double.Parse(ReadLine());

        public static List<string> ReadSplitString => ReadLine().Split().ToList();
        public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
        public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
        public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

        #endregion
    }

    /// <summary>
    /// 正の数の四則演算のみ対応
    /// </summary>
    public class Mod
    {
        // 割る数の定義
        private readonly static long M = 1000000007;

        // 足し算
        public static long Add(long a, long b) => (a * b) % M;
        // 引き算
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        // 掛け算
        public static long Multi(long a, long b) => (a * b) % M;
    }

    public class MathLib
    {
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int, int> pii;
#define mp(a, b) make_pair(a, b)
#define sqr(s) ((s) * (s))
const int inf = 0x7fffffff / 3.27;
const int maxn = 105;
int i, j, t, n, m, l, r, k, z, y, x;
int a, b;
char f[maxn][maxn];
void calc(int a, int b) {
    int i, j;
    i = 1;
    while (a > 1 && i + 5 <= n) {
        for (j = 1; j <= m; j++) {
            f[i][j] = f[i + 1][j] = f[i + 2][j] = '.';
            f[i + 3][j] = f[i + 4][j] = f[i + 5][j] = '#';
        }
        a--;
        b--;
        i += 6;
    }
    for (; i <= n; i++)
        for (j = 1; j <= m; j++) f[i][j] = '.';
    a--;
    i = 5;
    while (a > 0) {
        for (j = 1; j <= m; j += 2) {
            f[i][j] = '.';
            a--;
            if (a == 0) break;
        }
        i += 6;
    }
    i = 2;
    while (b > 0) {
        for (j = 1; j <= m; j += 2) {
            f[i][j] = '#';
            b--;
            if (b == 0) break;
        }
        i += 6;
    }
}
int main() {
    int I, T = 1;
    // scanf("%d", &T);
    for (I = 1; I <= T; I++) {
        scanf("%d%d", &a, &b);
        n = m = 100;
        calc(min(a, b), max(a, b));
        if (a > b) {
            for (i = 1; i <= n; i++)
                for (j = 1; j <= m; j++) {
                    f[i][j] = (f[i][j] == '.') ? '#' : '.';
                }
        }
        printf("%d %d\n", n, m);
        for (i = 1; i <= n; i++) {
            for (j = 1; j <= m; j++) printf("%c", f[i][j]);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int h,w,black=0;
    scanf("%d%d",&h,&w);
    char s[h][w+2];
    int cost[h*w][h*w];
    for (int i=0; i<h; i++){
        scanf("%s",s[i]);
    }
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            if (s[i][j]=='#'){
                black++;
            }
        }
    }
    for (int i=0; i<h*w; i++){
        for (int j=0; j<h*w; j++){
            cost[i][j]=1e9;
        }
    }
    cost[0][0]=1;
    int count=0,x[h*w],y[h*w];
    x[0]=0,y[0]=0;
    for (int i=0; i<count+1; i++){
        if (s[x[i]-1][y[i]]=='.' && cost[x[i]-1][y[i]]>cost[x[i]][y[i]]+1){
            cost[x[i]-1][y[i]]=cost[x[i]][y[i]]+1;
            count++;
            x[count]=x[i]-1;
            y[count]=y[i];
        }
        if (s[x[i]+1][y[i]]=='.' && cost[x[i]+1][y[i]]>cost[x[i]][y[i]]+1){
            cost[x[i]+1][y[i]]=cost[x[i]][y[i]]+1;
            count++;
            x[count]=x[i]+1;
            y[count]=y[i];
        }
        if (s[x[i]][y[i]-1]=='.' && cost[x[i]][y[i]-1]>cost[x[i]][y[i]]+1){
            cost[x[i]][y[i]-1]=cost[x[i]][y[i]]+1;
            count++;
            x[count]=x[i];
            y[count]=y[i]-1;
        }
        if (s[x[i]][y[i]+1]=='.' && cost[x[i]][y[i]+1]>cost[x[i]][y[i]]+1){
            cost[x[i]][y[i]+1]=cost[x[i]][y[i]]+1;
            count++;
            x[count]=x[i];
            y[count]=y[i]+1;
        }
    }
    if (cost[h-1][w-1]==1e9){
        printf("-1\n");
    } else {
        printf("%d\n",h*w-black-cost[h-1][w-1]);
    }
	return 0 ;
}


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

int main() {
  string S;
  cin >> S;
  S += '0';
  int cnt = 0;
  for (int i = 0; i + 1 < S.size(); i++) {
    int num = S.at(i) - '0';
    if (num >= 6 || num == 5 && S.at(i + 1) >= '5') cnt += 10 - num, S.at(i + 1)++;
    else cnt += num;
  }
  cnt += S.back() - '0';
  cout << cnt << "\n";
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += d[i] * d[j];
    }
  }

  cout << ans << endl;
}

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

int main(){
	int n,a,c,s;
	s=1;
	c=1;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==0){
			c=1;
			continue;
		}
		else{
			c++;
			if(s<c) s=c;
		}
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3096
s = input()
n = int(input())
for _ in range(n):
    t = [i for i in input().split()]
    if t[0] == "print":
        print(s[int(t[1]) : int(t[2]) + 1])
    elif t[0] == "reverse":
        s = s[:int(t[1])] + s[int(t[1]) : int(t[2]) + 1][::-1] + s[int(t[2]) + 1:]
    else:
        s = s[:int(t[1])] + t[3] + s[int(t[2]) + 1:]

Measured memory_bytes: 7696
#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t

void miss(){
    cout << 0 << endl;
    exit(0);
}

int main(void){
    int N;
    cin >> N;
    int h[N];
    bool detect[N];
    
    for(int i = 0 ; i < N ; i++ ){
        detect[i] = false;
    }
    
    vector<int> T;
    vector<int> A;
    
    for(int i = 0 ; i < N ; i++ ){
        int temp;
        cin >> temp;
        T.push_back(temp);
    }
    
    for(int i = 0 ; i < N ; i++ ){
        int temp;
        cin >> temp;
        A.push_back(temp);
    }
    
    h[0] = T[0];
    detect[0] = true;
    for(int i = 1 ; i < N ; i++ ){
        h[i] = T[i];
        if( T[i-1] != T[i] ){
            detect[i] = true;
        }
    }
    
    //if( h[N-1] != A[N-1] ){
    //    miss();
    //}
    if( detect[N-1] && h[N-1] != A[N-1]){
        miss();
    }
    h[N-1] = A[N-1];
    detect[N-1] = true;
    
    for(int i = N - 2 ; i >= 0 ;i-- ){
        if( detect[i] && h[i] > A[i] ){
            miss();
        }
        
        if( h[i] > A[i] ){
            h[i] = A[i];
        }
        
        if( A[i+1] != A[i] ){
            detect[i] = true;
        }
    }
    
    ll ret = 1;
    
    for(int i = 0 ; i < N ; i++ ){
        if( detect[i] ){
        }else{
            ret = (ret * h[i]) % N_PRIME;
        }
    }
    /*
    for(int i = 0 ; i < N ; i++ )
        cout << h[i] << " ";
    cout << endl;
    
    for(int i = 0 ; i < N ; i++ )
        cout << (detect[i]?'*':' ') << " ";
    cout << endl;
    */
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	string n;
	cin >> n;
	if(n[0] == n[2]) cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
#pragma comment (linker, "/STACK:256000000")
 
#define _USE_MATH_DEFINES
#define _CRT_NO_DEPRECEATE
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <memory.h>
#include <sstream>
#include <cassert>
#include <ctime>
#include <complex>
#include <bitset>

//#include <random>
 
using namespace std;
 
 
double PI = 3.1415926535897932384626433832795;
long double EPS = 1e-12;
 
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
const int MOD = 1e9 + 7;
const int BASE = 1327; 
typedef pair<int64, int64> pii;
const int MAXN = 100100;
const int64 LINF = 2e18; 
const int LN = 30;
int n, q, m, l;

int mas[MAXN];
string st;

void solve()
{
	cin >> st;
	for(int i = 1; i < st.size(); ++i)
	{
		if (st[i - 1] == st[i])
		{
			cout << i << ' ' << i + 1;
			return;
		}
	}
	for(int i = 2; i < st.size(); ++i)
	{
		if (st[i - 2] == st[i])
		{
			cout << i - 1 << ' ' << i + 1 << endl;
			return;
		}
	}
	cout << "-1 -1";
}
 

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _MY_DEBUG
    freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#else
    //freopen(TASK ".in", "rt", stdin); freopen(TASK ".out", "wt", stdout);
#endif
    srand(1313);
	
	int t = 1;
	//scanf("%d", &t);
	for(int i = 0; i < t; ++i)
	{
		solve();
	}
	
    return 0;
}      

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

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int>dp(n,0);
  dp[0]=0;
  dp[1]=abs(a[0]-a[1]);
  for(int i=2;i<n;i++){
    int w1=dp[i-2]+abs(a[i-2]-a[i]);
    int w2=dp[i-1]+abs(a[i]-a[i-1]);
    dp[i]=min(w1,w2);
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    int a[n+1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(i % 2 == 1 && a[i] % 2 == 1){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3564
#include<iostream>
using namespace std;
int a[10001],k,n,ans;
int main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++)
	  cin>>a[i];
	for (int i=1;i<=n-1;i++)
	  for (int j=i+1;j<=n;j++)
	    if (a[i]<a[j]) swap(a[i],a[j]);
	for (int i=1;i<=k;i++)
	  ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var line string
	fmt.Scan(&line)
	count1, count2 := 0, 0
	for i, ss := range line {
		s := string(ss)
		if i % 2 == 0 && s == "0" {
			count1++
		} else if i % 2 == 1 && s == "1" {
			count1++
		}
	}

	for i, ss := range line {
		s := string(ss)
		if i % 2 == 0 && s == "1" {
			count2++
		} else if i % 2 == 1 && s == "0" {
			count2++
		}
	}

	if count1 > count2 {
		fmt.Println(count2)
	} else {
		fmt.Println(count1)
	}
}

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

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

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

  max = n;
  n--;
  while (n > 1) {
    cout  << a[n] << ' ';
    n -= 2;
  }
  cout<< a[n] << ' ';
  if (n == 0)
    n++;
  else
    n--;
  while (n < max) {
    cout << a[n] << ' ';
    n += 2;
  }

  return 0;
}


Measured memory_bytes: 15872
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=1e9+7;
template<class T>struct mow{
	T pow(T x,T n){
		T ret=1;
		if(n>0){
			ret=pow(x,n/2);
			if(n%2==0){
				(ret=(ret*ret))%=mod;
			}else{
				(ret=((ret*ret)%mod)*x)%=mod;
			}
		}
		return ret;
	}
	T inv(T n){
		return pow(n,mod-2);
	}
};
int main(){
	int n;
	long long a[200000];
	cin>>n;
	long long s=0;
	long long ss=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		(s+=a[i])%=mod;
		(ss+=a[i]*a[i])%=mod;
	}
	(s*=s)%=mod;
	s+=mod;
	s-=ss;
	s%=mod;
	mow<long long> nii;
	s*=nii.inv(2);
	s%=mod;
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 4728
//include
//------------------------------------------
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

int main(void){
  string s;
  string c;
  cin >>s;
  cin >>s;
  cin >>c;
  cout << "A"<<s.at(0)<<"C"<<endl;
  return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7
S = input()
res = 0
dpn = 1
dp0 = 0 # a
dp1 = 0 # ab

for c in S:
    if c == 'A':
        dp0 += dpn
    elif c == 'B':
        dp1 += dp0
    elif c == 'C':
        res += dp1
    else:
        dp0,dp1,res = dp0*3+dpn,dp1*3+dp0,res*3+dp1
        dpn *= 3
    dpn %= MOD
    dp0 %= MOD
    dp1 %= MOD
    res %= MOD
print(res)


Measured memory_bytes: 73276
// in the name of Allah
// Ya Ali!
#include <bits/stdc++.h>
using namespace std;

typedef long long ll ;
const ll maxn = 111111 ;
const ll INF = 1e18 ;

#define f first
#define s second

ll n , w1 , w[maxn] , v[maxn] , dp[110][maxn] , sum = 0 ;

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

 cin >> n >> w1 ;
 for(int i = 1 ; i <= n ; i ++){
    cin >> w[i] >> v[i] ;
    sum += v[i] ;
 }

 for(int i = 1 ; i <= sum+1 ; i ++){
  dp[0][i] = INF ;
 }

 for(int i = 1 ; i <= n ; i ++){
    for(int j = 0 ; j <= sum+1 ; j ++){
     dp[i][j] = dp[i-1][j] ;
     if(j >= v[i])dp[i][j] = min(dp[i][j] , dp[i-1][j-v[i]]+w[i]) ;
    }
 }

 ll ans = 0 ;
 for(ll i = 0 ; i <= sum+1 ; i ++){
    if(dp[n][i] <= w1)ans = max(ans , i);
 }
 cout << ans ;

     return 0;
}


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

int main() {
  long long n,k;
  cin>>n>>k;
  long long ans=0;
  if(k==0) {
    ans=n*n;
    cout<<ans<<endl;
  }
  else{
  for(long long b=k+1;b<=n;b++){
    long long block=n/b;
    ans+=block*(b-k);
    long long amari=n%b;
    amari-=k-1;
    if(amari>0) ans+=amari;
  }
  cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int S_N = Integer.parseInt(S);
		int N = S.length();
		int[] nums = {3, 5, 7, 0};
		int cnt=0;

		String[] str_array = new String[(int)Math.pow(4,N)];
		for (int i=0;i<Math.pow(4,N);i++) {
			int[] array = new int[N];
			for (int j=0;j<N;j++) {
				int tmp = i;
				for (int k=0;k<j;k++) {
					tmp/=4;
				}
				array[j] = tmp%4;
			}
			for (int j=0;j<N;j++) {
				str_array[i]+=String.valueOf(nums[array[j]]);
			}
			str_array[i]=str_array[i].replace("null","");
			int ans = Integer.parseInt(str_array[i]);

			int[] flag = new int[5];
			for (int j=0;j<N;j++) {
				char number = str_array[i].charAt(j);
				if (number=='3') {
					flag[0]=1;
					flag[4]=1;
				} else if (number=='5') {
					flag[1]=1;
					flag[4]=1;
				} else if (number=='7') {
					flag[2]=1;
					flag[4]=1;
				} else if (number=='0') {
					if (flag[4]==1) {
						flag[3]=1;
					}
				}
			}
			if (flag[0]==1 && flag[1]==1 && flag[2]==1 && flag[3]==0) {
				if (ans<=S_N) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

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

using namespace std;

int main()
{
    int N;
    vector<int> units(3);
    cin >> units[0] >> units[1] >> units[2] >> N;
    std::sort(units.begin(), units.end());
    std::reverse(units.begin(), units.end());

    int count = 0;
    for (int i1 = 0, n1 = N / units[0]; i1 <= n1; ++i1)
    {
        for (int rem23 = N - i1 * units[0]; rem23 >= 0; rem23 -= units[1])
        {
            if (rem23 % units[2] == 0)
            {
                ++count;
            }
        }
    }
    cout << count;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Buffer(make([]byte, 0), 1e6) // maxTokenSize
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	/* --- code --- */
	a, v, b, w := nextInt64(), nextInt64(), nextInt64(), nextInt64()
	t := nextInt64()
	l := abs(b - a)
	vsub := v - w

	if vsub*t >= l || a == b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}

func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
vector<lli> divisor(lli N){
  vector<lli>res;
  for(lli i=1;i*i<=N;i++){
    if(N%i==0){
      res.push_back(i);
      if(i!=N/i)res.push_back(N/i);
    }
  }
  Sort(res);
  return res;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N;
  rep(i,1,N+1){
    num=i*floor(N/i)*floor((N+i)/i);
    sum+=num/2;
  }
  Out(sum);
}
  

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
namespace AOJ
{
    internal class Program
    {
        public static void Main(string[] args) { new Program().solve(); }
        void solve() {
            var D = new DiceClass();
            var inputs = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
            var order = Console.ReadLine();
            Action<char> f = (c) => {
                if (c == 'N') D.RollN();
                if (c == 'S') D.RollS();
                if (c == 'W') D.RollW();
                if (c == 'E') D.RollE();
            };

            D.SetDice(inputs);
            foreach (var c in order.ToCharArray()) {
                f(c);
            }
            Console.WriteLine(D.Above);
        }
    }
    class DiceClass
    {
        //above figure is |0|
        //front figure is |1|
        //     N
        //    |0|
        //W |3|1|2|4| E
        //    |5|
        //     S
        public int[] Dice = new int[6];
        public int Above { get { return Dice[0]; } }
        public void SetDice(int[] a) {
            for (int i = 0; i < 6; ++i) Dice[i] = a[i];
        }
        public void SetBasicDice() {
            SetDice(Enumerable.Range(1, 6).ToArray());
        }
        private int[] genArr(params int[] a) {
            return new int[] { Dice[a[0]], Dice[a[1]], Dice[a[2]], Dice[a[3]], Dice[a[4]], Dice[a[5]] };
        }
        public void RollN() {
            SetDice(genArr(1, 5, 2, 3, 0, 4));
        }
        public void RollW() {
            SetDice(genArr(2, 1, 5, 0, 4, 3));
        }
        public void RollE() {
            SetDice(genArr(3, 1, 0, 5, 4, 2));
        }
        public void RollS() {
            SetDice(genArr(4, 0, 2, 3, 5, 1));
        }
        public void Show() {
            //     N
            //    |0|
            //W |3|1|2|4| E
            //    |5|       
            //     S
            Console.WriteLine("     N");
            Console.WriteLine("    |" + Dice[0] + "|");
            Console.WriteLine("W |" + Dice[3] + "|" + Dice[1] + "|" + Dice[2] + "|" + Dice[4] + "| E");
            Console.WriteLine("    |" + Dice[5] + "|");
            Console.WriteLine("     S");

        }




    }
}


Measured memory_bytes: 9632
#include <cstdio>
#include <cstring>
using namespace std;

int w, h, k, dir, y, x;

void adjust()
{
  if (x < 1) x = 1;
  else if (x > w) x = w;
  if (y < 1) y = 1;
  else if (y > h) y = h;
}

int main()
{
  while (scanf("%d%d\n", &w, &h), w|h) {
    static const int dy[] = {1, 0, -1, 0};
    static const int dx[] = {0, 1, 0, -1};
    char buffer[256];
    x = y = 1;
    dir = 0;
    for (;;) {
      fgets(buffer, sizeof(buffer), stdin);
      switch (buffer[0]) {
      case 'F':
        sscanf(buffer, "FORWARD %d", &k);
        y += k * dy[dir];
        x += k * dx[dir];
        adjust();
        break;
      case 'B':
        sscanf(buffer, "BACKWARD %d", &k);
        y -= k * dy[dir];
        x -= k * dx[dir];
        adjust();
        break;
      case 'R':
        dir = (dir + 1) % 4;
        break;
      case 'L':
        dir = (dir + 3) % 4;
        break;
      case 'S':
        goto stop;
      }
    }
stop:
    printf("%d %d\n", x, y);
  }
}

Measured memory_bytes: 0
#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,k,sum = 0;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p.at(i);
  sort(p.begin(),p.end());
  rep(i,k){
    sum += p.at(i);
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 3584
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

chars = 'abcdefghijklmnopqrstuvwxyz'
s = input()
i = 0
while True:
    if s == chars[i]:
        break
    i+=1
print(chars[i+1])

Measured memory_bytes: 66028
#include<bits/stdc++.h>
using namespace std;
double dp[3001][3001],a[3001],sum;
main(){
	int n,i,j;
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	dp[0][0] = 1.0;
	for(i=1;i<=n;i++)
		for(j=0;j<i;j++){
			dp[i][j+1]+=(a[i]*dp[i-1][j]);
			dp[i][j]+=((1-a[i])*dp[i-1][j]);	
		}		
	for(i=(n+1)/2;i<=n;i++)sum+=dp[n][i];
	cout<<fixed<<setprecision(10)<<sum;	
}

Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    double N, M, K;
    bool flag = false;
    cin >> N >> M >> K;
    rep(i, N + 1) //合計でi個行ボタンを押したとき
    {
        double minus = (double)i;
        double def = (K - minus * M) / (N - 2.0*minus);
        if (def >= 0 and def <= M and def == floor(def))
            flag = true;
    }
    if (flag)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
input_int = int(input())
input_list = []

for i in range(input_int):
    input_line = input()
    input_list.append(input_line)

counter = Counter(input_list)

max_val = max(counter.values())
keys_of_max_val = [key for key in counter if counter[key] == max_val]

keys_of_max_val.sort()
for i in keys_of_max_val:
    print(i)

Measured memory_bytes: 35576
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <queue>
#include <tuple>
using namespace std;
using ll = long long;

ll N, M, LCM, GCD;
char S[100001], T[100001];

int gcd(ll l, ll r) {
	while(l) {
		tie(l, r) = make_tuple(r % l, l);
	}
	return r;
}

bool isPos() {
	ll di = LCM / N, dj = LCM / M;
	for(ll i = 0, j = 0, s = 0, t = 0; i < LCM;) {
		// printf("%lld %lld %lld %lld\n", i, j, s, t);
		if(i == j) {
			// printf("%lld <> %lld\n", s, t);
			if(S[s] !=T[t]) return false;
			i += di, s++, j += dj, t++;
		}
		else if(i < j) {
			i += di, s++;
		}
		else {
			j += dj, t++;
		}
	}
	return true;
}

int main () {
	scanf("%lld %lld", &N, &M);
	scanf("%s %s", S, T);
	GCD = gcd(N, M);
	LCM = N * M / GCD;
	if(isPos()){
		printf("%lld\n", LCM);
	}
	else {
		printf("-1\n");
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;

int main()
{
    
    string s,t;
    cin >> s >> t;
    t.pop_back();
    if(s == t)
       cout << "Yes\n";
      else
       cout << "No\n";
    
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const double PI = 3.1415926535898;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int R;cin>>R;
	cout<<2*PI*R<<'\n';
	return 0;
}

Measured memory_bytes: 3804
'use strict'

function main(input) {
  input = input.split(/\n/)
  const N = Number(input[0])
  const jobs = input
    .slice(1, -1)
    .map(v => v.split(' ').map(v => ~~v))
    .sort((a, b) => {
      return a[1] > b[1] ? 1 : -1
    })
  // console.log(jobs.length === N)

  let time = 0
  let i = 0
  while (true) {
    // for (let i = 0; i < N; i++) {
    // for (let job of jobs) {
    time += jobs[i][0]
    if (time > jobs[i][1]) {
      console.log('No')
      return false
    }
    i++
    if (i >= N) {
      console.log('Yes')
      return false
    }
  }
  // console.log('Yes')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 72744
N, K = map(int, input().split())
num = list(range(N+1))
count = 0
base_minimum = sum([i for i in num[:K]])
base_maximum = sum([i for i in num[-K:]])
count += base_maximum - base_minimum + 1

for k in range(K, N+1):
    base_minimum += num[k]
    base_maximum += num[-k-1]
    count += base_maximum - base_minimum + 1
    
print(int(count%(1e9+7)))

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

#define FLASH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >  
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"

int32_t main()
{
 FLASH;
 string s;
 cin>>s;
 int count=0,ans=0;
 for(int i=0;i<s.size();i++)
 {
    if(s[i]=='A' or s[i]=='C'  or s[i]=='G' or s[i]=='T')
    {
        count++;
    }
    else
        {
          ans=max(count,ans);
          count=0;
        }
 }
 ans=max(count,ans);
 cout<<ans<<endl;
}



Measured memory_bytes: 3628
def main():
    N, K = map(int, input().split())
    H = [int(input()) for i in range(N)]
    H.sort()
    mi = 10**9
    for i in range(N - K + 1):
        diff = H[i+K-1] - H[i]
        if diff < mi:
            mi = diff
    print(mi)
if __name__ == "__main__":
    main()

Measured memory_bytes: 7384
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  string S; cin >> S;
  ll wi = 0, retval = 0;
  rep(i,S.size()){
    if (S[i]=='W') {
      retval += i - wi;
      wi++;
    }
    else continue;
  }

  cout << retval << endl;
  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,total=0;
	scanf("%d",&n);
	int a[n+1];
	for(int i=1;i<n;i++){
		scanf("%d",&a[i]);
	}
	a[n]=2100000000;
	total=a[1];
	for(int i=2;i<=n;i++){
		total+=min(a[i],a[i-1]);
	}
	printf("%d",total);
	return 0;
} 

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

int main() {
  ll N, ans = 1000;
  cin >> N;
  for (int i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      ans = min(ans, (ll)log10(N / i) + 1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
int main()
{
    long long a,b,c,d; cin>>a>>b>>c>>d;
    long long x;
    x = max((a*c),max((a*d),max((b*d),b*c)));
    cout<<x;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,T,A; cin>>N>>T>>A;

    int ans=0,min=1e18;
    REP(i,N){
        int x; cin>>x;
        int d=T*1000-x*6-A*1000;
        if(d<0) d=-d;

        if(d<min){
            min=d;
            ans=i+1;
        }
    }
    cout<<ans<<endl;

}


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

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

  vector<int> BOX(N+1, 1);
  BOX.at(0) = 0; //使わない
  vector<bool> fg(N+1, false);
  fg.at(1) = true; //赤が入っている可能性のある箱だけtrue

  for( int i = 0; i < M; i++ ){
    int X, Y;
    cin >> X >> Y;
    BOX.at(X)--;
    BOX.at(Y)++;
    if( fg.at(X) ) fg.at(Y) = true;
    if( BOX.at(X) == 0 ) fg.at(X) = false;
  }

  int ans = 0;
  for( int i = 1; i <= N; i++ ){
    if( fg.at(i) ) ans++;
  }

  cout << ans << endl;

}

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int k;cin>>k;
  int odd=0,even=0;
  rep(i,k)i%2==0 ? even++ : odd++;
  cout<<odd*even<<endl;
}


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

int main() {
    int N;
    // vector<int> data(N);
    int data[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> data[i];
    
    sort(data, data+N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i=0; i < N; ++i) {
        if (i%2 == 0) {
            Alice += data[i];
        } else {
            Bob += data[i];
        }
    }
    
    cout << Alice - Bob << endl;
    
    return 0;
}

Measured memory_bytes: 3640