akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


struct b_t
{
	int op, cl;
	b_t() : op(0), cl(0) {}
	bool operator < (const b_t&rhs) const
	{
//		if(cl!=rhs.cl) return cl<rhs.cl;
		return (op-cl)>(rhs.op-rhs.cl);
	}
};


bool cmp_p(const b_t&a, const b_t&b)
{
	return a.cl<b.cl;
}


bool cmp_n(const b_t&a, const b_t&b)
{
	return a.op>b.op;
}


int main(void)
{
	int n;
	char s[1000000+2];
	while(scanf("%d\n", &n)==1)
	{
		vector<b_t> bp, bn;

		for(int i=0;i<n;i++)
		{
			b_t mb;
			scanf("%[()]\n", s);
			for(int j=0;s[j];j++)
			{
				if(s[j]=='(')
				{
					mb.op++;
				}
				else if(s[j]==')')
				{
					if(mb.op>0) mb.op--;
					else mb.cl++;
				}
			}
			if(mb.op>=mb.cl) bp.push_back(mb);
			else bn.push_back(mb);
		}
		sort(bp.begin(), bp.end(), cmp_p);
		sort(bn.begin(), bn.end(), cmp_n);

		bool ans=true;
		int op=0;
		for(auto&mb:bp)
		{
			op-=mb.cl;
			if(op<0) ans=false;
			op+=mb.op;
		}

		for(auto&mb:bn)
		{
			op-=mb.cl;
			if(op<0) ans=false;
			op+=mb.op;
		}
		if(op!=0) ans=false;
		printf("%s\n", ans?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 10804
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	char s[4];
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
		cout << "Bad";
	else
		cout << "Good";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] h = new int[n];
		
		boolean[] good = new boolean[n];
		for(int i = 0;i<n;i++) {
			h[i] = sc.nextInt();
			good[i]= true;
		}
		
		for(int i=0;i<m;i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			
			if(h[a]<=h[b]) {
				good[a]=false;
			}
			
			if(h[b]<=h[a]) {
				good[b]=false;
			}
		}
		

		
		int counter =0;
		for(int i =0;i<n;i++) {
			if(good[i])counter++;
		}

		System.out.println(counter);

	}

	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 58092
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
using ll = long long;
using ld = long double;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s; cin >> s;
  deque<char> ans(s.begin(), s.end());
  bool rev = 0;
  int q; cin >> q;
  while (q--) {
    int t; cin >> t;
    if (t == 1) {
      rev ^= 1;
    } else {
      int f; char c; cin >> f >> c;
      f--;
      if (f ^ rev) {
        ans.push_back(c);
      } else {
        ans.push_front(c);
      }
    }
  }
  if (rev) reverse(ans.begin(), ans.end());
  for (char c : ans) cout << c;
  cout << nl;
}


