akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);    cout.tie(NULL);
#define forf(i,n) for(int i=0;i<n;i++)
#define foro(i,n) for(int i=1;i<=n;i++)
using namespace std;


int main(){
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(n/x)*t+(n%x==0?0:1)*t;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
#define fo freopen("in.txt","r",stdin)
#define fc fclose(stdin)
#define fu0(i,n) for(i=0;i<n;i++)
#define fu1(i,n) for(i=1;i<=n;i++)
#define fd0(i,n) for(i=n-1;i>=0;i--)
#define fd1(i,n) for(i=n;i>0;i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d %d",&n,&m)
#define ss(s) scanf("%s",s)
#define sddd(n,m,k) scanf("%d %d %d",&n,&m,&k)
#define pans() printf("%d\n",ans)
#define all(a) a.begin(),a.end()
#define sc(c) scanf("%c",&c)
#define we(a) while(scanf("%d",&a)!=EOF)
const int maxn=200005;
const double eps=1e-8;
const int p=1e9+7;
int main()
{
    int n;
    while(cin>>n)
    {
        ll s=1;
        for(int i=1;i<=n;i++)
        {
            s=s%p*i%p;
        }
        cout<<s%p<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>
using namespace std;
int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int m1 = 0, m2 = 0, m3 = 0;
    for (int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        if (p <= a)
            m1++;
        else if (a < p && p <= b)
            m2++;
        else if (b < p)
            m3++;
    }
    cout << min(m1, min(m2, m3)) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		final Scanner s=new Scanner(System.in);
		int h=s.nextInt();
		int w=s.nextInt();
		int[][] a=new int[h+1][w+1];
		char[][] c=new char[h+1][w+1];

		Arrays.fill(a[0], 99999);
		for(int i=2;i<=h;++i)
			a[i][0]=99999;
		c[1][0]='.';

		for(int i=1;i<=h;++i){
			String t=s.next();
			for(int j=1;j<=w;++j){
				c[i][j]=t.charAt(j-1);

				int u=(c[i][j]!=c[i-1][j]?1:0)+a[i-1][j];
				int l=(c[i][j]!=c[i][j-1]?1:0)+a[i][j-1];
				a[i][j]=Math.min(u,l);
			}
		}
		System.out.println((a[h][w]+1)/2);
	}
}


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

const int N = 110000;

vector<int> con[N];
int vis[N];

bool dfs(int u, int col) {
	vis[u] = col;
	for (int v : con[u]) {
		if (vis[v] && 3 - col != vis[v]) return false;
		if (!vis[v] && !dfs(v, 3 - col)) return false;
	}
	return true;
}

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		con[u].push_back(v), con[v].push_back(u);
	}
	
	if (!dfs(1, 1)) cout << (long long)n * (n - 1) / 2 - m << "\n";
	else {
		int cnt = 0;
		for (int i = 1; i <= n; i++) cnt += vis[i] == 1;
		cout << (long long)cnt * (n - cnt) - m << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 10128
/* ***********************************************
Author        :caowushang
Created Time  :2016/8/3 19:18:25
TASK		  :新建.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdlib>
#define inf 99999999
#define cl(x,v) memset(x,v,sizeof(x))
#define PI 3.14159265358979323
#define LL long long int
using namespace std;
const int MX=1e5+10;
const int mod=1e9+7;
struct pp
{
	int x,o;
	bool operator <(const pp & t)const
	{
		return x<t.x;
	}
} a[MX];
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n;
	while(cin >> n)
	{
		for(int i=0;i<n;i++)
		{
			scanf("%d",&a[i].x);
			a[i].o=i;
		}
		sort(a,a+n);
		int ans=0;
		for(int i=0;i<n;i++)
		{
			if((a[i].o^i)&1)
				ans++;
		}
		cout << ans/2 << endl;
	}
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node {int parent, left, right;};
//Nodeは各節点の番号を記録するための構造体

Node T[MAX];
int n, D[MAX], H[MAX];
//Dは各節点の深さを記録する配列 D[T[i]]で深さが求められる
//Hは各節点の高さを記録する配列 H[T[i]]で高さが求められる

//各節点の深さを再帰的に設定
void setDepth(int u, int d) {
  if (u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

//各節点の高さを再帰的に設定
int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if (T[u].left != NIL) {
    h1 = setHeight(T[u].left) + 1;
  }
  if (T[u].right != NIL) {
    h2 = setHeight(T[u].right) + 1;
  }

  H[u] = max(h1, h2);
  return H[u];
}

//u番目の節点の兄弟を得る
//自分の親の左の子が自分の場合　-> 自分の親の右の子がsibling
//自分の親の右の子が自分の場合　-> 自分の親の左の子がsibling
int getSibling(int u) {
  if ( T[u].parent == NIL) return NIL;
  if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL) {
    return T[T[u].parent].left;
  }
  if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL)  {
    return T[T[u].parent].right;
  }
  return NIL;
}

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));

  int deg = 0;
  if (T[u].left != NIL) deg++;
  if (T[u].right != NIL) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].parent == NIL ) {
    printf("root\n");
  }
  else if (T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  }
  else {
    printf("internal node\n");
  }
}

int main() {
  int v, l, r, root = 0;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) T[i].parent = NIL;

  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l; T[v].right = r;

    if (l != NIL) T[l].parent = v;
    if (r != NIL) T[r].parent = v;
  }

  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) root = i;
  }

  setDepth(root, 0); //rootがdepth = 0なのでそこから始める
  setHeight(root);

  for (int i = 0; i < n; i++) print(i);

  return 0;
}



Measured memory_bytes: 3200
[x,n]=[int(i) for i in input().split()]

if n!=0:
    p_list=[int(i) for i in input().split()]
    
    if x not in p_list:
        print(x)
        
    else:
        i=1
        while True:
            if (x-i) not in p_list:
                print(x-i)
                break
            elif (x+i) not in p_list:
                print(x+i)
                break
            else:
                i+=1
                


else:
    print(x)
    

Measured memory_bytes: 9192
class stack{
    constructor(){
        this.S = [null];
        this.top = 0;
    }
    push(x){
        this.top++;
        this.S[this.top]=x;
    }
    pop(){
        if(this.isEmpty()){
            return false;
        }
        let ret = this.S[this.top];
        this.top--;
        return ret;
    }
    isEmpty(){
        return this.top===0;
    }
}


let main = function(input){
    input = input.trim();
    let args = input.split(" ");
    let calc = new stack();
    
    while(args.length>0){
        let arg = args.shift();
        if(arg==="-" || arg ==="+" || arg==="*"){
            if(arg==="-"){
                let b = calc.pop();
                let a = calc.pop();
                calc.push(a-b);
            }else if(arg==="+"){
                let a = calc.pop();
                let b = calc.pop();
                calc.push(a+b);
            }else if(arg==="*"){
                let a = calc.pop();
                let b = calc.pop();
                calc.push(a*b);
            }
        }else{
            calc.push(parseInt(arg));
        }
    }
    console.log(calc.S[1]);
    
}

main(require("fs").readFileSync("/dev/stdin","utf-8"));



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

int main() {
    string s;
    cin >> s;
    int a=0;

    for(int i=0;i<s.size();i++){
        for(int j=0;j<s.size();j++){
            if(i != j && s.at(i) == s.at(j)){
                cout << "no" << endl;
                i = s.size()-1;
                j = s.size()-1;
            }
            else a++;
        }
    }

    if(a == s.size()*s.size()) cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------
using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<P>> xy(n);
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for(int j = 0; j < a; j++) {
            int x, y;
            cin >> x >> y;
            x--;
            xy[i].emplace_back(P(x, y));
        }
    }
    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++) {
        // 0:嘘つき 1:正直者
        vector<int> check(n);
        for(int i = 0; i < n; i++) {
            if(bit & (1 << i)) {
                check[i] = 1;
            } else {
                check[i] = 0;
            }
        }
        // 真偽チェックする
        bool ok = true;
        for(int i = 0; i < n; i++) {
            if(check[i]) {
                for(auto p : xy[i]) {
                    int x = p.first;
                    int y = p.second;
                    if(y == 1 && check[x] == 0) {
                        ok = false;
                    }
                    if(y == 0 && check[x] == 1) {
                        ok = false;
                    }
                }
            }
        }
        if(ok) {
            chmax(ans, (int)(count(ALL(check), 1)));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <bitset>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1000000007;
const long long INF = 1LL << 55;
const double EPS = 1e-10;

int main()
{
    int M;
    cin >> M;
    cout << 48 - M << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define MOD 1e9
#define MAX LONG_MAX
#define MIN LONG_MIN
#define pb push_back

using namespace std;

vector<int> arr(10000002,0);

void sieve(){
	for(int i=2;i<10000002;i++){
		//if(arr[i]==0){
			for(int j=i*2;j<10000002;j+=i){
				arr[j]++;
			//}
		}
	}
}

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	sieve();

	int n;
	cin>>n;

	int sum=1;

	for(int i=2;i<=n;i++){
		if(arr[i]==-1)
			sum+=i*2;
		else
			sum+=i*(arr[i]+2);
	}

	cout<<sum;

	return 0;
}

Measured memory_bytes: 81212
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(N);
	READV(M);
	vector<pll> W;
	FORI(i,0,N)
	{
		READV(A);
		READV(B);
		W.pb({A,B});
	}
	sort(W.begin(),W.end());
	ll s=0,ans=0;
	multiset<ll,greater<ll>> S;
	FORI(i,0,M+1)
	{
		while(s<N && W[s].fi<=i)
		{
			S.insert(W[s].se);
			s++;
		}
		if(sz(S)>0)
		{
			ans+=*(S.begin());
			S.erase(S.begin());
		}
	}
	cout<<ans<<endl;

	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < 3; i++) if (s[i] == t[i]) ans++;
  cout << ans << endl;
  return 0;
}


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

int main(void){
    ll x;
    cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T>
void read(T &x)
{
	char ch=getchar();
	for (x=0;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
}
int n;
pair<int,int> x[200010];
multiset<int> b,r;
ll ans;
int main()
{
	read(n);
	for (int i=1;i<=n;i++)
	{
		read(x[i].first),read(x[i].second);
		if (x[i].first>x[i].second) swap(x[i].first,x[i].second);
		b.insert(x[i].first),r.insert(x[i].second);
	}
	ans=1LL*(*b.rbegin()-*b.begin())*(*r.rbegin()-*r.begin());
	
	sort(x+1,x+n+1);
	for (int i=1;i<=n;i++)
	{
		b.erase(b.find(x[i].first)),r.insert(x[i].first);
		r.erase(r.find(x[i].second)),b.insert(x[i].second);
		ans=min(ans,1LL*(*b.rbegin()-*b.begin())*(*r.rbegin()-*r.begin()));
	}
	printf("%lld",ans);
	return 0;
}

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

int main(void)
{
    int N;
    int t[110000],x[110000],y[110000];
    t[0]=0;
    x[0]=0;
    y[0]=0;

    cin >> N;
    
    for (int i=0; i < N; i++){
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }

    int dt,dist;
    bool can = true;
    for (int i=0; i < N; i++){
        dt = t[i+1] - t[i];
        dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);

        if(dt < dist){
            can = false;
            break;
        }

        if(!(dt%2 == dist%2)){
            can = false;
            break;
        }


    }

    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
int a[1005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int flag=false;
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==0)
		{
			if(a[i]%3==0||a[i]%5==0)
				continue;
			else
				flag=true;
		}
	}
	if(!flag)
		cout<<"APPROVED";
	else
		cout<<"DENIED";

	return 0;
}

Measured memory_bytes: 256
import Foundation

class Scanner {
    static func readInt() -> Int {
        return Int(readLine()!)!
    }
    
    static func readIntArr() -> [Int] {
        return readLine()!.split(separator: " ").map { Int($0)! }
    }
    
    static func readM(_ n: Int) -> [[Int]] {
        var res = [[Int]]()
        for _ in 0..<n {
            res.append(readIntArr())
        }
        return res
    }
    
    static func readUknownIntMat() -> [[Int]] {
        var res = [[Int]]()
        while let line = readLine() {
            res.append(line.split(separator: " ").map { Int($0)! })
        }
        return res
    }
    
    static func readString() -> String {
        return readLine()!
    }
}

class Printer {
    static func printIntArray(_ arr: [Int]) {
        print(arr.map { String($0) }.joined(separator: " "))
    }
}

let n = Scanner.readInt()
let s = Scanner.readString()

class Solution {
    func echo(_ s: String) -> Bool {
        let s = Array(s)
        guard s.count%2 == 0 else {
            return false
        }
        for i in stride(from: 0, to: s.count/2, by: 1) {
            guard s[i] == s[s.count/2 + i] else {
                return false
            }
        }
        return true
    }
}

print((Solution().echo(s) ? "Yes" : "No"))


Measured memory_bytes: 13084
n,k,*a=map(int,open(0).read().split())
s=sum(a)
b=[]
for i in range(1,int(s**.5)+1):b+=[s//i,i]*(s%i<1)
m=1
for i in b:c=sorted(j%i for j in a);m=max(m,i*(sum(c[:-sum(c)//i])<=k))
print(m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 1e5 + 5;


int32_t main()
{
   IOS;
   int x,y;
   cin >> x >> y;
   

   for(int i=0; i<=x; i++)
   {
       int t= x-i;

       if(2*i + 4*t==y)
       {
         cout << "Yes" << endl;
         return 0;
      }
   }

   cout << "No" << endl;


   return 0;
}
 

Measured memory_bytes: 3696
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            long[] Arr = cin.ReadLongArray(3);
            var P = new long[Arr[0]];
            for(long i = 0; i < Arr[2]; i++)
            {
                P[(cin.ReadLong) - 1]++;
            }
            for(long i = 0; i < Arr[0]; i++)
            {
                if (P[i] > Arr[2] - Arr[1])
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }

        }
            

                
    }  
            


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}


Measured memory_bytes: 16336
import heapq as hq
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ab = []
for a in A:
    for b in B:
        hq.heappush(ab, -a-b)
abc = []
cnt = 0
while cnt < k and ab:
    cnt += 1
    a = hq.heappop(ab)
    for b in C:
        hq.heappush(abc, a-b)
cnt = 0
while cnt < k:
    print(-hq.heappop(abc))
    cnt += 1

Measured memory_bytes: 230824
#include <bits/stdc++.h>
 
using namespace std; 
 
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()
#define INF 1e9
 
typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	
 
 
int main(){
	
	int n;
	
	string s;
	
	cin >> n >> s; 
	
	vi left(n); 
	vi right(n);
	
	left[0] = 0;
	
	f(i,1,n){
		if(s[i-1]=='E'){
			left[i] = left[i-1] + 1;
		}else{
			left[i] = left[i-1];
		}
	}
	right[n-1] = 0;
	fr(i,n-2,0){
		if(s[i+1]=='W'){
			right[i] = right[i+1] + 1;
		}else{
			right[i] = right[i+1];
		}
	}
	
	int ans = 3e5 + 10;
	f(i,0,n){
		ans = min(ans,n-1-left[i]-right[i]);
	}
	
	cout << ans << endl;
 
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int c = 1;
    for (int i = 1; i <= n; i++) {
        if (c * 2 > c + k) c += k;
	else c *= 2;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long int MOD = 1000000007;
const long long  INF = 1LL << 60;

int main(void){
    int N; cin >> N;
    if (N % 1000 == 0) cout << 0 << endl;
    else cout << 1000 - (N % 1000) << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll d;cin>>d;
    vector<ll>c(26);
    rep(i,26)cin>>c[i];
    vector<vector<ll> >s(d,vector<ll>(26));
    rep(i,d){
        rep(j,26)cin>>s[i][j];
    }
    vector<ll>last(26);
    vector<ll>v(d);
    ll ans=0;
    rep(i,d){
        ll ma=-inf*inf;
        ll idx=0;
        rep(t,26){
            ll cn=0;
            cn+=s[i][t];
            ll m=last[t];
            last[t]=i+1;
            cn+=5*(d-last[t]+1);
            last[t]=m;
            if(cn>ma){
                ma=cn;
                idx=t;
            }
        }
        last[idx]=i+1;
        v[i]=idx+1;
    }
    rep(i,d){
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    string s;
    cin >> s;
    map<string,int>mp;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
typedef long long ll;
#define  fi0(i,n)  for(size_t i=0;i<n;i++)
#define   pb()    push_back()
#define   mk()    make_pair()
#define   fst      first
#define   scnd    second
#define   fast    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define   endl     '\n';
using namespace std;
void mum(){

}
void f(){

 }
void ff(){

}
int I[2][2]={1,0,0,1};
int a[1][2]={0,1};
int b[2][2]={0,1,1,1};
ll fun(int a[][2],int b[][2])
{
    for(int i=0;i<1;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){

            }
        }
    }
}
void fff(){
     ll n,k;cin>>n>>k;
        ll a[n];
        fi0(i,n)cin>>a[i];
       for(int i=0;i<n;i++){
            for(int j=0;j<n-1;j++){
                if(a[j]<a[j+1]){
                    swap(a[j],a[j+1]);
                    k--;
                }
                if(k==0)break;
            }
            if(k==0)break;
       }
       fi0(i,n)cout<<a[i];
       cout<<endl;
}
int main()
{
    fast;
    ll a,b;cin>>a>>b;
    ll d=abs(a-b);
    if(d&1){
        cout<<"IMPOSSIBLE";
    }
    else {
        cout<<min(a,b)+d/2;
    }
}



Measured memory_bytes: 3628
n=int(input())
lst_1=list(map(int,input().split()))
lst_2=list(map(int,input().split()))
ans=[]
ab=0
for i in range(n):
  ab+=lst_1[i]
  aa=0
  for j in range(i,n):
    aa += lst_2[j]
  ans.append(aa+ab)
print(max(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define vvsort(v) sort(v.begin(),v.end(),greater<int>());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
typedef priority_queue<int> pq;
typedef priority_queue<int,vector<int>,greater<int> > rpq;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//----------------------------------------------------------------------------------------------------------------------------------//
int n;
int a[1001];
ll ans=1;
int main(){
        cin>>n;
        for(int i=2; i<=n; i++) {
                int ii=i;
                int j=2;
                while(j<=ii) {
                        if(ii%j==0) {
                                a[j]+=1;
                                ii/=j;
                        }else{
                                j++;
                        }
                }
        }
        for(int i=2; i<=n; i++) {
                ans*=(a[i]+1);
                ans%=MOD;
        }
        cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 10000 + 10;
typedef long long ll;
ll k, a, b;

int main(){
    ios::sync_with_stdio(false);
    cin >> k >> a >> b;
    ll tmp = a - b, ans = 0;
    if(k > a && tmp < 0){
        ans = -1;
    }
    else if(k <= a){
        ans = 1;
    }
    else if(tmp != 0){
        ans = (k - a)/tmp;
        if(ans * tmp == (k - a)){
            ans = ans*2 + 1;
        }
        else ans = (ans + 1)*2 + 1;
    }
    else ans = -1;
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  string S;
  cin >> S;

  ll last = S.front();
  for (ll i = 1; i < S.length(); i++) {
    if (last != S[i]) {
      cout << "Yes" << endl;
      return 0;
    }

    last = S[i];
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){
  char str[4];
  scanf("%s", str);
  
  if(str[0]==str[1] && str[2]==str[3]  && str[0]!=str[2]){
    printf("Yes\n");
  }
  else if(str[0]==str[2] && str[1]==str[3] && str[0]!=str[1]){
    printf("Yes\n");
  }
  else if(str[0]==str[3] && str[1]==str[2] && str[0]!=str[2]){
    printf("Yes\n");
  }
  else{
     printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> ans(n, 0);
    rep(i, n) {
        int sgn;
        if(i%2==0) sgn = 1;
        else sgn = -1;
        ans[0] += a[i]*sgn;
    }

    FOR(i, 1, n) ans[i] = 2*a[i-1] - ans[i-1];

    prvec(ans);
    return 0;}

Measured memory_bytes: 4828
using static System.Console;

public static class Program
{
    public static void Main()
    {
        var line = ReadLine();
        int sum = 0;
        for(int i = 0; i < line.Length; ++i)
        {
            sum += (line[i] - '0');
            sum %= 9;
        }
        WriteLine(sum == 0 ? "Yes" : "No");
    }
}

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

int main() {
  int N, M;
  cin >> N;
  map<string, int> cnt;
  string a;
  for (int i=0; i < N; i++) {
    cin >> a;
    cnt[a]++;
  }
  cin >> M;
  vector<string> B(M);
  for (int i=0; i < M; i++) {
    cin >> a;
    cnt[a]--;
  }
  int ans = 0;
  for (pair<string, int> x : cnt) {
    ans = max(ans, x.second);
  }
  cout << ans << endl;
}

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

using namespace std;

#define int long long
#define test int t = 1;while(t--)

int32_t main()
{
    test
    {
        int n,w;cin>>n>>w;
        
        int wt[n+1] , v[n+1];
        
        for(int i = 1 ; i <= n ; i++)
            cin>>wt[i]>>v[i];
        
        int dp[n+1][w+1];
        
        memset(dp , 0 , sizeof dp);
        
        for(int i = 1; i <= w ; i++)
        {
            for(int j = 1 ; j <= n ; j++)
            {
                if(wt[j] <= i)
                    dp[j][i] = max(dp[j][i] , max(dp[j-1][i] , dp[j-1][i-wt[j]] + v[j]));
                else
                    dp[j][i] = dp[j-1][i];
            }
        }
        
        cout<<dp[n][w]<<endl;
    }
    return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#include<map>
#include<string>
using namespace std ;
int main()
{
    map < string ,int > m ;
    m["SUN"]=7,m["MON"]=6,m["TUE"]=5,m["WED"]=4,m["THU"]=3,m["FRI"]=2,m["SAT"]=1;
    string s ;
    cin >> s ;
    cout << m[s] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <cstdio>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  long double l;
  cin >> l;
  cout << setprecision(15);
  cout << pow(l/3.0, 3) << endl;
}


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

int main(){
    int N,K;
    cin >> N >> K;
    vector<char> S(N);
    for(int i=0; i < N; ++i){
        cin >> S[i];
    }

    if(S[K-1]=='A'){
        S[K-1] = 'a';
    }else if(S[K-1]=='B'){
        S[K-1] = 'b';
    }else if(S[K-1]=='C'){
        S[K-1] = 'c';
    }

    for(int i=0; i<N; ++i){
        cout << S[i];
    }
    
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int digits(int a)
{
    int sum=0;
    while(a!=0){
        sum+=a%10;
        a/=10;
    }
    return sum;
}
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int sum=0;
    for(int i=0;i<=n;i++)
    {
        int totaldigits=digits(i);
        if(totaldigits>=a&&totaldigits<=b){
            sum+=i;

        }
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 3528
# = int(input())
S = str(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]


if "RRR" in S:
    print(3)
    exit()
elif "RR" in S:
    print(2)
    exit()
elif "R" in S:
    print(1)
else:
    print(0)


Measured memory_bytes: 9080
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
using namespace std;
typedef long long ll;
int main(void)
{
	ll n;
	ll ab=100;
	cin>>n;
	ll cnt=0;
	while(ab<n)
	{
		ab+=ab/100;cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
using namespace std;

vector<pair<int, int> > solve(string const & s_) {
    const int n = s_.size();
    vector<bool> s(n + 1);
    REP (i, n) s[i + 1] = (s_[i] != '0');

    if (not s[1]) {
        return vector<pair<int, int> >();  // leaves are required
    }
    REP (i, n + 1) {
        if (s[i] != s[n - i]) {
            return vector<pair<int, int> >();  // invariant
        }
    }

    vector<pair<int, int> > edges;
    int root = 0;
    int root_size = 1;
    int next = 1;
    REP3 (size, 2, n + 1) if (s[size] or size == n) {
        edges.emplace_back(root, next);
        root = next;
        ++ root_size;
        ++ next;
        while (root_size < size) {
            edges.emplace_back(root, next);
            ++ root_size;
            ++ next;
        }
    }
    return edges;
}

int main() {
    string s; cin >> s;
    auto edges = solve(s);
    if (edges.empty()) {
        cout << -1 << endl;
    } else {
        for (auto edge : edges) {
            int u, v; tie(u, v) = edge;
            cout << u + 1 << ' ' << v + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2420
#!/usr/bin/env python3
import sys

def main():
    N, M = map(int, input().split())
    
    if M % 2 == 1:
        for i in range(M//2):
            print(i+1,M-i)
        for j in range(M//2 + 1):
            print(M+1+j,2*M+1-j)
    else:
        for i in range(M//2):
            print(i+1, M+1-i)
        for j in range(M//2):
            print(M+2+j,2*M+1-j)

if __name__ == '__main__':
    main()

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

int main(){
  int64_t A,B,C;
  cin >> A >> B >> C;
  if (A % 2 != 0 && B % 2 != 0 && C % 2 != 0){
    cout << min(min(A * B,B * C),C * A) << endl;
  }
  else cout << 0 << endl;
}

Measured memory_bytes: 256
l, r = map(int, input().split())
if r-l >= 2019:
    ans = 0
else:
    n = 2019
    l = l%n
    r = r%n
    ans = 2019
    a = min(l,r)
    b = max(l,r)

    for i in range(a,b):
        for j in range(a+1,b+1):
            ans = min(ans, (i*j)%n)

print(ans)

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    string w;
    cin >> w;
    map<char, int> m;

    for ( auto l : w ) m[l]++;

    for ( auto p : m ) {
        if ( p.ss & 1 ) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
// 素因数分解
vector<pair<long long, long long>> prime_factorize(long long n)
{
  vector<pair<long long, long long>> res;
  for (long long p = 2; p * p <= n; ++p)
  {
    if (n % p != 0)
      continue;
    int num = 0;
    while (n % p == 0)
    {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}
int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> sv(m), cv(m);
  rep(i, m)
  {
    cin >> sv[i];
    sv[i]--;
    cin >> cv[i];
  }
  for (int ans = 0; ans <= 999; ans++)
  {
    string s = to_string(ans);
    bool ok = true;
    if (s.length() != n)
    {
      ok = false;
    }
    for (int i = 0; i < m; i++)
    {
      for (int j = 0; j < n; j++)
      {
        if (j == sv[i] && (s[j] - '0') != cv[i])
        {
          ok = false;
        }
      }
    }
    if (ok)
    {
      cout << ans << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

using namespace std;

int main()
{
  long long N, H;
  cin >> N >> H;
  vector<long long> av(N), bv(N);
  for (int i=0; i<N; i++) {
    cin >> av[i] >> bv[i];
  }
  sort(av.begin(), av.end(), std::greater<long long>());
  sort(bv.begin(), bv.end(), std::greater<long long>());
  long long maxa = av[0];
  long long maxhit = 0;
  long long maxhitcount = 0;
  long long ans = 0;
  for (int i=0; i<N && bv[i]>maxa && H > 0; ++i) {
    H -= bv[i];
    ans++;
  }

  if (H>0)
    ans += (H-1)/maxa + 1;
  cout << ans  << endl;
  // cout << maxa << endl;
}

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

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

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

int main() {
    int n;
    cin >> n;
    ll t[n];
    ll ans=1;
    for (int i = 0; i < n; i++) {
        cin >> t[i];
        ans=lcm(ans,t[i]);
    }
    cout<<ans<<endl;
}

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

int main()
{
	char s[3];
	for(int i = 0; i < 3; i++)
		cin >> s[i];
	int num = 0;
	if(s[0] == 'R')
		num++;
	if(s[1] == 'R')
		num++;
	if(s[2] == 'R'){
		if(s[1] == 'R')
			num++;
		else
			num = 1;
	}
	cout << num << "\n";
	return 0;
}

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

const int N=300010;
int mmax[N<<2],n,k;

#define ls now<<1
#define rs now<<1|1
void add(int now,int x,int t,int l=0,int r=300000){
	mmax[now]=max(mmax[now],t);
	if(l==r) return ;
	int mid=(l+r)/2;
	if(x<=mid) add(ls,x,t,l,mid);
	else add(rs,x,t,mid+1,r);
}

int gas(int now,int x,int y,int l=0,int r=300000){
	if(x==l && y==r) return mmax[now];
	int mid=(l+r)/2;
	if(y<=mid) return gas(ls,x,y,l,mid);
	else if(mid<x) return gas(rs,x,y,mid+1,r);
	else return max(gas(ls,x,mid,l,mid),gas(rs,mid+1,y,mid+1,r));
}

int main(){
	scanf("%d %d",&n,&k);
	int x,y,l,r;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		l=max(0,x-k);r=min(300000,x+k);
		y=gas(1,l,r)+1;
		add(1,x,y);
	}
	printf("%d\n",mmax[1]);
}

Measured memory_bytes: 7924
#include "stdio.h"
#include <utility>
using namespace std;

int num;
pair<int, int> num_pair[100000];

int main(void){
	int N;
	int i, j;
	int cnt = 0;

	scanf("%d", &N);

	for(i=0;i<N;i++){
		scanf("%d", &num);
		if(num>100000){
			cnt++;
			continue;
		};

		for(j=0;j<N;j++){
			if(num_pair[j].first==0||num_pair[j].first==num){
				num_pair[j].second++;
				num_pair[j].first = num;
				break;
			}
		}
	}

	for(j=0;j<N;j++){
		if(num_pair[j].second>=num_pair[j].first){
			cnt += num_pair[j].second-num_pair[j].first;
		}
		else
		{
			cnt += num_pair[j].second;
		}
	}

	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
import sys
n = int(input())
A = [int(e)for e in sys.stdin]
cnt = 0
G = [int((2.25**i-1)/1.25)for i in range(19,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print(*A,sep='\n')


Measured memory_bytes: 53512
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := 0; i < n-1; i++ {
		var a int
		fmt.Scan(&a)
		a--
		as[a]++
	}
	for i := range as {
		fmt.Println(as[i])
	}
}


Measured memory_bytes: 6468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

string S;

signed main()
{
    cin >> S;
    int N = S.size();
    int len = 0;
    for(int i = 0; i < N; i++){
        if(S[i] != 'x'){
            len++;
        }
    }
    if(len == 0){
        printf("0\n");
        return 0;
    }
    int cnt = 0;
    int l = 0, r = 0;
    for(int i = 0; i < N; i++){
        if(S[i] != 'x'){
            cnt++;
            if(cnt == (len + 1) / 2){
                l = i;
            }
        }
    }
    cnt = 0;
    for(int i = N - 1; i >= 0; i--){
        if(S[i] != 'x'){
            cnt++;
            if(cnt == (len + 1) / 2){
                r = i;
            }
        }
    }
    string s = S.substr(0, l + 1);
    string t = S.substr(r, N - r);
    reverse(s.begin(), s.end());
    //cout << s << endl << t << endl;
    l = 0, r = 0;
    int ans = 0;
    s += '1';
    t += '1';
    while(1){
        if(s[l] == '1' && t[r] == '1'){
            break;
        }
        else if(s[l] == t[r]){
            l++;
            r++;
            continue;
        }
        else if(s[l] == 'x'){
            ans++;
            l++;
        }
        else if(t[r] == 'x'){
            ans++;
            r++;
        }
        else {
            printf("-1\n");
            return 0;
        }
    }
    printf("%d\n", ans);


    return 0;
}
/*

*/




Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)

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

	for(int i = 0; i < n; i++){
		double xa,ya,ra,xb,yb,rb;
		cin>>xa>>ya>>ra>>xb>>yb>>rb;
		double dist=(ya-yb)*(ya-yb)+(xa-xb)*(xa-xb);
		// AÆBªdÈçÈ¢
		if((ra+rb)*(ra+rb)<dist)
			cout<<0<<endl;
		// ~üªðíé
		else if(((abs(ra-rb))*(abs(ra-rb))<dist&&(ra+rb)*(ra+rb)>dist))
			cout<<1<<endl;
		else if(abs(ra-rb)*abs(ra-rb)>dist){
			// Ç¿ç©ªÉ¶Ý·é
			if(ra>rb)
				cout<<2<<endl;
			else
				cout<<-2<<endl;
		}
		else
			cout<<1<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{c: chars}
    println!("{}", (c[0] as u8 + 1) as char);
}


