akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

int main(){
  string s;
  cin>>s;
  if(s[1]=='B') {out("ARC");}
  else {out("ABC");}
  // cin>>N;

}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int n;
int num[100];
int ans;
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
		cin>>num[i];
	num[0]=num[n]=1<<20;
	for(int i=1;i<=n;i++)
		ans+=min(num[i],num[i-1]);
	cout<<ans<<endl;	
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n; cin>>n;
	ll ans=1, sub=1;
	rep(i,n){
		int a; cin>>a; ans*=3;
		if(a%2==0) sub*=2;
	}
	cout<<ans-sub<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[110];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	for(int i=0;i<n-8;i++)printf("%c",in[i]);
		printf("\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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 main(){
ll int a,b,c,d;
cin >> a >> b >> c >> d;
cout << max(a*b,c*d) << endl;
}

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

using namespace std;

typedef long long ll;

ll n, a, b, c, d;

const ll mod = 1e9 + 7;

ll fac[1005];
ll rfac[1005];
ll dp[1005][1005];

ll p(ll a, ll x)
{
    ll res = 1;

    while (x > 0)
    {
        if (x & 1)
        {
            res = res * a % mod;
        }
        a = a * a % mod;
        x >>= 1;
    }

    return res;
}

int main()
{
    cin >> n >> a >> b >> c >> d;

    fac[0] = rfac[0] = 1;

    for (int i = 1; i <= n; i++)
    {
        fac[i] = fac[i - 1] * i % mod;
        rfac[i] = p(fac[i], mod - 2);
    }
    dp[a - 1][0] = 1;

    for (ll i = a; i <= b; i++)
    {
        for (ll j = 0; j <= n; j++)
            dp[i][j] = dp[i - 1][j];
        for (ll k = c; k <= d; k++)
        {
            for (ll j = k * i; j <= n; j++)
            {

                dp[i][j] = (dp[i][j] + dp[i - 1][j - k * i] * fac[j] % mod * rfac[j - k * i] % mod * rfac[k] % mod * p(p(fac[i], k), mod - 2) % mod) % mod;
            }
        }
    }

    /* for (ll i = a; i <= b; i++)
    {
        for (ll j = 0; j <= n; j++)
        {
            cout << "dp[" << i << "][" << j << "] = " << dp[i][j] << endl;
        }
    }*/

    cout << dp[b][n] << endl;
}

Measured memory_bytes: 8064
#include "bits/stdc++.h"
#define FR(var, max) for(int var = 0; i < (max); ++i)
using namespace std;
using ll = long long;
using l = long;
using vi = vector<int>;
using vl = vector<l>;
using vll = vector<ll>;
using vvl = vector<vector<l>>;
using vvll = vector<vector<ll>>;
using pll = pair<ll, ll>;

