akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int main(){
    int N;
    cin >> N;
    int a[N];
    int pos = 1;
    rep(i, N){
        cin >> a[i];
        if(a[i] == pos) pos++;
    }
    if(pos == 1) cout << -1 << endl;
    else cout << N+1-pos << endl;
}

Measured memory_bytes: 1024
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const INF: i64 = 1e18 as i64;

fn solve(head: i64, a: &Vec<i64>) -> i64 {
    let n = a.len();
    let mut sum = (a[0] - head).abs();
    let mut psum = head;
    for i in 1..n {
        let tsum = psum + a[i];
        if psum < 0 {
            sum += max(1 - tsum, 0);
            psum = max(1, tsum);
        } else {
            sum += max(tsum + 1, 0);
            psum = min(-1, tsum);
        }
    }
    sum
}

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = readnc();

    let head = a[0];
    let mut ans = min(solve(1, &a), solve(-1, &a));
    if a[0] != 0 {
        ans = min(ans, solve(a[0], &a));
    }
    println!("{}", ans);
}

Measured memory_bytes: 8444
class MaxHeap:

    @classmethod
    def heapify(cls, array):
        size = len(array)
        for i in reversed(range(size // 2)):
            cls.siftdown(array, i, size)

    @classmethod
    def push(cls, heap, x):
        heap.append(x)
        cls.siftup(heap, len(heap) - 1)

    @classmethod
    def pop(cls, heap):
        if heap:
            heap[0], heap[-1] = heap[-1], heap[0]
            res = heap.pop()
            cls.siftdown(heap, 0, len(heap) - 1)
            return res
        else:
            return None

    @staticmethod
    def peek(heap):
        return heap[0]

    @staticmethod
    def siftup(heap, i):
        parent = (i - 1) // 2
        while i > 0 and heap[i] >= heap[parent]:
            heap[i], heap[parent] = heap[parent], heap[i]
            i = parent
            parent = (i - 1) // 2

    @staticmethod
    def siftdown(heap, i, size):
        while True:
            left = 2 * i + 1
            right = 2 * i + 2
            largest = left
            if right < size and heap[right] > heap[left]:
                largest = right

            if left >= size or heap[i] > heap[largest]:
                break

            heap[i], heap[largest] = heap[largest], heap[i]
            i = largest


if __name__ == '__main__':
    input()
    array = list(map(int, input().split()))
    MaxHeap.heapify(array)
    print(' ' + ' '.join(map(str, array)))


Measured memory_bytes: 63948
#include<map>
#include<cstdio>
#include<queue>
#include<bitset>
#include<vector>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
# define Type template<typename T>
# define ll long long
# define ull unsigned ll
# define read read1<int>()
Type inline T read1(){
    T t=0;
    char k;
    bool fl=0;
    do k=getchar(),(k=='-')&&(fl=1);while('0'>k||k>'9');
    while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar();
    return fl?-t:t;
}
int main(){
    ll w=read;
    for(ll i=-200;i<=200;++i)
        for(ll j=-200;j<=200;++j)
            if(i*i*i*i*i-j*j*j*j*j==w)
                return printf("%lld %lld",i,j),0;
    return 0;
}

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

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define fset(arr,n,val) for(int i=0;i<n;++i) arr[i] = val
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------

void solve_main()
{
    int n,k;cin>>n>>k;
    int arr[n];
    frepi(0,n-1,1)cin>>arr[i];
    if(k>=n)
    {
    	cout<<"0\n";
    	return;
    }
    sort(arr,arr+n,greater<int>());
    long long ans = 0;
    for(int i=k;i<n;++i)
    	ans+=arr[i];
    cout<<ans;
}

int main()
{

	#ifndef ONLINE_JUDGE
		freopen("/home/suryakant/input.txt","r",stdin);
		freopen("/home/suryakant/output.txt","w",stdout);
	#endif

    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  long long x, y;
  x = y = 0;

  cin >> n;
  cin >> x >> y;
  for (int i = 1; i < n; i++) {
    long long t, a;
    cin >> t >> a;
    long long k = max(x/t, y/a);
    if (t*k >= x && a*k >= y) {
      x = t*k; y = a*k;
    } else {
      x = t*++k; y = a*k;
    }
  }

  cout << x+y << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	double [][] time = {{35.5, 71.0}, {37.5, 77.0}, {40.0, 83.0}, {43.0, 89.0},
			{50.0, 105.0}, {55.0, 116.0}, {70.0, 148.0}};
	String [] rank = {"AAA", "AA", "A", "B", "C", "D", "E"};
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			double sec500 = sc.nextDouble();
			double sec1000 = sc.nextDouble();
			int len = time.length;
			boolean flg = true;
			for(int i = 0; i < len; i++){
				if(sec500 < time[i][0] && sec1000 < time[i][1]){
					System.out.println(rank[i]);
					flg = false;
					break;
				}
			}
			if(flg){
				System.out.println("NA");
			}
		}
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

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

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

/**
 * https://qiita.com/EqualL2/items/b3c2530c458f8450d390
*/
bool is_prime(int a){
  switch(a){
    case 0:
    case 1:
      return false;
    case 2:
    case 3:
      return true;
  }
  //a > 3

  if(a % 2 == 0 || a % 3 == 0) return false;
  //aは2と3のいずれの倍数でもない
  //aは6の倍数-1または6の倍数+1

  for(int i = 5; i * i <= a; i += 6){
    if(a % i == 0) return false;      //6の倍数-1
    if(a % (i + 2) == 0) return false;//6の倍数+1
  }

  return true;
}

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

  int q;
  cin >> q;
  vec l(q), r(q);
  REP(i, q) {
    cin >> l[i] >> r[i];
    l[i]--;
  } 

  //1から10^5までのなかで適する物の個数を求める
  vector<bool> a(10e5 + 1, false);
  FOR(i, 1, 10e5 + 1){
    a[i] = is_prime(i);
  }
  vec b(10e5 + 1, 0);
  FOR(i, 1, 10e5 + 1){
    b[i] += b[i - 1];
    if(i % 2 == 1){
      if(a[i] && a[(i + 1) / 2]){
        b[i]++;
      }
    }
  }

  REP(i, q){
    cout << b[r[i]] - b[l[i]] << endl;
  }

  return 0;
}

Measured memory_bytes: 10112
#include <stdio.h>

int main() {
  char character_x, character_y;
  scanf("%c %c", &character_x, &character_y);
  if(character_x > character_y) {
    printf(">\n");
  } else if(character_x < character_y) {
    printf("<\n");
  } else {
    printf("=\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long double LD; 
typedef long long ll; 
#define int ll 
#define ff(i,a,b) for (int i = a; i < b; i++) 
#define bf(i,a,b) for (int i = a; i >= b; i--) 
#define all(v) v.begin(),v.end() 
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define F first 
#define S second
#define pb push_back
#define mp make_pair
#define lb lower_bound   
#define ub upper_bound
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define one cout<<"-1"<<endl
#define pi 3.141592653589793238
#define intmx INT_MAX 
#define intmi INT_MIN
const int MOD=1e9+7;
int mod(int x){
    return ((x%MOD + MOD)%MOD);
}
int add(int a,int b){
    return mod(mod(a)+mod(b));
}
int mul(int a,int b){
    return mod(mod(a)*mod(b));
}
void solve(){
   int n;
   long double d;
   cin>>n>>d;
   int ans=0;
   ff(i,0,n){
       long double x,y;
       cin>>x>>y;
long double dis=sqrt(x*x+y*y);
       if(dis<=d)
       ans++;
   }
   cout<<ans<<endl;
}
signed main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3788
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
using namespace std;

int main(){
    int n;
    while(cin>>n&&n){
        int count=0;
        while(n!=1){
            if(n%2==1){
                n=n*3+1;
            }else{
                n/=2;
            }
            count++;
        }
        cout<<count<<endl;
    }
    return 0;
}


Measured memory_bytes: 2996
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
 ll n,m;
  cin >> n >> m;
  cout << (n==m?"Yes":"No") << endl;
}

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

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  bool ans = false;
  for (int i = 1; i <= 1000; i++) {
    if (K * i >= A && K * i <= B)
      ans = true;
    if (ans == 1) {
      cout << "OK" << endl;
      break;
    }
  }
  if (ans == 0)
    cout << "NG" << endl;
}


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

using ll = long long;

int main(){
	ll n, e, t;
	cin >> n >> e >> t;
	vector<ll> ps(n);
	for(auto& x : ps) cin >> x;

	vector<ll> d(n, 0);

	ll best_left = 1000000001;
	multiset<ll> inner_best;

	auto get_dyn_minus_unu = [&](const ll x){
		return x == 0 ? 0 : d[x-1]; };

	for(ll i = 0, st = 0; i < n; ++i){
		if(i != 0) best_left += 2 * (ps[i] - ps[i-1]);
		inner_best.insert(get_dyn_minus_unu(i));
		while(2 * (ps[i] - ps[st]) >= t){
			inner_best.erase(inner_best.find(get_dyn_minus_unu(st)));
			best_left = min(best_left, 2 * (ps[i] - ps[st]) + get_dyn_minus_unu(st));
			++st; }
		ll rez = best_left;
		if(!inner_best.empty()){
			rez = min(rez, *begin(inner_best) + t); }
		d[i] = rez; }

	cout << d.back() + e << endl;
	return 0; }


Measured memory_bytes: 3840
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+4;
int n;
ll a[N];
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
inline bool cmp(int x,int y) {
	return x>y;
}
int main() {
	n=read();
	for (register int i=1;i<=n;++i) a[i]=read();
	sort(a+1,a+n+1,cmp);
	ll ans=a[1];
	int pos=2;
	for (int i=3;i<=n;++i) {
//		printf("%d %d\n",a[i],a[pos]);
		ans+=a[pos];
		if (!(i&1)) ++pos;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

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

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cstring>
#include <bits/stdc++.h>
#include <search.h>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include<stack>
#include <utility>
using namespace std;
int main()
{
int num=0;
string s;
cin>>s;
for(int i=0;i<s.length()/2;++i){
        if(s[i]!=s[s.length()-1-i]) num++;

}
cout<<num;
return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC106A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            c = a * b - (a + b - 1);

            Console.WriteLine(c);

            Console.ReadKey();

        }
    }
}


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

int main() {
  int64_t A, B, V, W, T;
  
  cin >> A >> V >> B >> W >> T;
  
  if (max(A,B)-min(A,B)>T*(V-W)){
    cout << "NO" << endl;
  }
  
  else {
    cout << "YES" << endl;
  }
  
}



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

  int X,Y;cin>>X>>Y;
  
  if(Y>=2*X&&4*X>=Y){
    if((Y-2*X)%2==0&&(4*X-Y)%2==0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

main(){
    string a,b,comp;
    cin>>a>>b;
    int x,y;
    cin>>x>>y>>comp;

    if(comp == a) cout<<x-1<<" "<<y<<endl;
    else cout<<x<<" "<<y-1<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    auto a = make_vec<int>(n, n);
    rep(i, n) rep(j, n) cin >> a[i][j];

    vector<ll> dp(1<<n);

    for (int i = 0; i < 1<<n; ++i) {
        ll score = 0;
        for (int j = 0; j < n; ++j) {
            for (int k = j+1; k < n; ++k) {
                if ((i >> j & 1) && (i >> k & 1)) {
                    score += a[j][k];
                }
            }
        }
        chmax(dp[i], score);
        for (int j = i; j >= 0; --j) {
            j &= i;
            chmax(dp[i], dp[j] + dp[i-j]);
        }
    }

    cout << dp[(1<<n)-1] << endl;
}


Measured memory_bytes: 3736
from itertools import accumulate
N, X = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
p = list(accumulate(a))

result = 0
for i, x in enumerate(p):
  if X < x:
    break
  if i == N-1 and x != X:
    break
  result += 1

print(result)

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pi;

const int maxn = 105;

vector<int> cc[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n;
    if(n & 1){
        m = (n + 1) / 2;
        for(int i = 1;i <= n / 2;i++){
            cc[i].push_back(i);
            cc[i].push_back(n - i);
        }
        cc[m].push_back(n);
    }else{
        m = n / 2;
        for(int i = 1;i <= m;i++){
            cc[i].push_back(i);
            cc[i].push_back(n + 1 - i);
        }
    }
    vector<pi> edge;
    for(int i = 1;i < m;i++){
        for(int j = i + 1;j <= m;j++){
            for(auto u : cc[i]){
                for(auto v : cc[j]){
                    edge.eb(u, v);
                }
            }
        }
    }
    cout << edge.size() << endl;
    for(auto e : edge){
        cout << e.fi << " " << e.se << endl;
    }
    return 0;
}


Measured memory_bytes: 384
x = list(map(int,input().split()))
count=0
for a in range(max(0,x[1]-2*x[0]),min(x[0],x[1])+1):
    for b in range(max(0,x[1]-a-x[0]),min(x[0],x[1]-a)+1):
        for c in range(max(x[1]-a-b,0),min(x[1]-a-b,x[0])+1):
            if(a+b+c==x[1]):
                count+=1
print(count)

Measured memory_bytes: 41052
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp(a,b) make_pair(a,b)
const long long mod = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<int ,P> PP;
struct edge { int to; int to2; int cost; };
int a[100006];
int gcd(int a, int b) {
	if (!b)return a;
	return gcd(b, a%b);
}
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	vector<int>V;
	for (int i = 1; i*i <= a[0]; i++) {
		if (a[0] % i == 0) {
			V.push_back(i);
			V.push_back(a[0] / i);
		}
	}
	for (int i = 1; i*i <= a[1]; i++) {
		if (a[1] % i == 0) {
			V.push_back(i);
			V.push_back(a[1] / i);
		}
	}
	sort(V.begin(), V.end());
	V.erase(unique(V.begin(), V.end()), V.end());
	int ans = 0;
	rep(i, V.size()) {
		int cnt = 0;
		rep(j, n) {
			if (a[j] % V[i] != 0)cnt++;
		}
		if (cnt <= 1)ans = V[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

double n;
double pi=3.1415926;

int main() {
    ios::sync_with_stdio(false);
    cin>>n;
    printf("%lf",2*pi*n);

    return 0;
}

Measured memory_bytes: 3808
N = int(input())
import math

ans = []

for i in range(1,round((N-1)**0.5)+1):
  if (N-1)%i == 0:
    ans.append(i)
    if (N-1)//i != i:
      ans.append((N-1)//i)

ans.remove(1)
ans.append(N)
for i in range(2,round(N**0.5)+1):
  if N%i == 0:
    n = N
    while n%i==0:
      n//=i
    if n%i==1:
      ans.append(i)

print(len(ans))

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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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 ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

void warshall_floyd(vector<vector<int>>& G, ll n){
  for (int k = 0; k < n; ++k){      //経由する頂点
    for (int i = 0; i < n; ++i){    //始点
      for (int j = 0; j < n; ++j){  //終点
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
}

int main(){
  int H, W; cin >> H >> W;
  vector<vector<int>> c(10, vector<int>(10));
  rep(i, 10) rep(j, 10) cin >> c[i][j];

  map<int, int> mp;
  rep(i, H) rep(j, W) {
    int a; cin >> a;
    mp[a]++;
  }
  warshall_floyd(c, 10);
  ll ans = 0;
  for (auto p: mp){
    if (p.first == -1) continue;
    ans += c[p.first][1] * p.second;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

c=input().rstrip()
if c=="a" or c=="i" or c=="u" or c=="e" or c=="o":
    print("vowel")
else:
    print("consonant")

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint h;cin >> h;
    lint ans=0,c=0;
    while(true){
        h /= 2L;
        if(h==0){
            break;
        }
        c++;
    }
    //cout << c << "\n";
    //ans += 1;
    REP(i,c+1){
        ans += (1LL<<i);
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include<limits.h>
using namespace std;
using T = tuple<int,int,int>;

#define gc getchar_unlocked
#define sdi(a, b)   si(a);si(b)
#define FOR(i, n)  for(int i = 0;i < n; i++) 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define INF 1e9
#define ss second
#define ff first
#define vi vector<int>
#define pri(arr,a,b) repn(i,1,a){repn(j,i+1,b){cout<<arr[i][j]<<" ";}cout<<endl;}
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair<int,pair<int,int>> piii;
 
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
 
const int mod=1e9+7;
//const int mod=998244353;
const int up=1e5+10;
const int MAXN=1e6+10;

string s;
int a[2*up];

void solve()
{
    int a;
    cin>>a;
    int ans=a+a*a+a*a*a;
    cout<<ans<<endl;
}

int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("inputf.in", "r", stdin);
    //     freopen("outputf.in", "w", stdout);
    // #endif
    fast_cin();
    int T;
    //sieve();
    //cin>>T;
    T=1;
    int t1=1;
    while(true)
    {  
        
        solve(); 
        t1++;
        if(t1>T)
            break;
    }
}

Measured memory_bytes: 3584
#include <algorithm>
#include <climits>
#include <cstring>
#include <inttypes.h>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

const int cap = 1e5 + 1;
int A[101];
bool dp[cap];

int N, K;

int main() {
    scanf("%d %d", &N, &K);
    for (int i = 1; i <= N; ++i)
        scanf(" %d", &A[i]);

    sort(A + 1, A + N + 1);
    fill(dp, dp + K + 1, false);
    for (int i = 0; i + A[1] <= K; ++i) {
        if (!dp[i])
            for (int j = 1; j <= N && i + A[j] <= K; ++j) 
                dp[i + A[j]] = true;
    }
    string ans = dp[K] ? "First" : "Second";
    cout << ans << endl;
}









Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//Choose Integers
//A*1 から A *Bまでやればよい(A*(B+1) のあまりは(A*1) と一緒)
int main(){
  ll H,W;
  cin >> H >> W;

  string tmp;

  REP(i,H)
  {
    cin >> tmp;
    cout << tmp << endl;
    cout << tmp << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  int count=0;
  std::cin >> s;
  std::vector<int> arpha(26, 0);
  range(i, 26){
    count=0;
    range(j, s.size()){
      count++;
      if(s[j]==i+'a'){
        arpha[i]=max(arpha[i], count);
        count=0;
      }else if(j==s.size()-1) arpha[i]=max(arpha[i], count+1);
    }
  }
  int ans = MODs;
  range(i, 26) if(arpha[i]!=0) ans = min(ans, arpha[i]);
  std::cout << ans-1 << '\n';
  return 0;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

const int MOD = 1e9+7;

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

    ll power = 1;
    for (int i = 1; i <= n; i++) {
        power = ((power % MOD) * (i % MOD))%MOD;
    }

    cout << power << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>

#define max 100005
#define inf 0xfffffff

using namespace std;

struct Edge {
	int from;
	int to;
	int w;
};

vector<Edge> G[max];
int d[max];
int n;

int max_ini(int a, int b) {
	return (a>=b) ? a : b; 
}

void bfs(int s) {
	int i;
	for(i=0;i<n;i++) {
		d[i]=inf;
	}
	queue<int> q;
	q.push(s);
	d[s]=0;
	int u;
	while(!q.empty()) {
		u=q.front();
		q.pop();
		for(i=0;i<G[u].size();i++) {
			Edge e=G[u][i];
			if(d[e.to]==inf) {
				d[e.to]=d[u]+e.w;
				q.push(e.to);
			}
		}
	}
}

void solve() {
	int maxa,i,tgt;
	maxa=tgt=0;
	
	bfs(0);
	
	for(i=0;i<n;i++) {
		if(d[i]==inf) continue;
		if(maxa<d[i]) {
			maxa=d[i];
			tgt=i;
		}
	}
	
	bfs(tgt);
	
	maxa=0;
	for(i=0;i<n;i++) {
		if(d[i]==inf) continue;
		maxa=max_ini(maxa,d[i]);
	}
	
	cout<<maxa<<endl;
}

int main() {
	int i;

	scanf("%d",&n);
	
	for(i=1;i<n;i++) {
		Edge now;
		scanf("%d %d %d",&now.from,&now.to,&now.w);
		G[now.from].push_back(now);
		
		Edge now_Sec;
		now_Sec.from=now.to;
		now_Sec.to=now.from;
		now_Sec.w=now.w;
		G[now_Sec.from].push_back(now_Sec);
	}
	
	solve();
	
	return 0;
}

 


Measured memory_bytes: 10700
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        int length = input.length();
        char[] S = new char[length];
        for (int i = 0; i < length; i++) {
            S[i] = input.charAt(i);
        }

        int ans = 0;
        for (int i = 1; i < length; i++) {
            if(S[i-1] == S[i]) {
                ans++;
                if (S[i] == '0') {
                    S[i] = '1';
                }
                else {
                    S[i] = '0';
                }
            }
        }

        System.out.println(ans);
    }
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  
  	vector<int> v(3);
  	cin >> v[0] >> v[1] >> v[2];
  	sort(v.begin(), v.end());
  
  	if(v[0] == 5 && v[1] == 5 && v[2] == 7){
    	cout << "YES" << "\n";
    }else{
    	cout << "NO" << "\n";
    }

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>

using namespace std;

int const MAX_R = 1010;
int const MAX_N = 210;
int const INF = 1<<29;

long long dl[MAX_N][MAX_N];
long long ds[MAX_N][MAX_N];
long long dp[MAX_R][MAX_N];
int z[MAX_R];
int N, M, R;

int main() {
  
  while(cin >> N >> M && (N|M)) {
    for(int i=0; i<N; i++) {
      for(int j=i+1; j<N; j++) {
        dl[i][j] = dl[j][i] = INF;
        ds[i][j] = ds[j][i] = INF;
      }
      dl[i][i] = dl[i][i] = ds[i][i] = ds[i][i] = 0;
    }
    for(int i=0; i<M; i++) {
      int x, y, t; char sl;
      cin >> x >> y >> t >> sl; x--, y--;
      if(sl == 'L') {
        dl[x][y] = dl[y][x] = t;
      }
      else {
        ds[x][y] = ds[y][x] = t;
      }
    }
    
    for(int k=0; k<N; k++)
      for(int i=0; i<N; i++)
        for(int j=0; j<N; j++) {
          dl[i][j] = min(dl[i][j], dl[i][k]+dl[k][j]);
          ds[i][j] = min(ds[i][j], ds[i][k]+ds[k][j]);
        }
    
    cin >> R;
    for(int i=0; i<R; i++) { cin >> z[i]; z[i]--; }
    
    fill(dp[0], dp[0]+MAX_R*MAX_N, INF);
    dp[0][z[0]] = 0;
    
    for(int i=1; i<R; i++) {
      for(int s=0; s<N; s++) {
        for(int t=0; t<N; t++) {
          dp[i][t] = min(dp[i][t], dp[i-1][s]+dl[z[i-1]][s]+ds[s][t]+dl[t][z[i]]);
        }
        dp[i][s] = min(dp[i][s], dp[i-1][s]+dl[z[i-1]][z[i]]);
      }
    }
    
    cout << *min_element(dp[R-1], dp[R]) << endl;
    
  }
  
  return 0;
}

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

  cin >> N;
  vector<string> blue(N);
  for (int i = 0; i < N; i++)
    cin >> blue.at(i);

  cin >> M;
  vector<string> red(M);
  for (int i = 0; i < M; i++)
    cin >> red.at(i);

  vector<int> profit(N, 0);

  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if ( blue.at(i) != blue.at(j) ){
        continue;
      } else {
        profit.at(i)++;
      }
    }
    for (int j = 0; j < M; j++){
      if ( blue.at(i) != red.at(j) ){
        continue;
      } else {
        profit.at(i)--;
      }
    }
  }

  int max = 0;
  for (int i = 0; i < N; i++){
    if ( profit.at(i) > max ) max = profit.at(i);
  }
    cout << max;
}


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

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

using namespace std;

int N, A, B;

int main() {
    cin >> N >> A >> B;
    cout << min(B, A * N) << endl;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string s;
    cin>>s;
    int x=-1,y=-1;
  	if (s.size()==2){
    	if (s[0]==s[1]){
        	cout<<1<<' '<<2<<endl;
        }else cout<<-1<<' '<<-1<<endl;
    	return 0;
    }
    for (int i=0;i<s.size()-2;i++){
        if (s[i]==s[i+1]||s[i+1]==s[i+2]||s[i+2]==s[i]){
            x=i+1;
            y=i+3;
            break;
        }
    }cout<<x<<' '<<y<<endl;
    return 0;

}


Measured memory_bytes: 512
import sys
input=sys.stdin.readline   
sys.setrecursionlimit(100000000)
from functools import lru_cache
INF = 1000000000
MOD = 10**9+7

def main():
    n=int(input())
    s=input()

    dp=[[0]*(1+n) for _ in range(n)]
    for i in range(n-1):
        for j in range(i+1,n):
            if s[i]==s[j]:
                dp[i+1][j+1]=min(dp[i][j]+1,j-i)          
    
    ans=0
    for i in range(n+1):
        for j in range(i+1,n+1):
            ans=max(ans,dp[i][j])
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 231432
n,m = map(int,input().split())
ls = [[int(x) for x in input().split()] for _ in range(m)]
can = [int(x) for x in range(2,n+1)]

import itertools
ans = 0 
for ls_can in list(itertools.permutations(can)):
    ls_can = [1]+list(ls_can)
    flg = 0
    for i in range(n-1):
        if [ls_can[i],ls_can[i+1]] in ls or [ls_can[i+1],ls_can[i]] in ls :
            flg +=1
        else:
            break
        if flg == n-1:
            ans +=1
print(ans)

Measured memory_bytes: 42844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
 
 
int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    rep(i,n-1){
       if(a[i]==a[i+1]){
           cout << "NO" << endl;
           return 0;
       }
    }
    cout << "YES" << endl;
return 0;
}

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

int main(){

  int n,i,x,j,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    int f=1;
    scanf("%d",&x);
    for(j=2;j<=sqrt(x);j++){
      if(x%j==0){
	f=0;
      }
    }
    if(f==1){
      count++;
    }
  }

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

Measured memory_bytes: 596
Q = int(input())

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(n**0.5)+1):
        if n % k == 0:
            return 0
    return n

prime_numbers = [is_prime(i) for i in range(2, 10**5 + 1) if is_prime(i) != 0]
same = [0]*(10**5 + 1)
for n in prime_numbers:
    if (n+1) // 2 in prime_numbers:
        same[n] += 1

for i in range(10**5):
    same[i+1] += same[i]

ans = []
for _ in range(Q):
    l, r = map(int, input().split())
    N = same[r] - same[l-1]
    ans.append(N)

print(*ans, sep='\n')


Measured memory_bytes: 12688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll a,b,c; cin>>a>>b>>c;
    if(a==b && a!=c) cout<<"Yes"<<endl;
    else if(a==c && a!=b) cout<<"Yes"<<endl;
    else if(b==c && b!=a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int i,n,max,ans;
    scanf("%d",&n);
    int x[n];
    ans=0;
    for (i=0;i<n;i++) {
        scanf("%d",&x[i]);
    }
    max=x[0];
    for (i=0;i<n;i++) {
        if (x[i]>=max)
            max=x[i];
    }
    for (i=0;i<n;i++) {
        ans+=x[i];
    }
    printf("%d",ans-max/2);
}

Measured memory_bytes: 128
<?php
$D = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($N,$M,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$c = array_map('intval',explode(" ",trim(fgets(STDIN))));

$x = 1000;
while(1) {
  if ($D <= $x) {
    printf("%d\n",$x-$D);
    exit;
  }
  $x+=1000;
}


Measured memory_bytes: 16252
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x <<  " " << x << endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<vector<int>> vvi;
typedef std::vector<ll> vl;
typedef std::vector<vector<ll>> vvl;
typedef std::vector<string> vs;
typedef std::vector<bool> vb;
typedef std::pair<int, int> pii;
const ll inf = 1e18L + 5;

template <typename T>
void print(T v){ for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(2)<<*i<<" ";cout<<endl; }
template <typename T>
void print_vv(T v, bool same_line=true){
for(auto i= 0; i<v.size(); i++){cout<<"{";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(3)<<v[i][j]<<",";}cout<<"},";if(same_line) cout<<endl;}cout<<endl;}

int main(){
    int n;
    while(cin>>n){
        vl a(n);
        for(int i=0; i<n; i++)
            cin>>a[i];
        
        vl acc(n+1);
        for(int i=1; i<=n; i++)
            acc[i] = acc[i-1]+a[i-1];

        vvl dp(n, vl(n, inf));

        for(int l = n-1; l>=0; l--){
            for(int r=l; r<n; r++){
                if(l==r){
                    dp[l][r] = 0;
                }else{
                    ll s = acc[r+1] - acc[l];
                    for(int i=l; i<=r-1; i++){
                        dp[l][r] = min(dp[l][r], dp[l][i] + dp[i+1][r] + s);
                    }
                }
            }
        }

        printf("%lld\n", dp[0][n-1]);
    }
    return 0;
}

Measured memory_bytes: 1536
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())

# ----------------------------------------------------------- #

n = I()
B = LI()

ANS = []
for _ in range(n):
    for i in reversed(range(len(B))):
        if i+1 == B[i]:
            ANS.append(B.pop(i))
            break
    else:
        print(-1)
        exit()

ANS.reverse()
for ans in ANS:
    print(ans)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

int N;

signed main(){
	cin>>N;
	vint A;
	rep(i,N){
		int a;cin>>a;
		A.pb(a);
		A.pb(a);
	}
	sort(all(A));
	reverse(all(A));

	cout<<accumulate(A.begin()+1,A.begin()+N,0ll)<<endl;
    return 0;
}



Measured memory_bytes: 7448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

const ll mod = 1e9 + 7;

int main() {

    int n, m;
    cin >> n >> m;
    vector<bool> broken(n+1);
    rep(i, m){
        int a;
        cin >> a;
        broken[a] = true;
    }

    vector<ll> dp(n+2);
    dp[n] =  1;
    for(int i=n-1; i>=0; --i){
        if(broken[i]){
            dp[i] = 0;
            continue;
        }
        dp[i] = dp[i+1] + dp[i+2];
        dp[i] %= mod;
    }

    cout << dp[0] << endl;


    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

vector<int> UF=vector<int>(1000000);
void init() {
    for(int i=0; i<1000000; i++)
        UF[i]=i;
}
int root(int a) {
    if(UF[a]==a)
        return a;
    return UF[a]=root(UF[a]);
}
void unite(int a, int b) {
  a=root(a);
  b=root(b);
  if(a==b)
    return;
  UF[a]=b;
}
bool same(int a, int b) {
    return root(a)==root(b);
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n,m,k;
  cin>>n>>m>>k;
  init();
  vector<ll> deg(n+1);
  rep(i,m) {
    int a,b;
    cin>>a>>b;
    unite(a,b);
    deg[a]++;
    deg[b]++;
  }
  vector<ll> block(n+1);
  rep(i,k) {
    int c,d;
    cin>>c>>d;
    if(same(c,d)) {
      block[c]++;
      block[d]++;
    }
  }
  unordered_map<int,ll> mp;
  repeat(i,1,n+1) {
    mp[root(i)]++;
  }
  repeat(i,1,n+1) {
    cout << mp[root(i)]-deg[i]-block[i]-1 << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 10020
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  string S,T;
  cin >> S >> T;
  int ans=0;
  for(int i=0;i<S.size();i++){
    if(S[i]!=T[i]) ans++;
  }

  cout << ans << endl;

  return 0;
}


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

const long long maxn = 2e3+10;
const long long mod = 1e9+7 ;
long long pp[maxn][maxn] ;
long long a[maxn],b[maxn] ;

int main(){

    long long n, m;
    cin >> n >> m ;
    for(long long i = 0; i < n; i++)
        cin>>a[i] ;
    for(long long i = 0; i < m; i++)
        cin>>b[i] ;

    for(long long i = 0; i < maxn; i++){
        pp[i][0] = 1;
        pp[0][i] = 1;
    }
    for(long long i = 0; i < n; i++){
        for(long long j = 0; j < m; j++){

            if(i!=0 && j!=0){
                pp[i][j] = pp[i-1][j] + pp[i][j-1] - pp[i-1][j-1]+mod ;
                if(a[i]==b[j])
                    pp[i][j]+= pp[i-1][j-1];
            }
            if(i!=0 && j==0){
                pp[i][j] = pp[i-1][j] ;
                if(a[i]==b[j])
                    pp[i][j]++ ;
            }
            if(i==0 && j!=0){
                pp[i][j] = pp[i][j-1] ;
                if(a[i]==b[j])
                    pp[i][j]++ ;
            }
            if(i==0 && j==0){
                if(a[i]==b[j])
                    pp[i][j]++ ;
            }
            pp[i][j] %= mod ;

        }

    }
    cout << pp[n-1][m-1] ;

}


Measured memory_bytes: 31744
import java.util.Scanner;

//AtCoder Beginner Contest 154
//A	Remaining Balls
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		String U = sc.next();
		sc.close();

		if (S.equals(U)) {
	 		System.out.println(--A + " " + B);
		} else {
	 		System.out.println(A + " " + --B);
		}
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int A, B;
    cin >> A >> B;
    if (A >= B + 1)
    {
        cout << A + (A - 1) << endl;
    }
    else if (B >= A + 1)
    {
        cout << B + (B - 1) << endl;
    }
    else
    {
        cout << A + B << endl;
    }
}

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

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

  int ans = 1;
  int t = k;
  while (n / t > 0) {
    t *= k;
    ans ++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;public class Main {public static void main(String[] args) {Scanner yomi = new Scanner(System.in);int suuzi;suuzi = yomi.nextInt();for (int i=9;i>=1;i--){for (int y=9;y>=1;y--){if (i*y==suuzi){System.out.println("Yes");System.exit(0);}}}System.out.println("No");}}

Measured memory_bytes: 21844
s=list(input())

flag=0
#cnt1=0
#cnt2=0
if ord(s[0])==65 and 65+32<=ord(s[1])<=90+32 and 65+32<=ord(s[-1])<=90+32:
  flag=1
  for i in range(2,len(s)-1):
    if ord(s[i])==67:
      flag+=1
  
print('AC' if flag==2 else 'WA')


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

int main(){
  string s;
  cin >> s;
  int y = stoi(s.substr(0, 4));
  if (y > 2019) {
    cout << "TBD" << endl;
  }else if (y == 2019) {
    int m = stoi(s.substr(5, 7));
    if (m > 4) {
      cout << "TBD" << endl;
    }else {
      cout << "Heisei" << endl;
    }
  }else {
    cout << "Heisei" << endl;
  }
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll q,h,s,d,n;
  cin >> q >> h >> s >> d >> n;

  h = min(2*q,h);
  s = min(2*h,s);
  ll ca = d*(n/2) + s*(n%2);
  ll cb = s*n;
  ll ans =min(ca, cb);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256