akhauriyash/Code-Regression huggingface dataset:
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 500001LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

struct Query {
    ll l, r, ind;
};

bool compare (Query A, Query B) {
    return (A.r < B.r);
}

ll ft[MAX];
ll vis[MAX];

void update(ll i, ll val){
    while(i < MAX){
        ft[i] += val;
        i += (i & (-i));
    }
}

ll query(ll i){
    ll ret = 0;
    while(i > 0){
        ret += ft[i];
        i -= (i & (-i));
    }
    return ret;
}

void Flash(){
    ll n, q;
    cin>>n>>q;
    ll a[n + 1];
    for (ll i = 1; i <= n; i++) {
        cin>>a[i];
    }
    memset(vis, -1, sizeof(vis));
    memset(ft, 0, sizeof(ft));
    ll l, r;
    Query qq[q];
    for (ll i = 0; i < q; i++) {
        cin>>qq[i].l>>qq[i].r;
        qq[i].ind = i;
    }
    sort (qq, qq + q, compare);
    ll ans[q];
    memset(ans, -1, sizeof(ans));
    ll currPtr = 1;
    ll queryPtr = 0;
    while (currPtr <= n) {
        if (vis[a[currPtr]] != -1) {
            update(vis[a[currPtr]], -1);
        }

        vis[a[currPtr]] = currPtr;
        update(currPtr, 1);

        while (queryPtr < q && currPtr >= qq[queryPtr].r) {
            //debugg(queryPtr);
            ans[qq[queryPtr].ind] = (query(qq[queryPtr].r) - query(qq[queryPtr].l - 1));
            ++queryPtr;
        }
        ++currPtr;
    }

    for (ll i = 0; i < q; i++) {
        cout<<ans[i]<<"\n";
    }
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


Measured memory_bytes: 31096
N, M = map(int, input().split())

l = [0] * (N + 1)
l[1] = 1
c = [1] * (N + 1)

for _ in range(M):
    x, y = map(int, input().split())
    if l[x] == 1:
        l[y] = 1
    if c[x] == 1:
        l[x] = 0
    c[x] -= 1
    c[y] += 1

print(sum(l))


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

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

#define INF 100000000

double snuke(LL a)
{
	LL adig = 0, atem = a;
	while (atem > 0)
	{
		adig += atem % 10;
		atem /= 10;
	}
	return (double)(a)/(double)(adig);
}

int main()
{
	int K;
	cin >> K;

	vector<LL> numbers;
	LL base = 1;
	set<LL> used;
	for (int a = 0; a < 15; a++)
	{
		for (int b = 1; b <= 150; b++)
		{
			LL c = base*(b+1) - 1;
			if (used.find(c) != used.end())
				continue;
			numbers.push_back(c);
			used.insert(c);
		}
		base *= 10;
	}
	unique(numbers.begin(), numbers.end());
	sort(numbers.begin(), numbers.end());	
	reverse(numbers.begin(), numbers.end());
	
	double best = DBL_MAX;
	vector<LL> res;
	for (int i = 0; i < numbers.size(); i++)
	{
		double now = snuke(numbers[i]);
		if (now - 0.0000000000001 <= best)
		{
			best = now;
			res.push_back(numbers[i]);
		}
	}
	reverse(res.begin(), res.end());
	for (int k = 0; k < K; k++)
		cout << res[k] << endl;
}



Measured memory_bytes: 3644
#include <stdio.h>

int main(void) {
	int num1, num2,temp;
	int i, j;
	int nums[100000];

	scanf("%d", &num1);
	for (i = 0; i < num1; i++) {
			scanf("%d",&num2);
			nums[i] = num2;
	}
	for (i = 0; i < num1 - 1; i++) {
		if (nums[i] < nums[i + 1]) {
			temp = nums[i];
			nums[i] = nums[i + 1];
			nums[i + 1] = temp;
		}
		temp = nums[i] % nums[i + 1];
		while (temp != 0) {
			nums[i] = nums[i + 1];
			nums[i + 1] = temp;
			temp = nums[i] % nums[i + 1];
		}
	}
	printf("%d", nums[i]);
	
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#define N 10000
int search(int t,int S[],int n)
{
    int i=0;
    S[n]=t;
    while(S[i]!=S[n])
    {
        i++;
    }
    if(i!=n) return 1;
    return 0;
}
int main()
{
    int sum=0;
    int n;
    int S[N];
    int q;
    int T[N];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    scanf("%d",&S[i]);
    scanf("%d",&q);
    for(int i=0;i<q;i++)
    scanf("%d",&T[i]);
    for(int i=0;i<q;i++)
    {
        //TODO
        if(search(T[i],S,n)) sum++;
    }
    printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 2740
# がんばったけどTLE
n, m = [int(i) for i in input().split()]
G = [[] for i in range(n)]
for mi in range(m):
    u, v = [int(i) for i in input().split()]
    G[u].append(v)
    G[v].append(u)
NIL = -1
Group = [NIL for i in range(n)]
num = 0
S = []
D = []


def DFS(id, u):
    S.append(u)
    Group[u] = id
    while S != []:
        for v in G[u]:
            if Group[v] == NIL:
                S.append(v)
                Group[v] = id
        u = S.pop()

'''
for num in range(n):
    if NIL not in Group:
        break
    else:
        u = Group.index(NIL)
        DFS(num, u)
'''
num = 0
q = int(input())
for qi in range(q):
    s, t = [int(i) for i in input().split()]
    if Group[s] == NIL:
        DFS(num, s)
        num += 1
    if Group[s] == Group[t]:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 23148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    double r=180.0/3.141592653589793;
    double a,b,x; cin >> a >> b >> x;
    if(a*a*b>2*x){
        fout(90.0-atan2(2.0*x,a*b*b)*r);
    }else{
        fout(90.0-atan2(a*a*a,2.0*(a*a*b-x))*r);
    }
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


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

  int cnt_a=0, cnt_b=0, cnt0=0, ans=0;
  for(int i=0;i<n;i++) {
    for(int j=0;j<(int)s[i].size()-1;j++) {
      if(s[i][j]=='A' && s[i][j+1]=='B') { ans++; }
    }
    if(s[i][0] == 'B') { cnt_b++; }
    if(s[i][(int)s[i].size()-1] == 'A') { cnt_a++; }
    if(s[i][0] == 'B' && s[i][(int)s[i].size()-1] == 'A') { cnt0++; }
  }

  if(cnt0>0 && (cnt_a-cnt0)+(cnt_b-cnt0)==0) { ans--; }
  cout << ans + cnt0 + min(cnt_a-cnt0,cnt_b-cnt0) << endl;
  return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int powmod(int x, int y, int mod)
{
    int res = 1;
    x %= mod;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

void solve()
{
}

int main()
{
    // freopen("filename.in","r",stdin);
    // freopen("filename.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    ll a;
    cin>>a;
    cout<<a + a*a + a*a*a;

    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MAX=1001000;
int main(){
  ll N;
  cin>>N;
  vector<ll>A(N);
  for(ll i=0;i<N;i++)cin>>A[i];
  vector<ll>D(MAX,0);
  for(auto a:A){
    if(D[a]!=0){
      D[a]=2;
      continue;
    }
    for(ll i=a;i<=MAX;i+=a){
      D[i]++;
    }
  }
  ll cnt=0;
  for(auto a:A){
    if(D[a]==1)cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 12760
def shellsort(a):
    l = len(a)
    gaps = [1]
    while gaps[0]*3+1 < l and len(gaps) <= 100:
        gaps.insert(0, gaps[0]*3+1)
    count = 0
    for g in gaps:
        for i in range(g, l):
            v = a[i]
            j = i-g
            while j >= 0 and v < a[j]:
                a[j+g] = a[j]
                j -= g
                count += 1
            a[j+g] = v

    print(len(gaps))
    print(" ".join([str(n) for n in gaps]))
    print(count)
    print("\n".join([str(n) for n in a]))

shellsort([int(input()) for _ in [None]*(int(input()))])

Measured memory_bytes: 132060
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin >> s;
  bool single = true;
  for(int i = 0; i < s.size(); i++){
 	for(int j = 0; j < s.size(); j++){
    if(s[i] == s[j] && i != j)
      single = false;
    }
  }
  if(single)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep (i, n) {
    int tmp;
    cin >> tmp;
    if (tmp == i + 1) v[i] = 1;
    else v[i] = 0;
  }
  int ans = 0;

  for (int i = 1; i < n - 1; i++) {
    if (v[i] == 1) {
      if (v[i - 1] + v[i] == 2) {
        ans++;
        v[i - 1] = v[i] = 0;
      } else if (v[i] + v[i + 1] == 2) {
        ans++;
        v[i] = v[i + 1] = 0;
      } else {
        ans++;
        v[i] = 0;
      }
    }
  }
  if (n == 2 && v[0] == 1 && v[n - 1] == 1) ans++;
  else {
    if (v[0] == 1) ans++;
    if (v[n - 1] == 1) ans++;
  }
  P(ans);
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>

using namespace std;

uint32_t ceil2(uint32_t a)
{
    uint32_t b = 1;
    while (a >= b) {
        b <<= 1;
    }
    return b;
}

int main()
{
    int N;
    cin >> N;

    unordered_multiset<int> S;
    vector<int> A(N);
    for (auto &&a : A) {
        cin >> a;
        S.insert(a);
    }
    sort(begin(A), end(A), greater<>());

    int ans = 0;
    for (auto a : A) {
        auto pa = S.find(a);
        if (pa == S.end()) {
            continue;
        }
        S.erase(pa);

        int b = ceil2(a) - a;

        auto pb = S.find(b);
        if (pb != S.end()) {
            S.erase(pb);
            ans += 1;
        }
    }

    cout << ans << '\n';
}


Measured memory_bytes: 9416
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n, k;
    string s;
    cin >> n >> k >> s;

    s[k - 1] = tolower(s[k - 1]);
    cout << s;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string s, t;
    cin >> s >> t;

    cout << t+s << endl;
    

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

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

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

void solve() {
    int ans = 0;
    // 人数分 bit を立てる
    // 人数分の真偽パターン
    for(int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        //cerr << bits << endl;
        for(int i = 1; i <= N; i++) {
            // i-1 はbitshift数を表す
            // 1 を 0 bitshiftすると 1 001
            // 1 を 1 bitshiftすると 2 010
            // 1 を 2 bitshiftすると 4 110
            // & は両方が1のときのみ1とする
            if(!(bits & (1 << (i-1)))) continue;
            // 真実を証言している場合のみ検証
            for(int j = 1; j <= A[i]; j++) {
                // ^ : XOR
                // 右bitシフトしている
                // bitですでにその人が真か偽か仮定しているのでそれと反して(XOR)いたら矛盾
                //cerr << "\t" << i << "," << j  << ":" << (bits >> (x[i][j]-1)) << endl;
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}

int main() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    solve();
    return 0;
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u)
    cout << a-1 << " " << b << endl;
  else
    cout << a << " " << b-1 << endl;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::HashSet;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let mut hash = HashSet::new();
    let n = read_as_vec::<usize>()[0];

    let a = read_as_vec::<u64>();

    for elem in &a{
        hash.insert(*elem);
    }

    if hash.len() == n{
        println!("YES");
    }else{
        println!("NO");
    }
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int i, ans;
  ans=1;
  rep(i, n) {
    if (ans > k) {
      ans+=k;
    } else {
      ans*=2;
    }
  }
  cout << ans << endl;
}
  

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

int main()
{
ll n , p ;
cin >> n >> p ;
string s ;
cin >> s ;
auto mod = [&](ll modx) {modx%=p;modx+=p;modx%=p;return modx; };
vector<ll> v;
rep(i,n){
  v.push_back(s[i]-'0');
}
if(p==2||p==5){
  rep(i,n){
    if(v[i]%p==0)ans+=i+1;
  }
}
else{
vector<ll> a(p);
vector<ll> b(n);
ll k=1,kk=0;
rep(i,n){
  kk=mod(k*v[n-1-i]+kk);
  a[kk]++;
  b[n-i-1]=kk;
  k=mod(k*10);
}
a[0]++;
rep(i,n){
  ans+=a[b[i]]-1;
  a[b[i]]--;
}

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

Measured memory_bytes: 3700
n = int(input())
a = list(map(int, input().split()))

import math
l_gcd = []
r_gcd = []

c = a[0]
for i in a[:-1]:
  c = math.gcd(c, i)
  l_gcd.append(c)
  
c = a[-1]
for j in a[1:][::-1]:
  c = math.gcd(c, j)
  r_gcd.append(c)
  
ans = max(r_gcd[-1], l_gcd[-1])
for r, l in zip(r_gcd[:-1], l_gcd[:-1][::-1]):
  c = math.gcd(r, l)
  ans = max(ans, c)
print(ans)

Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int N, H[100];
main(void){
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> H[i];
  }
  int r=0;
  for(int i=0; i<N; i++){
    bool flag = true;
    for(int j=0; j<i; j++){
      if(H[j]>H[i]){
        flag=false;break;
      }
    }
    if(flag)r+=1;
  }
  cout << r << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000000000000;
const double PI = acos(-1);
constexpr int MAX_V = 100010;

int main() {
	int n;
	cin >> n;
	vector<LL>a(3 * n);
	priority_queue<LL, vector<LL>, greater<LL>>minq;
	priority_queue<LL> maxq;
	LL sum1 = 0, sum2 = 0;
	LL ans = -INF;

	for (int i = 0; i < 3 * n; i++) {
		cin >> a[i];
		if (i < n) {
			minq.push(a[i]);
			sum1 += a[i];
		}
		if(i>=n*2) {
			maxq.push(a[i]);
			sum2 += a[i];
		}
	}
	vector<LL>suma(n + 1), sumb(n + 1);
	suma[0] = sum1;
	sumb[0] = sum2;
	for (int i = 0; i < n; i++) {
		minq.push(a[n + i]);
		sum1 += a[n + i];
		sum1 -= minq.top();
		suma[i + 1] = sum1;
		minq.pop();
	}
	for (int i = 0; i < n; i++) {
		maxq.push(a[2 * n - 1 - i]);
		sum2 += a[2 * n - 1 - i];
		sum2 -= maxq.top();
		sumb[i + 1] = sum2;
		maxq.pop();
	}
	for (int i = 0; i < n + 1; i++) {
		ans = max(ans, suma[i] - sumb[n - i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5876
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <set>
#include <map>
#include <numeric>
#include <string>

intmax_t gcd(intmax_t m, intmax_t n) {
  while (n) std::swap(m %= n, n);
  return m;
}

intmax_t lcm(intmax_t m, intmax_t n) {
  return m / gcd(m, n) * n;
}

intmax_t nya(intmax_t M, intmax_t C, intmax_t D) {
  intmax_t res = 0;
  res += M / C;
  res += M / D;
  res -= M / lcm(C, D);
  return M-1 - res;
}

int main() {
  intmax_t A, B, C, D;
  scanf("%jd %jd %jd %jd", &A, &B, &C, &D);

  intmax_t res = 0;
  res += nya(B, C, D);
  res -= nya(A, C, D);
  if (A % C != 0 && A % D != 0) ++res;
  printf("%jd\n", res);
}


Measured memory_bytes: 128
/*
Dont BLUNDER
*/
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;*/
 
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1=998244353;
int const mod=1000000007;
#define l first
#define r second
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ******** Using PBDS ********
 /*typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
                os; */
 
int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}
int go(int x)
{
    int ans=0;
    for(int i=1;i<=x;i++)
    {
        if((i)*(i+1)<=2*x)
        {
            ans=i;
        }
        else
        break;
    }
    return ans;
}


signed main() {
	haha
	int x;
	cin>>x;
	vector<pii> v;
	int x1=x;
	for(int i=2;i*i<=x1;i++)
	{
	    int c=0;
	    while(x%i==0)
	    {
	        c++;
	        x/=i;
	    }
	    if(c>0)
	    {
	        v.pb({i,c});
	    }
	}
	if(x!=1)
	{
	    v.pb({x,1});
	}

	int ans=0;
	for(auto x:v)
	{
	   // cout<<x.first<<" "<<x.second<<endl;
	    ans+=go(x.second);
	}
	cout<<ans;
	
	
	




}

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

using namespace std;
typedef pair<int,int>P;

int h,w,k,n,x,y,c,ans;
int dp[10099];
set<P>s;

int A(int y,int x){
  return s.count(P(y-1,x))?2:1;
}

int B(int y,int x){
  if(s.count(P(y-1,x-1)))return 4;
  return 2;
}

int main(){
  cin>>w>>h>>k>>n;
  while(n--){
    cin>>x>>y;
    s.insert(P(y,x));
  }
  int t=(w/2+1);
  for(int i=3;i<=h;i+=2){
    memset(dp,0,sizeof(dp));
    dp[1]=A(i,1);
    dp[3]=min(dp[1]+A(i,3),B(i,3));
    for(int j=5;j<=w;j+=2){
      dp[j]=min(dp[j-2]+A(i,j),dp[j-4]+B(i,j));
    }
    ans+=dp[w];
    c+=dp[w]-(w/2+1);
  }
  if(t>k)cout<<-1<<endl;
  else{
    ans-=min(c,k-t)*2;
    if((k-t)>c)ans-=(k-t)-c;
    cout<<max(0,ans)<<endl;
  }
}


Measured memory_bytes: 7768
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
#include <functional>																							   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	char c;
	cin >> c;
	if(c == 'A'){
		cout << 'T' << endl;
	}
	else if(c == 'T'){
		cout << 'A' << endl;
	}
	else if(c == 'G'){
		cout << 'C' << endl;
	}
	else cout << 'G' << endl;
	
	
	
	
	
	
	
	
	
	
	
	
    
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int N;
    string S;
    cin>>N>>S;
    if(N%2==0){
        if(S.substr(0,N/2)==S.substr(N/2,N/2)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>

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

using namespace std;

int main() {
    string S; cin >> S;
    int N = S.size();
    int one = 0;
    int zero = 0;
    rep(i, N) {
        if (S[i] == '1') one++;
        else zero++;
    }   
    cout << 2 * min(one, zero) << endl;
}

Measured memory_bytes: 512
x,y = map(int, input().split())
if y % 2 == 0:
  y1 = y / 2
  d = y1 - x
  a = d.is_integer()
  if a == 1:
    if x >= d and d >= 0:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ar[100005]={0},gsum[100005]={0},rsum[100005]={0};
int main(){
  ll n,k;
  cin>>n>>k;
  for(int i=1;i<=n;i++){
    ll a;
    cin>>a;
    ar[i]=a;
    gsum[i]=gsum[i-1]+max(a,(ll)0);
    rsum[i]=rsum[i-1]+a;
  }
  ll ans=0;
  for(int i=0;i<n-k+1;i++){
    ll ls=gsum[i];
    ll rs=gsum[n]-gsum[i+k];
    ll ms=max((ll)0,rsum[i+k]-rsum[i]);
    ans=max(ans,ls+ms+rs);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <set>

using namespace std;

class Unionfind {
    vector<int> par; //親
    vector<int> rank; //深さ
public:
    void init(int n)//初期化
    {
        par = vector<int>(n);
        rank = vector<int>(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

public:
    int root(int x)//根を求める
    {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

public:
    void unite(int x, int y)//集合を併合
    {
        x = root(x);
        y = root(y);
        if (x == y) return;
        else {
            if (rank[x] < rank[y]) par[x] = y;
            else {
                par[y] = x;
                if (rank[x] == rank[y]) rank[x]++;
            }
        }
    }

public:
    bool issame(int x, int y)//同じ集合に属しているか
    {
        return root(x) == root(y);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    Unionfind uf;
    uf.init(n);

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        uf.unite(x, y);
    }

    set<int> ret;
    for (int i = 0; i < n; i++)ret.insert(uf.root(i));

    cout << ret.size() << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int n,m,k,e[100009],f[100009],num[100009];
vector<int>gg[100009];
int getf(int x) {
	if(x!=f[x]) f[x]=getf(f[x]);
	return f[x];
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=0;i<m;i++) {
		int a,b;
		cin>>a>>b;
		e[a]++;
		e[b]++;
		if(getf(a)!=getf(b)) {
			int fa=getf(a),fb=getf(b);
			f[fa]=fb;
		}
	}
	for(int i=1;i<=n;i++) num[getf(i)]++;
	for(int i=1;i<=n;i++) num[i]=num[getf(i)];
	for(int i=1;i<=n;i++) num[i]=num[i]-e[i]-1;
	for(int i=0;i<k;i++) {
		int a,b;
		cin>>a>>b;
		if(getf(a)==getf(b)) num[a]--,num[b]--;
	}
	for(int i=1;i<=n;i++) cout<<num[i]<<' ';
	return 0;
}

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

UL N;
UL A[300002];
UL Q;
UL C=0;

void acng(UL i, UL v){
  if(A[i-1] <= A[i]) C--;
  if(A[i] <= A[i+1]) C--;
  A[i] = v;
  if(A[i-1] <= A[i]) C++;
  if(A[i] <= A[i+1]) C++;
}

void aswap(UL i, UL j){
  UL J = A[j];
  acng(j,A[i]);
  acng(i,J);
}

int main(){
  scanf("%u", &N);
  A[0] = 0;
  A[N+1] = ~0u;
  rep(i,N) scanf("%u", &A[i+1]);
  scanf("%u", &Q);
  UL ans = ~0u;
  rep(i,N+1) if(A[i]<=A[i+1])C++;
  if(C==N+1) ans=0;
  rep(q, Q){
    UL x,y; scanf("%u%u", &x, &y);
    aswap(x,y);
    if(C==N+1) ans=min(ans,q+1);
  }
  cout << (int)ans << endl;
  return 0;
}



Measured memory_bytes: 4496
#include<bits/stdc++.h>
#define mod 1000000007
#define max 500
//#define max1 60000000
//#define inf 1e17
using namespace std;
typedef  long long int ll;
template<typename T> inline T maxi(T a,T b){return a>b?a:b;}
template<typename T> inline T mini(T a,T b){return a<b?a:b;}
template<typename T> inline T absl(T a){return a>0?a:-a;}
template<typename T> inline T gcd(T a,T b){T t;if(a<b){while(a){t=a;a=b%a;b=t;}return b;}else{while(b){t=b;b=a%b;a=t;}return a;}}
template<typename T> inline T ceiling(T a,T b){if(a%b==0)return (a/b);return ((a/b)+1);}
#define mp(a,b) make_pair(a,b)
#define  f(n)  for(int i =0;i<n;++i)
//###################################################------------------------------------------------------#######################################

void input(){
     int n;cin>>n;
     vector<int>a;
     f(n){
        int b ;cin>>b;
        if(b>i+1){
            cout<<-1<<endl;return;
        }
        a.insert(a.begin() + b-1,b);
     }
     for(auto it:a)cout<<it<<" ";cout<<endl;
}

int main(){
    input();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n, x);
  vector<pair<int, int>> vp;
  for (int i = 1; i <= n; ++i) {
    Cin(int, m);
    vp.push_back({i, m});
  }

  int all1 = 0;
  for (auto e : vp) all1 += e.second;
  x -= all1;

  sort(all(vp),
       [](pair<int, int> a, pair<int, int> b) { return a.second < b.second; });

  int argmin = x / vp[0].second;

  cout << n + argmin << endl;

  return 0;
}

Measured memory_bytes: 256
/***
*	author  :_shamim
*	created : 05.05.2020
*
***/

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <list>
#include <set>
#include <queue>
#include <iterator>
#include <bitset>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll             long long
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define loop           for(i=0;i<n;i++)
#define pb             push_back
#define tc()           int t;cin>>t;while(t--)          

using namespace std;

ll i,j,temp;

int main()
{_
	
	int n,digit=0,sum=0,cnt=0;
	cin>>n;

	temp = n;

	while(temp>0){
		temp/=10;
		digit++;
	}
	temp = n;
	int arr[digit];
	while(temp>0){
		arr[cnt] = temp%10;
		cnt++;
		temp/=10;
	}
	for(i=0;i<cnt;i++){
		sum = sum*10 + arr[i];
	}

	if(sum == n){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}

int main(){
	int c[3][3];
	int sum=0;
	rep(i,3){
		rep(j,3){
			cin>>c[i][j];
			sum+=c[i][j];
		}
	}
	if(sum%3!=0){
		cout<<"No"<<endl;
		return 0;
	}
	sum/=3;
	if( c[0][0]+c[1][1]+c[2][2] == sum &&
		c[2][0]+c[1][1]+c[0][2] == sum &&
		c[0][1]+c[1][0]+c[2][2] == sum &&
		c[0][0]+c[1][2]+c[2][1] == sum ){
			cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}





Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int mod = 1000000007;

int main() {
  int n,m;
  S2(n,m);
  if(abs(n - m) > 1) {
    P(0);
    return 0;
  }

  if(abs(n - m) == 1) {
    LL ans = 1;
    while(n) {
      ans = ans * n % mod;
      n--;
    }
    while(m) {
      ans = ans * m % mod;
      m--;
    }
    cout << ans << "\n";
    return 0;
  }
  LL ans = 2;
  while(n) {
    ans = ans * n % mod;
    n--;
  }
  while(m) {
    ans = ans * m % mod;
    m--;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
def c():
    N, M, Q = map(int, input().split())
    a, b, c, d = ([0]*Q, [0]*Q, [0]*Q, [0]*Q)
    for i in range(Q):
        a[i], b[i], c[i], d[i] = map(int, input().split())

    def dfs(lst, depth):
        score = 0
        if len(lst) < depth:
            start = 1 if len(lst) == 0 else lst[-1]
            for m in range(start, M+1):
                score = max(score, dfs(lst + [m], depth))
            return score

        else:
            for i in range(Q):
                score += d[i] if lst[b[i]-1] - lst[a[i]-1] == c[i] else 0
            return score

    A = []
    print(dfs(A, N))


##########
if __name__ == "__main__":
    c()


Measured memory_bytes: 9152
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  ll n,k,ans=0;cin>>n>>k;
  vll p(n,0);
  rep(i,0,k){
    int d;cin>>d;
    rep(j,0,d){
      int a;cin>>a;a--;
      p[a]++;
    }
  }
  rep(i,0,n){
    if(p[i]==0)ans++;
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
const int maxm=100;
int nextable[maxm];
void getnext(string b){
	int m=b.size();
	int j=0;
	nextable[j]=-1;
	int t=nextable[j];
	while(j<m){
		if(t==-1||nextable[j]==nextable[t]){
			t++;j++;nextable[j]=t;
		}
		else t=nextable[t];
	}
	return;
}
bool KMP(string a,string b){
	getnext(b);
	int n=a.size(),m=b.size();
	int i=0,j=0;
	while(i<n&&j<m){
		if(j==-1||a[i]==b[j]){
			i++;
			j++;
		}
		else{
			j=nextable[j];
		}
	}
	if(j==m) return true;
	else return false;
}
int main(){
	string a,b;
	cin>>a>>b;
	a+=a;
	bool r=KMP(a,b);
	if(r) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   char s[5];
   int i,ln=0,j;
   gets(s);
    for(i=0;i<4;i++){
     for(j=0;j<4;j++){
        if(s[i]==s[j+1]){
            ln++;
        }
        j++;
     }

     }
    if(ln==4)
        printf("Yes\n");
        else
            printf("No\n");
    return 0;
}

Measured memory_bytes: 128
import math

A, B, H, M = map(int, input().split())

AX = A*math.cos(math.pi*(H/6+M/360))
AY = A*math.sin(math.pi*(H/6+M/360))

BX = B*math.cos(M*math.pi/30)
BY = B*math.sin(M*math.pi/30)

print(math.sqrt((AX-BX)**2 + (AY-BY)**2))


Measured memory_bytes: 9504
use std::io::{self, Read, Write};

#[rustfmt::skip] #[macro_use] #[allow(unused_macros)]
mod rwc {
    macro_rules! rd { ($buf:ident, $t:ty)       => { $buf.next().unwrap().parse::<$t>().ok().unwrap() }; }
    macro_rules! wt { ($out:ident, $($arg:tt)*) => { write!($out, $($arg)*).ok()                      }; }
    macro_rules! cv { ($n:expr, $fn:expr)       => { (0..$n).map($fn).collect::<Vec<_>>()             }; }
}

fn main() {
    let (mut _buf, mut _out) = (String::new(), io::stdout());
    let (mut _buf, mut _out) = {
        io::stdin().read_to_string(&mut _buf).ok();
        (_buf.split_whitespace(), io::BufWriter::new(_out.lock()))
    };

    let n = rd!(_buf, u64);
    let mut ans = 0u64;

    for i in 1..=n {
        if i % 15 == 0 || i % 5 == 0 || i % 3 == 0 {
            continue;
        }
        ans += i;
    }
    wt!(_out, "{}\n", ans);
}


Measured memory_bytes: 2144
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);

	if(n == 25)
		printf("Christmas\n");
	if(n == 24)
		printf("Christmas Eve\n");
	if(n == 23)
		printf("Christmas Eve Eve\n");
	if(n == 22)
		printf("Christmas Eve Eve Eve\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int n,ans=0;
int dfs(ll k, int f1, int f2, int f3){
    if(k > n) return 0;
    if(f1 && f2 && f3) ans++;
    dfs(k*10+3, f1+1, f2, f3);
    dfs(k*10+5, f1, f2+1, f3);
    dfs(k*10+7, f1, f2, f3+1);
    return 0;
}
int main() {
    cin >> n;
    dfs(0,0,0,0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def countingsort(a, b, k):
    c = [0 for i in range(k)]
    for i in range(len(a)):
        c[a[i]] += 1
    for i in range(1,k):
        c[i] += c[i - 1]
    for i in range(len(a))[::-1]:
        b[c[a[i]] - 1] = a[i]
        c[a[i]] -= 1

n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(n)]
countingsort(a, b, max(a) + 1)
print(" ".join(map(str, b)))


Measured memory_bytes: 241916
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main()
	{
		var t = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));

		var ans = (t[0] + t[1]) % 24;
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 11092
N = int(raw_input())
s = raw_input()
t = raw_input()

for i in range(N):
    is_match = True
    for j in range(N-i):
        if s[i+j] != t[j]:
            is_match = False
            break
    if is_match:
        print N+i
        exit()

print 2*N


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

int main()
{
  int N, K;
  int min = 0;
  cin >> N >> K;
  
  for(int i = N; i > 0; i--)
  {
    int value = 1;
    for(int A = 0; A < i; A++)
    {
      value *= 2;
    }
    for(int B = 0; B < N - i; B++)
    {
      value += K;
    }
    
    if((i == N) || (min > value))
    {
      min = value;
    }
  }
  
  cout << min << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <algorithm>

#define GET_IDX(idx, n) ((idx+n) % n)


using namespace std;

int main(){
  int n;
  scanf("%d", &n);
  vector<long> a(n);
  vector<long> b(n);
  vector<bool> flags(n);
  int num_flgs = n;
  bool is_crct=true;
  long count = 0;

  for(int i=0;i<n;i++){
    scanf("%ld", &a[i]);
    flags[i] = true;
  }
  for(int i=0;i<n;i++){
    scanf("%ld", &b[i]);
  }

  long sum_m=-10;;

  while(sum_m!=0){
    sum_m = 0;
    int m;
    long tmp;
    int i=0;
    bool dpnd=true;
    {
      if(flags[i]&&(b[i]>b[i+1]&&b[i]>b[n-1])){
        tmp = b[i+1] + b[n-1];
        m = max((b[i] - a[i]) / (tmp),0L);
        b[i] -= tmp*m;
        sum_m += m;
        count += m;
        if(m!=0)i++;
        dpnd = false;
      }
    }
    for(i++;i<n-1;i++){
      if(flags[i]&&(b[i]>b[i+1]&&b[i]>b[i-1])){
        tmp = b[i+1] + b[i-1];
        m = max((b[i] - a[i]) / (tmp),0L);
        b[i] -= tmp*m;
        sum_m += m;
        count += m;
        if(m!=0)i++;
      }
    }
    if(i==n-1&&dpnd){
      if(flags[i]&&(b[i]>b[0]&&b[i]>b[i-1])){
        tmp = b[0] + b[i-1];
        m = max((b[i] - a[i]) / (tmp),0L);
        b[i] -= tmp*m;
        sum_m += m;
        count += m;
        if(m!=0)i++;
      }
    }
  }

  for(int i=0;i<n;i++){
    is_crct = is_crct && a[i]==b[i];
  }

  if(is_crct){
    cout << count << endl;
  }else{
    cout << "-1" << endl;
  }


  return 0;
}

Measured memory_bytes: 3456
N, M = list(map(int, input().split()))

D = list(map(int, input().split()))

S = {0 : 1}
t = 0
for i in range(N):
  t = (t + D[i]) % M
  if t in S:
    S[t] += 1
  else:
    S[t] = 1

r = 0

for i in S.values():
  r += i * (i - 1) // 2
  
print(r)

Measured memory_bytes: 14224
//file_name:ABC110_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;
    string t;
    cin >> t;

    int al[300][2];
    rep(i,300){
        rep(j,2){
            al[i][j]=0;
        }
    }

    rep(i,s.size()){
        if(al[s[i]][0]==0){
            al[s[i]][0]=1;
            al[s[i]][1]=t[i];
        }else{
            if(al[s[i]][1]!=t[i]){
                puts("No");
                return 0;
            }
        }
    }
    rep(i,300){
        rep(j,2){
            al[i][j]=0;
        }
    }
    rep(i,s.size()){
        if(al[t[i]][0]==0){
            al[t[i]][0]=1;
            al[t[i]][1]=s[i];
        }else{
            if(s[i]!=al[t[i]][1]){
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}



Measured memory_bytes: 776
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define int long long
#define mod 924844033
using namespace std;
inline int read(){
	int f=1,ans=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return f*ans;
}
const int MAXN=2001;
int a[MAXN<<1],f[MAXN<<1][MAXN][2],n,k,fac[MAXN];
signed main(){
//	freopen("1.in","r",stdin);
	n=read(),k=read();
	fac[0]=1;for(int i=1;i<=n;i++) fac[i]=(fac[i-1]*i)%mod;
	for(int i=1;i<=k;i++){
		for(int j=i;j<=n;j+=k) a[++a[0]]=(i!=j);
		for(int j=i;j<=n;j+=k) a[++a[0]]=(i!=j);
	}
	f[0][0][0]=1;
	for(int i=1;i<=a[0];i++)
		for(int j=0;j<=n;j++){
			f[i][j][0]=f[i-1][j][0]+f[i-1][j][1],f[i][j][0]%=mod;
			if(j&&a[i]) f[i][j][1]=f[i-1][j-1][0],f[i][j][1]%=mod;
		}
	int pw=1,ans=0;
	for(int i=0;i<=n;i++)
		ans+=pw*fac[n-i]*((f[a[0]][i][0]+f[a[0]][i][1])%mod),pw*=-1,ans=((ans%mod)+mod)%mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 125312
#include<stdio.h>
int main(){
  int n,m,k,l;
  scanf("%d%d",&n,&m);
  if(n<m){
    l=n;
    n=m;
    m=l;
  }
  k=n%m;
  while(k!=0){
    n=m;
    m=k;
    k=n%m;
  }
  printf("%d\n",m);
  return 0;
}



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


int main() {
    int N;
    cin >> N;

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

    int minusNum = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] < 0) minusNum++;
    }

    long all_abs_sum = 0;

    for (int i = 0; i < N; i++) {
        all_abs_sum += abs(A[i]);
    }

    long result;
    if (minusNum % 2 == 0) {
        result = all_abs_sum;
    } else {
        int min = 1000000009;
        for (int i = 0; i < N; i++) {
            if (min > abs(A[i])) {
                min = abs(A[i]);
            }
        }
        result = all_abs_sum - 2 * min;
    }

    cout << result << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a,b,ju;
    cin>>a>>b;
    ju=b-a+1;//数字个数
    if(a>0)
    {
        cout<<"Positive"<<endl;
        return 0;
    }
    if(a<0&&b<0&&ju%2==1)//刚开始没想到负负得正，WA了多次
    {
        cout<<"Negative"<<endl;
        return 0;
    }
    if(a<=0&&b>=0)
    {
        cout<<"Zero"<<endl;
        return 0;
    }
    cout<<"Positive"<<endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin >> a;
    if(a[0]==a[1] || a[1]==a[2] || a[2]==a[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  
  int cnt;
  cnt = b / a;
  
  if(cnt > c){
    printf("%d\n", c);
  }
  else{
    printf("%d\n", cnt);
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
using namespace std;
using ll = long long;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = 1;
  if (a==b || b==c || c==a) {
    if (a==b && b==c) {
      ans = 1;
    } else {
      ans = 2;
    }
  } else {
    ans = 3;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256