int main()
{
    ll n, m, l, r, mal = 0, mir = 100000; cin >> n >> m;
    FR(i, m) {
        cin >> l >> r;
        mal = max(mal, l);
        mir = min(r, mir);
    }
    ll res;
    (res = mir - mal + 1) >= 0 ? cout << res : cout << 0;
    return 0;
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	for (int i = 0; ; i++) {
		if (i % 2 == 0) {
			c -= b;
			if (c <= 0) { cout << "Yes" << endl; break; }
		}
		else {
			a -= d;
			if (a <= 0) { cout << "No" << endl; break; }
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200010;
int a[N], n;
ll sum[N];
inline void chkmin(ll& a, ll b){
	if(a > b) a = b;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		a[i] -= i;
	}
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++)
		sum[i] = sum[i - 1] + a[i];
	ll ans = 1LL << 60;
	for(int i = 1; i <= n; i++)
		chkmin(ans, (ll)a[i] * i - sum[i] + (sum[n] - sum[i - 1] - 1LL * a[i] * (n - i + 1)));
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#define MAXW 1000000500
#define MAXN 105 
#define MAXV 10001
//question why I can not get the right size, try in java
//the sizze of array is the same as W
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int main(){
	
	//i means:the first ith ele and j means: the capacity
	int N = 0,W=0;
	scanf("%d %d",&N,&W);
	int dp[10001]; // store the value
	int ele[N+1][2];
	for(int i = 1; i<=N;i++){
		scanf("%d %d",&ele[i][0],&ele[i][1]);//v,w	
	}
	//initialize the weight MAXW
	for(int i = 0; i<MAXV; i++){
		dp[i] = MAXW;
	}
	dp[0] = 0;
	for(int i = 1; i<=N; i++){
		for(int j = 10000; j>=ele[i][0]; j--){
			dp[j] = min(dp[j],dp[j-ele[i][0]]+ele[i][1]);
		}
	}
	int value = 0;
	for(int i = 0; i<MAXV; i++){
		if(dp[i]<=W) value = max(value,i);
	}
	printf("%d\n",value);
	return 0;
}


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


int main() {
    int n,m;
    cin >> n >> m;
    vector<int> data(m,0);
    rep(i,n){
        int k = 0;
        cin >> k;
        rep(j,k){
            int a;
            cin >> a;
            data.at(a-1)++;
        }
    }
    int ans = 0;
    rep(i,m){
        if(data.at(i) == n)ans++;
    }
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	// 入力
	ll N;
	cin >> N;
	vec H(N);
	REP(i, N) {
		cin >> H[i];
	}

	ll ans = 0;
	ll anstemp = 0;

	REP(i, N - 1) {
		if (H[i] >= H[i + 1]) anstemp++;
		else {
			Max(ans, anstemp);
			anstemp = 0;
		}
	}
	Max(ans, anstemp);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int f(int a,int b,int num){
	int ans=0;
	a = a%b;
	for(int i=0;i<num;i++){
		a*=10;
		ans += a/b;
		a = a%b;
	}
	return ans;
}

int main(){
	int a,b;
	int n;
	double c;
	while(cin>>a){
		cin>>b;
		cin>>n;
		c = a/(double)b;
		cout<<f(a,b,n)<<endl;
	}

	return 0;
}

/*
Sample Input
1 2 3
2 3 4
5 4 3
4 3 2
Output for the Sample Input
5
24
7
6
*/

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    int cnt = 0;
    FOR(i,1,n+1) if(i % 2 == 1) cnt++;
    double ans = (double) cnt / n;
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
dl = [[0,0] for _ in range(n)]
for i in range(n):
    dl[i][0] ,dl[i][1]= map(int, input().split())
     

for i in range(n-2):
    if dl[i][0] == dl[i][1] and dl[i+1][0] == dl[i+1][1] and dl[i+2][0] == dl[i+2][1]:
        print("Yes")
        exit()
print("No")



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pa;

#define fst first
#define snd second
#define pb push_back

const int maxn=500005,maxm=512;
const double pi=acos(-1.0);
//const ll mod=1000000007;
const ll mod=998244353;
const double eps=1e-8;

int n;

char c[5],b[5][5]={"AC","WA","TLE","RE"};
int a[5]={0};

int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
    {
        scanf("%s",c);
        if(c[0]=='A') a[0]++;
        else if(c[0]=='W') a[1]++;
        else if(c[0]=='T') a[2]++;
        else a[3]++;
    }
    for(i=0;i<4;i++) printf("%s x %d\n",b[i],a[i]);
    return 0;
}


Measured memory_bytes: 3816
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfLong().toLongArray()
    fun dfs(nest: Int, left: Int, right: Int, c_l: Int, c_r: Int): Long {
        var ans = if (left + 1 < right) Long.MAX_VALUE else 0L
        for (m in left + 1 until right) {
            val c_m = c_l + c_r
            ans = Math.min(ans, dfs(nest+1, left, m, c_l, c_m) + dfs(nest+1, m, right, c_m, c_r) + c_m * A[m])
        }
        return ans
    }
    val ans = A[0] + dfs(0,0, N - 1, 1, 1) + A[N - 1]
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { it.toLong() }



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

#define y1 as214
#define ii pair < int , ll >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back
#define t top()

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

#define ll long long
#define oo INT_MAX
#define int long long

ll n , mod = 1e9 + 7;
ll dp[100005][105];
string s;
vector < int > digit;

ll getdigit(int idx , int sum , int tight)
{
    if(idx == -1)
        return (sum == 0);
    if(tight == 0 && dp[idx][sum] != -1)
        return dp[idx][sum];
    int lim = (tight == 0) ? 9 : digit[idx];
    ll ret = 0;
    FOR(k , 0 , lim)
        ret = (ret + getdigit(idx - 1 , (sum + k) % n , tight & (digit[idx] == k))) % mod;
    if(tight == 0)
        dp[idx][sum] = ret;
    return ret;
}

main()
{
    //freopen("S.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    getline(cin , s);
    memset(dp , -1 , sizeof(dp));
    for(int i = s.size() - 1 ; i >= 0 ; i--)
        if(s[i] >= 48 && s[i] <= 57)
            digit.pb(s[i] - 48);
    cin >> n;
    int x = getdigit(digit.size() - 1 , 0 , 1) - 1;
    if(x < 0)
        cout << x + mod;
    else
        cout << x;
}


Measured memory_bytes: 83328
<?php

$N = trim(fgets(STDIN));
$A = [];
$A[] = explode(" ", trim(fgets(STDIN)));
$A[] = explode(" ", trim(fgets(STDIN)));

$max = 0;
for ($i = 0; $i < $N; $i++) {
    $tmp = 0;
    for ($j = 0; $j <= $i; $j++) {
        $tmp += $A[0][$j];
    }
    for ($j = $i; $j < $N; $j++) {
        $tmp += $A[1][$j];
    }
    if ($tmp > $max) {
        $max = $tmp;
    }
}

echo $max.PHP_EOL;

Measured memory_bytes: 3956
import Data.Array.Unboxed

type Tab = Array Int Int

main :: IO ()
main = do
  n <- readLn :: IO Int
  ns <- zip [1..] <$> getInts
  let tab = accumArray (\_ c -> c) (-1) (1, n) ns :: Tab
  print $ solve tab n

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: Tab -> Int -> Int
solve tab n = go [1..n] `div` 2
  where
    go [] = 0
    go (x:xs) = let b = tab ! x
                    a = tab ! b in
                  (if a == x then 1 else 0) + go xs


Measured memory_bytes: 42748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

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

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int arr[n+1];
		int ans = 0;
		for(int i=1; i<=n; i++) {
			cin>>arr[i];
			if(i%2 and arr[i]%2) ans++;
		}
		cout<<ans<<"\n";
 	}
 	return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
#define MP make_pair
#define PB push_back
const int N=1e5+10;
const int INF=1e9+10;
int main(){
int n,m,s,d[N],l;
pi temp,nxt;
vector<pi> graph[N];
priority_queue<pi,vector<pi>,greater<pi>>pq;
scanf("%d%d%d",&n,&m,&s);
for(int i=0;i<n;i++)d[i]=INF;
d[s]=0;
while(m--){
scanf("%d%d%d",&l,&temp.F,&temp.S);
graph[l].PB(temp);
}
pq.push(MP(0,s));
while(!pq.empty()){
nxt=pq.top();
pq.pop();
if(d[nxt.S]<nxt.F)continue;
for(int i=0;i<graph[nxt.S].size();i++)if(nxt.F+graph[nxt.S][i].S<d[graph[nxt.S][i].F]){
d[graph[nxt.S][i].F]=nxt.F+graph[nxt.S][i].S;
pq.push(MP(d[graph[nxt.S][i].F],graph[nxt.S][i].F));
}
}

for(int i=0;i<n;i++)if(d[i]==INF)printf("INF\n");
else printf("%d\n",d[i]);
}


Measured memory_bytes: 12636
#include <iostream>

using namespace std;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int X; cin >> X;
	int ans = 1;
	while (1) {
		if ((ans * X) % 360 == 0) {
			cout << ans << "\n";
			return 0;
		}
		++ans;
	}

	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>

using namespace std;

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

	string a, b;
	cin >> a >> b;
	string s = a + b;
	int x = 0;
	for (int i = 0; i < s.length(); i++) {
		x = x * 10 + (s[i] - '0');
	}
	
	for (int i = 1; i <= 500; i++) {
		if (x == i * i) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

string k;
int d;
int dp[10010][110][2];

signed main() {
	cin >> k >> d;
	int n = (int)k.size();
	dp[0][0][0] = 1;
	for (int i = 1; i <= n; i++) {
		int x = k[i - 1] - '0';
		for (int j = 0; j < 10; j++) {
			if (j == x) {
				for (int l = 0; l < d; l++) {
					dp[i][(l + j) % d][0] += dp[i - 1][l][0];
					dp[i][(l + j) % d][1] += dp[i - 1][l][1];
					dp[i][(l + j) % d][0] %= mod;
					dp[i][(l + j) % d][1] %= mod;
				}
			}
			else if (j < x) {
				for (int l = 0; l < d; l++) {
					dp[i][(l + j) % d][1] += dp[i - 1][l][1];
					dp[i][(l + j) % d][1] += dp[i - 1][l][0];
					dp[i][(l + j) % d][1] %= mod;
				}
			}
			else {
				for (int l = 0; l < d; l++) {
					dp[i][(l + j) % d][1] += dp[i - 1][l][1];
					dp[i][(l + j) % d][1] %= mod;
				}
			}
		}
	}
	cout << (dp[n][0][0] + dp[n][0][1] - 1 + mod) % mod << endl;
}

Measured memory_bytes: 17408
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define N 110
using namespace std;
inline void read(int &x)
{
	x=0;
	int p=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^'0');c=getchar();}
	x*=p;
}
int h,w;
int n;
int a[N*N];
int map[N][N];
int fx[4][2]={{0,1},{0,-1},{-1,0},{1,0}};
struct node
{
	int x,y;
}s;
/*void bfs()
{
	int x=1,y=1;
	s.x=1;
	int ys=1;
	queue<node>q;
	q.push((node){x,y});
	while(!q.empty())
	{
		node k=q.front();
		q.pop();
		for(int i=0;i<4;i++)
		{
			int xx=fx[i][0]+k.x,yy=fx[i][1]+k.y;
			if(xx<0||xx>h||yy<0||yy>w||map[xx][yy])continue;
			q.push((node){xx,yy});
			map[xx][yy]=ys;
			s.y++;
			if(s.y==a[ys]){ys++;s.x=ys;s.y=0;}
		}
	}
}*/
void dfs(int x,int y,int cs)
{
	if(x<1||y<1||x>h||y>w)return;
	if(cs==h*w-1)
	{
		map[x][y]=s.x;
		for(int i=1;i<=h;i++)
		{
			for(int j=1;j<=w;j++)
			printf("%d ",map[i][j]);
			printf("\n");
		}
		exit(0);
	}
	map[x][y]=s.x;
	s.y++;
	if(s.y==a[s.x])s.x++,s.y=0;
	for(int i=0;i<4;i++)
	{
		int xx=fx[i][0]+x,yy=fx[i][1]+y;
		if(map[xx][yy])continue;
		else dfs(xx,yy,cs+1);
	}
}
int main()
{
//	freopen("D.in","r",stdin);
//	freopen("D.out","w",stdout);
	read(h);read(w);
	read(n);
	for(int i=1;i<=n;i++)
	read(a[i]);
	s.x=1;s.y=0;
	dfs(1,1,0);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n;
const int N=3010;
int posa[N],posb[N],id[N<<1],nt[N<<1];
string s,f[N];
int main()
{
	cin>>n>>s;s=" "+s;
	for(int i=1,a=0,b=0;i<=n*2;++i)
		if(s[i]=='a')posa[id[i]=++a]=i;
		else posb[id[i]=++b]=i;
	posa[n+1]=posb[n+1]=2*n+1;id[2*n+1]=n+1;
	for(int i=1,j=0;i<=n+1;++i)
		while(j<min(posa[i],posb[i]))nt[++j]=i;
    for(int i=n;i>=1;--i)
    {
    	if(posa[i]>posb[i])
    	{
    		int j=posb[i];
    		for(;posb[id[j]]<posa[id[j]]&&(id[j]<=i||posb[id[j]]<posa[id[j]-1]);++j)
    			if(id[j]>=i)f[i]+=s[j];
    		f[i]+=f[id[j]];
		}
		else f[i]="ab"+f[nt[posb[i]+1]];
    	f[i]=max(f[i],f[i+1]);
	}
	cout<<f[1];
	return 0;
}

Measured memory_bytes: 14592
#include <iostream>

using namespace std;

int main(){
    int h, w;
    while (cin >> h >> w && h) {
        for (int j=0; j<w; j++) cout << '#';
        cout << endl;
        for (int i=0; i<h-2; i++) {
            cout << '#';
            for (int j=0; j<w-2; j++) cout <<'.';
            cout << '#' << endl;
        }
        for (int j=0; j<w; j++) cout << '#';
        cout << endl << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
//全力前進　Yosoro！
//AT3877 
#include<cstdio>
#include<iostream>
using namespace std;
int d[11][11],n,m,tot,now,sum;
int pa[110],pb[110];
bool vis[11][11];
struct edg{
    int a,b,c;
}ans[310];
void print()
{
    int numn=0,numm=0;
    for (int i=1;i<=sum;i++)
    {
        numm+=ans[i].a+ans[i].b+1;
        numn+=ans[i].a+ans[i].b;
    }
    numn+=2;
    if (numn>300) {while(1);printf("Impossible\n");return;}
    printf("Possible\n");
    printf("%d %d\n",numn,numm);
    int t=1,pre=1;
    for (int i=1;i<=sum;i++)
    {
        pre=1;
        printf("%d %d %d\n",pre,++t,ans[i].c),pre=t;
        for (int j=1;j<=ans[i].a;j++)
        {
            printf("%d %d %c\n",pre,(j==ans[i].a&&ans[i].b==0)?numn:++t,'X'),pre=t;
        }
        for (int j=1;j<=ans[i].b;j++)
            printf("%d %d %c\n",pre,(j==ans[i].b)?numn:++t,'Y'),pre=t;

    }
    printf("%d %d\n",1,numn);
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            scanf("%d",&d[i][j]);
    for (int s=0;s<=300;s++)
        for (int a=0;a<=s&&a<=100;a++)
            for (int b=0;b<=s-a&&b<=100;b++)
                {
                    int c=s-a-b;
                    bool p=0,q=0;
                    int now=0;
                    for (int i=1;i<=n;i++)
                    {
                        for (int j=1;j<=m;j++)
                        {
                            if (a*i+b*j+c==d[i][j]&&!vis[i][j]) q=1,now++,pa[now]=i,pb[now]=j;
                            else if (a*i+b*j+c<d[i][j]) {p=1;break;}
                        }
                        if (p==1) break;
                    }
                    if ((!p)&&q) 
                    {
                        for (int i=1;i<=now;i++)
                            vis[pa[i]][pb[i]]=1;
                        tot+=now,ans[++sum].a=a,ans[sum].b=b,ans[sum].c=c;
                        if (tot==n*m){print();return 0;}
                    }
                }
    printf("Impossible\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
inline int read(){
    int x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}
int n,d,a[15][15],ans;
bool check(int x,int y){
	int o=0;
	for(int i=1;i<=d;i++){
		o=o+(a[x][i]-a[y][i])*(a[x][i]-a[y][i]);
	}
	int p=sqrt(o);
	if(p*p==o)return 1;
	return 0;
}
int main(){
	n=read(),d=read();
	for(int i=1;i<=n;i++)for(int j=1;j<=d;j++)cin>>a[i][j];
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(check(i,j))ans++;
		}
	}	
	cout<<ans;
}

Measured memory_bytes: 256
//encoding:utf-8
#include <iostream> //c++
#include<time.h> //時間にかんして
#include<stack> //スタックに関して　最新のデータから捨てる
#include<queue> //キューに関して　最古のデータから捨てる
#include<math.h>
#include<vector>
#include<algorithm> //sort とかにいる

#define ll long long
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans = 0;
  ans += min(a,b);
  ans += min(c,d);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int X = int.Parse(Console.ReadLine());
        if (X >= 2000) { Console.WriteLine("1"); }
        else
        {
            if (X % 100 <= (X / 100) * 5) { Console.WriteLine("1"); }
            else { Console.WriteLine("0"); }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T &n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

signed main(){
  int a,b; cin>>a>>b;
  if(a%2==1&&b%2==1) cout<<"Yes"<<en;
  else cout<<"No"<<en;
}

Measured memory_bytes: 256
inputLine = gets.chomp.split(" ")
numSubjects = inputLine[0].to_i
numSubmit = inputLine[1].to_i
wa = Array.new(100000, 0)
ac= Array.new(100000, false)
acnum = 0
wanum = 0

for i in 0 .. numSubmit - 1
  inputLine = gets.chomp.split(" ")
  targetSubject = inputLine[0].to_i
  result = inputLine[1]
  if ac[targetSubject] then
    next
  end
  if result == "AC" then
    ac[targetSubject] = true
    acnum += 1
    wanum += wa[targetSubject]
  elsif result == "WA" then
    wa[targetSubject] += 1
  end
end
printf("%d %d\n",acnum, wanum)

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    string s; cin >> s;
    int n = (int) s.length();
    vector<bool> used(n + 10, false);
    auto get = [&](int mod, int rem) {
        int res = 1;
        for (int i = 0; i < 100; i++) {
            res = (res * 10) % mod;
        }
        res -= rem;
        res += mod;
        res %= mod;
        res += mod;
        res += mod;
        res %= mod;
        assert(res >= 0);
        return res;
    };
    vector<int> cnt(n + 10, 0);
    int pos = -1;
    vector<int> gaps(n + 10, 0);
    set<int> rights, lefts;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            rights.insert(i);
        } else {
            lefts.insert(i);
        }
    }
    for (int i = 0; i < n; i++) {
        if (s[i] == 'L') {
            int dd = 0;
            auto it = rights.lower_bound(i);
            it--;
            int pos = *it;
            int ll = *lefts.upper_bound(pos);
            gaps[pos] = ll - pos + 1;
            for (int j = i; j >= 0 && !used[j]; j--) {
                if (s[j] == 'R') {
                    int first = pos;
                    int left = get(gaps[first], dd);
                    assert(first + left < n);
                    cnt[first + left]++;
                    used[j] = true;
                    dd++;
                } else {
                    int left = get(gaps[pos], i - pos);
                    assert(pos + left < n);
                    cnt[pos + left]++;
                    used[j] = true;
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << cnt[i] << " \n"[i == n - 1];
    }
}


Measured memory_bytes: 6096
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim S As String = NextString()
        WriteLine(New String() {"WA", "AC"}(B2I(Judge(S))))
    End Sub

    Function Judge(S As String) As Boolean
        Dim flg As Boolean


        For i As Integer = 0 To S.Length - 1
            If i = 0 Then
                If S(i) <> "A"c Then Return False
            ElseIf 2 <= i AndAlso i < S.Length - 1 AndAlso S(i) = "C"c AndAlso Not flg Then
                flg = True
            ElseIf S(i) <> StrConv(S(i), vbLowerCase) Then
                Return False
            End If
        Next
        If Not flg Then Return False
        Return True
    End Function

    Function B2I(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 20560
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);

    int A = scanner.nextInt();
    int V = scanner.nextInt();
    int B = scanner.nextInt();
    int W = scanner.nextInt();
    double T = scanner.nextDouble();

    if(V-W <= 0){
      System.out.println("NO");
      scanner.close();
      return;
    }

    double x = Math.abs((double)(B-A)) / (double)(V-W);
    // int y = (B-A) % (V-W);
    if(x > T){
        System.out.println("NO");
    }else{
        System.out.println("YES");
    }

    scanner.close();

  }
}

Measured memory_bytes: 37232
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,ans;
int a[25];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=2;i<n;i++){
		int res=0;
		for(int j=i-1;j<=i+1;j++) if(a[j]>a[i]) res++;
		if(res==1) ans++;
	}
	printf("%d",ans);
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a (n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    ll ans = 0;
    ll count = 1;
    ll now = a.at(0);
    for(int i=1; i<n; i++){
        if(a.at(i) == now) count++;
        else{
            if(now > count){
                ans += count;
                count = 1;
                now = a.at(i);
            }
            if(now < count){
                ans += count - now;
                count = 1;
                now = a.at(i);
            }
            if(now == count){
                count = 1;
                now = a.at(i);
                continue;
            }
        }
    }
    if(now > count){
        ans += count;
        now = a.at(n-1);
    }
    if(now < count){
        ans += count - now;
        now = a.at(n-1);
    }
    if(now == count){
        now = a.at(n-1);
    }
    if(n ==1){
        if(a.at(0) == 1) ans = 0;
        else ans = 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=readline()
    ans="None"
    for i in 'a':'z'
        if !(i in s)
            ans=i
            break
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 115656
#include "bits/stdc++.h"
using namespace std;

using  ll =          long long;
using ull = unsigned long long;
const char en = '\n';
const ll INFL = 810000001919114514;
const int INF =         1919114514;

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


char in[100000],b[4][100000];


char rev(char c){
	if(c=='S')
	return 'W';
	return 'S';
}
int main(){
	ios::sync_with_stdio(false);cin.tie();


	const char S='S',W='W';
	int n;
	cin>>n;

	REP(i,n){
		cin>>in[i];
	}

	b[0][0]=S;b[0][1]=S;
	b[1][0]=S;b[1][1]=W;
	b[2][0]=W;b[2][1]=S;
	b[3][0]=W;b[3][1]=W;

	FOR(i,1,n-1){
		REP(a,4){
			b[a][i+1]=((in[i]=='o')^(b[a][i]==W))?b[a][i-1]:rev(b[a][i-1]);
		}
	}

	/*
	REP(i,4){
		REP(j,n){
			cout<<b[i][j];
		}
		cout<<en;
	}
	*/
	REP(i,4){
		char c1=((in[n-1]=='o')^(b[i][n-1]==W))?b[i][n-2]:rev(b[i][n-2]);
		char c2=((in[0  ]=='o')^(b[i][0  ]==W))?b[i][n-1]:rev(b[i][n-1]);
		if(b[i][0]==c1&&b[i][1]==c2){
			REP(j,n){
				cout<<b[i][j];
			}
			cout<<en;
			return 0;
		}
	}
	cout<<-1<<en;


	return 0;
}


Measured memory_bytes: 896
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            String line = sc.nextLine();
            if(line.equals("0")) {
                break;
            }
            int n = Integer.parseInt(line);
            String line1 = sc.nextLine();
            String[] line1sp = line1.split(" ");
            int[] nums = new int[n];
            double sum = 0;
            double av = 0;
            for(int i = 0; i < n; i++) {
                nums[i] = Integer.parseInt(line1sp[i]);
                sum += nums[i];
            }
            av = sum / n;
            double x = 0;
            for(int i = 0; i < n; i++) {
                x += Math.pow(nums[i] - av, 2);
            }
            
            double delta = Math.sqrt(x / n);
            System.out.println(delta);
        }   
       
    
    }
 }


