akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 20, MAX_M = 20;
int N, M, C;
int B[MAX_M];
int A[MAX_N][MAX_M];

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

  cin >> N >> M >> C;
  rep(i, M) cin >> B[i];
  rep(i, N) {
    rep(j, M) {
      cin >> A[i][j];
    }
  }

  int ans = 0;
  rep(i, N) {
    int tmp = C;
    rep(j, M) {
      tmp += A[i][j] * B[j];
    }
    if (tmp > 0) ++ans;
  }

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


Measured memory_bytes: 888
#include <iostream>

using ll = long long;
using namespace std;

const ll LIMIT = 1000000000000000000;

int main() {
  ll a, b, c, k;
  cin >> a, cin >> b, cin >> c, cin >> k;

  ll ans = a - b;
  if (k % 2 == 1) {
    ans *= -1;
  }

  if (abs(ans) > LIMIT) {
    cout << "Unfair" << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n,y = map(int,input().split())

for i in range(y // 10000 + 1):
    for k in range(( y - i*10000) // 5000 + 1):
        if i*10000 + k*5000 + (n - i - k)*1000 == y:
            print(i,k,(n - i - k))
            quit()
print("-1 -1 -1")


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            String s = sc.next();
            int zero = 0;
            int one = 0;
            for (int i = 0; i < s.length(); i++) {
                if(s.charAt(i) == '0') {
                    zero ++;
                } else {
                    one++;
                }
            }
            System.out.println(Math.min(zero, one) * 2);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 24916
#include<bits/stdc++.h>
using namespace std;
int a[100050];
int main(){
//	freopen("input.txt","r",stdin);
	int n;
	scanf("%d",&n);
	int count=1;
	scanf("%d",&a[1]);
	int flag=0;
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(flag==1)
		{
			if(a[i]<a[i-1])
			{
				count++;
				flag=0;
			}
		}
		else if(flag==2)
		{
			if(a[i]>a[i-1])
			{
				count++;
				flag=0;
			}
		}
		else
		{
			if(a[i]>a[i-1])
				flag=1;
			if(a[i]<a[i-1])
				flag=2;	
		}
	}
	printf("%d\n",count);
	return 0;
} 


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
    int D;
    cin >> D;
    string s;
    if(D==25) s="Christmas";
    else if(D==24) s="Christmas Eve";
    else if(D==23) s="Christmas Eve Eve";
    else if(D==22) s="Christmas Eve Eve Eve";

    cout << s << endl;
}

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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }
signed main() {
	string s; cin >> s;
	int n = s.size();
	int ans = 0;
	rep(i, 1, n) ans += s[i - 1] != s[i];
	cout << ans << endl;
	system("pause");
}

Measured memory_bytes: 760
marks = ["S", "H", "C", "D"]
cards = []
marks.each do |m|
  (1..13).each do |n|
    cards << m + "\s" + n.to_s
  end
end

ARGF.each_line do |line|
  next unless marks.include?(line[0])
  d_line = line.chomp
  cards.delete(d_line)
end

cards.each do |card|
  puts card
end

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

map <int,int> memo;
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,t;
	int res = 0;

	cin >> n;

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

	for(auto it : memo)
	{
		int x = it.first;
		int y = it.second;

		if(y>=x)
		{
			res += (y-x);
		}
		else
		{
			res += y;
		}
	}

	cout << res << '\n';

	return 0;	
}

Measured memory_bytes: 4736
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
#define N 100009
#define LL long long
#define INF 0x3f3f3f3f
#define mymin(x,y) (x>=y?y:x)
#define mymax(x,y) (x>=y?x:y)
int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	LL n;
	cin >> n;
	LL sqrn = sqrt(n), a, b;
	for(int i = 1; i <= sqrn; i++){
		if(n % i == 0){
			a = i;
		}
	}
	b = n / a;
	cout << a + b - 2 << endl;
	return 0;
}


Measured memory_bytes: 3704
#include <stdio.h>
#define LL long long

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

int main()
{
  LL int A,B;
  scanf("%lld %lld",&A,&B);
  printf("%lld",A*B/gcd(A,B) );

  return 0;
}


Measured memory_bytes: 1700
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    
    if(n>=1 && n<=9){
      int ans = n*n*n;
      
      System.out.println(ans);
      
    }else{
      System.out.println("数値は1桁で入力してください");
    }
    
  }
  
}