Measured memory_bytes: 4352
#include<stdio.h>
 int main(){
    int n;
     scanf("%d",&n);
      int Ar[2*n];
        for(int i=0;i<(2*n);i++){
             scanf("%d",&Ar[i]);
        }
        int count=0;
          int track=0;
        for(int i=0;i<(2*n);i=i+2){
            int k= count;
             if(Ar[i]==Ar[i+1]){
                 count++;
             }
             if(count>k){
                  track++;
             }
             else if(track>=3){
                 track=track;
             }
             else track=0;
        }
        if(track>=3) {
            printf("Yes");
        }
        else printf("No");

}


Measured memory_bytes: 1716
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;

    vector<int> sum;

    int left = 0;
    int right = 0;
    for (int i = 1; i < s.size(); i++){
        if (s[i] == 'E'){
            right++;
        }
    }
    sum.push_back(left + right);

    for (int i = 1; i < s.size(); i++){
        if (s[i-1] == 'W'){
            left++;
        }
        if (s[i] == 'E'){
            right--;
        }
        sum.push_back(left + right);
    }
    cout << *min_element(all(sum)) << endl;
}


Measured memory_bytes: 2812
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;

int n, a[N];
ll dp[N][3];

ll solve(int i, int rem){
    if(i >= n)return rem == 2 ? -1e17 : 0;
    ll &ret = dp[i][rem];
    if(~ret)return ret;
    ret = -1e17;
    ret = max(ret, solve(i + 2, rem) + a[i]);
    if(rem)
        ret = max(ret, solve(i + 1, rem - 1));
    return ret;
}

int main(){
    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d", a + i);
    memset(dp, -1 , sizeof dp);
    printf("%lld\n", solve(0, (n & 1) + 1));
}

Measured memory_bytes: 15556
def gcd(m,n)
	if n == 0 
		m
	else
		gcd(n,m%n)
	end
end

def lcm(m, n)
	(m * n ) / gcd(m,n)
end

n = gets.to_i
a = gets.split.map(&:to_i)
l=1
n.times do |i|
		l = lcm(l,a[i])
end
sum = 0;
n.times do |i|
	sum = sum + l/a[i]
end
puts sum % 1000000007
		


Measured memory_bytes: 63548