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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    string s;
    lli begin, end;
    cin >> s;
    for(lli i=0; i<s.length(); i++){
        if(s[i]=='A'){
            begin = i;
            break;
        }
    }
    for(lli i=s.length()-1; i>=0; i--){
        if(s[i]=='Z'){
            end = i;
            break;
        }
    }
    cout << (end-begin)+1 << endl;

    return 0;
}

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

#define NIL NULL
#define INF 1000000001

using namespace std;

struct node {
    int key,priority;
    struct node *right;
    struct node *left;
};

typedef node * Node;


Node delete_(Node t,int key);
Node _delete(Node t,int key);

Node rightRotate(Node t){
    Node s = t->left;
    t->left  = s->right;
    s->right = t;
    return s;
}

Node leftRotate(Node t){
    Node s = t->right;
    t->right = s->left;
    s->left  = t;
    return s;
}

Node insert(Node t,int key,int priority){
    if(t == NIL){
        t = (Node)malloc(sizeof(struct node));
        t->key = key;
        t->priority = priority;
        t->left = NIL;t->right = NIL;
    }else if(t->key == key) return NIL; 

    if(key < t->key){
        t->left = insert(t->left,key,priority);
        if(t->priority < t->left->priority) t = rightRotate(t);
    }else if(key > t->key){
        t->right = insert(t->right,key,priority);
        if(t->priority < t->right->priority)t = leftRotate(t);
    }
    return t;
}

Node delete_(Node t,int key){
    if(t == NIL) return NIL;
    if(key < t->key) t->left = delete_(t->left,key);
    else if(key > t->key) t->right = delete_(t->right,key);
    else return _delete(t,key);
    return t;
}

Node _delete(Node t,int key){
    if(t->left ==NIL && t->right == NIL) return NIL;
    else if(t->left == NIL) t  = leftRotate(t);
    else if(t->right== NIL) t  = rightRotate(t);
    else{
        if(t->left->priority < t->right->priority) t = leftRotate(t);
        else t = rightRotate(t);
    }
    return delete_(t,key);
}

Node findElement(Node current_node,int v){
    if(current_node == NIL) return NIL;
    else if(current_node->key == v) return current_node;
    else if(current_node->key > v) return findElement(current_node->left, v);
    else if(current_node->key < v) return findElement(current_node->right,v);
}


void inOrder(Node current_node){
    if(current_node == NIL) return;
    inOrder(current_node->left);
    printf(" %d",current_node->key);
    inOrder(current_node->right);
}

void preOrder(Node current_node){
    printf(" %d",current_node->key);
    if(current_node->left != NIL)        preOrder(current_node->left);
    if (current_node->right != NIL) preOrder(current_node->right);
}


int main(){
    int num_query;
    char command[20];
    Node root = NIL;
    
    int key,priority;
    scanf("%d",&num_query);
    for(int i = 0;i < num_query;i++){
        scanf("%s",command);
        if(command[0] == 'i'){
            scanf("%d %d",&key,&priority);
            root = insert(root,key,priority);
        }else if(command[0] == 'f'){
            scanf("%d",&key);
            if(findElement(root,key)!=NIL) printf("yes\n");
            else printf("no\n");
        }else if(command[0] == 'p'){
            inOrder(root);printf("\n");
            preOrder(root);printf("\n");
        }else if(command[0] == 'd'){
            scanf("%d",&key);
            root = delete_(root,key);
        }
    }
    return 0;   
}



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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
    cout << a << "\n";
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	// source code
    ll n,k,q;
    vector<ll> a;
    cin >> n >> k >> q;
    inputVector(a,q);
    vector<ll> person(n,0);

    for(ll _a : a)
    {
        person[_a-1]++;    
    }

    for(ll _p : person)
    {
        if(_p + k -q  > 0 )
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }



	return 0;
}


Measured memory_bytes: 2292
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;

int main(){
	int64_t Q,S,L,D,N;
	cin>>Q>>S>>L>>D>>N;
	int64_t oneliter=min(4*Q,2*S);
	oneliter=min(oneliter,L);
	int64_t twoliter=min(2*oneliter,D);
	cout<<(N/2)*twoliter+(N%2)*oneliter<<endl;





}


Measured memory_bytes: 256
s = input()
def is_palindrome(s):
    return s == s[::-1]

