akhauriyash/Code-Regression huggingface dataset:
N = [int(input()) for i in range(5)]
Ni = [0]*5
smallmin = 11
for i in range(5):
    Ni[i] = N[i]%10
    if Ni[i] == 0:
        Ni[i] = 10
    if Ni[i]<smallmin:
        smallmin = Ni[i]
        LAST = i
ans = 0
for i in range(5):
  if i == LAST:
    ans += N[i]
  else:
    ans = ans + N[i] + (10-Ni[i])
print(ans)


Measured memory_bytes: 61644
/**
 * Header Files
 */
#include <bits/stdc++.h>

/**
 * Namespace declaration
 */
using namespace std;

int main(void){
    int H,N;
    scanf("%d %d", &H,&N);

    vector<int> v;
    vector<int> z;
    int x;
    for(int i=0;i<N;i++){
        scanf("%d",&x);
        v.push_back(x);
    }

    for(int z=0;z<N;z++){
        H = H - v[z];
    }

    if(H == 0 || H < 0){
        printf("%s","Yes");
    }else{
        printf("%s","No");
    }

	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
 
int32_t main(){
        ios_base::sync_with_stdio(false);cin.tie(0);
        int n;
        cin >> n;
        int res=0;
        for(int i=1;i<=n;i++){
                if(i%3!=0 && i%5!=0){
                        res+=i;
                }
        }
        cout << res << endl;
        return 0;
}

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

typedef long long LL;
const int MAXN = 100010;
std::queue<int> q;
int n, m, col[MAXN], vis[MAXN], fa[MAXN];
int cnt[MAXN][4], cant[MAXN], siz[MAXN];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], val[MAXN << 1], tot;
void addedge(int b, int e) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e; val[tot] = 1;
	nxt[++tot] = head[e]; to[head[e] = tot] = b; val[tot] = 2;
	fa[find(b)] = find(e);
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m;
	for (int i = 1; i <= n; ++i) fa[i] = i;
	for (int i = 1, t1, t2; i <= m; ++i)
		std::cin >> t1 >> t2, addedge(t1, t2);
	memset(col, -1, sizeof col);
	for (int i = 1; i <= n; ++i) if (fa[i] == i)
		col[i] = 0, q.push(i);
	for (int i = 1; i <= n; ++i) ++siz[find(i)];
	while (!q.empty()) {
		int t = q.front(); q.pop(); ++cnt[find(t)][col[t]];
		for (int i = head[t]; i; i = nxt[i]) {
			++cnt[find(t)][3];
			if (col[to[i]] == -1) {
				col[to[i]] = (col[t] + val[i]) % 3;
				q.push(to[i]);
			} else if (col[to[i]] != (col[t] + val[i]) % 3)
				cant[find(t)] = true;
		}
	}
	LL ans = 0;
	for (int i = 1; i <= n; ++i) if (fa[i] == i) {
		if (cant[i]) ans += (LL) siz[i] * siz[i];
		else if (!cnt[i][0] || !cnt[i][1] || !cnt[i][2])
			ans += cnt[i][3] >> 1;
		else {
			ans += (LL) cnt[i][0] * cnt[i][1];
			ans += (LL) cnt[i][1] * cnt[i][2];
			ans += (LL) cnt[i][2] * cnt[i][0];
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 8448
#include<iostream>
using namespace std;
int min (int a, int b) {
  if (a < b) return a;
  else return b;
}
int euclid(int a, int b) {
  int k = min(a, b);
  int j = a + b - k;
  while(k) {
    j = j % k;
    int t = j;
    j = k;
    k = t;
  }
  return j;
}
int main () {
  int N;
  cin >> N;
  int a[100003];
  for (int i = 0; i < N; i ++) cin >> a[i];
  //for (int i = 0; i < N; i ++) cout << a[i] << endl;
  int p = a[0];
  for (int i = 1; i < N; i ++) {
    p = euclid(p, a[i]);
    //cout << p << endl;
  }
  cout << p << endl;
}

Measured memory_bytes: 640
//#define TEST
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Diagnostics;
class p{
    static void Main(){
        int[] nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = nx[0], x = nx[1];
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        Array.Sort(a);
#if TEST
        foreach (var i in a) Console.Write("{0} ",i);
        Console.WriteLine();
#endif
        int ans = 0;
        int sum = 0;
        for (int i = 0;;i++){
            try{
                sum += (int)a[i];
                if (sum > x){
                    ans = i;
                    break;
                }
            }
            catch{
                ans = n;
                break;
            }
        }
        if (a.Sum() < x) ans = n - 1;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
import java.awt.Point;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main{

	static Scanner s=new Scanner(System.in);
	public static int maximumBipartiteMatching(int L,ArrayList<HashSet<Integer>> adj){
		boolean[] visited=new boolean[adj.size()];
		int[] match=new int[adj.size()];
		Arrays.fill(match,-1);

		int count=0;
		for(int curr=0;curr<L;curr++){
			Arrays.fill(visited,false);

			if(augment(adj,curr,match,visited)){
				count++;
			}
		}

		return count;
	}

	private static boolean augment(ArrayList<HashSet<Integer>> adj,int curr,int[] match,boolean[] visited){
		if(curr<0){
			return true;
		}

		for(final int next:adj.get(curr)){
			if(visited[next]){
				continue;
			}

			visited[next]=true;
			if(augment(adj,match[next],match,visited)){
				match[curr]=next;
				match[next]=curr;
				return true;
			}
		}

		return false;
	}

	public static void main(String[] args){

		int n=s.nextInt();
		final int size=n*2;
		ArrayList<HashSet<Integer>> adj=new ArrayList<>();
		for(int i=0;i<size;i++){
			adj.add(new HashSet<Integer>());
		}

		Point[]red=new Point[n];
		for(int i=0;i<n;++i)
			red[i]=new Point(s.nextInt(),s.nextInt());

		for(int i=0;i<n;i++){
			int x=s.nextInt(),y=s.nextInt();
			for(int j=0;j<n;++j) {
				if(red[j].x<x&&red[j].y<y) {
					adj.get(j).add(n+i);
				}
			}
		}
		System.out.println(maximumBipartiteMatching(n,adj));
	}
}

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

long long N, H;
vector<long long> a;
vector<long long> b;

int main(){
	cin >> N >> H;
	for(long long i = 0; i < N; i++){
		long long tmpa, tmpb;
		cin >> tmpa >> tmpb;
		a.push_back(tmpa);
		b.push_back(tmpb);
	}

	sort(a.begin(), a.end(), greater<long long>());
	sort(b.begin(), b.end(), greater<long long>());

	long long maxia = a[0];
	long long curb = 0;
	long long ans = INT_MAX;
	for(long long i = 0; i < b.size(); i++){
		long long tmp = i;
		if(H-curb <= 0){
			ans = min(ans, tmp);
		}else if((H-curb)%maxia == 0){
			ans = min(ans, tmp +(H-curb)/maxia);
		}else{
			ans = min(ans, tmp +(H-curb)/maxia + 1);
		}
		curb += b[i];
	}
	if(H-curb <= 0){
		ans = min(ans, (long long)b.size());
	} else if((H-curb)%maxia == 0){
		ans = min(ans, (long long)b.size() +(H-curb)/maxia);
	}else{
		ans = min(ans, (long long)b.size() +(H-curb)/maxia + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 2036
import java.util.*;
public class Main{
  public static long p = 1_000_000_007;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    if((2*y-x)%3!=0||(2*x-y)%3!=0||Math.max(x,y)>Math.min(x,y)*2){
      System.out.println(0);
      return;
    }
    int s = (2*y-x)/3;
    int t = (2*x-y)/3;
    long z = (long)s+t;
    long A = 1;
    long B = 1;
    for(int i=0;i<s;i++){
      A*=(z-i);
      A=A%p;
      B*=(s-i);
      B=B%p;
    }
    System.out.println(A*inv(B,p-2)%p);
  }
  public static long inv(long n, long k){
    if(k == 0){
      return 1;
    }
    if(k%2 == 0){
      long l = inv(n, k/2);
      return l * l % p;
    }else{
      return n * inv(n, k-1) % p;
    }
  }
}

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

int main(){
  char s[4];
  for (int i =0;i<4;i++) cin >> s[i];
  bool fmm=true,bmm=true;

  if ((s[0] - '0')*10+(s[1] - '0') > 12 ||(s[0] - '0')*10+(s[1] - '0') == 0) fmm = false;
  if ((s[2] - '0')*10+(s[3] - '0') > 12 ||(s[2] - '0')*10+(s[3] - '0') == 0) bmm = false;

  if (fmm && bmm){
    cout << "AMBIGUOUS" << endl;
  }else if (fmm && !bmm){
    cout << "MMYY" << endl;
  }else if (!fmm && bmm){
    cout << "YYMM" << endl;
  }else if (!fmm && !bmm){
    cout << "NA" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
    double x1, y1;
    double x2, y2;
    double x3, y3;
    double xp, yp;
    double r;
    int i;
    int n;

    scanf("%d", &n);
    
    for (i = 0; i < n; ++i){
        scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
        xp = ((2*(y2-y1))*(pow(x1,2)-pow(x3,2)+pow(y1,2)-pow(y3,2))-(2*(y3-y1))*(pow(x1,2)-pow(x2,2)+pow(y1,2)-pow(y2,2)))
            /((2*(x2-x1))*(2*(y3-y1))-(2*(x3-x1))*(2*(y2-y1)));
        
        yp = ((pow(x1,2)-pow(x2,2)+pow(y1,2)-pow(y2,2))*(2*(x3-x1))-(pow(x1,2)-pow(x3,2)+pow(y1,2)-pow(y3,2))*(2*(x2-x1))) 
            /((2*(x2-x1))*(2*(y3-y1))-(2*(x3-x1))*(2*(y2-y1)));
        r = sqrt((pow(xp-x1,2))+(pow(yp-y1,2)));
        printf("%.3lf %.3lf %.3lf\n", xp, yp, r);
    }

    return 0;
}

Measured memory_bytes: 656
def main():
    n, k = map(int, input().split())
    s = input()
    
    count = 0
    for i in range(n-1):
        if s[i] == s[i + 1]:
            count += 1

    print(min(count+2*k,n-1))  


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 値を取得
		int n = sc.nextInt();
		int[] p = new int[n];
		int ans = 0;

		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}

		for (int i = 0; i < n - 1; i++) {
			if (p[i] == i + 1) {
				int a = p[i + 1];
				p[i + 1] = p[i];
				p[i] = a;
				ans++;
			}
		}

		if (p[n - 1] == n) {
			int a = p[n - 1];
			p[n - 1] = p[n - 2];
			p[n - 2] = a;
			ans++;
		}

		System.out.println(ans);

		sc.close();
	}
}


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

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    ll N;
    cin >> N;
    int a = N%10;
    if(a==2 || a==4 || a==5 || a==7 || a==9) out("hon");
    else if(a==0 || a==1 || a==6 || a==8) out("pon");
    else out("bon");
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main()
{
    char c;cin>>c;
    c+=1;
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

map<Int, Int> cnt;
map<Int, Int> other;
Int ans;
Int n, s;
map<Int, Int> sqs;
vector<Int> primes;
bool isPrime[1080000];
void init(){
  fill(isPrime, isPrime + 1080000, true);
  isPrime[0] = isPrime[1] = false;
  for(Int i = 2;i*i < 1080000;i++){
    if(!isPrime[i])continue;
    for(Int j = i * i;j < 1080000;j += i)isPrime[j] = false;
  }
}

int main(){
  init();
  for(Int i = 2;i <= 2200;i++)if(isPrime[i])primes.push_back(i);
  for(Int i = 1;i*i <= 10000000000LL;i++)sqs[i*i] = i;
  cin >> n;
  for(Int i = 0;i < n;i++){
    cin >> s;
    Int op = 1, ed = 1;
    for(Int jj = 0;jj < primes.size() && s > 1;jj++){
      Int j = primes[jj];
      while(s % (j*j*j) == 0)s /= j*j*j;
      if(s % j != 0)continue;
      if(s % (j*j) != 0){
	op *= j;
	ed *= j*j;
      }
      else{
	op *= j*j;
	ed *= j;
      }
      while(s % j == 0)s /= j;
    }
    if(sqs.count(s)){
      op *= s;
      ed *= sqs[s];
      s = 1;
    }
    else if(s < 108000 && ed*s <= 10000000000LL && isPrime[s]){
      op *= s;
      ed *= s*s;
      s = 1;
    }
    if(s != 1){ans++;continue;}
    //    cout << op << endl;
    cnt[op]++;
    other[op] = ed;
  }
  for(auto p: cnt){
    Int val = p.first;
    Int c = p.second;
    if(val == 1){
      ans++;
      continue;
    }
    Int op = other[val];
    //    cout << val << " " << c << " " << cnt[op] << endl;
    ans += max(c, cnt[op]);
    cnt[val] = cnt[op] = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 28160
#include <iostream>

using namespace std;

int main(){
    int A,B;
    cin>>A>>B;
    int counter = 0;
    for(int n = A;n<=B;n++){
        int n1 = n%10;
        int n2 = (n%100)/10;
        int n4 = (n/1000)%10;
        int n5 = n/10000;
        if(n1==n5 and n2==n4){
            counter++;
        }
    }
    cout<<counter<<endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
const int mod=998244353;
int n,m,a[310][310];
int od[310],ev[310],bit[310],xxj[310];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j],a[i][j]&=1;
/*	if(n<m)
	{
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=m;j++)
				swap(a[i][j],a[j][i]);
		swap(n,m);
	}
*/
/*	for(int i=1;i<=n;i++,puts(""))
		for(int j=1;j<=m;j++)
			printf("%d ",a[i][j]);
*/

	int u=max(n,m);
	od[1]=1;ev[1]=3;
	for(int i=2;i<=u;i++)
	{
		od[i]=(ev[i-1]+3ll*od[i-1]%mod)%mod;
		ev[i]=(od[i-1]+3ll*ev[i-1]%mod)%mod;
	}
	int cnt=0;
/*	for(int i=1;i<=u;i++)
	{
		int p=i;
		for(int j=i+1;j<=u;j++)
			if(a[i][i]<a[j][i]) p=j;
		if(p!=i) swap(a[p],a[i]);
		if(!a[i][i]) continue;
		cnt++;
		for(int j=i+1;j<=u;j++)
			if(a[j][i])
				for(int k=i;k<=u;k++)
					a[j][k]^=a[i][k];
	}
*/
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			if(a[i][j])
			{
				if(xxj[j])
					for(int k=j;k<=m;k++)
						a[i][k]^=a[xxj[j]][k];
				else {xxj[j]=i;cnt++;break;}
			}
	}
	bit[0]=1;
	for(int i=1;i<=u;i++) bit[i]=2ll*bit[i-1]%mod;
	int bs=1ll*bit[n-cnt]*bit[m-cnt]%mod;
	printf("%lld\n",1ll*od[cnt]*bs%mod);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    for(int i = 1; i < 10; i++)
    {
        if(N <= i + 10*i + 100*i)
        {
            cout << i + 10*i + 100*i << endl;
            break;
        }
    }
}

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

using namespace std;

int M[1010], a[1010], n, m;
int dp[1010][1 << 16];

int call(int i, int mask)
{	
	if(mask == (1 << n) - 1)return 0;
	if(i == m)return 1e7;
	if(dp[i][mask] != -1)return dp[i][mask];

	return dp[i][mask] = min( call(i + 1, mask), a[i] + call(i + 1, mask | M[i]));
}

int main() {

	int x, y;

	cin >> n >> m;

	for(int i = 0; i < m; i++) {
		cin >> a[i] >> x;

		for(int j = 0; j < x; j++){
			cin >> y;
			M[i] |= (1 << (y - 1));
		}
	}
	memset(dp, -1, sizeof dp);
	int ans = call(0, 0);

	if(ans >= 1e7)cout << -1 << endl;
	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 258944
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
#define ll long long
#define trace(x) cerr << #x << " = " << x << endl
using namespace std;

int main()
{
   /* #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("ouput.txt","w",stdout);
    #endif*/ 

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while(t--){
            int k;
	    cin>>k;
	    int curr = 7%k, ans = 1;
	    if(k%2==0  or  k%5==0){
		    return cout<<-1<<endl,0;
	    }
	    else{
		  
                   while(curr!=0){
			   curr = curr*10 + 7;
			   curr%=k;
                           ans++;
		   }
	    }
	    cout<<ans<<endl;
      } 
    return 0;
} 


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

int main() {
  int N;
  cin >> N;
  int i = 0;
  int kekka = 1000000000;
  while(i < N){
    int A;
    cin >> A;
    int kaz = 0;
    while(A % 2 == 0){
      A = A / 2;
      kaz++;
    }
    if(kaz < kekka){
      kekka = kaz;
    }
      i++;
  }
    cout << kekka << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll x;
   cin>>x;
   
   ll ans = (360/__gcd(x,360ll));
   
   cout<<ans;
   
   return 0;        
}  
  
          
   

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

double p[3009], dp[3009][3009];

int main()
{
    int n, i, j;
    cin >> n;
    for(i = 1; i <= n; i++)
        cin >> p[i];

    dp[0][0] = 1;
    for(i = 1; i <= n; i++)
        dp[i][0] = dp[i-1][0] * (1 - p[i]);

    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= i; j++)
            dp[i][j] += dp[i-1][j-1]*p[i] + dp[i-1][j]*(1 - p[i]);
    }

//    for(i = 0; i <= n; i++)
//    {
//        for(j = 0; j <= n; j++)
//            cout << setw(5) << dp[i][j] << " ";
//        cout << endl;
//    }

    double ans = 0;
    for(i = n/2 + 1; i <= n; i++)
        ans += dp[n][i];

    cout << fixed << setprecision(9) << ans;
}


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

// modint: mod 計算を int を扱うように扱える構造体
// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#8-modint
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream &operator >> (istream &is, const Fp<MOD>& a) noexcept {
        long long t;
        is >> t;
        a = Fp<MOD>(t);
        return (is);
    }
    // 指数関数 O(logN)
    friend constexpr Fp<MOD> mpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = mpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
    
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

mint modpow(long long x, long long n){
    mint ret = x;
    return mpow(ret,n);
}

mint binomial(long long n, long long k){
    if(k < 0 || n < k) return 0;
    if (n-k < k) return binomial(n,n-k);
    mint ret = 1;
    for(long long i = 1; i <= k; ++i) {
        mint tmp = i;
        ret *= n--;
        ret /= tmp;
    }
    return ret;
}

int main(){
    // ABC156-D
    int n, a, b;  cin >> n >> a >> b;
    mint ans = modpow(2,n) - 1 - binomial(n,a) - binomial(n,b);
    cout << ans << endl;
    

    // cout << ans << endl;
}


Measured memory_bytes: 3604
# ABC120 C - String Transformation
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

S = si()
T = si()
 
dict_S = {}
dict_T = {}
 
for i in range(len(S)):
    if S[i] in dict_S:
        if dict_S[S[i]] != T[i]:
            print("No")
            exit()
    else:
        dict_S[S[i]] = T[i]
        
    if T[i] in dict_T:
        if dict_T[T[i]] != S[i]:
            print("No")
            exit()
    else:
        dict_T[T[i]] = S[i]
        
print("Yes")

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll z=1000000007,n;
int main()
{
	
	cin>>n;
	std::vector<ll> h(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	std::vector<ll> dp(n,0);
	dp[n-2]=fabs(h[n-1]-h[n-2]);
	for (int i = n-3; i >=0 ; --i)
	{
		dp[i]=min(dp[i+1]+fabs(h[i+1]-h[i]),dp[i+2]+fabs(h[i+2]-h[i]));

	}
	
	cout<<dp[0]<<"\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    for (auto &&i : v) scanf("%lld",&i);
    sort(v.begin(), v.end(), greater<>());
    int l = MOD, r = 0;
    while (std::abs(r-l) > 1){
        int mid = (l+r)/2;
        ll p = 0;
        for (auto &&i : v) {
            if(i > mid*b) p += (i-mid*b+a-b-1)/(a-b);
        }
        if(p <= mid){
            l = mid;
        }else {
            r = mid;
        }
    }
    cout << l << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	string str;
	cin >> str;
	if(n%2 != 0)
	  cout << "No";
	else
	{
		string str1 = str.substr(0,n/2);
		string str2 = str.substr(n/2,n/2);
		if(str1 == str2)
		   cout << "Yes";
		else
		   cout << "No";
	}
	return 0;
}


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

#define int long long
#define MOD 1000000007

int n;
int memo[100010][20];
string s;

int dp(int i, int num){
    if(i == n){
        if(num == 5){
            return 1;
        }else{
            return 0;
        }
    }

    if(memo[i][num] != -1){
        return memo[i][num];
    }

    int ans = 0;

    if(s[i] != '?'){
        ans += dp(i+1, (num*10+(s[i]-'0'))%13);
        ans %= MOD;
    }else{
        for(int j = 0;j < 10;j++){
            ans += dp(i+1, (num*10+j)%13);
            ans %= MOD;
        }
    }

    return memo[i][num] = ans;
}

signed main(){
    cin >> s;
    n = s.size();
    memset(memo, -1, sizeof(memo));
    cout << dp(0, 0) << endl;
    return 0;
}



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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>>  var(n, vector<int>(m, 0))
#define vecb2(var, n, m)   vector<vector<bool>> var(n, vector<bool>(m, false))
#define vecll2(var, n, m)  vector<vector<ll>>   var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  vec ans;

  while(1){
    int n;
    cin >> n;
    if(n==0){break;}
    arr(w,n);

    vec2(dp, n, n);

    rep(i,n-1){
      dp[i][i+1] = (abs(w[i]-w[i+1])<2 ? 2 : 0);
    }

    REP(num, 3, n+1){
      rep(i,n+1-num){
        int j = i+num-1;
        if(dp[i+1][j-1] == (j-1)-(i+1)+1 && abs(w[i]-w[j])<2){
          dp[i][j] = dp[i+1][j-1] + 2;
        } else {
          REP(k,i,j){
            chmax(dp[i][j], dp[i][k]+dp[k+1][j]);
          }
        }
      }
    }

    ans.pb(dp[0][n-1]);
  }

  rep(i,ans.size()){
    prt(ans[i]);
  }
}



Measured memory_bytes: 3280
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        ok, ng = j, n
        while ng - ok > 1:
            mid = (ok + ng) // 2
            if l[mid] < l[i] + l[j]:
                ok = mid
            else:
                ng = mid
        ans += ok - j
print(ans)

Measured memory_bytes: 41580
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
 
  int main(){      
  lint x;
  cin>>x;
    rep(i,3000){
        rep(j,3000){
            lint g=i*i*i*i*i;
            lint h=j*j*j*j*j;
            if(g-h==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
            if(g+h==x){
                cout<<i<<" "<<-j<<endl;
                return 0;
            }
        }
    }
    }

  
          
  

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n,m;
    cin >> n >> m;
    int ln = 0,rn = n-1;
    rep(i,m) {
        int l,r;
        cin >> l >> r;
        l--; r--;
        chmax(ln,l);
        chmin(rn,r);
    }
    cout << max(0,rn-ln+1) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class Main {

    private long MOD = (long) (1e9 + 7);

    private void solve() throws IOException {
        int n = nextInt();
        long[] a = new long[2];
        a[0] = nextLong();
        a[1] = nextLong();
        long[] x = new long[n];
        for (int i = 0; i < n; i++) {
            x[i] = nextLong();
        }
        int[][] d = new int[2][n];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < n; j++) {
                if (j > 0 && x[j] >= x[j - 1] + a[i]) {
                    d[i][j] = d[i][j - 1] + 1;
                }
            }
        }
        long[][] e = new long[2][n];
        int[] l = new int[2];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2; j++) {
                while (x[l[j]] <= x[i] - a[j]) l[j]++;
                if (l[j] == i) {
                    if (l[j] == 0) {
                        e[j][i]++;
                    } else {
                        e[j][i] += e[0][i - 1] + e[1][i - 1];
                    }
                } else {
                    if (d[1 - j][i - 1] >= i - l[j] - 1) {
                        e[j][i] += e[1 - j][l[j]];
                    }
                }
                e[j][i] %= MOD;
//                System.out.println(i + " " + j + " " + e[j][i]);
            }
        }
        out.println((e[0][n - 1] + e[1][n - 1]) % MOD);
    }

    // ------------------

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    private void run() throws IOException {
        solve();
        out.close();
    }

}


Measured memory_bytes: 29036
#include <bits/stdc++.h>
#include <string.h>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
//#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define INF (int)1e15
#define MOD 1000000007
//#define N 12
#define sz 1000*1000



int main(){

 int n,k,s;
 cin>>n>>k>>s;
   ll inf = 1e10;
    vector <long long> ans(n, inf);

    for(int i=0;i<k;i++){
      ans[i] = s; }

    for(int i=0;i<n;i++){
      if(ans[i] == inf){
              if (s == 1e9) ans[i] = 1;
            else ans[i] = 1e9;
      }
    }

    for(int i=0;i<n;i++)
      cout<<ans[i]<<" ";

    cout<<endl;
    return 0;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int> >
#define VPII vector<pair<int,int> >

#define INT ll

using namespace std;
/*........................................Define functions.........................................*/


/*....................................Define global variables .....................................*/



/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);


	ll A,B,K;
	cin>>A>>B>>K;
	if(A>=K)A-=K;
	else{
		ll aoki=K-A;
		A=0;
		if(B>=aoki)B-=aoki;
		else B=0;
	}

	cout<<A<<" "<<B<<endl;
	









		

		return 0;
}




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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
  gearup;
  ll n,m; cin >> n >> m;
  vl cost(m),type(m),bit(m);
  rep(i,m){
    cin >> cost[i] >> type[i];
    ll sum = 0;
    rep(j,type[i]){
      ll c; cin >> c;c--;
      sum |= (1<<c);
    }
    bit[i] = sum;
  }

  //dp[i][bit] iの鍵までの最大の部分bit
  vvl dp(m+1,vl(1<<n,L_INF));
  dp[0][0] = 0;
  rep(i,m){
    for(int j=0;j<(1<<n);j++){
      chmin(dp[i+1][j],dp[i][j]); //iの鍵を使わない
      chmin(dp[i+1][j|bit[i]],dp[i][j] + cost[i]);
    }
  }
  ll res = dp[m][(1<<n)-1];
  cout << ((res==L_INF)?-1:res) << endl;
}


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