Measured memory_bytes: 35840
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int num[] = new int[9];
		int color[] = new int[9];
		int red_num = 0;
		int green_num = 0;
		int blue_num = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 9; j++) {
				num[j] = sc.nextInt();
			}
			for (int j = 0; j < 9; j++) {
				String a = sc.next();
				if (a.compareTo("R") == 0) {
					color[j] = 1;
					red_num += 1;
				}
				if (a.compareTo("G") == 0) {
					color[j] = 2;
					green_num += 1;
				}
				if (a.compareTo("B") == 0) {
					color[j] = 3;
					blue_num += 1;
				}
			}
			int red[] = new int[red_num];
			int green[] = new int[green_num];
			int blue[] = new int[blue_num];
			red_num = 0;
			green_num = 0;
			blue_num = 0;
			for (int j = 0; j < 9; j++) {
				switch (color[j]) {
				case 1:
					red[red_num] = num[j];
					red_num += 1;
					break;
				case 2:
					green[green_num] = num[j];
					green_num += 1;
					break;
				case 3:
					blue[blue_num] = num[j];
					blue_num += 1;
					break;
				}
			}
			Arrays.sort(red);
			Arrays.sort(blue);
			Arrays.sort(green);
			int count = 0;
			if (change(red) != null) {
				red = change(red);
				count += search(red);
			}
			if (change(green) != null) {
				green = change(green);
				count += search(green);
			}
			if (change(blue) != null) {
				blue = change(blue);
				count += search(blue);
			}
			if (count == 3)
				System.out.println(1);
			else
				System.out.println(0);

		}
	}

	static int search(int[] a) {
		int[] num = a;
		int count = 0;

		for (int i = 0; i < num.length; i++) {
			if (num[i] >= 3) {
				count += 1;
				num[i] -= 3;
			}
		}

		int i = 0;
		while (true) {
			if (num[i] <= 0) {
				i += 1;
			}
			if (i >= 7)
				break;
			if (num[i] >= 1 && num[i + 1] >= 1 && num[i + 2] >= 1) {
				count += 1;
				num[i] -= 1;
				num[i + 1] -= 1;
				num[i + 2] -= 1;
			} else {
				num[i] -= 1;
			}
			boolean check = true;
			for (int j = 0; j < 9; j++) {
				if (num[j] != 0)
					check = false;
			}
			if (check == true)
				break;
		}
		return count;
	}

	static int[] change(int[] a) {
		if (a.length != 0) {
			int count = 0;
			int number[] = new int[9];
			for (int i = 0; i < 9; i++) {
				number[i] = 0;
			}
			for (int i = 0; i < a.length; i++) {
				if (a[i] != 0)
					number[(a[i] - 1)] += 1;
			}
			return number;
		} else
			return null;
	}

	static int array_search(int[] a) {
		if (a.length != 0) {
			int count = 0;
			int number[] = new int[9];
			for (int i = 0; i < 9; i++) {
				number[i] = 0;
			}
			for (int i = 0; i < a.length; i++) {
				if (a[i] != 0)
					number[(a[i] - 1)] += 1;
			}
			for (int i = 0; i <= 6; i++) {
				if (number[i] > 0 && number[i + 1] > 0 && number[i + 2] > 0) {
					count += 1;
					number[i] -= 1;
					number[i + 1] -= 1;
					number[i + 2] -= 1;
				}
			}
			return count;
		} else
			return 0;

	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    ll a, b;
    int k;
    cin >> a >> b >> k;
    for (int i = 0; i < k; i++) {
        if (i % 2 == 0) {
            if (a % 2 == 0) {
                b += a / 2;
                a /= 2;
            }else{
                b += (a - 1) / 2;
                a = (a - 1) / 2; 
            }
        }else{
            if (b % 2 == 0) {
                a += b / 2;
                b /= 2;
            }else{
                a += (b - 1) / 2;
                b = (b - 1) / 2; 
            }
        }
    }
    cout << a << ' ' << b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
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, M; cin >> N >> M;
  if(N==M) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

int main()
{
	long long n, k;

	std::cin >> n >> k;

	std::vector<long long> v(n);

	for (size_t i = 0; i < n; i++)
	{
		std::cin >> v[i];
	}

	std::sort(v.begin(), v.end());
	std::reverse(v.begin(), v.end());

	long long sum = 0;

	for (size_t i = 0; i < k; i++)
	{
		sum += v[i];
	}

	std::cout << sum << std::endl;

	return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7


def power(x, y, z):
    if x == 1 or y == 0:
        return 1
    a = power(x, y // 2, z)
    a = (a * a) % z
    if y % 2 == 1:
        a = (a * x) % z
    return a


def choose(n, r, z):
    x = 1
    y = 1

    for i in range(min(r, n - r)):
        x = (x * (n - i)) % z
        y = (y * (i + 1)) % z

    y = power(y, z - 2, z)
    return (x * y) % z


ans = power(2, n, mod) - 1 - choose(n, a, mod) - choose(n, b, mod)
ans %= mod

print(ans)


Measured memory_bytes: 3064
X,K,D=map(int,input().split())
"""
XからK回移動しなければならない
Dは一回の移動距離
"""
kaisu=abs(X)//abs(D)

one=abs(abs(X)-abs(D)*kaisu)
two=abs(abs(X)-abs(D)*(kaisu+1))

#まず、たどりつけないとき
if K<kaisu:
    ans=abs(X)-abs(D)*K
elif K==kaisu:
    ans=one
elif K>kaisu:
    #kaisu,kaisu+2,kaisu+4 動かすとoneにたどり着く
    #kaisu+1,kaisu+3,kaisu+5 動かすとtwoにたどり着く
    if (K-kaisu)%2==0:
        ans=one
    elif (K-kaisu)%2!=0:
        ans=two
print(ans)


Measured memory_bytes: 61696
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int x,y;
int main(){
	in(x);in(y);
    if(x==y)puts("Yes");
    else puts("No");
	return 0;
}


Measured memory_bytes: 256
S = gets.chomp; x, y = gets.split.map(&:to_i)

x -= $~[0].size if /^F+/ =~ S
horz, vert, h_flag = [], [], true
S.scan(/(T+)(F+)/).each do |t, f|
  h_flag = !h_flag if t.size.odd?
  h_flag ? horz << f.size : vert << f.size
end

def go(as)
  as.inject([0]){|res, a| res.flat_map{|k| [k + a, (k - a).abs]}.uniq}
end

puts go(horz).member?(x.abs) && go(vert).member?(y.abs) ? 'Yes' : 'No'

Measured memory_bytes: 4092
import math
X = int(input())
if X < 4:
    print(X)
    exit()
n = X
ans = 0
while 1:
    for i in range(2, 1+int(math.sqrt(n))):
        if n % i == 0:
            n += 1
            break
        if (i == int(math.sqrt(n))):
            ans = n
    if ans != 0:
        print(n)
        exit()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll>pairs;
int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,c,f;
	cin>>n;
	f=0;
	vector<ll>a(n+1);
	i=1;
	while(i<=n)
	{
	    cin>>a[i];
	    if(a[i]==2)
	    f++;
	    i++;
	}
	i=1;c=0;
	while(a[i]!=2)
	{
	    if(a[i]==0)
	    {f=0;break;}
	    else{
	    c++;k=a[i];a[i]=0;i=k;}
	}
	if(f)
	cout<<c+1;
	else
	cout<<-1;
	return 0;
}


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

#define int long long
//#define uint __int128_t

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,Q;
int s[100010];
int s1[100010];
int oddS[100010],evenS[100010];
vint v;
int X;

bool f(int c){
    if(c>N)return false;
    int a=(c+1)/2;
    int aa=N-a;
    int x=low(v,X-(v[aa]-X));
    return (x+c<=N);
}

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>N>>Q;
    v.resize(N);
    rep(i,0,N){
        cin>>v[i];
        s[i+1]=v[i]+s[i];
        if(N%2==0)s1[i+1]=s1[i]+(i%2)*v[i];
        else s1[i+1]=s1[i]+(i%2==0)*v[i];
    }
    while(Q--){
        cin>>X;
        int r=0;
		for(int i=20;i>=0;i--) {
			if(f(r+(1<<i))) r+=1<<i;
		}
        if(r%2)r++;
        //cout<<r<<endl;
        int ans=s[N]-s[N-r/2];
        if(r<N)ans+=s1[N-r];
        cout<<ans<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll umin(ll a ,ll b)
{
	if(a>b)return b;return a;
}
ll dp[2][100001];
int main()
{
	ll n,w;cin >> n >> w;
	vector<ll> ww,vv;ll maxv=0;
	for(ll i=0;i<n;i++)
		{
			ll d;
			cin >> d;ww.push_back(d);cin >> d;vv.push_back(d);
				maxv+=vv[i];
		}
		for(ll i=0;i<=1;i++)
			for(ll j=0;j<=100001;j++)
				dp[i][j]=1e16;
			ll ans =0;
					//ans=j;
		for(ll i=0;i<=n;i++)
		{
			for(ll j=0;j<=maxv;j++)
			{
				int t=i%2;
				if(i==0 and j!=0)
					dp[t][j]=1e16;
				else if(i==0 or j==0)
					dp[t][j]=0;
				else
				{
					dp[t][j]=umin(dp[t][j],dp[!t][j]);
					if(j-vv[i-1]>=0)
					dp[t][j]=umin(dp[!t][j],ww[i-1]+dp[!t][j-vv[i-1]]);
				}
				if(dp[t][j]<=w and ans <j)
					ans =j;
			}
		}
				cout << ans;
	return 0;
}

Measured memory_bytes: 1792
fac=[1]*505050
inv=[1]*505050
finv=[1]*505050
mod=1000000007
for i in range(2,500010):
  fac[i]=fac[i-1]*i%mod
  inv[i]=-inv[mod%i]*(mod//i)%mod
  finv[i]=finv[i-1]*inv[i]%mod

def C(n,r):
  if n<0 or r<0 or n<r: return 0
  return fac[n]*finv[n-r]%mod*finv[r]%mod

N,M=map(int,input().split())
ans=0
for i in range(N+1):
  ans+=C(N,i)*fac[M]%mod*finv[M-i]%mod*((fac[M-i]*finv[M-N]%mod)**2%mod)*(1 if i%2==0 else -1)%mod
  ans%=mod
print(ans%mod)


Measured memory_bytes: 107388
#include <stdio.h>
#include <array>
#include <algorithm>
#include <vector>

constexpr int MAX_X = 1e5;
constexpr int MAX_N = 200;
constexpr int mod = 1e9 + 7;
std::vector<int> S;
std::array<std::array<long long int, MAX_X+1>, MAX_N> DP;

int main(void){
    int n, X; scanf("%d%d", &n, &X);
    S.resize(n); for(int i = 0; i < n; ++i) scanf("%d", &S[i]);
    // DP[n][x] := 数字 x を s0 ... sn-1 で やった時の解
    // 遷移式 : DP[i][0] = 0 for all i 
    //       : DP[0][x] = x % s0
    //         DP[i][x] = DP[i-1][x] * i + DP[i-1][x % i]
    std::sort(S.begin(), S.end());
    for(int x = 0; x <= X; ++x) DP[0][x] = x % S[0];
    for(int i = 0; i < n; ++i) DP[i][0] = 0;
    for(int i = 1; i < n; ++i){
        for(int x = 0; x <= X; ++x) DP[i][x] = (DP[i-1][x] * i + DP[i-1][x % S[i]]) % mod;
    }
    printf("%lld\n", DP[n-1][X]);
    return 0;
}

Measured memory_bytes: 156544
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;


int main(void)
{
	int n;
	vector<int> s;

	while(scanf("%d", &n)==1)
	{
		s.resize(n);
		int ans=0;
		int t10_min=0;
		for(int i=0;i<n;i++)
		{
			scanf("%d", &s[i]);
			ans+=s[i];
			if(s[i]%10)
			{
				if(t10_min==0 || t10_min>s[i])
				{
					t10_min=s[i];
				}
			}
		}
		if(ans%10==0) ans-=(t10_min?t10_min:ans);
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 3001
string s, t;
int dp[N][N];
int bc[N][N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s>>t;
	for(int i=1; i<=s.size(); i++)
		for(int j=1; j<=t.size(); j++)
			if(s[i-1] == t[j-1]){
				dp[i][j] = 1 + dp[i-1][j-1];
				bc[i][j] = 3;
			}else{
				if(dp[i-1][j] > dp[i][j-1]){
					dp[i][j] = dp[i-1][j];
					bc[i][j] = 1;
				}else{
					dp[i][j] = dp[i][j-1];
					bc[i][j] = 2;
				}
			}
	int ans = -1, n1 = s.size(), n2 = t.size();
	stringstream ss;
	while(n1 > 0 and n2 > 0){
		if(bc[n1][n2] == 3)
			ss<<s[n1-1], n1--, n2--;
		else if(bc[n1][n2] == 1)
			n1--;
		else
			n2--;
	}
	string s = ss.str();
	reverse(s.begin(), s.end());
	cout<<s;
	return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int n;
    int a;
    int sum=0;
    cin>>n;
    rep(i,n){
        cin>>a;
        sum+=(a-1);
    }
    cout<<sum;
}

Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int min(int a,int b,int c) {
    int t=a<b?a:b;
    return t<c?t:c;
}
int main() {
    string s1,s2;
    int d[1010][1010];
    cin>>s1>>s2;
    int n=s1.length();
    int m=s2.length();
    if(n==0){return n;}
    if(m==0){return m;}
    for(int i=0;i<=n;i++){
        d[i][0]=i;
    }
    for(int j=0;j<=m;j++){
        d[0][j]=j;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s1[i-1] == s2[j-1]){
                d[i][j] = d[i-1][j-1];
            }
            else{
                d[i][j] = min(d[i-1][j]+1,d[i][j-1]+1,d[i-1][j-1]+1);
            }
            
        }
    }
    cout<<d[n][m]<<endl;
}

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n, m; cin>>n>>m;
  if(n == m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



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

int main() {
    int N, a;

    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        cin >> a;
        if (i % 2 == 1 && a % 2 == 1)
        {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(){
  char a[81];
  int i,j;
  
  while(fgets(a,80,stdin)!=NULL){
    for(i=0;i<9;i++){
      for(j=0;j<(9-i);j++){
        a[j]=a[j]+a[j+1]-'0';
        a[j]=(a[j]>'9'?a[j]-=10:a[j]);
      }
    }
    putchar(a[0]);putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 524
N, M = map(int, input().split())
k = [0] * M
s = [0] * M
for i in range(M):
    s[i] = list(map(int, input().split()))
    k[i] = s[i].pop(0)
p = list(map(int, input().split()))

ans = 0

for i in range(2**N):
    b = format(i, "0" + str(N) + "b")
    for j in range(M):
        if sum([int(b[x-1]) for x in s[j]]) % 2 != p[j]:
            break
        if j == M - 1:
            ans += 1

print(ans)

Measured memory_bytes: 9004
#include <bits/stdc++.h>
using namespace std;
string s,t;
int b=1;
int main()
{
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            b=0;
    }
    if(s.size()+1!=t.size())
    {
            b=0;
            cout<<t.size()+1<<s.size()<<b<<endl;
    }
     if(s.size()>10 || s.size()<1)
            b=0;
            
        if(b==1)
    cout <<"Yes"<< endl;
    else
cout <<"No"<< endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] e = new int[4][2];
		while(sc.hasNext()){
			for(int i=0;i<2;i++){
				double x = sc.nextDouble();
				if(x<0.2)e[3][i]++;
				else if(x<0.6)e[2][i]++;
				else if(x<1.1)e[1][i]++;
				else e[0][i]++;
			}
		}
		for(int i=0;i<4;i++)System.out.println(e[i][0]+" "+e[i][1]);
	}
}

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

int main() {
  string s ;
  cin >> s;
  
  int a =0;
  int b =0;
  
  for (int i =0 ; i<s.size();i++){
    
   
    if (s[i] == 'A'){
      a += i;
      break;
    }
  } 
    for(int j = s.size(); j>=0; j--){
      
      if(s[j] =='Z'){
        b += j;
        break;
      }
    } 
      
  cout << b-a+1 <<endl;
    
}

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

using namespace std;

bool solve(const vector<string>& W) {
  const int n = W.size();
  for (int i = 0; i < n - 1; i++) {
    if (W[i].back() != W[i + 1].front()) {
      return false;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (W[i] == W[j])
        return false;
    }
  }
  return true;
}

int main() {
  int N;
  cin >> N;
  vector<string> W(N);
  for (int i = 0; i < N; i++) {
    cin >> W[i];
  }
  if (solve(W)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  /*
  unordered_set<string> S;
  cin >> N;
  string ls = "___";

  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;

    if (i > 1) {
      if (s.front() != ls.back()) {
        cout << "No" << endl;
        return 0;
      } else if (S.find(s) != S.end()) {
        cout << "No" << endl;
        return 0;
      }
    }
    ls = s;
    S.insert(s);
  }
  cout << "Yes" << endl;
  */
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Constans;

public static class Constans
{
    public const long Mod = (long)1e9 + 7;
}

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var M = vals[1];
        var ng = new bool[N+1];
        for (int i = 0; i < M; i++)
        {
            var v = int.Parse(Console.ReadLine());
            ng[v] = true;
        }

        var pattern = new long[N + 1];
        pattern[0] = 1;
        for (int i = 0; i < N; i++)
        {
            if (ng[i])
            {
                continue;
            }

            for (var j = 1; j <= 2; j++)
            {
                var next = i + j;
                if (next <= N)
                {
                    pattern[next] += pattern[i];
                    pattern[next] %= Mod;
                }
            }
        }

        Console.WriteLine(pattern[N]);
    }
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int>V(N);
	for (int n = 0;n<N;++n) {
		cin >> V[n];
	}
	int num = min(N,K);
	int ans = 0;
	for (int n = 0;n<=num;++n) {
		for (int a = 0;a<=n;++a) {
			vector<int>Bad;
			int b = n - a;
			int tmp = 0;
			for (int m = 0;m<a;++m) {
				tmp += V[m];
				if (V[m]<0) {
					Bad.push_back(V[m]);
				}
			}
			for (int m = 0;m<b;++m) {
				tmp += V[N - 1 - m]; 
				if (V[N - 1 - m] < 0) {
					Bad.push_back(V[N - 1 - m]);
				}
			}
			sort(Bad.begin(), Bad.end());
			for (int m = 0;m< min((int)Bad.size(),K-n);++m) {
				tmp -= Bad[m];
			}
			ans = max(ans, tmp);
		}
	}
	cout << ans <<  endl;
	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>

using namespace std;

constexpr bool __debugFlag = false;

class Sushi {
public:
    Sushi () {};
    int64_t x;
    int64_t v;
    int64_t rx;
};

class rotationCalory {
public:
    int64_t calorySum;
    int64_t maxCalorySum;

};

int main(int argc, char **argv) {

    int64_t numberOfSushi;
    int64_t circumference;
    cin >> numberOfSushi >> circumference ;
    
    vector <Sushi> sushis(numberOfSushi);

    for(int64_t i=0; i<numberOfSushi; i++){
        cin >> sushis[i].x >> sushis[i].v;
        sushis[i].rx = circumference - sushis[i].x;
    }

    vector<rotationCalory> rightRotation(numberOfSushi);
    vector<rotationCalory> leftRotation(numberOfSushi);
    
    int64_t maxCalorySum = 0;

    rightRotation[0].calorySum = sushis[0].v - sushis[0].x;
    rightRotation[0].maxCalorySum = rightRotation[0].calorySum;
    for(int64_t i=1; i<numberOfSushi; i++){
        rightRotation[i].calorySum = rightRotation[i-1].calorySum + (sushis[i].v - sushis[i].x + sushis[i-1].x) ;
        rightRotation[i].maxCalorySum = max(rightRotation[i-1].maxCalorySum, rightRotation[i].calorySum);
    }
    maxCalorySum = max(rightRotation[numberOfSushi-1].maxCalorySum, maxCalorySum);

    leftRotation[numberOfSushi-1].calorySum = sushis[numberOfSushi-1].v - sushis[numberOfSushi-1].rx;
    leftRotation[numberOfSushi-1].maxCalorySum = leftRotation[numberOfSushi-1].calorySum;
    for(int64_t i=numberOfSushi-2; i>=0; i--){
        leftRotation[i].calorySum = leftRotation[i+1].calorySum + (sushis[i].v - sushis[i].rx + sushis[i+1].rx) ;
        leftRotation[i].maxCalorySum = max(leftRotation[i+1].maxCalorySum, leftRotation[i].calorySum);
    }
    maxCalorySum = max(maxCalorySum, leftRotation[0].maxCalorySum);
    

    for(int64_t i=0; i<numberOfSushi-1; i++){
        maxCalorySum = max(maxCalorySum, rightRotation[i].calorySum - sushis[i].x + leftRotation[i+1].maxCalorySum);
    }

    for(int64_t i=numberOfSushi-1; i>=1; i--){
        maxCalorySum = max(maxCalorySum, leftRotation[i].calorySum - sushis[i].rx + rightRotation[i-1].maxCalorySum);
    }


    cout << maxCalorySum << endl;


    if (__debugFlag) { 

        cout << numberOfSushi << "," << circumference << endl;
        for(int64_t i=0; i<numberOfSushi; i++){
            cout <<  sushis[i].x << "," << sushis[i].rx  << ","<<  sushis[i].v<< endl;
        }
        cout << "-----------" << endl;
        for(int64_t i=0; i<numberOfSushi; i++){
            cout <<  rightRotation[i].calorySum << ":" << rightRotation[i].maxCalorySum << ",";
            cout <<  leftRotation[i].calorySum << ":" << leftRotation[i].maxCalorySum << endl;
        }
    }
    return 0;

}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n, m;
vector<int> g[100005];
int c[100005];
void solve() {
    cin >> n >> m;

    rep(i, m) {
        int a, b; cin >> a >> b; --a; --b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }

    queue<int> que;
    que.push(0);
    c[0] = 1;
    while (!que.empty()) {
        auto v = que.front(); que.pop();

        rep(i, g[v].size()) {
            auto nv = g[v][i];
            if (c[v] == c[nv]) {
                cout << ((ll)n) * (n - 1) / 2 - m << endn;
                return;
            }

            if (c[nv] == 0) {
                c[nv] = -c[v];
                que.push(nv);
            }

        }
    }

    ll b = 0;
    rep(i, n) if (c[i] == 1) ++b;

    cout << b * (n - b) - m << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 6272
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
typedef pair<P, int> PP;
struct edge { int to, cost; };


int V;
vector<edge> G[310];
P d[310][310];
int L;
void dijkstra(int s) {
    priority_queue<PP, vector<PP>, greater<PP> > que;
    d[s][s] = {0, 0};
    que.push({{0, 0}, s});

    while (!que.empty()) {
        PP p = que.top(); que.pop();
        int v = p.second;
        if (d[s][v].first < p.first.first || (d[s][v].first == p.first.first && d[s][v].second <p.first.second) ) continue;
        for (edge e: G[v]){
            P toCost = {d[s][v].first, d[s][v].second + e.cost};
            if (toCost.second > L) {
                toCost.first++;
                toCost.second = e.cost;
            }
            if (d[s][e.to].first> toCost.first || (d[s][e.to].first == toCost.first && d[s][e.to].second > toCost.second)) {
                d[s][e.to] = toCost;
                que.push({d[s][e.to], e.to});
            }
        }
    }
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M >> L;
    rep(i, N) rep(j, N) d[i][j] = {INF, INF};
    rep(i, M) {
        int s, t, c;
        cin >> s >> t >> c;
        if (c > L) continue;
        s--; t--;
        G[s].push_back({t, c});
        G[t].push_back({s, c});
    }
    rep(i, N)
        dijkstra(i);
    int Q; cin >> Q;
    while(Q--) {
        int s, t; cin >> s >> t;
        s--; t--; 
        //cout << "***" << d[s][t].first << " " << d[s][t].second <<"***" << endl;
        if (d[s][t].first == INF) {
            cout << -1 << endl;
        } else {
            cout << d[s][t].first << endl;
        }
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int m;
bool gg[830][830];
vi g[830];

bool used[830];
int color[830];

pii dfs(int p, int c){
  pii ret = pii(0,0); // 0cnt, 1cnt
  color[p] = c;
  used[p] = true;
  (c?ret.second:ret.first)++;
  for(int to : g[p]){
    if(color[to] == c){
      return pii(-1, -1);
    }
    if(used[to])continue;
    pii P = dfs(to, c^1);
    if(P.first == -1)return P;
    ret.first += P.first;
    ret.second += P.second;
  }
  return ret;
}

bool dp[830][830];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,n)REP(j,n)gg[i][j] = true;
  REP(i,n)gg[i][i] = true;
  REP(i,m){
    int a,b;
    scanf("%d%d",&a,&b);
    a--; b--;
    gg[a][b] = gg[b][a] = false;
  }
  REP(i,n)REP(j,i)if(gg[i][j]){
    g[i].push_back(j);
    g[j].push_back(i);
  }
  REP(i,n)color[i] = -1;
  vector<pii> po;
  REP(i,n)if(!used[i]){
    pii P = dfs(i,0);
    if(P.first == -1){
      puts("-1");
      return 0;
    }
    po.push_back(P);
  }
  int l = po.size();
  dp[0][0] = true;
  REP(i,l){
    int a = po[i].first;
    int b = po[i].second;
    REP(j,n){
      if(dp[i][j]){
        dp[i+1][j+a] = true;
        dp[i+1][j+b] = true;
      }
    }
  }
  int ans = n*n;
  REP(i,n+1)if(dp[l][i]){
    CHMIN(ans, i*(i-1)/2 + (n-i)*(n-i-1)/2);
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>

int main(){

   int W, H, x, y, r;       // define variable, -100<=x, y<=100, 0<W, H, r<=100
   int flag=1;            // define flag, if circle in the rectangle, flag is true

   scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

   if(x-r < 0) flag = 0;
   if(x+r > W) flag = 0;
   if(y-r < 0) flag = 0;
   if(y+r > H) flag = 0;

   if (flag == 1) printf("Yes\n");
   else printf("No\n");

   return 0;
}

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

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

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  vector<ll> tmp;
  for(int i = min(a, b); i > 0; i--) {
    if (a % i == 0 && b % i == 0) {
      tmp.push_back(i);
    }
  }
  cout << tmp[k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
vi Digit(ll x){
	vi res ;
	while(x){
		res.pb(x % 10) ;
		x /= 10 ;
	}
	return res ;
}
		

int main(){
	IOS;
	cout.precision(30) ;
	string s , t ; cin >> s >> t ;
	vector<vi> pos(26);
	int n = s.size() ;
	for(int i = 0 ; i < n ; i++){
		pos[(int)s[i] - (int)'a'].pb(i) ;
	}
	vector<bool> visited(n , false); 
	for(int i = 0 ; i < n ; i++){
		if(s[i] != t[i] &&!visited[i]){
			int c1 = (int)s[i] - (int)'a' ;
			int c2 = (int)t[i] - (int)'a' ;
			for(int j = 0 ; j < (int)pos[c1].size();j++){
				s[pos[c1][j]] = t[i] ;
				visited[pos[c1][j]] = true ;
			}
			for(int j = 0 ; j < (int)pos[c2].size() ; j++){
				s[pos[c2][j]] = (char)(c1 + (int)'a') ;
			}
			swap(pos[c1] , pos[c2]) ;
		}
		//cout << s << endl ;
		
	}
	if(s == t) cout << "Yes" << endl ;
	else cout << "No" << endl ;
	return 0;
}


Measured memory_bytes: 1812
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
ll ans = 0;
ll n, arr[200005];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	REP(i, 0, n){
		cin >> arr[i];
		if (i == 0) continue;
		if (arr[i] >= arr[i - 1]) continue;
		ans += (arr[i - 1] - arr[i]);
		arr[i] = arr[i - 1];
	}
	cout << ans << endl;
}

//cout.flush()
//cout << fixed << setprecision(9) << x << endl;

Measured memory_bytes: 5208
<?php
	while(true) {
		$stdin = trim(fgets(STDIN));
		if($stdin === '') {
			break;
		}
		$val = explode(',', $stdin);
		$number = $val[0];
		$weight = $val[1];
		$height = $val[2];

		$bmi = $weight / ($height * $height);
		if ($bmi >= 25) {
			printf("%d\n", $number);
		}
	}

Measured memory_bytes: 15076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string s;
    cin >>s;
    sort(s.begin(),s.end());
    if(s=="abc") cout << "Yes" <<endl;
    else cout <<"No" <<endl;



}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  char s[100001];
  scanf("%s",s);
  
  char st0[100001] , st1[1000001];
  
  for(int i = 0;s[i] != '\0';i ++){
    if(i%2 == 0){
     st0[i] = '0';
     st1[i] = '1';
     }
     else{
      st0[i] = '1';
      st1[i] = '0';
     }
    }
  int t0 = 0,t1 = 0;
  for(int i = 0;s[i] != '\0';i ++){
    if(s[i] != st0[i]){
      t0 ++;
    }
    if(s[i] != st1[i]){
      t1 ++;
    }
  }

  printf("%d",(t0<t1?t0:t1));
  
  return 0;
}

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

int a[555][555];

void solve(int l, int r, int level)
{
  if (l >= r)
    return;
  int m = (l + r) / 2;
  for (int i = l; i <= m; i++)
    for (int j = m + 1; j <= r; j++)
      a[i][j] = level;
  solve(l, m, level + 1);
  solve(m + 1, r, level + 1);
}

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

  int n;
  cin >> n;
  solve(1, n, 1);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      cout << a[i][j] << " \n"[j == n];
}


Measured memory_bytes: 1536
n,m=[int(i) for i in input().split()]
AC=[False]*n
WA=[0]*n
for i in range(m):
    p,s=[_ for _ in input().split()]
    p=int(p)-1
    if s=="WA" and not AC[p]:
        WA[p]+=1
    elif s=="AC":
        AC[p]=True
ans=[0,0]
for i in range(n):
    if AC[i]:
        ans[0]+=1
        ans[1]+=WA[i]
print(*ans,sep=" ")

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int INF=1001001001;

int main() {
  string s;
  cin>>s;
  if(s.size()==2){cout<<s<<endl;}
  else{reverse(s.begin(),s.end());cout<<s<<endl;}
  return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += a[i] - 1;
  }
  cout << ans << endl;  
  return 0;
}

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

int main(){
	int n, k, x, y;
	int sum = 0;
	cin >> n >> k >> x >> y;
	if (n > k) {
		sum = (n - k) * y + k * x;
	} else {
		sum = n * x;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  string a[n],b[m];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int j=0;j<m;j++)cin>>b[j];
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      int c=1;
      for(int k=i;k<i+m;k++){
        for(int l=j;l<j+m;l++){
          if(a[k][l]!=b[k-i][l-j]){
            c=0;
            break;
          }
        }
        if(c==0)break;
        
      }
      if(c==1){
        cout<<"Yes"<<endl;
        return 0;
      }
      
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split(" "))

ans = 0
for b in range(K+1,N+1):
	#for rem in range(K,b):
	# ans += (N - rem) // b

	k = ((N - K) // b)
	num = min(((N - K) % b) + 1,b-K)
	other = (b - K) - num

	ans += ((b - K) * (k + 1) - other)
	

if K == 0:
	print(ans - N)
else:
	print(ans)

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

int main() {
  int N;
  cin >> N;
  
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  
  vector<int> Q(N);
  for (int i = 0; i < N; i++) {
    cin >> Q.at(i);
  }
  
  vector<int> X(N-1,1);
  for (int j = 2; j < N + 1; j++) {
    for (int i = 1; i < j ; i++) {
      X.at(j - 2) *= i;
    }
  }
  
  vector<int> Y(N-1,0);
  
  for (int i = N; i != 1; i--) {
    for (int j = N; j > i-1; j--) {
      if (P.at(i-2) > P.at(j-1)){
        Y.at(N-i)++;
      }
    }
  }
  
  vector<int> Z(N-1,0);
  
  for (int i = N; i != 1; i--) {
    for (int j = N; j > i-1; j--) {
      if (Q.at(i-2) > Q.at(j-1)){
        Z.at(N-i)++;
      }
    }
  }
  
  int p = 0;
  for (int i = 0; i < N - 1; i++) {
    p += X.at(i) * Y.at(i);
  }
  
  int q = 0;
  for (int i = 0; i < N - 1; i++) {
    q += X.at(i) * Z.at(i);
  }
  
  
 
  
  if (p == q){
    cout << 0 << endl;
  }
  else if (p > q){
    cout << p - q << endl;
  }
  else {
    cout << q - p << endl;
  }
}
    
  



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll w[205];
ll v[205];
ll c[200005];
ll h[200005];
ll dp[105][100005];
typedef pair<int, int> P;

int main() {
	int h, a;
	cin >> h >> a;
	if (h % a != 0) {
		cout << h / a + 1 << endl;
	}
	else {
		cout << h / a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, x = [int(i) for i in input().split()]
S = [int(i) for i in input().split()]
DP = [[0] * (x + 1) for i in range(n + 1)]
DP[0][x] = 1
p = 10 ** 9 + 7
S.sort(reverse=True)

for i in range(n):
    for j in range(x + 1):
        DP[i][j] %= p
        if i != n - 1:
            DP[i + 1][j] += DP[i][j] * (n - i - 1)
        DP[i + 1][j % S[i]] += DP[i][j]

print(sum(i * d % p for i, d in enumerate(DP[n])) % p)

Measured memory_bytes: 192024
def get_primes(n: int) -> list:
    sieve=[1]*n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i] = [0] * ((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i]]

N=int(input())
L=get_primes(10000)
ans=[]
for i in range(len(L)):
    if L[i]%5==1:
        ans.append(L[i])
    if len(ans)==55:
        break

print(*ans[:N])

Measured memory_bytes: 38768