s_len = len(s)
if is_palindrome(s) and is_palindrome(s[:(s_len-1)//2]) and is_palindrome(s[(s_len+3)//2-1:]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<stdio.h>

int main(){
	
	int a,b,c,tmp;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a>b){
		tmp=a;
		a=b;
		b=tmp;
	}
	if(b>c){
		tmp=b;
		b=c;
		c=tmp;
	}
	if(a>b){
		tmp=a;
		a=b;
		b=tmp;
	}
	
	printf("%d %d %d\n",a,b,c);
	return 0;
}

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

using namespace std;

int main(){
    string s;
    cin>>s;
    int n=s.length();
    vector<pair<int,int>> ans;
    if(s[n-1]=='1' || s[0]=='0'){
        cout<<"-1\n";
        return 0;
    }
    bool flag=false;
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-2-i]){
            flag=true;
            break;
        }
    }
    if(flag){
        cout<<"-1\n";
        return 0;
    }
    int siz=1,hi=1;
    for(int i=1;i<n/2;i++){
        if(siz==i && s[i]=='1'){
            ans.emplace_back(hi,siz+1);
            siz++;
            hi=siz;
        }
        else if(s[i]=='1'){
            ans.emplace_back(hi,siz+1);
            siz++;
            hi=siz;
            while(siz<=i){
                ans.emplace_back(hi,siz+1);
                siz++;
            }
        }
    }
    if(n%2==0 && siz==n/2){
        auto new_ans=ans;
        for(auto i:new_ans){
            ans.emplace_back(n+1-i.first,n+1-i.second);
        }
        ans.emplace_back(siz,n+1-siz);
    }
    else{
        ans.emplace_back(hi,siz+1);
        siz++;
        hi=siz;
        while(siz<n){
            ans.emplace_back(hi,siz+1);
            siz++;
        }
    }
    for(auto i:ans){
        cout<<i.first<<" "<<i.second<<endl;
    }
    return 0;
}

Measured memory_bytes: 4780
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

#define INF 999999999

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

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