Measured memory_bytes: 28544
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int b[n],f[n],r[n],v[n];
	int b1[3][10] = {0},b2[3][10] = {0},b3[3][10] = {0},b4[3][10] = {0};
		
	for(int i = 0;i < n;i++){
		cin >> b[i] >> f[i] >> r[i] >> v[i];
		switch (b[i]){
			case 1: b1[f[i] - 1][r[i] - 1] += v[i]; break;
			case 2: b2[f[i] - 1][r[i] - 1] += v[i]; break;
			case 3: b3[f[i] - 1][r[i] - 1] += v[i]; break;
			case 4: b4[f[i] - 1][r[i] - 1] += v[i]; break;
		}
	}
	
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 10;j++){
			cout << " " << b1[i][j];
		}
		cout << endl;
	}
	
	cout << "####################" << endl;
	
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 10;j++){
			cout << " " << b2[i][j];
		}
		cout << endl;
	}
	
	cout << "####################" << endl;
	
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 10;j++){
			cout << " " << b3[i][j];
		}
		cout << endl;
	}
	
	cout << "####################" << endl;
	
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 10;j++){
			cout << " " << b4[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

LL MOD=998244353,MAX=222222;
LL N,M,K;

LL fac[222222], finv[222222], inv[222222];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
LL COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

LL modpow(LL a, LL n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}
int main() {
	COMinit();
	cin>>N>>M>>K;
	LL ans=0;
	for(int i=0;i<=K;i++){
		LL tmp=modpow(M-1,N-1-i);
		tmp=tmp*M%MOD;
		tmp=tmp*COM(N-1,i)%MOD;
		ans=(ans+tmp)%MOD;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 8816
using System;

public class HelloWorld
{
    static public void Main ()
    {
		string[] s = Console.ReadLine().Split(' ');
	
		int a = int.Parse(s[0]);
		int b = int.Parse(s[1]);
		
		if(a==b)
		{
			Console.Write((a*2).ToString());

		}
		else
		{
			a = a > b ? a : b ;			
		
			Console.Write((a*2-1).ToString());	
		}
		
		
		
			
	 }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int X, N;
    cin >> X >> N;
    map<int, int> mp;
    for (int i = 0; i < N; i++)
    {
        int n;
        cin >> n;
        mp[n]++;
    }
    int ans = X;
    int i = 0;
    while (1)
    {
        if (mp[X - i] == 0)
        {
            cout << X - i << endl;
            return 0;
        }
        if (mp[X + i] == 0)
        {
            cout << X + i << endl;
            return 0;
        }
        i++;
    }
}


Measured memory_bytes: 3636
# include <stdio.h>
# include <string.h>
# include <iostream>
# include <algorithm>

using namespace std;

const int mod = 1e9 + 7;

int n, m, k;
int f[2][2010], s[2010];

int main() {
//	freopen("board.in", "r", stdin);
//	freopen("board.out", "w", stdout);
	cin >> n >> m >> k;	
	int l_max = (n + m - 1) / (k - 1);
	f[0][0] = 1;
	int pre = 0, cur = 1, ans = 0;
	for (int i = 1; i <= l_max; ++ i) {
		s[0] = f[pre][0];
		for (int j = 1; j <= n; ++ j) {
			s[j] = s[j - 1] + f[pre][j];
			if (s[j] >= mod) s[j] -= mod;
		}
		for (int j = 0; j <= n && j <= k - 1; ++ j)
			f[cur][j] = s[j];
		for (int j = k; j <= n; ++ j) {
			f[cur][j] = s[j] - s[j - k];
			if (f[cur][j] < 0) f[cur][j] += mod;
		}
		for (int j = 1; j <= n; ++ j) 
			if (j % (k - 1) == n % (k - 1) && (k - 1 - j % (k - 1)) % (k - 1) == (m - 1) % (k - 1) && (k - 1) * i - j <= m - 1)
				ans = (1ll * ans + f[cur][j] + (s[j - 1] - s[j]) + mod) % mod;
		swap(cur, pre);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kessido
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATwoAbbreviations solver = new ATwoAbbreviations();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATwoAbbreviations {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.NextInt();
            long m = in.NextInt();
            char[] s = in.next().toCharArray();
            char[] t = in.next().toCharArray();

            if (s[0] != t[0]) {
                out.println(-1);
                return;
            }
            if (n == m) {
                if (Arrays.equals(s, t)) {
                    out.println(n);
                } else {
                    out.println(-1);
                }
                return;
            }
            long gcd = MathExtensions.gcd(n, m);
            long lcd = (n / gcd) * m;

            for (long x = 1; x < m; x++) {
                long xn = x * n;
                long y = xn / m;
                if (y * m == xn) {
                    if (s[(int) y] != t[(int) x]) {
                        out.println(-1);
                        return;
                    }
                }
            }

            out.println(lcd);
//        x*l/m=y*l/n
//        x/m=y/n
//        x=y*m/n;
//        x*n=y*m;
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NextInt() {
            return Integer.parseInt(next());
        }

    }

    static class MathExtensions {
        public static long gcd(long a, long b) {
            if (b == 0) return a;
            long t;
            while (a != 0) {
                t = a;
                a = b % a;
                b = t;
            }
            return b;
        }

    }
}



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

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

/*
    ll  A;
    float B;
    cin >> A >> B;
*/
    long double A,B;
    cin >> A >> B;
    cout << (long long)(A*B) << endl;

/*
    ll ans = 0;
    double amari = 0.0;
    ll keta = 1;
    while(A!=0){
        int res = A%10;
        ans += keta * res * B;
        amari += ((double)(keta * res * B) - (ll)(keta * res * B));
        keta *= 10;
        A /= 10;
    }
    cout << ans << endl;
*/
    

    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M; cin>>N>>M;
  vector<int>K(M);
  vector<vector<int>>S(M,vector<int>(N));
  vector<int>p(M);
  for(int i=0;i<M;i++){
    cin>>K[i];
    for(int j=0;j<K[i];j++)cin>>S[i][j];
  }
  for(int i=0;i<M;i++)cin>>p[i];
  long long ans=0;
  for(int bit=0;bit<(1<<N);bit++){
    vector<bool>C(N,false);
    for(int i=0;i<N;i++)if(bit&(1<<i))C[i]=true;
    for(int i=0;i<M;i++){
      long long count=0;
      for(int j=0;j<K[i];j++)if(C[S[i][j]-1])count++;
      if(count%2!=p[i])break;
      if(i==M-1)ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <cstring>
#include <ctime>
#include <vector>
#define inf 1e9
#define ll long long
#define For(i,j,k) for(ll i=j;i<=k;i++)
#define Dow(i,j,k) for(ll i=k;i>=j;i--)
using namespace std;
inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return x*f; }
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  }
inline void writeln(ll x){write(x);puts("");}
int  n,a[500001],ans[500001];
int main()
{
	n=read();
	For(i,1,n)	a[i]=read();
	ans[n/2+1]=a[1];
	int mid=n/2+1;
	int t1=mid,n1=3;
	if(n&1)
	{
		while(t1-1>0)
		{
			t1--;
			ans[t1]=a[n1];n1+=2;
		}
		int t2=mid,n2=2;
		while(t2+1<=n)
		{
			t2++;
			ans[t2]=a[n2];n2+=2;
		}
	}
	else
	{
		int t2=mid,n2=2;
		while(t2-1>0)
		{
			t2--;
			ans[t2]=a[n2];n2+=2;
		}
		int t1=mid,n1=3;
		while(t1+1<=n)
		{
			t1++;
			ans[t1]=a[n1];n1+=2;
		}
	}
	For(i,1,n)	write(ans[i]),putchar(' ');
}  

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
	int N;
  	cin>>N;
  	int a[N];
  	int num[100010];
  	rep(i,100009) num[i]=0;
  	
  	rep(i,N) {
      cin>>a[i];
      num[a[i]]++;
    }
  	
  	int m=0;
  
  	rep(i,100000){
      int sum=num[i]+num[i+1]+num[i+2];
      m=max(m,sum);
    }
  
  	cout<<m<<endl;
  
  	
  	
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    ll n;
    cin >> n;
    vll a(n);
    ll allXOR = 0;
    rep(i, n){
        cin >> a[i];
        allXOR ^= a[i];
    }

    // for(auto x : a){
    //     cout << (allXOR ^ x) << ' ';
    // }

    for(int i = 0; i < a.size() - 1; i++){
        cout << (allXOR ^ a[i]) << ' ';
    }
    cout << (allXOR ^ *a.rbegin());
    cout << endl;
    return 0;
}


Measured memory_bytes: 4772
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;//for StringBuilder
class c
{
    static void Main()
    {
        int x = int.Parse(Console.ReadLine());
        if (x <= 599) Console.WriteLine(8);
        else if (x <= 799) Console.WriteLine(7);
        else if (x <= 999) Console.WriteLine(6);
        else if (x <= 1199) Console.WriteLine(5);
        else if (x <= 1399) Console.WriteLine(4);
        else if (x <= 1599) Console.WriteLine(3);
        else if (x <= 1799) Console.WriteLine(2);
        else Console.WriteLine(1);
    }
}

Measured memory_bytes: 27468
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


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

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

void primes(vector<int>& list, int a){
    list.push_back(2);
    int index = 0;
    for (int i=3; i<a; ++i){
        bool check = 1;
        for(int j=0; j<=index; j++){
            if(i%list[j]==0){
                check=0;
                break;
            }
        }
        if (check){
            list.push_back(i);
            index ++;
        }
    }
}

int main(){
    int x; cin >> x;
    vector<int> prime = {};
    primes(prime, x);
    if(x==2){
        cout << 2 << endl;
        return 0;
    }
    for(int j=x;x<=j; ++j){
        bool check = 1;
        for(int p:prime){
            if(j%p==0) {
                check=0;
                break;
            }
        }
        if(check==1){
            cout << j << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 384