Measured memory_bytes: 976
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
map<char, int> m;
signed main() {
    int n;
    cin >> n;
    string node;
    cout << n-1 << endl;
    cin >> node;
    if(node=="Vacant") {
        return 0;
    }
    cout << 0 << endl;
    cin >> node;
    if(node=="Vacant") {
        return 0;
    }

    int left = 0;
    int right = n-1;
    int mid = (left+right)/2;
    while(left<=right) {
        cout << mid << endl;
        string now;
        cin >> now;
        if(now=="Vacant") {
            return 0;
        }
        if((mid%2==0 && now==node) || (mid%2==1 && now!=node)) {
            left = mid+1;
            mid = (left+right)/2;
        }else {
            right = mid-1;
            mid = (left+right)/2;
        }
    } 
  return 0;
}



Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	int h1 = h - b;
	int w1 = w - a;
	for (int i = 1; i <= h1; i++) {
		for (int j = 1; j <= w1; j++) {
			cout << 1;
		}
		for (int j = w1 + 1; j <= w; j++) {
			cout << 0;
		}
		cout << endl;
	}
	for (int i = h1 + 1; i <= h; i++) {
		for (int j = 1; j <= w1; j++) {
			cout << 0;
		}
		for (int j = w1 + 1; j <= w; j++) {
			cout << 1;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         long H=gl();


         System.out.println(f(H));
     }

     public static long f(long n) {
    	 if(n==1)return 1;
    	 return 1+(2*f(n>>1));
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 35584
from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)

Q = deque()
Q.append(0)
C = [-1] * N
C[0] = 0

B = True
while len(Q) > 0:
    q = Q.popleft()
    pc = C[q]
    for g in G[q]:
        if C[g] == -1:
            C[g] = 1 - pc
            Q.append(g)
            continue
        if C[g] == pc:
            B = False

if not B:
    print((N * (N - 1) // 2) - M)
else:
    W = C.count(0)
    B = C.count(1)
    print(W * B - M)

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;
    deque<char> dq;
    bool rev = false;

    cin >> s;
    for(char c: s) dq.emplace_back(c);
    int q;
    cin >> q;
    while(q--){
        int t;
        cin >> t;
        if(t == 1) rev ^= 1;
        else{
            int f;
            char c;
            cin >> f >> c;
            --f;
            if(f ^ rev == 1) dq.emplace_back(c);
            else dq.emplace_front(c);
        }
    }
    while(!dq.empty()){
        if(rev){
            cout << dq.back();
            dq.pop_back();
        }else{
            cout << dq.front();
            dq.pop_front();
        }
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 976
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    print(n - sum(a) if sum(a) <= n else -1)


if __name__ == '__main__':
    solve()


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


int main()
{
  int n;
  cin >> n;
  vector<ll> a(n + 1, 0);
  rep(i, n)
  {
    int v;
    cin >> v;
    a[i+1] = a[i] + v;
  }
  vector<vector<ll>> dp(n, vector<ll>(n, LONG_LONG_MAX));
  rep(i, n)
    dp[i][i] = 0;
  for (int l=1; l<n; l++)
    rep(i, n - l)
      for (int j=i; j<i+l; j++)
        dp[i][i+l] = min(dp[i][i+l], dp[i][j] + dp[j+1][i+l] + a[i+l+1] - a[i]);
  cout << dp[0][n-1] << endl;
  return 0;
}

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

#define MAX 100


int MinOf(int,int);

int main(){
  int i,j,n,x,y;
  int p[MAX+1],m[MAX+1][MAX+1];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }

  for(i=0;i<=n;i++){
    m[i][i]=0;
  }

  for(y=2;y<=n;y++){
    
    for(i=1;i<=n-y+1;i++){
      j=i+y-1;
      m[i][j]=1<<21;

      for(x=i;x<=j-1;x++){
	m[i][j]=MinOf(m[i][j],m[i][x]+m[x+1][j]+p[i-1]*p[x]*p[j]);
      }
    
    }

  }

  printf("%d\n",m[1][n]);
  return 0;
}

int MinOf(int a,int b){
  if(a<b){
    return (a);
  }
  else{
    return (b);
  }
}



Measured memory_bytes: 2112
//長方形の面積と周の長さ
#include <stdio.h>

int main(void)
{
    //変数定義
    int iVertical;      //縦
    int iHorizontal;    //横
    int iArea;          //面積
    int iPerimeter;     //外周

    //変数初期化
    iVertical = 0;
    iHorizontal = 0;
    iArea = 0;
    iPerimeter = 0;

    scanf ("%d %d",&iVertical,&iHorizontal);
    iPerimeter = (iVertical + iHorizontal) * 2;
    iArea = iVertical*iHorizontal;

    printf("%d %d\n",iArea,iPerimeter);

    return 0;
}


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

using namespace std;
using ll = long long;


bool cmp(pair<int, int> &a, pair<int, int> &b) {
    if (a.first != b.first)
        return a.first > b.first;
    return a.second < b.second;
}

int main()
{
    multiset<int> st;
    int n;
    cin >> n;
    vector<pair<int, int>> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    st.insert(0);
    st.insert(0);
    st.insert(n + 1);
    st.insert(n + 1);
    ll ans = 0;
    sort(a.begin(), a.end(), cmp);
    for (int i = 0; i < n; i++) {
        ll idx = a[i].second;
        ll num = a[i].first;
        auto it = st.lower_bound(idx);
        ll x = *it;
        it++;
        ll y = *it;
        it--;
        it--;
        ll c = *it;
        it--;
        ll d = *it;
        ans += num * ((c - d) * (x - idx) + (idx - c) * (y - x));
        st.insert(idx);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5760
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
const int MAX=100000;
const int geta=100;
struct BIT
{
	int bit[MAX+1];
	void add(int i,int x)
	{
		while(i<=MAX)
		{
			bit[i]+=x;
			i+=i&-i;
		}
	}
	int sum(int i)
	{
		int res=0;
		while(i>0)
		{
			res+=bit[i];
			i-=i&-i;
		}
		return res;
	}
};
BIT bit;
int N,a[105];
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%d",&a[i]);
		a[i]+=geta;
	}
	int ans=0;
	for(int i=0;i<N;i++)
	{
		ans+=bit.sum(a[i]);
		bit.add(a[i],1);
	}
	sort(a,a+N);
	for(int i=0;i<N;i++)printf("%d%c",a[i]-geta,(i==N-1)?'\n':' ');
	printf("%d\n",N*(N-1)/2-ans);
	return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

struct Stat{
    vi cnt;
    Stat(int val): cnt(10, val){}
    Stat(const Stat &st): cnt(all(st.cnt)){}
    bool operator <(Stat &st){
        int lcnt = accumulate(all(cnt), 0);
        int rcnt = accumulate(all(st.cnt), 0);
        if(lcnt != rcnt) return lcnt < rcnt;
        rrep(i,10){
            if(cnt[i] != st.cnt[i]){
                return cnt[i] < st.cnt[i];
            }
        }
        return false;
    }
};

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    vi matches = {0,2,5,5,4,5,6,3,7,6};
    int n,m; cin >> n >> m;
    vi num(8, -1);
    rep(i,m){
        int a; cin >> a;
        int match = matches[a];
        num[match] = max(num[match], a);
    }

    vector<pii> items;
    rep(match,8){
        if(num[match] != -1) items.emplace_back(match, num[match]);
    }

    int l = items.size();
    vector<vector<Stat>> dp(l+1, vector<Stat>(n+1, Stat(-1)));
    dp[0][0] = Stat(0);
    rep(i,l){
        int match = items[i].fi;
        int num = items[i].se;
        rep(j,n+1){
            dp[i+1][j] = dp[i][j];
            if(j-match >= 0){
                Stat tmp(dp[i+1][j-match]);
                tmp.cnt[num]++;
                if(dp[i+1][j] < tmp) dp[i+1][j] = tmp;
            }
        }
    }

    string ans;
    RREP(i,1,10){
        int d = dp[l][n].cnt[i];
        rep(j,d){
            ans += '0' + i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8552
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,c;
  int ans=0;
  cin>>a>>b>>c;
  if(a==b && b==c && a%2==0){cout<<-1<<endl;return 0;}
  else{
    while(a%2==0 && b%2==0 && c%2==0){
      ans++;
      int A=a/2,B=b/2,C=c/2;
      a=B+C;b=A+C;c=A+B;
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
int cnt[111];
char a[111][111];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>a[i][j];
			cnt[a[i][j]-'a']++;
		}
	}
	if(n%2==0&&m%2==0)
	{
		for(int i=0;i<26;i++)
		{
			if(cnt[i]%4!=0)
			{
				cout<<"No\n";
				return 0;
			}
		}
		cout<<"Yes\n";
	}
	else if((n&1)&&(m&1))
	{
		int odd=0; int even=0;
		for(int i=0;i<26;i++)
		{
			cnt[i]%=4;
			if(cnt[i]&1)
			{
				odd++;
			}
			else if(cnt[i]==2)
			{
				even++;
			}
		}
		if(odd==1&&even<=n/2 + m/2)
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
	else
	{
		int odd=0; int even=0;
		for(int i=0;i<26;i++)
		{
			cnt[i]%=4;
			if(cnt[i]&1)
			{
				odd++;
			}
			else if(cnt[i]==2)
			{
				even++;
			}
		}
		int tmp = m/2;
		if(n%2==0) tmp=n/2;
		if(odd==0&&even<=tmp)
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>
 
#define MAX 100
#define INF 1000000
#define white 0
#define gray 1
#define black 2
 
int n,u,M[MAX][MAX];
 
void dijkstra(void);
 
int main(){
  int i,j,k,v,c;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      M[i][j] = INF;
 
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      M[u][v] = c;
    }
  }
 
  dijkstra();
 
  return 0;
}
 
void dijkstra(){
  int i,min,d[MAX],color[MAX] = {white};
 
  for(i=0;i<n;i++)
    d[i] = INF;
 
  d[0] = 0;
  color[0] = gray;
 
  while(1){
    min = INF;
    u = -1;
    for(i=0;i<n;i++)
      if(min > d[i] && color[i] != black){
	u = i;
	min = d[i];
      }
    
    if(u == -1)break;
    color[u] = black;
    
    for(i=0;i<n;i++)
      if(color[i] != black && M[u][i] != INF){
	if(d[i] > d[u] + M[u][i]){
	  d[i] = d[u] + M[u][i];
	  color[i] = gray;
	}
      }
  }
  for(i=0;i<n;i++){
    if(d[i] == INF)printf("%d -1\n",i);
    else printf("%d %d\n",i,d[i]);
  }
 
}

Measured memory_bytes: 636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.length() <= k)
    cout << s << endl;
  else
    cout << s.substr(0, k) << "...\n";
}


Measured memory_bytes: 3132
#include <cstdio>
#include <iostream>
#include <algorithm>
#define INT long long
using namespace std;
INT f(INT x, INT n)
{
    if( x == 0 ) return -n;
    return (n/x) * 2*x + f(n%x, x);

}

int main()
{
    INT n, x;
    cin>>n>>x;
    cout<<f(x, n-x) + n;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1e9;

typedef long long ll;

#define MAX_V 10000

struct edge {
    int to;
    int cost;
};


int V;
vector<edge> G[MAX_V];
int d[MAX_V];


void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}



int main(){
  int h,w;
  V = 10;
  
  cin >> h >> w;
  REP(i,10){
    REP(j,10){
      int c;
      cin >> c;
      edge e = {j,c};
      G[i].pb(e);
    }
  }
  
  ll dis[10][10];
  REP(i,10){
    dijkstra(i);
    REP(j,10){
      dis[i][j] = d[j];
    }
  }
  ll sum = 0;
  REP(i,10){
    //cout << "i = " << d[i] << endl;
  }
  REP(i,h){
    REP(j,w){
      int a;
      cin >> a;
      if(a != -1 && a != 1){
	sum += dis[a][1];
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 512
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    S = list(_ for _ in input())
    S = S[::-1]    
    S_num = 0
    temp_ans_0 = '0b'
    temp_ans_1 = '0b'
    num_temp_ans_0 = 0
    num_temp_ans_1 = 0
    for i in range(len(S)):
        if(i%2 ==0):
            temp_ans_0 += '0'
            temp_ans_1 += '1'
        else:
            temp_ans_0 += '1'
            temp_ans_1 += '0'
    # i = 0
    # for s in S:
    #     S_num += int(s) * 2**i
    #     if(i%2 ==0):
    #         num_temp_ans_0 += 0 * 2**i
    #         num_temp_ans_1 += 1 * 2**i
    #     else:
    #         num_temp_ans_0 += 1 * 2**i
    #         num_temp_ans_1 += 0 * 2**i
    #     i +=1
    S_str ='0b'+''.join(S)
    S_num = int(S_str,0)
    num_temp_ans_0 = int(temp_ans_0,0)
    num_temp_ans_1 = int(temp_ans_1,0) 
    c0 = bin(S_num ^ num_temp_ans_0).count('1')
    c1 = bin(S_num ^ num_temp_ans_1).count('1')
    
    print(min(c0,c1))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 5264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[26];
ll b[26];
int main() {
	string s;
	cin>>s;
	for(ll i=0;i<s.size();i++){
		ll now=s[i]-'a';
		ll p=i-a[now];
		a[now]=i+1;
		b[now]=max(b[now],p);
	}
	ll ans=inf;
	for(ll i=0;i<26;i++){
		ll now=s.size()-a[i];
		b[i]=max(b[i],now);
		ans=min(ans,b[i]);
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

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

    int n;
    cin >> n;

    bool judge = false;
    if (n % 4 == 0) judge = true;
    if (n % 7 == 0) judge = true;
    if (judge) {
        cout << "Yes" << endl;
        return 0;
    }

    while (n >= 0) {
        if (n == 0) {
            judge = true;
            break;
        }
        n -= 4;
        if (n % 7 == 0) {
            judge = true;
            break;
        }
    }
    if (judge) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


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

int main(){
    int N, a, sum;
    sum = 0;
    cin >> N;
    for (int i=0; i<N; ++i){
        cin >> a;
        while(a%2 == 0){
            sum++;
            a /= 2;
        }
    }
    cout << sum << endl;
    return 0;
}

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

if(N==1):
    if M==1:
       print(1)
    elif M==2:
        print(0)
    else:
        print(M-2)
elif(N==2):
    print(0)
else:
    if M==1:
       print(N-2)
    elif M==2:
        print(0)
    else:
        print((N-2)*(M-2))

Measured memory_bytes: 3064
/*#### bits/stdc++.h */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<deque>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
/*####*/

int n;
int a[111111],b[111111],c[111111];
int id1[111111], ord[111111];
double dir[111111];
bool cmp1(int x,int y){
	return dir[x] > dir[y];
}
bool cmp2(int x,int y){
	return dir[x] < dir[y];
}

int lowbit(int x){return x&-x;}
int bit[111111];
void add(int x){
	while(x<=n){
		bit[x]++;
		x+=lowbit(x);
	}
}
int query(int x){
	int res=0;
	while(x){
		res += bit[x];
		x-=lowbit(x);
	}
	return res;
}

double process(){
	for(int i=0; i<n; i++){
		id1[i] = i;
		dir[i] = ((double)(-a[i]))/b[i];
	}
	sort(id1, id1 + n, cmp1);
	for(int i=0; i<n; i++)
		ord[id1[i]] = i;
	long long int AA = (n * (n-1LL)/2 + 1)/2;

	double lo = -2e9, hi = 2e9;
	for(int run = 0; run < 80; run++){
		double mi = (lo + hi)/2;
		for(int i=0; i<n; i++){
			id1[i] = i;
			dir[i] = (c[i] - a[i] * mi)/b[i];
		}
		sort(id1, id1+n, cmp2);
		
		memset(bit,0,sizeof(bit));
		long long int BB = 0;
		for(int i=n-1; i>=0; i--){
			int x = ord[id1[i]] + 1;
			BB += query(x);
			add(x);
		}
		if(BB < AA)
			lo = mi;
		else
			hi = mi;
	}
	return lo;
}
int main(){
	scanf("%d",&n);
	for(int run = 0; run < 2; run++){
		for(int i=0; i<n; i++)
			if(run == 0)
				scanf("%d%d%d",&a[i],&b[i],&c[i]);
			else
				swap(a[i], b[i]);
		printf("%.12lf%c",process(), run==0?' ':'\n');
	}
	return 0;
}

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

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

    char a[n][m];
    int b[n][m];
    for(int i = 0; i<n; i++){
        for(int j = 0; j<m; j++){
            cin >> a[i][j];
        }
    }
    b[0][0] = 0;
    if(a[0][0] == '#') b[0][0] = 1;

    for(int k = 1; k<n + m - 1; k++){
        for(int j = 0; j<m; j++){
            int i = k - j;

            if(i < 0 || i >= n) continue;
            b[i][j] = 1e9 + 7;

            if(i > 0){
                if(a[i][j] == '#' && a[i - 1][j] == '.') b[i][j] = min(b[i][j], b[i - 1][j] + 1);
                else b[i][j] = min(b[i][j], b[i - 1][j]);
            }

            if(j > 0){
                if(a[i][j] == '#' && a[i][j - 1] == '.') b[i][j] = min(b[i][j], b[i][j - 1] + 1);
                else b[i][j] = min(b[i][j], b[i][j - 1]);
            }
        }
    }

    cout << b[n -1 ][m - 1] << endl;

}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k;
    string s;
    cin>>k>>s;
    if(s.size()<=k) cout<<s;
    else cout<<s.substr(0,k)<<"...";
    return 0;
}



Measured memory_bytes: 3656
#include<stdio.h>

int main(void){
  int i,n,count=0;
  scanf("%d",&n);
  int p[n];
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }

  for(i=0;i<n-2;i++){
    if((p[i]<p[i+1])&&(p[i+1]<p[i+2])){
      count+=1;
    }
    else if((p[i]>p[i+1])&&(p[i+1]>p[i+2])){
      count+=1;
    }
  }

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

  return 0;
}

Measured memory_bytes: 128
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """29
20
7
35
120"""
        output = """215"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """101
86
119
108
57"""
        output = """481"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """123
123
123
123
123"""
        output = """643"""
        self.assertIO(input, output)

def resolve():
    a=[]
    count=0
    for i in range(5):
        x=int(input())
        if x%10==0:
            count+=x
        else:
            a.append(x)
    if len(a)==0:
        print(count)
    else:
        a.sort(key= lambda xx: xx%10 , reverse= True)

        for i in a[:-1]:
            count+=i-i%10+10
        else:
            count+=a[-1]
        print(count)
if __name__ == "__main__":
    resolve()

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))


int main()
{
    double a, b, x;
    scanf("%lf", &a);
    scanf("%lf", &b);
    scanf("%lf", &x);

    double S = x / a;
    double r;

    if(S >= a * b /2){
        double h = 2.0 * (a * b - S) / a;
        r = atan2(h, a);
    }else{
        double w = 2.0 * S / b;
        r = atan2(b, w);

    }
    double deg = r / M_PI * 180.0;

    printf("%.10lf\n", deg);

    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.math.*;
import java.io.*;


public class Main {
    static int popcount(int X){
        int p = 0;
        for(int i=0; i<30; i++) if((X & (1<<i)) != 0) p++;
        return p;
    }
    static int popCount(String X){
        int p=0;
        for(int i=0; i<X.length(); i++) if(X.charAt(i)=='1') p++;
        return p;
    }
    static int powmod(int a, int n, int m){
        if(n==0) return 1;
        if(n==1) return a%m;
        if(n%2==0) {
            long half = powmod(a, n/2, m);
            return (int)(half * half % m);
        }
        return (int)((a * powmod(a, n-1, m))%m);
    }

    static int calc(int X, Map<Integer,Integer> result){
        //if(X==0) return 0;
        if(result.containsKey(X)) return result.get(X);
        else{
            int next = X % popcount(X);
            int less = calc(next, result);
            result.put(X, 1+less);
            return 1+less;
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        String X = sc.next();

        int p = popCount(X);

        int mm = p-1<=0 ? 0 : new BigInteger(X,2).mod(new BigInteger(Integer.toString(p-1))).intValue();
        int mp = new BigInteger(X,2).mod(new BigInteger(Integer.toString(p+1))).intValue();
        Map<Integer, Integer> result = new HashMap<>();
        result.put(0, 0);

        for(int n=0; n<N; n++){
            if(X.charAt(n)=='1'){
                int pi = p-1;
                if(pi==0){
                    System.out.println(0);
                    continue;
                }
                int first = (mm + pi - powmod(2, N-1-n, pi)) % pi;
                //System.out.printf("first: %d - 2^%d = %d\n", mm, N-1-n, first);
                System.out.println(1 + calc(first, result));
            }else{
                int pi = p+1;
                int first = (mp + pi + powmod(2, N-1-n, pi)) % pi;
                //System.out.printf("first: %d + 2^%d = %d\n", mp, N-1-n, first);
                System.out.println(1 + calc(first, result));
            }
        }
        
    }
}


Measured memory_bytes: 61628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

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

    void run() {
        Scanner sc = new Scanner(System.in);
        int h =sc.nextInt();
        int w = sc.nextInt();
        char[][] array = new char[2*h][w];

        for(int i=0; i<h; i++){
            char[] input = sc.next().toCharArray();

            for(int j=0; j<w; j++){
                array[2*i][j] = input[j];
                array[2*i+1][j] = input[j];
            }
        }

        for(int i=0; i<2*h; i++){
            for(int j=0; j<w; j++){
                if(j == w-1){
                    System.out.println(array[i][j]);
                } else {
                    System.out.print(array[i][j]);
                }
            }
        }
    }

    double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
}

class Ten{
    private int x;
    private int y;

    Ten(int x, int y){
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}


Measured memory_bytes: 27536
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    lis=[[0]*9 for _ in range(9)]
    for i in range(1,n+1):
        si=str(i)
        if int(si[-1])>0:
            lis[int(si[0])-1][int(si[-1])-1]+=1
    cunt=0
    for i in range(9):
        for j in range(9):
            cunt+=lis[i][j]*lis[j][i]
    print(cunt)
    
    

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std; 
#define endl '\n' 
typedef long long int lli ; 
using namespace std; 

int main(int argc, char const *argv[])
{	
	vector<int> a(3); 
	for(int i = 0; i<3; ++i){
		int a_; 
		cin >> a_; 
		a.push_back(a_); 
	}
	sort(a.rbegin(), a.rend()); 
	int ans = min(2*a[0] - a[1] - a[2] , a[0] - a[2]) ; 
	cout <<ans; 
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE StrictData #-}
main = do
    k <- readLn
    print $ 6*(sum [euclid a $ euclid b c | a <- [3..k], b <- [2..a-1], c <- [1..b-1]]) + 6*(sum [euclid a b | a <- [2..k], b <- [1..a-1]]) + (k*(k+1))`div`2

euclid :: Int -> Int -> Int
euclid a b = if b == 0 then a else euclid b (a`mod`b)

Measured memory_bytes: 4908
import java.io.*;
import java.util.*;

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        int n = in.nextInt();
        int a = n/15;
        out.print(n*800 - a*200);
    }

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

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

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

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

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

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


Measured memory_bytes: 21076
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    if(v <= w){
        printf("NO\n");
        return 0;
    }

    if(abs(b-a)<= t*(v-w)){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    
    return 0;
}

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

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

    int a,b,c,d; cin >> a >> b >> c >> d;
    bool wins;
    while(a>0 && c>0){
        c -= b;
        if (c<=0){
            wins = true;
            break;
        }
        a -= d;
        if(a <= 0){
            wins = false;
            break;
        }
    }
    if(wins){
        cout << "Yes";
    }
    else{
        cout << "No";
    }


    return 0;
}


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

using namespace std;
typedef long long ll;
int mod(int a,int b,int d);

int main() {
  int n,k;
  int div = 1000000007;
  cin >> n >> k;
  vector<int> a(n),ap,am;
  for(int i=0;i<n;++i){
    cin >> a[i];
    if(a[i]>0) ap.push_back(a[i]);
    else am.push_back(a[i]);
  }
  int pn,mn;
  pn = ap.size();
  mn = am.size();
  //cout<<"size "<<pn<<" "<<mn<<endl;
  sort(ap.begin(),ap.end());
  sort(am.begin(),am.end(),greater<int>());
  int ans=1;
  if(n==k){
    for(int i=0;i<k;++i){
      ans = mod(ans,a[i],div);
    }
  }else if( pn==0 && k%2==1){
    for(int i=0;i<k;++i){
      ans = mod(ans,am[i],div);
    }
  }else{
    if(k%2==1){
      ans = ap.back(); ap.pop_back();
      pn--;
      k--;
    }
    //cout<<"a"<<endl;
    vector<ll> al;
    for(int i=0;i<pn/2;++i){
      al.push_back(ap.back());  ap.pop_back();
      al[i] = al[i]*ap.back();  ap.pop_back();
      //cout<<i<<" "<<al[i]<<endl;
    }
    for(int i=pn/2;i<pn/2+mn/2;++i){
      al.push_back(am.back());  am.pop_back();
      al[i] = al[i]*am.back();  am.pop_back();
      //cout<<i<<" "<<al[i]<<endl;
    }
    sort(al.begin(),al.end(),greater<ll>());
    for(int i=0;i<k/2;++i){
      int ai;
      ai = al[i]%div;
      //cout<<"ai= "<<ai<<" "<<al[i]<<endl;
      ans = mod(ans,ai,div);
    }
  }
  cout<<ans<<endl;
    
}

int mod(int a,int b,int d){
  int seki;
  ll al=a;
  ll bl=b;
  while(al<0) al+=d;
  while(bl<0) bl+=d;
  seki = al*bl%d;
  //cout<<"mod "<<a<<" "<<b<<" "<<seki<<endl;
  return seki;
}
  

Measured memory_bytes: 6352
MOD=998244353
N,M,K=map(int,input().split())

inv_table = [0]+[1]
for i in range(2,K+2):
  inv_table.append(-(MOD//i)*inv_table[MOD%i]%MOD)

def powmod(a,p):
  if p==0:
    return 1
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD
def invmod(a):
  return powmod(a,MOD-2)

if M==1 and K<N-1:
  print(0)
elif K==N-1:
  print(powmod(M,N))
else:
  ans=0
  term1=powmod(M-1,N-1)
  term2=1
  inv_M1=invmod(M-1)
  for i in range(K+1):
    ans+=term1*term2
    ans%=MOD
    term1=term1*inv_M1%MOD
    term2=term2*(N-i-1)*inv_table[i+1]%MOD
    
  answer=M*ans%MOD
  print(answer)

Measured memory_bytes: 16852
n=int(input())
a=list(map(int,input().split()))
set(a)
ans=[0]*1000005
x=1
for i in a:
    if(ans[i]!=0):
        ans[i]=2
        continue
    for j in range(i,1000005,i):
        ans[j]=ans[j]+1
cnt=0
for i in range(0,n):
    if(ans[a[i]]==1):
        cnt=cnt+1
print(cnt)


Measured memory_bytes: 32304
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(true){
int H=Integer.parseInt(sc.next());
int W=Integer.parseInt(sc.next());
if(H==0&&W==0){break;}

for(int j=0;j<H;j++){
    for(int i=0;i<W;i++){
    if(i%2==j%2)System.out.print("#");
    if(i%2!=j%2)System.out.print(".");
    }System.out.println();
}System.out.println();


}
}
}


Measured memory_bytes: 33272
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define ll long long
#define re return
#define mp map<int,int>
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	rep(i,1,5000){
		double x=1.0*i*0.08,y=1.0*i*0.1;
		if(int(x)==a&&int(y)==b){
			cout<<i;
			re 0;
		}
	}
	cout<<"-1";
	re 0;
}


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

int main(){
    
    int A,B,M;
    cin >> A >> B >> M;
    
    int a[A];
    int mina = INT_MAX;
    for(int i = 0; i < A;i++){
        cin >> a[i];
        mina = min(a[i],mina);
    }

    int b[B];
    int minb = INT_MAX;
    for(int i = 0; i < B;i++){
        cin >> b[i];
        minb = min(b[i],mina);
    }

    int ans = mina + minb;
    int x,y,c;
    for(int i = 0; i < M;i++){
        cin >> x >> y >> c;
        x--,y--;
        ans = min(ans, a[x]+b[y]-c);
        
    }
    
    cout << ans <<endl;
}
    
    



Measured memory_bytes: 1024
A = int(input())
B = int(input())
C = int(input())
X = int(input())

A_list = list()
for i in range(A+1) :
    A_list.append(i*500)
B_list = list()
for i in range(B+1) :
    B_list.append(i*100)
C_list = list()
for i in range(C+1) :
    C_list.append(i*50)

count = 0
for a in A_list :
    for b in B_list :
        for c in C_list :
            if (a + b + c) == X :
                count += 1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
//typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) <<double値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    double l;
    cin >> l;
    double a = l/3.0;
    cout << std::fixed << std::setprecision(14) << pow(a,3) << endl;

}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll= long long;
using ld= long double;
using P =pair<ll,ll>;


//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<=(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define sort(a) sort(ALL(a))//sortの省略
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define in(T, x) T x;cin >> x;//Tは型,xが入力値
#define vec(T,a,n,x) vector<T> a(n,x);
#define vec2(T,a,n,m) vector<vector<T>> a(n,vector<T>(m));
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define out(x) cout << x << endl//出力
#define bout(b) if(b){out("Yes");}else{out("No");}//真偽問題に対する出力
#define ain(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}//配列の宣言と入力
#define a2in(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}//2つの配列を同時宣言、入力

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }//dp表とかで最大値更新するやつ
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }//最小値更新


signed main(){
  int cnt=0;
  in(ll,a);in(ll,b);in(ll,c);in(ll,x);
  x/=50;
  REP(i,a){
    REP(j,b){
      REP(k,c){
        if(10*i+2*j+k==x)cnt++;
      }
    }
  }
  out(cnt);
  
   

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	vector<int>a,b,c;
	int aa, bb, cc;
	for (int i = 0;i < n;i++){
		cin >> aa;
		a.push_back(aa);
	}
	sort(a.begin(), a.end());
	for (int i = 0;i < n;i++) {
		cin >> bb;
		b.push_back(bb);
	}
	sort(b.begin(), b.end());
	for (int i = 0;i < n;i++) {
		cin >> cc;
		c.push_back(cc);
	}
	sort(c.begin(), c.end());
	for (int i = 0;i < n;i++) {
		ll aaa = (lower_bound(a.begin(), a.end(), b[i]) - a.begin());
		ll ccc = (c.end() - upper_bound(c.begin(), c.end(), b[i]));
		ans += aaa * ccc;
	}
	cout << ans << endl;
}



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

string fb[10001];

int main() {

    for(int i=1;i<10001;i++){
        if(i%15==0){
            fb[i] = "FizzBuzz";
        }
        else if(i%3==0){
            fb[i] = "Fizz";
        }
        else if(i%5==0){
            fb[i] = "Buzz";
        }
        else{
            stringstream ss;
            ss << i;
            ss >> fb[i];
        }
    }

    while(1){

        int m,n;

        scanf(" %d %d",&m,&n);

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

        list<int> l;

        for(int i=1; i<= m; i++){
            l.push_back(i);
        }

        list<int>::iterator itr = l.begin();

        for(int i=1; i<=n; i++){

            string s;

            cin >> s;

            if(l.size() == 1){
                continue;
            }

            if(s != fb[i]){
                list<int>::iterator itmp = itr;
                itr++;
                l.erase(itmp);
            }else{
                itr++;
            }

            if(itr == l.end()){
                itr = l.begin();
            }

        }

        if(l.size() != 0) {

            itr = l.begin();

            cout << *itr;

            itr++;

            for (; itr != l.end(); itr++) {
                cout << ' ' << *itr;
            }

            cout << endl;

        }

    }

    return 0;
}

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

typedef long long  ll;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,in,i;
  set<ll>s;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>in;
   s.insert(in);
  }
  if(s.size()==n)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 9600