int main() {
	int a[30] = { 0 };
	a[0] = 1; a[1] = 2; a[2] = 4;
	for (int i = 3; i < 30; i++) {
		a[i] = a[i - 1] + a[i - 2] + a[i - 3];
	}
	while (1) {
		int n;
		cin >> n;
		if (n == 0)break;
		if (a[n-1] % 3650 == 0)cout << a[n-1] / 3650 << endl;
		else cout << a[n-1] / 3650 + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3060
using System;
using System.Text;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();

        for (int i = 1; i <= b; i++)
        {
            if ((a * i) % b == c)
            {
                Console.WriteLine("YES");
                return;
            }
        }

        Console.WriteLine("NO");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>

const int MAXN = 2e5 + 10;
typedef long long ll;

using namespace std;

int main()
{
	ll a, b, c, d, x, y;
	cin >> a >> b >> c >> d;
	ll maxn = a*c;
	maxn = max(maxn, a*d);
	maxn = max(maxn, b*c);
	maxn = max(maxn, b*d);
	cout << maxn <<endl;
	return 0;
} 

Measured memory_bytes: 3624
def main():
    X, N = map(int, input().split())
    P = list(map(int, input().split()))

    if N == 0:
        print(X)
        exit()

    P = sorted(P)

    mini = -1
    for i in range(102):
        if i in P:
            continue
        if abs(X - i) < abs(X-mini):
            mini = i
    
    print(mini)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9196
import math

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

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

x1 = B * math.sin(math.pi * M / 30)
y1 = B * math.cos(math.pi * M / 30)

print(math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2))


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(V),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	int a, b;
	cin >> a >> b;
	if (n <= k)cout << a*n << endl;
	else cout << a*k + b*(n - k) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,x;
    int cnt = 0;
    cin >> a >> b >> c >> x;
    for(int i = 0; i <= a; i++)
    {
        for(int j = 0; j <= b; j++)
        {
            for(int k = 0; k <= c; k++)
            {
                
                if(x == 500 * i + 100 * j + 50 * k)
                    cnt++;
                else if(500 * i + 100 * j + 50 * k > x)
                    break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 998244353;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, -1, 1, 1, -1 };

namespace {
    template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
    template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    string s = inp1;

    vector<int> vec(s.length());
    rep(i, s.length()) vec[i] = s[i] - 'a';

    int ans = inf;

    rep(c, 26) {
        // 何回でできるか
        int cnt = 0;
        string tmp = s;
        
        char ch = (char)(c + 'a');

        while (true) {
            // すべて同じ文字列なら終了
            bool same = true;
            rep(i, (int)tmp.length() - 1) {
                if (tmp[i] != tmp[i + 1]) {
                    same = false;
                    break;
                }
            }
            if (same) break;

            string t = "";
            rep(i, (int)tmp.length() - 1) {
                if (tmp[i] == ch || tmp[i + 1] == ch) t += ch;
                else t += tmp[i];
            }
            tmp = t;

            ++cnt;
        }

        chmin(ans, cnt);
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
t = a + b
s = input()
for c in s:
    if c=='a' and t>0:
        print('Yes')
        t -= 1
    elif c=='b' and t>0 and b>0:
        print('Yes')
        t -= 1
        b -= 1
    else:
        print('No')

Measured memory_bytes: 4016
import collections as col
N= int(input())
A = [int(x) for x in input().split()]
a = A[::2]

a = col.Counter(a)
b = A[1::2]

b = col.Counter(b)
ans = 0
i = 0
j = 0
if len(a.most_common())==1 and len(b.most_common())==1 and a.most_common()[i][0]==b.most_common()[j][0]:
  print(N//2)
  exit()
while a.most_common()[i][0]==b.most_common()[j][0]:
  m=a.most_common()[i][1]
  n=b.most_common()[j][1]
  if m>n:
    j +=1
  elif m==n:
      if a.most_common()[i+1][1]>b.most_common()[j+1][1]:
        i+=1
      else:
        j +=1
  else:
    i +=1
#print(i,j,a,b)
ans += sum(a.values())+sum(b.values())-a.most_common()[i][1]-b.most_common()[j][1]
print(ans)

Measured memory_bytes: 18656
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
string S;






int main()
{

	cin >> S;
	REP(i,S.length()){
		REP(j,S.length() - i + 1){
			string tmp = S;
			tmp.erase(tmp.begin()+j,tmp.begin()+j+i);

			if(tmp == "keyence"){
				cout << "YES" << endl;
				return 0;
			}

		}
	}
	cout << "NO" << endl;
	return 0;

}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD (LL)(1e9+7)

int main(){
	int K, X, Y;
	cin >> K >> X >> Y;

	int memo[2] ={ 1,1 };
	bool s = false;
	if(X < 0){
		X *= -1;
		memo[0] *= -1;
	}
	if(Y < 0){
		Y *= -1;
		memo[1] *= -1;
	}
	if(X > Y){
		swap(X, Y);
		s = true;
	}

	if((X+Y)%2 == 1 && K%2 == 0){
		cout << -1 << endl;
		return 0;
	}

	vector<pair<int, int>> ans;
	int x = 0;
	int y = 0;
	if(X + Y >= K){
		int muda = (X+Y + K-1) / K * K - (X+Y);
		if(muda % 2 == 1) muda += K;
		while(x != X || y != Y){
			int nokori = K;
			if(muda > 0){
				int tmp = min(muda/2, nokori);
				muda -= tmp * 2;
				nokori -= tmp;
				x -= tmp;
			}
			if(y != Y){
				int tmp = min(Y-y, nokori);
				nokori -= tmp;
				y += tmp;
			}
			if(x != X){
				int tmp = min(X-x, nokori);
				nokori -= tmp;
				x += tmp;
			}
			ans.PB(MP(x, y));
		}
	}
	else{
		if((X+Y)%2 == 0){
			int a = (2*K - X - Y) / 2;
			ans.PB(MP(-a, K-a));
			ans.PB(MP(X, Y));
		}
		else{
			int a = (K - X - Y) / 2;
			ans.PB(MP(0, -K));
			ans.PB(MP(-a, -a));
			ans.PB(MP(X, Y));
		}
	}

	cout << ans.size() << endl;
	for(int i=0; i<ans.size(); i++){
		if(!s){
			cout << ans[i].first * memo[0] << " " << ans[i].second * memo[1] << endl;
		}
		else{
			cout << ans[i].second * memo[0] << " " << ans[i].first * memo[1] << endl;
		}
	}
}

Measured memory_bytes: 3952
#include <stdio.h>
int main(){
  int vector[3][4]={{0,2,5,3},{0,1,5,4},{1,2,4,3}};
  int ii,i,j,k,l,m,n,c,cc=0;
  scanf("%d",&n);
  int dice[n][6];
  for(i=0;i<n;i++){
    for(j=0;j<6;j++){
      scanf("%d",&dice[i][j]);
    }
  }
  //for(i=0;i<n;i++)printf("dice[%d] : %d %d %d %d %d %d\n",i,dice[i][0],dice[i][1],dice[i][2],dice[i][3],dice[i][4],dice[i][5]);
  for(ii=1;ii<n;ii++){
    for(i=0;i<2;i++){
      for(j=0;j<4;j++){
	int temp = dice[ii][vector[i][0]];
	for(k=0;k<3;k++){
	  dice[ii][vector[i][k]] = dice[ii][vector[i][k+1]];
	}
	dice[ii][vector[i][3]] = temp;
	c = 0;
	for(k=0;k<6;k++){
	  if(dice[0][k]==dice[ii][k])c++;
	}
	//printf("dice[%d] fuck : %d %d %d %d %d %d\n",ii,dice[ii][0],dice[ii][1],dice[ii][2],dice[ii][3],dice[ii][4],dice[ii][5]);
	//printf("c : %d\n",c);
	if(c==6)break;
	for(m=0;m<3;m++){
	  for(k=0;k<4;k++){
	    int temp = dice[ii][vector[m][0]];
	    for(l=0;l<3;l++){
	      dice[ii][vector[m][l]] = dice[ii][vector[m][l+1]];
	    }
	    dice[ii][vector[m][3]] = temp;
	    c=0;
	    for(l=0;l<6;l++){
	      if(dice[0][l]==dice[ii][l])c++;
	    }
	    //printf("dice[%d] : %d %d %d %d %d %d\n",ii,dice[ii][0],dice[ii][1],dice[ii][2],dice[ii][3],dice[ii][4],dice[ii][5]);
	    //printf("c : %d\n",c);
	    if(c==6)break;
	  }
	  if(c==6)break;
	}
	if(c==6)break;
      }
      if(c==6){
	cc++;
	break;
      }
    }
  }
  if(cc==0)printf("Yes\n");
  else printf("No\n");
  return 0;
}

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


using namespace std;
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(100002);
vector<ll> ifac(100002);

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}

ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}

int main()
{
	int n;
	cin >> n;
	set<int> found;
	vector<int> list;
	int p1, p2;
	for (int i = 0; i < n+1; ++i) {
		int ai;
		cin >> ai;
		auto ite = found.find(ai);
		if (ite != found.end()) {
			auto ite2 = find(list.begin(), list.end(), ai);
			p1 = distance(list.begin(), ite2);
			p2 = i;
		}
		else {
			found.insert(ai);
		}
		list.push_back(ai);
	}
	int left_count = p1;
	int middle_count = p2 - p1 - 1;
	int right_count = n+1 - p2-1;

	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i <= 100000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}


	for (int k = 1; k <= n+1; ++k) {
		if (k == 1) cout << n << endl;
		else cout << (comb(n + 1, k) - comb(left_count + right_count, k - 1)+M) % M << endl;
	}
	return 0;
}

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

ll dp[101][100001];

int main(){
    int N,W;
    cin >> N >> W;
    vector<ll> w(N);
    vector<ll> v(N);

    rep(i,N) cin >> w[i] >> v[i];
    rep(i,N)rep(j,W) dp[i][j] = 0;
    rep(i,N){ 
        rep(j,W+1){
            if(j-w[i]>=0)
                dp[i+1][j] = max(dp[i+1][j],dp[i][j-w[i]]+v[i]); 
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
        }
    }
    cout<<dp[N][W]<<endl;

}

Measured memory_bytes: 79104
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 300010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
#define eps 1e-6
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m, k, ans, t;
ll a[SIZE];
bool vis[SIZE];
int main() {
	io(); cin >> n >> m;
	rep(i, 1, m) {
		string s; cin >> k >> s;
		if (s[0] == 'A') {
			if (vis[k]) continue;
			vis[k] = true;
		}
		else {
			if (vis[k]) continue;
			++a[k];
		}
	}
	rep(i, 1, n) {
		if (!vis[i]) continue;
		++ans;
		t += a[i];
	}
	cout << ans << ' ' << t;
}

Measured memory_bytes: 1152
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
R,G,B,N = map(int,input().split())

ans = 0
for r in range(N//R + 1):
    for g in range(N//G +1):
        rest = N - R*r - G*g
        if rest >= 0 and rest%B == 0:
            # print(r,g,rest//B)
            ans +=1

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

const int MAXN = 100005, mod = 1e9+7;
long long n, x, y;
long long a[MAXN];

int f[MAXN], g[MAXN], sumf[MAXN], sumg[MAXN];
int prex[MAXN], prey[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> x >> y;
	for (int i = 1; i <= n; i++) cin >> a[i];
	f[0] = g[0] = sumf[0] = sumg[0] = 1;
	a[n+1] = 1ll<<62;
	prex[1] = prey[1] = 0;
	for (int i = 2; i <= n+1; i++) {
		int px = prex[i-1], py = prey[i-1];
		while (px < i && a[i]-a[px+1] >= x) px++;
		while (py < i && a[i]-a[py+1] >= y) py++;
		prex[i] = px, prey[i] = py;
	}
	int px = 1, py = 1;
	for (int i = 1; i <= n; i++) {
		if (i > 1) {
			if (a[i]-a[i-1] < x) px = i;
			if (a[i]-a[i-1] < y) py = i;
		}
		int R = min(i-1, prey[i+1]), L = px-1;
		if (L <= R) f[i] = (L == 0 ? sumg[R] : ((sumg[R]-sumg[L-1])%mod+mod)%mod);
		R = min(i-1, prex[i+1]), L = py-1;
		if (L <= R) g[i] = (L == 0 ? sumf[R] : ((sumf[R]-sumf[L-1])%mod+mod)%mod);
		sumf[i] = (sumf[i-1]+f[i])%mod;
		sumg[i] = (sumg[i-1]+g[i])%mod;
	}
	cout << (f[n]+g[n])%mod << endl;
	return 0;
}


Measured memory_bytes: 3328
# 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>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;

constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> G[100];
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}
	vector<int> v;
	for (int i = 0; i < n; i++) {
		v.emplace_back(i + 1);
	}
	int ans = 0;
	do {
		if (v[0] != 1)continue;
		int count = 0;
		for (int i = 0; i < n - 1; i++) {
			for (int j = 0; j < G[v[i]].size(); j++) {
				if (G[v[i]][j] == v[i + 1])count++;
			}
		}
		if (count == n - 1)ans++;
	} while (next_permutation(ALL(v)));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int ans = 0;
    string S;
    cin >> S;
    rep(i,4) {
        if (S[i] == '+') ans++;
        else ans--;
    }

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

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

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define MOD 1000
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, k;
string s;
set<string> ss;

int main () {
    cin >> s;
    cin >> k;
    n = s.length();

    fto(len, 1, 5) {
        fto(l, 0, n-len) ss.insert(s.substr(l, len));
    }

    fto(i, 1, k-1) ss.erase(ss.begin());
    cout << *ss.begin();

    return 0;
}


Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		short point1 = 0, point2 = 0, n = Short.parseShort(in.readLine());
		for (int i = 0; i < n; i++) {
			String[] card = in.readLine().split(" ");
			if (card[0].compareTo(card[1]) > 0) {
				point1 += 3;
			} else if (card[0].compareTo(card[1]) < 0) {
				point2 += 3;
			} else if (card[0].compareTo(card[1]) == 0) {
				point1++;
				point2++;
			}
		}
		System.out.println(point1 + " " + point2);
	}
}

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

int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
    for(int i = k; i < n; i++){
        cout << (a[i] > a[i-k] ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 4412
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int m1 = sc.nextInt();
        int d1 = sc.nextInt();
        int m2 = sc.nextInt();
        int d2 = sc.nextInt();
        System.out.println(m1 != m2 ? 1 : 0);
    }
}

Measured memory_bytes: 23380
using System;

namespace A___Wanna_go_back_home
{
    class Program
    {
        static void Main (string[] args)
        {
            var str = Console.ReadLine ();
            var n = false;
            var s = false;
            var w = false;
            var e = false;
            for (var i = 0; i < str.Length; i++)
            {
                if (str[i] == 'N')
                    n = true;

                else if (str[i] == 'W')
                    w = true;

                else if (str[i] == 'S')
                    s = true;

                else
                    e = true;
            }
            if (n == true && s == false || n == false && s == true || w == true && e == false || w == false && e == true)
                Console.WriteLine ("No");

            else
                Console.WriteLine ("Yes");
        }
    }
}

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

const int MAXN = 100005, M = 3, mod = 1e9+7;

struct matrix {
	int a[M][M];
	matrix()
	{ memset(a, 0, sizeof a); }
	matrix(int id)
	{ memset(a, 0, sizeof a), a[0][0] = a[1][1] = a[2][2] = 1; }
	friend matrix operator * (const matrix &a, const matrix &b)
	{
		matrix ret;
		for (int i = 0; i < M; i++)
			for (int j = 0; j < M; j++)
				for (int k = 0; k < M; k++)
					ret.a[i][j] = ((long long)a.a[i][k]*b.a[k][j]+ret.a[i][j])%mod;
		return ret;
	}
	friend matrix operator ^ (matrix a, int n)
	{
		matrix ans = 1;
		for (; n; n >>= 1) {
			if (n&1) ans = ans*a;
			a = a*a;
		}
		return ans;
	}
	friend matrix operator + (const matrix &a, const matrix &b)
	{
		matrix ans;
		for (int i = 0; i < M; i++)
			for (int j = 0; j < M; j++)
				ans.a[i][j] = (a.a[i][j]+b.a[i][j])%mod;
		return ans;
	}
	friend matrix operator * (int x, const matrix &a)
	{
		matrix ans;
		for (int i = 0; i < M; i++)
			for (int j = 0; j < M; j++)
				ans.a[i][j] = (long long)x*a.a[i][j]%mod;
		return ans;
	}
};

int n, m, a[MAXN], b[] = {4, mod-2, 1}, g[MAXN];

matrix get_matrix()
{
	matrix ans;
	for (int i = 0; i < M; i++) ans.a[0][i] = b[i];
	ans.a[1][0] = ans.a[2][1] = 1;
	return ans;
}

inline int read()
{
	int a = 0, c;
	do c = getchar(); while (!isdigit(c));
	while (isdigit(c)) {
		a = a*10+c-'0';
		c = getchar();
	}
	return a;
}

inline int f(const matrix &M)
{ return (M.a[2][0]*5ll+M.a[2][1])%mod; }

int main()
{
	n = read(), m = read();
	a[0] = 0, a[m+1] = n;
	for (int i = 1; i <= m; i++) a[i] = read();
	matrix M = get_matrix(), I = 1;
	matrix cur;
	for (int i = 1; i <= m+1; i++) {
		cur = cur*(M^(a[i]-a[i-1]));
		g[i] = ((f(M^a[i])-f(cur))%mod+mod)%mod;
		cur = cur+g[i]*I;
	}
	cout << g[m+1] << endl;
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
s = str(input())
sE = s.count('E')
sW = s.count('W')
l = []
e, w = 0, 0
for ch in s:
    if ch == 'E':
        e += 1
    else:
        w += 1
    m = (sE-e)+w
    l.append(sE-e+w-1 if ch == 'W' else sE-e+w)
print(min(l))


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

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

int main()
{
	int n;
	cin >> n;
	vector<int64_t> num(100001);
	int64_t sum = 0;
	for (int i = 0; i < n; i++) {
		int a_in;
		cin >> a_in;
		num.at(a_in)++;
		sum += a_in;
	}
	int q;
	cin >> q;
	vector<int64_t> ans(q);
	for (int i = 0; i < q; i++) {
		int64_t b_in, c_in;
		cin >> b_in >> c_in;
		sum += (c_in - b_in) * num.at(b_in);
		num.at(c_in) += num.at(b_in);
		num.at(b_in) = 0;
		ans.at(i) = sum;
	}

	for (auto ans_ele : ans) {
		cout << ans_ele << endl;
	}
}


Measured memory_bytes: 4840
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		long a = 100;
		int ans = 0;

		while (a < x) {
			ans++;
			a += a / 100;
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 27028
import sys
n = int(input())
print(0, flush=True)
s = input()
if s == "Vacant":
    sys.exit()
l = 0
r = n
ls = s
rs = s

def nibun(l, r, m, ls, rs, s):
    if ((m-l) % 2 == 0 and ls == s) or\
        ((m-l) % 2 == 1 and ls != s):
        return 1
    else:
        return 0

for ii in range(21):
    m = (l+r)//2
    print(m, flush=True)
    s = input()
    if s == "Vacant":
        break
    if nibun(l, r, m, ls, rs, s) == 0:
        r = m
        rs = s
    else:
        l = m
        ls = s

Measured memory_bytes: 3660
//  Created by liszt on 2019/07/28.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,sum=0,i=0,ans; cin>>n;
    
    vector<int> s(n),maxim(n);
    
    for(i=0;i<n;i++){
        cin>>s[i];
        sum+=s[i];
    }
    
    sort(s.begin(),s.end());
    
    if(sum%10!=0){
        ans=sum;
    }else{
        bool ok=false;
        
        for(i=0;i<n;i++){
            
            if(s[i]%10!=0){
                
                ans=sum-s[i];
                ok=true;
                break;
                
            }
            
        }
        if(!ok)ans=0;
    }
    
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
void func(int n,int num, int w[]);
int main(void)
{
	int n; cin>>n;
	int w[n]; for(int i = 0; i < n; i++) w[i] = 0;
	func(n,0,w);
	return 0;
}


void func(int n,int num, int w[]){
	if(num+1 == n){
		for(int i = 0; i < n; i++){
			cout<<(char)(w[i]+97);
		}
		cout<<endl;
	}
	else{
		int ww[n];
		int max = 0;
		for(int i = 0; i < n; i++){
			ww[i] = w[i];
			if(max < w[i]) max = w[i];
		}
		for(int i = 0; i <= max+1; i++){
			ww[num+1] = i;
			func(n,num+1,ww);
		}
	}
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

struct State {
    int t_in, t_pace, c_rem;
    State(){}
    State(int _t_in, int _t_pace, int _c_rem) : t_in(_t_in), t_pace(_t_pace), c_rem(_c_rem) {}
    bool operator<(const State& o) const {
        if (t_pace != o.t_pace) return t_pace < o.t_pace;
        if (c_rem != o.c_rem) return c_rem < o.c_rem;
        return t_in < o.t_in;
    }
};

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

    int n;
    while (cin >> n, n) {
        vector<deque<State>> deq(2);
        vector<State> initial_states;
        rep(i, n) {
            int t_pace, c_rem;
            cin >> t_pace >> c_rem;
            initial_states.emplace_back(0, t_pace, c_rem - 1);
        }
        sort(all(initial_states));
        for (auto state : initial_states) {
            deq[0].emplace_back(state);
        }

        int t_max = 0;
        while (!(deq[0].empty() && deq[1].empty())) {
            int t_now_0 = (deq[0].empty() ? inf : deq[0].front().t_in + deq[0].front().t_pace);
            int t_now_1 = (deq[1].empty() ? inf : deq[1].front().t_in + deq[1].front().t_pace);
            int t_now = min(t_now_0, t_now_1);
            vector<vector<State>> states(2);
            rep(k, 2) {
                while (!deq[k].empty() && t_now >= deq[k].front().t_in + deq[k].front().t_pace) {
                    if (k && deq[k].front().c_rem == 0) {
                        t_max = t_now;
                    }
                    else {
                        states[k].emplace_back(deq[k].front());
                    }
                    deq[k].pop_front();
                }
            }

            rep(k, 2) {
                sort(all(states[k]));
                for (auto state : states[k]) {
                    deq[k^1].emplace_back(t_now, state.t_pace, state.c_rem - k);
                }
            }
        }

        cout << t_max << endl;
    }
}

Measured memory_bytes: 3036
n=int(input())
ae=[];ao=[]
for i,ai in enumerate(list(map(int,input().split()))):
    if i%2==0:
        ae.append(ai)
    else:
        ao.append(ai)

if n%2==0:
    ans=ao[::-1]+ae
else:
    ans=ae[::-1]+ao

print(*ans)

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

int main(){
	int i,n,tmp;
	cin>>n;
	map<int,int> mp;
	for(i=0;i<n;i++){
		cin>>tmp;
		if(mp.find(tmp)!=mp.end())
			mp.erase(tmp);
		else
			mp[tmp]++;
	}
	cout<<mp.size()<<endl;
	return 0;
}

Measured memory_bytes: 4864
BUFSIZE = 30
D = int(input())
C = list(map(int, input().split()))

c0 = sum(C)
Q = [(0, [], 0, [0]*26)]

for d in range(D):
    S = list(map(int, input().split()))
    Q2 = []
    
    for q in Q:
        sc, ts, c1, lasts = q
        c2 = c1 + c0

        for t in range(26):
            c3 = c2 - (d + 1 - lasts[t])*C[t]
            lasts2 = lasts[:]
            lasts2[t] = d+1
            Q2.append((sc + S[t] - c3, [ts, t], c3, lasts2))

    sizeOfQ2 = len(Q2)
    Q = sorted(Q2, reverse=True)[:min(sizeOfQ2, BUFSIZE)]

# print(Q[0][0])
T = []
ts = Q[0][1]

for d in range(D):
    T.append(ts[1] + 1)
    ts = ts[0]

for t in reversed(T):
    print(t)



Measured memory_bytes: 9580
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int n, r;
		int p, c;
		while (true)
		{
			n = sc.nextInt();
			r = sc.nextInt();

			if (n == 0 && r == 0)
			{
				break;
			}

			int[] pile = new int[n];
			for (int i = 0; i < n; i++)
			{
				pile[i] = n - i;
			}

			for (int i = 0; i < r; i++)
			{
				p = sc.nextInt();
				c = sc.nextInt();

				if (p == 1)
				{
					continue;
				}
				else
				{
					int[] move = new int[c];
					for (int j = 0; j < c; j++)
					{
						move[j] = pile[p - 1 + j];
					}

					for (int j = 0; j < p - 1; j++)
					{
						pile[p + c - 2 - j] = pile[p - 2 - j];
					}

					for (int j = 0; j < c; j++)
					{
						pile[c - 1 - j] = move[c - 1 - j];
					}
				}
			}

			System.out.println(pile[0]);
		}
	}
}



Measured memory_bytes: 38936
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = p = 1
  for i in range(1, n + 1):
    x = c[i]
    if x == 0:
      break
    r = r * pow(p, x, M) % M
    p = x; n -= p
print((r, 0)[n > 1])

Measured memory_bytes: 22636
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int gcd(int a,int b){
   if(a%b==0) return b;
   return gcd(b,a%b);
}

int main(void){
   int N;
   cin>>N;
   string s,t;
   cin>>s>>t;
   if(s==t){
      cout<<N<<endl;
   }else{
      int ans=N;
      for(int i=1;i<N;i++){
         if(s.substr(i)==t.substr(0,N-i)){
            ans+=i;
            break;
         }
      }
      if(ans!=N) cout<<ans<<endl;
      else cout<<2*N<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
import math
import numpy as np
A, B, H, M = (int(i) for i in input().split())  

angleA = math.pi * 2 * (1 - (H/12 + 1/12 * M/60) + 1/4)
angleB = math.pi * 2 * (1 - M/60 + 1/4)

a = np.array([A * math.cos(angleA), A * math.sin(angleA)])
b = np.array([B * math.cos(angleB), B * math.sin(angleB)])

print(np.linalg.norm(a - b))


Measured memory_bytes: 27272
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	if(B-A==C-B)
	{
		printf("YES");
		return 0;
	}
	printf("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y;
	cin >> x >> y;
	if (x == 1 && y == 1) {
		dunk(300000 * 2 + 400000);
		return 0;
	}
	if (x >= 4) x = 4;
	if (y >= 4) y = 4;
	int ans = 100000 * (4 - x) + 100000 * (4 - y);
	dunk(ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int D = sc.nextInt();

        if(N % (2 * D + 1) == 0){
            System.out.println(N / (2 * D + 1));
        }else{
            System.out.println(N / (2 * D + 1) + 1);
        }

        sc.close();
    }
}

Measured memory_bytes: 21844
/*
"اله السماء يعطينا النجاح ونحن عبيده نقوم ونبني" 
"تكفيك نعمتي لان قوتي في الضعف تكمل"
created by shady rafet 
my face book : https://www.facebook.com/profile.php?id=100019579575853
never give up
one day i will do it ':(

*/
#include <bits/stdc++.h>
using namespace std;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ul;
const ll oo = 1e18;
const ll N = 1e6;
const ll mod = 1e9 + 7;
#define point complex<double>
const double pi = acos(-1);
double dot(point a, point b)
{
    return (conj(a) * b).real();
}
double cross(point a, point b)
{
    return (conj(a) * b).imag();
}
ll inv[N],fact[N];
ll fb(ll x, ll y)
{
    if(y == 0)
    return 1;
   ll ans = fb(x,y/2);
   ans = (ans * ans)%mod;
   if(y % 2 !=0)
   {
       ans = (ans*(x%mod))%mod;
   }
   return ans ;
}
void pre(ll n)
{
    fact[0] = 1;
    inv[0] = 1;
    for ( int i = 1;i<=n;i++)
    {
        fact[i] = (i * fact[i-1])% mod;
        inv[i] = fb(fact[i], mod-2);
    }
}
ll ncr (ll n , ll r)
{
      return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
ll npr (ll n,ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}
vector<int> adj[N];
bool visted[N];
int main()
{
   int cnt = 0;
   string a,b;
   cin>>a>>b;
   for(int i = 0;i<a.size();i++)
   {
       if(a[i]!=b[i])
       cnt++;
   }
   cout<<cnt;
    return 0;
}

Measured memory_bytes: 27348
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
#include<cmath>

#define rep(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;


int main() {
    int a, b;
    scanf("%d %d", &a, &b);

    int sum, minus, mult;
    sum = a + b;
    minus = a - b; 
    mult = a * b;

    int max = sum;
    if (max < minus) {
        max = minus;
    }
    if (max < mult) {
        max = mult;
    }

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

    return 0;
}

Measured memory_bytes: 256
N, M = [int(i) for i in input().split()]

mod = 10 ** 9 + 7

def mod_fact(n, mod = 10 ** 9 + 7):
    result = 1
    for i in range(2, n + 1):
        result = (result * i) % mod
    return result

if N == M:
    print((2 * mod_fact(N) * mod_fact(M)) % mod)
elif abs(N - M) == 1:
    print((mod_fact(N) * mod_fact(M)) % mod)
else:
    print(0)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

const ll N=2e5+10;
mat G(N);
vec si(N,-1);
vec ans(N,-1);
ll n;

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x%mod;
    }
    x=x*x%mod;
    n>>=1;
  }
  return ans;
}

vec tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

ll dfss(ll cur, ll pre) {
  if(si[cur]>-1) return si[cur];
  ll res=1;
  for(ll nex:G[cur]) {
    if(nex==pre) continue;
    res+=dfss(nex,cur);
  }
  return si[cur]=res;
}

ll dfs(ll cur, ll pre) {
  if(ans[cur]>-1) return ans[cur];
  ll res=tfact[dfss(cur,pre)-1];
  for(ll nex:G[cur]) {
    if(nex==pre) continue;
    (res*=mpow(tfact[dfss(nex,cur)],mod-2))%=mod;
    (res*=dfs(nex,cur))%=mod;
  }
  return ans[cur]=res;
}



int main() {
  cin >> n;
  fact(n);
  for(ll i=0;i<n-1;i++) {
    ll a,b;
    cin >> a >> b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0,-1);
  queue<pll> q;
  q.push({0,-1});
  while(q.size()) {
    ll cur=q.front().first;
    ll pre=q.front().second;
    q.pop();
    if(cur!=0) {
      ll res=ans[cur];
      (res*=mpow(tfact[si[cur]-1],mod-2))%=mod;
      (res*=tfact[n-1])%=mod;
      (res*=mpow(tfact[n-si[cur]],mod-2))%=mod;
      ll tmp=ans[pre];
      (tmp*=mpow(tfact[n-1],mod-2))%=mod;
      (tmp*=tfact[n-si[cur]-1])%=mod;
      (tmp*=tfact[si[cur]])%=mod;
      (tmp*=mpow(ans[cur],mod-2))%=mod;
      (res*=tmp)%=mod;
      ans[cur]=res;
    }
    for(ll nex:G[cur]) {
      if(nex==pre) continue;
      q.push({nex,cur});
    }
  }
  for(ll i=0;i<n;i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 99184
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
using namespace std;
#define MOD 1000000007




int main() {
	int count[100001];

	memset(count, 0, sizeof(count));
	int n, k;
	cin >> n >> k;
	vector<pair<int, int>> susi;
	for (int i = 0; i < n; i++) {
		int neta, oisisa;
		cin >> neta >> oisisa;
		susi.push_back(make_pair(oisisa, neta));
	}
	sort(susi.begin(), susi.end(),greater<pair<int,int>>());
	long long ans = 0;
	long long num = 0;
	for (int i = 0; i < k; i++) {
		ans += susi[i].first;
		if (count[susi[i].second] == 0) {
			num++;
		}
		count[susi[i].second]++;
	}
	long long max = ans + num * num;
	int min = k - 1;
	int now = k;
	int flag = 0;
	for (int i = num; i <= n; i++) {
		for (int j = min; j >= 0; j--) {
			if (count[susi[j].second] >= 2) {
				count[susi[j].second]--;
				ans -= susi[j].first;
				min = j - 1;
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			cout << max;
			return 0;
		}
		flag = 0;
		for (int j = now; j < n; j++) {
			if (count[susi[j].second] == 0) {
				count[susi[j].second]++;
				ans += susi[j].first;
				now = k + 1;
				num++;
				flag = 1;
				break;
			}					   
		}
		if (flag == 0) {
			cout << max;
			return 0;
		}
		flag = 0;
		long long temp = ans + num * num;
		if (max < temp)max = temp;
	}
	cout << max;


	return 0;
}


Measured memory_bytes: 1784