akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

const i64 mod = 1e9 + 7;
i64 ipow(i64 a, i64 b) {
    i64 x = a, y = 1;
    for (; b > 0; b >>= 1) {
        if (b & 1) (y *= x) %= mod;
        (x *= x) %= mod;
    }
    return y;
}
i64 inv(i64 x) {
    return ipow(x, mod - 2);
}
i64 fact(i64 x) {
    static vector<i64> f;
    i64 i = f.size();
    if (x >= i) {
        f.resize(x + 1);
        for (; i <= x; ++i) {
            f[i] = i == 0 ? 1 : i * f[i - 1] % mod;
        }
    }
    return f[x];
}
i64 perm(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(n - k)) % mod : 0;
}
i64 comb(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(k) * fact(n - k) % mod) % mod : 0;
}

int main() {
    i64 n, k;
    cin >> n >> k;
    i64 ans = 0, x = 1;
    for (i64 i = 0; i <= min(k, n - 1); ++i) {
        i64 j = n - i;
        (ans += comb(n, j) * comb(i + j - 1, i) % mod) %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10, mod = 998244353;

int n, q, ten[N], seg[N << 2], lazy[N << 2];

int t(int l, int r) {
  return ((ten[n - l + 1] - ten[n - r]) % mod + mod) % mod;
}

void push(int n, int i, int j) {
  if (lazy[n]) {
    if (i != j) {
      lazy[n << 1] = lazy[n << 1 | 1] = lazy[n];
    }
    seg[n] = (lazy[n] * t(i, j)) % mod;
    lazy[n] = 0;
  }
}

void update(int i, int j, int l, int r, int v, int n) {
  push(n, i, j);
  if (i > r || j < l) {
    return;
  }
  if (i >= l && j <= r) {
    lazy[n] = v;
    push(n, i, j);
    return;
  }
  int m = (i + j) >> 1;
  update(i, m, l, r, v, n << 1);
  update(m + 1, j, l, r, v, n << 1 | 1);
  seg[n] = (seg[n << 1] + seg[n << 1 | 1]) % mod;
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);    
  cin >> n >> q;
  ten[1] = 1;
  for (int i = 2; i <= n; ++i) {
    ten[i] = (ten[i - 1] * 10) % mod;
  }
  for (int i = 2; i <= n; ++i) {
    ten[i] = (ten[i - 1] + ten[i]) % mod;
  }
  update(1, n, 1, n, 1, 1);
  while (q--) {
    int l, r, d;
    cin >> l >> r >> d;
    update(1, n, l, r, d, 1);
    cout << seg[1] << '\n';
  }
  return 0;
}


Measured memory_bytes: 13416
#include<bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define __ ios::sync_with_stdio(false),cin.tie(0)
using namespace std;
string s;
int main(){
__;
getline(cin,s);
if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I')
    cout<<"Yes"; else cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int d[110000];
int out[110000];

int main()
{
    int i,j,n;
    cin>>n;
    for(i=0;i<n;i++)cin>>d[i];
    sort(d,d+n);
    for(i=1;i<n-1;i++)
    {
        if(d[i]<0)out[i]=d[n-1],d[n-1]-=d[i];
        else out[i]=d[0],d[0]-=d[i];
    }
    cout<<d[n-1]-d[0]<<endl;
    for(i=1;i<n-1;i++)printf("%d %d\n",out[i],d[i]);
    cout<<d[n-1]<<" "<<d[0]<<endl;
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define pi 3.14159265359
#define INF 1000000000

int main() {
  int N; cin >> N;
  vector<int> v(N);
  rep(i, N) {
    cin >> v[i];
  }
  sort(all(v));
  float ans = v[0];
  rep(i, N) {
    ans = (ans + v[i]) / 2;
  }
  cout << setprecision(5) << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
N, M = map(int, input().split())
A = []
for _ in range(M):
    A.append([int(x) for x in stdin.readline().rstrip().split()])

A.sort(key=lambda x: x[1])
l = 0
ans = 0
for i in range(M):
    if l < A[i][0]:
        ans += 1
        l = A[i][1] - 1
    else:
        pass
print(ans)


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

struct edge{
  int to, cost;
};

int main(int argc, char *argv[]){
  int n, m, r;
  cin >> n >> m >> r;
  vector<vector<edge> > g(n);
  int from;
  for (int i = 0; i < m; i++) {
    edge e;
    cin >> from >> e.to >> e.cost;
    g[from].push_back(e);
  }
  int dp[n];
  for (int i = 0; i < n; i++) {
    dp[i] = 1e9;
  }
  dp[r] = 0;
  //???????????§?????????
  //????????????????????????????????????
  bool update = true;
  int cnt = 0;
  while(update){
    if(cnt > n)break;
    cnt++;
    update = false;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < g[i].size(); j++) {
        edge e = g[i][j];
        if(dp[e.to] > dp[i] + e.cost && dp[i] != 1e9){
          dp[e.to] = dp[i] + e.cost;
          update = true;
        }
      }
    }
  }
  if(cnt > n){
    std::cout << "NEGATIVE CYCLE" << std::endl;
  }else{
    for (int i = 0; i < n; i++) {
      if(dp[i] == 1e9)std::cout << "INF" << std::endl;
      else std::cout << dp[i] << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1280
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     setbits(x)  __builtin_popcountll(x)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int k,n;
    cin>>k>>n;
    int a[n+5]{0};
    rep(i,1,n) cin>>a[i];
    int maxi=0;
    a[n+1]=k;
    rep(i,0,n) maxi=max(maxi,a[i+1]-a[i]);
    cout<<min(k-maxi,a[n]-a[1]);
    return 0;
}


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

int main() {
    int x, a, b;
    cin >> x >> a >> b;

    int c = abs(a - b);
    if (a >= b) {
        cout << "delicious" << endl;
    } else if (a + x >= b) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

signed main() {
    int N, D, A;
    cin >> N >> D >> A;
    V(P) XH(N);
    rep(i, N) {
        int x, h;
        cin >> x >> h;
        x--;
        XH[i] = P(x, h);
    }
    SORT(XH);

    queue<P> q;
    int cnt = 0, res = 0;
    rep(i, N) {
        int x = XH[i].fi, h = XH[i].se;
        while(!q.empty()) {
            P p = q.front();
            if(x>p.fi) {
                cnt -= p.se;
                q.pop();
            } else break;
        }
        int b = A*cnt;
        if(h>b) {
            int t = ((h-b)/A) + ((h-b)%A ? 1 : 0);
            res += t;
            q.push(P(x+2*D, t));
            cnt += t;
        }
    }

    cout << res << endl;
 
    return 0;
}

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

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

    long long sum[N]; // 上からi枚目までの和(0-indexed)
    sum[0] = a[0];

    // 累積和を計算しておく
    for (int i = 1; i < N; i++) sum[i] = sum[i - 1] + a[i];

    long long minimum = 1000000000000000000ll;
    for (int i = 0; i < N - 1; i++) {
        long long sum_snuke = 0, sum_kuma = 0;
        // すぬけくんは上からi枚目まで取る(0-indexed)
        sum_snuke = sum[i];
        // 残りをアライグマが取る
        sum_kuma = sum[N - 1] - sum_snuke;
        long long score = abs(sum_snuke - sum_kuma);
        // 2人の手札の差の絶対値が小さければ更新
        if (minimum > score) minimum = score;
    }
    // 最小値を出力
    cout << minimum << endl;

    return 0;
}

Measured memory_bytes: 5940
#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 x;
    cin >> x;
    while (1) {
        bool flag = true;
        for (int i = 2; i < x; ++i) if (x%i == 0) flag = false;
        if (flag) break;
        else x++;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var ns []int
	kk := n
	for kk != 0 {
		ns = append(ns, kk%10)
		kk /= 10
	}

	k := calc(n, 0, 0, len(ns))
	fmt.Println(k)
}

func calc(n, p, a, length int) int {
	var k int
	if check(p) && p <= n {
		k ++
	}
	if a < length {
		k += calc(n, p*10+3, a+1, length)
		k += calc(n, p*10+5, a+1, length)
		k += calc(n, p*10+7, a+1, length)
	}
	return k
}

func check(p int) bool {
	var b [10]bool
	for p != 0 {
		b[p%10] = true
		p /= 10
	}
	if b[3] && b[5] && b[7] {
		return true
	} else {
		return false
	}
}

func full(n int) int {
	return pow(3, n) - (3 * pow(2, n-1)) + 3
}

func pow(i, n int) int {
	result := 1
	for k := 0; k < n; k++ {
		result *= i
	}
	return result
}


Measured memory_bytes: 640
#  Copyright: this code was written at 2020. for AtCoder by Silviase

# Aをi回,Bをj回行ったとする
#   - i+j <= k を満たす
#   - i+j >= n なら全部取ったことにする
#   - 戻す回数はmin(k, 負の要素数)である
# 以上のことを踏まえfor文を回す

n, k = map(int, input().split())
val = list(map(int, input().split()))
left_acc = [0]
right_acc = [0]
for i in range(len(val)):
    left_acc.append(left_acc[len(left_acc) - 1] + val[i])
    right_acc.append(right_acc[len(right_acc) - 1] + val[len(val) - 1 - i])

res = 0

for i in range(0, k + 1):
    for j in range(0, k - i + 1):
        # print("i, j = ", i, j)
        valnew = []
        if i + j > n:
            valnew = val
        else:
            for l in range(1, i+1):
                valnew.append(val[l - 1])
            for l in range(1, j+1):
                valnew.append(val[n - l])
        valnew.sort()
        valsum = sum(valnew)
        for l in range(k-i-j):
            if l >= len(valnew):
                break
            else:
                valsum = max(valsum, valsum - valnew[l])
        res = max(res, valsum)
        # print(valnew)

print(res)


Measured memory_bytes: 41968
#include <stdio.h>

int isstraight(int[5]);

int main(void) {
	int cards[5];
	int i,j,temp;
	int yaku;
	char yakuname[7][11]={"null","one pair","two pair","three card",
						"straight","full house","four card"};
	while(1) {
		if(scanf("%d,%d,%d,%d,%d",
			&cards[0],&cards[1],&cards[2],&cards[3],&cards[4])==-1)break;
		for(i=4;i>0;i--) {
			for(j=0;j<i;j++) {
				if(cards[j]>cards[j+1]) {
					temp=cards[j];
					cards[j]=cards[j+1];
					cards[j+1]=temp;
				}
			}
		}
		yaku=0;
		if(cards[1]==cards[2] && cards[2]==cards[3]) {
			if(cards[0]==cards[1] || cards[3]==cards[4])yaku=6;
			else yaku=3;
		} else if(cards[0]==cards[1] && cards[1]==cards[2]) {
			if(cards[3]==cards[4])yaku=5; else yaku=3;
		} else if(cards[2]==cards[3] && cards[3]==cards[4]) {
			if(cards[0]==cards[1])yaku=5; else yaku=3;
		} else if(isstraight(cards))yaku=4;
		else {
			for(i=0;i<4;i++) {
				if(cards[i]==cards[i+1])yaku++;
			}
		}
		printf("%s\n",yakuname[yaku]);
	}
	return 0;
}

int isstraight(int cards[5]) {
	int i;
	for(i=0;i<4;i++) {
		if(cards[i]+1!=cards[i+1])break;
	}
	if(i<4) {
		if(cards[0]==1 && cards[1]==10 && cards[2]==11 &&
			cards[3]==12 && cards[4]==13)return 1; else return 0;
	} else return 1;
}

Measured memory_bytes: 0
Option Explicit On

Module Module1

    Sub Main()

        Dim K As Integer = Console.ReadLine()
        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim A As Integer = CInt(tmp(0))
        Dim B As Integer = CInt(tmp(1))

        Dim p1 = A Mod K
        If p1 = 0 Or (A + (K - p1)) <= B Then
            Console.WriteLine("OK")
        Else
            Console.WriteLine("NG")
        End If

    End Sub

End Module


Measured memory_bytes: 28388
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)
#define INF 1000000000
#define MOD 1000000007
typedef  long long ll;
using namespace std;

ll conv(ll n,ll r){
    if(r == 0 || n==r){
        return 1;
    }
    return conv(n-1,r)+conv(n-1,r-1);
}

int a[15][29];

void solve(void){
    int n,d;
    cin >> n >> d;
    int x[n][d];
    int ans = 0;
    rep(i,0,n)
    rep(j,0,d) cin >> x[i][j];
    int s[10000];
    for(int i=0;i < 10000;i++){
        s[i] = i*i;
    }

    for(int i = 0;i < n-1;i++){
        for(int j = i+1;j <n;j++){
            ll tmp = 0;
            for(int k = 0;k < d;k++){
                tmp += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }

            for(int p = 0;p < 10000;p++){
                if(s[p] == tmp){
                    ans++;
                    break;
                }
            }

        }
    }
    cout << ans << endl;

}


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



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する

ll calc(vector<ll> v, ll b) {
    ll ret = 0;
    rep(i, 0, v.size()) {
        ret += abs(v[i] - (b + i));
    }
    return ret;
}


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

    int N;
    cin >> N;

    vector<ll> v(N);
    rep(i, 0, N) cin >> v[i];

    ll lower = (ll) -2e10;
    ll upper = (ll) 2e10;

    while (upper - lower > 10) {
        ll first = (2 * lower + upper) / 3;
        ll second = (lower + 2 * upper) / 3;
        ll firstAns = calc(v, first);
        ll secondAns = calc(v, second);
        if (firstAns < secondAns) {
            upper = second;
        } else {
            lower = first;
        }
    }

//    ll lowerAns = calc(v,lower);
//    ll upperAns = calc(v,upper);
//
//    if(lowerAns < upperAns){
//        cout << lowerAns << endl;
//    }else{
//        cout << upperAns << endl;
//    }

    ll best = INFl;
    rep(i, lower, upper + 1) {
        best = min(best, calc(v, i));
    }

    cout << best << endl;


    return 0;
}


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

using namespace std;

int main(){
    string s;
    cin>>s;
    
    int l=s.length();
    for(int i=0;i<l/2;i++){
        if(s[i]!=s[l-1-i]){
            cout<<"No"<<endl;
            goto Exit;
        }
    }
    
    for(int i=0;i<(l-1)/4;i++){
        if(s[i]!=s[(l-1)/2-1-i]){
            cout<<"No"<<endl;
            goto Exit;
        }
    }
    
    for(int i=0;i<(l-1)/4;i++){
        if(s[(l+3)/2-1+i]!=s[l-1-i]){
            cout<<"No"<<endl;
            goto Exit;
        }
    }
    
    cout<<"Yes"<<endl;
    
    Exit:
        ;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[100][100], b[100];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin>>n>>m;
	for(int i=0; i<n; ++i) {
		for(int j=0; j<m; ++j) {
			cin>>a[i][j];
		}
	}
	for(int i=0; i<m; ++i) {
		cin>>b[i];
	}
	int c;
	for(int i=0; i<n; ++i) {
		c=0;
		for(int j=0; j<m; ++j) {
			c+=a[i][j]*b[j];
		}
		cout<<c<<'\n';
	}
	return 0;
}



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

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
typedef long long int int64;

void print() {
    cout << endl;
}

void print(const char* s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(char s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(string s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int64 s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int s, bool endline = true) {
    cout << s;
    if (endline) print();
}

template <typename T, typename T2>
void print(pair<T, T2>& p, bool endline = true) {
    cout << "(";
    print(p.first, false);
    cout << ", ";
    print(p.second, false);
    cout << ")";

    if (endline) print();
}

template <typename T>
void print(T& t, bool endline = true) {
    cout << "[";
    for (auto it = t.begin(); it != t.end(); ++it) {
        if (it != t.begin()) cout << ", ";
        print(*it, false);
    }
    cout << "]";

    if(endline) print();
}

template <typename T>
vector<T> operator+(const vector<T> &a, const vector<T> &b)
{
    vector<T> ret;
    ret.reserve( a.size() + b.size() );                // preallocate memory
    ret.insert( ret.end(), a.begin(), a.end() );        // add A;
    ret.insert( ret.end(), b.begin(), b.end() );        // add B;

    return ret;
}

template <typename T>
vector<T> &operator+=(vector<T> &a, const vector<T> &b)
{
    a.reserve( a.size() + b.size() );                // preallocate memory without erase original data
    a.insert( a.end(), b.begin(), b.end() );         // add B;
    return a;
}

bool c(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.first + a.second > b.first + b.second); 
}

int main() {
    // g++ -Wall -Wextra -O2 -std=c++17 helloworld.cpp  
    
    vector<int> p;
    // p.push_back(2);

    for(int i = 3; i <= 55555; i += 2) {
        bool prime = true;
        for(int j = 3; j <= sqrt(i); j += 2) {
            if (i % j == 0) {
                prime = false;
                break;
            }
        }

        if (prime && i % 5 == 1) {
            p.push_back(i);
        }
    }

    int n;
    cin >> n;


    for(int i = 0; i < n; i++) {
        cout << p[i] << " ";
    }

    cout << endl;


    return 0;
}

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

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

int main() {
    int N,c=0;
    cin >> N;
    vector<int> p(N);

    rep(i,N)
        cin >> p.at(i);
    
    rep(i,N-1)
        if(p.at(i)-1 == i) {
            swap(p.at(i), p.at(i+1));
            c++;
        }
    if(p.at(N-1) == N) {
        swap(p.at(N-1), p.at(N-2));
        c++;
    }

    cout << c << endl;
}

Measured memory_bytes: 640
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	string s;
	cin >> s;
	map<int, int> mp;
	rep(i, s.size()) {
		mp[s[i] - 'a']++;
	}

	if (mp.size() == 26) cout << "None" << endl;
	else {
		rep(i, 26){
			if (mp[i] == 0) {
				cout << (char)('a' + i) << endl;
				break;
			}
		}
	}
	return 0;
}

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

int main() {
  string N;
  cin >> N;
  int n = N.size();
  int count_2 = 0;
  rep(i,n) {
    if (N[i] == '2') {
      count_2++;
    }
  }
  cout << count_2 <<endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int N; cin >> N;
  vector<int> rabit(N);
  rep(i,N) cin >> rabit.at(i);
  int ans =0;
  rep(i,N){
    if(rabit.at(rabit.at(i)-1)==i+1) ans++;
  }

  cout << ans/2 << endl;
}


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

#define ll long long
#define pb push_back
#define N 1000000007
#define nmax 200001
#define pll pair<ll,ll>
#define fill_nums(A,n) for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}

ll extended_gcd(ll a, ll b, ll &x, ll &y) {
	if(a==0) {
		x = 0;
		y = 1;
		return b;
	}

	ll x1,y1;
	ll gcd = extended_gcd(b%a,a,x1,y1);

	x = y1 - (b/a)*x1;
	y = x1;

	return gcd;
}

class matrix {
public:
	vector<vector<ll>> A;
	int n;
	
	matrix(int n){
		A.resize(n, vector<ll>(n,0));
		this->n = n;
	}

	matrix operator* (matrix &B) {
		matrix C(n);
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				for(int k=0;k<n;k++)
					C.A[i][k] = (C.A[i][k] + A[i][j]*B.A[j][k])%N;
		return C;
	}
};

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

    vector<vector<ll>> A(n, vector<ll>(n,0));
    for(int i=0;i<n;i++)
    	for(int j=0;j<n;j++)
    		cin>>A[i][j];

    matrix I(n);
    for(int i=0;i<n;i++)
    	I.A[i][i]=1;

    matrix M(n);
    M.A = A;

    while(k) {
    	if(k%2){
    		I = I*M;
    	}
    	M = M*M;
    	k/=2;
    }

    ll res = 0;
    for(int i=0;i<n;i++)
    	for(int j=0;j<n;j++)
    		res = (res + I.A[i][j])%N;

    cout<<res<<endl;

	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n,chk;
    cin>>n;
    chk=n/100;
    if(chk==7)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    n=n%100;
    chk=n/10;
    if(chk==7)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    n=n%10;
    if(n==7)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3632
n = int(input())
cnt = 0
p = [int(x) for x in input().split()]
for i in range(n-2):
  s = p[i:i+3]
  if (s[0] < s[1] and s[1] < s[2]) or (s[0] > s[1] and s[1] > s[2]):
    cnt += 1
print(cnt)

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

using namespace std;
using ll = long long;

int main(void) {
  long long a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  long long d = abs(b - a);
  if (d <= (v - w) * t) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define rev(a,n) reverse(a,a+n)
using namespace std;
int n,m,ans;
ll a[N],b[N],k;
int main() {
	cin>>n>>m>>k;
	rep1(i,1,n) cin>>a[i];
	rep1(i,1,m) cin>>b[i];
	rep1(i,1,n) a[i]+=a[i-1];
	rep1(i,1,m) b[i]+=b[i-1];
	int j=m;
	rep1(i,0,n) {
		if(k<a[i])break;
		while(b[j]>k-a[i]){
			j--;
		}
		ans=max(ans,i+j);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6764
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct{
	char name[11];
	int p;
	int label;
}set;

	set a[101];

//nameによるソート
int compare(const set *a,const set *b){
	return strcmp(a->name,b->name);
}

int main(){
	//input
	int n;
	scanf("%d",&n);
	//構造体にinput
	for(int i=0;i<n;i++){
		scanf("%s %d",a[i].name,&a[i].p);
		a[i].label=i+1;
	}
	
	//void qsort(先頭要素のポインタ,要素数,一つの要素のサイズ,比較方法);
	//stdlib.hに入っている
	//compareには、aがbよりも先であるとき負の値を返すような関数を入れる必要がある
	qsort(a,n,sizeof(set),compare);
	
	//同名をpointでソート
	for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(strcmp(a[i].name,a[j].name)==0&&a[i].p<a[j].p){
                set tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
	
    for(int i=0;i<n;i++)printf("%d\n",a[i].label);
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

#define MAX 25
#define NIL -1

typedef struct
{
  int parent;
  int sib;
  int left;
  int right;
}node;

node T[MAX];
int D[MAX],H[MAX];

void depth(int u,int p)
{
  D[u] = p;

  if(T[u].right != NIL) depth(T[u].right,p+1);
  if(T[u].left != NIL) depth(T[u].left,p+1);

  return;
}

void height(int u,int p)
{
  if(T[u].left == NIL && T[u].right == NIL) H[u] = p = 0;
  else if(p > H[u]) H[u] = p;

  if(T[u].left != NIL && H[T[u].left] == NIL) height(T[u].left,0);
  if(T[u].right != NIL && H[T[u].right] == NIL) height(T[u].right,0);
  if(T[u].parent != NIL) height(T[u].parent,p+1);
  
  return;
}

void print(int u)
{
  int deg=0;
  
  printf("node %d: parent = %d, sibling = %d, ",u,T[u].parent,T[u].sib);

  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;

  printf("degree = %d, depth = %d, height = %d, ",deg,D[u],H[u]);

  if(T[u].parent == NIL) printf("root\n");
  else  if(T[u].left != NIL || T[u].right != NIL) printf("internal node\n");
  else printf("leaf\n");
  
  return;
}

int main()
{
  int n,i,id,left,right,root,maxdep,min;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) //データの初期化
    {
      T[i].parent = NIL;
      T[i].sib = NIL;
      T[i].left = NIL;
      T[i].right = NIL;
      H[i] = NIL;
    }

  for(i = 0 ; i < n ; i++)
    {
      scanf("%d",&id);

      scanf("%d %d",&left,&right);

      T[left].parent = T[right].parent = id;

      T[id].left = T[right].sib = left;
      T[id].right = T[left].sib = right;
    }

  for(i = 0 ; i < n ; i++)
    {
      if(T[i].parent == -1) root = i;
    }

  depth(root,0);

  for(i = 0,maxdep = 0 ; i < n ; i++)
    {
      if(D[i] > maxdep)
	{
	  maxdep = D[i];
	  min = i; 
	}
    }
  
  height(min,0);

  for(i = 0 ; i < n ; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 2104
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 2e5+5,mod = 1e9+7;
vi dp(N,0),ans(N,0),siz(N,0),fact(N,1),fact_inv(N,1);
vvi adj(N,vi ());
ll n;



ll power(ll x,ll y)
{
	ll anst=1;
	while(y)
	{
		if(y&1) anst = (anst*x)%mod;
		y>>=1;
		x=(x*x)%mod;
	}
	return anst;
}
		

void dfs(ll u,ll p)
{
	siz[u]=1;
	dp[u]=1;
	for(ll i=0;i<sz(adj[u]);i++)
	{
		ll ch = adj[u][i];
		if(ch==p) continue;


		dfs(ch,u);
		siz[u]+=siz[ch];
		dp[u] = (dp[u]*dp[ch])%mod;
		dp[u] = (dp[u]*fact_inv[siz[ch]])%mod;
	}

	dp[u] = (dp[u]*fact[siz[u]-1])%mod;
	return ;
}

void dfs2(ll u,ll p=-1)
{
	if(p==-1) ans[u]=dp[u];
	rep(i,0,sz(adj[u]))
	{
		ll ch = adj[u][i];
		if(ch==p) continue;


		ll temp = (ans[u]*fact_inv[n-1])%mod;
		temp = (temp*fact[siz[ch]])%mod;
		temp = (temp*power(dp[ch],mod-2))%mod;
		temp = (temp*fact[n-siz[ch]-1])%mod;
		


		ans[ch] = dp[ch];
		ans[ch] = (ans[ch]*temp)%mod;
		ans[ch] = (ans[ch]*fact_inv[n-siz[ch]])%mod;
		ans[ch] = (ans[ch]*fact[n-1])%mod;
		ans[ch] = (ans[ch]*fact_inv[siz[ch]-1])%mod;
		// ans[ch] = (ans[ch]*fact_inv[siz[ch]-1])%mod;


		dfs2(ch,u);
	}

	return ;
}


int solve()
{

	// ll k = (2*power(500,mod-2))%mod;
	// k = (k*500)%mod;
	// whatis(k);

	rep(i,1,N) fact[i] = (fact[i-1]*i)%mod,fact_inv[i] = (fact_inv[i-1]*power(i,mod-2))%mod;
	cin>>n;
	rep(i,0,n-1)
	{
		// adj[i].pb(i+1);
		// adj[i+1].pb(i);

		ll x,y;cin>>x>>y;
		x--,y--;
		adj[x].pb(y);
		adj[y].pb(x);
	}

	dfs(0,-1);
	dfs2(0,-1);


	rep(i,0,n) cout<<ans[i]<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 22512
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i < n; ++i)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}

void solve() {
  // main coding
  ll n; cin>>n;
  ll V=0; // num of vertex
  ll matchID[1001][1001];
  // create matchID
  rep(i,n) rep(j,n) if(i<j) {
    matchID[i][j]=V;
    V++;
  }
  // toID func
  auto toID=[&](ll i,ll j){
    if(i>j) swap(i,j);
    return matchID[i][j];
  };
  vector<vector<ll>> E(V); // V=n*(n-1)/2
  vector<ll> A(n-1);
  rep(i,n) {
    rep(j,n-1) {
      cin>>A[j];
      A[j]--; // 0-indexed
    }
    rep1(j,n-1) E[toID(i,A[j])].push_back(toID(i,A[j-1]));
  }
  // dynamic programming
  // -1: unvisited 0: visited and uncalculated(detection of cycle)
  vector<ll> dp(V,-1);
  function<void(ll)> dfs=[&](ll v){
    if(dp[v]>0) return;
    else if(dp[v]==0) {
      cout<<-1<<"\n";
      exit(0);
    }
    dp[v]=0;
    ll len=1;
    for(ll u:E[v]) { // from v to u
      if(dp[u]<=0) dfs(u);
      len=max(len,dp[u]+1);
    }
    dp[v]=len;
  };
  rep(i,V) dfs(i);
  cout<<*max_element(dp.begin(),dp.end())<<"\n";
}

int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 39040
#include<iostream> 
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<vector> 
#include<array>
#include<deque>
#include<list>
#include<forward_list>
#include<stack>
#include<queue>
#include<algorithm>
#include<numeric>
#include<iterator>
#include<functional>
#include<map>
#include<unordered_map>
#include<set>
#include<utility>
#include<unordered_set>
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define sort_all(v) sort(v.begin(), v.end())
#define fill(a) memset(a, 0, sizeof(a))

#define FOR(i, a, b) for(int i = a; i < b; i++)
#define FOR_REV(i, a ,b) for(int i = a; i >= b; i--)
#define REP(i, n) FOR(i, 0, n)


void test() {
    int a, b;
    cin >> a >> b;
    cout << a * b;
}   
 
int main ()     
{
    // int t;
    // cin >> t;
    // while(t--) 
        test();
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
const long long inf = (long long) 1e18;
 
const int N = 5010;
 
long long f[N][N];
 
int main() {
  int n;
  scanf("%d", &n);
  vector< pair<int,int> > a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first, &a[i].second);
    a[i].first += a[i].second;
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    a[i].first -= a[i].second;
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      f[i][j] = inf;
    }
  }
  f[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      long long ft = f[i][j];

      f[i + 1][j] = min(f[i + 1][j], ft);
      if (ft <= a[i].first) {
        f[i + 1][j + 1] = min(f[i + 1][j + 1], ft + a[i].second);
      }
    }
  }
  int ans = 0;
  for (int j = 0; j <= n; j++) {
    if (f[n][j] != inf) {
      ans = j;
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

int R, S, P;

int tokuten(char t){
  if(t == 'r') return R;
  if(t == 's') return S;
  if(t == 'p') return P;
}

char kachite(char t){
  if(t == 'r') return 'p';
  if(t == 's') return 'r';
  if(t == 'p') return 's';
}

int main(void){

  int N, K;
  int x = 0;
  string T;
  string te, l;

  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  l = {"rsp"};

  for(int i=0; i<N; i++){
    if(i<K || kachite(T[i])!=te[i-K]){
      te+=kachite(T[i]);
      x+=tokuten(te[i]);
    }
    else{
      for(int j=0; j<3; j++){
        if(l[j]!=te[i-K] && l[j]!=kachite(T[i+K])){
          te+=l[j];
          break;
        }
      }
    }
  }
  cout << x << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void){
    int n, m;
    cin >> n >> m;
    string a,b,c;
    int cnta = 0, cntb = 0, cntc = 0;
    for (int i = 0; i < n; i++) {
        char d; cin >> d;
        if (d == '1') cnta++;
        a += d;
    }
    for (int i = 0; i< m; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            if (i%2) {
                b += '1'; cntb++;
                c += '0';
            }
            else {
                b += '0';
                c += '1'; cntc++;
            }
        }
    }
    
    int ans = 1e9;
    if (cnta == cntb) {
        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] != b[i]) {
                int j = i;
                while (b[j] != a[i]) j++;
                sum += j-i;
                swap(b[i], b[j]);
            }
        }
        ans = min(ans, sum);
    }
    
    if (cnta == cntc) {
        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] != c[i]) {
                int j = i;
                while (c[j] != a[i]) j++;
                sum += j-i;
                swap(c[i], c[j]);
            }
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

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

int main() {
	int n, k;
	ll ans = 9999999999999;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	for(int i = 0; i < 1<<(n - 1); i++) {
		if(k - 1 != __builtin_popcount(i)) continue;
		ll yen = 0, max = a[0] + 1;
		rep(j,n-1) {
			if(i>>j & 1) {
				if(max <= a[j + 1]) max = a[j + 1] + 1;
				else {
					yen += max - a[j + 1];
					max++;
				}
			}
			else if (max <= a[j + 1]) {
				yen = 999999999999;
				j = n - 2;
			}
		}
		ans = min(yen,ans);
	}

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

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

int main() {
	int n,k;cin>>n>>k;
  	vector<int> l(n);for(int i=0;i<n;i++) cin>>l.at(i);
  	sort(l.begin(),l.end(),greater<int>());
  	int ans=0;
  	for(int i=0;i<k;i++){
    	ans+=l[i];
    }
  	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long n, q;

class UnionFind{
private:
    std::vector<long> parent;
    std::vector<long> rank;

public:
    UnionFind(long n);
private:
    long root(long x);
public:
    bool same(long x, long y);
    void unite(long x, long y);
};

UnionFind::UnionFind(long n){
    parent = std::vector<long>(n);
    rank = std::vector<long>(n, 0);
    for(long i = 0; i < n; i++){
        parent[i] = i;
    }
}

long UnionFind::root(long x){
    if(x < 0 || parent.size() <= x){
        printf("UnionFind::root range invalid!\n");
        return -1;
    }
    if(parent[x] == x){
        return x;
    }else{
        long res = root(parent[x]);
        parent[x] = res;
        return res;
    }
}

bool UnionFind::same(long x, long y){
    return root(x) == root(y);
}

void UnionFind::unite(long x, long y){
    x = root(x);
    y = root(y);
    if(x == y){
        return;
    }
    if(rank[x] < rank[y]){
        parent[x] = y;
    }else{
        parent[y] = x;
        if(rank[x] == rank[y]){
            rank[x]++;
        }
    }
}

int main(){
    scanf("%ld%ld", &n, &q);
    UnionFind uf(n);
    for(int i = 0; i < q; i++){
        long c, x, y;
        scanf("%ld%ld%ld", &c, &x, &y);
        if(c == 0){
            uf.unite(x, y);
        }else{
            if(uf.same(x, y)){
                printf("1\n");
            }else{
                printf("0\n");
            }
        }
    }
}



Measured memory_bytes: 3280
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static long[] ReadLongArray()
    {
	return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
    }

    public static long Gcd(long a, long b)
    {
	if (a < b){ return Gcd(b, a); }
	while (b != 0)
	{
	    var r = a % b;
	    a = b;
	    b = r;
	}
	return a;
    }
}

class Program
{
    static int checkChar(string s, long L, long i)
    {
	int n = s.Length;
	long a = L / n;
	if (i % a == 0)
	{
	    return (int) s[(int)(i/a)];
	}
	else
	{
	    return -1;
	}
    }

    static bool check(string s, string t, long L)
    {
	int m = t.Length;
	for (int i = 0; i < m; i++)
	{
	    long a = (int) (L / m);
	    int c = checkChar(s, L, i*a);
	    if (c > 0 && c != (int) t[i])
		return false;
	}
	return true;
    }
    
    public static void Main()
    {
	var tmp = ReadLongArray();
	long n = tmp[0], m = tmp[1];
	long g = n * m / Gcd(n, m);

	string s = ReadLine();
	string t = ReadLine();


	int l = 0;
	int r = (int) Gcd(n, m);

	if (!check(s, t, n*m))
	{
	    WriteLine(-1);
	    return;
	}
	
	while (r - l > 1)
	{
	    int mid = (l + r) / 2;
	    long L = g * mid;

	    if (check(s, t, L))
		r = mid;
	    else
		l = mid;
	}
	WriteLine(r*g);
    }
}


Measured memory_bytes: 13792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define all(v) v.begin(),v.end()
using namespace std;

template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

int n;
int dis[1000005];
deque<P>que;
signed main() {
	cin>>n;
	rep(i,n)dis[i]=inf;
	dis[1]=1;
	que.push_back({1,1});
	while(!que.empty()){
		P p=que.front();que.pop_front();
		if(dis[p.second]<p.first)continue;
		if(p.second%10!=9){
			if(dis[(p.second+1)%n]>p.first+1){
				dis[(p.second+1)%n]=p.first+1;
				que.push_back({p.first+1,(p.second+1)%n});
			}
		}
		if(dis[(p.second*10)%n]>p.first){
			dis[(p.second*10)%n]=p.first;
			que.push_front({p.first,(p.second*10)%n});
		}
	}
	cout<<dis[0]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int f(int x) {
  int res = 0;
  while (x % 2 == 0) {
    x /= 2;
    res++;
  }
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  // a -> a'にしている
  REP(i, n) {
    if (a[i] % 2 == 1) {
      cout << 0 << endl;
      return 0;
    }
    a[i] /= 2;
  }

  /* a' -> a''、つまり上記で言う所の2^tで割ってる
     これをやると一々a'の最大に最小公倍数を
     合わせるとか考えることがなくなるので楽
  */
  int t = f(a[0]);
  REP(i, n) {
    if (f(a[i]) != t) {
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t;  // a[i] /= 2^t
  }
  m >>= t;

  ll l = 1;
  REP(i, n) {
    l = lcm(l, a[i]);
    if (l > m) {
      cout << 0 << endl;
      return 0;
    }
  }
  // m -> m'
  m /= l;

  /*
    これはm'以下の奇数の数、つまり
    mを最小公倍数で割った時の奇数倍を表す
    (奇数倍の数=倍数中の奇数の数を求めれば良い)
  */
  ll ans = (m + 1) / 2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>
#define lint int64_t

int main(){
    lint N,M,C;
    cin >> N >> M >> C;
    
    vector<lint> Bi;
    rep(i,M){
        lint tmpBi;
        cin >> tmpBi;
        Bi.push_back(tmpBi);
    }
    
    lint ans = 0;
    rep(i,N){
        vector<lint> Ai;
        lint sum = 0;
        rep(i,M){
            lint tmpAi;
            cin >> tmpAi;
            sum += tmpAi * Bi.at(i);
        }

        if((sum + C) > 0) ans++;
    }

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


Measured memory_bytes: 256
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;

void solve()
{
    int x, y;
    scn(x); scn(y);

    bool ok = 0;

    rep(i, 0, x+1) {
        if(2*i + 4*(x-i) == y) {
            ok = 1;
            break;
        }
    }

    puts(ok? "Yes": "No");
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3756
N, K = map(int, input().split())
x = list(map(int, input().split()))

Min = 10**9
for i in range(N-K+1):
    x_l = x[i]
    x_r = x[i+K-1]
    ans_1 = abs(x_l-0) + abs(x_l-x_r)
    ans_2 = abs(x_r-0) + abs(x_l-x_r)
    Min = min(Min, ans_1, ans_2)

print(Min)


Measured memory_bytes: 14252
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

S = gets.chomp

arr = %w[SUN MON TUE WED THU FRI SAT]

puts 7 - arr.find_index { |x| x == S }


Measured memory_bytes: 14468
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <map>
#include <memory.h>
#include <queue>
#include <string.h>
#include <set>
#include <bitset>
using namespace std;

#define ll long long
#define N 300005
#define mod 1000003
#define M 40

int mul(int x,int y) {
  return (ll)x*y%mod;
}
int dp[mod][M];
int mypow(int x,int c) {
  int ret = 1;
  while(c>0) {
    if(c&1) {
      ret = mul(ret,x);
    }
    x = mul(x,x);
    c/=2;
  }
  return ret;
}

void solve() {
  for(int i=1;i<=mod-1;++i) {
    dp[i][0] = i;
  }
  for(int j=1;j<M;++j) {
    for(int i=1;i<=mod-2;++i) {
      dp[i][j] = mul(dp[i][j-1], dp[ (i+ (1LL<<(j-1) )  )%mod][j-1]);
    }
  }
  int Q;scanf("%d",&Q);
  while(Q--) {
    int x,d,n;scanf("%d %d %d ", &x,&d,&n);
    if(d==0) {
      printf("%d\n", mypow(x,n));
    }
    else {
      int cur = x,ret = 1;
      cur = mul(cur, mypow(d,mod-2));
      int u = mypow(d,n);
      for(int i=M-1;i>=0;--i) {
        if(n&(1LL<<i)) {
          ret = mul(ret, dp[cur][i]);
          cur = (cur + (1LL<<i))%mod;
        }
      }
      ret = mul(ret,u);
      printf("%d\n", ret);
    }
  }
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 157184
#include <stdio.h>
#include<string>
#include <cmath>
#include <iostream>

using namespace std;

int main(){
	int a,b,k;
	double c;
	scanf("%d %d",&a,&b);
	if((a+b)%2 == 0){
		k=(a+b)/2;
		cout<<k<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b, c;
	int sakura_ayane, minase_inori = 0;
	if (scanf("%d%d%d", &a, &b, &c) != 3) return 1;
	for (sakura_ayane = a; sakura_ayane <= b; sakura_ayane++) {
		if (c % sakura_ayane == 0) minase_inori++;
	}
	printf("%d\n", minase_inori);
	return 0;
}



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

using namespace std;

const int MAXN = 1e5 + 7;

int n;
int a[MAXN];
int cnt1[MAXN], cnt2[MAXN];

int get(int x, int y) {
    if (x == y) return MAXN;
    int ans = 0;
    for (int i = 0; i < n; i += 2) {
        ans += (a[i] != x);
    }
    for (int i = 1; i < n; i += 2) {
        ans += (a[i] != y);
    }
    return ans;
}

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

    cin >> n;

    for (int i = 0; i < n; ++i) cin >> a[i];

    for (int i = 0; i < n; i += 2) {
        cnt1[a[i]]++;
    }
    for (int i = 1; i < n; i += 2) {
        ++cnt2[a[i]];
    }

    int mx11 = 0, mx12 = 0;
    for (int i = 0; i < MAXN; ++i) {
        if (cnt1[i] > cnt1[mx11]) {
            mx12 = mx11;
            mx11 = i;
        }
        else if (cnt1[i] > cnt1[mx12]) {
            mx12 = i;
        }
    }


    int mx21 = 0, mx22 = 0;
    for (int i = 0; i < MAXN; ++i) {
        if (cnt2[i] > cnt2[mx21]) {
            mx22 = mx21;
            mx21 = i;
        }
        else if (cnt2[i] > cnt2[mx22]) {
            mx22 = i;
        }
    }
    
    int ans = MAXN;
    ans = min(ans, get(mx11, mx21));
    ans = min(ans, get(mx11, mx22));
    ans = min(ans, get(mx12, mx21));
    ans = min(ans, get(mx12, mx22));
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1408