ll mod = 1000000007;

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

ll nCr(int n, int r, int mod) {
  ll res = 1;
  for(int i = 1; i <= r; i++) {
    res = res * (n-i+1) % mod * pow(i, mod-2, mod) % mod;
  }
  return res;
}

int main() {
  ll n;
  int a, b;
  cin >> n >> a >> b;
  
  ll nn = pow(2, n, mod) - 1 - nCr(n, a, mod) - nCr(n, b, mod);

  nn += mod;
  nn %= mod;
  nn += mod;
  nn %= mod;

  cout << nn << endl;

  return 0;
}



Measured memory_bytes: 256
import sys
from functools import reduce

def gcd(a, b): return gcd(b, a % b) if b else abs(a)
def lcm(a, b): return abs(a // gcd(a, b) * b)

n, *a = map(int, sys.stdin.read().split())

def main():
    print(reduce(gcd, a))

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 14548
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[12];
int ABS(int a){return max(a,-a);}
int main(){
	while(~scanf("%s",str)){
		bool ok=true;
		for(int i=1;str[i];i++){
			int r=(str[i]-'A')/3;
			int c=(str[i]-'A')%3;
			int lr=(str[i-1]-'A')/3;
			int lc=(str[i-1]-'A')%3;
			if(ABS(r-lr)+ABS(c-lc)!=1)ok=false;
		}
		if(ok)printf("%s\n",str);
	}
}

Measured memory_bytes: 952
// AtCoder ABC054 D - Mixing Experiment
// 2020.1.24 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

typedef struct { int ab, a, b, c; } T;
T tbl[45]; int N;

void Qsort(T *a, int l, int r) {
	int i, j; int m; T t;
	
	i = l, j = r, m = a[(l+r) >> 1].ab;
	while (1) {
		while (a[i].ab > m) i++;
		while (m > a[j].ab) j--;
		if (i >= j)	break;
		t = a[i], a[i] = a[j], a[j] = t;
		i++, j--;
	}
	if (l+1 < i) Qsort(a, l, i-1);
	if (j+1 < r) Qsort(a, j+1, r);
}

#define SFT 9
#define MSK 511
int dp[230000];

int main()
{
	int i, j, a, b, Ma, Mb;
	int ma, ans;
	
	N = in(), Ma = in(), Mb = in();
	for (i = 0; i < N; ++i) {
		a = in(), b = in();
		tbl[i].ab = (a << SFT) | b;
		tbl[i].a = a, tbl[i].b = b, tbl[i].c = in();
	}
//	Qsort(tbl, 0, N-1);
	
	ans = -1, ma = 0;
	memset(dp, -1, sizeof(dp));
	dp[0] = 0;
	for (i = 0; i < N; ++i) {
		for (j = ma; j >= 0; --j) if (dp[j] >= 0) {
			int x = dp[j] + tbl[i].c;
			a = (j >> SFT) + tbl[i].a, b = (j & MSK) + tbl[i].b;
			if (a*Mb == b*Ma) {
				if (ans < 0 || ans > x) ans = x;
			}
			int k = (a << SFT) | b;
			if (k > ma) ma = k;
			if (dp[k] < 0 || dp[k] > x) dp[k] = x;
		}
	}
	if (ans >= 0) printf("%d\n", ans);
	else puts("-1");
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>

struct Point{
    double x;
    double y;
};

Point s_func(Point p,Point q){
    Point s = {(2*p.x+q.x)/3,(2*p.y+q.y)/3};
    return s;
}

Point t_func(Point p,Point q){
    Point s = {(p.x+2*q.x)/3,(p.y+2*q.y)/3};
    return s;
}

Point u_func(Point s,Point t){
    double r=M_PI/3;
    Point u;
    u.x = (t.x-s.x)*cos(r)-(t.y-s.y)*sin(r)+s.x;
    u.y = (t.x-s.x)*sin(r)+(t.y-s.y)*cos(r)+s.y;
    
    return u;
}

void kock(int n,Point p1,Point p2){
    if(n==0){
        std::cout << p2.x << ' ' << p2.y <<'\n';
        return;
    }
    
    Point s,t,u;
    s = s_func(p1,p2);
    t = t_func(p1,p2);
    u = u_func(s,t);
    
    kock(n-1,p1,s);
    kock(n-1,s,u);
    kock(n-1,u,t);
    kock(n-1,t,p2);
}
    
    
int main(){
    Point p1 = {0,0},p2 = {100,0};
    int n;
    std::cin >> n;
    std::cout << p1.x << ' ' << p1.y << '\n';
    kock(n,p1,p2);
    return 0;
}



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

void insertionSort(int n,int A[],int g);
void shellSort(int A[],int n);
void print(int A[],int n,vector<int> G,int m);

int count;
vector<int> G;

int main(){
	int n; cin>>n;
	int *A; A = new int[n];
	for(int i=0;i<n;i++) cin>>A[i];

	shellSort(A,n);

	delete [] A;
	cin.sync(); cin.get();
}

void insertionSort(int n,int A[],int g){
	for(int i=g;i<n;i++){
		int v = A[i];
		int j = i-g;
		while(j>=0 && A[j]>v){
			A[j+g] = A[j];
			j -= g;
			count++;
		}
		A[j+g] = v;
	}
}

void shellSort(int A[],int n){
	int m = 0;
	while(true){
		if(m==0)
			G.push_back(1);
		else
			G.push_back(3*G[m-1]+1);
		if(G[m]>n) break;
		m++;
	}

	for(int i=m-1;i>=0;i--)
		insertionSort(n,A,G[i]);

	print(A,n,G,m);
}

void print(int A[],int n,vector<int> G,int m){
	cout<<m<<endl;
	for(int i=m-1;i>=0;i--){
		cout<<G[i];
		if(i)
			cout<<" ";
		else
			cout<<endl;
	}
	cout<<count<<endl;
	for(int i=0;i<n;i++)
		cout<<A[i]<<endl;
}

Measured memory_bytes: 6716
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()
    println(if (good(n)) "Yes" else "No")

}

fun good(n: Int): Boolean {
    var x = n
    var prev = -1
    var count = 0
    while (x > 0) {
        val d = x % 10
        if (prev != d) {
            count = 1
            prev = d
        }
        else {
            count += 1
        }
        if (count >= 3) return true
        x /= 10

    }
    return false
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

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

int main(){
  int n;
  cin >> n;
  for (int i=1; i<=n; i++){
    if (i%3 == 0){
      cout << " " << i;
    }
    else{
      int x = i;
      while (true){
	if (x%10 == 3){
	  cout << " " << i;
	  break;
	}
	x /= 10;
	if (x == 0) break;
      }
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3080
using System;

public class hello
{
	public static void Main()
	{
		var n = int.Parse(Console.ReadLine().Trim());
		var h = new int[n];
		for (int i = 0; i < n; i++) h[i] = int.Parse(Console.ReadLine().Trim());
		Array.Sort(h);
		Array.Reverse(h);
		var ans = getAns(h, n);
		Console.WriteLine(ans);
	}
	static long getAns(int[] h, int n)
	{
		var d = 0;
		var p = 0;
		var count = 1L;
		while (true)
		{
			for (int i = 0; i < 4; i++)
			{
				if (h[p] - d > 0) count += h[p] - d;
				else return count;
				p++;
				if (p == n) return count;
			}
			d++;
		}
	}
}



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

using namespace std;


int main(){
 
  string s;
  cin>>s;
  if(s.length() %2==1)
  {
    cout<<"No";
    return 0;
  }
  for(int i =0 ;i < s.length();i+=2){
    
    if(s[i]=='h' && s[i+1]=='i'){
      continue;
    }
    
    cout<<"No\n";
    return 0;
    
  }
  
cout<<"Yes";
  return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		scan.close();

		if(!S.startsWith("A")) {
			System.out.println("WA");
			return;
		}
		if(S.substring(2, S.length()-1).indexOf("C")<0) {
			System.out.println("WA");
			return;
		}
		String s = S.toLowerCase();
		int w = 0;
		for(int i=0; i<s.length(); i++) {
			if(S.charAt(i) != s.charAt(i)) {
				w++;
			}
		}
		if(w==2) {
			System.out.println("AC");
		} else {
			System.out.println("WA");
		}
	}

}


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

int main(void){
  int r,g,b;
  cin >> r >> g >> b;
  int number = r*100 + g*10 + b;
  if(number%4 == 0){
    cout << "YES" << '\n';
  }
  else{
    cout << "NO" << '\n';
  }
}


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

const int N=310000;
int n,m,tr[N],Ans[N];
struct suv 
{
	int l,r;
	bool operator < (const suv& tp) const
	{
		return r-l<tp.r-tp.l;
	}
}p[N];

void Add(int x,int s)
{
	while(x<=m+1) tr[x]+=s, x+=(x&(-x));
}

int Query(int x)
{
	int ret=0;
	while(x) ret+=tr[x], x-=(x&(-x));
	return ret;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d%d",&p[i].l,&p[i].r), ++p[i].l, ++p[i].r;
	sort(p+1,p+n+1);
	for(int i=1;i<=n;++i) Add(p[i].l,1), Add(p[i].r+1,-1);
	for(int d=m,cur=n;d>=1;--d)
	{
		while(p[cur].r-p[cur].l+1>=d && cur) Add(p[cur].l,-1), Add(p[cur--].r+1,1);
		Ans[d]=n-cur;// cout<<Ans[d]<<endl;
		for(int i=0;i*d<=m;++i)
			Ans[d] += Query(i*d+1);
	}
	for(int i=1;i<=m;++i) printf("%d\n",Ans[i]);
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n=0;
    if(s.at(0) == '+') n++;
    else n--;
    if(s.at(1) == '+') n++;
    else n--;
    if(s.at(2) == '+') n++;
    else n--;
    if(s.at(3) == '+') n++;
    else n--;

    cout << n << endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 1000

using namespace std;

int m, n, b[501], r[501];
int match[SIZE];
bool used[SIZE];
vector<int> G[SIZE];

bool dfs(int v){
	used[v]=1;
	for(int i=0; i<G[v].size(); i++){
		int u = G[v][i], w = match[u];
		if(w<0 || !used[w] && dfs(w)){
			match[v] = u, match[u] = v;
			return 1;
		}
	}
	return 0;
}


int main(){
	while(1){
		cin >> n >> m;
		if(!n && !m) break;
		for(int i=0; i<n; i++){
			cin >> b[i];
		}
		for(int i=0; i<m; i++){
			cin >> r[i];
		}
		for(int i=0; i<SIZE; i++) {
			G[i].clear();
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				int a = b[i], c = r[j];
				while(c){
					a %= c;
					swap(a, c);
				}
				if(a != 1){
					G[i].push_back(j+n);
					G[n+j].push_back(i);
				}
			}
		}

		int res=0;
		fill(match, match+SIZE, -1);
		for(int v=0; v<m+n; v++){
			if(match[v]<0){
				fill(used, used+SIZE, 0);
				if(dfs(v)) res++;
			}
		}
		cout<<res<<endl;
	}
}


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

using namespace std;

#define int long long

const int N = (int)3e5, MOD = (int)1e9 + 7, INF = (int)3e18;

main() {
    ios :: sync_with_stdio(0);
    cin.tie(0);
    int k;
    cin >> k;
    int ans = 0;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int l = 1; l <= k; ++l) {
                int gcd = __gcd(i, j);
                gcd = __gcd(gcd, l);
                ans += gcd;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3656
def CanKenKen(List,Start,Goal):
    Q=List[Start:Goal+1]
    return all([i=="." or Q[n+1]=="." or n==Goal-Start for n,i in enumerate(Q[:-1])])
N,A,B,C,D=map(int,input().split())
A,B,C,D=map(lambda x:x-1 ,[A,B,C,D])#0-indexed
S=input()

if A<C<B<D:
    if CanKenKen(S,A,C) and CanKenKen(S,B,D+1):
        print("Yes")
    else:print("No")
elif A<B<D<C:
    if CanKenKen(S,A,C):
        if B>=2:Q=S[B-1:D+2]
        else:Q=S[:D+2]
        if "..." in Q:print("Yes")
        else:print("No")
    else:print("No")
elif A<B<C<D:
    if CanKenKen(S,A,D):print("Yes")
    else:print("No")


Measured memory_bytes: 5300
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) throws IOException {
        MyReader reader = new MyReader();
        int[] ab = reader.readInts(" ");
        int a = ab[0];
        int b = ab[1];
        String s = reader.readString();
        System.out.println(problem084b(a, b, s));
    }

    private static String problem084b(int a, int b, String s) {
        String regex = "[0-9]{" + a + "}-[0-9]{" + b + "}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(s);
        return (matcher.matches()) ? "Yes" : "No";
    }

    private static class MyReader {
        private final BufferedReader br;
        private MyReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String readString() throws IOException {
            return br.readLine();
        }

        private int readInt() throws IOException {
            return Integer.parseInt(readString());
        }

        private String[] readStrings(String regex) throws IOException {
            return readString().split(regex);
        }

        private int[] readInts(String regex) throws IOException {
            String[] strings = readStrings(regex);
            int[] ints = new int[strings.length];
            for (int i = 0; i < ints.length; i++) {
                ints[i] = Integer.parseInt(strings[i]);
            }
            return ints;
        }
    }
}

Measured memory_bytes: 25492
# coding: utf-8
import re
import math
import fractions
import numpy as np

def C(n,a):
    if(n==0):return 0
    else:
        return n//a+C(n//a,a)

#main
n=int(input())
if(n%2==1):
    print(0)
else:
    print(C(n//2,5))


Measured memory_bytes: 13564